omlish 0.0.0.dev123__py3-none-any.whl → 0.0.0.dev125__py3-none-any.whl
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.
- omlish/__about__.py +3 -2
- omlish/__init__.py +3 -0
- omlish/antlr/_runtime/LICENSE.txt +28 -0
- omlish/c3.py +35 -37
- omlish/dataclasses/__init__.py +4 -0
- omlish/dataclasses/utils.py +22 -4
- omlish/http/consts.py +2 -0
- omlish/inject/impl/inspect.py +4 -2
- omlish/lang/__init__.py +3 -0
- omlish/lang/typing.py +8 -0
- omlish/lite/check.py +5 -0
- omlish/lite/http/__init__.py +0 -0
- omlish/lite/http/coroserver.py +585 -0
- omlish/lite/http/handlers.py +36 -0
- omlish/lite/http/parsing.py +376 -0
- omlish/lite/http/versions.py +17 -0
- omlish/lite/inject.py +153 -82
- omlish/lite/journald.py +0 -1
- omlish/lite/runtime.py +1 -2
- omlish/lite/socket.py +77 -0
- omlish/lite/socketserver.py +66 -0
- omlish/lite/typing.py +13 -0
- omlish-0.0.0.dev125.dist-info/METADATA +100 -0
- {omlish-0.0.0.dev123.dist-info → omlish-0.0.0.dev125.dist-info}/RECORD +28 -19
- {omlish-0.0.0.dev123.dist-info → omlish-0.0.0.dev125.dist-info}/WHEEL +1 -1
- omlish-0.0.0.dev123.dist-info/METADATA +0 -94
- {omlish-0.0.0.dev123.dist-info → omlish-0.0.0.dev125.dist-info}/LICENSE +0 -0
- {omlish-0.0.0.dev123.dist-info → omlish-0.0.0.dev125.dist-info}/entry_points.txt +0 -0
- {omlish-0.0.0.dev123.dist-info → omlish-0.0.0.dev125.dist-info}/top_level.txt +0 -0
omlish/__about__.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
__version__ = '0.0.0.
|
2
|
-
__revision__ = '
|
1
|
+
__version__ = '0.0.0.dev125'
|
2
|
+
__revision__ = 'ab4e58c3eaba25f0520ed6cb0df32e2322ca439a'
|
3
3
|
|
4
4
|
|
5
5
|
#
|
@@ -168,6 +168,7 @@ class SetuptoolsBase:
|
|
168
168
|
'.manifests.json',
|
169
169
|
|
170
170
|
'LICENSE',
|
171
|
+
'LICENSE.txt',
|
171
172
|
],
|
172
173
|
}
|
173
174
|
|
omlish/__init__.py
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
Copyright (c) 2012-2022 The ANTLR Project. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions
|
5
|
+
are met:
|
6
|
+
|
7
|
+
1. Redistributions of source code must retain the above copyright
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer in the
|
12
|
+
documentation and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
3. Neither name of copyright holders nor the names of its contributors
|
15
|
+
may be used to endorse or promote products derived from this software
|
16
|
+
without specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
+
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
21
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
|
22
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
23
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
24
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
25
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
26
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
27
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
28
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
omlish/c3.py
CHANGED
@@ -1,40 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
OR
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
License Agreement.
|
37
|
-
"""
|
1
|
+
# PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
2
|
+
# --------------------------------------------
|
3
|
+
#
|
4
|
+
# 1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and the Individual or Organization
|
5
|
+
# ("Licensee") accessing and otherwise using this software ("Python") in source or binary form and its associated
|
6
|
+
# documentation.
|
7
|
+
#
|
8
|
+
# 2. Subject to the terms and conditions of this License Agreement, PSF hereby grants Licensee a nonexclusive,
|
9
|
+
# royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare derivative
|
10
|
+
# works, distribute, and otherwise use Python alone or in any derivative version, provided, however, that PSF's License
|
11
|
+
# Agreement and PSF's notice of copyright, i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
12
|
+
# 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Python Software Foundation; All Rights Reserved" are retained in Python
|
13
|
+
# alone or in any derivative version prepared by Licensee.
|
14
|
+
#
|
15
|
+
# 3. In the event Licensee prepares a derivative work that is based on or incorporates Python or any part thereof, and
|
16
|
+
# wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in
|
17
|
+
# any such work a brief summary of the changes made to Python.
|
18
|
+
#
|
19
|
+
# 4. PSF is making Python available to Licensee on an "AS IS" basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES,
|
20
|
+
# EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY
|
21
|
+
# OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT INFRINGE ANY THIRD PARTY
|
22
|
+
# RIGHTS.
|
23
|
+
#
|
24
|
+
# 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL
|
25
|
+
# DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, OR ANY DERIVATIVE THEREOF, EVEN IF
|
26
|
+
# ADVISED OF THE POSSIBILITY THEREOF.
|
27
|
+
#
|
28
|
+
# 6. This License Agreement will automatically terminate upon a material breach of its terms and conditions.
|
29
|
+
#
|
30
|
+
# 7. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint
|
31
|
+
# venture between PSF and Licensee. This License Agreement does not grant permission to use PSF trademarks or trade
|
32
|
+
# name in a trademark sense to endorse or promote products or services of Licensee, or any third party.
|
33
|
+
#
|
34
|
+
# 8. By copying, installing or otherwise using Python, Licensee agrees to be bound by the terms and conditions of this
|
35
|
+
# License Agreement.
|
38
36
|
import operator
|
39
37
|
import typing as ta
|
40
38
|
|
omlish/dataclasses/__init__.py
CHANGED
omlish/dataclasses/utils.py
CHANGED
@@ -14,7 +14,7 @@ from .impl.params import get_field_extras
|
|
14
14
|
T = ta.TypeVar('T')
|
15
15
|
|
16
16
|
|
17
|
-
|
17
|
+
##
|
18
18
|
|
19
19
|
|
20
20
|
def maybe_post_init(sup: ta.Any) -> bool:
|
@@ -26,7 +26,7 @@ def maybe_post_init(sup: ta.Any) -> bool:
|
|
26
26
|
return True
|
27
27
|
|
28
28
|
|
29
|
-
|
29
|
+
##
|
30
30
|
|
31
31
|
|
32
32
|
def opt_repr(o: ta.Any) -> str | None:
|
@@ -37,7 +37,7 @@ def truthy_repr(o: ta.Any) -> str | None:
|
|
37
37
|
return repr(o) if o else None
|
38
38
|
|
39
39
|
|
40
|
-
|
40
|
+
##
|
41
41
|
|
42
42
|
|
43
43
|
def fields_dict(cls_or_instance: ta.Any) -> dict[str, dc.Field]:
|
@@ -121,7 +121,7 @@ def update_fields_metadata(
|
|
121
121
|
return update_fields(inner, fields)
|
122
122
|
|
123
123
|
|
124
|
-
|
124
|
+
##
|
125
125
|
|
126
126
|
|
127
127
|
def deep_replace(o: T, *args: str | ta.Callable[[ta.Any], ta.Mapping[str, ta.Any]]) -> T:
|
@@ -131,3 +131,21 @@ def deep_replace(o: T, *args: str | ta.Callable[[ta.Any], ta.Mapping[str, ta.Any
|
|
131
131
|
return dc.replace(o, **args[0](o)) # type: ignore
|
132
132
|
else:
|
133
133
|
return dc.replace(o, **{args[0]: deep_replace(getattr(o, args[0]), *args[1:])}) # type: ignore
|
134
|
+
|
135
|
+
|
136
|
+
##
|
137
|
+
|
138
|
+
|
139
|
+
def iter_items(obj: ta.Any) -> ta.Iterator[tuple[str, ta.Any]]:
|
140
|
+
for f in dc.fields(obj):
|
141
|
+
yield (f.name, getattr(obj, f.name))
|
142
|
+
|
143
|
+
|
144
|
+
def iter_keys(obj: ta.Any) -> ta.Iterator[str]:
|
145
|
+
for f in dc.fields(obj):
|
146
|
+
yield f.name
|
147
|
+
|
148
|
+
|
149
|
+
def iter_values(obj: ta.Any) -> ta.Iterator[ta.Any]:
|
150
|
+
for f in dc.fields(obj):
|
151
|
+
yield getattr(obj, f.name)
|
omlish/http/consts.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"""
|
2
2
|
TODO:
|
3
3
|
- import mimetypes lol
|
4
|
+
- http.HTTPStatus / http.HTTPMethod
|
4
5
|
"""
|
5
6
|
import base64
|
6
7
|
import http
|
@@ -36,6 +37,7 @@ STATUS_GATEWAY_TIMEOUT = format_status(http.HTTPStatus.GATEWAY_TIMEOUT)
|
|
36
37
|
|
37
38
|
|
38
39
|
HEADER_CONTENT_TYPE = b'Content-Type'
|
40
|
+
HEADER_CONTENT_LENGTH = b'Content-Length'
|
39
41
|
HEADER_ACCEPT = b'Accept'
|
40
42
|
|
41
43
|
CONTENT_CHARSET_UTF8 = b'charset=utf-8'
|
omlish/inject/impl/inspect.py
CHANGED
@@ -31,13 +31,15 @@ _SIGNATURE_CACHE: ta.MutableMapping[ta.Any, inspect.Signature] = weakref.WeakKey
|
|
31
31
|
|
32
32
|
|
33
33
|
def signature(obj: ta.Any) -> inspect.Signature:
|
34
|
+
def get() -> inspect.Signature:
|
35
|
+
return inspect.signature(obj, eval_str=True)
|
34
36
|
try:
|
35
37
|
return _SIGNATURE_CACHE[obj]
|
36
38
|
except TypeError:
|
37
|
-
return
|
39
|
+
return get()
|
38
40
|
except KeyError:
|
39
41
|
pass
|
40
|
-
sig =
|
42
|
+
sig = get()
|
41
43
|
_SIGNATURE_CACHE[obj] = sig
|
42
44
|
return sig
|
43
45
|
|
omlish/lang/__init__.py
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# This module should import nothing but stdlib modules, and as few as possible. That *includes* lite - no using lite.
|
2
|
+
|
1
3
|
from .cached import ( # noqa
|
2
4
|
cached_function,
|
3
5
|
cached_property,
|
@@ -217,6 +219,7 @@ from .timeouts import ( # noqa
|
|
217
219
|
)
|
218
220
|
|
219
221
|
from .typing import ( # noqa
|
222
|
+
AnyFunc,
|
220
223
|
BytesLike,
|
221
224
|
Func0,
|
222
225
|
Func1,
|
omlish/lang/typing.py
CHANGED
@@ -106,6 +106,14 @@ def typed_partial(obj, **kw): # noqa
|
|
106
106
|
# A workaround for typing deficiencies (like `Argument 2 to NewType(...) must be subclassable`).
|
107
107
|
|
108
108
|
|
109
|
+
@dc.dataclass(frozen=True)
|
110
|
+
class AnyFunc(ta.Generic[T]):
|
111
|
+
fn: ta.Callable[..., T]
|
112
|
+
|
113
|
+
def __call__(self, *args: ta.Any, **kwargs: ta.Any) -> T:
|
114
|
+
return self.fn(*args, **kwargs)
|
115
|
+
|
116
|
+
|
109
117
|
@dc.dataclass(frozen=True)
|
110
118
|
class Func0(ta.Generic[T]):
|
111
119
|
fn: ta.Callable[[], T]
|
omlish/lite/check.py
CHANGED
File without changes
|