backrefs 5.9__py314-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.
Files changed (40) hide show
  1. backrefs/__init__.py +2 -0
  2. backrefs/__meta__.py +197 -0
  3. backrefs/_bre_parse.py +1529 -0
  4. backrefs/_bregex_parse.py +1362 -0
  5. backrefs/_bregex_typing.py +6 -0
  6. backrefs/bre.py +652 -0
  7. backrefs/bregex.py +726 -0
  8. backrefs/py.typed +0 -0
  9. backrefs/uniprops/__init__.py +592 -0
  10. backrefs/uniprops/unidata/__init__.py +26 -0
  11. backrefs/uniprops/unidata/age.py +119 -0
  12. backrefs/uniprops/unidata/alias.py +783 -0
  13. backrefs/uniprops/unidata/bidiclass.py +99 -0
  14. backrefs/uniprops/unidata/bidipairedbrackettype.py +19 -0
  15. backrefs/uniprops/unidata/binary.py +335 -0
  16. backrefs/uniprops/unidata/block.py +1363 -0
  17. backrefs/uniprops/unidata/canonicalcombiningclass.py +1031 -0
  18. backrefs/uniprops/unidata/decompositiontype.py +79 -0
  19. backrefs/uniprops/unidata/eastasianwidth.py +31 -0
  20. backrefs/uniprops/unidata/generalcategory.py +173 -0
  21. backrefs/uniprops/unidata/graphemeclusterbreak.py +79 -0
  22. backrefs/uniprops/unidata/hangulsyllabletype.py +31 -0
  23. backrefs/uniprops/unidata/indicpositionalcategory.py +71 -0
  24. backrefs/uniprops/unidata/indicsyllabiccategory.py +155 -0
  25. backrefs/uniprops/unidata/joininggroup.py +427 -0
  26. backrefs/uniprops/unidata/joiningtype.py +31 -0
  27. backrefs/uniprops/unidata/linebreak.py +199 -0
  28. backrefs/uniprops/unidata/numerictype.py +23 -0
  29. backrefs/uniprops/unidata/numericvalue.py +583 -0
  30. backrefs/uniprops/unidata/quickcheck.py +59 -0
  31. backrefs/uniprops/unidata/script.py +695 -0
  32. backrefs/uniprops/unidata/scriptextensions.py +695 -0
  33. backrefs/uniprops/unidata/sentencebreak.py +67 -0
  34. backrefs/uniprops/unidata/verticalorientation.py +23 -0
  35. backrefs/uniprops/unidata/wordbreak.py +99 -0
  36. backrefs/util.py +163 -0
  37. backrefs-5.9.dist-info/METADATA +73 -0
  38. backrefs-5.9.dist-info/RECORD +40 -0
  39. backrefs-5.9.dist-info/WHEEL +4 -0
  40. backrefs-5.9.dist-info/licenses/LICENSE.md +21 -0
backrefs/util.py ADDED
@@ -0,0 +1,163 @@
1
+ """
2
+ Utilities and compatibility abstraction.
3
+
4
+ Licensed under MIT
5
+ Copyright (c) 2015 - 2020 Isaac Muse <isaacmuse@gmail.com>
6
+ """
7
+ from __future__ import annotations
8
+ import warnings
9
+ import sys
10
+ from typing import Any, Callable, AnyStr
11
+
12
+ PY311 = (3, 11) <= sys.version_info
13
+ PY312 = (3, 12) <= sys.version_info
14
+
15
+ FMT_FIELD = 0
16
+ FMT_INDEX = 1
17
+ FMT_ATTR = 2
18
+ FMT_CONV = 3
19
+ FMT_SPEC = 4
20
+
21
+
22
+ class StringIter:
23
+ """Preprocess replace tokens."""
24
+
25
+ def __init__(self, text: str) -> None:
26
+ """Initialize."""
27
+
28
+ self._string = text
29
+ self._index = 0
30
+
31
+ def __iter__(self) -> StringIter:
32
+ """Iterate."""
33
+
34
+ return self
35
+
36
+ def __next__(self) -> str:
37
+ """Python 3 iterator compatible next."""
38
+
39
+ return self.iternext()
40
+
41
+ @property
42
+ def index(self) -> int:
43
+ """Get Index."""
44
+
45
+ return self._index
46
+
47
+ def rewind(self, count: int) -> None:
48
+ """Rewind index."""
49
+
50
+ if count > self._index: # pragma: no cover
51
+ raise ValueError("Can't rewind past beginning!")
52
+
53
+ self._index -= count
54
+
55
+ def iternext(self) -> str:
56
+ """Iterate through characters of the string."""
57
+
58
+ try:
59
+ char = self._string[self._index]
60
+ self._index += 1
61
+ except IndexError as e:
62
+ raise StopIteration from e
63
+
64
+ return char
65
+
66
+
67
+ def _to_bstr(obj: Any) -> bytes:
68
+ """Convert to byte string."""
69
+
70
+ if isinstance(obj, str):
71
+ return obj.encode('ascii', 'backslashreplace')
72
+ elif not isinstance(obj, bytes):
73
+ return str(obj).encode('ascii', 'backslashreplace')
74
+ return obj
75
+
76
+
77
+ def _to_str(obj: Any) -> str:
78
+ """Convert to string."""
79
+
80
+ if not isinstance(obj, str):
81
+ return str(obj)
82
+ return obj
83
+
84
+
85
+ def format_captures(
86
+ captures: list[AnyStr],
87
+ formatting: tuple[tuple[int, Any]],
88
+ converter: Callable[[Any], AnyStr],
89
+ default: AnyStr
90
+ ) -> AnyStr:
91
+ """Perform a string format on a set of captures."""
92
+
93
+ capture = captures # type: Any
94
+ for i, fmt in enumerate(formatting, 0):
95
+ if i == 0:
96
+ continue
97
+ fmt_type, value = fmt
98
+ if fmt_type == FMT_ATTR:
99
+ # Attribute
100
+ capture = getattr(capture, value)
101
+ elif fmt_type == FMT_INDEX:
102
+ # Index
103
+ if value is not None:
104
+ capture = capture[value]
105
+ else:
106
+ capture = default if not capture else capture[0]
107
+ elif fmt_type == FMT_CONV:
108
+ # Conversion
109
+ if value == 'a':
110
+ capture = ascii(capture)
111
+ elif value == 'r':
112
+ capture = repr(capture)
113
+ elif value == 's':
114
+ # If the object is not string or byte string already
115
+ capture = str(capture)
116
+ elif fmt_type == FMT_SPEC:
117
+ # Integers and floats don't have an explicit 's' format type.
118
+ if value[3] and value[3] == 's':
119
+ if isinstance(capture, int): # pragma: no cover
120
+ raise ValueError("Unknown format code 's' for object of type 'int'")
121
+ if isinstance(capture, float): # pragma: no cover
122
+ raise ValueError("Unknown format code 's' for object of type 'float'")
123
+
124
+ # Ensure object is a byte string
125
+ capture = converter(capture)
126
+
127
+ spec_type = value[1]
128
+ if spec_type == '^':
129
+ capture = capture.center(value[2], value[0])
130
+ elif spec_type == ">":
131
+ capture = capture.rjust(value[2], value[0])
132
+ else:
133
+ capture = capture.ljust(value[2], value[0])
134
+
135
+ # Make sure the final object is a byte string
136
+ return converter(capture)
137
+
138
+
139
+ class Immutable:
140
+ """Immutable."""
141
+
142
+ __slots__: tuple[Any, ...] = ()
143
+
144
+ def __init__(self, **kwargs: Any) -> None:
145
+ """Initialize."""
146
+
147
+ for k, v in kwargs.items():
148
+ super().__setattr__(k, v)
149
+
150
+ def __setattr__(self, name: str, value: Any) -> None:
151
+ """Prevent mutability."""
152
+
153
+ raise AttributeError('Class is immutable!')
154
+
155
+
156
+ def warn_deprecated(message: str, stacklevel: int = 2) -> None: # pragma: no cover
157
+ """Warn deprecated."""
158
+
159
+ warnings.warn(
160
+ message,
161
+ category=DeprecationWarning,
162
+ stacklevel=stacklevel
163
+ )
@@ -0,0 +1,73 @@
1
+ Metadata-Version: 2.4
2
+ Name: backrefs
3
+ Version: 5.9
4
+ Summary: A wrapper around re and regex that adds additional back references.
5
+ Project-URL: Homepage, https://github.com/facelessuser/backrefs
6
+ Author-email: Isaac Muse <Isaac.Muse@gmail.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE.md
9
+ Keywords: re,regex
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.9
25
+ Provides-Extra: extras
26
+ Requires-Dist: regex; extra == 'extras'
27
+ Description-Content-Type: text/markdown
28
+
29
+ [![Donate via PayPal][donate-image]][donate-link]
30
+ [![Build][github-ci-image]][github-ci-link]
31
+ [![Coverage Status][codecov-image]][codecov-link]
32
+ [![PyPI Version][pypi-image]][pypi-link]
33
+ [![PyPI Downloads][pypi-down]][pypi-link]
34
+ [![PyPI - Python Version][python-image]][pypi-link]
35
+ [![License][license-image-mit]][license-link]
36
+
37
+ # Backrefs
38
+
39
+ Backrefs is a wrapper around Python's built-in [Re][re] and the 3rd party [Regex][regex] library. Backrefs adds various
40
+ additional back references (and a couple other features) that are known to some regular expression engines, but not to
41
+ Python's Re and/or Regex. The supported back references actually vary depending on the regular expression engine being
42
+ used as the engine may already have support for some.
43
+
44
+ ```python
45
+ >>> from backrefs import bre
46
+ >>> pattern = bre.compile(r'(\p{Letter}+)')
47
+ >>> pattern.sub(r'\C\1\E', 'sometext')
48
+ 'SOMETEXT'
49
+ ```
50
+
51
+ # Documentation
52
+
53
+ https://facelessuser.github.io/backrefs/
54
+
55
+ # License
56
+
57
+ MIT
58
+
59
+ [github-ci-image]: https://github.com/facelessuser/backrefs/workflows/build/badge.svg
60
+ [github-ci-link]: https://github.com/facelessuser/backrefs/actions?query=workflow%3Abuild+branch%3Amaster
61
+ [codecov-image]: https://img.shields.io/codecov/c/github/facelessuser/backrefs/master.svg?logo=codecov&logoColor=aaaaaa&labelColor=333333
62
+ [codecov-link]: https://codecov.io/github/facelessuser/backrefs
63
+ [pypi-image]: https://img.shields.io/pypi/v/backrefs.svg?logo=pypi&logoColor=aaaaaa&labelColor=333333
64
+ [pypi-down]: https://img.shields.io/pypi/dm/backrefs.svg?logo=pypi&logoColor=aaaaaa&labelColor=333333
65
+ [pypi-link]: https://pypi.python.org/pypi/backrefs
66
+ [python-image]: https://img.shields.io/pypi/pyversions/backrefs?logo=python&logoColor=aaaaaa&labelColor=333333
67
+ [license-image-mit]: https://img.shields.io/badge/license-MIT-blue.svg?labelColor=333333
68
+ [license-link]: https://github.com/facelessuser/backrefs/blob/main/LICENSE.md
69
+ [donate-image]: https://img.shields.io/badge/Donate-PayPal-3fabd1?logo=paypal
70
+ [donate-link]: https://www.paypal.me/facelessuser
71
+
72
+ [re]: https://docs.python.org/3/library/re.html
73
+ [regex]: https://pypi.python.org/pypi/regex
@@ -0,0 +1,40 @@
1
+ backrefs/__init__.py,sha256=8Qt-anmlWzm-8FEjX1c9xYa47PG8-ccQgWQOAiKA4PM,90
2
+ backrefs/__meta__.py,sha256=-nze3aU0JUz7So11iCeDvTSm34UGsaM-KQV4dRLhEfE,6766
3
+ backrefs/_bre_parse.py,sha256=w6wONmzAZRTf0sz1pIFGH3fxlpPa-rDutMjEBl8oSx0,52529
4
+ backrefs/_bregex_parse.py,sha256=VGrP76iMRPXiaYo3vKGu9Jq5PFaYOaWUDMg6537N6n4,46436
5
+ backrefs/_bregex_typing.py,sha256=THgf80whbUAJrpKWayEMJx8ixrU5oXwmVaQAa8n0DsQ,236
6
+ backrefs/bre.py,sha256=1NY-n_gcftYTkgdhDgOBGGrWgedBHwygFys1UOutufo,19815
7
+ backrefs/bregex.py,sha256=VHdyZkcoIWcfRlZ4jYfCLTdWhM872wJL7DSwKAe3WFw,20919
8
+ backrefs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ backrefs/util.py,sha256=2qnLiUsB06IKKIdrjWIxYqwUG7OFqtOhafgx23ZwBn8,4285
10
+ backrefs/uniprops/__init__.py,sha256=87ZqdAgKgULgX_SyxRlEXcUsMVOmLY2XqOYqcwYEG-0,20983
11
+ backrefs/uniprops/unidata/__init__.py,sha256=7xMSYECvPbM5irfSdl_IvSU1AVtZhKUh6igu3McBOQY,992
12
+ backrefs/uniprops/unidata/age.py,sha256=aVqBF4mLx1FdoJHZgNHIrCt34taJBqLMTl8zuTzr9YE,75269
13
+ backrefs/uniprops/unidata/alias.py,sha256=GK36oTTYpNazalazVIBAF8iG7P3RyiJQOp4G9CSvEBk,24444
14
+ backrefs/uniprops/unidata/bidiclass.py,sha256=fUYa2WubCpEsLOrF6t3pOYIrYFtnPfZJ_oebEq_ENUc,47035
15
+ backrefs/uniprops/unidata/bidipairedbrackettype.py,sha256=eSGL06au9LyuhvzUyfAhpGsosLEONOPRIdfDGsgsyXc,3226
16
+ backrefs/uniprops/unidata/binary.py,sha256=rf9myAQa1Z_jZ-Sfww-bt6kqGWP35RjknC2NHt6nULI,436604
17
+ backrefs/uniprops/unidata/block.py,sha256=1B5_RDwOXnR5J3oUrv9AQCUpcqsMz00TBn6UdWdfbz4,60624
18
+ backrefs/uniprops/unidata/canonicalcombiningclass.py,sha256=nLyX0YWMIlJyDJUwMPTZRb8O_LrhJ6TwlKk5Vta-VgE,38259
19
+ backrefs/uniprops/unidata/decompositiontype.py,sha256=3lXH2sO_ExZ6tf1qNqBZL2oxBi_3yyK_HrHwzE9RYlA,28066
20
+ backrefs/uniprops/unidata/eastasianwidth.py,sha256=vWbo6egscNC8F-oCF--zxOC2dpN8sVxlUWas5ifkmrU,15543
21
+ backrefs/uniprops/unidata/generalcategory.py,sha256=TFdOOTwyJYZ935Fd8LLU_LmGpB5pQeq8TofuNsY5vu0,141740
22
+ backrefs/uniprops/unidata/graphemeclusterbreak.py,sha256=5-F3h7fsYK0-BuXao59hcf0142F8J57X_MHEc0VTkdU,43212
23
+ backrefs/uniprops/unidata/hangulsyllabletype.py,sha256=F1YUNObYObxBC3FvJSxR7Rw5U5wxeD0Rw7J-_tQAFyU,16173
24
+ backrefs/uniprops/unidata/indicpositionalcategory.py,sha256=45olrGQIDhYbGYIItsPokzZQl0KoUaFfVNQEsfCgvRw,25636
25
+ backrefs/uniprops/unidata/indicsyllabiccategory.py,sha256=HVpfXMT7zdTHVqPHc73kE6-ezPAcm9FOVJrMooazlcw,36890
26
+ backrefs/uniprops/unidata/joininggroup.py,sha256=vpVkrj3ivuvhpuGSmznisRN36C6dzqaCG7OXPzG186o,18142
27
+ backrefs/uniprops/unidata/joiningtype.py,sha256=COknPO0Q2Py7GEXs4V0HjEtrfcxaJcn5T-J9UTJ1_mY,25738
28
+ backrefs/uniprops/unidata/linebreak.py,sha256=ckO5uchxkzHlT4Q0_3Sh33eil9Qd_Ke53ckDQ2aE1sk,96742
29
+ backrefs/uniprops/unidata/numerictype.py,sha256=qLfjmOFEtZvm_b6vEUbNgtE_A_Fcq-2gActXhbre1Ls,14563
30
+ backrefs/uniprops/unidata/numericvalue.py,sha256=3W3KumpRuGBuUmifNuGktpZsXQFHZj-Z8qC4yY87Hsc,71671
31
+ backrefs/uniprops/unidata/quickcheck.py,sha256=X2AjLO3CtuB4rvxmK7wL2EA6svYuVZwfv1kLlvwW4r0,50110
32
+ backrefs/uniprops/unidata/script.py,sha256=8vDKnQo7vZHNq4sXF7waw_x2eTqX5v7Uq6aZ-Ow5too,70852
33
+ backrefs/uniprops/unidata/scriptextensions.py,sha256=ceqJZ3wmIY3Ld3pBl9dc73dGDp4bLQvVP93yfKvTdsk,79015
34
+ backrefs/uniprops/unidata/sentencebreak.py,sha256=OVW08mGQBInHEgyZBNGmZmwRv7NQgawTSohDxF-7sjk,79866
35
+ backrefs/uniprops/unidata/verticalorientation.py,sha256=r-c1BRMRYxhlU7BrFIpnfqnKikLYTAajTQSNYs4L8Ec,6776
36
+ backrefs/uniprops/unidata/wordbreak.py,sha256=trR7lEzorjT_ors-q_VyDpWeFnQJerQqFAdn5NaqrKM,56791
37
+ backrefs-5.9.dist-info/METADATA,sha256=ngLZVFl2nPGfC_tAlOPQVojf-oiY_5j6FdCjkOkhtYE,3235
38
+ backrefs-5.9.dist-info/WHEEL,sha256=xA5FQg44T5CFni23urzJOdaaFb7BSPHipPtkvdJaKtU,89
39
+ backrefs-5.9.dist-info/licenses/LICENSE.md,sha256=9BPB7mvyVGUeAmtgcAFhNxNb_KKkKOYIwY035bV6Tgs,1084
40
+ backrefs-5.9.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py314-none-any
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 - 2025 Isaac Muse
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.