xplia 1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- venv/Lib/site-packages/_distutils_hack/__init__.py +222 -0
- venv/Lib/site-packages/_distutils_hack/override.py +1 -0
- venv/Lib/site-packages/pip/__init__.py +13 -0
- venv/Lib/site-packages/pip/__main__.py +24 -0
- venv/Lib/site-packages/pip/__pip-runner__.py +50 -0
- venv/Lib/site-packages/pip/_internal/__init__.py +19 -0
- venv/Lib/site-packages/pip/_internal/build_env.py +311 -0
- venv/Lib/site-packages/pip/_internal/cache.py +292 -0
- venv/Lib/site-packages/pip/_internal/cli/__init__.py +4 -0
- venv/Lib/site-packages/pip/_internal/cli/autocompletion.py +171 -0
- venv/Lib/site-packages/pip/_internal/cli/base_command.py +236 -0
- venv/Lib/site-packages/pip/_internal/cli/cmdoptions.py +1074 -0
- venv/Lib/site-packages/pip/_internal/cli/command_context.py +27 -0
- venv/Lib/site-packages/pip/_internal/cli/main.py +79 -0
- venv/Lib/site-packages/pip/_internal/cli/main_parser.py +134 -0
- venv/Lib/site-packages/pip/_internal/cli/parser.py +294 -0
- venv/Lib/site-packages/pip/_internal/cli/progress_bars.py +68 -0
- venv/Lib/site-packages/pip/_internal/cli/req_command.py +508 -0
- venv/Lib/site-packages/pip/_internal/cli/spinners.py +159 -0
- venv/Lib/site-packages/pip/_internal/cli/status_codes.py +6 -0
- venv/Lib/site-packages/pip/_internal/commands/__init__.py +132 -0
- venv/Lib/site-packages/pip/_internal/commands/cache.py +222 -0
- venv/Lib/site-packages/pip/_internal/commands/check.py +54 -0
- venv/Lib/site-packages/pip/_internal/commands/completion.py +121 -0
- venv/Lib/site-packages/pip/_internal/commands/configuration.py +282 -0
- venv/Lib/site-packages/pip/_internal/commands/debug.py +199 -0
- venv/Lib/site-packages/pip/_internal/commands/download.py +147 -0
- venv/Lib/site-packages/pip/_internal/commands/freeze.py +108 -0
- venv/Lib/site-packages/pip/_internal/commands/hash.py +59 -0
- venv/Lib/site-packages/pip/_internal/commands/help.py +41 -0
- venv/Lib/site-packages/pip/_internal/commands/index.py +139 -0
- venv/Lib/site-packages/pip/_internal/commands/inspect.py +92 -0
- venv/Lib/site-packages/pip/_internal/commands/install.py +778 -0
- venv/Lib/site-packages/pip/_internal/commands/list.py +368 -0
- venv/Lib/site-packages/pip/_internal/commands/search.py +174 -0
- venv/Lib/site-packages/pip/_internal/commands/show.py +189 -0
- venv/Lib/site-packages/pip/_internal/commands/uninstall.py +113 -0
- venv/Lib/site-packages/pip/_internal/commands/wheel.py +183 -0
- venv/Lib/site-packages/pip/_internal/configuration.py +381 -0
- venv/Lib/site-packages/pip/_internal/distributions/__init__.py +21 -0
- venv/Lib/site-packages/pip/_internal/distributions/base.py +39 -0
- venv/Lib/site-packages/pip/_internal/distributions/installed.py +23 -0
- venv/Lib/site-packages/pip/_internal/distributions/sdist.py +150 -0
- venv/Lib/site-packages/pip/_internal/distributions/wheel.py +34 -0
- venv/Lib/site-packages/pip/_internal/exceptions.py +733 -0
- venv/Lib/site-packages/pip/_internal/index/__init__.py +2 -0
- venv/Lib/site-packages/pip/_internal/index/collector.py +505 -0
- venv/Lib/site-packages/pip/_internal/index/package_finder.py +1029 -0
- venv/Lib/site-packages/pip/_internal/index/sources.py +223 -0
- venv/Lib/site-packages/pip/_internal/locations/__init__.py +467 -0
- venv/Lib/site-packages/pip/_internal/locations/_distutils.py +173 -0
- venv/Lib/site-packages/pip/_internal/locations/_sysconfig.py +213 -0
- venv/Lib/site-packages/pip/_internal/locations/base.py +81 -0
- venv/Lib/site-packages/pip/_internal/main.py +12 -0
- venv/Lib/site-packages/pip/_internal/metadata/__init__.py +127 -0
- venv/Lib/site-packages/pip/_internal/metadata/_json.py +84 -0
- venv/Lib/site-packages/pip/_internal/metadata/base.py +688 -0
- venv/Lib/site-packages/pip/_internal/metadata/importlib/__init__.py +4 -0
- venv/Lib/site-packages/pip/_internal/metadata/importlib/_compat.py +55 -0
- venv/Lib/site-packages/pip/_internal/metadata/importlib/_dists.py +224 -0
- venv/Lib/site-packages/pip/_internal/metadata/importlib/_envs.py +188 -0
- venv/Lib/site-packages/pip/_internal/metadata/pkg_resources.py +270 -0
- venv/Lib/site-packages/pip/_internal/models/__init__.py +2 -0
- venv/Lib/site-packages/pip/_internal/models/candidate.py +34 -0
- venv/Lib/site-packages/pip/_internal/models/direct_url.py +237 -0
- venv/Lib/site-packages/pip/_internal/models/format_control.py +80 -0
- venv/Lib/site-packages/pip/_internal/models/index.py +28 -0
- venv/Lib/site-packages/pip/_internal/models/installation_report.py +53 -0
- venv/Lib/site-packages/pip/_internal/models/link.py +581 -0
- venv/Lib/site-packages/pip/_internal/models/scheme.py +31 -0
- venv/Lib/site-packages/pip/_internal/models/search_scope.py +132 -0
- venv/Lib/site-packages/pip/_internal/models/selection_prefs.py +51 -0
- venv/Lib/site-packages/pip/_internal/models/target_python.py +110 -0
- venv/Lib/site-packages/pip/_internal/models/wheel.py +92 -0
- venv/Lib/site-packages/pip/_internal/network/__init__.py +2 -0
- venv/Lib/site-packages/pip/_internal/network/auth.py +561 -0
- venv/Lib/site-packages/pip/_internal/network/cache.py +69 -0
- venv/Lib/site-packages/pip/_internal/network/download.py +186 -0
- venv/Lib/site-packages/pip/_internal/network/lazy_wheel.py +210 -0
- venv/Lib/site-packages/pip/_internal/network/session.py +519 -0
- venv/Lib/site-packages/pip/_internal/network/utils.py +96 -0
- venv/Lib/site-packages/pip/_internal/network/xmlrpc.py +60 -0
- venv/Lib/site-packages/pip/_internal/operations/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/operations/build/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/operations/build/build_tracker.py +124 -0
- venv/Lib/site-packages/pip/_internal/operations/build/metadata.py +39 -0
- venv/Lib/site-packages/pip/_internal/operations/build/metadata_editable.py +41 -0
- venv/Lib/site-packages/pip/_internal/operations/build/metadata_legacy.py +74 -0
- venv/Lib/site-packages/pip/_internal/operations/build/wheel.py +37 -0
- venv/Lib/site-packages/pip/_internal/operations/build/wheel_editable.py +46 -0
- venv/Lib/site-packages/pip/_internal/operations/build/wheel_legacy.py +102 -0
- venv/Lib/site-packages/pip/_internal/operations/check.py +187 -0
- venv/Lib/site-packages/pip/_internal/operations/freeze.py +255 -0
- venv/Lib/site-packages/pip/_internal/operations/install/__init__.py +2 -0
- venv/Lib/site-packages/pip/_internal/operations/install/editable_legacy.py +46 -0
- venv/Lib/site-packages/pip/_internal/operations/install/wheel.py +740 -0
- venv/Lib/site-packages/pip/_internal/operations/prepare.py +743 -0
- venv/Lib/site-packages/pip/_internal/pyproject.py +179 -0
- venv/Lib/site-packages/pip/_internal/req/__init__.py +92 -0
- venv/Lib/site-packages/pip/_internal/req/constructors.py +506 -0
- venv/Lib/site-packages/pip/_internal/req/req_file.py +552 -0
- venv/Lib/site-packages/pip/_internal/req/req_install.py +874 -0
- venv/Lib/site-packages/pip/_internal/req/req_set.py +119 -0
- venv/Lib/site-packages/pip/_internal/req/req_uninstall.py +650 -0
- venv/Lib/site-packages/pip/_internal/resolution/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/resolution/base.py +20 -0
- venv/Lib/site-packages/pip/_internal/resolution/legacy/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/resolution/legacy/resolver.py +600 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/base.py +141 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/candidates.py +555 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/factory.py +730 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py +155 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/provider.py +255 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/reporter.py +80 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/requirements.py +165 -0
- venv/Lib/site-packages/pip/_internal/resolution/resolvelib/resolver.py +299 -0
- venv/Lib/site-packages/pip/_internal/self_outdated_check.py +242 -0
- venv/Lib/site-packages/pip/_internal/utils/__init__.py +0 -0
- venv/Lib/site-packages/pip/_internal/utils/_jaraco_text.py +109 -0
- venv/Lib/site-packages/pip/_internal/utils/_log.py +38 -0
- venv/Lib/site-packages/pip/_internal/utils/appdirs.py +52 -0
- venv/Lib/site-packages/pip/_internal/utils/compat.py +63 -0
- venv/Lib/site-packages/pip/_internal/utils/compatibility_tags.py +165 -0
- venv/Lib/site-packages/pip/_internal/utils/datetime.py +11 -0
- venv/Lib/site-packages/pip/_internal/utils/deprecation.py +120 -0
- venv/Lib/site-packages/pip/_internal/utils/direct_url_helpers.py +87 -0
- venv/Lib/site-packages/pip/_internal/utils/egg_link.py +72 -0
- venv/Lib/site-packages/pip/_internal/utils/encoding.py +36 -0
- venv/Lib/site-packages/pip/_internal/utils/entrypoints.py +84 -0
- venv/Lib/site-packages/pip/_internal/utils/filesystem.py +153 -0
- venv/Lib/site-packages/pip/_internal/utils/filetypes.py +27 -0
- venv/Lib/site-packages/pip/_internal/utils/glibc.py +88 -0
- venv/Lib/site-packages/pip/_internal/utils/hashes.py +151 -0
- venv/Lib/site-packages/pip/_internal/utils/inject_securetransport.py +35 -0
- venv/Lib/site-packages/pip/_internal/utils/logging.py +348 -0
- venv/Lib/site-packages/pip/_internal/utils/misc.py +735 -0
- venv/Lib/site-packages/pip/_internal/utils/models.py +39 -0
- venv/Lib/site-packages/pip/_internal/utils/packaging.py +57 -0
- venv/Lib/site-packages/pip/_internal/utils/setuptools_build.py +146 -0
- venv/Lib/site-packages/pip/_internal/utils/subprocess.py +260 -0
- venv/Lib/site-packages/pip/_internal/utils/temp_dir.py +246 -0
- venv/Lib/site-packages/pip/_internal/utils/unpacking.py +257 -0
- venv/Lib/site-packages/pip/_internal/utils/urls.py +62 -0
- venv/Lib/site-packages/pip/_internal/utils/virtualenv.py +104 -0
- venv/Lib/site-packages/pip/_internal/utils/wheel.py +136 -0
- venv/Lib/site-packages/pip/_internal/vcs/__init__.py +15 -0
- venv/Lib/site-packages/pip/_internal/vcs/bazaar.py +112 -0
- venv/Lib/site-packages/pip/_internal/vcs/git.py +526 -0
- venv/Lib/site-packages/pip/_internal/vcs/mercurial.py +163 -0
- venv/Lib/site-packages/pip/_internal/vcs/subversion.py +324 -0
- venv/Lib/site-packages/pip/_internal/vcs/versioncontrol.py +705 -0
- venv/Lib/site-packages/pip/_internal/wheel_builder.py +355 -0
- venv/Lib/site-packages/pip/_vendor/__init__.py +120 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/__init__.py +18 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/_cmd.py +61 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/adapter.py +137 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/cache.py +65 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/caches/__init__.py +9 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/caches/file_cache.py +188 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/caches/redis_cache.py +39 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/compat.py +32 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/controller.py +439 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/filewrapper.py +111 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/heuristics.py +139 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/serialize.py +190 -0
- venv/Lib/site-packages/pip/_vendor/cachecontrol/wrapper.py +33 -0
- venv/Lib/site-packages/pip/_vendor/certifi/__init__.py +4 -0
- venv/Lib/site-packages/pip/_vendor/certifi/__main__.py +12 -0
- venv/Lib/site-packages/pip/_vendor/certifi/core.py +108 -0
- venv/Lib/site-packages/pip/_vendor/chardet/__init__.py +115 -0
- venv/Lib/site-packages/pip/_vendor/chardet/big5freq.py +386 -0
- venv/Lib/site-packages/pip/_vendor/chardet/big5prober.py +47 -0
- venv/Lib/site-packages/pip/_vendor/chardet/chardistribution.py +261 -0
- venv/Lib/site-packages/pip/_vendor/chardet/charsetgroupprober.py +106 -0
- venv/Lib/site-packages/pip/_vendor/chardet/charsetprober.py +147 -0
- venv/Lib/site-packages/pip/_vendor/chardet/cli/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/chardet/cli/chardetect.py +112 -0
- venv/Lib/site-packages/pip/_vendor/chardet/codingstatemachine.py +90 -0
- venv/Lib/site-packages/pip/_vendor/chardet/codingstatemachinedict.py +19 -0
- venv/Lib/site-packages/pip/_vendor/chardet/cp949prober.py +49 -0
- venv/Lib/site-packages/pip/_vendor/chardet/enums.py +85 -0
- venv/Lib/site-packages/pip/_vendor/chardet/escprober.py +102 -0
- venv/Lib/site-packages/pip/_vendor/chardet/escsm.py +261 -0
- venv/Lib/site-packages/pip/_vendor/chardet/eucjpprober.py +102 -0
- venv/Lib/site-packages/pip/_vendor/chardet/euckrfreq.py +196 -0
- venv/Lib/site-packages/pip/_vendor/chardet/euckrprober.py +47 -0
- venv/Lib/site-packages/pip/_vendor/chardet/euctwfreq.py +388 -0
- venv/Lib/site-packages/pip/_vendor/chardet/euctwprober.py +47 -0
- venv/Lib/site-packages/pip/_vendor/chardet/gb2312freq.py +284 -0
- venv/Lib/site-packages/pip/_vendor/chardet/gb2312prober.py +47 -0
- venv/Lib/site-packages/pip/_vendor/chardet/hebrewprober.py +316 -0
- venv/Lib/site-packages/pip/_vendor/chardet/jisfreq.py +325 -0
- venv/Lib/site-packages/pip/_vendor/chardet/johabfreq.py +2382 -0
- venv/Lib/site-packages/pip/_vendor/chardet/johabprober.py +47 -0
- venv/Lib/site-packages/pip/_vendor/chardet/jpcntx.py +238 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langbulgarianmodel.py +4649 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langgreekmodel.py +4397 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langhebrewmodel.py +4380 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langhungarianmodel.py +4649 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langrussianmodel.py +5725 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langthaimodel.py +4380 -0
- venv/Lib/site-packages/pip/_vendor/chardet/langturkishmodel.py +4380 -0
- venv/Lib/site-packages/pip/_vendor/chardet/latin1prober.py +147 -0
- venv/Lib/site-packages/pip/_vendor/chardet/macromanprober.py +162 -0
- venv/Lib/site-packages/pip/_vendor/chardet/mbcharsetprober.py +95 -0
- venv/Lib/site-packages/pip/_vendor/chardet/mbcsgroupprober.py +57 -0
- venv/Lib/site-packages/pip/_vendor/chardet/mbcssm.py +661 -0
- venv/Lib/site-packages/pip/_vendor/chardet/metadata/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/chardet/metadata/languages.py +352 -0
- venv/Lib/site-packages/pip/_vendor/chardet/resultdict.py +16 -0
- venv/Lib/site-packages/pip/_vendor/chardet/sbcharsetprober.py +162 -0
- venv/Lib/site-packages/pip/_vendor/chardet/sbcsgroupprober.py +88 -0
- venv/Lib/site-packages/pip/_vendor/chardet/sjisprober.py +105 -0
- venv/Lib/site-packages/pip/_vendor/chardet/universaldetector.py +362 -0
- venv/Lib/site-packages/pip/_vendor/chardet/utf1632prober.py +225 -0
- venv/Lib/site-packages/pip/_vendor/chardet/utf8prober.py +82 -0
- venv/Lib/site-packages/pip/_vendor/chardet/version.py +9 -0
- venv/Lib/site-packages/pip/_vendor/colorama/__init__.py +7 -0
- venv/Lib/site-packages/pip/_vendor/colorama/ansi.py +102 -0
- venv/Lib/site-packages/pip/_vendor/colorama/ansitowin32.py +277 -0
- venv/Lib/site-packages/pip/_vendor/colorama/initialise.py +121 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/__init__.py +1 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/ansi_test.py +76 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/ansitowin32_test.py +294 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/initialise_test.py +189 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/isatty_test.py +57 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/utils.py +49 -0
- venv/Lib/site-packages/pip/_vendor/colorama/tests/winterm_test.py +131 -0
- venv/Lib/site-packages/pip/_vendor/colorama/win32.py +180 -0
- venv/Lib/site-packages/pip/_vendor/colorama/winterm.py +195 -0
- venv/Lib/site-packages/pip/_vendor/distlib/__init__.py +23 -0
- venv/Lib/site-packages/pip/_vendor/distlib/compat.py +1116 -0
- venv/Lib/site-packages/pip/_vendor/distlib/database.py +1350 -0
- venv/Lib/site-packages/pip/_vendor/distlib/index.py +508 -0
- venv/Lib/site-packages/pip/_vendor/distlib/locators.py +1300 -0
- venv/Lib/site-packages/pip/_vendor/distlib/manifest.py +393 -0
- venv/Lib/site-packages/pip/_vendor/distlib/markers.py +152 -0
- venv/Lib/site-packages/pip/_vendor/distlib/metadata.py +1076 -0
- venv/Lib/site-packages/pip/_vendor/distlib/resources.py +358 -0
- venv/Lib/site-packages/pip/_vendor/distlib/scripts.py +437 -0
- venv/Lib/site-packages/pip/_vendor/distlib/util.py +1932 -0
- venv/Lib/site-packages/pip/_vendor/distlib/version.py +739 -0
- venv/Lib/site-packages/pip/_vendor/distlib/wheel.py +1082 -0
- venv/Lib/site-packages/pip/_vendor/distro/__init__.py +54 -0
- venv/Lib/site-packages/pip/_vendor/distro/__main__.py +4 -0
- venv/Lib/site-packages/pip/_vendor/distro/distro.py +1399 -0
- venv/Lib/site-packages/pip/_vendor/idna/__init__.py +44 -0
- venv/Lib/site-packages/pip/_vendor/idna/codec.py +112 -0
- venv/Lib/site-packages/pip/_vendor/idna/compat.py +13 -0
- venv/Lib/site-packages/pip/_vendor/idna/core.py +400 -0
- venv/Lib/site-packages/pip/_vendor/idna/idnadata.py +2151 -0
- venv/Lib/site-packages/pip/_vendor/idna/intranges.py +54 -0
- venv/Lib/site-packages/pip/_vendor/idna/package_data.py +2 -0
- venv/Lib/site-packages/pip/_vendor/idna/uts46data.py +8600 -0
- venv/Lib/site-packages/pip/_vendor/msgpack/__init__.py +57 -0
- venv/Lib/site-packages/pip/_vendor/msgpack/exceptions.py +48 -0
- venv/Lib/site-packages/pip/_vendor/msgpack/ext.py +193 -0
- venv/Lib/site-packages/pip/_vendor/msgpack/fallback.py +1010 -0
- venv/Lib/site-packages/pip/_vendor/packaging/__about__.py +26 -0
- venv/Lib/site-packages/pip/_vendor/packaging/__init__.py +25 -0
- venv/Lib/site-packages/pip/_vendor/packaging/_manylinux.py +301 -0
- venv/Lib/site-packages/pip/_vendor/packaging/_musllinux.py +136 -0
- venv/Lib/site-packages/pip/_vendor/packaging/_structures.py +61 -0
- venv/Lib/site-packages/pip/_vendor/packaging/markers.py +304 -0
- venv/Lib/site-packages/pip/_vendor/packaging/requirements.py +146 -0
- venv/Lib/site-packages/pip/_vendor/packaging/specifiers.py +802 -0
- venv/Lib/site-packages/pip/_vendor/packaging/tags.py +487 -0
- venv/Lib/site-packages/pip/_vendor/packaging/utils.py +136 -0
- venv/Lib/site-packages/pip/_vendor/packaging/version.py +504 -0
- venv/Lib/site-packages/pip/_vendor/pkg_resources/__init__.py +3361 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/__init__.py +566 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/__main__.py +53 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/android.py +210 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/api.py +223 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/macos.py +91 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/unix.py +223 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/version.py +4 -0
- venv/Lib/site-packages/pip/_vendor/platformdirs/windows.py +255 -0
- venv/Lib/site-packages/pip/_vendor/pygments/__init__.py +82 -0
- venv/Lib/site-packages/pip/_vendor/pygments/__main__.py +17 -0
- venv/Lib/site-packages/pip/_vendor/pygments/cmdline.py +668 -0
- venv/Lib/site-packages/pip/_vendor/pygments/console.py +70 -0
- venv/Lib/site-packages/pip/_vendor/pygments/filter.py +71 -0
- venv/Lib/site-packages/pip/_vendor/pygments/filters/__init__.py +940 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatter.py +124 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/__init__.py +158 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/_mapping.py +23 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/bbcode.py +108 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/groff.py +170 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/html.py +989 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/img.py +645 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/irc.py +154 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/latex.py +521 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/other.py +161 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/pangomarkup.py +83 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/rtf.py +146 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/svg.py +188 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/terminal.py +127 -0
- venv/Lib/site-packages/pip/_vendor/pygments/formatters/terminal256.py +338 -0
- venv/Lib/site-packages/pip/_vendor/pygments/lexer.py +943 -0
- venv/Lib/site-packages/pip/_vendor/pygments/lexers/__init__.py +362 -0
- venv/Lib/site-packages/pip/_vendor/pygments/lexers/_mapping.py +559 -0
- venv/Lib/site-packages/pip/_vendor/pygments/lexers/python.py +1198 -0
- venv/Lib/site-packages/pip/_vendor/pygments/modeline.py +43 -0
- venv/Lib/site-packages/pip/_vendor/pygments/plugin.py +88 -0
- venv/Lib/site-packages/pip/_vendor/pygments/regexopt.py +91 -0
- venv/Lib/site-packages/pip/_vendor/pygments/scanner.py +104 -0
- venv/Lib/site-packages/pip/_vendor/pygments/sphinxext.py +217 -0
- venv/Lib/site-packages/pip/_vendor/pygments/style.py +197 -0
- venv/Lib/site-packages/pip/_vendor/pygments/styles/__init__.py +103 -0
- venv/Lib/site-packages/pip/_vendor/pygments/token.py +213 -0
- venv/Lib/site-packages/pip/_vendor/pygments/unistring.py +153 -0
- venv/Lib/site-packages/pip/_vendor/pygments/util.py +330 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/__init__.py +322 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/actions.py +217 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/common.py +432 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/core.py +6115 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/diagram/__init__.py +656 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/exceptions.py +299 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/helpers.py +1100 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/results.py +796 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/testing.py +331 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/unicode.py +361 -0
- venv/Lib/site-packages/pip/_vendor/pyparsing/util.py +284 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/__init__.py +23 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/_compat.py +8 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/_impl.py +330 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/_in_process/__init__.py +18 -0
- venv/Lib/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py +353 -0
- venv/Lib/site-packages/pip/_vendor/requests/__init__.py +182 -0
- venv/Lib/site-packages/pip/_vendor/requests/__version__.py +14 -0
- venv/Lib/site-packages/pip/_vendor/requests/_internal_utils.py +50 -0
- venv/Lib/site-packages/pip/_vendor/requests/adapters.py +538 -0
- venv/Lib/site-packages/pip/_vendor/requests/api.py +157 -0
- venv/Lib/site-packages/pip/_vendor/requests/auth.py +315 -0
- venv/Lib/site-packages/pip/_vendor/requests/certs.py +24 -0
- venv/Lib/site-packages/pip/_vendor/requests/compat.py +67 -0
- venv/Lib/site-packages/pip/_vendor/requests/cookies.py +561 -0
- venv/Lib/site-packages/pip/_vendor/requests/exceptions.py +141 -0
- venv/Lib/site-packages/pip/_vendor/requests/help.py +131 -0
- venv/Lib/site-packages/pip/_vendor/requests/hooks.py +33 -0
- venv/Lib/site-packages/pip/_vendor/requests/models.py +1034 -0
- venv/Lib/site-packages/pip/_vendor/requests/packages.py +16 -0
- venv/Lib/site-packages/pip/_vendor/requests/sessions.py +833 -0
- venv/Lib/site-packages/pip/_vendor/requests/status_codes.py +128 -0
- venv/Lib/site-packages/pip/_vendor/requests/structures.py +99 -0
- venv/Lib/site-packages/pip/_vendor/requests/utils.py +1094 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/__init__.py +26 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/compat/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/compat/collections_abc.py +6 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/providers.py +133 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/reporters.py +43 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/resolvers.py +547 -0
- venv/Lib/site-packages/pip/_vendor/resolvelib/structs.py +170 -0
- venv/Lib/site-packages/pip/_vendor/rich/__init__.py +177 -0
- venv/Lib/site-packages/pip/_vendor/rich/__main__.py +274 -0
- venv/Lib/site-packages/pip/_vendor/rich/_cell_widths.py +451 -0
- venv/Lib/site-packages/pip/_vendor/rich/_emoji_codes.py +3610 -0
- venv/Lib/site-packages/pip/_vendor/rich/_emoji_replace.py +32 -0
- venv/Lib/site-packages/pip/_vendor/rich/_export_format.py +76 -0
- venv/Lib/site-packages/pip/_vendor/rich/_extension.py +10 -0
- venv/Lib/site-packages/pip/_vendor/rich/_fileno.py +24 -0
- venv/Lib/site-packages/pip/_vendor/rich/_inspect.py +270 -0
- venv/Lib/site-packages/pip/_vendor/rich/_log_render.py +94 -0
- venv/Lib/site-packages/pip/_vendor/rich/_loop.py +43 -0
- venv/Lib/site-packages/pip/_vendor/rich/_null_file.py +69 -0
- venv/Lib/site-packages/pip/_vendor/rich/_palettes.py +309 -0
- venv/Lib/site-packages/pip/_vendor/rich/_pick.py +17 -0
- venv/Lib/site-packages/pip/_vendor/rich/_ratio.py +160 -0
- venv/Lib/site-packages/pip/_vendor/rich/_spinners.py +482 -0
- venv/Lib/site-packages/pip/_vendor/rich/_stack.py +16 -0
- venv/Lib/site-packages/pip/_vendor/rich/_timer.py +19 -0
- venv/Lib/site-packages/pip/_vendor/rich/_win32_console.py +662 -0
- venv/Lib/site-packages/pip/_vendor/rich/_windows.py +72 -0
- venv/Lib/site-packages/pip/_vendor/rich/_windows_renderer.py +56 -0
- venv/Lib/site-packages/pip/_vendor/rich/_wrap.py +56 -0
- venv/Lib/site-packages/pip/_vendor/rich/abc.py +33 -0
- venv/Lib/site-packages/pip/_vendor/rich/align.py +311 -0
- venv/Lib/site-packages/pip/_vendor/rich/ansi.py +240 -0
- venv/Lib/site-packages/pip/_vendor/rich/bar.py +94 -0
- venv/Lib/site-packages/pip/_vendor/rich/box.py +517 -0
- venv/Lib/site-packages/pip/_vendor/rich/cells.py +154 -0
- venv/Lib/site-packages/pip/_vendor/rich/color.py +622 -0
- venv/Lib/site-packages/pip/_vendor/rich/color_triplet.py +38 -0
- venv/Lib/site-packages/pip/_vendor/rich/columns.py +187 -0
- venv/Lib/site-packages/pip/_vendor/rich/console.py +2633 -0
- venv/Lib/site-packages/pip/_vendor/rich/constrain.py +37 -0
- venv/Lib/site-packages/pip/_vendor/rich/containers.py +167 -0
- venv/Lib/site-packages/pip/_vendor/rich/control.py +225 -0
- venv/Lib/site-packages/pip/_vendor/rich/default_styles.py +190 -0
- venv/Lib/site-packages/pip/_vendor/rich/diagnose.py +37 -0
- venv/Lib/site-packages/pip/_vendor/rich/emoji.py +96 -0
- venv/Lib/site-packages/pip/_vendor/rich/errors.py +34 -0
- venv/Lib/site-packages/pip/_vendor/rich/file_proxy.py +57 -0
- venv/Lib/site-packages/pip/_vendor/rich/filesize.py +89 -0
- venv/Lib/site-packages/pip/_vendor/rich/highlighter.py +232 -0
- venv/Lib/site-packages/pip/_vendor/rich/json.py +140 -0
- venv/Lib/site-packages/pip/_vendor/rich/jupyter.py +101 -0
- venv/Lib/site-packages/pip/_vendor/rich/layout.py +443 -0
- venv/Lib/site-packages/pip/_vendor/rich/live.py +375 -0
- venv/Lib/site-packages/pip/_vendor/rich/live_render.py +113 -0
- venv/Lib/site-packages/pip/_vendor/rich/logging.py +289 -0
- venv/Lib/site-packages/pip/_vendor/rich/markup.py +246 -0
- venv/Lib/site-packages/pip/_vendor/rich/measure.py +151 -0
- venv/Lib/site-packages/pip/_vendor/rich/padding.py +141 -0
- venv/Lib/site-packages/pip/_vendor/rich/pager.py +34 -0
- venv/Lib/site-packages/pip/_vendor/rich/palette.py +100 -0
- venv/Lib/site-packages/pip/_vendor/rich/panel.py +308 -0
- venv/Lib/site-packages/pip/_vendor/rich/pretty.py +994 -0
- venv/Lib/site-packages/pip/_vendor/rich/progress.py +1702 -0
- venv/Lib/site-packages/pip/_vendor/rich/progress_bar.py +224 -0
- venv/Lib/site-packages/pip/_vendor/rich/prompt.py +376 -0
- venv/Lib/site-packages/pip/_vendor/rich/protocol.py +42 -0
- venv/Lib/site-packages/pip/_vendor/rich/region.py +10 -0
- venv/Lib/site-packages/pip/_vendor/rich/repr.py +149 -0
- venv/Lib/site-packages/pip/_vendor/rich/rule.py +130 -0
- venv/Lib/site-packages/pip/_vendor/rich/scope.py +86 -0
- venv/Lib/site-packages/pip/_vendor/rich/screen.py +54 -0
- venv/Lib/site-packages/pip/_vendor/rich/segment.py +739 -0
- venv/Lib/site-packages/pip/_vendor/rich/spinner.py +137 -0
- venv/Lib/site-packages/pip/_vendor/rich/status.py +132 -0
- venv/Lib/site-packages/pip/_vendor/rich/style.py +796 -0
- venv/Lib/site-packages/pip/_vendor/rich/styled.py +42 -0
- venv/Lib/site-packages/pip/_vendor/rich/syntax.py +948 -0
- venv/Lib/site-packages/pip/_vendor/rich/table.py +1002 -0
- venv/Lib/site-packages/pip/_vendor/rich/terminal_theme.py +153 -0
- venv/Lib/site-packages/pip/_vendor/rich/text.py +1307 -0
- venv/Lib/site-packages/pip/_vendor/rich/theme.py +115 -0
- venv/Lib/site-packages/pip/_vendor/rich/themes.py +5 -0
- venv/Lib/site-packages/pip/_vendor/rich/traceback.py +756 -0
- venv/Lib/site-packages/pip/_vendor/rich/tree.py +251 -0
- venv/Lib/site-packages/pip/_vendor/six.py +998 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/__init__.py +608 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/_asyncio.py +94 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/_utils.py +76 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/after.py +51 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/before.py +46 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/before_sleep.py +71 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/nap.py +43 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/retry.py +272 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/stop.py +103 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/tornadoweb.py +59 -0
- venv/Lib/site-packages/pip/_vendor/tenacity/wait.py +228 -0
- venv/Lib/site-packages/pip/_vendor/tomli/__init__.py +11 -0
- venv/Lib/site-packages/pip/_vendor/tomli/_parser.py +691 -0
- venv/Lib/site-packages/pip/_vendor/tomli/_re.py +107 -0
- venv/Lib/site-packages/pip/_vendor/tomli/_types.py +10 -0
- venv/Lib/site-packages/pip/_vendor/typing_extensions.py +3072 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/__init__.py +102 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/_collections.py +337 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/_version.py +2 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/connection.py +572 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/connectionpool.py +1132 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_appengine_environ.py +36 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/bindings.py +519 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/_securetransport/low_level.py +397 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/appengine.py +314 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/ntlmpool.py +130 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py +518 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/securetransport.py +921 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/contrib/socks.py +216 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/exceptions.py +323 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/fields.py +274 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/filepost.py +98 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py +0 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/makefile.py +51 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/backports/weakref_finalize.py +155 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/packages/six.py +1076 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/poolmanager.py +537 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/request.py +170 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/response.py +879 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/__init__.py +49 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/connection.py +149 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/proxy.py +57 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/queue.py +22 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/request.py +137 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/response.py +107 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/retry.py +620 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/ssl_.py +495 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/ssl_match_hostname.py +159 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/ssltransport.py +221 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/timeout.py +271 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/url.py +435 -0
- venv/Lib/site-packages/pip/_vendor/urllib3/util/wait.py +152 -0
- venv/Lib/site-packages/pip/_vendor/webencodings/__init__.py +342 -0
- venv/Lib/site-packages/pip/_vendor/webencodings/labels.py +231 -0
- venv/Lib/site-packages/pip/_vendor/webencodings/mklabels.py +59 -0
- venv/Lib/site-packages/pip/_vendor/webencodings/tests.py +153 -0
- venv/Lib/site-packages/pip/_vendor/webencodings/x_user_defined.py +325 -0
- venv/Lib/site-packages/pip/py.typed +4 -0
- venv/Lib/site-packages/pkg_resources/__init__.py +3296 -0
- venv/Lib/site-packages/pkg_resources/_vendor/__init__.py +0 -0
- venv/Lib/site-packages/pkg_resources/_vendor/appdirs.py +608 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/__init__.py +36 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/_adapters.py +170 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/_common.py +104 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/_compat.py +98 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/_itertools.py +35 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/_legacy.py +121 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/abc.py +137 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/readers.py +122 -0
- venv/Lib/site-packages/pkg_resources/_vendor/importlib_resources/simple.py +116 -0
- venv/Lib/site-packages/pkg_resources/_vendor/jaraco/__init__.py +0 -0
- venv/Lib/site-packages/pkg_resources/_vendor/jaraco/context.py +213 -0
- venv/Lib/site-packages/pkg_resources/_vendor/jaraco/functools.py +525 -0
- venv/Lib/site-packages/pkg_resources/_vendor/jaraco/text/__init__.py +599 -0
- venv/Lib/site-packages/pkg_resources/_vendor/more_itertools/__init__.py +4 -0
- venv/Lib/site-packages/pkg_resources/_vendor/more_itertools/more.py +4316 -0
- venv/Lib/site-packages/pkg_resources/_vendor/more_itertools/recipes.py +698 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/__about__.py +26 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/__init__.py +25 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/_manylinux.py +301 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/_musllinux.py +136 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/_structures.py +61 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/markers.py +304 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/requirements.py +146 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/specifiers.py +802 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/tags.py +487 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/utils.py +136 -0
- venv/Lib/site-packages/pkg_resources/_vendor/packaging/version.py +504 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/__init__.py +331 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/actions.py +207 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/common.py +424 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/core.py +5814 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/diagram/__init__.py +642 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/exceptions.py +267 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/helpers.py +1088 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/results.py +760 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/testing.py +331 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/unicode.py +352 -0
- venv/Lib/site-packages/pkg_resources/_vendor/pyparsing/util.py +235 -0
- venv/Lib/site-packages/pkg_resources/_vendor/zipp.py +329 -0
- venv/Lib/site-packages/pkg_resources/extern/__init__.py +76 -0
- venv/Lib/site-packages/setuptools/__init__.py +247 -0
- venv/Lib/site-packages/setuptools/_deprecation_warning.py +7 -0
- venv/Lib/site-packages/setuptools/_distutils/__init__.py +24 -0
- venv/Lib/site-packages/setuptools/_distutils/_collections.py +56 -0
- venv/Lib/site-packages/setuptools/_distutils/_functools.py +20 -0
- venv/Lib/site-packages/setuptools/_distutils/_macos_compat.py +12 -0
- venv/Lib/site-packages/setuptools/_distutils/_msvccompiler.py +572 -0
- venv/Lib/site-packages/setuptools/_distutils/archive_util.py +280 -0
- venv/Lib/site-packages/setuptools/_distutils/bcppcompiler.py +408 -0
- venv/Lib/site-packages/setuptools/_distutils/ccompiler.py +1220 -0
- venv/Lib/site-packages/setuptools/_distutils/cmd.py +436 -0
- venv/Lib/site-packages/setuptools/_distutils/command/__init__.py +25 -0
- venv/Lib/site-packages/setuptools/_distutils/command/_framework_compat.py +55 -0
- venv/Lib/site-packages/setuptools/_distutils/command/bdist.py +157 -0
- venv/Lib/site-packages/setuptools/_distutils/command/bdist_dumb.py +144 -0
- venv/Lib/site-packages/setuptools/_distutils/command/bdist_rpm.py +615 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build.py +153 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build_clib.py +208 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build_ext.py +787 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build_py.py +407 -0
- venv/Lib/site-packages/setuptools/_distutils/command/build_scripts.py +173 -0
- venv/Lib/site-packages/setuptools/_distutils/command/check.py +151 -0
- venv/Lib/site-packages/setuptools/_distutils/command/clean.py +76 -0
- venv/Lib/site-packages/setuptools/_distutils/command/config.py +377 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install.py +814 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_data.py +84 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_egg_info.py +91 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_headers.py +45 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_lib.py +238 -0
- venv/Lib/site-packages/setuptools/_distutils/command/install_scripts.py +61 -0
- venv/Lib/site-packages/setuptools/_distutils/command/py37compat.py +31 -0
- venv/Lib/site-packages/setuptools/_distutils/command/register.py +319 -0
- venv/Lib/site-packages/setuptools/_distutils/command/sdist.py +531 -0
- venv/Lib/site-packages/setuptools/_distutils/command/upload.py +205 -0
- venv/Lib/site-packages/setuptools/_distutils/config.py +139 -0
- venv/Lib/site-packages/setuptools/_distutils/core.py +291 -0
- venv/Lib/site-packages/setuptools/_distutils/cygwinccompiler.py +364 -0
- venv/Lib/site-packages/setuptools/_distutils/debug.py +5 -0
- venv/Lib/site-packages/setuptools/_distutils/dep_util.py +96 -0
- venv/Lib/site-packages/setuptools/_distutils/dir_util.py +243 -0
- venv/Lib/site-packages/setuptools/_distutils/dist.py +1286 -0
- venv/Lib/site-packages/setuptools/_distutils/errors.py +127 -0
- venv/Lib/site-packages/setuptools/_distutils/extension.py +248 -0
- venv/Lib/site-packages/setuptools/_distutils/fancy_getopt.py +470 -0
- venv/Lib/site-packages/setuptools/_distutils/file_util.py +249 -0
- venv/Lib/site-packages/setuptools/_distutils/filelist.py +371 -0
- venv/Lib/site-packages/setuptools/_distutils/log.py +80 -0
- venv/Lib/site-packages/setuptools/_distutils/msvc9compiler.py +832 -0
- venv/Lib/site-packages/setuptools/_distutils/msvccompiler.py +695 -0
- venv/Lib/site-packages/setuptools/_distutils/py38compat.py +8 -0
- venv/Lib/site-packages/setuptools/_distutils/py39compat.py +22 -0
- venv/Lib/site-packages/setuptools/_distutils/spawn.py +109 -0
- venv/Lib/site-packages/setuptools/_distutils/sysconfig.py +558 -0
- venv/Lib/site-packages/setuptools/_distutils/text_file.py +287 -0
- venv/Lib/site-packages/setuptools/_distutils/unixccompiler.py +401 -0
- venv/Lib/site-packages/setuptools/_distutils/util.py +513 -0
- venv/Lib/site-packages/setuptools/_distutils/version.py +358 -0
- venv/Lib/site-packages/setuptools/_distutils/versionpredicate.py +175 -0
- venv/Lib/site-packages/setuptools/_entry_points.py +86 -0
- venv/Lib/site-packages/setuptools/_imp.py +82 -0
- venv/Lib/site-packages/setuptools/_importlib.py +47 -0
- venv/Lib/site-packages/setuptools/_itertools.py +23 -0
- venv/Lib/site-packages/setuptools/_path.py +29 -0
- venv/Lib/site-packages/setuptools/_reqs.py +19 -0
- venv/Lib/site-packages/setuptools/_vendor/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/__init__.py +1047 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_adapters.py +68 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_collections.py +30 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_compat.py +71 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_functools.py +104 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_itertools.py +73 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_meta.py +48 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_metadata/_text.py +99 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/__init__.py +36 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/_adapters.py +170 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/_common.py +104 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/_compat.py +98 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/_itertools.py +35 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/_legacy.py +121 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/abc.py +137 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/readers.py +122 -0
- venv/Lib/site-packages/setuptools/_vendor/importlib_resources/simple.py +116 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/__init__.py +0 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/context.py +213 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/functools.py +525 -0
- venv/Lib/site-packages/setuptools/_vendor/jaraco/text/__init__.py +599 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/__init__.py +4 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/more.py +3824 -0
- venv/Lib/site-packages/setuptools/_vendor/more_itertools/recipes.py +620 -0
- venv/Lib/site-packages/setuptools/_vendor/ordered_set.py +488 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/__about__.py +26 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/__init__.py +25 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/_manylinux.py +301 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/_musllinux.py +136 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/_structures.py +61 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/markers.py +304 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/requirements.py +146 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/specifiers.py +802 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/tags.py +487 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/utils.py +136 -0
- venv/Lib/site-packages/setuptools/_vendor/packaging/version.py +504 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/__init__.py +331 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/actions.py +207 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/common.py +424 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/core.py +5814 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/diagram/__init__.py +642 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/exceptions.py +267 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/helpers.py +1088 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/results.py +760 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/testing.py +331 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/unicode.py +352 -0
- venv/Lib/site-packages/setuptools/_vendor/pyparsing/util.py +235 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/__init__.py +11 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/_parser.py +691 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/_re.py +107 -0
- venv/Lib/site-packages/setuptools/_vendor/tomli/_types.py +10 -0
- venv/Lib/site-packages/setuptools/_vendor/typing_extensions.py +2296 -0
- venv/Lib/site-packages/setuptools/_vendor/zipp.py +329 -0
- venv/Lib/site-packages/setuptools/archive_util.py +213 -0
- venv/Lib/site-packages/setuptools/build_meta.py +511 -0
- venv/Lib/site-packages/setuptools/command/__init__.py +12 -0
- venv/Lib/site-packages/setuptools/command/alias.py +78 -0
- venv/Lib/site-packages/setuptools/command/bdist_egg.py +457 -0
- venv/Lib/site-packages/setuptools/command/bdist_rpm.py +40 -0
- venv/Lib/site-packages/setuptools/command/build.py +146 -0
- venv/Lib/site-packages/setuptools/command/build_clib.py +101 -0
- venv/Lib/site-packages/setuptools/command/build_ext.py +383 -0
- venv/Lib/site-packages/setuptools/command/build_py.py +368 -0
- venv/Lib/site-packages/setuptools/command/develop.py +193 -0
- venv/Lib/site-packages/setuptools/command/dist_info.py +142 -0
- venv/Lib/site-packages/setuptools/command/easy_install.py +2312 -0
- venv/Lib/site-packages/setuptools/command/editable_wheel.py +844 -0
- venv/Lib/site-packages/setuptools/command/egg_info.py +763 -0
- venv/Lib/site-packages/setuptools/command/install.py +139 -0
- venv/Lib/site-packages/setuptools/command/install_egg_info.py +63 -0
- venv/Lib/site-packages/setuptools/command/install_lib.py +122 -0
- venv/Lib/site-packages/setuptools/command/install_scripts.py +70 -0
- venv/Lib/site-packages/setuptools/command/py36compat.py +134 -0
- venv/Lib/site-packages/setuptools/command/register.py +18 -0
- venv/Lib/site-packages/setuptools/command/rotate.py +64 -0
- venv/Lib/site-packages/setuptools/command/saveopts.py +22 -0
- venv/Lib/site-packages/setuptools/command/sdist.py +210 -0
- venv/Lib/site-packages/setuptools/command/setopt.py +149 -0
- venv/Lib/site-packages/setuptools/command/test.py +251 -0
- venv/Lib/site-packages/setuptools/command/upload.py +17 -0
- venv/Lib/site-packages/setuptools/command/upload_docs.py +213 -0
- venv/Lib/site-packages/setuptools/config/__init__.py +35 -0
- venv/Lib/site-packages/setuptools/config/_apply_pyprojecttoml.py +377 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/__init__.py +34 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/error_reporting.py +318 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/extra_validations.py +36 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/fastjsonschema_exceptions.py +51 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/fastjsonschema_validations.py +1035 -0
- venv/Lib/site-packages/setuptools/config/_validate_pyproject/formats.py +259 -0
- venv/Lib/site-packages/setuptools/config/expand.py +462 -0
- venv/Lib/site-packages/setuptools/config/pyprojecttoml.py +493 -0
- venv/Lib/site-packages/setuptools/config/setupcfg.py +762 -0
- venv/Lib/site-packages/setuptools/dep_util.py +25 -0
- venv/Lib/site-packages/setuptools/depends.py +176 -0
- venv/Lib/site-packages/setuptools/discovery.py +600 -0
- venv/Lib/site-packages/setuptools/dist.py +1222 -0
- venv/Lib/site-packages/setuptools/errors.py +58 -0
- venv/Lib/site-packages/setuptools/extension.py +148 -0
- venv/Lib/site-packages/setuptools/extern/__init__.py +76 -0
- venv/Lib/site-packages/setuptools/glob.py +167 -0
- venv/Lib/site-packages/setuptools/installer.py +104 -0
- venv/Lib/site-packages/setuptools/launch.py +36 -0
- venv/Lib/site-packages/setuptools/logging.py +36 -0
- venv/Lib/site-packages/setuptools/monkey.py +165 -0
- venv/Lib/site-packages/setuptools/msvc.py +1703 -0
- venv/Lib/site-packages/setuptools/namespaces.py +107 -0
- venv/Lib/site-packages/setuptools/package_index.py +1126 -0
- venv/Lib/site-packages/setuptools/py34compat.py +13 -0
- venv/Lib/site-packages/setuptools/sandbox.py +530 -0
- venv/Lib/site-packages/setuptools/unicode_utils.py +42 -0
- venv/Lib/site-packages/setuptools/version.py +6 -0
- venv/Lib/site-packages/setuptools/wheel.py +222 -0
- venv/Lib/site-packages/setuptools/windows_support.py +29 -0
- xplia/__init__.py +72 -0
- xplia/api/__init__.py +432 -0
- xplia/api/fastapi_app.py +453 -0
- xplia/cli.py +321 -0
- xplia/compliance/__init__.py +39 -0
- xplia/compliance/ai_act.py +538 -0
- xplia/compliance/compliance_checker.py +511 -0
- xplia/compliance/compliance_report.py +236 -0
- xplia/compliance/expert_review/__init__.py +18 -0
- xplia/compliance/expert_review/evaluation_criteria.py +209 -0
- xplia/compliance/expert_review/integration.py +270 -0
- xplia/compliance/expert_review/trust_expert_evaluator.py +379 -0
- xplia/compliance/explanation_rights.py +45 -0
- xplia/compliance/formatters/__init__.py +35 -0
- xplia/compliance/formatters/csv_formatter.py +179 -0
- xplia/compliance/formatters/html_formatter.py +689 -0
- xplia/compliance/formatters/html_trust_formatter.py +147 -0
- xplia/compliance/formatters/json_formatter.py +107 -0
- xplia/compliance/formatters/pdf_formatter.py +641 -0
- xplia/compliance/formatters/pdf_trust_formatter.py +309 -0
- xplia/compliance/formatters/trust_formatter_mixin.py +267 -0
- xplia/compliance/formatters/xml_formatter.py +173 -0
- xplia/compliance/gdpr.py +803 -0
- xplia/compliance/hipaa.py +134 -0
- xplia/compliance/report_base.py +205 -0
- xplia/compliance/report_generator.py +820 -0
- xplia/compliance/translations.py +299 -0
- xplia/core/__init__.py +98 -0
- xplia/core/base.py +391 -0
- xplia/core/config.py +297 -0
- xplia/core/factory.py +416 -0
- xplia/core/model_adapters/__init__.py +47 -0
- xplia/core/model_adapters/base.py +160 -0
- xplia/core/model_adapters/pytorch_adapter.py +339 -0
- xplia/core/model_adapters/sklearn_adapter.py +215 -0
- xplia/core/model_adapters/tensorflow_adapter.py +280 -0
- xplia/core/model_adapters/xgboost_adapter.py +295 -0
- xplia/core/optimizations.py +322 -0
- xplia/core/performance/__init__.py +57 -0
- xplia/core/performance/cache_manager.py +502 -0
- xplia/core/performance/memory_optimizer.py +465 -0
- xplia/core/performance/parallel_executor.py +327 -0
- xplia/core/registry.py +1234 -0
- xplia/explainers/__init__.py +70 -0
- xplia/explainers/__init__updated.py +62 -0
- xplia/explainers/adaptive/__init__.py +24 -0
- xplia/explainers/adaptive/explainer_selector.py +405 -0
- xplia/explainers/adaptive/explanation_quality.py +395 -0
- xplia/explainers/adaptive/fusion_strategies.py +297 -0
- xplia/explainers/adaptive/meta_explainer.py +320 -0
- xplia/explainers/adversarial/__init__.py +21 -0
- xplia/explainers/adversarial/adversarial_xai.py +678 -0
- xplia/explainers/anchor_explainer.py +1769 -0
- xplia/explainers/attention_explainer.py +996 -0
- xplia/explainers/bayesian/__init__.py +8 -0
- xplia/explainers/bayesian/bayesian_explainer.py +127 -0
- xplia/explainers/bias/__init__.py +17 -0
- xplia/explainers/bias/advanced_bias_detection.py +934 -0
- xplia/explainers/calibration/__init__.py +26 -0
- xplia/explainers/calibration/audience_adapter.py +376 -0
- xplia/explainers/calibration/audience_profiles.py +372 -0
- xplia/explainers/calibration/calibration_metrics.py +299 -0
- xplia/explainers/calibration/explanation_calibrator.py +460 -0
- xplia/explainers/causal/__init__.py +19 -0
- xplia/explainers/causal/causal_inference.py +669 -0
- xplia/explainers/certified/__init__.py +21 -0
- xplia/explainers/certified/certified_explanations.py +619 -0
- xplia/explainers/continual/__init__.py +8 -0
- xplia/explainers/continual/continual_explainer.py +102 -0
- xplia/explainers/counterfactual_explainer.py +804 -0
- xplia/explainers/counterfactuals/__init__.py +17 -0
- xplia/explainers/counterfactuals/advanced_counterfactuals.py +259 -0
- xplia/explainers/expert_evaluator.py +538 -0
- xplia/explainers/feature_importance_explainer.py +376 -0
- xplia/explainers/federated/__init__.py +17 -0
- xplia/explainers/federated/federated_xai.py +664 -0
- xplia/explainers/generative/__init__.py +15 -0
- xplia/explainers/generative/generative_explainer.py +243 -0
- xplia/explainers/gradient_explainer.py +3590 -0
- xplia/explainers/graph/__init__.py +26 -0
- xplia/explainers/graph/gnn_explainer.py +638 -0
- xplia/explainers/graph/molecular_explainer.py +438 -0
- xplia/explainers/lime_explainer.py +1580 -0
- xplia/explainers/llm/__init__.py +23 -0
- xplia/explainers/llm/llm_explainability.py +737 -0
- xplia/explainers/metalearning/__init__.py +15 -0
- xplia/explainers/metalearning/metalearning_explainer.py +276 -0
- xplia/explainers/moe/__init__.py +8 -0
- xplia/explainers/moe/moe_explainer.py +108 -0
- xplia/explainers/multimodal/__init__.py +30 -0
- xplia/explainers/multimodal/base.py +262 -0
- xplia/explainers/multimodal/diffusion_explainer.py +608 -0
- xplia/explainers/multimodal/foundation_model_explainer.py +323 -0
- xplia/explainers/multimodal/registry.py +139 -0
- xplia/explainers/multimodal/text_image_explainer.py +381 -0
- xplia/explainers/multimodal/vision_language_explainer.py +608 -0
- xplia/explainers/nas/__init__.py +5 -0
- xplia/explainers/nas/nas_explainer.py +65 -0
- xplia/explainers/neuralodes/__init__.py +5 -0
- xplia/explainers/neuralodes/neuralode_explainer.py +64 -0
- xplia/explainers/neurosymbolic/__init__.py +8 -0
- xplia/explainers/neurosymbolic/neurosymbolic_explainer.py +97 -0
- xplia/explainers/partial_dependence_explainer.py +509 -0
- xplia/explainers/privacy/__init__.py +21 -0
- xplia/explainers/privacy/differential_privacy_xai.py +624 -0
- xplia/explainers/quantum/__init__.py +5 -0
- xplia/explainers/quantum/quantum_explainer.py +79 -0
- xplia/explainers/recommender/__init__.py +8 -0
- xplia/explainers/recommender/recsys_explainer.py +124 -0
- xplia/explainers/reinforcement/__init__.py +15 -0
- xplia/explainers/reinforcement/rl_explainer.py +173 -0
- xplia/explainers/shap_explainer.py +2238 -0
- xplia/explainers/streaming/__init__.py +19 -0
- xplia/explainers/streaming/streaming_xai.py +703 -0
- xplia/explainers/timeseries/__init__.py +15 -0
- xplia/explainers/timeseries/timeseries_explainer.py +252 -0
- xplia/explainers/trust/__init__.py +24 -0
- xplia/explainers/trust/confidence_report.py +368 -0
- xplia/explainers/trust/fairwashing.py +489 -0
- xplia/explainers/trust/uncertainty.py +453 -0
- xplia/explainers/unified_explainer.py +566 -0
- xplia/explainers/unified_explainer_utils.py +309 -0
- xplia/integrations/__init__.py +3 -0
- xplia/integrations/mlflow_integration.py +331 -0
- xplia/integrations/wandb_integration.py +375 -0
- xplia/plugins/__init__.py +36 -0
- xplia/plugins/example_visualizer.py +11 -0
- xplia/utils/__init__.py +18 -0
- xplia/utils/performance.py +119 -0
- xplia/utils/validation.py +109 -0
- xplia/visualizations/__init__.py +31 -0
- xplia/visualizations/base.py +256 -0
- xplia/visualizations/boxplot_chart.py +224 -0
- xplia/visualizations/charts_impl.py +65 -0
- xplia/visualizations/gauge_chart.py +211 -0
- xplia/visualizations/gradient_viz.py +117 -0
- xplia/visualizations/heatmap_chart.py +173 -0
- xplia/visualizations/histogram_chart.py +176 -0
- xplia/visualizations/line_chart.py +100 -0
- xplia/visualizations/pie_chart.py +134 -0
- xplia/visualizations/radar_chart.py +154 -0
- xplia/visualizations/registry.py +76 -0
- xplia/visualizations/sankey_chart.py +190 -0
- xplia/visualizations/scatter_chart.py +252 -0
- xplia/visualizations/table_chart.py +263 -0
- xplia/visualizations/treemap_chart.py +216 -0
- xplia/visualizations.py +535 -0
- xplia/visualizers/__init__.py +87 -0
- xplia/visualizers/base_visualizer.py +294 -0
- xplia-1.0.1.dist-info/METADATA +685 -0
- xplia-1.0.1.dist-info/RECORD +870 -0
- xplia-1.0.1.dist-info/WHEEL +5 -0
- xplia-1.0.1.dist-info/entry_points.txt +2 -0
- xplia-1.0.1.dist-info/licenses/LICENSE +21 -0
- xplia-1.0.1.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,1088 @@
|
|
|
1
|
+
# helpers.py
|
|
2
|
+
import html.entities
|
|
3
|
+
import re
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
from . import __diag__
|
|
7
|
+
from .core import *
|
|
8
|
+
from .util import _bslash, _flatten, _escape_regex_range_chars
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
#
|
|
12
|
+
# global helpers
|
|
13
|
+
#
|
|
14
|
+
def delimited_list(
|
|
15
|
+
expr: Union[str, ParserElement],
|
|
16
|
+
delim: Union[str, ParserElement] = ",",
|
|
17
|
+
combine: bool = False,
|
|
18
|
+
min: typing.Optional[int] = None,
|
|
19
|
+
max: typing.Optional[int] = None,
|
|
20
|
+
*,
|
|
21
|
+
allow_trailing_delim: bool = False,
|
|
22
|
+
) -> ParserElement:
|
|
23
|
+
"""Helper to define a delimited list of expressions - the delimiter
|
|
24
|
+
defaults to ','. By default, the list elements and delimiters can
|
|
25
|
+
have intervening whitespace, and comments, but this can be
|
|
26
|
+
overridden by passing ``combine=True`` in the constructor. If
|
|
27
|
+
``combine`` is set to ``True``, the matching tokens are
|
|
28
|
+
returned as a single token string, with the delimiters included;
|
|
29
|
+
otherwise, the matching tokens are returned as a list of tokens,
|
|
30
|
+
with the delimiters suppressed.
|
|
31
|
+
|
|
32
|
+
If ``allow_trailing_delim`` is set to True, then the list may end with
|
|
33
|
+
a delimiter.
|
|
34
|
+
|
|
35
|
+
Example::
|
|
36
|
+
|
|
37
|
+
delimited_list(Word(alphas)).parse_string("aa,bb,cc") # -> ['aa', 'bb', 'cc']
|
|
38
|
+
delimited_list(Word(hexnums), delim=':', combine=True).parse_string("AA:BB:CC:DD:EE") # -> ['AA:BB:CC:DD:EE']
|
|
39
|
+
"""
|
|
40
|
+
if isinstance(expr, str_type):
|
|
41
|
+
expr = ParserElement._literalStringClass(expr)
|
|
42
|
+
|
|
43
|
+
dlName = "{expr} [{delim} {expr}]...{end}".format(
|
|
44
|
+
expr=str(expr.copy().streamline()),
|
|
45
|
+
delim=str(delim),
|
|
46
|
+
end=" [{}]".format(str(delim)) if allow_trailing_delim else "",
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
if not combine:
|
|
50
|
+
delim = Suppress(delim)
|
|
51
|
+
|
|
52
|
+
if min is not None:
|
|
53
|
+
if min < 1:
|
|
54
|
+
raise ValueError("min must be greater than 0")
|
|
55
|
+
min -= 1
|
|
56
|
+
if max is not None:
|
|
57
|
+
if min is not None and max <= min:
|
|
58
|
+
raise ValueError("max must be greater than, or equal to min")
|
|
59
|
+
max -= 1
|
|
60
|
+
delimited_list_expr = expr + (delim + expr)[min, max]
|
|
61
|
+
|
|
62
|
+
if allow_trailing_delim:
|
|
63
|
+
delimited_list_expr += Opt(delim)
|
|
64
|
+
|
|
65
|
+
if combine:
|
|
66
|
+
return Combine(delimited_list_expr).set_name(dlName)
|
|
67
|
+
else:
|
|
68
|
+
return delimited_list_expr.set_name(dlName)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def counted_array(
|
|
72
|
+
expr: ParserElement,
|
|
73
|
+
int_expr: typing.Optional[ParserElement] = None,
|
|
74
|
+
*,
|
|
75
|
+
intExpr: typing.Optional[ParserElement] = None,
|
|
76
|
+
) -> ParserElement:
|
|
77
|
+
"""Helper to define a counted list of expressions.
|
|
78
|
+
|
|
79
|
+
This helper defines a pattern of the form::
|
|
80
|
+
|
|
81
|
+
integer expr expr expr...
|
|
82
|
+
|
|
83
|
+
where the leading integer tells how many expr expressions follow.
|
|
84
|
+
The matched tokens returns the array of expr tokens as a list - the
|
|
85
|
+
leading count token is suppressed.
|
|
86
|
+
|
|
87
|
+
If ``int_expr`` is specified, it should be a pyparsing expression
|
|
88
|
+
that produces an integer value.
|
|
89
|
+
|
|
90
|
+
Example::
|
|
91
|
+
|
|
92
|
+
counted_array(Word(alphas)).parse_string('2 ab cd ef') # -> ['ab', 'cd']
|
|
93
|
+
|
|
94
|
+
# in this parser, the leading integer value is given in binary,
|
|
95
|
+
# '10' indicating that 2 values are in the array
|
|
96
|
+
binary_constant = Word('01').set_parse_action(lambda t: int(t[0], 2))
|
|
97
|
+
counted_array(Word(alphas), int_expr=binary_constant).parse_string('10 ab cd ef') # -> ['ab', 'cd']
|
|
98
|
+
|
|
99
|
+
# if other fields must be parsed after the count but before the
|
|
100
|
+
# list items, give the fields results names and they will
|
|
101
|
+
# be preserved in the returned ParseResults:
|
|
102
|
+
count_with_metadata = integer + Word(alphas)("type")
|
|
103
|
+
typed_array = counted_array(Word(alphanums), int_expr=count_with_metadata)("items")
|
|
104
|
+
result = typed_array.parse_string("3 bool True True False")
|
|
105
|
+
print(result.dump())
|
|
106
|
+
|
|
107
|
+
# prints
|
|
108
|
+
# ['True', 'True', 'False']
|
|
109
|
+
# - items: ['True', 'True', 'False']
|
|
110
|
+
# - type: 'bool'
|
|
111
|
+
"""
|
|
112
|
+
intExpr = intExpr or int_expr
|
|
113
|
+
array_expr = Forward()
|
|
114
|
+
|
|
115
|
+
def count_field_parse_action(s, l, t):
|
|
116
|
+
nonlocal array_expr
|
|
117
|
+
n = t[0]
|
|
118
|
+
array_expr <<= (expr * n) if n else Empty()
|
|
119
|
+
# clear list contents, but keep any named results
|
|
120
|
+
del t[:]
|
|
121
|
+
|
|
122
|
+
if intExpr is None:
|
|
123
|
+
intExpr = Word(nums).set_parse_action(lambda t: int(t[0]))
|
|
124
|
+
else:
|
|
125
|
+
intExpr = intExpr.copy()
|
|
126
|
+
intExpr.set_name("arrayLen")
|
|
127
|
+
intExpr.add_parse_action(count_field_parse_action, call_during_try=True)
|
|
128
|
+
return (intExpr + array_expr).set_name("(len) " + str(expr) + "...")
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def match_previous_literal(expr: ParserElement) -> ParserElement:
|
|
132
|
+
"""Helper to define an expression that is indirectly defined from
|
|
133
|
+
the tokens matched in a previous expression, that is, it looks for
|
|
134
|
+
a 'repeat' of a previous expression. For example::
|
|
135
|
+
|
|
136
|
+
first = Word(nums)
|
|
137
|
+
second = match_previous_literal(first)
|
|
138
|
+
match_expr = first + ":" + second
|
|
139
|
+
|
|
140
|
+
will match ``"1:1"``, but not ``"1:2"``. Because this
|
|
141
|
+
matches a previous literal, will also match the leading
|
|
142
|
+
``"1:1"`` in ``"1:10"``. If this is not desired, use
|
|
143
|
+
:class:`match_previous_expr`. Do *not* use with packrat parsing
|
|
144
|
+
enabled.
|
|
145
|
+
"""
|
|
146
|
+
rep = Forward()
|
|
147
|
+
|
|
148
|
+
def copy_token_to_repeater(s, l, t):
|
|
149
|
+
if t:
|
|
150
|
+
if len(t) == 1:
|
|
151
|
+
rep << t[0]
|
|
152
|
+
else:
|
|
153
|
+
# flatten t tokens
|
|
154
|
+
tflat = _flatten(t.as_list())
|
|
155
|
+
rep << And(Literal(tt) for tt in tflat)
|
|
156
|
+
else:
|
|
157
|
+
rep << Empty()
|
|
158
|
+
|
|
159
|
+
expr.add_parse_action(copy_token_to_repeater, callDuringTry=True)
|
|
160
|
+
rep.set_name("(prev) " + str(expr))
|
|
161
|
+
return rep
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def match_previous_expr(expr: ParserElement) -> ParserElement:
|
|
165
|
+
"""Helper to define an expression that is indirectly defined from
|
|
166
|
+
the tokens matched in a previous expression, that is, it looks for
|
|
167
|
+
a 'repeat' of a previous expression. For example::
|
|
168
|
+
|
|
169
|
+
first = Word(nums)
|
|
170
|
+
second = match_previous_expr(first)
|
|
171
|
+
match_expr = first + ":" + second
|
|
172
|
+
|
|
173
|
+
will match ``"1:1"``, but not ``"1:2"``. Because this
|
|
174
|
+
matches by expressions, will *not* match the leading ``"1:1"``
|
|
175
|
+
in ``"1:10"``; the expressions are evaluated first, and then
|
|
176
|
+
compared, so ``"1"`` is compared with ``"10"``. Do *not* use
|
|
177
|
+
with packrat parsing enabled.
|
|
178
|
+
"""
|
|
179
|
+
rep = Forward()
|
|
180
|
+
e2 = expr.copy()
|
|
181
|
+
rep <<= e2
|
|
182
|
+
|
|
183
|
+
def copy_token_to_repeater(s, l, t):
|
|
184
|
+
matchTokens = _flatten(t.as_list())
|
|
185
|
+
|
|
186
|
+
def must_match_these_tokens(s, l, t):
|
|
187
|
+
theseTokens = _flatten(t.as_list())
|
|
188
|
+
if theseTokens != matchTokens:
|
|
189
|
+
raise ParseException(
|
|
190
|
+
s, l, "Expected {}, found{}".format(matchTokens, theseTokens)
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
rep.set_parse_action(must_match_these_tokens, callDuringTry=True)
|
|
194
|
+
|
|
195
|
+
expr.add_parse_action(copy_token_to_repeater, callDuringTry=True)
|
|
196
|
+
rep.set_name("(prev) " + str(expr))
|
|
197
|
+
return rep
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def one_of(
|
|
201
|
+
strs: Union[typing.Iterable[str], str],
|
|
202
|
+
caseless: bool = False,
|
|
203
|
+
use_regex: bool = True,
|
|
204
|
+
as_keyword: bool = False,
|
|
205
|
+
*,
|
|
206
|
+
useRegex: bool = True,
|
|
207
|
+
asKeyword: bool = False,
|
|
208
|
+
) -> ParserElement:
|
|
209
|
+
"""Helper to quickly define a set of alternative :class:`Literal` s,
|
|
210
|
+
and makes sure to do longest-first testing when there is a conflict,
|
|
211
|
+
regardless of the input order, but returns
|
|
212
|
+
a :class:`MatchFirst` for best performance.
|
|
213
|
+
|
|
214
|
+
Parameters:
|
|
215
|
+
|
|
216
|
+
- ``strs`` - a string of space-delimited literals, or a collection of
|
|
217
|
+
string literals
|
|
218
|
+
- ``caseless`` - treat all literals as caseless - (default= ``False``)
|
|
219
|
+
- ``use_regex`` - as an optimization, will
|
|
220
|
+
generate a :class:`Regex` object; otherwise, will generate
|
|
221
|
+
a :class:`MatchFirst` object (if ``caseless=True`` or ``asKeyword=True``, or if
|
|
222
|
+
creating a :class:`Regex` raises an exception) - (default= ``True``)
|
|
223
|
+
- ``as_keyword`` - enforce :class:`Keyword`-style matching on the
|
|
224
|
+
generated expressions - (default= ``False``)
|
|
225
|
+
- ``asKeyword`` and ``useRegex`` are retained for pre-PEP8 compatibility,
|
|
226
|
+
but will be removed in a future release
|
|
227
|
+
|
|
228
|
+
Example::
|
|
229
|
+
|
|
230
|
+
comp_oper = one_of("< = > <= >= !=")
|
|
231
|
+
var = Word(alphas)
|
|
232
|
+
number = Word(nums)
|
|
233
|
+
term = var | number
|
|
234
|
+
comparison_expr = term + comp_oper + term
|
|
235
|
+
print(comparison_expr.search_string("B = 12 AA=23 B<=AA AA>12"))
|
|
236
|
+
|
|
237
|
+
prints::
|
|
238
|
+
|
|
239
|
+
[['B', '=', '12'], ['AA', '=', '23'], ['B', '<=', 'AA'], ['AA', '>', '12']]
|
|
240
|
+
"""
|
|
241
|
+
asKeyword = asKeyword or as_keyword
|
|
242
|
+
useRegex = useRegex and use_regex
|
|
243
|
+
|
|
244
|
+
if (
|
|
245
|
+
isinstance(caseless, str_type)
|
|
246
|
+
and __diag__.warn_on_multiple_string_args_to_oneof
|
|
247
|
+
):
|
|
248
|
+
warnings.warn(
|
|
249
|
+
"More than one string argument passed to one_of, pass"
|
|
250
|
+
" choices as a list or space-delimited string",
|
|
251
|
+
stacklevel=2,
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
if caseless:
|
|
255
|
+
isequal = lambda a, b: a.upper() == b.upper()
|
|
256
|
+
masks = lambda a, b: b.upper().startswith(a.upper())
|
|
257
|
+
parseElementClass = CaselessKeyword if asKeyword else CaselessLiteral
|
|
258
|
+
else:
|
|
259
|
+
isequal = lambda a, b: a == b
|
|
260
|
+
masks = lambda a, b: b.startswith(a)
|
|
261
|
+
parseElementClass = Keyword if asKeyword else Literal
|
|
262
|
+
|
|
263
|
+
symbols: List[str] = []
|
|
264
|
+
if isinstance(strs, str_type):
|
|
265
|
+
symbols = strs.split()
|
|
266
|
+
elif isinstance(strs, Iterable):
|
|
267
|
+
symbols = list(strs)
|
|
268
|
+
else:
|
|
269
|
+
raise TypeError("Invalid argument to one_of, expected string or iterable")
|
|
270
|
+
if not symbols:
|
|
271
|
+
return NoMatch()
|
|
272
|
+
|
|
273
|
+
# reorder given symbols to take care to avoid masking longer choices with shorter ones
|
|
274
|
+
# (but only if the given symbols are not just single characters)
|
|
275
|
+
if any(len(sym) > 1 for sym in symbols):
|
|
276
|
+
i = 0
|
|
277
|
+
while i < len(symbols) - 1:
|
|
278
|
+
cur = symbols[i]
|
|
279
|
+
for j, other in enumerate(symbols[i + 1 :]):
|
|
280
|
+
if isequal(other, cur):
|
|
281
|
+
del symbols[i + j + 1]
|
|
282
|
+
break
|
|
283
|
+
elif masks(cur, other):
|
|
284
|
+
del symbols[i + j + 1]
|
|
285
|
+
symbols.insert(i, other)
|
|
286
|
+
break
|
|
287
|
+
else:
|
|
288
|
+
i += 1
|
|
289
|
+
|
|
290
|
+
if useRegex:
|
|
291
|
+
re_flags: int = re.IGNORECASE if caseless else 0
|
|
292
|
+
|
|
293
|
+
try:
|
|
294
|
+
if all(len(sym) == 1 for sym in symbols):
|
|
295
|
+
# symbols are just single characters, create range regex pattern
|
|
296
|
+
patt = "[{}]".format(
|
|
297
|
+
"".join(_escape_regex_range_chars(sym) for sym in symbols)
|
|
298
|
+
)
|
|
299
|
+
else:
|
|
300
|
+
patt = "|".join(re.escape(sym) for sym in symbols)
|
|
301
|
+
|
|
302
|
+
# wrap with \b word break markers if defining as keywords
|
|
303
|
+
if asKeyword:
|
|
304
|
+
patt = r"\b(?:{})\b".format(patt)
|
|
305
|
+
|
|
306
|
+
ret = Regex(patt, flags=re_flags).set_name(" | ".join(symbols))
|
|
307
|
+
|
|
308
|
+
if caseless:
|
|
309
|
+
# add parse action to return symbols as specified, not in random
|
|
310
|
+
# casing as found in input string
|
|
311
|
+
symbol_map = {sym.lower(): sym for sym in symbols}
|
|
312
|
+
ret.add_parse_action(lambda s, l, t: symbol_map[t[0].lower()])
|
|
313
|
+
|
|
314
|
+
return ret
|
|
315
|
+
|
|
316
|
+
except re.error:
|
|
317
|
+
warnings.warn(
|
|
318
|
+
"Exception creating Regex for one_of, building MatchFirst", stacklevel=2
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
# last resort, just use MatchFirst
|
|
322
|
+
return MatchFirst(parseElementClass(sym) for sym in symbols).set_name(
|
|
323
|
+
" | ".join(symbols)
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
def dict_of(key: ParserElement, value: ParserElement) -> ParserElement:
|
|
328
|
+
"""Helper to easily and clearly define a dictionary by specifying
|
|
329
|
+
the respective patterns for the key and value. Takes care of
|
|
330
|
+
defining the :class:`Dict`, :class:`ZeroOrMore`, and
|
|
331
|
+
:class:`Group` tokens in the proper order. The key pattern
|
|
332
|
+
can include delimiting markers or punctuation, as long as they are
|
|
333
|
+
suppressed, thereby leaving the significant key text. The value
|
|
334
|
+
pattern can include named results, so that the :class:`Dict` results
|
|
335
|
+
can include named token fields.
|
|
336
|
+
|
|
337
|
+
Example::
|
|
338
|
+
|
|
339
|
+
text = "shape: SQUARE posn: upper left color: light blue texture: burlap"
|
|
340
|
+
attr_expr = (label + Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join))
|
|
341
|
+
print(attr_expr[1, ...].parse_string(text).dump())
|
|
342
|
+
|
|
343
|
+
attr_label = label
|
|
344
|
+
attr_value = Suppress(':') + OneOrMore(data_word, stop_on=label).set_parse_action(' '.join)
|
|
345
|
+
|
|
346
|
+
# similar to Dict, but simpler call format
|
|
347
|
+
result = dict_of(attr_label, attr_value).parse_string(text)
|
|
348
|
+
print(result.dump())
|
|
349
|
+
print(result['shape'])
|
|
350
|
+
print(result.shape) # object attribute access works too
|
|
351
|
+
print(result.as_dict())
|
|
352
|
+
|
|
353
|
+
prints::
|
|
354
|
+
|
|
355
|
+
[['shape', 'SQUARE'], ['posn', 'upper left'], ['color', 'light blue'], ['texture', 'burlap']]
|
|
356
|
+
- color: 'light blue'
|
|
357
|
+
- posn: 'upper left'
|
|
358
|
+
- shape: 'SQUARE'
|
|
359
|
+
- texture: 'burlap'
|
|
360
|
+
SQUARE
|
|
361
|
+
SQUARE
|
|
362
|
+
{'color': 'light blue', 'shape': 'SQUARE', 'posn': 'upper left', 'texture': 'burlap'}
|
|
363
|
+
"""
|
|
364
|
+
return Dict(OneOrMore(Group(key + value)))
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def original_text_for(
|
|
368
|
+
expr: ParserElement, as_string: bool = True, *, asString: bool = True
|
|
369
|
+
) -> ParserElement:
|
|
370
|
+
"""Helper to return the original, untokenized text for a given
|
|
371
|
+
expression. Useful to restore the parsed fields of an HTML start
|
|
372
|
+
tag into the raw tag text itself, or to revert separate tokens with
|
|
373
|
+
intervening whitespace back to the original matching input text. By
|
|
374
|
+
default, returns astring containing the original parsed text.
|
|
375
|
+
|
|
376
|
+
If the optional ``as_string`` argument is passed as
|
|
377
|
+
``False``, then the return value is
|
|
378
|
+
a :class:`ParseResults` containing any results names that
|
|
379
|
+
were originally matched, and a single token containing the original
|
|
380
|
+
matched text from the input string. So if the expression passed to
|
|
381
|
+
:class:`original_text_for` contains expressions with defined
|
|
382
|
+
results names, you must set ``as_string`` to ``False`` if you
|
|
383
|
+
want to preserve those results name values.
|
|
384
|
+
|
|
385
|
+
The ``asString`` pre-PEP8 argument is retained for compatibility,
|
|
386
|
+
but will be removed in a future release.
|
|
387
|
+
|
|
388
|
+
Example::
|
|
389
|
+
|
|
390
|
+
src = "this is test <b> bold <i>text</i> </b> normal text "
|
|
391
|
+
for tag in ("b", "i"):
|
|
392
|
+
opener, closer = make_html_tags(tag)
|
|
393
|
+
patt = original_text_for(opener + SkipTo(closer) + closer)
|
|
394
|
+
print(patt.search_string(src)[0])
|
|
395
|
+
|
|
396
|
+
prints::
|
|
397
|
+
|
|
398
|
+
['<b> bold <i>text</i> </b>']
|
|
399
|
+
['<i>text</i>']
|
|
400
|
+
"""
|
|
401
|
+
asString = asString and as_string
|
|
402
|
+
|
|
403
|
+
locMarker = Empty().set_parse_action(lambda s, loc, t: loc)
|
|
404
|
+
endlocMarker = locMarker.copy()
|
|
405
|
+
endlocMarker.callPreparse = False
|
|
406
|
+
matchExpr = locMarker("_original_start") + expr + endlocMarker("_original_end")
|
|
407
|
+
if asString:
|
|
408
|
+
extractText = lambda s, l, t: s[t._original_start : t._original_end]
|
|
409
|
+
else:
|
|
410
|
+
|
|
411
|
+
def extractText(s, l, t):
|
|
412
|
+
t[:] = [s[t.pop("_original_start") : t.pop("_original_end")]]
|
|
413
|
+
|
|
414
|
+
matchExpr.set_parse_action(extractText)
|
|
415
|
+
matchExpr.ignoreExprs = expr.ignoreExprs
|
|
416
|
+
matchExpr.suppress_warning(Diagnostics.warn_ungrouped_named_tokens_in_collection)
|
|
417
|
+
return matchExpr
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
def ungroup(expr: ParserElement) -> ParserElement:
|
|
421
|
+
"""Helper to undo pyparsing's default grouping of And expressions,
|
|
422
|
+
even if all but one are non-empty.
|
|
423
|
+
"""
|
|
424
|
+
return TokenConverter(expr).add_parse_action(lambda t: t[0])
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
def locatedExpr(expr: ParserElement) -> ParserElement:
|
|
428
|
+
"""
|
|
429
|
+
(DEPRECATED - future code should use the Located class)
|
|
430
|
+
Helper to decorate a returned token with its starting and ending
|
|
431
|
+
locations in the input string.
|
|
432
|
+
|
|
433
|
+
This helper adds the following results names:
|
|
434
|
+
|
|
435
|
+
- ``locn_start`` - location where matched expression begins
|
|
436
|
+
- ``locn_end`` - location where matched expression ends
|
|
437
|
+
- ``value`` - the actual parsed results
|
|
438
|
+
|
|
439
|
+
Be careful if the input text contains ``<TAB>`` characters, you
|
|
440
|
+
may want to call :class:`ParserElement.parseWithTabs`
|
|
441
|
+
|
|
442
|
+
Example::
|
|
443
|
+
|
|
444
|
+
wd = Word(alphas)
|
|
445
|
+
for match in locatedExpr(wd).searchString("ljsdf123lksdjjf123lkkjj1222"):
|
|
446
|
+
print(match)
|
|
447
|
+
|
|
448
|
+
prints::
|
|
449
|
+
|
|
450
|
+
[[0, 'ljsdf', 5]]
|
|
451
|
+
[[8, 'lksdjjf', 15]]
|
|
452
|
+
[[18, 'lkkjj', 23]]
|
|
453
|
+
"""
|
|
454
|
+
locator = Empty().set_parse_action(lambda ss, ll, tt: ll)
|
|
455
|
+
return Group(
|
|
456
|
+
locator("locn_start")
|
|
457
|
+
+ expr("value")
|
|
458
|
+
+ locator.copy().leaveWhitespace()("locn_end")
|
|
459
|
+
)
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
def nested_expr(
|
|
463
|
+
opener: Union[str, ParserElement] = "(",
|
|
464
|
+
closer: Union[str, ParserElement] = ")",
|
|
465
|
+
content: typing.Optional[ParserElement] = None,
|
|
466
|
+
ignore_expr: ParserElement = quoted_string(),
|
|
467
|
+
*,
|
|
468
|
+
ignoreExpr: ParserElement = quoted_string(),
|
|
469
|
+
) -> ParserElement:
|
|
470
|
+
"""Helper method for defining nested lists enclosed in opening and
|
|
471
|
+
closing delimiters (``"("`` and ``")"`` are the default).
|
|
472
|
+
|
|
473
|
+
Parameters:
|
|
474
|
+
- ``opener`` - opening character for a nested list
|
|
475
|
+
(default= ``"("``); can also be a pyparsing expression
|
|
476
|
+
- ``closer`` - closing character for a nested list
|
|
477
|
+
(default= ``")"``); can also be a pyparsing expression
|
|
478
|
+
- ``content`` - expression for items within the nested lists
|
|
479
|
+
(default= ``None``)
|
|
480
|
+
- ``ignore_expr`` - expression for ignoring opening and closing delimiters
|
|
481
|
+
(default= :class:`quoted_string`)
|
|
482
|
+
- ``ignoreExpr`` - this pre-PEP8 argument is retained for compatibility
|
|
483
|
+
but will be removed in a future release
|
|
484
|
+
|
|
485
|
+
If an expression is not provided for the content argument, the
|
|
486
|
+
nested expression will capture all whitespace-delimited content
|
|
487
|
+
between delimiters as a list of separate values.
|
|
488
|
+
|
|
489
|
+
Use the ``ignore_expr`` argument to define expressions that may
|
|
490
|
+
contain opening or closing characters that should not be treated as
|
|
491
|
+
opening or closing characters for nesting, such as quoted_string or
|
|
492
|
+
a comment expression. Specify multiple expressions using an
|
|
493
|
+
:class:`Or` or :class:`MatchFirst`. The default is
|
|
494
|
+
:class:`quoted_string`, but if no expressions are to be ignored, then
|
|
495
|
+
pass ``None`` for this argument.
|
|
496
|
+
|
|
497
|
+
Example::
|
|
498
|
+
|
|
499
|
+
data_type = one_of("void int short long char float double")
|
|
500
|
+
decl_data_type = Combine(data_type + Opt(Word('*')))
|
|
501
|
+
ident = Word(alphas+'_', alphanums+'_')
|
|
502
|
+
number = pyparsing_common.number
|
|
503
|
+
arg = Group(decl_data_type + ident)
|
|
504
|
+
LPAR, RPAR = map(Suppress, "()")
|
|
505
|
+
|
|
506
|
+
code_body = nested_expr('{', '}', ignore_expr=(quoted_string | c_style_comment))
|
|
507
|
+
|
|
508
|
+
c_function = (decl_data_type("type")
|
|
509
|
+
+ ident("name")
|
|
510
|
+
+ LPAR + Opt(delimited_list(arg), [])("args") + RPAR
|
|
511
|
+
+ code_body("body"))
|
|
512
|
+
c_function.ignore(c_style_comment)
|
|
513
|
+
|
|
514
|
+
source_code = '''
|
|
515
|
+
int is_odd(int x) {
|
|
516
|
+
return (x%2);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
int dec_to_hex(char hchar) {
|
|
520
|
+
if (hchar >= '0' && hchar <= '9') {
|
|
521
|
+
return (ord(hchar)-ord('0'));
|
|
522
|
+
} else {
|
|
523
|
+
return (10+ord(hchar)-ord('A'));
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
'''
|
|
527
|
+
for func in c_function.search_string(source_code):
|
|
528
|
+
print("%(name)s (%(type)s) args: %(args)s" % func)
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
prints::
|
|
532
|
+
|
|
533
|
+
is_odd (int) args: [['int', 'x']]
|
|
534
|
+
dec_to_hex (int) args: [['char', 'hchar']]
|
|
535
|
+
"""
|
|
536
|
+
if ignoreExpr != ignore_expr:
|
|
537
|
+
ignoreExpr = ignore_expr if ignoreExpr == quoted_string() else ignoreExpr
|
|
538
|
+
if opener == closer:
|
|
539
|
+
raise ValueError("opening and closing strings cannot be the same")
|
|
540
|
+
if content is None:
|
|
541
|
+
if isinstance(opener, str_type) and isinstance(closer, str_type):
|
|
542
|
+
if len(opener) == 1 and len(closer) == 1:
|
|
543
|
+
if ignoreExpr is not None:
|
|
544
|
+
content = Combine(
|
|
545
|
+
OneOrMore(
|
|
546
|
+
~ignoreExpr
|
|
547
|
+
+ CharsNotIn(
|
|
548
|
+
opener + closer + ParserElement.DEFAULT_WHITE_CHARS,
|
|
549
|
+
exact=1,
|
|
550
|
+
)
|
|
551
|
+
)
|
|
552
|
+
).set_parse_action(lambda t: t[0].strip())
|
|
553
|
+
else:
|
|
554
|
+
content = empty.copy() + CharsNotIn(
|
|
555
|
+
opener + closer + ParserElement.DEFAULT_WHITE_CHARS
|
|
556
|
+
).set_parse_action(lambda t: t[0].strip())
|
|
557
|
+
else:
|
|
558
|
+
if ignoreExpr is not None:
|
|
559
|
+
content = Combine(
|
|
560
|
+
OneOrMore(
|
|
561
|
+
~ignoreExpr
|
|
562
|
+
+ ~Literal(opener)
|
|
563
|
+
+ ~Literal(closer)
|
|
564
|
+
+ CharsNotIn(ParserElement.DEFAULT_WHITE_CHARS, exact=1)
|
|
565
|
+
)
|
|
566
|
+
).set_parse_action(lambda t: t[0].strip())
|
|
567
|
+
else:
|
|
568
|
+
content = Combine(
|
|
569
|
+
OneOrMore(
|
|
570
|
+
~Literal(opener)
|
|
571
|
+
+ ~Literal(closer)
|
|
572
|
+
+ CharsNotIn(ParserElement.DEFAULT_WHITE_CHARS, exact=1)
|
|
573
|
+
)
|
|
574
|
+
).set_parse_action(lambda t: t[0].strip())
|
|
575
|
+
else:
|
|
576
|
+
raise ValueError(
|
|
577
|
+
"opening and closing arguments must be strings if no content expression is given"
|
|
578
|
+
)
|
|
579
|
+
ret = Forward()
|
|
580
|
+
if ignoreExpr is not None:
|
|
581
|
+
ret <<= Group(
|
|
582
|
+
Suppress(opener) + ZeroOrMore(ignoreExpr | ret | content) + Suppress(closer)
|
|
583
|
+
)
|
|
584
|
+
else:
|
|
585
|
+
ret <<= Group(Suppress(opener) + ZeroOrMore(ret | content) + Suppress(closer))
|
|
586
|
+
ret.set_name("nested %s%s expression" % (opener, closer))
|
|
587
|
+
return ret
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
def _makeTags(tagStr, xml, suppress_LT=Suppress("<"), suppress_GT=Suppress(">")):
|
|
591
|
+
"""Internal helper to construct opening and closing tag expressions, given a tag name"""
|
|
592
|
+
if isinstance(tagStr, str_type):
|
|
593
|
+
resname = tagStr
|
|
594
|
+
tagStr = Keyword(tagStr, caseless=not xml)
|
|
595
|
+
else:
|
|
596
|
+
resname = tagStr.name
|
|
597
|
+
|
|
598
|
+
tagAttrName = Word(alphas, alphanums + "_-:")
|
|
599
|
+
if xml:
|
|
600
|
+
tagAttrValue = dbl_quoted_string.copy().set_parse_action(remove_quotes)
|
|
601
|
+
openTag = (
|
|
602
|
+
suppress_LT
|
|
603
|
+
+ tagStr("tag")
|
|
604
|
+
+ Dict(ZeroOrMore(Group(tagAttrName + Suppress("=") + tagAttrValue)))
|
|
605
|
+
+ Opt("/", default=[False])("empty").set_parse_action(
|
|
606
|
+
lambda s, l, t: t[0] == "/"
|
|
607
|
+
)
|
|
608
|
+
+ suppress_GT
|
|
609
|
+
)
|
|
610
|
+
else:
|
|
611
|
+
tagAttrValue = quoted_string.copy().set_parse_action(remove_quotes) | Word(
|
|
612
|
+
printables, exclude_chars=">"
|
|
613
|
+
)
|
|
614
|
+
openTag = (
|
|
615
|
+
suppress_LT
|
|
616
|
+
+ tagStr("tag")
|
|
617
|
+
+ Dict(
|
|
618
|
+
ZeroOrMore(
|
|
619
|
+
Group(
|
|
620
|
+
tagAttrName.set_parse_action(lambda t: t[0].lower())
|
|
621
|
+
+ Opt(Suppress("=") + tagAttrValue)
|
|
622
|
+
)
|
|
623
|
+
)
|
|
624
|
+
)
|
|
625
|
+
+ Opt("/", default=[False])("empty").set_parse_action(
|
|
626
|
+
lambda s, l, t: t[0] == "/"
|
|
627
|
+
)
|
|
628
|
+
+ suppress_GT
|
|
629
|
+
)
|
|
630
|
+
closeTag = Combine(Literal("</") + tagStr + ">", adjacent=False)
|
|
631
|
+
|
|
632
|
+
openTag.set_name("<%s>" % resname)
|
|
633
|
+
# add start<tagname> results name in parse action now that ungrouped names are not reported at two levels
|
|
634
|
+
openTag.add_parse_action(
|
|
635
|
+
lambda t: t.__setitem__(
|
|
636
|
+
"start" + "".join(resname.replace(":", " ").title().split()), t.copy()
|
|
637
|
+
)
|
|
638
|
+
)
|
|
639
|
+
closeTag = closeTag(
|
|
640
|
+
"end" + "".join(resname.replace(":", " ").title().split())
|
|
641
|
+
).set_name("</%s>" % resname)
|
|
642
|
+
openTag.tag = resname
|
|
643
|
+
closeTag.tag = resname
|
|
644
|
+
openTag.tag_body = SkipTo(closeTag())
|
|
645
|
+
return openTag, closeTag
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
def make_html_tags(
|
|
649
|
+
tag_str: Union[str, ParserElement]
|
|
650
|
+
) -> Tuple[ParserElement, ParserElement]:
|
|
651
|
+
"""Helper to construct opening and closing tag expressions for HTML,
|
|
652
|
+
given a tag name. Matches tags in either upper or lower case,
|
|
653
|
+
attributes with namespaces and with quoted or unquoted values.
|
|
654
|
+
|
|
655
|
+
Example::
|
|
656
|
+
|
|
657
|
+
text = '<td>More info at the <a href="https://github.com/pyparsing/pyparsing/wiki">pyparsing</a> wiki page</td>'
|
|
658
|
+
# make_html_tags returns pyparsing expressions for the opening and
|
|
659
|
+
# closing tags as a 2-tuple
|
|
660
|
+
a, a_end = make_html_tags("A")
|
|
661
|
+
link_expr = a + SkipTo(a_end)("link_text") + a_end
|
|
662
|
+
|
|
663
|
+
for link in link_expr.search_string(text):
|
|
664
|
+
# attributes in the <A> tag (like "href" shown here) are
|
|
665
|
+
# also accessible as named results
|
|
666
|
+
print(link.link_text, '->', link.href)
|
|
667
|
+
|
|
668
|
+
prints::
|
|
669
|
+
|
|
670
|
+
pyparsing -> https://github.com/pyparsing/pyparsing/wiki
|
|
671
|
+
"""
|
|
672
|
+
return _makeTags(tag_str, False)
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
def make_xml_tags(
|
|
676
|
+
tag_str: Union[str, ParserElement]
|
|
677
|
+
) -> Tuple[ParserElement, ParserElement]:
|
|
678
|
+
"""Helper to construct opening and closing tag expressions for XML,
|
|
679
|
+
given a tag name. Matches tags only in the given upper/lower case.
|
|
680
|
+
|
|
681
|
+
Example: similar to :class:`make_html_tags`
|
|
682
|
+
"""
|
|
683
|
+
return _makeTags(tag_str, True)
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
any_open_tag: ParserElement
|
|
687
|
+
any_close_tag: ParserElement
|
|
688
|
+
any_open_tag, any_close_tag = make_html_tags(
|
|
689
|
+
Word(alphas, alphanums + "_:").set_name("any tag")
|
|
690
|
+
)
|
|
691
|
+
|
|
692
|
+
_htmlEntityMap = {k.rstrip(";"): v for k, v in html.entities.html5.items()}
|
|
693
|
+
common_html_entity = Regex("&(?P<entity>" + "|".join(_htmlEntityMap) + ");").set_name(
|
|
694
|
+
"common HTML entity"
|
|
695
|
+
)
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
def replace_html_entity(t):
|
|
699
|
+
"""Helper parser action to replace common HTML entities with their special characters"""
|
|
700
|
+
return _htmlEntityMap.get(t.entity)
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
class OpAssoc(Enum):
|
|
704
|
+
LEFT = 1
|
|
705
|
+
RIGHT = 2
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
InfixNotationOperatorArgType = Union[
|
|
709
|
+
ParserElement, str, Tuple[Union[ParserElement, str], Union[ParserElement, str]]
|
|
710
|
+
]
|
|
711
|
+
InfixNotationOperatorSpec = Union[
|
|
712
|
+
Tuple[
|
|
713
|
+
InfixNotationOperatorArgType,
|
|
714
|
+
int,
|
|
715
|
+
OpAssoc,
|
|
716
|
+
typing.Optional[ParseAction],
|
|
717
|
+
],
|
|
718
|
+
Tuple[
|
|
719
|
+
InfixNotationOperatorArgType,
|
|
720
|
+
int,
|
|
721
|
+
OpAssoc,
|
|
722
|
+
],
|
|
723
|
+
]
|
|
724
|
+
|
|
725
|
+
|
|
726
|
+
def infix_notation(
|
|
727
|
+
base_expr: ParserElement,
|
|
728
|
+
op_list: List[InfixNotationOperatorSpec],
|
|
729
|
+
lpar: Union[str, ParserElement] = Suppress("("),
|
|
730
|
+
rpar: Union[str, ParserElement] = Suppress(")"),
|
|
731
|
+
) -> ParserElement:
|
|
732
|
+
"""Helper method for constructing grammars of expressions made up of
|
|
733
|
+
operators working in a precedence hierarchy. Operators may be unary
|
|
734
|
+
or binary, left- or right-associative. Parse actions can also be
|
|
735
|
+
attached to operator expressions. The generated parser will also
|
|
736
|
+
recognize the use of parentheses to override operator precedences
|
|
737
|
+
(see example below).
|
|
738
|
+
|
|
739
|
+
Note: if you define a deep operator list, you may see performance
|
|
740
|
+
issues when using infix_notation. See
|
|
741
|
+
:class:`ParserElement.enable_packrat` for a mechanism to potentially
|
|
742
|
+
improve your parser performance.
|
|
743
|
+
|
|
744
|
+
Parameters:
|
|
745
|
+
- ``base_expr`` - expression representing the most basic operand to
|
|
746
|
+
be used in the expression
|
|
747
|
+
- ``op_list`` - list of tuples, one for each operator precedence level
|
|
748
|
+
in the expression grammar; each tuple is of the form ``(op_expr,
|
|
749
|
+
num_operands, right_left_assoc, (optional)parse_action)``, where:
|
|
750
|
+
|
|
751
|
+
- ``op_expr`` is the pyparsing expression for the operator; may also
|
|
752
|
+
be a string, which will be converted to a Literal; if ``num_operands``
|
|
753
|
+
is 3, ``op_expr`` is a tuple of two expressions, for the two
|
|
754
|
+
operators separating the 3 terms
|
|
755
|
+
- ``num_operands`` is the number of terms for this operator (must be 1,
|
|
756
|
+
2, or 3)
|
|
757
|
+
- ``right_left_assoc`` is the indicator whether the operator is right
|
|
758
|
+
or left associative, using the pyparsing-defined constants
|
|
759
|
+
``OpAssoc.RIGHT`` and ``OpAssoc.LEFT``.
|
|
760
|
+
- ``parse_action`` is the parse action to be associated with
|
|
761
|
+
expressions matching this operator expression (the parse action
|
|
762
|
+
tuple member may be omitted); if the parse action is passed
|
|
763
|
+
a tuple or list of functions, this is equivalent to calling
|
|
764
|
+
``set_parse_action(*fn)``
|
|
765
|
+
(:class:`ParserElement.set_parse_action`)
|
|
766
|
+
- ``lpar`` - expression for matching left-parentheses; if passed as a
|
|
767
|
+
str, then will be parsed as Suppress(lpar). If lpar is passed as
|
|
768
|
+
an expression (such as ``Literal('(')``), then it will be kept in
|
|
769
|
+
the parsed results, and grouped with them. (default= ``Suppress('(')``)
|
|
770
|
+
- ``rpar`` - expression for matching right-parentheses; if passed as a
|
|
771
|
+
str, then will be parsed as Suppress(rpar). If rpar is passed as
|
|
772
|
+
an expression (such as ``Literal(')')``), then it will be kept in
|
|
773
|
+
the parsed results, and grouped with them. (default= ``Suppress(')')``)
|
|
774
|
+
|
|
775
|
+
Example::
|
|
776
|
+
|
|
777
|
+
# simple example of four-function arithmetic with ints and
|
|
778
|
+
# variable names
|
|
779
|
+
integer = pyparsing_common.signed_integer
|
|
780
|
+
varname = pyparsing_common.identifier
|
|
781
|
+
|
|
782
|
+
arith_expr = infix_notation(integer | varname,
|
|
783
|
+
[
|
|
784
|
+
('-', 1, OpAssoc.RIGHT),
|
|
785
|
+
(one_of('* /'), 2, OpAssoc.LEFT),
|
|
786
|
+
(one_of('+ -'), 2, OpAssoc.LEFT),
|
|
787
|
+
])
|
|
788
|
+
|
|
789
|
+
arith_expr.run_tests('''
|
|
790
|
+
5+3*6
|
|
791
|
+
(5+3)*6
|
|
792
|
+
-2--11
|
|
793
|
+
''', full_dump=False)
|
|
794
|
+
|
|
795
|
+
prints::
|
|
796
|
+
|
|
797
|
+
5+3*6
|
|
798
|
+
[[5, '+', [3, '*', 6]]]
|
|
799
|
+
|
|
800
|
+
(5+3)*6
|
|
801
|
+
[[[5, '+', 3], '*', 6]]
|
|
802
|
+
|
|
803
|
+
-2--11
|
|
804
|
+
[[['-', 2], '-', ['-', 11]]]
|
|
805
|
+
"""
|
|
806
|
+
# captive version of FollowedBy that does not do parse actions or capture results names
|
|
807
|
+
class _FB(FollowedBy):
|
|
808
|
+
def parseImpl(self, instring, loc, doActions=True):
|
|
809
|
+
self.expr.try_parse(instring, loc)
|
|
810
|
+
return loc, []
|
|
811
|
+
|
|
812
|
+
_FB.__name__ = "FollowedBy>"
|
|
813
|
+
|
|
814
|
+
ret = Forward()
|
|
815
|
+
if isinstance(lpar, str):
|
|
816
|
+
lpar = Suppress(lpar)
|
|
817
|
+
if isinstance(rpar, str):
|
|
818
|
+
rpar = Suppress(rpar)
|
|
819
|
+
|
|
820
|
+
# if lpar and rpar are not suppressed, wrap in group
|
|
821
|
+
if not (isinstance(rpar, Suppress) and isinstance(rpar, Suppress)):
|
|
822
|
+
lastExpr = base_expr | Group(lpar + ret + rpar)
|
|
823
|
+
else:
|
|
824
|
+
lastExpr = base_expr | (lpar + ret + rpar)
|
|
825
|
+
|
|
826
|
+
for i, operDef in enumerate(op_list):
|
|
827
|
+
opExpr, arity, rightLeftAssoc, pa = (operDef + (None,))[:4]
|
|
828
|
+
if isinstance(opExpr, str_type):
|
|
829
|
+
opExpr = ParserElement._literalStringClass(opExpr)
|
|
830
|
+
if arity == 3:
|
|
831
|
+
if not isinstance(opExpr, (tuple, list)) or len(opExpr) != 2:
|
|
832
|
+
raise ValueError(
|
|
833
|
+
"if numterms=3, opExpr must be a tuple or list of two expressions"
|
|
834
|
+
)
|
|
835
|
+
opExpr1, opExpr2 = opExpr
|
|
836
|
+
term_name = "{}{} term".format(opExpr1, opExpr2)
|
|
837
|
+
else:
|
|
838
|
+
term_name = "{} term".format(opExpr)
|
|
839
|
+
|
|
840
|
+
if not 1 <= arity <= 3:
|
|
841
|
+
raise ValueError("operator must be unary (1), binary (2), or ternary (3)")
|
|
842
|
+
|
|
843
|
+
if rightLeftAssoc not in (OpAssoc.LEFT, OpAssoc.RIGHT):
|
|
844
|
+
raise ValueError("operator must indicate right or left associativity")
|
|
845
|
+
|
|
846
|
+
thisExpr: Forward = Forward().set_name(term_name)
|
|
847
|
+
if rightLeftAssoc is OpAssoc.LEFT:
|
|
848
|
+
if arity == 1:
|
|
849
|
+
matchExpr = _FB(lastExpr + opExpr) + Group(lastExpr + opExpr[1, ...])
|
|
850
|
+
elif arity == 2:
|
|
851
|
+
if opExpr is not None:
|
|
852
|
+
matchExpr = _FB(lastExpr + opExpr + lastExpr) + Group(
|
|
853
|
+
lastExpr + (opExpr + lastExpr)[1, ...]
|
|
854
|
+
)
|
|
855
|
+
else:
|
|
856
|
+
matchExpr = _FB(lastExpr + lastExpr) + Group(lastExpr[2, ...])
|
|
857
|
+
elif arity == 3:
|
|
858
|
+
matchExpr = _FB(
|
|
859
|
+
lastExpr + opExpr1 + lastExpr + opExpr2 + lastExpr
|
|
860
|
+
) + Group(lastExpr + OneOrMore(opExpr1 + lastExpr + opExpr2 + lastExpr))
|
|
861
|
+
elif rightLeftAssoc is OpAssoc.RIGHT:
|
|
862
|
+
if arity == 1:
|
|
863
|
+
# try to avoid LR with this extra test
|
|
864
|
+
if not isinstance(opExpr, Opt):
|
|
865
|
+
opExpr = Opt(opExpr)
|
|
866
|
+
matchExpr = _FB(opExpr.expr + thisExpr) + Group(opExpr + thisExpr)
|
|
867
|
+
elif arity == 2:
|
|
868
|
+
if opExpr is not None:
|
|
869
|
+
matchExpr = _FB(lastExpr + opExpr + thisExpr) + Group(
|
|
870
|
+
lastExpr + (opExpr + thisExpr)[1, ...]
|
|
871
|
+
)
|
|
872
|
+
else:
|
|
873
|
+
matchExpr = _FB(lastExpr + thisExpr) + Group(
|
|
874
|
+
lastExpr + thisExpr[1, ...]
|
|
875
|
+
)
|
|
876
|
+
elif arity == 3:
|
|
877
|
+
matchExpr = _FB(
|
|
878
|
+
lastExpr + opExpr1 + thisExpr + opExpr2 + thisExpr
|
|
879
|
+
) + Group(lastExpr + opExpr1 + thisExpr + opExpr2 + thisExpr)
|
|
880
|
+
if pa:
|
|
881
|
+
if isinstance(pa, (tuple, list)):
|
|
882
|
+
matchExpr.set_parse_action(*pa)
|
|
883
|
+
else:
|
|
884
|
+
matchExpr.set_parse_action(pa)
|
|
885
|
+
thisExpr <<= (matchExpr | lastExpr).setName(term_name)
|
|
886
|
+
lastExpr = thisExpr
|
|
887
|
+
ret <<= lastExpr
|
|
888
|
+
return ret
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
def indentedBlock(blockStatementExpr, indentStack, indent=True, backup_stacks=[]):
|
|
892
|
+
"""
|
|
893
|
+
(DEPRECATED - use IndentedBlock class instead)
|
|
894
|
+
Helper method for defining space-delimited indentation blocks,
|
|
895
|
+
such as those used to define block statements in Python source code.
|
|
896
|
+
|
|
897
|
+
Parameters:
|
|
898
|
+
|
|
899
|
+
- ``blockStatementExpr`` - expression defining syntax of statement that
|
|
900
|
+
is repeated within the indented block
|
|
901
|
+
- ``indentStack`` - list created by caller to manage indentation stack
|
|
902
|
+
(multiple ``statementWithIndentedBlock`` expressions within a single
|
|
903
|
+
grammar should share a common ``indentStack``)
|
|
904
|
+
- ``indent`` - boolean indicating whether block must be indented beyond
|
|
905
|
+
the current level; set to ``False`` for block of left-most statements
|
|
906
|
+
(default= ``True``)
|
|
907
|
+
|
|
908
|
+
A valid block must contain at least one ``blockStatement``.
|
|
909
|
+
|
|
910
|
+
(Note that indentedBlock uses internal parse actions which make it
|
|
911
|
+
incompatible with packrat parsing.)
|
|
912
|
+
|
|
913
|
+
Example::
|
|
914
|
+
|
|
915
|
+
data = '''
|
|
916
|
+
def A(z):
|
|
917
|
+
A1
|
|
918
|
+
B = 100
|
|
919
|
+
G = A2
|
|
920
|
+
A2
|
|
921
|
+
A3
|
|
922
|
+
B
|
|
923
|
+
def BB(a,b,c):
|
|
924
|
+
BB1
|
|
925
|
+
def BBA():
|
|
926
|
+
bba1
|
|
927
|
+
bba2
|
|
928
|
+
bba3
|
|
929
|
+
C
|
|
930
|
+
D
|
|
931
|
+
def spam(x,y):
|
|
932
|
+
def eggs(z):
|
|
933
|
+
pass
|
|
934
|
+
'''
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
indentStack = [1]
|
|
938
|
+
stmt = Forward()
|
|
939
|
+
|
|
940
|
+
identifier = Word(alphas, alphanums)
|
|
941
|
+
funcDecl = ("def" + identifier + Group("(" + Opt(delimitedList(identifier)) + ")") + ":")
|
|
942
|
+
func_body = indentedBlock(stmt, indentStack)
|
|
943
|
+
funcDef = Group(funcDecl + func_body)
|
|
944
|
+
|
|
945
|
+
rvalue = Forward()
|
|
946
|
+
funcCall = Group(identifier + "(" + Opt(delimitedList(rvalue)) + ")")
|
|
947
|
+
rvalue << (funcCall | identifier | Word(nums))
|
|
948
|
+
assignment = Group(identifier + "=" + rvalue)
|
|
949
|
+
stmt << (funcDef | assignment | identifier)
|
|
950
|
+
|
|
951
|
+
module_body = stmt[1, ...]
|
|
952
|
+
|
|
953
|
+
parseTree = module_body.parseString(data)
|
|
954
|
+
parseTree.pprint()
|
|
955
|
+
|
|
956
|
+
prints::
|
|
957
|
+
|
|
958
|
+
[['def',
|
|
959
|
+
'A',
|
|
960
|
+
['(', 'z', ')'],
|
|
961
|
+
':',
|
|
962
|
+
[['A1'], [['B', '=', '100']], [['G', '=', 'A2']], ['A2'], ['A3']]],
|
|
963
|
+
'B',
|
|
964
|
+
['def',
|
|
965
|
+
'BB',
|
|
966
|
+
['(', 'a', 'b', 'c', ')'],
|
|
967
|
+
':',
|
|
968
|
+
[['BB1'], [['def', 'BBA', ['(', ')'], ':', [['bba1'], ['bba2'], ['bba3']]]]]],
|
|
969
|
+
'C',
|
|
970
|
+
'D',
|
|
971
|
+
['def',
|
|
972
|
+
'spam',
|
|
973
|
+
['(', 'x', 'y', ')'],
|
|
974
|
+
':',
|
|
975
|
+
[[['def', 'eggs', ['(', 'z', ')'], ':', [['pass']]]]]]]
|
|
976
|
+
"""
|
|
977
|
+
backup_stacks.append(indentStack[:])
|
|
978
|
+
|
|
979
|
+
def reset_stack():
|
|
980
|
+
indentStack[:] = backup_stacks[-1]
|
|
981
|
+
|
|
982
|
+
def checkPeerIndent(s, l, t):
|
|
983
|
+
if l >= len(s):
|
|
984
|
+
return
|
|
985
|
+
curCol = col(l, s)
|
|
986
|
+
if curCol != indentStack[-1]:
|
|
987
|
+
if curCol > indentStack[-1]:
|
|
988
|
+
raise ParseException(s, l, "illegal nesting")
|
|
989
|
+
raise ParseException(s, l, "not a peer entry")
|
|
990
|
+
|
|
991
|
+
def checkSubIndent(s, l, t):
|
|
992
|
+
curCol = col(l, s)
|
|
993
|
+
if curCol > indentStack[-1]:
|
|
994
|
+
indentStack.append(curCol)
|
|
995
|
+
else:
|
|
996
|
+
raise ParseException(s, l, "not a subentry")
|
|
997
|
+
|
|
998
|
+
def checkUnindent(s, l, t):
|
|
999
|
+
if l >= len(s):
|
|
1000
|
+
return
|
|
1001
|
+
curCol = col(l, s)
|
|
1002
|
+
if not (indentStack and curCol in indentStack):
|
|
1003
|
+
raise ParseException(s, l, "not an unindent")
|
|
1004
|
+
if curCol < indentStack[-1]:
|
|
1005
|
+
indentStack.pop()
|
|
1006
|
+
|
|
1007
|
+
NL = OneOrMore(LineEnd().set_whitespace_chars("\t ").suppress())
|
|
1008
|
+
INDENT = (Empty() + Empty().set_parse_action(checkSubIndent)).set_name("INDENT")
|
|
1009
|
+
PEER = Empty().set_parse_action(checkPeerIndent).set_name("")
|
|
1010
|
+
UNDENT = Empty().set_parse_action(checkUnindent).set_name("UNINDENT")
|
|
1011
|
+
if indent:
|
|
1012
|
+
smExpr = Group(
|
|
1013
|
+
Opt(NL)
|
|
1014
|
+
+ INDENT
|
|
1015
|
+
+ OneOrMore(PEER + Group(blockStatementExpr) + Opt(NL))
|
|
1016
|
+
+ UNDENT
|
|
1017
|
+
)
|
|
1018
|
+
else:
|
|
1019
|
+
smExpr = Group(
|
|
1020
|
+
Opt(NL)
|
|
1021
|
+
+ OneOrMore(PEER + Group(blockStatementExpr) + Opt(NL))
|
|
1022
|
+
+ Opt(UNDENT)
|
|
1023
|
+
)
|
|
1024
|
+
|
|
1025
|
+
# add a parse action to remove backup_stack from list of backups
|
|
1026
|
+
smExpr.add_parse_action(
|
|
1027
|
+
lambda: backup_stacks.pop(-1) and None if backup_stacks else None
|
|
1028
|
+
)
|
|
1029
|
+
smExpr.set_fail_action(lambda a, b, c, d: reset_stack())
|
|
1030
|
+
blockStatementExpr.ignore(_bslash + LineEnd())
|
|
1031
|
+
return smExpr.set_name("indented block")
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
# it's easy to get these comment structures wrong - they're very common, so may as well make them available
|
|
1035
|
+
c_style_comment = Combine(Regex(r"/\*(?:[^*]|\*(?!/))*") + "*/").set_name(
|
|
1036
|
+
"C style comment"
|
|
1037
|
+
)
|
|
1038
|
+
"Comment of the form ``/* ... */``"
|
|
1039
|
+
|
|
1040
|
+
html_comment = Regex(r"<!--[\s\S]*?-->").set_name("HTML comment")
|
|
1041
|
+
"Comment of the form ``<!-- ... -->``"
|
|
1042
|
+
|
|
1043
|
+
rest_of_line = Regex(r".*").leave_whitespace().set_name("rest of line")
|
|
1044
|
+
dbl_slash_comment = Regex(r"//(?:\\\n|[^\n])*").set_name("// comment")
|
|
1045
|
+
"Comment of the form ``// ... (to end of line)``"
|
|
1046
|
+
|
|
1047
|
+
cpp_style_comment = Combine(
|
|
1048
|
+
Regex(r"/\*(?:[^*]|\*(?!/))*") + "*/" | dbl_slash_comment
|
|
1049
|
+
).set_name("C++ style comment")
|
|
1050
|
+
"Comment of either form :class:`c_style_comment` or :class:`dbl_slash_comment`"
|
|
1051
|
+
|
|
1052
|
+
java_style_comment = cpp_style_comment
|
|
1053
|
+
"Same as :class:`cpp_style_comment`"
|
|
1054
|
+
|
|
1055
|
+
python_style_comment = Regex(r"#.*").set_name("Python style comment")
|
|
1056
|
+
"Comment of the form ``# ... (to end of line)``"
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
# build list of built-in expressions, for future reference if a global default value
|
|
1060
|
+
# gets updated
|
|
1061
|
+
_builtin_exprs: List[ParserElement] = [
|
|
1062
|
+
v for v in vars().values() if isinstance(v, ParserElement)
|
|
1063
|
+
]
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
# pre-PEP8 compatible names
|
|
1067
|
+
delimitedList = delimited_list
|
|
1068
|
+
countedArray = counted_array
|
|
1069
|
+
matchPreviousLiteral = match_previous_literal
|
|
1070
|
+
matchPreviousExpr = match_previous_expr
|
|
1071
|
+
oneOf = one_of
|
|
1072
|
+
dictOf = dict_of
|
|
1073
|
+
originalTextFor = original_text_for
|
|
1074
|
+
nestedExpr = nested_expr
|
|
1075
|
+
makeHTMLTags = make_html_tags
|
|
1076
|
+
makeXMLTags = make_xml_tags
|
|
1077
|
+
anyOpenTag, anyCloseTag = any_open_tag, any_close_tag
|
|
1078
|
+
commonHTMLEntity = common_html_entity
|
|
1079
|
+
replaceHTMLEntity = replace_html_entity
|
|
1080
|
+
opAssoc = OpAssoc
|
|
1081
|
+
infixNotation = infix_notation
|
|
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
|