omlish 0.0.0.dev122__py3-none-any.whl → 0.0.0.dev124__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
omlish/__about__.py CHANGED
@@ -1,5 +1,5 @@
1
- __version__ = '0.0.0.dev122'
2
- __revision__ = 'f29d374baac7fe7644958440b50d3ba934c14595'
1
+ __version__ = '0.0.0.dev124'
2
+ __revision__ = '25f7c36b35a9ecdd1e39499b47d408e602d102bb'
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,3 @@
1
+ # While the library as a whole only supports modern python, the 'lite' package is importable and usable down to python
2
+ # 3.8. As a result this file needs to be kept basically empty as anything it would otherwise do would likely involve
3
+ # non-lite code.
@@ -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
- PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
3
- --------------------------------------------
4
-
5
- 1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and the Individual or Organization
6
- ("Licensee") accessing and otherwise using this software ("Python") in source or binary form and its associated
7
- documentation.
8
-
9
- 2. Subject to the terms and conditions of this License Agreement, PSF hereby grants Licensee a nonexclusive,
10
- royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare derivative works,
11
- distribute, and otherwise use Python alone or in any derivative version, provided, however, that PSF's License Agreement
12
- and PSF's notice of copyright, i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
13
- 2012, 2013, 2014, 2015, 2016, 2017 Python Software Foundation; All Rights Reserved" are retained in Python alone or in
14
- any derivative version prepared by Licensee.
15
-
16
- 3. In the event Licensee prepares a derivative work that is based on or incorporates Python or any part thereof, and
17
- wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any
18
- such work a brief summary of the changes made to Python.
19
-
20
- 4. PSF is making Python available to Licensee on an "AS IS" basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS
21
- OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF
22
- MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT INFRINGE ANY THIRD PARTY
23
- RIGHTS.
24
-
25
- 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL
26
- DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, OR ANY DERIVATIVE THEREOF, EVEN IF
27
- ADVISED OF THE POSSIBILITY THEREOF.
28
-
29
- 6. This License Agreement will automatically terminate upon a material breach of its terms and conditions.
30
-
31
- 7. Nothing in this License Agreement shall be deemed to create any relationship of agency, partnership, or joint venture
32
- between PSF and Licensee. This License Agreement does not grant permission to use PSF trademarks or trade name in a
33
- trademark sense to endorse or promote products or services of Licensee, or any third party.
34
-
35
- 8. By copying, installing or otherwise using Python, Licensee agrees to be bound by the terms and conditions of this
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
 
@@ -104,4 +104,8 @@ from .utils import ( # noqa
104
104
  update_fields_metadata,
105
105
 
106
106
  deep_replace,
107
+
108
+ iter_items,
109
+ iter_keys,
110
+ iter_values,
107
111
  )
@@ -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/lite/check.py CHANGED
@@ -5,7 +5,7 @@ import typing as ta
5
5
  T = ta.TypeVar('T')
6
6
 
7
7
 
8
- def check_isinstance(v: T, spec: ta.Union[ta.Type[T], tuple]) -> T:
8
+ def check_isinstance(v: ta.Any, spec: ta.Union[ta.Type[T], tuple]) -> T:
9
9
  if not isinstance(v, spec):
10
10
  raise TypeError(v)
11
11
  return v
@@ -17,6 +17,11 @@ def check_not_isinstance(v: T, spec: ta.Union[type, tuple]) -> T:
17
17
  return v
18
18
 
19
19
 
20
+ def check_none(v: T) -> None:
21
+ if v is not None:
22
+ raise ValueError(v)
23
+
24
+
20
25
  def check_not_none(v: ta.Optional[T]) -> T:
21
26
  if v is None:
22
27
  raise ValueError
File without changes