core-https 1.0.3__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +1,35 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: core-https
3
- Version: 1.0.3
3
+ Version: 1.1.0
4
4
  Summary: This project/library contains common elements related to HTTP & API services...
5
5
  Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
6
  Maintainer: Alejandro Cora González
7
7
  License: MIT
8
8
  Project-URL: Homepage, https://gitlab.com/bytecode-solutions/core/core-https
9
+ Project-URL: Repository, https://gitlab.com/bytecode-solutions/core/core-https
10
+ Project-URL: Issues, https://gitlab.com/bytecode-solutions/core/core-https/-/issues
11
+ Project-URL: Changelog, https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md
9
12
  Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Development Status :: 5 - Production/Stable
10
15
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Utilities
11
17
  Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.7
19
+ Classifier: Programming Language :: Python :: 3.8
12
20
  Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
13
22
  Classifier: Programming Language :: Python :: 3.11
14
23
  Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Intended Audience :: Developers
16
- Classifier: Topic :: Utilities
17
- Requires-Python: >=3.9
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Requires-Python: >=3.7
18
26
  Description-Content-Type: text/markdown
19
27
  License-File: LICENSE
20
- Requires-Dist: core-tests==1.0.3
21
- Requires-Dist: urllib3==2.2.3
22
- Provides-Extra: test
28
+ Requires-Dist: core-tests>=1.1.0
29
+ Requires-Dist: urllib3>=2.2.3; python_version >= "3.8"
30
+ Requires-Dist: urllib3>=1.26.20; python_version >= "3.7" and python_version < "3.8"
31
+ Requires-Dist: typing-extensions>=4.8.0; python_version >= "3.8" and python_version < "3.11"
32
+ Requires-Dist: typing-extensions>=4.2.0; python_version >= "3.7" and python_version < "3.8"
23
33
 
24
34
  # core-https
25
35
  _______________________________________________________________________________
@@ -1,6 +1,10 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- from enum import StrEnum
3
+ try:
4
+ from enum import StrEnum
5
+
6
+ except ImportError:
7
+ from core_https.utils import StrEnum
4
8
 
5
9
 
6
10
  class StatusInfo(StrEnum):
@@ -1,9 +1,14 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  from functools import wraps
4
- from http import HTTPStatus
5
4
  from typing import Any, Callable, Tuple
6
5
 
6
+ try:
7
+ from http import HTTPStatus
8
+
9
+ except ImportError:
10
+ from core_https.utils import HTTPStatus
11
+
7
12
  from core_https import StatusInfo
8
13
  from core_https.exceptions import AuthorizationException
9
14
  from core_https.exceptions import InternalServerError
@@ -1,10 +1,14 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  from abc import abstractmethod
4
- from http import HTTPMethod
5
4
 
6
- from urllib3 import Retry
7
- from urllib3.response import HTTPResponse
5
+ try:
6
+ from http import HTTPMethod
7
+
8
+ except ImportError:
9
+ from core_https.utils import HTTPMethod
10
+
11
+ from urllib3 import Retry, BaseHTTPResponse
8
12
 
9
13
 
10
14
  class Requester:
@@ -13,7 +17,8 @@ class Requester:
13
17
  @classmethod
14
18
  @abstractmethod
15
19
  def make_request(
16
- cls, method: HTTPMethod, url: str, headers=None, fields=None, timeout: float = 10,
17
- retries: Retry = False, **kwargs) -> HTTPResponse:
20
+ cls, method: HTTPMethod, url: str, headers=None, fields=None,
21
+ timeout: float = 10, retries: Retry = False,
22
+ **kwargs) -> BaseHTTPResponse:
18
23
 
19
24
  """ Makes the request and returns the response """
@@ -1,10 +1,16 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  import logging
4
- from http import HTTPMethod
5
4
 
6
- from urllib3 import PoolManager, Retry
7
- from urllib3.response import HTTPResponse
5
+ try:
6
+ from http import HTTPMethod
7
+
8
+ except ImportError:
9
+ from core_https.utils import HTTPMethod
10
+
11
+ from urllib3 import BaseHTTPResponse
12
+ from urllib3 import PoolManager
13
+ from urllib3 import Retry
8
14
 
9
15
  from .base import Requester
10
16
 
@@ -18,10 +24,11 @@ class Urllib3Requester(Requester):
18
24
 
19
25
  @classmethod
20
26
  def make_request(
21
- cls, method: HTTPMethod, url: str, headers=None, fields=None, timeout: float = 10,
22
- retries: Retry = False, **kwargs) -> HTTPResponse:
27
+ cls, method: HTTPMethod, url: str, headers=None, fields=None,
28
+ timeout: float = 10, retries: Retry = False,
29
+ **kwargs) -> BaseHTTPResponse:
23
30
 
24
31
  return cls._http.request(
25
- method=method, url=url, headers=headers,
32
+ method=str(method), url=url, headers=headers,
26
33
  fields=fields, timeout=timeout,
27
34
  retries=retries, **kwargs)
@@ -0,0 +1,162 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from enum import Enum
4
+
5
+ try:
6
+ from typing import Self
7
+
8
+ except ImportError:
9
+ # For earlier versions...
10
+ from typing_extensions import Self
11
+
12
+
13
+ class HTTPStatus(Enum):
14
+ """
15
+ For backward compatibility because HTTPStatus class
16
+ was added in Python 3.11...
17
+ """
18
+
19
+ CONTINUE = 100, "Continue"
20
+ SWITCHING_PROTOCOLS = 101, "Switching Protocols"
21
+ PROCESSING = 102, "Processing"
22
+ EARLY_HINTS = 103, "Early Hints"
23
+
24
+ OK = 200, "OK"
25
+ CREATED = 201, "Created"
26
+ ACCEPTED = 202, "Accepted"
27
+ NON_AUTHORITATIVE_INFORMATION = 203, "Non-Authoritative Information"
28
+ NO_CONTENT = 204, "No Content"
29
+ RESET_CONTENT = 205, "Reset Content"
30
+ PARTIAL_CONTENT = 206, "Partial Content"
31
+ MULTI_STATUS = 207, "Multi-Status"
32
+ ALREADY_REPORTED = 208, "Already Reported"
33
+ IM_USED = 226, "IM Used"
34
+
35
+ MULTIPLE_CHOICES = 300, "Multiple Choices"
36
+ MOVED_PERMANENTLY = 301, "Moved Permanently"
37
+ FOUND = 302, "Found"
38
+ SEE_OTHER = 303, "See Other"
39
+ NOT_MODIFIED = 304, "Not Modified"
40
+ USE_PROXY = 305, "Use Proxy"
41
+ TEMPORARY_REDIRECT = 307, "Temporary Redirect"
42
+ PERMANENT_REDIRECT = 308, "Permanent Redirect"
43
+
44
+ BAD_REQUEST = 400, "Bad Request"
45
+ UNAUTHORIZED = 401, "Unauthorized"
46
+ PAYMENT_REQUIRED = 402, "Payment Required"
47
+ FORBIDDEN = 403, "Forbidden"
48
+ NOT_FOUND = 404, "Not Found"
49
+ METHOD_NOT_ALLOWED = 405, "Method Not Allowed"
50
+ NOT_ACCEPTABLE = 406, "Not Acceptable"
51
+ PROXY_AUTHENTICATION_REQUIRED = 407, "Proxy Authentication Required"
52
+ REQUEST_TIMEOUT = 408, "Request Timeout"
53
+ CONFLICT = 409, "Conflict"
54
+ GONE = 410, "Gone"
55
+ LENGTH_REQUIRED = 411, "Length Required"
56
+ PRECONDITION_FAILED = 412, "Precondition Failed"
57
+ PAYLOAD_TOO_LARGE = 413, "Payload Too Large"
58
+ URI_TOO_LONG = 414, "URI Too Long"
59
+ UNSUPPORTED_MEDIA_TYPE = 415, "Unsupported Media Type"
60
+ RANGE_NOT_SATISFIABLE = 416, "Range Not Satisfiable"
61
+ EXPECTATION_FAILED = 417, "Expectation Failed"
62
+ IM_A_TEAPOT = 418, "I'm a teapot"
63
+ MISDIRECTED_REQUEST = 421, "Misdirected Request"
64
+ UNPROCESSABLE_ENTITY = 422, "Unprocessable Entity"
65
+ LOCKED = 423, "Locked"
66
+ FAILED_DEPENDENCY = 424, "Failed Dependency"
67
+ TOO_EARLY = 425, "Too Early"
68
+ UPGRADE_REQUIRED = 426, "Upgrade Required"
69
+ PRECONDITION_REQUIRED = 428, "Precondition Required"
70
+ TOO_MANY_REQUESTS = 429, "Too Many Requests"
71
+ REQUEST_HEADER_FIELDS_TOO_LARGE = 431, "Request Header Fields Too Large"
72
+ UNAVAILABLE_FOR_LEGAL_REASONS = 451, "Unavailable For Legal Reasons"
73
+
74
+ INTERNAL_SERVER_ERROR = 500, "Internal Server Error"
75
+ NOT_IMPLEMENTED = 501, "Not Implemented"
76
+ BAD_GATEWAY = 502, "Bad Gateway"
77
+ SERVICE_UNAVAILABLE = 503, "Service Unavailable"
78
+ GATEWAY_TIMEOUT = 504, "Gateway Timeout"
79
+ HTTP_VERSION_NOT_SUPPORTED = 505, "HTTP Version Not Supported"
80
+ VARIANT_ALSO_NEGOTIATES = 506, "Variant Also Negotiates"
81
+ INSUFFICIENT_STORAGE = 507, "Insufficient Storage"
82
+ LOOP_DETECTED = 508, "Loop Detected"
83
+ NOT_EXTENDED = 510, "Not Extended"
84
+ NETWORK_AUTHENTICATION_REQUIRED = 511, "Network Authentication Required"
85
+
86
+ def __init__(self, code, description):
87
+ self._value_ = code
88
+ self._description = description
89
+
90
+ def __repr__(self):
91
+ return f"<{self.__class__.__name__}.{self._value_}>"
92
+
93
+ def __str__(self):
94
+ return str(self.value)
95
+
96
+ @property
97
+ def description(self):
98
+ return self._description
99
+
100
+ @classmethod
101
+ def by_code(cls, code: int) -> Self:
102
+ for status in cls:
103
+ if status.value == code:
104
+ return status
105
+
106
+ raise ValueError(f"No HTTPStatus found for code: {code}")
107
+
108
+
109
+ class HTTPMethod(Enum):
110
+ """
111
+ For backward compatibility because HTTPMethod class
112
+ was added in Python 3.11...
113
+ """
114
+
115
+ CONNECT = "CONNECT", "Establish a connection to the server."
116
+ DELETE = "DELETE", "Delete the resource."
117
+ GET = "GET", "Retrieve the resource."
118
+ HEAD = "HEAD", "Same as GET, but only retrieve the status line and header section."
119
+ OPTIONS = "OPTIONS", "Describe the communication options for the resource."
120
+ PATCH = "PATCH", "Apply partial modifications to a resource."
121
+ POST = "POST", "Perform resource-specific processing with the request payload."
122
+ PUT = "PUT", "Replace the resource with the request payload."
123
+ TRACE = "TRACE", "Perform a message loop-back test along the path to the resource."
124
+
125
+ def __init__(self, name: str, description: str):
126
+ self._value_ = name
127
+ self._description = description
128
+
129
+ def __repr__(self):
130
+ return f"<{self.__class__.__name__}.{self._value_}>"
131
+
132
+ def __str__(self):
133
+ return self._value_
134
+
135
+ @property
136
+ def description(self):
137
+ return self._description
138
+
139
+ @classmethod
140
+ def by_name(cls, name: str) -> Self:
141
+ name = name.upper()
142
+
143
+ for http_method in cls:
144
+ if http_method.value == name:
145
+ return http_method
146
+
147
+ raise ValueError(f"No HTTPMethod found for name: {name}")
148
+
149
+
150
+ class StrEnum(str, Enum):
151
+ """
152
+ For backward compatibility because StrEnum class
153
+ was added in Python 3.11...
154
+ """
155
+
156
+ def __new__(cls, value, *args, **kwargs):
157
+ if not isinstance(value, str):
158
+ raise TypeError(f"{value} is not a string")
159
+
160
+ obj = str.__new__(cls, value)
161
+ obj._value_ = value
162
+ return obj
@@ -1,25 +1,35 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: core-https
3
- Version: 1.0.3
3
+ Version: 1.1.0
4
4
  Summary: This project/library contains common elements related to HTTP & API services...
5
5
  Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
6
  Maintainer: Alejandro Cora González
7
7
  License: MIT
8
8
  Project-URL: Homepage, https://gitlab.com/bytecode-solutions/core/core-https
9
+ Project-URL: Repository, https://gitlab.com/bytecode-solutions/core/core-https
10
+ Project-URL: Issues, https://gitlab.com/bytecode-solutions/core/core-https/-/issues
11
+ Project-URL: Changelog, https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md
9
12
  Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Development Status :: 5 - Production/Stable
10
15
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Utilities
11
17
  Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.7
19
+ Classifier: Programming Language :: Python :: 3.8
12
20
  Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
13
22
  Classifier: Programming Language :: Python :: 3.11
14
23
  Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Intended Audience :: Developers
16
- Classifier: Topic :: Utilities
17
- Requires-Python: >=3.9
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Requires-Python: >=3.7
18
26
  Description-Content-Type: text/markdown
19
27
  License-File: LICENSE
20
- Requires-Dist: core-tests==1.0.3
21
- Requires-Dist: urllib3==2.2.3
22
- Provides-Extra: test
28
+ Requires-Dist: core-tests>=1.1.0
29
+ Requires-Dist: urllib3>=2.2.3; python_version >= "3.8"
30
+ Requires-Dist: urllib3>=1.26.20; python_version >= "3.7" and python_version < "3.8"
31
+ Requires-Dist: typing-extensions>=4.8.0; python_version >= "3.8" and python_version < "3.11"
32
+ Requires-Dist: typing-extensions>=4.2.0; python_version >= "3.7" and python_version < "3.8"
23
33
 
24
34
  # core-https
25
35
  _______________________________________________________________________________
@@ -4,6 +4,7 @@ pyproject.toml
4
4
  setup.py
5
5
  core_https/__init__.py
6
6
  core_https/exceptions.py
7
+ core_https/utils.py
7
8
  core_https.egg-info/PKG-INFO
8
9
  core_https.egg-info/SOURCES.txt
9
10
  core_https.egg-info/dependency_links.txt
@@ -0,0 +1,11 @@
1
+ core-tests>=1.1.0
2
+
3
+ [:python_version >= "3.7" and python_version < "3.8"]
4
+ urllib3>=1.26.20
5
+ typing-extensions>=4.2.0
6
+
7
+ [:python_version >= "3.8"]
8
+ urllib3>=2.2.3
9
+
10
+ [:python_version >= "3.8" and python_version < "3.11"]
11
+ typing-extensions>=4.8.0
@@ -3,13 +3,13 @@
3
3
  # https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
4
4
 
5
5
  [build-system]
6
- requires = ["setuptools>=61", "wheel"]
6
+ requires = ["setuptools>=61.0.0", "wheel"]
7
7
  build-backend = "setuptools.build_meta"
8
8
 
9
9
  [project]
10
10
  name = "core-https"
11
11
  description = "This project/library contains common elements related to HTTP & API services..."
12
- version = "1.0.3"
12
+ version = "1.1.0"
13
13
 
14
14
  authors = [
15
15
  {name = "Alejandro Cora González", email = "alek.cora.glez@gmail.com"}
@@ -19,29 +19,40 @@ maintainers = [
19
19
  {name = "Alejandro Cora González"}
20
20
  ]
21
21
 
22
- requires-python = ">=3.9"
22
+ requires-python = ">=3.7"
23
23
  license = {text = "MIT"}
24
24
  readme = "README.md"
25
25
 
26
26
  classifiers = [
27
27
  # Classifiers -> https://pypi.org/classifiers/
28
28
  "License :: OSI Approved :: MIT License",
29
+ "Intended Audience :: Developers",
30
+ "Development Status :: 5 - Production/Stable",
29
31
  "Topic :: Software Development :: Libraries :: Python Modules",
32
+ "Topic :: Utilities",
30
33
  "Programming Language :: Python :: 3",
34
+ "Programming Language :: Python :: 3.7",
35
+ "Programming Language :: Python :: 3.8",
31
36
  "Programming Language :: Python :: 3.9",
37
+ "Programming Language :: Python :: 3.10",
32
38
  "Programming Language :: Python :: 3.11",
33
39
  "Programming Language :: Python :: 3.12",
34
- "Intended Audience :: Developers",
35
- "Topic :: Utilities"
40
+ "Programming Language :: Python :: 3.13"
36
41
  ]
37
42
 
38
43
  dependencies = [
39
- "core-tests==1.0.3",
40
- "urllib3==2.2.3"
44
+ "core-tests>=1.1.0",
45
+ "urllib3>=2.2.3; python_version >= '3.8'",
46
+ "urllib3>=1.26.20; python_version >= '3.7' and python_version < '3.8'",
47
+ "typing-extensions>=4.8.0; python_version >= '3.8' and python_version < '3.11'",
48
+ "typing-extensions>=4.2.0; python_version >= '3.7' and python_version < '3.8'"
41
49
  ]
42
50
 
51
+ #[project.optional-dependencies]
52
+ #test = []
53
+
43
54
  [project.urls]
44
55
  Homepage = "https://gitlab.com/bytecode-solutions/core/core-https"
45
-
46
- [project.optional-dependencies]
47
- test = []
56
+ Repository = "https://gitlab.com/bytecode-solutions/core/core-https"
57
+ Issues = "https://gitlab.com/bytecode-solutions/core/core-https/-/issues"
58
+ Changelog = "https://gitlab.com/bytecode-solutions/core/core-https/-/blob/master/CHANGELOG.md"
@@ -1,4 +0,0 @@
1
- core-tests==1.0.3
2
- urllib3==2.2.3
3
-
4
- [test]
File without changes
File without changes
File without changes
File without changes