ZTWHHH commited on
Commit
4f96087
·
verified ·
1 Parent(s): c03f4b6

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +5 -0
  2. openflamingo/lib/python3.10/site-packages/blackd/__init__.py +258 -0
  3. openflamingo/lib/python3.10/site-packages/blackd/__main__.py +3 -0
  4. openflamingo/lib/python3.10/site-packages/blackd/__pycache__/__init__.cpython-310.pyc +0 -0
  5. openflamingo/lib/python3.10/site-packages/blackd/__pycache__/__main__.cpython-310.pyc +0 -0
  6. openflamingo/lib/python3.10/site-packages/blackd/__pycache__/middlewares.cpython-310.pyc +0 -0
  7. openflamingo/lib/python3.10/site-packages/blackd/middlewares.py +35 -0
  8. openflamingo/lib/python3.10/site-packages/blib2to3/LICENSE +254 -0
  9. openflamingo/lib/python3.10/site-packages/blib2to3/README +24 -0
  10. openflamingo/lib/python3.10/site-packages/blib2to3/pygram.cpython-310-x86_64-linux-gnu.so +0 -0
  11. openflamingo/lib/python3.10/site-packages/blib2to3/pytree.cpython-310-x86_64-linux-gnu.so +0 -0
  12. openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/INSTALLER +1 -0
  13. openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/LICENSE +202 -0
  14. openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/METADATA +62 -0
  15. openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/RECORD +19 -0
  16. openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/REQUESTED +0 -0
  17. openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/WHEEL +6 -0
  18. openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/top_level.txt +1 -0
  19. openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/INSTALLER +1 -0
  20. openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/License.txt +1568 -0
  21. openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/METADATA +35 -0
  22. openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/RECORD +21 -0
  23. openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/REQUESTED +0 -0
  24. openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/WHEEL +5 -0
  25. openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/top_level.txt +1 -0
  26. openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/__init__.cpython-310.pyc +0 -0
  27. openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/actions.cpython-310.pyc +0 -0
  28. openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/common.cpython-310.pyc +0 -0
  29. openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/exceptions.cpython-310.pyc +0 -0
  30. openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/helpers.cpython-310.pyc +0 -0
  31. openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/testing.cpython-310.pyc +0 -0
  32. openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/unicode.cpython-310.pyc +0 -0
  33. openflamingo/lib/python3.10/site-packages/pyparsing/common.py +434 -0
  34. openflamingo/lib/python3.10/site-packages/pyparsing/diagram/__pycache__/__init__.cpython-310.pyc +0 -0
  35. openflamingo/lib/python3.10/site-packages/pyparsing/helpers.py +1102 -0
  36. openflamingo/lib/python3.10/site-packages/pyparsing/py.typed +0 -0
  37. openflamingo/lib/python3.10/site-packages/pyparsing/results.py +816 -0
  38. openflamingo/lib/python3.10/site-packages/pyparsing/unicode.py +356 -0
  39. openflamingo/lib/python3.10/site-packages/regex/__init__.py +3 -0
  40. openflamingo/lib/python3.10/site-packages/regex/__pycache__/__init__.cpython-310.pyc +0 -0
  41. openflamingo/lib/python3.10/site-packages/regex/__pycache__/regex.cpython-310.pyc +0 -0
  42. openflamingo/lib/python3.10/site-packages/regex/_regex_core.py +0 -0
  43. openflamingo/lib/python3.10/site-packages/regex/regex.py +746 -0
  44. openflamingo/lib/python3.10/site-packages/regex/test_regex.py +0 -0
  45. openflamingo/lib/python3.10/site-packages/setproctitle/__init__.py +57 -0
  46. openflamingo/lib/python3.10/site-packages/setproctitle/__pycache__/__init__.cpython-310.pyc +0 -0
  47. openflamingo/lib/python3.10/site-packages/setproctitle/_setproctitle.cpython-310-x86_64-linux-gnu.so +0 -0
  48. openflamingo/lib/python3.10/site-packages/setproctitle/py.typed +0 -0
  49. openflamingo/lib/python3.10/site-packages/wcwidth/__init__.py +29 -0
  50. openflamingo/lib/python3.10/site-packages/wcwidth/__pycache__/__init__.cpython-310.pyc +0 -0
.gitattributes CHANGED
@@ -759,3 +759,8 @@ phi4/lib/python3.10/site-packages/nvidia/cudnn/lib/libcudnn_engines_runtime_comp
759
  phi4/lib/python3.10/site-packages/nvidia/cudnn/lib/libcudnn_cnn.so.9 filter=lfs diff=lfs merge=lfs -text
760
  phi4/lib/python3.10/site-packages/nvidia/nvjitlink/lib/libnvJitLink.so.12 filter=lfs diff=lfs merge=lfs -text
761
  phi4/lib/python3.10/site-packages/nvidia/cudnn/lib/libcudnn_graph.so.9 filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
759
  phi4/lib/python3.10/site-packages/nvidia/cudnn/lib/libcudnn_cnn.so.9 filter=lfs diff=lfs merge=lfs -text
760
  phi4/lib/python3.10/site-packages/nvidia/nvjitlink/lib/libnvJitLink.so.12 filter=lfs diff=lfs merge=lfs -text
761
  phi4/lib/python3.10/site-packages/nvidia/cudnn/lib/libcudnn_graph.so.9 filter=lfs diff=lfs merge=lfs -text
762
+ phi4/lib/python3.10/site-packages/nvidia/cuda_cupti/lib/libcheckpoint.so filter=lfs diff=lfs merge=lfs -text
763
+ phi4/lib/python3.10/site-packages/nvidia/cudnn/lib/libcudnn_heuristic.so.9 filter=lfs diff=lfs merge=lfs -text
764
+ phi4/lib/python3.10/site-packages/nvidia/cudnn/lib/libcudnn_ops.so.9 filter=lfs diff=lfs merge=lfs -text
765
+ phi4/lib/python3.10/site-packages/nvidia/cuda_cupti/lib/libnvperf_target.so filter=lfs diff=lfs merge=lfs -text
766
+ phi4/lib/python3.10/site-packages/nvidia/cuda_cupti/lib/libcupti.so.12 filter=lfs diff=lfs merge=lfs -text
openflamingo/lib/python3.10/site-packages/blackd/__init__.py ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import logging
3
+ from concurrent.futures import Executor, ProcessPoolExecutor
4
+ from datetime import datetime, timezone
5
+ from functools import partial
6
+ from multiprocessing import freeze_support
7
+
8
+ try:
9
+ from aiohttp import web
10
+ from multidict import MultiMapping
11
+
12
+ from .middlewares import cors
13
+ except ImportError as ie:
14
+ raise ImportError(
15
+ f"aiohttp dependency is not installed: {ie}. "
16
+ + "Please re-install black with the '[d]' extra install "
17
+ + "to obtain aiohttp_cors: `pip install black[d]`"
18
+ ) from None
19
+
20
+ import click
21
+
22
+ import black
23
+ from _black_version import version as __version__
24
+ from black.concurrency import maybe_install_uvloop
25
+
26
+ # This is used internally by tests to shut down the server prematurely
27
+ _stop_signal = asyncio.Event()
28
+
29
+ # Request headers
30
+ PROTOCOL_VERSION_HEADER = "X-Protocol-Version"
31
+ LINE_LENGTH_HEADER = "X-Line-Length"
32
+ PYTHON_VARIANT_HEADER = "X-Python-Variant"
33
+ SKIP_SOURCE_FIRST_LINE = "X-Skip-Source-First-Line"
34
+ SKIP_STRING_NORMALIZATION_HEADER = "X-Skip-String-Normalization"
35
+ SKIP_MAGIC_TRAILING_COMMA = "X-Skip-Magic-Trailing-Comma"
36
+ PREVIEW = "X-Preview"
37
+ UNSTABLE = "X-Unstable"
38
+ ENABLE_UNSTABLE_FEATURE = "X-Enable-Unstable-Feature"
39
+ FAST_OR_SAFE_HEADER = "X-Fast-Or-Safe"
40
+ DIFF_HEADER = "X-Diff"
41
+
42
+ BLACK_HEADERS = [
43
+ PROTOCOL_VERSION_HEADER,
44
+ LINE_LENGTH_HEADER,
45
+ PYTHON_VARIANT_HEADER,
46
+ SKIP_SOURCE_FIRST_LINE,
47
+ SKIP_STRING_NORMALIZATION_HEADER,
48
+ SKIP_MAGIC_TRAILING_COMMA,
49
+ PREVIEW,
50
+ UNSTABLE,
51
+ ENABLE_UNSTABLE_FEATURE,
52
+ FAST_OR_SAFE_HEADER,
53
+ DIFF_HEADER,
54
+ ]
55
+
56
+ # Response headers
57
+ BLACK_VERSION_HEADER = "X-Black-Version"
58
+
59
+
60
+ class HeaderError(Exception):
61
+ pass
62
+
63
+
64
+ class InvalidVariantHeader(Exception):
65
+ pass
66
+
67
+
68
+ @click.command(context_settings={"help_option_names": ["-h", "--help"]})
69
+ @click.option(
70
+ "--bind-host",
71
+ type=str,
72
+ help="Address to bind the server to.",
73
+ default="localhost",
74
+ show_default=True,
75
+ )
76
+ @click.option(
77
+ "--bind-port", type=int, help="Port to listen on", default=45484, show_default=True
78
+ )
79
+ @click.version_option(version=black.__version__)
80
+ def main(bind_host: str, bind_port: int) -> None:
81
+ logging.basicConfig(level=logging.INFO)
82
+ app = make_app()
83
+ ver = black.__version__
84
+ black.out(f"blackd version {ver} listening on {bind_host} port {bind_port}")
85
+ web.run_app(app, host=bind_host, port=bind_port, handle_signals=True, print=None)
86
+
87
+
88
+ def make_app() -> web.Application:
89
+ app = web.Application(
90
+ middlewares=[cors(allow_headers=(*BLACK_HEADERS, "Content-Type"))]
91
+ )
92
+ executor = ProcessPoolExecutor()
93
+ app.add_routes([web.post("/", partial(handle, executor=executor))])
94
+ return app
95
+
96
+
97
+ async def handle(request: web.Request, executor: Executor) -> web.Response:
98
+ headers = {BLACK_VERSION_HEADER: __version__}
99
+ try:
100
+ if request.headers.get(PROTOCOL_VERSION_HEADER, "1") != "1":
101
+ return web.Response(
102
+ status=501, text="This server only supports protocol version 1"
103
+ )
104
+
105
+ fast = False
106
+ if request.headers.get(FAST_OR_SAFE_HEADER, "safe") == "fast":
107
+ fast = True
108
+ try:
109
+ mode = parse_mode(request.headers)
110
+ except HeaderError as e:
111
+ return web.Response(status=400, text=e.args[0])
112
+ req_bytes = await request.content.read()
113
+ charset = request.charset if request.charset is not None else "utf8"
114
+ req_str = req_bytes.decode(charset)
115
+ then = datetime.now(timezone.utc)
116
+
117
+ header = ""
118
+ if mode.skip_source_first_line:
119
+ first_newline_position: int = req_str.find("\n") + 1
120
+ header = req_str[:first_newline_position]
121
+ req_str = req_str[first_newline_position:]
122
+
123
+ loop = asyncio.get_event_loop()
124
+ formatted_str = await loop.run_in_executor(
125
+ executor, partial(black.format_file_contents, req_str, fast=fast, mode=mode)
126
+ )
127
+
128
+ # Preserve CRLF line endings
129
+ nl = req_str.find("\n")
130
+ if nl > 0 and req_str[nl - 1] == "\r":
131
+ formatted_str = formatted_str.replace("\n", "\r\n")
132
+ # If, after swapping line endings, nothing changed, then say so
133
+ if formatted_str == req_str:
134
+ raise black.NothingChanged
135
+
136
+ # Put the source first line back
137
+ req_str = header + req_str
138
+ formatted_str = header + formatted_str
139
+
140
+ # Only output the diff in the HTTP response
141
+ only_diff = bool(request.headers.get(DIFF_HEADER, False))
142
+ if only_diff:
143
+ now = datetime.now(timezone.utc)
144
+ src_name = f"In\t{then}"
145
+ dst_name = f"Out\t{now}"
146
+ loop = asyncio.get_event_loop()
147
+ formatted_str = await loop.run_in_executor(
148
+ executor,
149
+ partial(black.diff, req_str, formatted_str, src_name, dst_name),
150
+ )
151
+
152
+ return web.Response(
153
+ content_type=request.content_type,
154
+ charset=charset,
155
+ headers=headers,
156
+ text=formatted_str,
157
+ )
158
+ except black.NothingChanged:
159
+ return web.Response(status=204, headers=headers)
160
+ except black.InvalidInput as e:
161
+ return web.Response(status=400, headers=headers, text=str(e))
162
+ except Exception as e:
163
+ logging.exception("Exception during handling a request")
164
+ return web.Response(status=500, headers=headers, text=str(e))
165
+
166
+
167
+ def parse_mode(headers: MultiMapping[str]) -> black.Mode:
168
+ try:
169
+ line_length = int(headers.get(LINE_LENGTH_HEADER, black.DEFAULT_LINE_LENGTH))
170
+ except ValueError:
171
+ raise HeaderError("Invalid line length header value") from None
172
+
173
+ if PYTHON_VARIANT_HEADER in headers:
174
+ value = headers[PYTHON_VARIANT_HEADER]
175
+ try:
176
+ pyi, versions = parse_python_variant_header(value)
177
+ except InvalidVariantHeader as e:
178
+ raise HeaderError(
179
+ f"Invalid value for {PYTHON_VARIANT_HEADER}: {e.args[0]}",
180
+ ) from None
181
+ else:
182
+ pyi = False
183
+ versions = set()
184
+
185
+ skip_string_normalization = bool(
186
+ headers.get(SKIP_STRING_NORMALIZATION_HEADER, False)
187
+ )
188
+ skip_magic_trailing_comma = bool(headers.get(SKIP_MAGIC_TRAILING_COMMA, False))
189
+ skip_source_first_line = bool(headers.get(SKIP_SOURCE_FIRST_LINE, False))
190
+
191
+ preview = bool(headers.get(PREVIEW, False))
192
+ unstable = bool(headers.get(UNSTABLE, False))
193
+ enable_features: set[black.Preview] = set()
194
+ enable_unstable_features = headers.get(ENABLE_UNSTABLE_FEATURE, "").split(",")
195
+ for piece in enable_unstable_features:
196
+ piece = piece.strip()
197
+ if piece:
198
+ try:
199
+ enable_features.add(black.Preview[piece])
200
+ except KeyError:
201
+ raise HeaderError(
202
+ f"Invalid value for {ENABLE_UNSTABLE_FEATURE}: {piece}",
203
+ ) from None
204
+
205
+ return black.FileMode(
206
+ target_versions=versions,
207
+ is_pyi=pyi,
208
+ line_length=line_length,
209
+ skip_source_first_line=skip_source_first_line,
210
+ string_normalization=not skip_string_normalization,
211
+ magic_trailing_comma=not skip_magic_trailing_comma,
212
+ preview=preview,
213
+ unstable=unstable,
214
+ enabled_features=enable_features,
215
+ )
216
+
217
+
218
+ def parse_python_variant_header(value: str) -> tuple[bool, set[black.TargetVersion]]:
219
+ if value == "pyi":
220
+ return True, set()
221
+ else:
222
+ versions = set()
223
+ for version in value.split(","):
224
+ if version.startswith("py"):
225
+ version = version[len("py") :]
226
+ if "." in version:
227
+ major_str, *rest = version.split(".")
228
+ else:
229
+ major_str = version[0]
230
+ rest = [version[1:]] if len(version) > 1 else []
231
+ try:
232
+ major = int(major_str)
233
+ if major not in (2, 3):
234
+ raise InvalidVariantHeader("major version must be 2 or 3")
235
+ if len(rest) > 0:
236
+ minor = int(rest[0])
237
+ if major == 2:
238
+ raise InvalidVariantHeader("Python 2 is not supported")
239
+ else:
240
+ # Default to lowest supported minor version.
241
+ minor = 7 if major == 2 else 3
242
+ version_str = f"PY{major}{minor}"
243
+ if major == 3 and not hasattr(black.TargetVersion, version_str):
244
+ raise InvalidVariantHeader(f"3.{minor} is not supported")
245
+ versions.add(black.TargetVersion[version_str])
246
+ except (KeyError, ValueError):
247
+ raise InvalidVariantHeader("expected e.g. '3.7', 'py3.5'") from None
248
+ return False, versions
249
+
250
+
251
+ def patched_main() -> None:
252
+ maybe_install_uvloop()
253
+ freeze_support()
254
+ main()
255
+
256
+
257
+ if __name__ == "__main__":
258
+ patched_main()
openflamingo/lib/python3.10/site-packages/blackd/__main__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ import blackd
2
+
3
+ blackd.patched_main()
openflamingo/lib/python3.10/site-packages/blackd/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (6.66 kB). View file
 
openflamingo/lib/python3.10/site-packages/blackd/__pycache__/__main__.cpython-310.pyc ADDED
Binary file (206 Bytes). View file
 
openflamingo/lib/python3.10/site-packages/blackd/__pycache__/middlewares.cpython-310.pyc ADDED
Binary file (1.24 kB). View file
 
openflamingo/lib/python3.10/site-packages/blackd/middlewares.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Awaitable, Callable, Iterable
2
+
3
+ from aiohttp.typedefs import Middleware
4
+ from aiohttp.web_middlewares import middleware
5
+ from aiohttp.web_request import Request
6
+ from aiohttp.web_response import StreamResponse
7
+
8
+ Handler = Callable[[Request], Awaitable[StreamResponse]]
9
+
10
+
11
+ def cors(allow_headers: Iterable[str]) -> Middleware:
12
+ @middleware
13
+ async def impl(request: Request, handler: Handler) -> StreamResponse:
14
+ is_options = request.method == "OPTIONS"
15
+ is_preflight = is_options and "Access-Control-Request-Method" in request.headers
16
+ if is_preflight:
17
+ resp = StreamResponse()
18
+ else:
19
+ resp = await handler(request)
20
+
21
+ origin = request.headers.get("Origin")
22
+ if not origin:
23
+ return resp
24
+
25
+ resp.headers["Access-Control-Allow-Origin"] = "*"
26
+ resp.headers["Access-Control-Expose-Headers"] = "*"
27
+ if is_options:
28
+ resp.headers["Access-Control-Allow-Headers"] = ", ".join(allow_headers)
29
+ resp.headers["Access-Control-Allow-Methods"] = ", ".join(
30
+ ("OPTIONS", "POST")
31
+ )
32
+
33
+ return resp
34
+
35
+ return impl
openflamingo/lib/python3.10/site-packages/blib2to3/LICENSE ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ A. HISTORY OF THE SOFTWARE
2
+ ==========================
3
+
4
+ Python was created in the early 1990s by Guido van Rossum at Stichting
5
+ Mathematisch Centrum (CWI, see https://www.cwi.nl) in the Netherlands
6
+ as a successor of a language called ABC. Guido remains Python's
7
+ principal author, although it includes many contributions from others.
8
+
9
+ In 1995, Guido continued his work on Python at the Corporation for
10
+ National Research Initiatives (CNRI, see https://www.cnri.reston.va.us)
11
+ in Reston, Virginia where he released several versions of the
12
+ software.
13
+
14
+ In May 2000, Guido and the Python core development team moved to
15
+ BeOpen.com to form the BeOpen PythonLabs team. In October of the same
16
+ year, the PythonLabs team moved to Digital Creations, which became
17
+ Zope Corporation. In 2001, the Python Software Foundation (PSF, see
18
+ https://www.python.org/psf/) was formed, a non-profit organization
19
+ created specifically to own Python-related Intellectual Property.
20
+ Zope Corporation was a sponsoring member of the PSF.
21
+
22
+ All Python releases are Open Source (see https://opensource.org for
23
+ the Open Source Definition). Historically, most, but not all, Python
24
+ releases have also been GPL-compatible; the table below summarizes
25
+ the various releases.
26
+
27
+ Release Derived Year Owner GPL-
28
+ from compatible? (1)
29
+
30
+ 0.9.0 thru 1.2 1991-1995 CWI yes
31
+ 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
32
+ 1.6 1.5.2 2000 CNRI no
33
+ 2.0 1.6 2000 BeOpen.com no
34
+ 1.6.1 1.6 2001 CNRI yes (2)
35
+ 2.1 2.0+1.6.1 2001 PSF no
36
+ 2.0.1 2.0+1.6.1 2001 PSF yes
37
+ 2.1.1 2.1+2.0.1 2001 PSF yes
38
+ 2.1.2 2.1.1 2002 PSF yes
39
+ 2.1.3 2.1.2 2002 PSF yes
40
+ 2.2 and above 2.1.1 2001-now PSF yes
41
+
42
+ Footnotes:
43
+
44
+ (1) GPL-compatible doesn't mean that we're distributing Python under
45
+ the GPL. All Python licenses, unlike the GPL, let you distribute
46
+ a modified version without making your changes open source. The
47
+ GPL-compatible licenses make it possible to combine Python with
48
+ other software that is released under the GPL; the others don't.
49
+
50
+ (2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
51
+ because its license has a choice of law clause. According to
52
+ CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
53
+ is "not incompatible" with the GPL.
54
+
55
+ Thanks to the many outside volunteers who have worked under Guido's
56
+ direction to make these releases possible.
57
+
58
+
59
+ B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
60
+ ===============================================================
61
+
62
+ PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
63
+ --------------------------------------------
64
+
65
+ 1. This LICENSE AGREEMENT is between the Python Software Foundation
66
+ ("PSF"), and the Individual or Organization ("Licensee") accessing and
67
+ otherwise using this software ("Python") in source or binary form and
68
+ its associated documentation.
69
+
70
+ 2. Subject to the terms and conditions of this License Agreement, PSF hereby
71
+ grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
72
+ analyze, test, perform and/or display publicly, prepare derivative works,
73
+ distribute, and otherwise use Python alone or in any derivative version,
74
+ provided, however, that PSF's License Agreement and PSF's notice of copyright,
75
+ i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
76
+ 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Python Software Foundation; All
77
+ Rights Reserved" are retained in Python alone or in any derivative version
78
+ prepared by Licensee.
79
+
80
+ 3. In the event Licensee prepares a derivative work that is based on
81
+ or incorporates Python or any part thereof, and wants to make
82
+ the derivative work available to others as provided herein, then
83
+ Licensee hereby agrees to include in any such work a brief summary of
84
+ the changes made to Python.
85
+
86
+ 4. PSF is making Python available to Licensee on an "AS IS"
87
+ basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
88
+ IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
89
+ DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
90
+ FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
91
+ INFRINGE ANY THIRD PARTY RIGHTS.
92
+
93
+ 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
94
+ FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
95
+ A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
96
+ OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
97
+
98
+ 6. This License Agreement will automatically terminate upon a material
99
+ breach of its terms and conditions.
100
+
101
+ 7. Nothing in this License Agreement shall be deemed to create any
102
+ relationship of agency, partnership, or joint venture between PSF and
103
+ Licensee. This License Agreement does not grant permission to use PSF
104
+ trademarks or trade name in a trademark sense to endorse or promote
105
+ products or services of Licensee, or any third party.
106
+
107
+ 8. By copying, installing or otherwise using Python, Licensee
108
+ agrees to be bound by the terms and conditions of this License
109
+ Agreement.
110
+
111
+
112
+ BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
113
+ -------------------------------------------
114
+
115
+ BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
116
+
117
+ 1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
118
+ office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
119
+ Individual or Organization ("Licensee") accessing and otherwise using
120
+ this software in source or binary form and its associated
121
+ documentation ("the Software").
122
+
123
+ 2. Subject to the terms and conditions of this BeOpen Python License
124
+ Agreement, BeOpen hereby grants Licensee a non-exclusive,
125
+ royalty-free, world-wide license to reproduce, analyze, test, perform
126
+ and/or display publicly, prepare derivative works, distribute, and
127
+ otherwise use the Software alone or in any derivative version,
128
+ provided, however, that the BeOpen Python License is retained in the
129
+ Software, alone or in any derivative version prepared by Licensee.
130
+
131
+ 3. BeOpen is making the Software available to Licensee on an "AS IS"
132
+ basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
133
+ IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
134
+ DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
135
+ FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
136
+ INFRINGE ANY THIRD PARTY RIGHTS.
137
+
138
+ 4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
139
+ SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
140
+ AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
141
+ DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
142
+
143
+ 5. This License Agreement will automatically terminate upon a material
144
+ breach of its terms and conditions.
145
+
146
+ 6. This License Agreement shall be governed by and interpreted in all
147
+ respects by the law of the State of California, excluding conflict of
148
+ law provisions. Nothing in this License Agreement shall be deemed to
149
+ create any relationship of agency, partnership, or joint venture
150
+ between BeOpen and Licensee. This License Agreement does not grant
151
+ permission to use BeOpen trademarks or trade names in a trademark
152
+ sense to endorse or promote products or services of Licensee, or any
153
+ third party. As an exception, the "BeOpen Python" logos available at
154
+ http://www.pythonlabs.com/logos.html may be used according to the
155
+ permissions granted on that web page.
156
+
157
+ 7. By copying, installing or otherwise using the software, Licensee
158
+ agrees to be bound by the terms and conditions of this License
159
+ Agreement.
160
+
161
+
162
+ CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
163
+ ---------------------------------------
164
+
165
+ 1. This LICENSE AGREEMENT is between the Corporation for National
166
+ Research Initiatives, having an office at 1895 Preston White Drive,
167
+ Reston, VA 20191 ("CNRI"), and the Individual or Organization
168
+ ("Licensee") accessing and otherwise using Python 1.6.1 software in
169
+ source or binary form and its associated documentation.
170
+
171
+ 2. Subject to the terms and conditions of this License Agreement, CNRI
172
+ hereby grants Licensee a nonexclusive, royalty-free, world-wide
173
+ license to reproduce, analyze, test, perform and/or display publicly,
174
+ prepare derivative works, distribute, and otherwise use Python 1.6.1
175
+ alone or in any derivative version, provided, however, that CNRI's
176
+ License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
177
+ 1995-2001 Corporation for National Research Initiatives; All Rights
178
+ Reserved" are retained in Python 1.6.1 alone or in any derivative
179
+ version prepared by Licensee. Alternately, in lieu of CNRI's License
180
+ Agreement, Licensee may substitute the following text (omitting the
181
+ quotes): "Python 1.6.1 is made available subject to the terms and
182
+ conditions in CNRI's License Agreement. This Agreement together with
183
+ Python 1.6.1 may be located on the Internet using the following
184
+ unique, persistent identifier (known as a handle): 1895.22/1013. This
185
+ Agreement may also be obtained from a proxy server on the Internet
186
+ using the following URL: http://hdl.handle.net/1895.22/1013".
187
+
188
+ 3. In the event Licensee prepares a derivative work that is based on
189
+ or incorporates Python 1.6.1 or any part thereof, and wants to make
190
+ the derivative work available to others as provided herein, then
191
+ Licensee hereby agrees to include in any such work a brief summary of
192
+ the changes made to Python 1.6.1.
193
+
194
+ 4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
195
+ basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
196
+ IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
197
+ DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
198
+ FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
199
+ INFRINGE ANY THIRD PARTY RIGHTS.
200
+
201
+ 5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
202
+ 1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
203
+ A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
204
+ OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
205
+
206
+ 6. This License Agreement will automatically terminate upon a material
207
+ breach of its terms and conditions.
208
+
209
+ 7. This License Agreement shall be governed by the federal
210
+ intellectual property law of the United States, including without
211
+ limitation the federal copyright law, and, to the extent such
212
+ U.S. federal law does not apply, by the law of the Commonwealth of
213
+ Virginia, excluding Virginia's conflict of law provisions.
214
+ Notwithstanding the foregoing, with regard to derivative works based
215
+ on Python 1.6.1 that incorporate non-separable material that was
216
+ previously distributed under the GNU General Public License (GPL), the
217
+ law of the Commonwealth of Virginia shall govern this License
218
+ Agreement only as to issues arising under or with respect to
219
+ Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
220
+ License Agreement shall be deemed to create any relationship of
221
+ agency, partnership, or joint venture between CNRI and Licensee. This
222
+ License Agreement does not grant permission to use CNRI trademarks or
223
+ trade name in a trademark sense to endorse or promote products or
224
+ services of Licensee, or any third party.
225
+
226
+ 8. By clicking on the "ACCEPT" button where indicated, or by copying,
227
+ installing or otherwise using Python 1.6.1, Licensee agrees to be
228
+ bound by the terms and conditions of this License Agreement.
229
+
230
+ ACCEPT
231
+
232
+
233
+ CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
234
+ --------------------------------------------------
235
+
236
+ Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
237
+ The Netherlands. All rights reserved.
238
+
239
+ Permission to use, copy, modify, and distribute this software and its
240
+ documentation for any purpose and without fee is hereby granted,
241
+ provided that the above copyright notice appear in all copies and that
242
+ both that copyright notice and this permission notice appear in
243
+ supporting documentation, and that the name of Stichting Mathematisch
244
+ Centrum or CWI not be used in advertising or publicity pertaining to
245
+ distribution of the software without specific, written prior
246
+ permission.
247
+
248
+ STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
249
+ THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
250
+ FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
251
+ FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
252
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
253
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
254
+ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
openflamingo/lib/python3.10/site-packages/blib2to3/README ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ A subset of lib2to3 taken from Python 3.7.0b2. Commit hash:
2
+ 9c17e3a1987004b8bcfbe423953aad84493a7984
3
+
4
+ Reasons for forking:
5
+
6
+ - consistent handling of f-strings for users of Python < 3.6.2
7
+ - backport of BPO-33064 that fixes parsing files with trailing commas after \*args and
8
+ \*\*kwargs
9
+ - backport of GH-6143 that restores the ability to reformat legacy usage of `async`
10
+ - support all types of string literals
11
+ - better ability to debug (better reprs)
12
+ - INDENT and DEDENT don't hold whitespace and comment prefixes
13
+ - ability to Cythonize
14
+
15
+ Change Log:
16
+
17
+ - Changes default logger used by Driver
18
+ - Backported the following upstream parser changes:
19
+ - "bpo-42381: Allow walrus in set literals and set comprehensions (GH-23332)"
20
+ https://github.com/python/cpython/commit/cae60187cf7a7b26281d012e1952fafe4e2e97e9
21
+ - "bpo-42316: Allow unparenthesized walrus operator in indexes (GH-23317)"
22
+ https://github.com/python/cpython/commit/b0aba1fcdc3da952698d99aec2334faa79a8b68c
23
+ - Tweaks to help mypyc compile faster code (including inlining type information,
24
+ "Final-ing", etc.)
openflamingo/lib/python3.10/site-packages/blib2to3/pygram.cpython-310-x86_64-linux-gnu.so ADDED
Binary file (8.42 kB). View file
 
openflamingo/lib/python3.10/site-packages/blib2to3/pytree.cpython-310-x86_64-linux-gnu.so ADDED
Binary file (8.42 kB). View file
 
openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/METADATA ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: docker-pycreds
3
+ Version: 0.4.0
4
+ Summary: Python bindings for the docker credentials store API
5
+ Home-page: https://github.com/shin-/dockerpy-creds
6
+ Author: UNKNOWN
7
+ Author-email: UNKNOWN
8
+ License: Apache License 2.0
9
+ Platform: UNKNOWN
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Other Environment
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python
15
+ Classifier: Programming Language :: Python :: 2
16
+ Classifier: Programming Language :: Python :: 2.6
17
+ Classifier: Programming Language :: Python :: 2.7
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.3
20
+ Classifier: Programming Language :: Python :: 3.4
21
+ Classifier: Programming Language :: Python :: 3.5
22
+ Classifier: Programming Language :: Python :: 3.6
23
+ Classifier: Topic :: Utilities
24
+ Classifier: License :: OSI Approved :: Apache Software License
25
+ Requires-Dist: six (>=1.4.0)
26
+
27
+ # docker-pycreds
28
+
29
+ [![CircleCI](https://circleci.com/gh/shin-/dockerpy-creds/tree/master.svg?style=svg)](https://circleci.com/gh/shin-/dockerpy-creds/tree/master)
30
+
31
+ Python bindings for the docker credentials store API
32
+
33
+ ## Credentials store info
34
+
35
+ [Docker documentation page](https://docs.docker.com/engine/reference/commandline/login/#/credentials-store)
36
+
37
+ ## Requirements
38
+
39
+ On top of the dependencies in `requirements.txt`, the `docker-credential`
40
+ executable for the platform must be installed on the user's system.
41
+
42
+ ## API usage
43
+
44
+ ```python
45
+
46
+ import dockerpycreds
47
+
48
+ store = dockerpycreds.Store('secretservice')
49
+ store.store(
50
+ server='https://index.docker.io/v1/', username='johndoe',
51
+ secret='hunter2'
52
+ )
53
+
54
+ print(store.list())
55
+
56
+ print(store.get('https://index.docker.io/v1/'))
57
+
58
+
59
+ store.erase('https://index.docker.io/v1/')
60
+ ```
61
+
62
+
openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/RECORD ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ docker_pycreds-0.4.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ docker_pycreds-0.4.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
3
+ docker_pycreds-0.4.0.dist-info/METADATA,sha256=FOmAKPL9hzMoIGVedpB45WzPyJmvEqUPoWIWElf5S18,1821
4
+ docker_pycreds-0.4.0.dist-info/RECORD,,
5
+ docker_pycreds-0.4.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ docker_pycreds-0.4.0.dist-info/WHEEL,sha256=CihQvCnsGZQBGAHLEUMf0IdA4fRduS_NBUTMgCTtvPM,110
7
+ docker_pycreds-0.4.0.dist-info/top_level.txt,sha256=iHN9Ul5VnNovfI4c7fel4nGnEtE4BezC_IQ8_3meRVw,14
8
+ dockerpycreds/__init__.py,sha256=vdD-zY6geCywLcpf8Naplshb5a5dc8czaWtbL7VdEDE,116
9
+ dockerpycreds/__pycache__/__init__.cpython-310.pyc,,
10
+ dockerpycreds/__pycache__/constants.cpython-310.pyc,,
11
+ dockerpycreds/__pycache__/errors.cpython-310.pyc,,
12
+ dockerpycreds/__pycache__/store.cpython-310.pyc,,
13
+ dockerpycreds/__pycache__/utils.cpython-310.pyc,,
14
+ dockerpycreds/__pycache__/version.cpython-310.pyc,,
15
+ dockerpycreds/constants.py,sha256=5HjRGorpVvkamvLBI9yLPvur1E0glaq_ZhuRfbVA_bE,142
16
+ dockerpycreds/errors.py,sha256=ghtvHruuU_wK_f90fnoep-yoVNx4t-OpYrB84v2yHjg,576
17
+ dockerpycreds/store.py,sha256=uTjPxLKzqWanbCWe7fGVJyZX9PKv6QRE5omRSz6J4qE,3799
18
+ dockerpycreds/utils.py,sha256=_ErlaAETnJEvPbBRdrLKBzKCB37eH0uncCdBySPIIKo,1020
19
+ dockerpycreds/version.py,sha256=G-VpNfv2NAp81lTH0IeEq1qv9H2RSJW_Bn2UuwqxF_M,91
openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/REQUESTED ADDED
File without changes
openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/WHEEL ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.32.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py2-none-any
5
+ Tag: py3-none-any
6
+
openflamingo/lib/python3.10/site-packages/docker_pycreds-0.4.0.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ dockerpycreds
openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/License.txt ADDED
@@ -0,0 +1,1568 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ End User License Agreement
2
+ --------------------------
3
+
4
+
5
+ Preface
6
+ -------
7
+
8
+ The Software License Agreement in Chapter 1 and the Supplement
9
+ in Chapter 2 contain license terms and conditions that govern
10
+ the use of NVIDIA software. By accepting this agreement, you
11
+ agree to comply with all the terms and conditions applicable
12
+ to the product(s) included herein.
13
+
14
+
15
+ NVIDIA Driver
16
+
17
+
18
+ Description
19
+
20
+ This package contains the operating system driver and
21
+ fundamental system software components for NVIDIA GPUs.
22
+
23
+
24
+ NVIDIA CUDA Toolkit
25
+
26
+
27
+ Description
28
+
29
+ The NVIDIA CUDA Toolkit provides command-line and graphical
30
+ tools for building, debugging and optimizing the performance
31
+ of applications accelerated by NVIDIA GPUs, runtime and math
32
+ libraries, and documentation including programming guides,
33
+ user manuals, and API references.
34
+
35
+
36
+ Default Install Location of CUDA Toolkit
37
+
38
+ Windows platform:
39
+
40
+ %ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v#.#
41
+
42
+ Linux platform:
43
+
44
+ /usr/local/cuda-#.#
45
+
46
+ Mac platform:
47
+
48
+ /Developer/NVIDIA/CUDA-#.#
49
+
50
+
51
+ NVIDIA CUDA Samples
52
+
53
+
54
+ Description
55
+
56
+ This package includes over 100+ CUDA examples that demonstrate
57
+ various CUDA programming principles, and efficient CUDA
58
+ implementation of algorithms in specific application domains.
59
+
60
+
61
+ Default Install Location of CUDA Samples
62
+
63
+ Windows platform:
64
+
65
+ %ProgramData%\NVIDIA Corporation\CUDA Samples\v#.#
66
+
67
+ Linux platform:
68
+
69
+ /usr/local/cuda-#.#/samples
70
+
71
+ and
72
+
73
+ $HOME/NVIDIA_CUDA-#.#_Samples
74
+
75
+ Mac platform:
76
+
77
+ /Developer/NVIDIA/CUDA-#.#/samples
78
+
79
+
80
+ NVIDIA Nsight Visual Studio Edition (Windows only)
81
+
82
+
83
+ Description
84
+
85
+ NVIDIA Nsight Development Platform, Visual Studio Edition is a
86
+ development environment integrated into Microsoft Visual
87
+ Studio that provides tools for debugging, profiling, analyzing
88
+ and optimizing your GPU computing and graphics applications.
89
+
90
+
91
+ Default Install Location of Nsight Visual Studio Edition
92
+
93
+ Windows platform:
94
+
95
+ %ProgramFiles(x86)%\NVIDIA Corporation\Nsight Visual Studio Edition #.#
96
+
97
+
98
+ 1. License Agreement for NVIDIA Software Development Kits
99
+ ---------------------------------------------------------
100
+
101
+
102
+ Release Date: July 26, 2018
103
+ ---------------------------
104
+
105
+
106
+ Important NoticeRead before downloading, installing,
107
+ copying or using the licensed software:
108
+ -------------------------------------------------------
109
+
110
+ This license agreement, including exhibits attached
111
+ ("Agreement”) is a legal agreement between you and NVIDIA
112
+ Corporation ("NVIDIA") and governs your use of a NVIDIA
113
+ software development kit (“SDK”).
114
+
115
+ Each SDK has its own set of software and materials, but here
116
+ is a description of the types of items that may be included in
117
+ a SDK: source code, header files, APIs, data sets and assets
118
+ (examples include images, textures, models, scenes, videos,
119
+ native API input/output files), binary software, sample code,
120
+ libraries, utility programs, programming code and
121
+ documentation.
122
+
123
+ This Agreement can be accepted only by an adult of legal age
124
+ of majority in the country in which the SDK is used.
125
+
126
+ If you are entering into this Agreement on behalf of a company
127
+ or other legal entity, you represent that you have the legal
128
+ authority to bind the entity to this Agreement, in which case
129
+ “you” will mean the entity you represent.
130
+
131
+ If you don’t have the required age or authority to accept
132
+ this Agreement, or if you don’t accept all the terms and
133
+ conditions of this Agreement, do not download, install or use
134
+ the SDK.
135
+
136
+ You agree to use the SDK only for purposes that are permitted
137
+ by (a) this Agreement, and (b) any applicable law, regulation
138
+ or generally accepted practices or guidelines in the relevant
139
+ jurisdictions.
140
+
141
+
142
+ 1.1. License
143
+
144
+
145
+ 1.1.1. License Grant
146
+
147
+ Subject to the terms of this Agreement, NVIDIA hereby grants
148
+ you a non-exclusive, non-transferable license, without the
149
+ right to sublicense (except as expressly provided in this
150
+ Agreement) to:
151
+
152
+ 1. Install and use the SDK,
153
+
154
+ 2. Modify and create derivative works of sample source code
155
+ delivered in the SDK, and
156
+
157
+ 3. Distribute those portions of the SDK that are identified
158
+ in this Agreement as distributable, as incorporated in
159
+ object code format into a software application that meets
160
+ the distribution requirements indicated in this Agreement.
161
+
162
+
163
+ 1.1.2. Distribution Requirements
164
+
165
+ These are the distribution requirements for you to exercise
166
+ the distribution grant:
167
+
168
+ 1. Your application must have material additional
169
+ functionality, beyond the included portions of the SDK.
170
+
171
+ 2. The distributable portions of the SDK shall only be
172
+ accessed by your application.
173
+
174
+ 3. The following notice shall be included in modifications
175
+ and derivative works of sample source code distributed:
176
+ “This software contains source code provided by NVIDIA
177
+ Corporation.”
178
+
179
+ 4. Unless a developer tool is identified in this Agreement
180
+ as distributable, it is delivered for your internal use
181
+ only.
182
+
183
+ 5. The terms under which you distribute your application
184
+ must be consistent with the terms of this Agreement,
185
+ including (without limitation) terms relating to the
186
+ license grant and license restrictions and protection of
187
+ NVIDIA’s intellectual property rights. Additionally, you
188
+ agree that you will protect the privacy, security and
189
+ legal rights of your application users.
190
+
191
+ 6. You agree to notify NVIDIA in writing of any known or
192
+ suspected distribution or use of the SDK not in compliance
193
+ with the requirements of this Agreement, and to enforce
194
+ the terms of your agreements with respect to distributed
195
+ SDK.
196
+
197
+
198
+ 1.1.3. Authorized Users
199
+
200
+ You may allow employees and contractors of your entity or of
201
+ your subsidiary(ies) to access and use the SDK from your
202
+ secure network to perform work on your behalf.
203
+
204
+ If you are an academic institution you may allow users
205
+ enrolled or employed by the academic institution to access and
206
+ use the SDK from your secure network.
207
+
208
+ You are responsible for the compliance with the terms of this
209
+ Agreement by your authorized users. If you become aware that
210
+ your authorized users didn’t follow the terms of this
211
+ Agreement, you agree to take reasonable steps to resolve the
212
+ non-compliance and prevent new occurrences.
213
+
214
+
215
+ 1.1.4. Pre-Release SDK
216
+
217
+ The SDK versions identified as alpha, beta, preview or
218
+ otherwise as pre-release, may not be fully functional, may
219
+ contain errors or design flaws, and may have reduced or
220
+ different security, privacy, accessibility, availability, and
221
+ reliability standards relative to commercial versions of
222
+ NVIDIA software and materials. Use of a pre-release SDK may
223
+ result in unexpected results, loss of data, project delays or
224
+ other unpredictable damage or loss.
225
+
226
+ You may use a pre-release SDK at your own risk, understanding
227
+ that pre-release SDKs are not intended for use in production
228
+ or business-critical systems.
229
+
230
+ NVIDIA may choose not to make available a commercial version
231
+ of any pre-release SDK. NVIDIA may also choose to abandon
232
+ development and terminate the availability of a pre-release
233
+ SDK at any time without liability.
234
+
235
+
236
+ 1.1.5. Updates
237
+
238
+ NVIDIA may, at its option, make available patches, workarounds
239
+ or other updates to this SDK. Unless the updates are provided
240
+ with their separate governing terms, they are deemed part of
241
+ the SDK licensed to you as provided in this Agreement. You
242
+ agree that the form and content of the SDK that NVIDIA
243
+ provides may change without prior notice to you. While NVIDIA
244
+ generally maintains compatibility between versions, NVIDIA may
245
+ in some cases make changes that introduce incompatibilities in
246
+ future versions of the SDK.
247
+
248
+
249
+ 1.1.6. Third Party Licenses
250
+
251
+ The SDK may come bundled with, or otherwise include or be
252
+ distributed with, third party software licensed by a NVIDIA
253
+ supplier and/or open source software provided under an open
254
+ source license. Use of third party software is subject to the
255
+ third-party license terms, or in the absence of third party
256
+ terms, the terms of this Agreement. Copyright to third party
257
+ software is held by the copyright holders indicated in the
258
+ third-party software or license.
259
+
260
+
261
+ 1.1.7. Reservation of Rights
262
+
263
+ NVIDIA reserves all rights, title, and interest in and to the
264
+ SDK, not expressly granted to you under this Agreement.
265
+
266
+
267
+ 1.2. Limitations
268
+
269
+ The following license limitations apply to your use of the
270
+ SDK:
271
+
272
+ 1. You may not reverse engineer, decompile or disassemble,
273
+ or remove copyright or other proprietary notices from any
274
+ portion of the SDK or copies of the SDK.
275
+
276
+ 2. Except as expressly provided in this Agreement, you may
277
+ not copy, sell, rent, sublicense, transfer, distribute,
278
+ modify, or create derivative works of any portion of the
279
+ SDK. For clarity, you may not distribute or sublicense the
280
+ SDK as a stand-alone product.
281
+
282
+ 3. Unless you have an agreement with NVIDIA for this
283
+ purpose, you may not indicate that an application created
284
+ with the SDK is sponsored or endorsed by NVIDIA.
285
+
286
+ 4. You may not bypass, disable, or circumvent any
287
+ encryption, security, digital rights management or
288
+ authentication mechanism in the SDK.
289
+
290
+ 5. You may not use the SDK in any manner that would cause it
291
+ to become subject to an open source software license. As
292
+ examples, licenses that require as a condition of use,
293
+ modification, and/or distribution that the SDK be:
294
+
295
+ a. Disclosed or distributed in source code form;
296
+
297
+ b. Licensed for the purpose of making derivative works;
298
+ or
299
+
300
+ c. Redistributable at no charge.
301
+
302
+ 6. Unless you have an agreement with NVIDIA for this
303
+ purpose, you may not use the SDK with any system or
304
+ application where the use or failure of the system or
305
+ application can reasonably be expected to threaten or
306
+ result in personal injury, death, or catastrophic loss.
307
+ Examples include use in avionics, navigation, military,
308
+ medical, life support or other life critical applications.
309
+ NVIDIA does not design, test or manufacture the SDK for
310
+ these critical uses and NVIDIA shall not be liable to you
311
+ or any third party, in whole or in part, for any claims or
312
+ damages arising from such uses.
313
+
314
+ 7. You agree to defend, indemnify and hold harmless NVIDIA
315
+ and its affiliates, and their respective employees,
316
+ contractors, agents, officers and directors, from and
317
+ against any and all claims, damages, obligations, losses,
318
+ liabilities, costs or debt, fines, restitutions and
319
+ expenses (including but not limited to attorney’s fees
320
+ and costs incident to establishing the right of
321
+ indemnification) arising out of or related to your use of
322
+ the SDK outside of the scope of this Agreement, or not in
323
+ compliance with its terms.
324
+
325
+
326
+ 1.3. Ownership
327
+
328
+ 1. NVIDIA or its licensors hold all rights, title and
329
+ interest in and to the SDK and its modifications and
330
+ derivative works, including their respective intellectual
331
+ property rights, subject to your rights described in this
332
+ section. This SDK may include software and materials from
333
+ NVIDIA’s licensors, and these licensors are intended
334
+ third party beneficiaries that may enforce this Agreement
335
+ with respect to their intellectual property rights.
336
+
337
+ 2. You hold all rights, title and interest in and to your
338
+ applications and your derivative works of the sample
339
+ source code delivered in the SDK, including their
340
+ respective intellectual property rights, subject to
341
+ NVIDIA’s rights described in this section.
342
+
343
+ 3. You may, but don’t have to, provide to NVIDIA
344
+ suggestions, feature requests or other feedback regarding
345
+ the SDK, including possible enhancements or modifications
346
+ to the SDK. For any feedback that you voluntarily provide,
347
+ you hereby grant NVIDIA and its affiliates a perpetual,
348
+ non-exclusive, worldwide, irrevocable license to use,
349
+ reproduce, modify, license, sublicense (through multiple
350
+ tiers of sublicensees), and distribute (through multiple
351
+ tiers of distributors) it without the payment of any
352
+ royalties or fees to you. NVIDIA will use feedback at its
353
+ choice. NVIDIA is constantly looking for ways to improve
354
+ its products, so you may send feedback to NVIDIA through
355
+ the developer portal at https://developer.nvidia.com.
356
+
357
+
358
+ 1.4. No Warranties
359
+
360
+ THE SDK IS PROVIDED BY NVIDIA “AS IS” AND “WITH ALL
361
+ FAULTS.” TO THE MAXIMUM EXTENT PERMITTED BY LAW, NVIDIA AND
362
+ ITS AFFILIATES EXPRESSLY DISCLAIM ALL WARRANTIES OF ANY KIND
363
+ OR NATURE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING,
364
+ BUT NOT LIMITED TO, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
365
+ FOR A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, OR THE
366
+ ABSENCE OF ANY DEFECTS THEREIN, WHETHER LATENT OR PATENT. NO
367
+ WARRANTY IS MADE ON THE BASIS OF TRADE USAGE, COURSE OF
368
+ DEALING OR COURSE OF TRADE.
369
+
370
+
371
+ 1.5. Limitation of Liability
372
+
373
+ TO THE MAXIMUM EXTENT PERMITTED BY LAW, NVIDIA AND ITS
374
+ AFFILIATES SHALL NOT BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
375
+ PUNITIVE OR CONSEQUENTIAL DAMAGES, OR ANY LOST PROFITS, LOSS
376
+ OF USE, LOSS OF DATA OR LOSS OF GOODWILL, OR THE COSTS OF
377
+ PROCURING SUBSTITUTE PRODUCTS, ARISING OUT OF OR IN CONNECTION
378
+ WITH THIS AGREEMENT OR THE USE OR PERFORMANCE OF THE SDK,
379
+ WHETHER SUCH LIABILITY ARISES FROM ANY CLAIM BASED UPON BREACH
380
+ OF CONTRACT, BREACH OF WARRANTY, TORT (INCLUDING NEGLIGENCE),
381
+ PRODUCT LIABILITY OR ANY OTHER CAUSE OF ACTION OR THEORY OF
382
+ LIABILITY. IN NO EVENT WILL NVIDIA’S AND ITS AFFILIATES
383
+ TOTAL CUMULATIVE LIABILITY UNDER OR ARISING OUT OF THIS
384
+ AGREEMENT EXCEED US$10.00. THE NATURE OF THE LIABILITY OR THE
385
+ NUMBER OF CLAIMS OR SUITS SHALL NOT ENLARGE OR EXTEND THIS
386
+ LIMIT.
387
+
388
+ These exclusions and limitations of liability shall apply
389
+ regardless if NVIDIA or its affiliates have been advised of
390
+ the possibility of such damages, and regardless of whether a
391
+ remedy fails its essential purpose. These exclusions and
392
+ limitations of liability form an essential basis of the
393
+ bargain between the parties, and, absent any of these
394
+ exclusions or limitations of liability, the provisions of this
395
+ Agreement, including, without limitation, the economic terms,
396
+ would be substantially different.
397
+
398
+
399
+ 1.6. Termination
400
+
401
+ 1. This Agreement will continue to apply until terminated by
402
+ either you or NVIDIA as described below.
403
+
404
+ 2. If you want to terminate this Agreement, you may do so by
405
+ stopping to use the SDK.
406
+
407
+ 3. NVIDIA may, at any time, terminate this Agreement if:
408
+
409
+ a. (i) you fail to comply with any term of this
410
+ Agreement and the non-compliance is not fixed within
411
+ thirty (30) days following notice from NVIDIA (or
412
+ immediately if you violate NVIDIA’s intellectual
413
+ property rights);
414
+
415
+ b. (ii) you commence or participate in any legal
416
+ proceeding against NVIDIA with respect to the SDK; or
417
+
418
+ c. (iii) NVIDIA decides to no longer provide the SDK in
419
+ a country or, in NVIDIA’s sole discretion, the
420
+ continued use of it is no longer commercially viable.
421
+
422
+ 4. Upon any termination of this Agreement, you agree to
423
+ promptly discontinue use of the SDK and destroy all copies
424
+ in your possession or control. Your prior distributions in
425
+ accordance with this Agreement are not affected by the
426
+ termination of this Agreement. Upon written request, you
427
+ will certify in writing that you have complied with your
428
+ commitments under this section. Upon any termination of
429
+ this Agreement all provisions survive except for the
430
+ license grant provisions.
431
+
432
+
433
+ 1.7. General
434
+
435
+ If you wish to assign this Agreement or your rights and
436
+ obligations, including by merger, consolidation, dissolution
437
+ or operation of law, contact NVIDIA to ask for permission. Any
438
+ attempted assignment not approved by NVIDIA in writing shall
439
+ be void and of no effect. NVIDIA may assign, delegate or
440
+ transfer this Agreement and its rights and obligations, and if
441
+ to a non-affiliate you will be notified.
442
+
443
+ You agree to cooperate with NVIDIA and provide reasonably
444
+ requested information to verify your compliance with this
445
+ Agreement.
446
+
447
+ This Agreement will be governed in all respects by the laws of
448
+ the United States and of the State of Delaware as those laws
449
+ are applied to contracts entered into and performed entirely
450
+ within Delaware by Delaware residents, without regard to the
451
+ conflicts of laws principles. The United Nations Convention on
452
+ Contracts for the International Sale of Goods is specifically
453
+ disclaimed. You agree to all terms of this Agreement in the
454
+ English language.
455
+
456
+ The state or federal courts residing in Santa Clara County,
457
+ California shall have exclusive jurisdiction over any dispute
458
+ or claim arising out of this Agreement. Notwithstanding this,
459
+ you agree that NVIDIA shall still be allowed to apply for
460
+ injunctive remedies or an equivalent type of urgent legal
461
+ relief in any jurisdiction.
462
+
463
+ If any court of competent jurisdiction determines that any
464
+ provision of this Agreement is illegal, invalid or
465
+ unenforceable, such provision will be construed as limited to
466
+ the extent necessary to be consistent with and fully
467
+ enforceable under the law and the remaining provisions will
468
+ remain in full force and effect. Unless otherwise specified,
469
+ remedies are cumulative.
470
+
471
+ Each party acknowledges and agrees that the other is an
472
+ independent contractor in the performance of this Agreement.
473
+
474
+ The SDK has been developed entirely at private expense and is
475
+ “commercial items” consisting of “commercial computer
476
+ software” and “commercial computer software
477
+ documentation” provided with RESTRICTED RIGHTS. Use,
478
+ duplication or disclosure by the U.S. Government or a U.S.
479
+ Government subcontractor is subject to the restrictions in
480
+ this Agreement pursuant to DFARS 227.7202-3(a) or as set forth
481
+ in subparagraphs (c)(1) and (2) of the Commercial Computer
482
+ Software - Restricted Rights clause at FAR 52.227-19, as
483
+ applicable. Contractor/manufacturer is NVIDIA, 2788 San Tomas
484
+ Expressway, Santa Clara, CA 95051.
485
+
486
+ The SDK is subject to United States export laws and
487
+ regulations. You agree that you will not ship, transfer or
488
+ export the SDK into any country, or use the SDK in any manner,
489
+ prohibited by the United States Bureau of Industry and
490
+ Security or economic sanctions regulations administered by the
491
+ U.S. Department of Treasury’s Office of Foreign Assets
492
+ Control (OFAC), or any applicable export laws, restrictions or
493
+ regulations. These laws include restrictions on destinations,
494
+ end users and end use. By accepting this Agreement, you
495
+ confirm that you are not a resident or citizen of any country
496
+ currently embargoed by the U.S. and that you are not otherwise
497
+ prohibited from receiving the SDK.
498
+
499
+ Any notice delivered by NVIDIA to you under this Agreement
500
+ will be delivered via mail, email or fax. You agree that any
501
+ notices that NVIDIA sends you electronically will satisfy any
502
+ legal communication requirements. Please direct your legal
503
+ notices or other correspondence to NVIDIA Corporation, 2788
504
+ San Tomas Expressway, Santa Clara, California 95051, United
505
+ States of America, Attention: Legal Department.
506
+
507
+ This Agreement and any exhibits incorporated into this
508
+ Agreement constitute the entire agreement of the parties with
509
+ respect to the subject matter of this Agreement and supersede
510
+ all prior negotiations or documentation exchanged between the
511
+ parties relating to this SDK license. Any additional and/or
512
+ conflicting terms on documents issued by you are null, void,
513
+ and invalid. Any amendment or waiver under this Agreement
514
+ shall be in writing and signed by representatives of both
515
+ parties.
516
+
517
+
518
+ 2. CUDA Toolkit Supplement to Software License Agreement for
519
+ NVIDIA Software Development Kits
520
+ ------------------------------------------------------------
521
+
522
+
523
+ Release date: August 16, 2018
524
+ -----------------------------
525
+
526
+ The terms in this supplement govern your use of the NVIDIA
527
+ CUDA Toolkit SDK under the terms of your license agreement
528
+ (“Agreement”) as modified by this supplement. Capitalized
529
+ terms used but not defined below have the meaning assigned to
530
+ them in the Agreement.
531
+
532
+ This supplement is an exhibit to the Agreement and is
533
+ incorporated as an integral part of the Agreement. In the
534
+ event of conflict between the terms in this supplement and the
535
+ terms in the Agreement, the terms in this supplement govern.
536
+
537
+
538
+ 2.1. License Scope
539
+
540
+ The SDK is licensed for you to develop applications only for
541
+ use in systems with NVIDIA GPUs.
542
+
543
+
544
+ 2.2. Distribution
545
+
546
+ The portions of the SDK that are distributable under the
547
+ Agreement are listed in Attachment A.
548
+
549
+
550
+ 2.3. Operating Systems
551
+
552
+ Those portions of the SDK designed exclusively for use on the
553
+ Linux or FreeBSD operating systems, or other operating systems
554
+ derived from the source code to these operating systems, may
555
+ be copied and redistributed for use in accordance with this
556
+ Agreement, provided that the object code files are not
557
+ modified in any way (except for unzipping of compressed
558
+ files).
559
+
560
+
561
+ 2.4. Audio and Video Encoders and Decoders
562
+
563
+ You acknowledge and agree that it is your sole responsibility
564
+ to obtain any additional third-party licenses required to
565
+ make, have made, use, have used, sell, import, and offer for
566
+ sale your products or services that include or incorporate any
567
+ third-party software and content relating to audio and/or
568
+ video encoders and decoders from, including but not limited
569
+ to, Microsoft, Thomson, Fraunhofer IIS, Sisvel S.p.A.,
570
+ MPEG-LA, and Coding Technologies. NVIDIA does not grant to you
571
+ under this Agreement any necessary patent or other rights with
572
+ respect to any audio and/or video encoders and decoders.
573
+
574
+
575
+ 2.5. Licensing
576
+
577
+ If the distribution terms in this Agreement are not suitable
578
+ for your organization, or for any questions regarding this
579
+ Agreement, please contact NVIDIA at
580
+ nvidia-compute-license-questions@nvidia.com.
581
+
582
+
583
+ 2.6. Attachment A
584
+
585
+ The following portions of the SDK are distributable under the
586
+ Agreement:
587
+
588
+ Component
589
+
590
+ CUDA Runtime
591
+
592
+ Windows
593
+
594
+ cudart.dll, cudart_static.lib, cudadevrt.lib
595
+
596
+ Mac OSX
597
+
598
+ libcudart.dylib, libcudart_static.a, libcudadevrt.a
599
+
600
+ Linux
601
+
602
+ libcudart.so, libcudart_static.a, libcudadevrt.a
603
+
604
+ Android
605
+
606
+ libcudart.so, libcudart_static.a, libcudadevrt.a
607
+
608
+ Component
609
+
610
+ CUDA FFT Library
611
+
612
+ Windows
613
+
614
+ cufft.dll, cufftw.dll, cufft.lib, cufftw.lib
615
+
616
+ Mac OSX
617
+
618
+ libcufft.dylib, libcufft_static.a, libcufftw.dylib,
619
+ libcufftw_static.a
620
+
621
+ Linux
622
+
623
+ libcufft.so, libcufft_static.a, libcufftw.so,
624
+ libcufftw_static.a
625
+
626
+ Android
627
+
628
+ libcufft.so, libcufft_static.a, libcufftw.so,
629
+ libcufftw_static.a
630
+
631
+ Component
632
+
633
+ CUDA BLAS Library
634
+
635
+ Windows
636
+
637
+ cublas.dll, cublasLt.dll
638
+
639
+ Mac OSX
640
+
641
+ libcublas.dylib, libcublasLt.dylib, libcublas_static.a,
642
+ libcublasLt_static.a
643
+
644
+ Linux
645
+
646
+ libcublas.so, libcublasLt.so, libcublas_static.a,
647
+ libcublasLt_static.a
648
+
649
+ Android
650
+
651
+ libcublas.so, libcublasLt.so, libcublas_static.a,
652
+ libcublasLt_static.a
653
+
654
+ Component
655
+
656
+ NVIDIA "Drop-in" BLAS Library
657
+
658
+ Windows
659
+
660
+ nvblas.dll
661
+
662
+ Mac OSX
663
+
664
+ libnvblas.dylib
665
+
666
+ Linux
667
+
668
+ libnvblas.so
669
+
670
+ Component
671
+
672
+ CUDA Sparse Matrix Library
673
+
674
+ Windows
675
+
676
+ cusparse.dll, cusparse.lib
677
+
678
+ Mac OSX
679
+
680
+ libcusparse.dylib, libcusparse_static.a
681
+
682
+ Linux
683
+
684
+ libcusparse.so, libcusparse_static.a
685
+
686
+ Android
687
+
688
+ libcusparse.so, libcusparse_static.a
689
+
690
+ Component
691
+
692
+ CUDA Linear Solver Library
693
+
694
+ Windows
695
+
696
+ cusolver.dll, cusolver.lib
697
+
698
+ Mac OSX
699
+
700
+ libcusolver.dylib, libcusolver_static.a
701
+
702
+ Linux
703
+
704
+ libcusolver.so, libcusolver_static.a
705
+
706
+ Android
707
+
708
+ libcusolver.so, libcusolver_static.a
709
+
710
+ Component
711
+
712
+ CUDA Random Number Generation Library
713
+
714
+ Windows
715
+
716
+ curand.dll, curand.lib
717
+
718
+ Mac OSX
719
+
720
+ libcurand.dylib, libcurand_static.a
721
+
722
+ Linux
723
+
724
+ libcurand.so, libcurand_static.a
725
+
726
+ Android
727
+
728
+ libcurand.so, libcurand_static.a
729
+
730
+ Component
731
+
732
+ CUDA Accelerated Graph Library
733
+
734
+ Component
735
+
736
+ NVIDIA Performance Primitives Library
737
+
738
+ Windows
739
+
740
+ nppc.dll, nppc.lib, nppial.dll, nppial.lib, nppicc.dll,
741
+ nppicc.lib, nppicom.dll, nppicom.lib, nppidei.dll,
742
+ nppidei.lib, nppif.dll, nppif.lib, nppig.dll, nppig.lib,
743
+ nppim.dll, nppim.lib, nppist.dll, nppist.lib, nppisu.dll,
744
+ nppisu.lib, nppitc.dll, nppitc.lib, npps.dll, npps.lib
745
+
746
+ Mac OSX
747
+
748
+ libnppc.dylib, libnppc_static.a, libnppial.dylib,
749
+ libnppial_static.a, libnppicc.dylib, libnppicc_static.a,
750
+ libnppicom.dylib, libnppicom_static.a, libnppidei.dylib,
751
+ libnppidei_static.a, libnppif.dylib, libnppif_static.a,
752
+ libnppig.dylib, libnppig_static.a, libnppim.dylib,
753
+ libnppisu_static.a, libnppitc.dylib, libnppitc_static.a,
754
+ libnpps.dylib, libnpps_static.a
755
+
756
+ Linux
757
+
758
+ libnppc.so, libnppc_static.a, libnppial.so,
759
+ libnppial_static.a, libnppicc.so, libnppicc_static.a,
760
+ libnppicom.so, libnppicom_static.a, libnppidei.so,
761
+ libnppidei_static.a, libnppif.so, libnppif_static.a
762
+ libnppig.so, libnppig_static.a, libnppim.so,
763
+ libnppim_static.a, libnppist.so, libnppist_static.a,
764
+ libnppisu.so, libnppisu_static.a, libnppitc.so
765
+ libnppitc_static.a, libnpps.so, libnpps_static.a
766
+
767
+ Android
768
+
769
+ libnppc.so, libnppc_static.a, libnppial.so,
770
+ libnppial_static.a, libnppicc.so, libnppicc_static.a,
771
+ libnppicom.so, libnppicom_static.a, libnppidei.so,
772
+ libnppidei_static.a, libnppif.so, libnppif_static.a
773
+ libnppig.so, libnppig_static.a, libnppim.so,
774
+ libnppim_static.a, libnppist.so, libnppist_static.a,
775
+ libnppisu.so, libnppisu_static.a, libnppitc.so
776
+ libnppitc_static.a, libnpps.so, libnpps_static.a
777
+
778
+ Component
779
+
780
+ NVIDIA JPEG Library
781
+
782
+ Linux
783
+
784
+ libnvjpeg.so, libnvjpeg_static.a
785
+
786
+ Component
787
+
788
+ Internal common library required for statically linking to
789
+ cuBLAS, cuSPARSE, cuFFT, cuRAND, nvJPEG and NPP
790
+
791
+ Mac OSX
792
+
793
+ libculibos.a
794
+
795
+ Linux
796
+
797
+ libculibos.a
798
+
799
+ Component
800
+
801
+ NVIDIA Runtime Compilation Library and Header
802
+
803
+ All
804
+
805
+ nvrtc.h
806
+
807
+ Windows
808
+
809
+ nvrtc.dll, nvrtc-builtins.dll
810
+
811
+ Mac OSX
812
+
813
+ libnvrtc.dylib, libnvrtc-builtins.dylib
814
+
815
+ Linux
816
+
817
+ libnvrtc.so, libnvrtc-builtins.so
818
+
819
+ Component
820
+
821
+ NVIDIA Optimizing Compiler Library
822
+
823
+ Windows
824
+
825
+ nvvm.dll
826
+
827
+ Mac OSX
828
+
829
+ libnvvm.dylib
830
+
831
+ Linux
832
+
833
+ libnvvm.so
834
+
835
+ Component
836
+
837
+ NVIDIA Common Device Math Functions Library
838
+
839
+ Windows
840
+
841
+ libdevice.10.bc
842
+
843
+ Mac OSX
844
+
845
+ libdevice.10.bc
846
+
847
+ Linux
848
+
849
+ libdevice.10.bc
850
+
851
+ Component
852
+
853
+ CUDA Occupancy Calculation Header Library
854
+
855
+ All
856
+
857
+ cuda_occupancy.h
858
+
859
+ Component
860
+
861
+ CUDA Half Precision Headers
862
+
863
+ All
864
+
865
+ cuda_fp16.h, cuda_fp16.hpp
866
+
867
+ Component
868
+
869
+ CUDA Profiling Tools Interface (CUPTI) Library
870
+
871
+ Windows
872
+
873
+ cupti.dll
874
+
875
+ Mac OSX
876
+
877
+ libcupti.dylib
878
+
879
+ Linux
880
+
881
+ libcupti.so
882
+
883
+ Component
884
+
885
+ NVIDIA Tools Extension Library
886
+
887
+ Windows
888
+
889
+ nvToolsExt.dll, nvToolsExt.lib
890
+
891
+ Mac OSX
892
+
893
+ libnvToolsExt.dylib
894
+
895
+ Linux
896
+
897
+ libnvToolsExt.so
898
+
899
+ Component
900
+
901
+ NVIDIA CUDA Driver Libraries
902
+
903
+ Linux
904
+
905
+ libcuda.so, libnvidia-fatbinaryloader.so,
906
+ libnvidia-ptxjitcompiler.so
907
+
908
+ The NVIDIA CUDA Driver Libraries are only distributable in
909
+ applications that meet this criteria:
910
+
911
+ 1. The application was developed starting from a NVIDIA CUDA
912
+ container obtained from Docker Hub or the NVIDIA GPU
913
+ Cloud, and
914
+
915
+ 2. The resulting application is packaged as a Docker
916
+ container and distributed to users on Docker Hub or the
917
+ NVIDIA GPU Cloud only.
918
+
919
+
920
+ 2.7. Attachment B
921
+
922
+
923
+ Additional Licensing Obligations
924
+
925
+ The following third party components included in the SOFTWARE
926
+ are licensed to Licensee pursuant to the following terms and
927
+ conditions:
928
+
929
+ 1. Licensee's use of the GDB third party component is
930
+ subject to the terms and conditions of GNU GPL v3:
931
+
932
+ This product includes copyrighted third-party software licensed
933
+ under the terms of the GNU General Public License v3 ("GPL v3").
934
+ All third-party software packages are copyright by their respective
935
+ authors. GPL v3 terms and conditions are hereby incorporated into
936
+ the Agreement by this reference: http://www.gnu.org/licenses/gpl.txt
937
+
938
+ Consistent with these licensing requirements, the software
939
+ listed below is provided under the terms of the specified
940
+ open source software licenses. To obtain source code for
941
+ software provided under licenses that require
942
+ redistribution of source code, including the GNU General
943
+ Public License (GPL) and GNU Lesser General Public License
944
+ (LGPL), contact oss-requests@nvidia.com. This offer is
945
+ valid for a period of three (3) years from the date of the
946
+ distribution of this product by NVIDIA CORPORATION.
947
+
948
+ Component License
949
+ CUDA-GDB GPL v3
950
+
951
+ 2. Licensee represents and warrants that any and all third
952
+ party licensing and/or royalty payment obligations in
953
+ connection with Licensee's use of the H.264 video codecs
954
+ are solely the responsibility of Licensee.
955
+
956
+ 3. Licensee's use of the Thrust library is subject to the
957
+ terms and conditions of the Apache License Version 2.0.
958
+ All third-party software packages are copyright by their
959
+ respective authors. Apache License Version 2.0 terms and
960
+ conditions are hereby incorporated into the Agreement by
961
+ this reference.
962
+ http://www.apache.org/licenses/LICENSE-2.0.html
963
+
964
+ In addition, Licensee acknowledges the following notice:
965
+ Thrust includes source code from the Boost Iterator,
966
+ Tuple, System, and Random Number libraries.
967
+
968
+ Boost Software License - Version 1.0 - August 17th, 2003
969
+ . . . .
970
+
971
+ Permission is hereby granted, free of charge, to any person or
972
+ organization obtaining a copy of the software and accompanying
973
+ documentation covered by this license (the "Software") to use,
974
+ reproduce, display, distribute, execute, and transmit the Software,
975
+ and to prepare derivative works of the Software, and to permit
976
+ third-parties to whom the Software is furnished to do so, all
977
+ subject to the following:
978
+
979
+ The copyright notices in the Software and this entire statement,
980
+ including the above license grant, this restriction and the following
981
+ disclaimer, must be included in all copies of the Software, in whole
982
+ or in part, and all derivative works of the Software, unless such
983
+ copies or derivative works are solely in the form of machine-executable
984
+ object code generated by a source language processor.
985
+
986
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
987
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
988
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
989
+ NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
990
+ ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR
991
+ OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING
992
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
993
+ OTHER DEALINGS IN THE SOFTWARE.
994
+
995
+ 4. Licensee's use of the LLVM third party component is
996
+ subject to the following terms and conditions:
997
+
998
+ ======================================================
999
+ LLVM Release License
1000
+ ======================================================
1001
+ University of Illinois/NCSA
1002
+ Open Source License
1003
+
1004
+ Copyright (c) 2003-2010 University of Illinois at Urbana-Champaign.
1005
+ All rights reserved.
1006
+
1007
+ Developed by:
1008
+
1009
+ LLVM Team
1010
+
1011
+ University of Illinois at Urbana-Champaign
1012
+
1013
+ http://llvm.org
1014
+
1015
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1016
+ of this software and associated documentation files (the "Software"), to
1017
+ deal with the Software without restriction, including without limitation the
1018
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
1019
+ sell copies of the Software, and to permit persons to whom the Software is
1020
+ furnished to do so, subject to the following conditions:
1021
+
1022
+ * Redistributions of source code must retain the above copyright notice,
1023
+ this list of conditions and the following disclaimers.
1024
+
1025
+ * Redistributions in binary form must reproduce the above copyright
1026
+ notice, this list of conditions and the following disclaimers in the
1027
+ documentation and/or other materials provided with the distribution.
1028
+
1029
+ * Neither the names of the LLVM Team, University of Illinois at Urbana-
1030
+ Champaign, nor the names of its contributors may be used to endorse or
1031
+ promote products derived from this Software without specific prior
1032
+ written permission.
1033
+
1034
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1035
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1036
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1037
+ THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
1038
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1039
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1040
+ DEALINGS WITH THE SOFTWARE.
1041
+
1042
+ 5. Licensee's use (e.g. nvprof) of the PCRE third party
1043
+ component is subject to the following terms and
1044
+ conditions:
1045
+
1046
+ ------------
1047
+ PCRE LICENCE
1048
+ ------------
1049
+ PCRE is a library of functions to support regular expressions whose syntax
1050
+ and semantics are as close as possible to those of the Perl 5 language.
1051
+ Release 8 of PCRE is distributed under the terms of the "BSD" licence, as
1052
+ specified below. The documentation for PCRE, supplied in the "doc"
1053
+ directory, is distributed under the same terms as the software itself. The
1054
+ basic library functions are written in C and are freestanding. Also
1055
+ included in the distribution is a set of C++ wrapper functions, and a just-
1056
+ in-time compiler that can be used to optimize pattern matching. These are
1057
+ both optional features that can be omitted when the library is built.
1058
+
1059
+ THE BASIC LIBRARY FUNCTIONS
1060
+ ---------------------------
1061
+ Written by: Philip Hazel
1062
+ Email local part: ph10
1063
+ Email domain: cam.ac.uk
1064
+ University of Cambridge Computing Service,
1065
+ Cambridge, England.
1066
+ Copyright (c) 1997-2012 University of Cambridge
1067
+ All rights reserved.
1068
+
1069
+ PCRE JUST-IN-TIME COMPILATION SUPPORT
1070
+ -------------------------------------
1071
+ Written by: Zoltan Herczeg
1072
+ Email local part: hzmester
1073
+ Emain domain: freemail.hu
1074
+ Copyright(c) 2010-2012 Zoltan Herczeg
1075
+ All rights reserved.
1076
+
1077
+ STACK-LESS JUST-IN-TIME COMPILER
1078
+ --------------------------------
1079
+ Written by: Zoltan Herczeg
1080
+ Email local part: hzmester
1081
+ Emain domain: freemail.hu
1082
+ Copyright(c) 2009-2012 Zoltan Herczeg
1083
+ All rights reserved.
1084
+
1085
+ THE C++ WRAPPER FUNCTIONS
1086
+ -------------------------
1087
+ Contributed by: Google Inc.
1088
+ Copyright (c) 2007-2012, Google Inc.
1089
+ All rights reserved.
1090
+
1091
+ THE "BSD" LICENCE
1092
+ -----------------
1093
+ Redistribution and use in source and binary forms, with or without
1094
+ modification, are permitted provided that the following conditions are met:
1095
+
1096
+ * Redistributions of source code must retain the above copyright notice,
1097
+ this list of conditions and the following disclaimer.
1098
+
1099
+ * Redistributions in binary form must reproduce the above copyright
1100
+ notice, this list of conditions and the following disclaimer in the
1101
+ documentation and/or other materials provided with the distribution.
1102
+
1103
+ * Neither the name of the University of Cambridge nor the name of Google
1104
+ Inc. nor the names of their contributors may be used to endorse or
1105
+ promote products derived from this software without specific prior
1106
+ written permission.
1107
+
1108
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1109
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1110
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1111
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
1112
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1113
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1114
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1115
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1116
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1117
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1118
+ POSSIBILITY OF SUCH DAMAGE.
1119
+
1120
+ 6. Some of the cuBLAS library routines were written by or
1121
+ derived from code written by Vasily Volkov and are subject
1122
+ to the Modified Berkeley Software Distribution License as
1123
+ follows:
1124
+
1125
+ Copyright (c) 2007-2009, Regents of the University of California
1126
+
1127
+ All rights reserved.
1128
+
1129
+ Redistribution and use in source and binary forms, with or without
1130
+ modification, are permitted provided that the following conditions are
1131
+ met:
1132
+ * Redistributions of source code must retain the above copyright
1133
+ notice, this list of conditions and the following disclaimer.
1134
+ * Redistributions in binary form must reproduce the above
1135
+ copyright notice, this list of conditions and the following
1136
+ disclaimer in the documentation and/or other materials provided
1137
+ with the distribution.
1138
+ * Neither the name of the University of California, Berkeley nor
1139
+ the names of its contributors may be used to endorse or promote
1140
+ products derived from this software without specific prior
1141
+ written permission.
1142
+
1143
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
1144
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1145
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1146
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
1147
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1148
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1149
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1150
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1151
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
1152
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1153
+ POSSIBILITY OF SUCH DAMAGE.
1154
+
1155
+ 7. Some of the cuBLAS library routines were written by or
1156
+ derived from code written by Davide Barbieri and are
1157
+ subject to the Modified Berkeley Software Distribution
1158
+ License as follows:
1159
+
1160
+ Copyright (c) 2008-2009 Davide Barbieri @ University of Rome Tor Vergata.
1161
+
1162
+ All rights reserved.
1163
+
1164
+ Redistribution and use in source and binary forms, with or without
1165
+ modification, are permitted provided that the following conditions are
1166
+ met:
1167
+ * Redistributions of source code must retain the above copyright
1168
+ notice, this list of conditions and the following disclaimer.
1169
+ * Redistributions in binary form must reproduce the above
1170
+ copyright notice, this list of conditions and the following
1171
+ disclaimer in the documentation and/or other materials provided
1172
+ with the distribution.
1173
+ * The name of the author may not be used to endorse or promote
1174
+ products derived from this software without specific prior
1175
+ written permission.
1176
+
1177
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
1178
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1179
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1180
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
1181
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1182
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1183
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1184
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1185
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
1186
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1187
+ POSSIBILITY OF SUCH DAMAGE.
1188
+
1189
+ 8. Some of the cuBLAS library routines were derived from
1190
+ code developed by the University of Tennessee and are
1191
+ subject to the Modified Berkeley Software Distribution
1192
+ License as follows:
1193
+
1194
+ Copyright (c) 2010 The University of Tennessee.
1195
+
1196
+ All rights reserved.
1197
+
1198
+ Redistribution and use in source and binary forms, with or without
1199
+ modification, are permitted provided that the following conditions are
1200
+ met:
1201
+ * Redistributions of source code must retain the above copyright
1202
+ notice, this list of conditions and the following disclaimer.
1203
+ * Redistributions in binary form must reproduce the above
1204
+ copyright notice, this list of conditions and the following
1205
+ disclaimer listed in this license in the documentation and/or
1206
+ other materials provided with the distribution.
1207
+ * Neither the name of the copyright holders nor the names of its
1208
+ contributors may be used to endorse or promote products derived
1209
+ from this software without specific prior written permission.
1210
+
1211
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1212
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1213
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1214
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1215
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1216
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1217
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1218
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1219
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1220
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1221
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1222
+
1223
+ 9. Some of the cuBLAS library routines were written by or
1224
+ derived from code written by Jonathan Hogg and are subject
1225
+ to the Modified Berkeley Software Distribution License as
1226
+ follows:
1227
+
1228
+ Copyright (c) 2012, The Science and Technology Facilities Council (STFC).
1229
+
1230
+ All rights reserved.
1231
+
1232
+ Redistribution and use in source and binary forms, with or without
1233
+ modification, are permitted provided that the following conditions are
1234
+ met:
1235
+ * Redistributions of source code must retain the above copyright
1236
+ notice, this list of conditions and the following disclaimer.
1237
+ * Redistributions in binary form must reproduce the above
1238
+ copyright notice, this list of conditions and the following
1239
+ disclaimer in the documentation and/or other materials provided
1240
+ with the distribution.
1241
+ * Neither the name of the STFC nor the names of its contributors
1242
+ may be used to endorse or promote products derived from this
1243
+ software without specific prior written permission.
1244
+
1245
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1246
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1247
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1248
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE STFC BE
1249
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1250
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1251
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
1252
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
1253
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
1254
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
1255
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1256
+
1257
+ 10. Some of the cuBLAS library routines were written by or
1258
+ derived from code written by Ahmad M. Abdelfattah, David
1259
+ Keyes, and Hatem Ltaief, and are subject to the Apache
1260
+ License, Version 2.0, as follows:
1261
+
1262
+ -- (C) Copyright 2013 King Abdullah University of Science and Technology
1263
+ Authors:
1264
+ Ahmad Abdelfattah (ahmad.ahmad@kaust.edu.sa)
1265
+ David Keyes (david.keyes@kaust.edu.sa)
1266
+ Hatem Ltaief (hatem.ltaief@kaust.edu.sa)
1267
+
1268
+ Redistribution and use in source and binary forms, with or without
1269
+ modification, are permitted provided that the following conditions
1270
+ are met:
1271
+
1272
+ * Redistributions of source code must retain the above copyright
1273
+ notice, this list of conditions and the following disclaimer.
1274
+ * Redistributions in binary form must reproduce the above copyright
1275
+ notice, this list of conditions and the following disclaimer in the
1276
+ documentation and/or other materials provided with the distribution.
1277
+ * Neither the name of the King Abdullah University of Science and
1278
+ Technology nor the names of its contributors may be used to endorse
1279
+ or promote products derived from this software without specific prior
1280
+ written permission.
1281
+
1282
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1283
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1284
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1285
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1286
+ HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1287
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1288
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1289
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1290
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1291
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1292
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
1293
+
1294
+ 11. Some of the cuSPARSE library routines were written by or
1295
+ derived from code written by Li-Wen Chang and are subject
1296
+ to the NCSA Open Source License as follows:
1297
+
1298
+ Copyright (c) 2012, University of Illinois.
1299
+
1300
+ All rights reserved.
1301
+
1302
+ Developed by: IMPACT Group, University of Illinois, http://impact.crhc.illinois.edu
1303
+
1304
+ Permission is hereby granted, free of charge, to any person obtaining
1305
+ a copy of this software and associated documentation files (the
1306
+ "Software"), to deal with the Software without restriction, including
1307
+ without limitation the rights to use, copy, modify, merge, publish,
1308
+ distribute, sublicense, and/or sell copies of the Software, and to
1309
+ permit persons to whom the Software is furnished to do so, subject to
1310
+ the following conditions:
1311
+ * Redistributions of source code must retain the above copyright
1312
+ notice, this list of conditions and the following disclaimer.
1313
+ * Redistributions in binary form must reproduce the above
1314
+ copyright notice, this list of conditions and the following
1315
+ disclaimers in the documentation and/or other materials provided
1316
+ with the distribution.
1317
+ * Neither the names of IMPACT Group, University of Illinois, nor
1318
+ the names of its contributors may be used to endorse or promote
1319
+ products derived from this Software without specific prior
1320
+ written permission.
1321
+
1322
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1323
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1324
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1325
+ NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT
1326
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1327
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
1328
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
1329
+ SOFTWARE.
1330
+
1331
+ 12. Some of the cuRAND library routines were written by or
1332
+ derived from code written by Mutsuo Saito and Makoto
1333
+ Matsumoto and are subject to the following license:
1334
+
1335
+ Copyright (c) 2009, 2010 Mutsuo Saito, Makoto Matsumoto and Hiroshima
1336
+ University. All rights reserved.
1337
+
1338
+ Copyright (c) 2011 Mutsuo Saito, Makoto Matsumoto, Hiroshima
1339
+ University and University of Tokyo. All rights reserved.
1340
+
1341
+ Redistribution and use in source and binary forms, with or without
1342
+ modification, are permitted provided that the following conditions are
1343
+ met:
1344
+ * Redistributions of source code must retain the above copyright
1345
+ notice, this list of conditions and the following disclaimer.
1346
+ * Redistributions in binary form must reproduce the above
1347
+ copyright notice, this list of conditions and the following
1348
+ disclaimer in the documentation and/or other materials provided
1349
+ with the distribution.
1350
+ * Neither the name of the Hiroshima University nor the names of
1351
+ its contributors may be used to endorse or promote products
1352
+ derived from this software without specific prior written
1353
+ permission.
1354
+
1355
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1356
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1357
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1358
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1359
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1360
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1361
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1362
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1363
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1364
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1365
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1366
+
1367
+ 13. Some of the cuRAND library routines were derived from
1368
+ code developed by D. E. Shaw Research and are subject to
1369
+ the following license:
1370
+
1371
+ Copyright 2010-2011, D. E. Shaw Research.
1372
+
1373
+ All rights reserved.
1374
+
1375
+ Redistribution and use in source and binary forms, with or without
1376
+ modification, are permitted provided that the following conditions are
1377
+ met:
1378
+ * Redistributions of source code must retain the above copyright
1379
+ notice, this list of conditions, and the following disclaimer.
1380
+ * Redistributions in binary form must reproduce the above
1381
+ copyright notice, this list of conditions, and the following
1382
+ disclaimer in the documentation and/or other materials provided
1383
+ with the distribution.
1384
+ * Neither the name of D. E. Shaw Research nor the names of its
1385
+ contributors may be used to endorse or promote products derived
1386
+ from this software without specific prior written permission.
1387
+
1388
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1389
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1390
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1391
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1392
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1393
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1394
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1395
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1396
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1397
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1398
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1399
+
1400
+ 14. Some of the Math library routines were written by or
1401
+ derived from code developed by Norbert Juffa and are
1402
+ subject to the following license:
1403
+
1404
+ Copyright (c) 2015-2017, Norbert Juffa
1405
+ All rights reserved.
1406
+
1407
+ Redistribution and use in source and binary forms, with or without
1408
+ modification, are permitted provided that the following conditions
1409
+ are met:
1410
+
1411
+ 1. Redistributions of source code must retain the above copyright
1412
+ notice, this list of conditions and the following disclaimer.
1413
+
1414
+ 2. Redistributions in binary form must reproduce the above copyright
1415
+ notice, this list of conditions and the following disclaimer in the
1416
+ documentation and/or other materials provided with the distribution.
1417
+
1418
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1419
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1420
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1421
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1422
+ HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1423
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1424
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1425
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1426
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1427
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1428
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1429
+
1430
+ 15. Licensee's use of the lz4 third party component is
1431
+ subject to the following terms and conditions:
1432
+
1433
+ Copyright (C) 2011-2013, Yann Collet.
1434
+ BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
1435
+
1436
+ Redistribution and use in source and binary forms, with or without
1437
+ modification, are permitted provided that the following conditions are
1438
+ met:
1439
+
1440
+ * Redistributions of source code must retain the above copyright
1441
+ notice, this list of conditions and the following disclaimer.
1442
+ * Redistributions in binary form must reproduce the above
1443
+ copyright notice, this list of conditions and the following disclaimer
1444
+ in the documentation and/or other materials provided with the
1445
+ distribution.
1446
+
1447
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1448
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1449
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1450
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1451
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1452
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1453
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1454
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1455
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1456
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1457
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1458
+
1459
+ 16. The NPP library uses code from the Boost Math Toolkit,
1460
+ and is subject to the following license:
1461
+
1462
+ Boost Software License - Version 1.0 - August 17th, 2003
1463
+ . . . .
1464
+
1465
+ Permission is hereby granted, free of charge, to any person or
1466
+ organization obtaining a copy of the software and accompanying
1467
+ documentation covered by this license (the "Software") to use,
1468
+ reproduce, display, distribute, execute, and transmit the Software,
1469
+ and to prepare derivative works of the Software, and to permit
1470
+ third-parties to whom the Software is furnished to do so, all
1471
+ subject to the following:
1472
+
1473
+ The copyright notices in the Software and this entire statement,
1474
+ including the above license grant, this restriction and the following
1475
+ disclaimer, must be included in all copies of the Software, in whole
1476
+ or in part, and all derivative works of the Software, unless such
1477
+ copies or derivative works are solely in the form of machine-executable
1478
+ object code generated by a source language processor.
1479
+
1480
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1481
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1482
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
1483
+ NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
1484
+ ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR
1485
+ OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING
1486
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
1487
+ OTHER DEALINGS IN THE SOFTWARE.
1488
+
1489
+ 17. Portions of the Nsight Eclipse Edition is subject to the
1490
+ following license:
1491
+
1492
+ The Eclipse Foundation makes available all content in this plug-in
1493
+ ("Content"). Unless otherwise indicated below, the Content is provided
1494
+ to you under the terms and conditions of the Eclipse Public License
1495
+ Version 1.0 ("EPL"). A copy of the EPL is available at http://
1496
+ www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program"
1497
+ will mean the Content.
1498
+
1499
+ If you did not receive this Content directly from the Eclipse
1500
+ Foundation, the Content is being redistributed by another party
1501
+ ("Redistributor") and different terms and conditions may apply to your
1502
+ use of any object code in the Content. Check the Redistributor's
1503
+ license that was provided with the Content. If no such license exists,
1504
+ contact the Redistributor. Unless otherwise indicated below, the terms
1505
+ and conditions of the EPL still apply to any source code in the
1506
+ Content and such source code may be obtained at http://www.eclipse.org.
1507
+
1508
+ 18. Some of the cuBLAS library routines uses code from
1509
+ OpenAI, which is subject to the following license:
1510
+
1511
+ License URL
1512
+ https://github.com/openai/openai-gemm/blob/master/LICENSE
1513
+
1514
+ License Text
1515
+ The MIT License
1516
+
1517
+ Copyright (c) 2016 OpenAI (http://openai.com), 2016 Google Inc.
1518
+
1519
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1520
+ of this software and associated documentation files (the "Software"), to deal
1521
+ in the Software without restriction, including without limitation the rights
1522
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1523
+ copies of the Software, and to permit persons to whom the Software is
1524
+ furnished to do so, subject to the following conditions:
1525
+
1526
+ The above copyright notice and this permission notice shall be included in
1527
+ all copies or substantial portions of the Software.
1528
+
1529
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1530
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1531
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1532
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1533
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1534
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1535
+ THE SOFTWARE.
1536
+
1537
+ 19. Licensee's use of the Visual Studio Setup Configuration
1538
+ Samples is subject to the following license:
1539
+
1540
+ The MIT License (MIT)
1541
+ Copyright (C) Microsoft Corporation. All rights reserved.
1542
+
1543
+ Permission is hereby granted, free of charge, to any person
1544
+ obtaining a copy of this software and associated documentation
1545
+ files (the "Software"), to deal in the Software without restriction,
1546
+ including without limitation the rights to use, copy, modify, merge,
1547
+ publish, distribute, sublicense, and/or sell copies of the Software,
1548
+ and to permit persons to whom the Software is furnished to do so,
1549
+ subject to the following conditions:
1550
+
1551
+ The above copyright notice and this permission notice shall be included
1552
+ in all copies or substantial portions of the Software.
1553
+
1554
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1555
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1556
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1557
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1558
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1559
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1560
+
1561
+ 20. Licensee's use of linmath.h header for CPU functions for
1562
+ GL vector/matrix operations from lunarG is subject to the
1563
+ Apache License Version 2.0.
1564
+
1565
+ 21. The DX12-CUDA sample uses the d3dx12.h header, which is
1566
+ subject to the MIT license .
1567
+
1568
+ -----------------
openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/METADATA ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: nvidia-cufft-cu11
3
+ Version: 10.9.0.58
4
+ Summary: CUFFT native runtime libraries
5
+ Home-page: https://developer.nvidia.com/cuda-zone
6
+ Author: Nvidia CUDA Installer Team
7
+ Author-email: compute_installer@nvidia.com
8
+ License: NVIDIA Proprietary Software
9
+ Keywords: cuda,nvidia,runtime,machine learning,deep learning
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: Other/Proprietary License
15
+ Classifier: Natural Language :: English
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.5
18
+ Classifier: Programming Language :: Python :: 3.6
19
+ Classifier: Programming Language :: Python :: 3.7
20
+ Classifier: Programming Language :: Python :: 3.8
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3 :: Only
25
+ Classifier: Topic :: Scientific/Engineering
26
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
27
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
28
+ Classifier: Topic :: Software Development
29
+ Classifier: Topic :: Software Development :: Libraries
30
+ Classifier: Operating System :: Microsoft :: Windows
31
+ Classifier: Operating System :: POSIX :: Linux
32
+ Requires-Python: >=3
33
+ License-File: License.txt
34
+
35
+ CUFFT native runtime libraries
openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/RECORD ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ nvidia/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ nvidia/__pycache__/__init__.cpython-310.pyc,,
3
+ nvidia/cufft/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ nvidia/cufft/__pycache__/__init__.cpython-310.pyc,,
5
+ nvidia/cufft/include/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ nvidia/cufft/include/__pycache__/__init__.cpython-310.pyc,,
7
+ nvidia/cufft/include/cudalibxt.h,sha256=9GDuRiOzJuO61zRDhIpWpF7XHp8FXSOIlHJNoIMwOZQ,4105
8
+ nvidia/cufft/include/cufft.h,sha256=Ui7ajKuYZcP-2bm9mpH96YN1igLKeDLgrttyc4jMQJE,12570
9
+ nvidia/cufft/include/cufftXt.h,sha256=LfRdibvAlaNQ35vYqI4n8YcMpPYROrIjpZu2L0tISi4,11463
10
+ nvidia/cufft/include/cufftw.h,sha256=DBrJQf-dnCWD-OYgdhnEzn8OiAX0U3xdteEaNdhs7mU,19412
11
+ nvidia/cufft/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ nvidia/cufft/lib/__pycache__/__init__.cpython-310.pyc,,
13
+ nvidia/cufft/lib/libcufft.so.10,sha256=ylxvgdWEkGtNMrmErYcE3WW_db2rQzTtIs5-73UBqVo,279161544
14
+ nvidia/cufft/lib/libcufftw.so.10,sha256=GlkqWy81mpB3VQ7h_a3VjrLPnMC_q4_jl6N0-5SdoUM,1618440
15
+ nvidia_cufft_cu11-10.9.0.58.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
16
+ nvidia_cufft_cu11-10.9.0.58.dist-info/License.txt,sha256=rW9YU_ugyg0VnQ9Y1JrkmDDC-Mk_epJki5zpCttMbM0,59262
17
+ nvidia_cufft_cu11-10.9.0.58.dist-info/METADATA,sha256=8ZTc0J0I8IQvk3daH0k2WK62JYpm2a9XDaL3gUzZXA8,1506
18
+ nvidia_cufft_cu11-10.9.0.58.dist-info/RECORD,,
19
+ nvidia_cufft_cu11-10.9.0.58.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ nvidia_cufft_cu11-10.9.0.58.dist-info/WHEEL,sha256=6NTOzyjaR-9aJxJquqd0X0mRtq4MUYsP0w_ppLcEVkQ,108
21
+ nvidia_cufft_cu11-10.9.0.58.dist-info/top_level.txt,sha256=fTkAtiFuL16nUrB9ytDDtpytz2t0B4NvYTnRzwAhO14,7
openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/REQUESTED ADDED
File without changes
openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/WHEEL ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (72.2.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-manylinux2014_x86_64
5
+
openflamingo/lib/python3.10/site-packages/nvidia_cufft_cu11-10.9.0.58.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ nvidia
openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (7.09 kB). View file
 
openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/actions.cpython-310.pyc ADDED
Binary file (7.93 kB). View file
 
openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/common.cpython-310.pyc ADDED
Binary file (10.4 kB). View file
 
openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/exceptions.cpython-310.pyc ADDED
Binary file (10.3 kB). View file
 
openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/helpers.cpython-310.pyc ADDED
Binary file (34.8 kB). View file
 
openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/testing.cpython-310.pyc ADDED
Binary file (13 kB). View file
 
openflamingo/lib/python3.10/site-packages/pyparsing/__pycache__/unicode.cpython-310.pyc ADDED
Binary file (10.3 kB). View file
 
openflamingo/lib/python3.10/site-packages/pyparsing/common.py ADDED
@@ -0,0 +1,434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # common.py
2
+ from .core import *
3
+ from .helpers import DelimitedList, any_open_tag, any_close_tag
4
+ from datetime import datetime
5
+
6
+
7
+ # some other useful expressions - using lower-case class name since we are really using this as a namespace
8
+ class pyparsing_common:
9
+ """Here are some common low-level expressions that may be useful in
10
+ jump-starting parser development:
11
+
12
+ - numeric forms (:class:`integers<integer>`, :class:`reals<real>`,
13
+ :class:`scientific notation<sci_real>`)
14
+ - common :class:`programming identifiers<identifier>`
15
+ - network addresses (:class:`MAC<mac_address>`,
16
+ :class:`IPv4<ipv4_address>`, :class:`IPv6<ipv6_address>`)
17
+ - ISO8601 :class:`dates<iso8601_date>` and
18
+ :class:`datetime<iso8601_datetime>`
19
+ - :class:`UUID<uuid>`
20
+ - :class:`comma-separated list<comma_separated_list>`
21
+ - :class:`url`
22
+
23
+ Parse actions:
24
+
25
+ - :class:`convert_to_integer`
26
+ - :class:`convert_to_float`
27
+ - :class:`convert_to_date`
28
+ - :class:`convert_to_datetime`
29
+ - :class:`strip_html_tags`
30
+ - :class:`upcase_tokens`
31
+ - :class:`downcase_tokens`
32
+
33
+ Example::
34
+
35
+ pyparsing_common.number.run_tests('''
36
+ # any int or real number, returned as the appropriate type
37
+ 100
38
+ -100
39
+ +100
40
+ 3.14159
41
+ 6.02e23
42
+ 1e-12
43
+ ''')
44
+
45
+ pyparsing_common.fnumber.run_tests('''
46
+ # any int or real number, returned as float
47
+ 100
48
+ -100
49
+ +100
50
+ 3.14159
51
+ 6.02e23
52
+ 1e-12
53
+ ''')
54
+
55
+ pyparsing_common.hex_integer.run_tests('''
56
+ # hex numbers
57
+ 100
58
+ FF
59
+ ''')
60
+
61
+ pyparsing_common.fraction.run_tests('''
62
+ # fractions
63
+ 1/2
64
+ -3/4
65
+ ''')
66
+
67
+ pyparsing_common.mixed_integer.run_tests('''
68
+ # mixed fractions
69
+ 1
70
+ 1/2
71
+ -3/4
72
+ 1-3/4
73
+ ''')
74
+
75
+ import uuid
76
+ pyparsing_common.uuid.set_parse_action(token_map(uuid.UUID))
77
+ pyparsing_common.uuid.run_tests('''
78
+ # uuid
79
+ 12345678-1234-5678-1234-567812345678
80
+ ''')
81
+
82
+ prints::
83
+
84
+ # any int or real number, returned as the appropriate type
85
+ 100
86
+ [100]
87
+
88
+ -100
89
+ [-100]
90
+
91
+ +100
92
+ [100]
93
+
94
+ 3.14159
95
+ [3.14159]
96
+
97
+ 6.02e23
98
+ [6.02e+23]
99
+
100
+ 1e-12
101
+ [1e-12]
102
+
103
+ # any int or real number, returned as float
104
+ 100
105
+ [100.0]
106
+
107
+ -100
108
+ [-100.0]
109
+
110
+ +100
111
+ [100.0]
112
+
113
+ 3.14159
114
+ [3.14159]
115
+
116
+ 6.02e23
117
+ [6.02e+23]
118
+
119
+ 1e-12
120
+ [1e-12]
121
+
122
+ # hex numbers
123
+ 100
124
+ [256]
125
+
126
+ FF
127
+ [255]
128
+
129
+ # fractions
130
+ 1/2
131
+ [0.5]
132
+
133
+ -3/4
134
+ [-0.75]
135
+
136
+ # mixed fractions
137
+ 1
138
+ [1]
139
+
140
+ 1/2
141
+ [0.5]
142
+
143
+ -3/4
144
+ [-0.75]
145
+
146
+ 1-3/4
147
+ [1.75]
148
+
149
+ # uuid
150
+ 12345678-1234-5678-1234-567812345678
151
+ [UUID('12345678-1234-5678-1234-567812345678')]
152
+ """
153
+
154
+ convert_to_integer = token_map(int)
155
+ """
156
+ Parse action for converting parsed integers to Python int
157
+ """
158
+
159
+ convert_to_float = token_map(float)
160
+ """
161
+ Parse action for converting parsed numbers to Python float
162
+ """
163
+
164
+ integer = Word(nums).set_name("integer").set_parse_action(convert_to_integer)
165
+ """expression that parses an unsigned integer, returns an int"""
166
+
167
+ hex_integer = (
168
+ Word(hexnums).set_name("hex integer").set_parse_action(token_map(int, 16))
169
+ )
170
+ """expression that parses a hexadecimal integer, returns an int"""
171
+
172
+ signed_integer = (
173
+ Regex(r"[+-]?\d+")
174
+ .set_name("signed integer")
175
+ .set_parse_action(convert_to_integer)
176
+ )
177
+ """expression that parses an integer with optional leading sign, returns an int"""
178
+
179
+ fraction = (
180
+ signed_integer().set_parse_action(convert_to_float)
181
+ + "/"
182
+ + signed_integer().set_parse_action(convert_to_float)
183
+ ).set_name("fraction")
184
+ """fractional expression of an integer divided by an integer, returns a float"""
185
+ fraction.add_parse_action(lambda tt: tt[0] / tt[-1])
186
+
187
+ mixed_integer = (
188
+ fraction | signed_integer + Opt(Opt("-").suppress() + fraction)
189
+ ).set_name("fraction or mixed integer-fraction")
190
+ """mixed integer of the form 'integer - fraction', with optional leading integer, returns float"""
191
+ mixed_integer.add_parse_action(sum)
192
+
193
+ real = (
194
+ Regex(r"[+-]?(?:\d+\.\d*|\.\d+)")
195
+ .set_name("real number")
196
+ .set_parse_action(convert_to_float)
197
+ )
198
+ """expression that parses a floating point number and returns a float"""
199
+
200
+ sci_real = (
201
+ Regex(r"[+-]?(?:\d+(?:[eE][+-]?\d+)|(?:\d+\.\d*|\.\d+)(?:[eE][+-]?\d+)?)")
202
+ .set_name("real number with scientific notation")
203
+ .set_parse_action(convert_to_float)
204
+ )
205
+ """expression that parses a floating point number with optional
206
+ scientific notation and returns a float"""
207
+
208
+ # streamlining this expression makes the docs nicer-looking
209
+ number = (sci_real | real | signed_integer).set_name("number").streamline()
210
+ """any numeric expression, returns the corresponding Python type"""
211
+
212
+ fnumber = (
213
+ Regex(r"[+-]?\d+\.?\d*(?:[eE][+-]?\d+)?")
214
+ .set_name("fnumber")
215
+ .set_parse_action(convert_to_float)
216
+ )
217
+ """any int or real number, returned as float"""
218
+
219
+ ieee_float = (
220
+ Regex(r"(?i:[+-]?(?:(?:\d+\.?\d*(?:e[+-]?\d+)?)|nan|inf(?:inity)?))")
221
+ .set_name("ieee_float")
222
+ .set_parse_action(convert_to_float)
223
+ )
224
+ """any floating-point literal (int, real number, infinity, or NaN), returned as float"""
225
+
226
+ identifier = Word(identchars, identbodychars).set_name("identifier")
227
+ """typical code identifier (leading alpha or '_', followed by 0 or more alphas, nums, or '_')"""
228
+
229
+ ipv4_address = Regex(
230
+ r"(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})(\.(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})){3}"
231
+ ).set_name("IPv4 address")
232
+ "IPv4 address (``0.0.0.0 - 255.255.255.255``)"
233
+
234
+ _ipv6_part = Regex(r"[0-9a-fA-F]{1,4}").set_name("hex_integer")
235
+ _full_ipv6_address = (_ipv6_part + (":" + _ipv6_part) * 7).set_name(
236
+ "full IPv6 address"
237
+ )
238
+ _short_ipv6_address = (
239
+ Opt(_ipv6_part + (":" + _ipv6_part) * (0, 6))
240
+ + "::"
241
+ + Opt(_ipv6_part + (":" + _ipv6_part) * (0, 6))
242
+ ).set_name("short IPv6 address")
243
+ _short_ipv6_address.add_condition(
244
+ lambda t: sum(1 for tt in t if pyparsing_common._ipv6_part.matches(tt)) < 8
245
+ )
246
+ _mixed_ipv6_address = ("::ffff:" + ipv4_address).set_name("mixed IPv6 address")
247
+ ipv6_address = Combine(
248
+ (_full_ipv6_address | _mixed_ipv6_address | _short_ipv6_address).set_name(
249
+ "IPv6 address"
250
+ )
251
+ ).set_name("IPv6 address")
252
+ "IPv6 address (long, short, or mixed form)"
253
+
254
+ mac_address = Regex(
255
+ r"[0-9a-fA-F]{2}([:.-])[0-9a-fA-F]{2}(?:\1[0-9a-fA-F]{2}){4}"
256
+ ).set_name("MAC address")
257
+ "MAC address xx:xx:xx:xx:xx (may also have '-' or '.' delimiters)"
258
+
259
+ @staticmethod
260
+ def convert_to_date(fmt: str = "%Y-%m-%d"):
261
+ """
262
+ Helper to create a parse action for converting parsed date string to Python datetime.date
263
+
264
+ Params -
265
+ - fmt - format to be passed to datetime.strptime (default= ``"%Y-%m-%d"``)
266
+
267
+ Example::
268
+
269
+ date_expr = pyparsing_common.iso8601_date.copy()
270
+ date_expr.set_parse_action(pyparsing_common.convert_to_date())
271
+ print(date_expr.parse_string("1999-12-31"))
272
+
273
+ prints::
274
+
275
+ [datetime.date(1999, 12, 31)]
276
+ """
277
+
278
+ def cvt_fn(ss, ll, tt):
279
+ try:
280
+ return datetime.strptime(tt[0], fmt).date()
281
+ except ValueError as ve:
282
+ raise ParseException(ss, ll, str(ve))
283
+
284
+ return cvt_fn
285
+
286
+ @staticmethod
287
+ def convert_to_datetime(fmt: str = "%Y-%m-%dT%H:%M:%S.%f"):
288
+ """Helper to create a parse action for converting parsed
289
+ datetime string to Python datetime.datetime
290
+
291
+ Params -
292
+ - fmt - format to be passed to datetime.strptime (default= ``"%Y-%m-%dT%H:%M:%S.%f"``)
293
+
294
+ Example::
295
+
296
+ dt_expr = pyparsing_common.iso8601_datetime.copy()
297
+ dt_expr.set_parse_action(pyparsing_common.convert_to_datetime())
298
+ print(dt_expr.parse_string("1999-12-31T23:59:59.999"))
299
+
300
+ prints::
301
+
302
+ [datetime.datetime(1999, 12, 31, 23, 59, 59, 999000)]
303
+ """
304
+
305
+ def cvt_fn(s, l, t):
306
+ try:
307
+ return datetime.strptime(t[0], fmt)
308
+ except ValueError as ve:
309
+ raise ParseException(s, l, str(ve))
310
+
311
+ return cvt_fn
312
+
313
+ iso8601_date = Regex(
314
+ r"(?P<year>\d{4})(?:-(?P<month>\d\d)(?:-(?P<day>\d\d))?)?"
315
+ ).set_name("ISO8601 date")
316
+ "ISO8601 date (``yyyy-mm-dd``)"
317
+
318
+ iso8601_datetime = Regex(
319
+ r"(?P<year>\d{4})-(?P<month>\d\d)-(?P<day>\d\d)[T ](?P<hour>\d\d):(?P<minute>\d\d)(:(?P<second>\d\d(\.\d*)?)?)?(?P<tz>Z|[+-]\d\d:?\d\d)?"
320
+ ).set_name("ISO8601 datetime")
321
+ "ISO8601 datetime (``yyyy-mm-ddThh:mm:ss.s(Z|+-00:00)``) - trailing seconds, milliseconds, and timezone optional; accepts separating ``'T'`` or ``' '``"
322
+
323
+ uuid = Regex(r"[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}").set_name("UUID")
324
+ "UUID (``xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx``)"
325
+
326
+ _html_stripper = any_open_tag.suppress() | any_close_tag.suppress()
327
+
328
+ @staticmethod
329
+ def strip_html_tags(s: str, l: int, tokens: ParseResults):
330
+ """Parse action to remove HTML tags from web page HTML source
331
+
332
+ Example::
333
+
334
+ # strip HTML links from normal text
335
+ text = '<td>More info at the <a href="https://github.com/pyparsing/pyparsing/wiki">pyparsing</a> wiki page</td>'
336
+ td, td_end = make_html_tags("TD")
337
+ table_text = td + SkipTo(td_end).set_parse_action(pyparsing_common.strip_html_tags)("body") + td_end
338
+ print(table_text.parse_string(text).body)
339
+
340
+ Prints::
341
+
342
+ More info at the pyparsing wiki page
343
+ """
344
+ return pyparsing_common._html_stripper.transform_string(tokens[0])
345
+
346
+ _commasepitem = (
347
+ Combine(
348
+ OneOrMore(
349
+ ~Literal(",")
350
+ + ~LineEnd()
351
+ + Word(printables, exclude_chars=",")
352
+ + Opt(White(" \t") + ~FollowedBy(LineEnd() | ","))
353
+ )
354
+ )
355
+ .streamline()
356
+ .set_name("commaItem")
357
+ )
358
+ comma_separated_list = DelimitedList(
359
+ Opt(quoted_string.copy() | _commasepitem, default="")
360
+ ).set_name("comma separated list")
361
+ """Predefined expression of 1 or more printable words or quoted strings, separated by commas."""
362
+
363
+ upcase_tokens = staticmethod(token_map(lambda t: t.upper()))
364
+ """Parse action to convert tokens to upper case."""
365
+
366
+ downcase_tokens = staticmethod(token_map(lambda t: t.lower()))
367
+ """Parse action to convert tokens to lower case."""
368
+
369
+ # fmt: off
370
+ url = Regex(
371
+ # https://mathiasbynens.be/demo/url-regex
372
+ # https://gist.github.com/dperini/729294
373
+ r"(?P<url>" +
374
+ # protocol identifier (optional)
375
+ # short syntax // still required
376
+ r"(?:(?:(?P<scheme>https?|ftp):)?\/\/)" +
377
+ # user:pass BasicAuth (optional)
378
+ r"(?:(?P<auth>\S+(?::\S*)?)@)?" +
379
+ r"(?P<host>" +
380
+ # IP address exclusion
381
+ # private & local networks
382
+ r"(?!(?:10|127)(?:\.\d{1,3}){3})" +
383
+ r"(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})" +
384
+ r"(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})" +
385
+ # IP address dotted notation octets
386
+ # excludes loopback network 0.0.0.0
387
+ # excludes reserved space >= 224.0.0.0
388
+ # excludes network & broadcast addresses
389
+ # (first & last IP address of each class)
390
+ r"(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])" +
391
+ r"(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}" +
392
+ r"(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))" +
393
+ r"|" +
394
+ # host & domain names, may end with dot
395
+ # can be replaced by a shortest alternative
396
+ # (?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.)+
397
+ r"(?:" +
398
+ r"(?:" +
399
+ r"[a-z0-9\u00a1-\uffff]" +
400
+ r"[a-z0-9\u00a1-\uffff_-]{0,62}" +
401
+ r")?" +
402
+ r"[a-z0-9\u00a1-\uffff]\." +
403
+ r")+" +
404
+ # TLD identifier name, may end with dot
405
+ r"(?:[a-z\u00a1-\uffff]{2,}\.?)" +
406
+ r")" +
407
+ # port number (optional)
408
+ r"(:(?P<port>\d{2,5}))?" +
409
+ # resource path (optional)
410
+ r"(?P<path>\/[^?# ]*)?" +
411
+ # query string (optional)
412
+ r"(\?(?P<query>[^#]*))?" +
413
+ # fragment (optional)
414
+ r"(#(?P<fragment>\S*))?" +
415
+ r")"
416
+ ).set_name("url")
417
+ """URL (http/https/ftp scheme)"""
418
+ # fmt: on
419
+
420
+ # pre-PEP8 compatibility names
421
+ # fmt: off
422
+ convertToInteger = staticmethod(replaced_by_pep8("convertToInteger", convert_to_integer))
423
+ convertToFloat = staticmethod(replaced_by_pep8("convertToFloat", convert_to_float))
424
+ convertToDate = staticmethod(replaced_by_pep8("convertToDate", convert_to_date))
425
+ convertToDatetime = staticmethod(replaced_by_pep8("convertToDatetime", convert_to_datetime))
426
+ stripHTMLTags = staticmethod(replaced_by_pep8("stripHTMLTags", strip_html_tags))
427
+ upcaseTokens = staticmethod(replaced_by_pep8("upcaseTokens", upcase_tokens))
428
+ downcaseTokens = staticmethod(replaced_by_pep8("downcaseTokens", downcase_tokens))
429
+ # fmt: on
430
+
431
+
432
+ _builtin_exprs = [
433
+ v for v in vars(pyparsing_common).values() if isinstance(v, ParserElement)
434
+ ]
openflamingo/lib/python3.10/site-packages/pyparsing/diagram/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (19 kB). View file
 
openflamingo/lib/python3.10/site-packages/pyparsing/helpers.py ADDED
@@ -0,0 +1,1102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # helpers.py
2
+ import html.entities
3
+ import operator
4
+ import re
5
+ import sys
6
+ import typing
7
+
8
+ from . import __diag__
9
+ from .core import *
10
+ from .util import (
11
+ _bslash,
12
+ _flatten,
13
+ _escape_regex_range_chars,
14
+ make_compressed_re,
15
+ replaced_by_pep8,
16
+ )
17
+
18
+
19
+ #
20
+ # global helpers
21
+ #
22
+ def counted_array(
23
+ expr: ParserElement,
24
+ int_expr: typing.Optional[ParserElement] = None,
25
+ *,
26
+ intExpr: typing.Optional[ParserElement] = None,
27
+ ) -> ParserElement:
28
+ """Helper to define a counted list of expressions.
29
+
30
+ This helper defines a pattern of the form::
31
+
32
+ integer expr expr expr...
33
+
34
+ where the leading integer tells how many expr expressions follow.
35
+ The matched tokens returns the array of expr tokens as a list - the
36
+ leading count token is suppressed.
37
+
38
+ If ``int_expr`` is specified, it should be a pyparsing expression
39
+ that produces an integer value.
40
+
41
+ Example::
42
+
43
+ counted_array(Word(alphas)).parse_string('2 ab cd ef') # -> ['ab', 'cd']
44
+
45
+ # in this parser, the leading integer value is given in binary,
46
+ # '10' indicating that 2 values are in the array
47
+ binary_constant = Word('01').set_parse_action(lambda t: int(t[0], 2))
48
+ counted_array(Word(alphas), int_expr=binary_constant).parse_string('10 ab cd ef') # -> ['ab', 'cd']
49
+
50
+ # if other fields must be parsed after the count but before the
51
+ # list items, give the fields results names and they will
52
+ # be preserved in the returned ParseResults:
53
+ count_with_metadata = integer + Word(alphas)("type")
54
+ typed_array = counted_array(Word(alphanums), int_expr=count_with_metadata)("items")
55
+ result = typed_array.parse_string("3 bool True True False")
56
+ print(result.dump())
57
+
58
+ # prints
59
+ # ['True', 'True', 'False']
60
+ # - items: ['True', 'True', 'False']
61
+ # - type: 'bool'
62
+ """
63
+ intExpr = intExpr or int_expr
64
+ array_expr = Forward()
65
+
66
+ def count_field_parse_action(s, l, t):
67
+ nonlocal array_expr
68
+ n = t[0]
69
+ array_expr <<= (expr * n) if n else Empty()
70
+ # clear list contents, but keep any named results
71
+ del t[:]
72
+
73
+ if intExpr is None:
74
+ intExpr = Word(nums).set_parse_action(lambda t: int(t[0]))
75
+ else:
76
+ intExpr = intExpr.copy()
77
+ intExpr.set_name("arrayLen")
78
+ intExpr.add_parse_action(count_field_parse_action, call_during_try=True)
79
+ return (intExpr + array_expr).set_name(f"(len) {expr}...")
80
+
81
+
82
+ def match_previous_literal(expr: ParserElement) -> ParserElement:
83
+ """Helper to define an expression that is indirectly defined from
84
+ the tokens matched in a previous expression, that is, it looks for
85
+ a 'repeat' of a previous expression. For example::
86
+
87
+ first = Word(nums)
88
+ second = match_previous_literal(first)
89
+ match_expr = first + ":" + second
90
+
91
+ will match ``"1:1"``, but not ``"1:2"``. Because this
92
+ matches a previous literal, will also match the leading
93
+ ``"1:1"`` in ``"1:10"``. If this is not desired, use
94
+ :class:`match_previous_expr`. Do *not* use with packrat parsing
95
+ enabled.
96
+ """
97
+ rep = Forward()
98
+
99
+ def copy_token_to_repeater(s, l, t):
100
+ if not t:
101
+ rep << Empty()
102
+ return
103
+
104
+ if len(t) == 1:
105
+ rep << t[0]
106
+ return
107
+
108
+ # flatten t tokens
109
+ tflat = _flatten(t.as_list())
110
+ rep << And(Literal(tt) for tt in tflat)
111
+
112
+ expr.add_parse_action(copy_token_to_repeater, callDuringTry=True)
113
+ rep.set_name("(prev) " + str(expr))
114
+ return rep
115
+
116
+
117
+ def match_previous_expr(expr: ParserElement) -> ParserElement:
118
+ """Helper to define an expression that is indirectly defined from
119
+ the tokens matched in a previous expression, that is, it looks for
120
+ a 'repeat' of a previous expression. For example::
121
+
122
+ first = Word(nums)
123
+ second = match_previous_expr(first)
124
+ match_expr = first + ":" + second
125
+
126
+ will match ``"1:1"``, but not ``"1:2"``. Because this
127
+ matches by expressions, will *not* match the leading ``"1:1"``
128
+ in ``"1:10"``; the expressions are evaluated first, and then
129
+ compared, so ``"1"`` is compared with ``"10"``. Do *not* use
130
+ with packrat parsing enabled.
131
+ """
132
+ rep = Forward()
133
+ e2 = expr.copy()
134
+ rep <<= e2
135
+
136
+ def copy_token_to_repeater(s, l, t):
137
+ matchTokens = _flatten(t.as_list())
138
+
139
+ def must_match_these_tokens(s, l, t):
140
+ theseTokens = _flatten(t.as_list())
141
+ if theseTokens != matchTokens:
142
+ raise ParseException(
143
+ s, l, f"Expected {matchTokens}, found{theseTokens}"
144
+ )
145
+
146
+ rep.set_parse_action(must_match_these_tokens, callDuringTry=True)
147
+
148
+ expr.add_parse_action(copy_token_to_repeater, callDuringTry=True)
149
+ rep.set_name("(prev) " + str(expr))
150
+ return rep
151
+
152
+
153
+ def one_of(
154
+ strs: Union[typing.Iterable[str], str],
155
+ caseless: bool = False,
156
+ use_regex: bool = True,
157
+ as_keyword: bool = False,
158
+ *,
159
+ useRegex: bool = True,
160
+ asKeyword: bool = False,
161
+ ) -> ParserElement:
162
+ """Helper to quickly define a set of alternative :class:`Literal` s,
163
+ and makes sure to do longest-first testing when there is a conflict,
164
+ regardless of the input order, but returns
165
+ a :class:`MatchFirst` for best performance.
166
+
167
+ Parameters:
168
+
169
+ - ``strs`` - a string of space-delimited literals, or a collection of
170
+ string literals
171
+ - ``caseless`` - treat all literals as caseless - (default= ``False``)
172
+ - ``use_regex`` - as an optimization, will
173
+ generate a :class:`Regex` object; otherwise, will generate
174
+ a :class:`MatchFirst` object (if ``caseless=True`` or ``as_keyword=True``, or if
175
+ creating a :class:`Regex` raises an exception) - (default= ``True``)
176
+ - ``as_keyword`` - enforce :class:`Keyword`-style matching on the
177
+ generated expressions - (default= ``False``)
178
+ - ``asKeyword`` and ``useRegex`` are retained for pre-PEP8 compatibility,
179
+ but will be removed in a future release
180
+
181
+ Example::
182
+
183
+ comp_oper = one_of("< = > <= >= !=")
184
+ var = Word(alphas)
185
+ number = Word(nums)
186
+ term = var | number
187
+ comparison_expr = term + comp_oper + term
188
+ print(comparison_expr.search_string("B = 12 AA=23 B<=AA AA>12"))
189
+
190
+ prints::
191
+
192
+ [['B', '=', '12'], ['AA', '=', '23'], ['B', '<=', 'AA'], ['AA', '>', '12']]
193
+ """
194
+ asKeyword = asKeyword or as_keyword
195
+ useRegex = useRegex and use_regex
196
+
197
+ if (
198
+ isinstance(caseless, str_type)
199
+ and __diag__.warn_on_multiple_string_args_to_oneof
200
+ ):
201
+ warnings.warn(
202
+ "warn_on_multiple_string_args_to_oneof:"
203
+ " More than one string argument passed to one_of, pass"
204
+ " choices as a list or space-delimited string",
205
+ stacklevel=2,
206
+ )
207
+
208
+ if caseless:
209
+ is_equal = lambda a, b: a.upper() == b.upper()
210
+ masks = lambda a, b: b.upper().startswith(a.upper())
211
+ parse_element_class = CaselessKeyword if asKeyword else CaselessLiteral
212
+ else:
213
+ is_equal = operator.eq
214
+ masks = lambda a, b: b.startswith(a)
215
+ parse_element_class = Keyword if asKeyword else Literal
216
+
217
+ symbols: list[str]
218
+ if isinstance(strs, str_type):
219
+ strs = typing.cast(str, strs)
220
+ symbols = strs.split()
221
+ elif isinstance(strs, Iterable):
222
+ symbols = list(strs)
223
+ else:
224
+ raise TypeError("Invalid argument to one_of, expected string or iterable")
225
+ if not symbols:
226
+ return NoMatch()
227
+
228
+ # reorder given symbols to take care to avoid masking longer choices with shorter ones
229
+ # (but only if the given symbols are not just single characters)
230
+ i = 0
231
+ while i < len(symbols) - 1:
232
+ cur = symbols[i]
233
+ for j, other in enumerate(symbols[i + 1 :]):
234
+ if is_equal(other, cur):
235
+ del symbols[i + j + 1]
236
+ break
237
+ if len(other) > len(cur) and masks(cur, other):
238
+ del symbols[i + j + 1]
239
+ symbols.insert(i, other)
240
+ break
241
+ else:
242
+ i += 1
243
+
244
+ if useRegex:
245
+ re_flags: int = re.IGNORECASE if caseless else 0
246
+
247
+ try:
248
+ if all(len(sym) == 1 for sym in symbols):
249
+ # symbols are just single characters, create range regex pattern
250
+ patt = f"[{''.join(_escape_regex_range_chars(sym) for sym in symbols)}]"
251
+ else:
252
+ patt = "|".join(re.escape(sym) for sym in symbols)
253
+
254
+ # wrap with \b word break markers if defining as keywords
255
+ if asKeyword:
256
+ patt = rf"\b(?:{patt})\b"
257
+
258
+ ret = Regex(patt, flags=re_flags).set_name(" | ".join(symbols))
259
+
260
+ if caseless:
261
+ # add parse action to return symbols as specified, not in random
262
+ # casing as found in input string
263
+ symbol_map = {sym.lower(): sym for sym in symbols}
264
+ ret.add_parse_action(lambda s, l, t: symbol_map[t[0].lower()])
265
+
266
+ return ret
267
+
268
+ except re.error:
269
+ warnings.warn(
270
+ "Exception creating Regex for one_of, building MatchFirst", stacklevel=2
271
+ )
272
+
273
+ # last resort, just use MatchFirst
274
+ return MatchFirst(parse_element_class(sym) for sym in symbols).set_name(
275
+ " | ".join(symbols)
276
+ )
277
+
278
+
279
+ def dict_of(key: ParserElement, value: ParserElement) -> ParserElement:
280
+ """Helper to easily and clearly define a dictionary by specifying
281
+ the respective patterns for the key and value. Takes care of
282
+ defining the :class:`Dict`, :class:`ZeroOrMore`, and
283
+ :class:`Group` tokens in the proper order. The key pattern
284
+ can include delimiting markers or punctuation, as long as they are
285
+ suppressed, thereby leaving the significant key text. The value
286
+ pattern can include named results, so that the :class:`Dict` results
287
+ can include named token fields.
288
+
289
+ Example::
290
+
291
+ text = "shape: SQUARE posn: upper left color: light blue texture: burlap"
292
+ attr_expr = (label + Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join))
293
+ print(attr_expr[1, ...].parse_string(text).dump())
294
+
295
+ attr_label = label
296
+ attr_value = Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join)
297
+
298
+ # similar to Dict, but simpler call format
299
+ result = dict_of(attr_label, attr_value).parse_string(text)
300
+ print(result.dump())
301
+ print(result['shape'])
302
+ print(result.shape) # object attribute access works too
303
+ print(result.as_dict())
304
+
305
+ prints::
306
+
307
+ [['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'light blue'], ['texture', 'burlap']]
308
+ - color: 'light blue'
309
+ - posn: 'upper left'
310
+ - shape: 'SQUARE'
311
+ - texture: 'burlap'
312
+ SQUARE
313
+ SQUARE
314
+ {'color': 'light blue', 'shape': 'SQUARE', 'posn': 'upper left', 'texture': 'burlap'}
315
+ """
316
+ return Dict(OneOrMore(Group(key + value)))
317
+
318
+
319
+ def original_text_for(
320
+ expr: ParserElement, as_string: bool = True, *, asString: bool = True
321
+ ) -> ParserElement:
322
+ """Helper to return the original, untokenized text for a given
323
+ expression. Useful to restore the parsed fields of an HTML start
324
+ tag into the raw tag text itself, or to revert separate tokens with
325
+ intervening whitespace back to the original matching input text. By
326
+ default, returns a string containing the original parsed text.
327
+
328
+ If the optional ``as_string`` argument is passed as
329
+ ``False``, then the return value is
330
+ a :class:`ParseResults` containing any results names that
331
+ were originally matched, and a single token containing the original
332
+ matched text from the input string. So if the expression passed to
333
+ :class:`original_text_for` contains expressions with defined
334
+ results names, you must set ``as_string`` to ``False`` if you
335
+ want to preserve those results name values.
336
+
337
+ The ``asString`` pre-PEP8 argument is retained for compatibility,
338
+ but will be removed in a future release.
339
+
340
+ Example::
341
+
342
+ src = "this is test <b> bold <i>text</i> </b> normal text "
343
+ for tag in ("b", "i"):
344
+ opener, closer = make_html_tags(tag)
345
+ patt = original_text_for(opener + ... + closer)
346
+ print(patt.search_string(src)[0])
347
+
348
+ prints::
349
+
350
+ ['<b> bold <i>text</i> </b>']
351
+ ['<i>text</i>']
352
+ """
353
+ asString = asString and as_string
354
+
355
+ locMarker = Empty().set_parse_action(lambda s, loc, t: loc)
356
+ endlocMarker = locMarker.copy()
357
+ endlocMarker.callPreparse = False
358
+ matchExpr = locMarker("_original_start") + expr + endlocMarker("_original_end")
359
+ if asString:
360
+ extractText = lambda s, l, t: s[t._original_start : t._original_end]
361
+ else:
362
+
363
+ def extractText(s, l, t):
364
+ t[:] = [s[t.pop("_original_start") : t.pop("_original_end")]]
365
+
366
+ matchExpr.set_parse_action(extractText)
367
+ matchExpr.ignoreExprs = expr.ignoreExprs
368
+ matchExpr.suppress_warning(Diagnostics.warn_ungrouped_named_tokens_in_collection)
369
+ return matchExpr
370
+
371
+
372
+ def ungroup(expr: ParserElement) -> ParserElement:
373
+ """Helper to undo pyparsing's default grouping of And expressions,
374
+ even if all but one are non-empty.
375
+ """
376
+ return TokenConverter(expr).add_parse_action(lambda t: t[0])
377
+
378
+
379
+ def locatedExpr(expr: ParserElement) -> ParserElement:
380
+ """
381
+ (DEPRECATED - future code should use the :class:`Located` class)
382
+ Helper to decorate a returned token with its starting and ending
383
+ locations in the input string.
384
+
385
+ This helper adds the following results names:
386
+
387
+ - ``locn_start`` - location where matched expression begins
388
+ - ``locn_end`` - location where matched expression ends
389
+ - ``value`` - the actual parsed results
390
+
391
+ Be careful if the input text contains ``<TAB>`` characters, you
392
+ may want to call :class:`ParserElement.parse_with_tabs`
393
+
394
+ Example::
395
+
396
+ wd = Word(alphas)
397
+ for match in locatedExpr(wd).search_string("ljsdf123lksdjjf123lkkjj1222"):
398
+ print(match)
399
+
400
+ prints::
401
+
402
+ [[0, 'ljsdf', 5]]
403
+ [[8, 'lksdjjf', 15]]
404
+ [[18, 'lkkjj', 23]]
405
+ """
406
+ locator = Empty().set_parse_action(lambda ss, ll, tt: ll)
407
+ return Group(
408
+ locator("locn_start")
409
+ + expr("value")
410
+ + locator.copy().leaveWhitespace()("locn_end")
411
+ )
412
+
413
+
414
+ def nested_expr(
415
+ opener: Union[str, ParserElement] = "(",
416
+ closer: Union[str, ParserElement] = ")",
417
+ content: typing.Optional[ParserElement] = None,
418
+ ignore_expr: ParserElement = quoted_string(),
419
+ *,
420
+ ignoreExpr: ParserElement = quoted_string(),
421
+ ) -> ParserElement:
422
+ """Helper method for defining nested lists enclosed in opening and
423
+ closing delimiters (``"("`` and ``")"`` are the default).
424
+
425
+ Parameters:
426
+
427
+ - ``opener`` - opening character for a nested list
428
+ (default= ``"("``); can also be a pyparsing expression
429
+ - ``closer`` - closing character for a nested list
430
+ (default= ``")"``); can also be a pyparsing expression
431
+ - ``content`` - expression for items within the nested lists
432
+ (default= ``None``)
433
+ - ``ignore_expr`` - expression for ignoring opening and closing delimiters
434
+ (default= :class:`quoted_string`)
435
+ - ``ignoreExpr`` - this pre-PEP8 argument is retained for compatibility
436
+ but will be removed in a future release
437
+
438
+ If an expression is not provided for the content argument, the
439
+ nested expression will capture all whitespace-delimited content
440
+ between delimiters as a list of separate values.
441
+
442
+ Use the ``ignore_expr`` argument to define expressions that may
443
+ contain opening or closing characters that should not be treated as
444
+ opening or closing characters for nesting, such as quoted_string or
445
+ a comment expression. Specify multiple expressions using an
446
+ :class:`Or` or :class:`MatchFirst`. The default is
447
+ :class:`quoted_string`, but if no expressions are to be ignored, then
448
+ pass ``None`` for this argument.
449
+
450
+ Example::
451
+
452
+ data_type = one_of("void int short long char float double")
453
+ decl_data_type = Combine(data_type + Opt(Word('*')))
454
+ ident = Word(alphas+'_', alphanums+'_')
455
+ number = pyparsing_common.number
456
+ arg = Group(decl_data_type + ident)
457
+ LPAR, RPAR = map(Suppress, "()")
458
+
459
+ code_body = nested_expr('{', '}', ignore_expr=(quoted_string | c_style_comment))
460
+
461
+ c_function = (decl_data_type("type")
462
+ + ident("name")
463
+ + LPAR + Opt(DelimitedList(arg), [])("args") + RPAR
464
+ + code_body("body"))
465
+ c_function.ignore(c_style_comment)
466
+
467
+ source_code = '''
468
+ int is_odd(int x) {
469
+ return (x%2);
470
+ }
471
+
472
+ int dec_to_hex(char hchar) {
473
+ if (hchar >= '0' && hchar <= '9') {
474
+ return (ord(hchar)-ord('0'));
475
+ } else {
476
+ return (10+ord(hchar)-ord('A'));
477
+ }
478
+ }
479
+ '''
480
+ for func in c_function.search_string(source_code):
481
+ print("%(name)s (%(type)s) args: %(args)s" % func)
482
+
483
+
484
+ prints::
485
+
486
+ is_odd (int) args: [['int', 'x']]
487
+ dec_to_hex (int) args: [['char', 'hchar']]
488
+ """
489
+ if ignoreExpr != ignore_expr:
490
+ ignoreExpr = ignore_expr if ignoreExpr == quoted_string() else ignoreExpr
491
+ if opener == closer:
492
+ raise ValueError("opening and closing strings cannot be the same")
493
+ if content is None:
494
+ if isinstance(opener, str_type) and isinstance(closer, str_type):
495
+ opener = typing.cast(str, opener)
496
+ closer = typing.cast(str, closer)
497
+ if len(opener) == 1 and len(closer) == 1:
498
+ if ignoreExpr is not None:
499
+ content = Combine(
500
+ OneOrMore(
501
+ ~ignoreExpr
502
+ + CharsNotIn(
503
+ opener + closer + ParserElement.DEFAULT_WHITE_CHARS,
504
+ exact=1,
505
+ )
506
+ )
507
+ ).set_parse_action(lambda t: t[0].strip())
508
+ else:
509
+ content = empty.copy() + CharsNotIn(
510
+ opener + closer + ParserElement.DEFAULT_WHITE_CHARS
511
+ ).set_parse_action(lambda t: t[0].strip())
512
+ else:
513
+ if ignoreExpr is not None:
514
+ content = Combine(
515
+ OneOrMore(
516
+ ~ignoreExpr
517
+ + ~Literal(opener)
518
+ + ~Literal(closer)
519
+ + CharsNotIn(ParserElement.DEFAULT_WHITE_CHARS, exact=1)
520
+ )
521
+ ).set_parse_action(lambda t: t[0].strip())
522
+ else:
523
+ content = Combine(
524
+ OneOrMore(
525
+ ~Literal(opener)
526
+ + ~Literal(closer)
527
+ + CharsNotIn(ParserElement.DEFAULT_WHITE_CHARS, exact=1)
528
+ )
529
+ ).set_parse_action(lambda t: t[0].strip())
530
+ else:
531
+ raise ValueError(
532
+ "opening and closing arguments must be strings if no content expression is given"
533
+ )
534
+ ret = Forward()
535
+ if ignoreExpr is not None:
536
+ ret <<= Group(
537
+ Suppress(opener) + ZeroOrMore(ignoreExpr | ret | content) + Suppress(closer)
538
+ )
539
+ else:
540
+ ret <<= Group(Suppress(opener) + ZeroOrMore(ret | content) + Suppress(closer))
541
+ ret.set_name(f"nested {opener}{closer} expression")
542
+ # don't override error message from content expressions
543
+ ret.errmsg = None
544
+ return ret
545
+
546
+
547
+ def _makeTags(tagStr, xml, suppress_LT=Suppress("<"), suppress_GT=Suppress(">")):
548
+ """Internal helper to construct opening and closing tag expressions, given a tag name"""
549
+ if isinstance(tagStr, str_type):
550
+ resname = tagStr
551
+ tagStr = Keyword(tagStr, caseless=not xml)
552
+ else:
553
+ resname = tagStr.name
554
+
555
+ tagAttrName = Word(alphas, alphanums + "_-:")
556
+ if xml:
557
+ tagAttrValue = dbl_quoted_string.copy().set_parse_action(remove_quotes)
558
+ openTag = (
559
+ suppress_LT
560
+ + tagStr("tag")
561
+ + Dict(ZeroOrMore(Group(tagAttrName + Suppress("=") + tagAttrValue)))
562
+ + Opt("/", default=[False])("empty").set_parse_action(
563
+ lambda s, l, t: t[0] == "/"
564
+ )
565
+ + suppress_GT
566
+ )
567
+ else:
568
+ tagAttrValue = quoted_string.copy().set_parse_action(remove_quotes) | Word(
569
+ printables, exclude_chars=">"
570
+ )
571
+ openTag = (
572
+ suppress_LT
573
+ + tagStr("tag")
574
+ + Dict(
575
+ ZeroOrMore(
576
+ Group(
577
+ tagAttrName.set_parse_action(lambda t: t[0].lower())
578
+ + Opt(Suppress("=") + tagAttrValue)
579
+ )
580
+ )
581
+ )
582
+ + Opt("/", default=[False])("empty").set_parse_action(
583
+ lambda s, l, t: t[0] == "/"
584
+ )
585
+ + suppress_GT
586
+ )
587
+ closeTag = Combine(Literal("</") + tagStr + ">", adjacent=False)
588
+
589
+ openTag.set_name(f"<{resname}>")
590
+ # add start<tagname> results name in parse action now that ungrouped names are not reported at two levels
591
+ openTag.add_parse_action(
592
+ lambda t: t.__setitem__(
593
+ "start" + "".join(resname.replace(":", " ").title().split()), t.copy()
594
+ )
595
+ )
596
+ closeTag = closeTag(
597
+ "end" + "".join(resname.replace(":", " ").title().split())
598
+ ).set_name(f"</{resname}>")
599
+ openTag.tag = resname
600
+ closeTag.tag = resname
601
+ openTag.tag_body = SkipTo(closeTag())
602
+ return openTag, closeTag
603
+
604
+
605
+ def make_html_tags(
606
+ tag_str: Union[str, ParserElement]
607
+ ) -> tuple[ParserElement, ParserElement]:
608
+ """Helper to construct opening and closing tag expressions for HTML,
609
+ given a tag name. Matches tags in either upper or lower case,
610
+ attributes with namespaces and with quoted or unquoted values.
611
+
612
+ Example::
613
+
614
+ text = '<td>More info at the <a href="https://github.com/pyparsing/pyparsing/wiki">pyparsing</a> wiki page</td>'
615
+ # make_html_tags returns pyparsing expressions for the opening and
616
+ # closing tags as a 2-tuple
617
+ a, a_end = make_html_tags("A")
618
+ link_expr = a + SkipTo(a_end)("link_text") + a_end
619
+
620
+ for link in link_expr.search_string(text):
621
+ # attributes in the <A> tag (like "href" shown here) are
622
+ # also accessible as named results
623
+ print(link.link_text, '->', link.href)
624
+
625
+ prints::
626
+
627
+ pyparsing -> https://github.com/pyparsing/pyparsing/wiki
628
+ """
629
+ return _makeTags(tag_str, False)
630
+
631
+
632
+ def make_xml_tags(
633
+ tag_str: Union[str, ParserElement]
634
+ ) -> tuple[ParserElement, ParserElement]:
635
+ """Helper to construct opening and closing tag expressions for XML,
636
+ given a tag name. Matches tags only in the given upper/lower case.
637
+
638
+ Example: similar to :class:`make_html_tags`
639
+ """
640
+ return _makeTags(tag_str, True)
641
+
642
+
643
+ any_open_tag: ParserElement
644
+ any_close_tag: ParserElement
645
+ any_open_tag, any_close_tag = make_html_tags(
646
+ Word(alphas, alphanums + "_:").set_name("any tag")
647
+ )
648
+
649
+ _htmlEntityMap = {k.rstrip(";"): v for k, v in html.entities.html5.items()}
650
+ _most_common_entities = "nbsp lt gt amp quot apos cent pound euro copy".replace(
651
+ " ", "|"
652
+ )
653
+ common_html_entity = Regex(
654
+ lambda: f"&(?P<entity>{_most_common_entities}|{make_compressed_re(_htmlEntityMap)});"
655
+ ).set_name("common HTML entity")
656
+
657
+
658
+ def replace_html_entity(s, l, t):
659
+ """Helper parser action to replace common HTML entities with their special characters"""
660
+ return _htmlEntityMap.get(t.entity)
661
+
662
+
663
+ class OpAssoc(Enum):
664
+ """Enumeration of operator associativity
665
+ - used in constructing InfixNotationOperatorSpec for :class:`infix_notation`"""
666
+
667
+ LEFT = 1
668
+ RIGHT = 2
669
+
670
+
671
+ InfixNotationOperatorArgType = Union[
672
+ ParserElement, str, tuple[Union[ParserElement, str], Union[ParserElement, str]]
673
+ ]
674
+ InfixNotationOperatorSpec = Union[
675
+ tuple[
676
+ InfixNotationOperatorArgType,
677
+ int,
678
+ OpAssoc,
679
+ typing.Optional[ParseAction],
680
+ ],
681
+ tuple[
682
+ InfixNotationOperatorArgType,
683
+ int,
684
+ OpAssoc,
685
+ ],
686
+ ]
687
+
688
+
689
+ def infix_notation(
690
+ base_expr: ParserElement,
691
+ op_list: list[InfixNotationOperatorSpec],
692
+ lpar: Union[str, ParserElement] = Suppress("("),
693
+ rpar: Union[str, ParserElement] = Suppress(")"),
694
+ ) -> ParserElement:
695
+ """Helper method for constructing grammars of expressions made up of
696
+ operators working in a precedence hierarchy. Operators may be unary
697
+ or binary, left- or right-associative. Parse actions can also be
698
+ attached to operator expressions. The generated parser will also
699
+ recognize the use of parentheses to override operator precedences
700
+ (see example below).
701
+
702
+ Note: if you define a deep operator list, you may see performance
703
+ issues when using infix_notation. See
704
+ :class:`ParserElement.enable_packrat` for a mechanism to potentially
705
+ improve your parser performance.
706
+
707
+ Parameters:
708
+
709
+ - ``base_expr`` - expression representing the most basic operand to
710
+ be used in the expression
711
+ - ``op_list`` - list of tuples, one for each operator precedence level
712
+ in the expression grammar; each tuple is of the form ``(op_expr,
713
+ num_operands, right_left_assoc, (optional)parse_action)``, where:
714
+
715
+ - ``op_expr`` is the pyparsing expression for the operator; may also
716
+ be a string, which will be converted to a Literal; if ``num_operands``
717
+ is 3, ``op_expr`` is a tuple of two expressions, for the two
718
+ operators separating the 3 terms
719
+ - ``num_operands`` is the number of terms for this operator (must be 1,
720
+ 2, or 3)
721
+ - ``right_left_assoc`` is the indicator whether the operator is right
722
+ or left associative, using the pyparsing-defined constants
723
+ ``OpAssoc.RIGHT`` and ``OpAssoc.LEFT``.
724
+ - ``parse_action`` is the parse action to be associated with
725
+ expressions matching this operator expression (the parse action
726
+ tuple member may be omitted); if the parse action is passed
727
+ a tuple or list of functions, this is equivalent to calling
728
+ ``set_parse_action(*fn)``
729
+ (:class:`ParserElement.set_parse_action`)
730
+ - ``lpar`` - expression for matching left-parentheses; if passed as a
731
+ str, then will be parsed as ``Suppress(lpar)``. If lpar is passed as
732
+ an expression (such as ``Literal('(')``), then it will be kept in
733
+ the parsed results, and grouped with them. (default= ``Suppress('(')``)
734
+ - ``rpar`` - expression for matching right-parentheses; if passed as a
735
+ str, then will be parsed as ``Suppress(rpar)``. If rpar is passed as
736
+ an expression (such as ``Literal(')')``), then it will be kept in
737
+ the parsed results, and grouped with them. (default= ``Suppress(')')``)
738
+
739
+ Example::
740
+
741
+ # simple example of four-function arithmetic with ints and
742
+ # variable names
743
+ integer = pyparsing_common.signed_integer
744
+ varname = pyparsing_common.identifier
745
+
746
+ arith_expr = infix_notation(integer | varname,
747
+ [
748
+ ('-', 1, OpAssoc.RIGHT),
749
+ (one_of('* /'), 2, OpAssoc.LEFT),
750
+ (one_of('+ -'), 2, OpAssoc.LEFT),
751
+ ])
752
+
753
+ arith_expr.run_tests('''
754
+ 5+3*6
755
+ (5+3)*6
756
+ -2--11
757
+ ''', full_dump=False)
758
+
759
+ prints::
760
+
761
+ 5+3*6
762
+ [[5, '+', [3, '*', 6]]]
763
+
764
+ (5+3)*6
765
+ [[[5, '+', 3], '*', 6]]
766
+
767
+ (5+x)*y
768
+ [[[5, '+', 'x'], '*', 'y']]
769
+
770
+ -2--11
771
+ [[['-', 2], '-', ['-', 11]]]
772
+ """
773
+
774
+ # captive version of FollowedBy that does not do parse actions or capture results names
775
+ class _FB(FollowedBy):
776
+ def parseImpl(self, instring, loc, doActions=True):
777
+ self.expr.try_parse(instring, loc)
778
+ return loc, []
779
+
780
+ _FB.__name__ = "FollowedBy>"
781
+
782
+ ret = Forward()
783
+ ret.set_name(f"{base_expr.name}_expression")
784
+ if isinstance(lpar, str):
785
+ lpar = Suppress(lpar)
786
+ if isinstance(rpar, str):
787
+ rpar = Suppress(rpar)
788
+
789
+ nested_expr = (lpar + ret + rpar).set_name(f"nested_{base_expr.name}")
790
+
791
+ # if lpar and rpar are not suppressed, wrap in group
792
+ if not (isinstance(lpar, Suppress) and isinstance(rpar, Suppress)):
793
+ lastExpr = base_expr | Group(nested_expr)
794
+ else:
795
+ lastExpr = base_expr | nested_expr
796
+
797
+ arity: int
798
+ rightLeftAssoc: opAssoc
799
+ pa: typing.Optional[ParseAction]
800
+ opExpr1: ParserElement
801
+ opExpr2: ParserElement
802
+ matchExpr: ParserElement
803
+ match_lookahead: ParserElement
804
+ for operDef in op_list:
805
+ opExpr, arity, rightLeftAssoc, pa = (operDef + (None,))[:4] # type: ignore[assignment]
806
+ if isinstance(opExpr, str_type):
807
+ opExpr = ParserElement._literalStringClass(opExpr)
808
+ opExpr = typing.cast(ParserElement, opExpr)
809
+ if arity == 3:
810
+ if not isinstance(opExpr, (tuple, list)) or len(opExpr) != 2:
811
+ raise ValueError(
812
+ "if numterms=3, opExpr must be a tuple or list of two expressions"
813
+ )
814
+ opExpr1, opExpr2 = opExpr
815
+ term_name = f"{opExpr1}{opExpr2} operations"
816
+ else:
817
+ term_name = f"{opExpr} operations"
818
+
819
+ if not 1 <= arity <= 3:
820
+ raise ValueError("operator must be unary (1), binary (2), or ternary (3)")
821
+
822
+ if rightLeftAssoc not in (OpAssoc.LEFT, OpAssoc.RIGHT):
823
+ raise ValueError("operator must indicate right or left associativity")
824
+
825
+ thisExpr: ParserElement = Forward().set_name(term_name)
826
+ thisExpr = typing.cast(Forward, thisExpr)
827
+ match_lookahead = And([])
828
+ if rightLeftAssoc is OpAssoc.LEFT:
829
+ if arity == 1:
830
+ match_lookahead = _FB(lastExpr + opExpr)
831
+ matchExpr = Group(lastExpr + opExpr[1, ...])
832
+ elif arity == 2:
833
+ if opExpr is not None:
834
+ match_lookahead = _FB(lastExpr + opExpr + lastExpr)
835
+ matchExpr = Group(lastExpr + (opExpr + lastExpr)[1, ...])
836
+ else:
837
+ match_lookahead = _FB(lastExpr + lastExpr)
838
+ matchExpr = Group(lastExpr[2, ...])
839
+ elif arity == 3:
840
+ match_lookahead = _FB(
841
+ lastExpr + opExpr1 + lastExpr + opExpr2 + lastExpr
842
+ )
843
+ matchExpr = Group(
844
+ lastExpr + (opExpr1 + lastExpr + opExpr2 + lastExpr)[1, ...]
845
+ )
846
+ elif rightLeftAssoc is OpAssoc.RIGHT:
847
+ if arity == 1:
848
+ # try to avoid LR with this extra test
849
+ if not isinstance(opExpr, Opt):
850
+ opExpr = Opt(opExpr)
851
+ match_lookahead = _FB(opExpr.expr + thisExpr)
852
+ matchExpr = Group(opExpr + thisExpr)
853
+ elif arity == 2:
854
+ if opExpr is not None:
855
+ match_lookahead = _FB(lastExpr + opExpr + thisExpr)
856
+ matchExpr = Group(lastExpr + (opExpr + thisExpr)[1, ...])
857
+ else:
858
+ match_lookahead = _FB(lastExpr + thisExpr)
859
+ matchExpr = Group(lastExpr + thisExpr[1, ...])
860
+ elif arity == 3:
861
+ match_lookahead = _FB(
862
+ lastExpr + opExpr1 + thisExpr + opExpr2 + thisExpr
863
+ )
864
+ matchExpr = Group(lastExpr + opExpr1 + thisExpr + opExpr2 + thisExpr)
865
+
866
+ # suppress lookahead expr from railroad diagrams
867
+ match_lookahead.show_in_diagram = False
868
+
869
+ # TODO - determine why this statement can't be included in the following
870
+ # if pa block
871
+ matchExpr = match_lookahead + matchExpr
872
+
873
+ if pa:
874
+ if isinstance(pa, (tuple, list)):
875
+ matchExpr.set_parse_action(*pa)
876
+ else:
877
+ matchExpr.set_parse_action(pa)
878
+
879
+ thisExpr <<= (matchExpr | lastExpr).setName(term_name)
880
+ lastExpr = thisExpr
881
+
882
+ ret <<= lastExpr
883
+ return ret
884
+
885
+
886
+ def indentedBlock(blockStatementExpr, indentStack, indent=True, backup_stacks=[]):
887
+ """
888
+ (DEPRECATED - use :class:`IndentedBlock` class instead)
889
+ Helper method for defining space-delimited indentation blocks,
890
+ such as those used to define block statements in Python source code.
891
+
892
+ Parameters:
893
+
894
+ - ``blockStatementExpr`` - expression defining syntax of statement that
895
+ is repeated within the indented block
896
+ - ``indentStack`` - list created by caller to manage indentation stack
897
+ (multiple ``statementWithIndentedBlock`` expressions within a single
898
+ grammar should share a common ``indentStack``)
899
+ - ``indent`` - boolean indicating whether block must be indented beyond
900
+ the current level; set to ``False`` for block of left-most statements
901
+ (default= ``True``)
902
+
903
+ A valid block must contain at least one ``blockStatement``.
904
+
905
+ (Note that indentedBlock uses internal parse actions which make it
906
+ incompatible with packrat parsing.)
907
+
908
+ Example::
909
+
910
+ data = '''
911
+ def A(z):
912
+ A1
913
+ B = 100
914
+ G = A2
915
+ A2
916
+ A3
917
+ B
918
+ def BB(a,b,c):
919
+ BB1
920
+ def BBA():
921
+ bba1
922
+ bba2
923
+ bba3
924
+ C
925
+ D
926
+ def spam(x,y):
927
+ def eggs(z):
928
+ pass
929
+ '''
930
+
931
+
932
+ indentStack = [1]
933
+ stmt = Forward()
934
+
935
+ identifier = Word(alphas, alphanums)
936
+ funcDecl = ("def" + identifier + Group("(" + Opt(delimitedList(identifier)) + ")") + ":")
937
+ func_body = indentedBlock(stmt, indentStack)
938
+ funcDef = Group(funcDecl + func_body)
939
+
940
+ rvalue = Forward()
941
+ funcCall = Group(identifier + "(" + Opt(delimitedList(rvalue)) + ")")
942
+ rvalue << (funcCall | identifier | Word(nums))
943
+ assignment = Group(identifier + "=" + rvalue)
944
+ stmt << (funcDef | assignment | identifier)
945
+
946
+ module_body = stmt[1, ...]
947
+
948
+ parseTree = module_body.parseString(data)
949
+ parseTree.pprint()
950
+
951
+ prints::
952
+
953
+ [['def',
954
+ 'A',
955
+ ['(', 'z', ')'],
956
+ ':',
957
+ [['A1'], [['B', '=', '100']], [['G', '=', 'A2']], ['A2'], ['A3']]],
958
+ 'B',
959
+ ['def',
960
+ 'BB',
961
+ ['(', 'a', 'b', 'c', ')'],
962
+ ':',
963
+ [['BB1'], [['def', 'BBA', ['(', ')'], ':', [['bba1'], ['bba2'], ['bba3']]]]]],
964
+ 'C',
965
+ 'D',
966
+ ['def',
967
+ 'spam',
968
+ ['(', 'x', 'y', ')'],
969
+ ':',
970
+ [[['def', 'eggs', ['(', 'z', ')'], ':', [['pass']]]]]]]
971
+ """
972
+ backup_stacks.append(indentStack[:])
973
+
974
+ def reset_stack():
975
+ indentStack[:] = backup_stacks[-1]
976
+
977
+ def checkPeerIndent(s, l, t):
978
+ if l >= len(s):
979
+ return
980
+ curCol = col(l, s)
981
+ if curCol != indentStack[-1]:
982
+ if curCol > indentStack[-1]:
983
+ raise ParseException(s, l, "illegal nesting")
984
+ raise ParseException(s, l, "not a peer entry")
985
+
986
+ def checkSubIndent(s, l, t):
987
+ curCol = col(l, s)
988
+ if curCol > indentStack[-1]:
989
+ indentStack.append(curCol)
990
+ else:
991
+ raise ParseException(s, l, "not a subentry")
992
+
993
+ def checkUnindent(s, l, t):
994
+ if l >= len(s):
995
+ return
996
+ curCol = col(l, s)
997
+ if not (indentStack and curCol in indentStack):
998
+ raise ParseException(s, l, "not an unindent")
999
+ if curCol < indentStack[-1]:
1000
+ indentStack.pop()
1001
+
1002
+ NL = OneOrMore(LineEnd().set_whitespace_chars("\t ").suppress())
1003
+ INDENT = (Empty() + Empty().set_parse_action(checkSubIndent)).set_name("INDENT")
1004
+ PEER = Empty().set_parse_action(checkPeerIndent).set_name("")
1005
+ UNDENT = Empty().set_parse_action(checkUnindent).set_name("UNINDENT")
1006
+ if indent:
1007
+ smExpr = Group(
1008
+ Opt(NL)
1009
+ + INDENT
1010
+ + OneOrMore(PEER + Group(blockStatementExpr) + Opt(NL))
1011
+ + UNDENT
1012
+ )
1013
+ else:
1014
+ smExpr = Group(
1015
+ Opt(NL)
1016
+ + OneOrMore(PEER + Group(blockStatementExpr) + Opt(NL))
1017
+ + Opt(UNDENT)
1018
+ )
1019
+
1020
+ # add a parse action to remove backup_stack from list of backups
1021
+ smExpr.add_parse_action(
1022
+ lambda: backup_stacks.pop(-1) and None if backup_stacks else None
1023
+ )
1024
+ smExpr.set_fail_action(lambda a, b, c, d: reset_stack())
1025
+ blockStatementExpr.ignore(_bslash + LineEnd())
1026
+ return smExpr.set_name("indented block")
1027
+
1028
+
1029
+ # it's easy to get these comment structures wrong - they're very common,
1030
+ # so may as well make them available
1031
+ c_style_comment = Regex(r"/\*(?:[^*]|\*(?!/))*\*\/").set_name("C style comment")
1032
+ "Comment of the form ``/* ... */``"
1033
+
1034
+ html_comment = Regex(r"<!--[\s\S]*?-->").set_name("HTML comment")
1035
+ "Comment of the form ``<!-- ... -->``"
1036
+
1037
+ rest_of_line = Regex(r".*").leave_whitespace().set_name("rest of line")
1038
+ dbl_slash_comment = Regex(r"//(?:\\\n|[^\n])*").set_name("// comment")
1039
+ "Comment of the form ``// ... (to end of line)``"
1040
+
1041
+ cpp_style_comment = Regex(
1042
+ r"(?:/\*(?:[^*]|\*(?!/))*\*\/)|(?://(?:\\\n|[^\n])*)"
1043
+ ).set_name("C++ style comment")
1044
+ "Comment of either form :class:`c_style_comment` or :class:`dbl_slash_comment`"
1045
+
1046
+ java_style_comment = cpp_style_comment
1047
+ "Same as :class:`cpp_style_comment`"
1048
+
1049
+ python_style_comment = Regex(r"#.*").set_name("Python style comment")
1050
+ "Comment of the form ``# ... (to end of line)``"
1051
+
1052
+
1053
+ # build list of built-in expressions, for future reference if a global default value
1054
+ # gets updated
1055
+ _builtin_exprs: list[ParserElement] = [
1056
+ v for v in vars().values() if isinstance(v, ParserElement)
1057
+ ]
1058
+
1059
+
1060
+ # compatibility function, superseded by DelimitedList class
1061
+ def delimited_list(
1062
+ expr: Union[str, ParserElement],
1063
+ delim: Union[str, ParserElement] = ",",
1064
+ combine: bool = False,
1065
+ min: typing.Optional[int] = None,
1066
+ max: typing.Optional[int] = None,
1067
+ *,
1068
+ allow_trailing_delim: bool = False,
1069
+ ) -> ParserElement:
1070
+ """(DEPRECATED - use :class:`DelimitedList` class)"""
1071
+ return DelimitedList(
1072
+ expr, delim, combine, min, max, allow_trailing_delim=allow_trailing_delim
1073
+ )
1074
+
1075
+
1076
+ # Compatibility synonyms
1077
+ # fmt: off
1078
+ opAssoc = OpAssoc
1079
+ anyOpenTag = any_open_tag
1080
+ anyCloseTag = any_close_tag
1081
+ commonHTMLEntity = common_html_entity
1082
+ cStyleComment = c_style_comment
1083
+ htmlComment = html_comment
1084
+ restOfLine = rest_of_line
1085
+ dblSlashComment = dbl_slash_comment
1086
+ cppStyleComment = cpp_style_comment
1087
+ javaStyleComment = java_style_comment
1088
+ pythonStyleComment = python_style_comment
1089
+ delimitedList = replaced_by_pep8("delimitedList", DelimitedList)
1090
+ delimited_list = replaced_by_pep8("delimited_list", DelimitedList)
1091
+ countedArray = replaced_by_pep8("countedArray", counted_array)
1092
+ matchPreviousLiteral = replaced_by_pep8("matchPreviousLiteral", match_previous_literal)
1093
+ matchPreviousExpr = replaced_by_pep8("matchPreviousExpr", match_previous_expr)
1094
+ oneOf = replaced_by_pep8("oneOf", one_of)
1095
+ dictOf = replaced_by_pep8("dictOf", dict_of)
1096
+ originalTextFor = replaced_by_pep8("originalTextFor", original_text_for)
1097
+ nestedExpr = replaced_by_pep8("nestedExpr", nested_expr)
1098
+ makeHTMLTags = replaced_by_pep8("makeHTMLTags", make_html_tags)
1099
+ makeXMLTags = replaced_by_pep8("makeXMLTags", make_xml_tags)
1100
+ replaceHTMLEntity = replaced_by_pep8("replaceHTMLEntity", replace_html_entity)
1101
+ infixNotation = replaced_by_pep8("infixNotation", infix_notation)
1102
+ # fmt: on
openflamingo/lib/python3.10/site-packages/pyparsing/py.typed ADDED
File without changes
openflamingo/lib/python3.10/site-packages/pyparsing/results.py ADDED
@@ -0,0 +1,816 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # results.py
2
+ from __future__ import annotations
3
+
4
+ import collections
5
+ from collections.abc import (
6
+ MutableMapping,
7
+ Mapping,
8
+ MutableSequence,
9
+ Iterator,
10
+ Iterable,
11
+ )
12
+ import pprint
13
+ from typing import Any
14
+
15
+ from .util import replaced_by_pep8
16
+
17
+
18
+ str_type: tuple[type, ...] = (str, bytes)
19
+ _generator_type = type((_ for _ in ()))
20
+
21
+
22
+ class _ParseResultsWithOffset:
23
+ tup: tuple[ParseResults, int]
24
+ __slots__ = ["tup"]
25
+
26
+ def __init__(self, p1: ParseResults, p2: int):
27
+ self.tup: tuple[ParseResults, int] = (p1, p2)
28
+
29
+ def __getitem__(self, i):
30
+ return self.tup[i]
31
+
32
+ def __getstate__(self):
33
+ return self.tup
34
+
35
+ def __setstate__(self, *args):
36
+ self.tup = args[0]
37
+
38
+
39
+ class ParseResults:
40
+ """Structured parse results, to provide multiple means of access to
41
+ the parsed data:
42
+
43
+ - as a list (``len(results)``)
44
+ - by list index (``results[0], results[1]``, etc.)
45
+ - by attribute (``results.<results_name>`` - see :class:`ParserElement.set_results_name`)
46
+
47
+ Example::
48
+
49
+ integer = Word(nums)
50
+ date_str = (integer.set_results_name("year") + '/'
51
+ + integer.set_results_name("month") + '/'
52
+ + integer.set_results_name("day"))
53
+ # equivalent form:
54
+ # date_str = (integer("year") + '/'
55
+ # + integer("month") + '/'
56
+ # + integer("day"))
57
+
58
+ # parse_string returns a ParseResults object
59
+ result = date_str.parse_string("1999/12/31")
60
+
61
+ def test(s, fn=repr):
62
+ print(f"{s} -> {fn(eval(s))}")
63
+ test("list(result)")
64
+ test("result[0]")
65
+ test("result['month']")
66
+ test("result.day")
67
+ test("'month' in result")
68
+ test("'minutes' in result")
69
+ test("result.dump()", str)
70
+
71
+ prints::
72
+
73
+ list(result) -> ['1999', '/', '12', '/', '31']
74
+ result[0] -> '1999'
75
+ result['month'] -> '12'
76
+ result.day -> '31'
77
+ 'month' in result -> True
78
+ 'minutes' in result -> False
79
+ result.dump() -> ['1999', '/', '12', '/', '31']
80
+ - day: '31'
81
+ - month: '12'
82
+ - year: '1999'
83
+ """
84
+
85
+ _null_values: tuple[Any, ...] = (None, [], ())
86
+
87
+ _name: str
88
+ _parent: ParseResults
89
+ _all_names: set[str]
90
+ _modal: bool
91
+ _toklist: list[Any]
92
+ _tokdict: dict[str, Any]
93
+
94
+ __slots__ = (
95
+ "_name",
96
+ "_parent",
97
+ "_all_names",
98
+ "_modal",
99
+ "_toklist",
100
+ "_tokdict",
101
+ )
102
+
103
+ class List(list):
104
+ """
105
+ Simple wrapper class to distinguish parsed list results that should be preserved
106
+ as actual Python lists, instead of being converted to :class:`ParseResults`::
107
+
108
+ LBRACK, RBRACK = map(pp.Suppress, "[]")
109
+ element = pp.Forward()
110
+ item = ppc.integer
111
+ element_list = LBRACK + pp.DelimitedList(element) + RBRACK
112
+
113
+ # add parse actions to convert from ParseResults to actual Python collection types
114
+ def as_python_list(t):
115
+ return pp.ParseResults.List(t.as_list())
116
+ element_list.add_parse_action(as_python_list)
117
+
118
+ element <<= item | element_list
119
+
120
+ element.run_tests('''
121
+ 100
122
+ [2,3,4]
123
+ [[2, 1],3,4]
124
+ [(2, 1),3,4]
125
+ (2,3,4)
126
+ ''', post_parse=lambda s, r: (r[0], type(r[0])))
127
+
128
+ prints::
129
+
130
+ 100
131
+ (100, <class 'int'>)
132
+
133
+ [2,3,4]
134
+ ([2, 3, 4], <class 'list'>)
135
+
136
+ [[2, 1],3,4]
137
+ ([[2, 1], 3, 4], <class 'list'>)
138
+
139
+ (Used internally by :class:`Group` when `aslist=True`.)
140
+ """
141
+
142
+ def __new__(cls, contained=None):
143
+ if contained is None:
144
+ contained = []
145
+
146
+ if not isinstance(contained, list):
147
+ raise TypeError(
148
+ f"{cls.__name__} may only be constructed with a list, not {type(contained).__name__}"
149
+ )
150
+
151
+ return list.__new__(cls)
152
+
153
+ def __new__(cls, toklist=None, name=None, **kwargs):
154
+ if isinstance(toklist, ParseResults):
155
+ return toklist
156
+ self = object.__new__(cls)
157
+ self._name = None
158
+ self._parent = None
159
+ self._all_names = set()
160
+
161
+ if toklist is None:
162
+ self._toklist = []
163
+ elif isinstance(toklist, (list, _generator_type)):
164
+ self._toklist = (
165
+ [toklist[:]]
166
+ if isinstance(toklist, ParseResults.List)
167
+ else list(toklist)
168
+ )
169
+ else:
170
+ self._toklist = [toklist]
171
+ self._tokdict = dict()
172
+ return self
173
+
174
+ # Performance tuning: we construct a *lot* of these, so keep this
175
+ # constructor as small and fast as possible
176
+ def __init__(
177
+ self, toklist=None, name=None, asList=True, modal=True, isinstance=isinstance
178
+ ) -> None:
179
+ self._tokdict: dict[str, _ParseResultsWithOffset]
180
+ self._modal = modal
181
+
182
+ if name is None or name == "":
183
+ return
184
+
185
+ if isinstance(name, int):
186
+ name = str(name)
187
+
188
+ if not modal:
189
+ self._all_names = {name}
190
+
191
+ self._name = name
192
+
193
+ if toklist in self._null_values:
194
+ return
195
+
196
+ if isinstance(toklist, (str_type, type)):
197
+ toklist = [toklist]
198
+
199
+ if asList:
200
+ if isinstance(toklist, ParseResults):
201
+ self[name] = _ParseResultsWithOffset(ParseResults(toklist._toklist), 0)
202
+ else:
203
+ self[name] = _ParseResultsWithOffset(ParseResults(toklist[0]), 0)
204
+ self[name]._name = name
205
+ return
206
+
207
+ try:
208
+ self[name] = toklist[0]
209
+ except (KeyError, TypeError, IndexError):
210
+ if toklist is not self:
211
+ self[name] = toklist
212
+ else:
213
+ self._name = name
214
+
215
+ def __getitem__(self, i):
216
+ if isinstance(i, (int, slice)):
217
+ return self._toklist[i]
218
+
219
+ if i not in self._all_names:
220
+ return self._tokdict[i][-1][0]
221
+
222
+ return ParseResults([v[0] for v in self._tokdict[i]])
223
+
224
+ def __setitem__(self, k, v, isinstance=isinstance):
225
+ if isinstance(v, _ParseResultsWithOffset):
226
+ self._tokdict[k] = self._tokdict.get(k, list()) + [v]
227
+ sub = v[0]
228
+ elif isinstance(k, (int, slice)):
229
+ self._toklist[k] = v
230
+ sub = v
231
+ else:
232
+ self._tokdict[k] = self._tokdict.get(k, []) + [
233
+ _ParseResultsWithOffset(v, 0)
234
+ ]
235
+ sub = v
236
+ if isinstance(sub, ParseResults):
237
+ sub._parent = self
238
+
239
+ def __delitem__(self, i):
240
+ if not isinstance(i, (int, slice)):
241
+ del self._tokdict[i]
242
+ return
243
+
244
+ mylen = len(self._toklist)
245
+ del self._toklist[i]
246
+
247
+ # convert int to slice
248
+ if isinstance(i, int):
249
+ if i < 0:
250
+ i += mylen
251
+ i = slice(i, i + 1)
252
+ # get removed indices
253
+ removed = list(range(*i.indices(mylen)))
254
+ removed.reverse()
255
+ # fixup indices in token dictionary
256
+ for occurrences in self._tokdict.values():
257
+ for j in removed:
258
+ for k, (value, position) in enumerate(occurrences):
259
+ occurrences[k] = _ParseResultsWithOffset(
260
+ value, position - (position > j)
261
+ )
262
+
263
+ def __contains__(self, k) -> bool:
264
+ return k in self._tokdict
265
+
266
+ def __len__(self) -> int:
267
+ return len(self._toklist)
268
+
269
+ def __bool__(self) -> bool:
270
+ return not not (self._toklist or self._tokdict)
271
+
272
+ def __iter__(self) -> Iterator:
273
+ return iter(self._toklist)
274
+
275
+ def __reversed__(self) -> Iterator:
276
+ return iter(self._toklist[::-1])
277
+
278
+ def keys(self):
279
+ return iter(self._tokdict)
280
+
281
+ def values(self):
282
+ return (self[k] for k in self.keys())
283
+
284
+ def items(self):
285
+ return ((k, self[k]) for k in self.keys())
286
+
287
+ def haskeys(self) -> bool:
288
+ """
289
+ Since ``keys()`` returns an iterator, this method is helpful in bypassing
290
+ code that looks for the existence of any defined results names."""
291
+ return not not self._tokdict
292
+
293
+ def pop(self, *args, **kwargs):
294
+ """
295
+ Removes and returns item at specified index (default= ``last``).
296
+ Supports both ``list`` and ``dict`` semantics for ``pop()``. If
297
+ passed no argument or an integer argument, it will use ``list``
298
+ semantics and pop tokens from the list of parsed tokens. If passed
299
+ a non-integer argument (most likely a string), it will use ``dict``
300
+ semantics and pop the corresponding value from any defined results
301
+ names. A second default return value argument is supported, just as in
302
+ ``dict.pop()``.
303
+
304
+ Example::
305
+
306
+ numlist = Word(nums)[...]
307
+ print(numlist.parse_string("0 123 321")) # -> ['0', '123', '321']
308
+
309
+ def remove_first(tokens):
310
+ tokens.pop(0)
311
+ numlist.add_parse_action(remove_first)
312
+ print(numlist.parse_string("0 123 321")) # -> ['123', '321']
313
+
314
+ label = Word(alphas)
315
+ patt = label("LABEL") + Word(nums)[1, ...]
316
+ print(patt.parse_string("AAB 123 321").dump())
317
+
318
+ # Use pop() in a parse action to remove named result (note that corresponding value is not
319
+ # removed from list form of results)
320
+ def remove_LABEL(tokens):
321
+ tokens.pop("LABEL")
322
+ return tokens
323
+ patt.add_parse_action(remove_LABEL)
324
+ print(patt.parse_string("AAB 123 321").dump())
325
+
326
+ prints::
327
+
328
+ ['AAB', '123', '321']
329
+ - LABEL: 'AAB'
330
+
331
+ ['AAB', '123', '321']
332
+ """
333
+ if not args:
334
+ args = [-1]
335
+ for k, v in kwargs.items():
336
+ if k == "default":
337
+ args = (args[0], v)
338
+ else:
339
+ raise TypeError(f"pop() got an unexpected keyword argument {k!r}")
340
+ if isinstance(args[0], int) or len(args) == 1 or args[0] in self:
341
+ index = args[0]
342
+ ret = self[index]
343
+ del self[index]
344
+ return ret
345
+ else:
346
+ defaultvalue = args[1]
347
+ return defaultvalue
348
+
349
+ def get(self, key, default_value=None):
350
+ """
351
+ Returns named result matching the given key, or if there is no
352
+ such name, then returns the given ``default_value`` or ``None`` if no
353
+ ``default_value`` is specified.
354
+
355
+ Similar to ``dict.get()``.
356
+
357
+ Example::
358
+
359
+ integer = Word(nums)
360
+ date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
361
+
362
+ result = date_str.parse_string("1999/12/31")
363
+ print(result.get("year")) # -> '1999'
364
+ print(result.get("hour", "not specified")) # -> 'not specified'
365
+ print(result.get("hour")) # -> None
366
+ """
367
+ if key in self:
368
+ return self[key]
369
+ else:
370
+ return default_value
371
+
372
+ def insert(self, index, ins_string):
373
+ """
374
+ Inserts new element at location index in the list of parsed tokens.
375
+
376
+ Similar to ``list.insert()``.
377
+
378
+ Example::
379
+
380
+ numlist = Word(nums)[...]
381
+ print(numlist.parse_string("0 123 321")) # -> ['0', '123', '321']
382
+
383
+ # use a parse action to insert the parse location in the front of the parsed results
384
+ def insert_locn(locn, tokens):
385
+ tokens.insert(0, locn)
386
+ numlist.add_parse_action(insert_locn)
387
+ print(numlist.parse_string("0 123 321")) # -> [0, '0', '123', '321']
388
+ """
389
+ self._toklist.insert(index, ins_string)
390
+ # fixup indices in token dictionary
391
+ for occurrences in self._tokdict.values():
392
+ for k, (value, position) in enumerate(occurrences):
393
+ occurrences[k] = _ParseResultsWithOffset(
394
+ value, position + (position > index)
395
+ )
396
+
397
+ def append(self, item):
398
+ """
399
+ Add single element to end of ``ParseResults`` list of elements.
400
+
401
+ Example::
402
+
403
+ numlist = Word(nums)[...]
404
+ print(numlist.parse_string("0 123 321")) # -> ['0', '123', '321']
405
+
406
+ # use a parse action to compute the sum of the parsed integers, and add it to the end
407
+ def append_sum(tokens):
408
+ tokens.append(sum(map(int, tokens)))
409
+ numlist.add_parse_action(append_sum)
410
+ print(numlist.parse_string("0 123 321")) # -> ['0', '123', '321', 444]
411
+ """
412
+ self._toklist.append(item)
413
+
414
+ def extend(self, itemseq):
415
+ """
416
+ Add sequence of elements to end of ``ParseResults`` list of elements.
417
+
418
+ Example::
419
+
420
+ patt = Word(alphas)[1, ...]
421
+
422
+ # use a parse action to append the reverse of the matched strings, to make a palindrome
423
+ def make_palindrome(tokens):
424
+ tokens.extend(reversed([t[::-1] for t in tokens]))
425
+ return ''.join(tokens)
426
+ patt.add_parse_action(make_palindrome)
427
+ print(patt.parse_string("lskdj sdlkjf lksd")) # -> 'lskdjsdlkjflksddsklfjkldsjdksl'
428
+ """
429
+ if isinstance(itemseq, ParseResults):
430
+ self.__iadd__(itemseq)
431
+ else:
432
+ self._toklist.extend(itemseq)
433
+
434
+ def clear(self):
435
+ """
436
+ Clear all elements and results names.
437
+ """
438
+ del self._toklist[:]
439
+ self._tokdict.clear()
440
+
441
+ def __getattr__(self, name):
442
+ try:
443
+ return self[name]
444
+ except KeyError:
445
+ if name.startswith("__"):
446
+ raise AttributeError(name)
447
+ return ""
448
+
449
+ def __add__(self, other: ParseResults) -> ParseResults:
450
+ ret = self.copy()
451
+ ret += other
452
+ return ret
453
+
454
+ def __iadd__(self, other: ParseResults) -> ParseResults:
455
+ if not other:
456
+ return self
457
+
458
+ if other._tokdict:
459
+ offset = len(self._toklist)
460
+ addoffset = lambda a: offset if a < 0 else a + offset
461
+ otheritems = other._tokdict.items()
462
+ otherdictitems = [
463
+ (k, _ParseResultsWithOffset(v[0], addoffset(v[1])))
464
+ for k, vlist in otheritems
465
+ for v in vlist
466
+ ]
467
+ for k, v in otherdictitems:
468
+ self[k] = v
469
+ if isinstance(v[0], ParseResults):
470
+ v[0]._parent = self
471
+
472
+ self._toklist += other._toklist
473
+ self._all_names |= other._all_names
474
+ return self
475
+
476
+ def __radd__(self, other) -> ParseResults:
477
+ if isinstance(other, int) and other == 0:
478
+ # useful for merging many ParseResults using sum() builtin
479
+ return self.copy()
480
+ else:
481
+ # this may raise a TypeError - so be it
482
+ return other + self
483
+
484
+ def __repr__(self) -> str:
485
+ return f"{type(self).__name__}({self._toklist!r}, {self.as_dict()})"
486
+
487
+ def __str__(self) -> str:
488
+ return (
489
+ "["
490
+ + ", ".join(
491
+ [
492
+ str(i) if isinstance(i, ParseResults) else repr(i)
493
+ for i in self._toklist
494
+ ]
495
+ )
496
+ + "]"
497
+ )
498
+
499
+ def _asStringList(self, sep=""):
500
+ out = []
501
+ for item in self._toklist:
502
+ if out and sep:
503
+ out.append(sep)
504
+ if isinstance(item, ParseResults):
505
+ out += item._asStringList()
506
+ else:
507
+ out.append(str(item))
508
+ return out
509
+
510
+ def as_list(self, *, flatten: bool = False) -> list:
511
+ """
512
+ Returns the parse results as a nested list of matching tokens, all converted to strings.
513
+ If flatten is True, all the nesting levels in the returned list are collapsed.
514
+
515
+ Example::
516
+
517
+ patt = Word(alphas)[1, ...]
518
+ result = patt.parse_string("sldkj lsdkj sldkj")
519
+ # even though the result prints in string-like form, it is actually a pyparsing ParseResults
520
+ print(type(result), result) # -> <class 'pyparsing.ParseResults'> ['sldkj', 'lsdkj', 'sldkj']
521
+
522
+ # Use as_list() to create an actual list
523
+ result_list = result.as_list()
524
+ print(type(result_list), result_list) # -> <class 'list'> ['sldkj', 'lsdkj', 'sldkj']
525
+ """
526
+
527
+ def flattened(pr):
528
+ to_visit = collections.deque([*self])
529
+ while to_visit:
530
+ to_do = to_visit.popleft()
531
+ if isinstance(to_do, ParseResults):
532
+ to_visit.extendleft(to_do[::-1])
533
+ else:
534
+ yield to_do
535
+
536
+ if flatten:
537
+ return [*flattened(self)]
538
+ else:
539
+ return [
540
+ res.as_list() if isinstance(res, ParseResults) else res
541
+ for res in self._toklist
542
+ ]
543
+
544
+ def as_dict(self) -> dict:
545
+ """
546
+ Returns the named parse results as a nested dictionary.
547
+
548
+ Example::
549
+
550
+ integer = Word(nums)
551
+ date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
552
+
553
+ result = date_str.parse_string('12/31/1999')
554
+ print(type(result), repr(result)) # -> <class 'pyparsing.ParseResults'> (['12', '/', '31', '/', '1999'], {'day': [('1999', 4)], 'year': [('12', 0)], 'month': [('31', 2)]})
555
+
556
+ result_dict = result.as_dict()
557
+ print(type(result_dict), repr(result_dict)) # -> <class 'dict'> {'day': '1999', 'year': '12', 'month': '31'}
558
+
559
+ # even though a ParseResults supports dict-like access, sometime you just need to have a dict
560
+ import json
561
+ print(json.dumps(result)) # -> Exception: TypeError: ... is not JSON serializable
562
+ print(json.dumps(result.as_dict())) # -> {"month": "31", "day": "1999", "year": "12"}
563
+ """
564
+
565
+ def to_item(obj):
566
+ if isinstance(obj, ParseResults):
567
+ return obj.as_dict() if obj.haskeys() else [to_item(v) for v in obj]
568
+ else:
569
+ return obj
570
+
571
+ return dict((k, to_item(v)) for k, v in self.items())
572
+
573
+ def copy(self) -> ParseResults:
574
+ """
575
+ Returns a new shallow copy of a :class:`ParseResults` object. `ParseResults`
576
+ items contained within the source are shared with the copy. Use
577
+ :class:`ParseResults.deepcopy()` to create a copy with its own separate
578
+ content values.
579
+ """
580
+ ret = ParseResults(self._toklist)
581
+ ret._tokdict = self._tokdict.copy()
582
+ ret._parent = self._parent
583
+ ret._all_names |= self._all_names
584
+ ret._name = self._name
585
+ return ret
586
+
587
+ def deepcopy(self) -> ParseResults:
588
+ """
589
+ Returns a new deep copy of a :class:`ParseResults` object.
590
+ """
591
+ ret = self.copy()
592
+ # replace values with copies if they are of known mutable types
593
+ for i, obj in enumerate(self._toklist):
594
+ if isinstance(obj, ParseResults):
595
+ ret._toklist[i] = obj.deepcopy()
596
+ elif isinstance(obj, (str, bytes)):
597
+ pass
598
+ elif isinstance(obj, MutableMapping):
599
+ ret._toklist[i] = dest = type(obj)()
600
+ for k, v in obj.items():
601
+ dest[k] = v.deepcopy() if isinstance(v, ParseResults) else v
602
+ elif isinstance(obj, Iterable):
603
+ ret._toklist[i] = type(obj)(
604
+ v.deepcopy() if isinstance(v, ParseResults) else v for v in obj # type: ignore[call-arg]
605
+ )
606
+ return ret
607
+
608
+ def get_name(self) -> str | None:
609
+ r"""
610
+ Returns the results name for this token expression. Useful when several
611
+ different expressions might match at a particular location.
612
+
613
+ Example::
614
+
615
+ integer = Word(nums)
616
+ ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d")
617
+ house_number_expr = Suppress('#') + Word(nums, alphanums)
618
+ user_data = (Group(house_number_expr)("house_number")
619
+ | Group(ssn_expr)("ssn")
620
+ | Group(integer)("age"))
621
+ user_info = user_data[1, ...]
622
+
623
+ result = user_info.parse_string("22 111-22-3333 #221B")
624
+ for item in result:
625
+ print(item.get_name(), ':', item[0])
626
+
627
+ prints::
628
+
629
+ age : 22
630
+ ssn : 111-22-3333
631
+ house_number : 221B
632
+ """
633
+ if self._name:
634
+ return self._name
635
+ elif self._parent:
636
+ par: ParseResults = self._parent
637
+ parent_tokdict_items = par._tokdict.items()
638
+ return next(
639
+ (
640
+ k
641
+ for k, vlist in parent_tokdict_items
642
+ for v, loc in vlist
643
+ if v is self
644
+ ),
645
+ None,
646
+ )
647
+ elif (
648
+ len(self) == 1
649
+ and len(self._tokdict) == 1
650
+ and next(iter(self._tokdict.values()))[0][1] in (0, -1)
651
+ ):
652
+ return next(iter(self._tokdict.keys()))
653
+ else:
654
+ return None
655
+
656
+ def dump(self, indent="", full=True, include_list=True, _depth=0) -> str:
657
+ """
658
+ Diagnostic method for listing out the contents of
659
+ a :class:`ParseResults`. Accepts an optional ``indent`` argument so
660
+ that this string can be embedded in a nested display of other data.
661
+
662
+ Example::
663
+
664
+ integer = Word(nums)
665
+ date_str = integer("year") + '/' + integer("month") + '/' + integer("day")
666
+
667
+ result = date_str.parse_string('1999/12/31')
668
+ print(result.dump())
669
+
670
+ prints::
671
+
672
+ ['1999', '/', '12', '/', '31']
673
+ - day: '31'
674
+ - month: '12'
675
+ - year: '1999'
676
+ """
677
+ out = []
678
+ NL = "\n"
679
+ out.append(indent + str(self.as_list()) if include_list else "")
680
+
681
+ if not full:
682
+ return "".join(out)
683
+
684
+ if self.haskeys():
685
+ items = sorted((str(k), v) for k, v in self.items())
686
+ for k, v in items:
687
+ if out:
688
+ out.append(NL)
689
+ out.append(f"{indent}{(' ' * _depth)}- {k}: ")
690
+ if not isinstance(v, ParseResults):
691
+ out.append(repr(v))
692
+ continue
693
+
694
+ if not v:
695
+ out.append(str(v))
696
+ continue
697
+
698
+ out.append(
699
+ v.dump(
700
+ indent=indent,
701
+ full=full,
702
+ include_list=include_list,
703
+ _depth=_depth + 1,
704
+ )
705
+ )
706
+ if not any(isinstance(vv, ParseResults) for vv in self):
707
+ return "".join(out)
708
+
709
+ v = self
710
+ incr = " "
711
+ nl = "\n"
712
+ for i, vv in enumerate(v):
713
+ if isinstance(vv, ParseResults):
714
+ vv_dump = vv.dump(
715
+ indent=indent,
716
+ full=full,
717
+ include_list=include_list,
718
+ _depth=_depth + 1,
719
+ )
720
+ out.append(
721
+ f"{nl}{indent}{incr * _depth}[{i}]:{nl}{indent}{incr * (_depth + 1)}{vv_dump}"
722
+ )
723
+ else:
724
+ out.append(
725
+ f"{nl}{indent}{incr * _depth}[{i}]:{nl}{indent}{incr * (_depth + 1)}{vv}"
726
+ )
727
+
728
+ return "".join(out)
729
+
730
+ def pprint(self, *args, **kwargs):
731
+ """
732
+ Pretty-printer for parsed results as a list, using the
733
+ `pprint <https://docs.python.org/3/library/pprint.html>`_ module.
734
+ Accepts additional positional or keyword args as defined for
735
+ `pprint.pprint <https://docs.python.org/3/library/pprint.html#pprint.pprint>`_ .
736
+
737
+ Example::
738
+
739
+ ident = Word(alphas, alphanums)
740
+ num = Word(nums)
741
+ func = Forward()
742
+ term = ident | num | Group('(' + func + ')')
743
+ func <<= ident + Group(Optional(DelimitedList(term)))
744
+ result = func.parse_string("fna a,b,(fnb c,d,200),100")
745
+ result.pprint(width=40)
746
+
747
+ prints::
748
+
749
+ ['fna',
750
+ ['a',
751
+ 'b',
752
+ ['(', 'fnb', ['c', 'd', '200'], ')'],
753
+ '100']]
754
+ """
755
+ pprint.pprint(self.as_list(), *args, **kwargs)
756
+
757
+ # add support for pickle protocol
758
+ def __getstate__(self):
759
+ return (
760
+ self._toklist,
761
+ (
762
+ self._tokdict.copy(),
763
+ None,
764
+ self._all_names,
765
+ self._name,
766
+ ),
767
+ )
768
+
769
+ def __setstate__(self, state):
770
+ self._toklist, (self._tokdict, par, inAccumNames, self._name) = state
771
+ self._all_names = set(inAccumNames)
772
+ self._parent = None
773
+
774
+ def __getnewargs__(self):
775
+ return self._toklist, self._name
776
+
777
+ def __dir__(self):
778
+ return dir(type(self)) + list(self.keys())
779
+
780
+ @classmethod
781
+ def from_dict(cls, other, name=None) -> ParseResults:
782
+ """
783
+ Helper classmethod to construct a ``ParseResults`` from a ``dict``, preserving the
784
+ name-value relations as results names. If an optional ``name`` argument is
785
+ given, a nested ``ParseResults`` will be returned.
786
+ """
787
+
788
+ def is_iterable(obj):
789
+ try:
790
+ iter(obj)
791
+ except Exception:
792
+ return False
793
+ # str's are iterable, but in pyparsing, we don't want to iterate over them
794
+ else:
795
+ return not isinstance(obj, str_type)
796
+
797
+ ret = cls([])
798
+ for k, v in other.items():
799
+ if isinstance(v, Mapping):
800
+ ret += cls.from_dict(v, name=k)
801
+ else:
802
+ ret += cls([v], name=k, asList=is_iterable(v))
803
+ if name is not None:
804
+ ret = cls([ret], name=name)
805
+ return ret
806
+
807
+ asList = as_list
808
+ """Deprecated - use :class:`as_list`"""
809
+ asDict = as_dict
810
+ """Deprecated - use :class:`as_dict`"""
811
+ getName = get_name
812
+ """Deprecated - use :class:`get_name`"""
813
+
814
+
815
+ MutableMapping.register(ParseResults)
816
+ MutableSequence.register(ParseResults)
openflamingo/lib/python3.10/site-packages/pyparsing/unicode.py ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # unicode.py
2
+
3
+ import sys
4
+ from itertools import filterfalse
5
+ from typing import Union
6
+
7
+
8
+ class _lazyclassproperty:
9
+ def __init__(self, fn):
10
+ self.fn = fn
11
+ self.__doc__ = fn.__doc__
12
+ self.__name__ = fn.__name__
13
+
14
+ def __get__(self, obj, cls):
15
+ if cls is None:
16
+ cls = type(obj)
17
+ if not hasattr(cls, "_intern") or any(
18
+ cls._intern is getattr(superclass, "_intern", [])
19
+ for superclass in cls.__mro__[1:]
20
+ ):
21
+ cls._intern = {}
22
+ attrname = self.fn.__name__
23
+ if attrname not in cls._intern:
24
+ cls._intern[attrname] = self.fn(cls)
25
+ return cls._intern[attrname]
26
+
27
+
28
+ UnicodeRangeList = list[Union[tuple[int, int], tuple[int]]]
29
+
30
+
31
+ class unicode_set:
32
+ """
33
+ A set of Unicode characters, for language-specific strings for
34
+ ``alphas``, ``nums``, ``alphanums``, and ``printables``.
35
+ A unicode_set is defined by a list of ranges in the Unicode character
36
+ set, in a class attribute ``_ranges``. Ranges can be specified using
37
+ 2-tuples or a 1-tuple, such as::
38
+
39
+ _ranges = [
40
+ (0x0020, 0x007e),
41
+ (0x00a0, 0x00ff),
42
+ (0x0100,),
43
+ ]
44
+
45
+ Ranges are left- and right-inclusive. A 1-tuple of (x,) is treated as (x, x).
46
+
47
+ A unicode set can also be defined using multiple inheritance of other unicode sets::
48
+
49
+ class CJK(Chinese, Japanese, Korean):
50
+ pass
51
+ """
52
+
53
+ _ranges: UnicodeRangeList = []
54
+
55
+ @_lazyclassproperty
56
+ def _chars_for_ranges(cls) -> list[str]:
57
+ ret: list[int] = []
58
+ for cc in cls.__mro__: # type: ignore[attr-defined]
59
+ if cc is unicode_set:
60
+ break
61
+ for rr in getattr(cc, "_ranges", ()):
62
+ ret.extend(range(rr[0], rr[-1] + 1))
63
+ return sorted(chr(c) for c in set(ret))
64
+
65
+ @_lazyclassproperty
66
+ def printables(cls) -> str:
67
+ """all non-whitespace characters in this range"""
68
+ return "".join(filterfalse(str.isspace, cls._chars_for_ranges))
69
+
70
+ @_lazyclassproperty
71
+ def alphas(cls) -> str:
72
+ """all alphabetic characters in this range"""
73
+ return "".join(filter(str.isalpha, cls._chars_for_ranges))
74
+
75
+ @_lazyclassproperty
76
+ def nums(cls) -> str:
77
+ """all numeric digit characters in this range"""
78
+ return "".join(filter(str.isdigit, cls._chars_for_ranges))
79
+
80
+ @_lazyclassproperty
81
+ def alphanums(cls) -> str:
82
+ """all alphanumeric characters in this range"""
83
+ return cls.alphas + cls.nums
84
+
85
+ @_lazyclassproperty
86
+ def identchars(cls) -> str:
87
+ """all characters in this range that are valid identifier characters, plus underscore '_'"""
88
+ return "".join(
89
+ sorted(
90
+ set(filter(str.isidentifier, cls._chars_for_ranges))
91
+ | set(
92
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµº"
93
+ "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ"
94
+ "_"
95
+ )
96
+ )
97
+ )
98
+
99
+ @_lazyclassproperty
100
+ def identbodychars(cls) -> str:
101
+ """
102
+ all characters in this range that are valid identifier body characters,
103
+ plus the digits 0-9, and · (Unicode MIDDLE DOT)
104
+ """
105
+ identifier_chars = set(
106
+ c for c in cls._chars_for_ranges if ("_" + c).isidentifier()
107
+ )
108
+ return "".join(
109
+ sorted(identifier_chars | set(cls.identchars) | set("0123456789·"))
110
+ )
111
+
112
+ @_lazyclassproperty
113
+ def identifier(cls):
114
+ """
115
+ a pyparsing Word expression for an identifier using this range's definitions for
116
+ identchars and identbodychars
117
+ """
118
+ from pyparsing import Word
119
+
120
+ return Word(cls.identchars, cls.identbodychars)
121
+
122
+
123
+ class pyparsing_unicode(unicode_set):
124
+ """
125
+ A namespace class for defining common language unicode_sets.
126
+ """
127
+
128
+ # fmt: off
129
+
130
+ # define ranges in language character sets
131
+ _ranges: UnicodeRangeList = [
132
+ (0x0020, sys.maxunicode),
133
+ ]
134
+
135
+ class BasicMultilingualPlane(unicode_set):
136
+ """Unicode set for the Basic Multilingual Plane"""
137
+ _ranges: UnicodeRangeList = [
138
+ (0x0020, 0xFFFF),
139
+ ]
140
+
141
+ class Latin1(unicode_set):
142
+ """Unicode set for Latin-1 Unicode Character Range"""
143
+ _ranges: UnicodeRangeList = [
144
+ (0x0020, 0x007E),
145
+ (0x00A0, 0x00FF),
146
+ ]
147
+
148
+ class LatinA(unicode_set):
149
+ """Unicode set for Latin-A Unicode Character Range"""
150
+ _ranges: UnicodeRangeList = [
151
+ (0x0100, 0x017F),
152
+ ]
153
+
154
+ class LatinB(unicode_set):
155
+ """Unicode set for Latin-B Unicode Character Range"""
156
+ _ranges: UnicodeRangeList = [
157
+ (0x0180, 0x024F),
158
+ ]
159
+
160
+ class Greek(unicode_set):
161
+ """Unicode set for Greek Unicode Character Ranges"""
162
+ _ranges: UnicodeRangeList = [
163
+ (0x0342, 0x0345),
164
+ (0x0370, 0x0377),
165
+ (0x037A, 0x037F),
166
+ (0x0384, 0x038A),
167
+ (0x038C,),
168
+ (0x038E, 0x03A1),
169
+ (0x03A3, 0x03E1),
170
+ (0x03F0, 0x03FF),
171
+ (0x1D26, 0x1D2A),
172
+ (0x1D5E,),
173
+ (0x1D60,),
174
+ (0x1D66, 0x1D6A),
175
+ (0x1F00, 0x1F15),
176
+ (0x1F18, 0x1F1D),
177
+ (0x1F20, 0x1F45),
178
+ (0x1F48, 0x1F4D),
179
+ (0x1F50, 0x1F57),
180
+ (0x1F59,),
181
+ (0x1F5B,),
182
+ (0x1F5D,),
183
+ (0x1F5F, 0x1F7D),
184
+ (0x1F80, 0x1FB4),
185
+ (0x1FB6, 0x1FC4),
186
+ (0x1FC6, 0x1FD3),
187
+ (0x1FD6, 0x1FDB),
188
+ (0x1FDD, 0x1FEF),
189
+ (0x1FF2, 0x1FF4),
190
+ (0x1FF6, 0x1FFE),
191
+ (0x2129,),
192
+ (0x2719, 0x271A),
193
+ (0xAB65,),
194
+ (0x10140, 0x1018D),
195
+ (0x101A0,),
196
+ (0x1D200, 0x1D245),
197
+ (0x1F7A1, 0x1F7A7),
198
+ ]
199
+
200
+ class Cyrillic(unicode_set):
201
+ """Unicode set for Cyrillic Unicode Character Range"""
202
+ _ranges: UnicodeRangeList = [
203
+ (0x0400, 0x052F),
204
+ (0x1C80, 0x1C88),
205
+ (0x1D2B,),
206
+ (0x1D78,),
207
+ (0x2DE0, 0x2DFF),
208
+ (0xA640, 0xA672),
209
+ (0xA674, 0xA69F),
210
+ (0xFE2E, 0xFE2F),
211
+ ]
212
+
213
+ class Chinese(unicode_set):
214
+ """Unicode set for Chinese Unicode Character Range"""
215
+ _ranges: UnicodeRangeList = [
216
+ (0x2E80, 0x2E99),
217
+ (0x2E9B, 0x2EF3),
218
+ (0x31C0, 0x31E3),
219
+ (0x3400, 0x4DB5),
220
+ (0x4E00, 0x9FEF),
221
+ (0xA700, 0xA707),
222
+ (0xF900, 0xFA6D),
223
+ (0xFA70, 0xFAD9),
224
+ (0x16FE2, 0x16FE3),
225
+ (0x1F210, 0x1F212),
226
+ (0x1F214, 0x1F23B),
227
+ (0x1F240, 0x1F248),
228
+ (0x20000, 0x2A6D6),
229
+ (0x2A700, 0x2B734),
230
+ (0x2B740, 0x2B81D),
231
+ (0x2B820, 0x2CEA1),
232
+ (0x2CEB0, 0x2EBE0),
233
+ (0x2F800, 0x2FA1D),
234
+ ]
235
+
236
+ class Japanese(unicode_set):
237
+ """Unicode set for Japanese Unicode Character Range, combining Kanji, Hiragana, and Katakana ranges"""
238
+
239
+ class Kanji(unicode_set):
240
+ "Unicode set for Kanji Unicode Character Range"
241
+ _ranges: UnicodeRangeList = [
242
+ (0x4E00, 0x9FBF),
243
+ (0x3000, 0x303F),
244
+ ]
245
+
246
+ class Hiragana(unicode_set):
247
+ """Unicode set for Hiragana Unicode Character Range"""
248
+ _ranges: UnicodeRangeList = [
249
+ (0x3041, 0x3096),
250
+ (0x3099, 0x30A0),
251
+ (0x30FC,),
252
+ (0xFF70,),
253
+ (0x1B001,),
254
+ (0x1B150, 0x1B152),
255
+ (0x1F200,),
256
+ ]
257
+
258
+ class Katakana(unicode_set):
259
+ """Unicode set for Katakana Unicode Character Range"""
260
+ _ranges: UnicodeRangeList = [
261
+ (0x3099, 0x309C),
262
+ (0x30A0, 0x30FF),
263
+ (0x31F0, 0x31FF),
264
+ (0x32D0, 0x32FE),
265
+ (0xFF65, 0xFF9F),
266
+ (0x1B000,),
267
+ (0x1B164, 0x1B167),
268
+ (0x1F201, 0x1F202),
269
+ (0x1F213,),
270
+ ]
271
+
272
+ 漢字 = Kanji
273
+ カタカナ = Katakana
274
+ ひらがな = Hiragana
275
+
276
+ _ranges = (
277
+ Kanji._ranges
278
+ + Hiragana._ranges
279
+ + Katakana._ranges
280
+ )
281
+
282
+ class Hangul(unicode_set):
283
+ """Unicode set for Hangul (Korean) Unicode Character Range"""
284
+ _ranges: UnicodeRangeList = [
285
+ (0x1100, 0x11FF),
286
+ (0x302E, 0x302F),
287
+ (0x3131, 0x318E),
288
+ (0x3200, 0x321C),
289
+ (0x3260, 0x327B),
290
+ (0x327E,),
291
+ (0xA960, 0xA97C),
292
+ (0xAC00, 0xD7A3),
293
+ (0xD7B0, 0xD7C6),
294
+ (0xD7CB, 0xD7FB),
295
+ (0xFFA0, 0xFFBE),
296
+ (0xFFC2, 0xFFC7),
297
+ (0xFFCA, 0xFFCF),
298
+ (0xFFD2, 0xFFD7),
299
+ (0xFFDA, 0xFFDC),
300
+ ]
301
+
302
+ Korean = Hangul
303
+
304
+ class CJK(Chinese, Japanese, Hangul):
305
+ """Unicode set for combined Chinese, Japanese, and Korean (CJK) Unicode Character Range"""
306
+
307
+ class Thai(unicode_set):
308
+ """Unicode set for Thai Unicode Character Range"""
309
+ _ranges: UnicodeRangeList = [
310
+ (0x0E01, 0x0E3A),
311
+ (0x0E3F, 0x0E5B)
312
+ ]
313
+
314
+ class Arabic(unicode_set):
315
+ """Unicode set for Arabic Unicode Character Range"""
316
+ _ranges: UnicodeRangeList = [
317
+ (0x0600, 0x061B),
318
+ (0x061E, 0x06FF),
319
+ (0x0700, 0x077F),
320
+ ]
321
+
322
+ class Hebrew(unicode_set):
323
+ """Unicode set for Hebrew Unicode Character Range"""
324
+ _ranges: UnicodeRangeList = [
325
+ (0x0591, 0x05C7),
326
+ (0x05D0, 0x05EA),
327
+ (0x05EF, 0x05F4),
328
+ (0xFB1D, 0xFB36),
329
+ (0xFB38, 0xFB3C),
330
+ (0xFB3E,),
331
+ (0xFB40, 0xFB41),
332
+ (0xFB43, 0xFB44),
333
+ (0xFB46, 0xFB4F),
334
+ ]
335
+
336
+ class Devanagari(unicode_set):
337
+ """Unicode set for Devanagari Unicode Character Range"""
338
+ _ranges: UnicodeRangeList = [
339
+ (0x0900, 0x097F),
340
+ (0xA8E0, 0xA8FF)
341
+ ]
342
+
343
+ BMP = BasicMultilingualPlane
344
+
345
+ # add language identifiers using language Unicode
346
+ العربية = Arabic
347
+ 中文 = Chinese
348
+ кириллица = Cyrillic
349
+ Ελληνικά = Greek
350
+ עִברִית = Hebrew
351
+ 日本語 = Japanese
352
+ 한국어 = Korean
353
+ ไทย = Thai
354
+ देवनागरी = Devanagari
355
+
356
+ # fmt: on
openflamingo/lib/python3.10/site-packages/regex/__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from .regex import *
2
+ from . import regex
3
+ __all__ = regex.__all__
openflamingo/lib/python3.10/site-packages/regex/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (225 Bytes). View file
 
openflamingo/lib/python3.10/site-packages/regex/__pycache__/regex.cpython-310.pyc ADDED
Binary file (25.5 kB). View file
 
openflamingo/lib/python3.10/site-packages/regex/_regex_core.py ADDED
The diff for this file is too large to render. See raw diff
 
openflamingo/lib/python3.10/site-packages/regex/regex.py ADDED
@@ -0,0 +1,746 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #
2
+ # Secret Labs' Regular Expression Engine
3
+ #
4
+ # Copyright (c) 1998-2001 by Secret Labs AB. All rights reserved.
5
+ #
6
+ # This version of the SRE library can be redistributed under CNRI's
7
+ # Python 1.6 license. For any other use, please contact Secret Labs
8
+ # AB (info@pythonware.com).
9
+ #
10
+ # Portions of this engine have been developed in cooperation with
11
+ # CNRI. Hewlett-Packard provided funding for 1.6 integration and
12
+ # other compatibility work.
13
+ #
14
+ # 2010-01-16 mrab Python front-end re-written and extended
15
+
16
+ r"""Support for regular expressions (RE).
17
+
18
+ This module provides regular expression matching operations similar to those
19
+ found in Perl. It supports both 8-bit and Unicode strings; both the pattern and
20
+ the strings being processed can contain null bytes and characters outside the
21
+ US ASCII range.
22
+
23
+ Regular expressions can contain both special and ordinary characters. Most
24
+ ordinary characters, like "A", "a", or "0", are the simplest regular
25
+ expressions; they simply match themselves. You can concatenate ordinary
26
+ characters, so last matches the string 'last'.
27
+
28
+ There are a few differences between the old (legacy) behaviour and the new
29
+ (enhanced) behaviour, which are indicated by VERSION0 or VERSION1.
30
+
31
+ The special characters are:
32
+ "." Matches any character except a newline.
33
+ "^" Matches the start of the string.
34
+ "$" Matches the end of the string or just before the
35
+ newline at the end of the string.
36
+ "*" Matches 0 or more (greedy) repetitions of the preceding
37
+ RE. Greedy means that it will match as many repetitions
38
+ as possible.
39
+ "+" Matches 1 or more (greedy) repetitions of the preceding
40
+ RE.
41
+ "?" Matches 0 or 1 (greedy) of the preceding RE.
42
+ *?,+?,?? Non-greedy versions of the previous three special
43
+ characters.
44
+ *+,++,?+ Possessive versions of the previous three special
45
+ characters.
46
+ {m,n} Matches from m to n repetitions of the preceding RE.
47
+ {m,n}? Non-greedy version of the above.
48
+ {m,n}+ Possessive version of the above.
49
+ {...} Fuzzy matching constraints.
50
+ "\\" Either escapes special characters or signals a special
51
+ sequence.
52
+ [...] Indicates a set of characters. A "^" as the first
53
+ character indicates a complementing set.
54
+ "|" A|B, creates an RE that will match either A or B.
55
+ (...) Matches the RE inside the parentheses. The contents are
56
+ captured and can be retrieved or matched later in the
57
+ string.
58
+ (?flags-flags) VERSION1: Sets/clears the flags for the remainder of
59
+ the group or pattern; VERSION0: Sets the flags for the
60
+ entire pattern.
61
+ (?:...) Non-capturing version of regular parentheses.
62
+ (?>...) Atomic non-capturing version of regular parentheses.
63
+ (?flags-flags:...) Non-capturing version of regular parentheses with local
64
+ flags.
65
+ (?P<name>...) The substring matched by the group is accessible by
66
+ name.
67
+ (?<name>...) The substring matched by the group is accessible by
68
+ name.
69
+ (?P=name) Matches the text matched earlier by the group named
70
+ name.
71
+ (?#...) A comment; ignored.
72
+ (?=...) Matches if ... matches next, but doesn't consume the
73
+ string.
74
+ (?!...) Matches if ... doesn't match next.
75
+ (?<=...) Matches if preceded by ....
76
+ (?<!...) Matches if not preceded by ....
77
+ (?(id)yes|no) Matches yes pattern if group id matched, the (optional)
78
+ no pattern otherwise.
79
+ (?(DEFINE)...) If there's no group called "DEFINE", then ... will be
80
+ ignored, but any group definitions will be available.
81
+ (?|...|...) (?|A|B), creates an RE that will match either A or B,
82
+ but reuses capture group numbers across the
83
+ alternatives.
84
+ (*FAIL) Forces matching to fail, which means immediate
85
+ backtracking.
86
+ (*F) Abbreviation for (*FAIL).
87
+ (*PRUNE) Discards the current backtracking information. Its
88
+ effect doesn't extend outside an atomic group or a
89
+ lookaround.
90
+ (*SKIP) Similar to (*PRUNE), except that it also sets where in
91
+ the text the next attempt at matching the entire
92
+ pattern will start. Its effect doesn't extend outside
93
+ an atomic group or a lookaround.
94
+
95
+ The fuzzy matching constraints are: "i" to permit insertions, "d" to permit
96
+ deletions, "s" to permit substitutions, "e" to permit any of these. Limits are
97
+ optional with "<=" and "<". If any type of error is provided then any type not
98
+ provided is not permitted.
99
+
100
+ A cost equation may be provided.
101
+
102
+ Examples:
103
+ (?:fuzzy){i<=2}
104
+ (?:fuzzy){i<=1,s<=2,d<=1,1i+1s+1d<3}
105
+
106
+ VERSION1: Set operators are supported, and a set can include nested sets. The
107
+ set operators, in order of increasing precedence, are:
108
+ || Set union ("x||y" means "x or y").
109
+ ~~ (double tilde) Symmetric set difference ("x~~y" means "x or y, but not
110
+ both").
111
+ && Set intersection ("x&&y" means "x and y").
112
+ -- (double dash) Set difference ("x--y" means "x but not y").
113
+
114
+ Implicit union, ie, simple juxtaposition like in [ab], has the highest
115
+ precedence.
116
+
117
+ VERSION0 and VERSION1:
118
+ The special sequences consist of "\\" and a character from the list below. If
119
+ the ordinary character is not on the list, then the resulting RE will match the
120
+ second character.
121
+ \number Matches the contents of the group of the same number if
122
+ number is no more than 2 digits, otherwise the character
123
+ with the 3-digit octal code.
124
+ \a Matches the bell character.
125
+ \A Matches only at the start of the string.
126
+ \b Matches the empty string, but only at the start or end of a
127
+ word.
128
+ \B Matches the empty string, but not at the start or end of a
129
+ word.
130
+ \d Matches any decimal digit; equivalent to the set [0-9] when
131
+ matching a bytestring or a Unicode string with the ASCII
132
+ flag, or the whole range of Unicode digits when matching a
133
+ Unicode string.
134
+ \D Matches any non-digit character; equivalent to [^\d].
135
+ \f Matches the formfeed character.
136
+ \g<name> Matches the text matched by the group named name.
137
+ \G Matches the empty string, but only at the position where
138
+ the search started.
139
+ \h Matches horizontal whitespace.
140
+ \K Keeps only what follows for the entire match.
141
+ \L<name> Named list. The list is provided as a keyword argument.
142
+ \m Matches the empty string, but only at the start of a word.
143
+ \M Matches the empty string, but only at the end of a word.
144
+ \n Matches the newline character.
145
+ \N{name} Matches the named character.
146
+ \p{name=value} Matches the character if its property has the specified
147
+ value.
148
+ \P{name=value} Matches the character if its property hasn't the specified
149
+ value.
150
+ \r Matches the carriage-return character.
151
+ \s Matches any whitespace character; equivalent to
152
+ [ \t\n\r\f\v].
153
+ \S Matches any non-whitespace character; equivalent to [^\s].
154
+ \t Matches the tab character.
155
+ \uXXXX Matches the Unicode codepoint with 4-digit hex code XXXX.
156
+ \UXXXXXXXX Matches the Unicode codepoint with 8-digit hex code
157
+ XXXXXXXX.
158
+ \v Matches the vertical tab character.
159
+ \w Matches any alphanumeric character; equivalent to
160
+ [a-zA-Z0-9_] when matching a bytestring or a Unicode string
161
+ with the ASCII flag, or the whole range of Unicode
162
+ alphanumeric characters (letters plus digits plus
163
+ underscore) when matching a Unicode string. With LOCALE, it
164
+ will match the set [0-9_] plus characters defined as
165
+ letters for the current locale.
166
+ \W Matches the complement of \w; equivalent to [^\w].
167
+ \xXX Matches the character with 2-digit hex code XX.
168
+ \X Matches a grapheme.
169
+ \Z Matches only at the end of the string.
170
+ \\ Matches a literal backslash.
171
+
172
+ This module exports the following functions:
173
+ match Match a regular expression pattern at the beginning of a string.
174
+ fullmatch Match a regular expression pattern against all of a string.
175
+ search Search a string for the presence of a pattern.
176
+ sub Substitute occurrences of a pattern found in a string using a
177
+ template string.
178
+ subf Substitute occurrences of a pattern found in a string using a
179
+ format string.
180
+ subn Same as sub, but also return the number of substitutions made.
181
+ subfn Same as subf, but also return the number of substitutions made.
182
+ split Split a string by the occurrences of a pattern. VERSION1: will
183
+ split at zero-width match; VERSION0: won't split at zero-width
184
+ match.
185
+ splititer Return an iterator yielding the parts of a split string.
186
+ findall Find all occurrences of a pattern in a string.
187
+ finditer Return an iterator yielding a match object for each match.
188
+ compile Compile a pattern into a Pattern object.
189
+ purge Clear the regular expression cache.
190
+ escape Backslash all non-alphanumerics or special characters in a
191
+ string.
192
+
193
+ Most of the functions support a concurrent parameter: if True, the GIL will be
194
+ released during matching, allowing other Python threads to run concurrently. If
195
+ the string changes during matching, the behaviour is undefined. This parameter
196
+ is not needed when working on the builtin (immutable) string classes.
197
+
198
+ Some of the functions in this module take flags as optional parameters. Most of
199
+ these flags can also be set within an RE:
200
+ A a ASCII Make \w, \W, \b, \B, \d, and \D match the
201
+ corresponding ASCII character categories. Default
202
+ when matching a bytestring.
203
+ B b BESTMATCH Find the best fuzzy match (default is first).
204
+ D DEBUG Print the parsed pattern.
205
+ E e ENHANCEMATCH Attempt to improve the fit after finding the first
206
+ fuzzy match.
207
+ F f FULLCASE Use full case-folding when performing
208
+ case-insensitive matching in Unicode.
209
+ I i IGNORECASE Perform case-insensitive matching.
210
+ L L LOCALE Make \w, \W, \b, \B, \d, and \D dependent on the
211
+ current locale. (One byte per character only.)
212
+ M m MULTILINE "^" matches the beginning of lines (after a newline)
213
+ as well as the string. "$" matches the end of lines
214
+ (before a newline) as well as the end of the string.
215
+ P p POSIX Perform POSIX-standard matching (leftmost longest).
216
+ R r REVERSE Searches backwards.
217
+ S s DOTALL "." matches any character at all, including the
218
+ newline.
219
+ U u UNICODE Make \w, \W, \b, \B, \d, and \D dependent on the
220
+ Unicode locale. Default when matching a Unicode
221
+ string.
222
+ V0 V0 VERSION0 Turn on the old legacy behaviour.
223
+ V1 V1 VERSION1 Turn on the new enhanced behaviour. This flag
224
+ includes the FULLCASE flag.
225
+ W w WORD Make \b and \B work with default Unicode word breaks
226
+ and make ".", "^" and "$" work with Unicode line
227
+ breaks.
228
+ X x VERBOSE Ignore whitespace and comments for nicer looking REs.
229
+
230
+ This module also defines an exception 'error'.
231
+
232
+ """
233
+
234
+ # Public symbols.
235
+ __all__ = ["cache_all", "compile", "DEFAULT_VERSION", "escape", "findall",
236
+ "finditer", "fullmatch", "match", "purge", "search", "split", "splititer",
237
+ "sub", "subf", "subfn", "subn", "template", "Scanner", "A", "ASCII", "B",
238
+ "BESTMATCH", "D", "DEBUG", "E", "ENHANCEMATCH", "S", "DOTALL", "F",
239
+ "FULLCASE", "I", "IGNORECASE", "L", "LOCALE", "M", "MULTILINE", "P", "POSIX",
240
+ "R", "REVERSE", "T", "TEMPLATE", "U", "UNICODE", "V0", "VERSION0", "V1",
241
+ "VERSION1", "X", "VERBOSE", "W", "WORD", "error", "Regex", "__version__",
242
+ "__doc__", "RegexFlag"]
243
+
244
+ __version__ = "2.5.148"
245
+
246
+ # --------------------------------------------------------------------
247
+ # Public interface.
248
+
249
+ def match(pattern, string, flags=0, pos=None, endpos=None, partial=False,
250
+ concurrent=None, timeout=None, ignore_unused=False, **kwargs):
251
+ """Try to apply the pattern at the start of the string, returning a match
252
+ object, or None if no match was found."""
253
+ pat = _compile(pattern, flags, ignore_unused, kwargs, True)
254
+ return pat.match(string, pos, endpos, concurrent, partial, timeout)
255
+
256
+ def fullmatch(pattern, string, flags=0, pos=None, endpos=None, partial=False,
257
+ concurrent=None, timeout=None, ignore_unused=False, **kwargs):
258
+ """Try to apply the pattern against all of the string, returning a match
259
+ object, or None if no match was found."""
260
+ pat = _compile(pattern, flags, ignore_unused, kwargs, True)
261
+ return pat.fullmatch(string, pos, endpos, concurrent, partial, timeout)
262
+
263
+ def search(pattern, string, flags=0, pos=None, endpos=None, partial=False,
264
+ concurrent=None, timeout=None, ignore_unused=False, **kwargs):
265
+ """Search through string looking for a match to the pattern, returning a
266
+ match object, or None if no match was found."""
267
+ pat = _compile(pattern, flags, ignore_unused, kwargs, True)
268
+ return pat.search(string, pos, endpos, concurrent, partial, timeout)
269
+
270
+ def sub(pattern, repl, string, count=0, flags=0, pos=None, endpos=None,
271
+ concurrent=None, timeout=None, ignore_unused=False, **kwargs):
272
+ """Return the string obtained by replacing the leftmost (or rightmost with a
273
+ reverse pattern) non-overlapping occurrences of the pattern in string by the
274
+ replacement repl. repl can be either a string or a callable; if a string,
275
+ backslash escapes in it are processed; if a callable, it's passed the match
276
+ object and must return a replacement string to be used."""
277
+ pat = _compile(pattern, flags, ignore_unused, kwargs, True)
278
+ return pat.sub(repl, string, count, pos, endpos, concurrent, timeout)
279
+
280
+ def subf(pattern, format, string, count=0, flags=0, pos=None, endpos=None,
281
+ concurrent=None, timeout=None, ignore_unused=False, **kwargs):
282
+ """Return the string obtained by replacing the leftmost (or rightmost with a
283
+ reverse pattern) non-overlapping occurrences of the pattern in string by the
284
+ replacement format. format can be either a string or a callable; if a string,
285
+ it's treated as a format string; if a callable, it's passed the match object
286
+ and must return a replacement string to be used."""
287
+ pat = _compile(pattern, flags, ignore_unused, kwargs, True)
288
+ return pat.subf(format, string, count, pos, endpos, concurrent, timeout)
289
+
290
+ def subn(pattern, repl, string, count=0, flags=0, pos=None, endpos=None,
291
+ concurrent=None, timeout=None, ignore_unused=False, **kwargs):
292
+ """Return a 2-tuple containing (new_string, number). new_string is the string
293
+ obtained by replacing the leftmost (or rightmost with a reverse pattern)
294
+ non-overlapping occurrences of the pattern in the source string by the
295
+ replacement repl. number is the number of substitutions that were made. repl
296
+ can be either a string or a callable; if a string, backslash escapes in it
297
+ are processed; if a callable, it's passed the match object and must return a
298
+ replacement string to be used."""
299
+ pat = _compile(pattern, flags, ignore_unused, kwargs, True)
300
+ return pat.subn(repl, string, count, pos, endpos, concurrent, timeout)
301
+
302
+ def subfn(pattern, format, string, count=0, flags=0, pos=None, endpos=None,
303
+ concurrent=None, timeout=None, ignore_unused=False, **kwargs):
304
+ """Return a 2-tuple containing (new_string, number). new_string is the string
305
+ obtained by replacing the leftmost (or rightmost with a reverse pattern)
306
+ non-overlapping occurrences of the pattern in the source string by the
307
+ replacement format. number is the number of substitutions that were made. format
308
+ can be either a string or a callable; if a string, it's treated as a format
309
+ string; if a callable, it's passed the match object and must return a
310
+ replacement string to be used."""
311
+ pat = _compile(pattern, flags, ignore_unused, kwargs, True)
312
+ return pat.subfn(format, string, count, pos, endpos, concurrent, timeout)
313
+
314
+ def split(pattern, string, maxsplit=0, flags=0, concurrent=None, timeout=None,
315
+ ignore_unused=False, **kwargs):
316
+ """Split the source string by the occurrences of the pattern, returning a
317
+ list containing the resulting substrings. If capturing parentheses are used
318
+ in pattern, then the text of all groups in the pattern are also returned as
319
+ part of the resulting list. If maxsplit is nonzero, at most maxsplit splits
320
+ occur, and the remainder of the string is returned as the final element of
321
+ the list."""
322
+ pat = _compile(pattern, flags, ignore_unused, kwargs, True)
323
+ return pat.split(string, maxsplit, concurrent, timeout)
324
+
325
+ def splititer(pattern, string, maxsplit=0, flags=0, concurrent=None,
326
+ timeout=None, ignore_unused=False, **kwargs):
327
+ "Return an iterator yielding the parts of a split string."
328
+ pat = _compile(pattern, flags, ignore_unused, kwargs, True)
329
+ return pat.splititer(string, maxsplit, concurrent, timeout)
330
+
331
+ def findall(pattern, string, flags=0, pos=None, endpos=None, overlapped=False,
332
+ concurrent=None, timeout=None, ignore_unused=False, **kwargs):
333
+ """Return a list of all matches in the string. The matches may be overlapped
334
+ if overlapped is True. If one or more groups are present in the pattern,
335
+ return a list of groups; this will be a list of tuples if the pattern has
336
+ more than one group. Empty matches are included in the result."""
337
+ pat = _compile(pattern, flags, ignore_unused, kwargs, True)
338
+ return pat.findall(string, pos, endpos, overlapped, concurrent, timeout)
339
+
340
+ def finditer(pattern, string, flags=0, pos=None, endpos=None, overlapped=False,
341
+ partial=False, concurrent=None, timeout=None, ignore_unused=False, **kwargs):
342
+ """Return an iterator over all matches in the string. The matches may be
343
+ overlapped if overlapped is True. For each match, the iterator returns a
344
+ match object. Empty matches are included in the result."""
345
+ pat = _compile(pattern, flags, ignore_unused, kwargs, True)
346
+ return pat.finditer(string, pos, endpos, overlapped, concurrent, partial,
347
+ timeout)
348
+
349
+ def compile(pattern, flags=0, ignore_unused=False, cache_pattern=None, **kwargs):
350
+ "Compile a regular expression pattern, returning a pattern object."
351
+ if cache_pattern is None:
352
+ cache_pattern = _cache_all
353
+ return _compile(pattern, flags, ignore_unused, kwargs, cache_pattern)
354
+
355
+ def purge():
356
+ "Clear the regular expression cache"
357
+ _cache.clear()
358
+ _locale_sensitive.clear()
359
+
360
+ # Whether to cache all patterns.
361
+ _cache_all = True
362
+
363
+ def cache_all(value=True):
364
+ """Sets whether to cache all patterns, even those are compiled explicitly.
365
+ Passing None has no effect, but returns the current setting."""
366
+ global _cache_all
367
+
368
+ if value is None:
369
+ return _cache_all
370
+
371
+ _cache_all = value
372
+
373
+ def template(pattern, flags=0):
374
+ "Compile a template pattern, returning a pattern object."
375
+ return _compile(pattern, flags | TEMPLATE, False, {}, False)
376
+
377
+ def escape(pattern, special_only=True, literal_spaces=False):
378
+ """Escape a string for use as a literal in a pattern. If special_only is
379
+ True, escape only special characters, else escape all non-alphanumeric
380
+ characters. If literal_spaces is True, don't escape spaces."""
381
+ # Convert it to Unicode.
382
+ if isinstance(pattern, bytes):
383
+ p = pattern.decode("latin-1")
384
+ else:
385
+ p = pattern
386
+
387
+ s = []
388
+ if special_only:
389
+ for c in p:
390
+ if c == " " and literal_spaces:
391
+ s.append(c)
392
+ elif c in _METACHARS or c.isspace():
393
+ s.append("\\")
394
+ s.append(c)
395
+ else:
396
+ s.append(c)
397
+ else:
398
+ for c in p:
399
+ if c == " " and literal_spaces:
400
+ s.append(c)
401
+ elif c in _ALNUM:
402
+ s.append(c)
403
+ else:
404
+ s.append("\\")
405
+ s.append(c)
406
+
407
+ r = "".join(s)
408
+ # Convert it back to bytes if necessary.
409
+ if isinstance(pattern, bytes):
410
+ r = r.encode("latin-1")
411
+
412
+ return r
413
+
414
+ # --------------------------------------------------------------------
415
+ # Internals.
416
+
417
+ import regex._regex_core as _regex_core
418
+ import regex._regex as _regex
419
+ from threading import RLock as _RLock
420
+ from locale import getpreferredencoding as _getpreferredencoding
421
+ from regex._regex_core import *
422
+ from regex._regex_core import (_ALL_VERSIONS, _ALL_ENCODINGS, _FirstSetError,
423
+ _UnscopedFlagSet, _check_group_features, _compile_firstset,
424
+ _compile_replacement, _flatten_code, _fold_case, _get_required_string,
425
+ _parse_pattern, _shrink_cache)
426
+ from regex._regex_core import (ALNUM as _ALNUM, Info as _Info, OP as _OP, Source
427
+ as _Source, Fuzzy as _Fuzzy)
428
+
429
+ # Version 0 is the old behaviour, compatible with the original 're' module.
430
+ # Version 1 is the new behaviour, which differs slightly.
431
+
432
+ DEFAULT_VERSION = VERSION0
433
+
434
+ _METACHARS = frozenset("()[]{}?*+|^$\\.-#&~")
435
+
436
+ _regex_core.DEFAULT_VERSION = DEFAULT_VERSION
437
+
438
+ # Caches for the patterns and replacements.
439
+ _cache = {}
440
+ _cache_lock = _RLock()
441
+ _named_args = {}
442
+ _replacement_cache = {}
443
+ _locale_sensitive = {}
444
+
445
+ # Maximum size of the cache.
446
+ _MAXCACHE = 500
447
+ _MAXREPCACHE = 500
448
+
449
+ def _compile(pattern, flags, ignore_unused, kwargs, cache_it):
450
+ "Compiles a regular expression to a PatternObject."
451
+
452
+ global DEFAULT_VERSION
453
+ try:
454
+ from regex import DEFAULT_VERSION
455
+ except ImportError:
456
+ pass
457
+
458
+ # We won't bother to cache the pattern if we're debugging.
459
+ if (flags & DEBUG) != 0:
460
+ cache_it = False
461
+
462
+ # What locale is this pattern using?
463
+ locale_key = (type(pattern), pattern)
464
+ if _locale_sensitive.get(locale_key, True) or (flags & LOCALE) != 0:
465
+ # This pattern is, or might be, locale-sensitive.
466
+ pattern_locale = _getpreferredencoding()
467
+ else:
468
+ # This pattern is definitely not locale-sensitive.
469
+ pattern_locale = None
470
+
471
+ def complain_unused_args():
472
+ if ignore_unused:
473
+ return
474
+
475
+ # Complain about any unused keyword arguments, possibly resulting from a typo.
476
+ unused_kwargs = set(kwargs) - {k for k, v in args_needed}
477
+ if unused_kwargs:
478
+ any_one = next(iter(unused_kwargs))
479
+ raise ValueError('unused keyword argument {!a}'.format(any_one))
480
+
481
+ if cache_it:
482
+ try:
483
+ # Do we know what keyword arguments are needed?
484
+ args_key = pattern, type(pattern), flags
485
+ args_needed = _named_args[args_key]
486
+
487
+ # Are we being provided with its required keyword arguments?
488
+ args_supplied = set()
489
+ if args_needed:
490
+ for k, v in args_needed:
491
+ try:
492
+ args_supplied.add((k, frozenset(kwargs[k])))
493
+ except KeyError:
494
+ raise error("missing named list: {!r}".format(k))
495
+
496
+ complain_unused_args()
497
+
498
+ args_supplied = frozenset(args_supplied)
499
+
500
+ # Have we already seen this regular expression and named list?
501
+ pattern_key = (pattern, type(pattern), flags, args_supplied,
502
+ DEFAULT_VERSION, pattern_locale)
503
+ return _cache[pattern_key]
504
+ except KeyError:
505
+ # It's a new pattern, or new named list for a known pattern.
506
+ pass
507
+
508
+ # Guess the encoding from the class of the pattern string.
509
+ if isinstance(pattern, str):
510
+ guess_encoding = UNICODE
511
+ elif isinstance(pattern, bytes):
512
+ guess_encoding = ASCII
513
+ elif isinstance(pattern, Pattern):
514
+ if flags:
515
+ raise ValueError("cannot process flags argument with a compiled pattern")
516
+
517
+ return pattern
518
+ else:
519
+ raise TypeError("first argument must be a string or compiled pattern")
520
+
521
+ # Set the default version in the core code in case it has been changed.
522
+ _regex_core.DEFAULT_VERSION = DEFAULT_VERSION
523
+
524
+ global_flags = flags
525
+
526
+ while True:
527
+ caught_exception = None
528
+ try:
529
+ source = _Source(pattern)
530
+ info = _Info(global_flags, source.char_type, kwargs)
531
+ info.guess_encoding = guess_encoding
532
+ source.ignore_space = bool(info.flags & VERBOSE)
533
+ parsed = _parse_pattern(source, info)
534
+ break
535
+ except _UnscopedFlagSet:
536
+ # Remember the global flags for the next attempt.
537
+ global_flags = info.global_flags
538
+ except error as e:
539
+ caught_exception = e
540
+
541
+ if caught_exception:
542
+ raise error(caught_exception.msg, caught_exception.pattern,
543
+ caught_exception.pos)
544
+
545
+ if not source.at_end():
546
+ raise error("unbalanced parenthesis", pattern, source.pos)
547
+
548
+ # Check the global flags for conflicts.
549
+ version = (info.flags & _ALL_VERSIONS) or DEFAULT_VERSION
550
+ if version not in (0, VERSION0, VERSION1):
551
+ raise ValueError("VERSION0 and VERSION1 flags are mutually incompatible")
552
+
553
+ if (info.flags & _ALL_ENCODINGS) not in (0, ASCII, LOCALE, UNICODE):
554
+ raise ValueError("ASCII, LOCALE and UNICODE flags are mutually incompatible")
555
+
556
+ if isinstance(pattern, bytes) and (info.flags & UNICODE):
557
+ raise ValueError("cannot use UNICODE flag with a bytes pattern")
558
+
559
+ if not (info.flags & _ALL_ENCODINGS):
560
+ if isinstance(pattern, str):
561
+ info.flags |= UNICODE
562
+ else:
563
+ info.flags |= ASCII
564
+
565
+ reverse = bool(info.flags & REVERSE)
566
+ fuzzy = isinstance(parsed, _Fuzzy)
567
+
568
+ # Remember whether this pattern as an inline locale flag.
569
+ _locale_sensitive[locale_key] = info.inline_locale
570
+
571
+ # Fix the group references.
572
+ caught_exception = None
573
+ try:
574
+ parsed.fix_groups(pattern, reverse, False)
575
+ except error as e:
576
+ caught_exception = e
577
+
578
+ if caught_exception:
579
+ raise error(caught_exception.msg, caught_exception.pattern,
580
+ caught_exception.pos)
581
+
582
+ # Should we print the parsed pattern?
583
+ if flags & DEBUG:
584
+ parsed.dump(indent=0, reverse=reverse)
585
+
586
+ # Optimise the parsed pattern.
587
+ parsed = parsed.optimise(info, reverse)
588
+ parsed = parsed.pack_characters(info)
589
+
590
+ # Get the required string.
591
+ req_offset, req_chars, req_flags = _get_required_string(parsed, info.flags)
592
+
593
+ # Build the named lists.
594
+ named_lists = {}
595
+ named_list_indexes = [None] * len(info.named_lists_used)
596
+ args_needed = set()
597
+ for key, index in info.named_lists_used.items():
598
+ name, case_flags = key
599
+ values = frozenset(kwargs[name])
600
+ if case_flags:
601
+ items = frozenset(_fold_case(info, v) for v in values)
602
+ else:
603
+ items = values
604
+ named_lists[name] = values
605
+ named_list_indexes[index] = items
606
+ args_needed.add((name, values))
607
+
608
+ complain_unused_args()
609
+
610
+ # Check the features of the groups.
611
+ _check_group_features(info, parsed)
612
+
613
+ # Compile the parsed pattern. The result is a list of tuples.
614
+ code = parsed.compile(reverse)
615
+
616
+ # Is there a group call to the pattern as a whole?
617
+ key = (0, reverse, fuzzy)
618
+ ref = info.call_refs.get(key)
619
+ if ref is not None:
620
+ code = [(_OP.CALL_REF, ref)] + code + [(_OP.END, )]
621
+
622
+ # Add the final 'success' opcode.
623
+ code += [(_OP.SUCCESS, )]
624
+
625
+ # Compile the additional copies of the groups that we need.
626
+ for group, rev, fuz in info.additional_groups:
627
+ code += group.compile(rev, fuz)
628
+
629
+ # Flatten the code into a list of ints.
630
+ code = _flatten_code(code)
631
+
632
+ if not parsed.has_simple_start():
633
+ # Get the first set, if possible.
634
+ try:
635
+ fs_code = _compile_firstset(info, parsed.get_firstset(reverse))
636
+ fs_code = _flatten_code(fs_code)
637
+ code = fs_code + code
638
+ except _FirstSetError:
639
+ pass
640
+
641
+ # The named capture groups.
642
+ index_group = dict((v, n) for n, v in info.group_index.items())
643
+
644
+ # Create the PatternObject.
645
+ #
646
+ # Local flags like IGNORECASE affect the code generation, but aren't needed
647
+ # by the PatternObject itself. Conversely, global flags like LOCALE _don't_
648
+ # affect the code generation but _are_ needed by the PatternObject.
649
+ compiled_pattern = _regex.compile(pattern, info.flags | version, code,
650
+ info.group_index, index_group, named_lists, named_list_indexes,
651
+ req_offset, req_chars, req_flags, info.group_count)
652
+
653
+ # Do we need to reduce the size of the cache?
654
+ if len(_cache) >= _MAXCACHE:
655
+ with _cache_lock:
656
+ _shrink_cache(_cache, _named_args, _locale_sensitive, _MAXCACHE)
657
+
658
+ if cache_it:
659
+ if (info.flags & LOCALE) == 0:
660
+ pattern_locale = None
661
+
662
+ args_needed = frozenset(args_needed)
663
+
664
+ # Store this regular expression and named list.
665
+ pattern_key = (pattern, type(pattern), flags, args_needed,
666
+ DEFAULT_VERSION, pattern_locale)
667
+ _cache[pattern_key] = compiled_pattern
668
+
669
+ # Store what keyword arguments are needed.
670
+ _named_args[args_key] = args_needed
671
+
672
+ return compiled_pattern
673
+
674
+ def _compile_replacement_helper(pattern, template):
675
+ "Compiles a replacement template."
676
+ # This function is called by the _regex module.
677
+
678
+ # Have we seen this before?
679
+ key = pattern.pattern, pattern.flags, template
680
+ compiled = _replacement_cache.get(key)
681
+ if compiled is not None:
682
+ return compiled
683
+
684
+ if len(_replacement_cache) >= _MAXREPCACHE:
685
+ _replacement_cache.clear()
686
+
687
+ is_unicode = isinstance(template, str)
688
+ source = _Source(template)
689
+ if is_unicode:
690
+ def make_string(char_codes):
691
+ return "".join(chr(c) for c in char_codes)
692
+ else:
693
+ def make_string(char_codes):
694
+ return bytes(char_codes)
695
+
696
+ compiled = []
697
+ literal = []
698
+ while True:
699
+ ch = source.get()
700
+ if not ch:
701
+ break
702
+ if ch == "\\":
703
+ # '_compile_replacement' will return either an int group reference
704
+ # or a string literal. It returns items (plural) in order to handle
705
+ # a 2-character literal (an invalid escape sequence).
706
+ is_group, items = _compile_replacement(source, pattern, is_unicode)
707
+ if is_group:
708
+ # It's a group, so first flush the literal.
709
+ if literal:
710
+ compiled.append(make_string(literal))
711
+ literal = []
712
+ compiled.extend(items)
713
+ else:
714
+ literal.extend(items)
715
+ else:
716
+ literal.append(ord(ch))
717
+
718
+ # Flush the literal.
719
+ if literal:
720
+ compiled.append(make_string(literal))
721
+
722
+ _replacement_cache[key] = compiled
723
+
724
+ return compiled
725
+
726
+ # We define Pattern here after all the support objects have been defined.
727
+ _pat = _compile('', 0, False, {}, False)
728
+ Pattern = type(_pat)
729
+ Match = type(_pat.match(''))
730
+ del _pat
731
+
732
+ # Make Pattern public for typing annotations.
733
+ __all__.append("Pattern")
734
+ __all__.append("Match")
735
+
736
+ # We'll define an alias for the 'compile' function so that the repr of a
737
+ # pattern object is eval-able.
738
+ Regex = compile
739
+
740
+ # Register myself for pickling.
741
+ import copyreg as _copy_reg
742
+
743
+ def _pickle(pattern):
744
+ return _regex.compile, pattern._pickled_data
745
+
746
+ _copy_reg.pickle(Pattern, _pickle)
openflamingo/lib/python3.10/site-packages/regex/test_regex.py ADDED
The diff for this file is too large to render. See raw diff
 
openflamingo/lib/python3.10/site-packages/setproctitle/__init__.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Allow customization of the process title."""
2
+
3
+ import os
4
+ import sys
5
+ import logging
6
+
7
+ logger = logging.getLogger("setproctitle")
8
+
9
+ __version__ = "1.3.4"
10
+
11
+ __all__ = [
12
+ "setproctitle",
13
+ "getproctitle",
14
+ "setthreadtitle",
15
+ "getthreadtitle",
16
+ ]
17
+
18
+
19
+ def setproctitle(title: str) -> None:
20
+ logger.debug("setproctitle C module not available")
21
+ return None
22
+
23
+
24
+ def getproctitle() -> str:
25
+ logger.debug("setproctitle C module not available")
26
+ return " ".join(sys.argv)
27
+
28
+
29
+ def setthreadtitle(title: str) -> None:
30
+ logger.debug("setproctitle C module not available")
31
+ return None
32
+
33
+
34
+ def getthreadtitle() -> str:
35
+ logger.debug("setproctitle C module not available")
36
+ return ""
37
+
38
+
39
+ try:
40
+ from . import _setproctitle # type: ignore
41
+ except ImportError as e:
42
+ # Emulate SPT_DEBUG showing process info in the C module.
43
+ if os.environ.get("SPT_DEBUG", ""):
44
+ logging.basicConfig()
45
+ logger.setLevel(logging.DEBUG)
46
+ logger.debug("failed to import setproctitle: %s", e)
47
+ else:
48
+ setproctitle = _setproctitle.setproctitle # noqa: F811
49
+ getproctitle = _setproctitle.getproctitle # noqa: F811
50
+ setthreadtitle = _setproctitle.setthreadtitle # noqa: F811
51
+ getthreadtitle = _setproctitle.getthreadtitle # noqa: F811
52
+
53
+
54
+ # Call getproctitle to initialize structures and avoid problems caused
55
+ # by fork() on macOS (see #113).
56
+ if sys.platform == "darwin":
57
+ getproctitle()
openflamingo/lib/python3.10/site-packages/setproctitle/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (1.32 kB). View file
 
openflamingo/lib/python3.10/site-packages/setproctitle/_setproctitle.cpython-310-x86_64-linux-gnu.so ADDED
Binary file (68.8 kB). View file
 
openflamingo/lib/python3.10/site-packages/setproctitle/py.typed ADDED
File without changes
openflamingo/lib/python3.10/site-packages/wcwidth/__init__.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Wcwidth module.
3
+
4
+ https://github.com/jquast/wcwidth
5
+ """
6
+ # re-export all functions & definitions, even private ones, from top-level
7
+ # module path, to allow for 'from wcwidth import _private_func'. Of course,
8
+ # user beware that any _private function may disappear or change signature at
9
+ # any future version.
10
+
11
+ # local
12
+ from .wcwidth import ZERO_WIDTH # noqa
13
+ from .wcwidth import (WIDE_EASTASIAN,
14
+ VS16_NARROW_TO_WIDE,
15
+ wcwidth,
16
+ wcswidth,
17
+ _bisearch,
18
+ list_versions,
19
+ _wcmatch_version,
20
+ _wcversion_value)
21
+
22
+ # The __all__ attribute defines the items exported from statement,
23
+ # 'from wcwidth import *', but also to say, "This is the public API".
24
+ __all__ = ('wcwidth', 'wcswidth', 'list_versions')
25
+
26
+ # We also used pkg_resources to load unicode version tables from version.json,
27
+ # generated by bin/update-tables.py, but some environments are unable to
28
+ # import pkg_resources for one reason or another, yikes!
29
+ __version__ = '0.2.13'
openflamingo/lib/python3.10/site-packages/wcwidth/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (528 Bytes). View file