summaryrefslogtreecommitdiffstats
path: root/third_party/python/pkgutil_resolve_name
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /third_party/python/pkgutil_resolve_name
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/python/pkgutil_resolve_name')
-rw-r--r--third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/LICENSE75
-rw-r--r--third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/METADATA19
-rw-r--r--third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/RECORD5
-rw-r--r--third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/WHEEL4
-rw-r--r--third_party/python/pkgutil_resolve_name/pkgutil_resolve_name.py112
5 files changed, 215 insertions, 0 deletions
diff --git a/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/LICENSE b/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/LICENSE
new file mode 100644
index 0000000000..b76b412e28
--- /dev/null
+++ b/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/LICENSE
@@ -0,0 +1,75 @@
+The MIT License (MIT)
+
+Copyright (c) 2020 Thomas Grainger.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+Portions of this pkgutil-resolve-name Software may utilize the following copyrighted material, the use of which is hereby acknowledged.
+
+cpython: https://github.com/python/cpython/tree/1ed61617a4a6632905ad6a0b440cd2cafb8b6414
+
+
+PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
+--------------------------------------------
+
+1. This LICENSE AGREEMENT is between the Python Software Foundation
+("PSF"), and the Individual or Organization ("Licensee") accessing and
+otherwise using this software ("Python") in source or binary form and
+its associated documentation.
+
+2. Subject to the terms and conditions of this License Agreement, PSF hereby
+grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
+analyze, test, perform and/or display publicly, prepare derivative works,
+distribute, and otherwise use Python alone or in any derivative version,
+provided, however, that PSF's License Agreement and PSF's notice of copyright,
+i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation;
+All Rights Reserved" are retained in Python alone or in any derivative version
+prepared by Licensee.
+
+3. In the event Licensee prepares a derivative work that is based on
+or incorporates Python or any part thereof, and wants to make
+the derivative work available to others as provided herein, then
+Licensee hereby agrees to include in any such work a brief summary of
+the changes made to Python.
+
+4. PSF is making Python available to Licensee on an "AS IS"
+basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
+IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
+INFRINGE ANY THIRD PARTY RIGHTS.
+
+5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
+FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+
+6. This License Agreement will automatically terminate upon a material
+breach of its terms and conditions.
+
+7. Nothing in this License Agreement shall be deemed to create any
+relationship of agency, partnership, or joint venture between PSF and
+Licensee. This License Agreement does not grant permission to use PSF
+trademarks or trade name in a trademark sense to endorse or promote
+products or services of Licensee, or any third party.
+
+8. By copying, installing or otherwise using Python, Licensee
+agrees to be bound by the terms and conditions of this License
+Agreement.
diff --git a/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/METADATA b/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/METADATA
new file mode 100644
index 0000000000..0d08c6f369
--- /dev/null
+++ b/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/METADATA
@@ -0,0 +1,19 @@
+Metadata-Version: 2.1
+Name: pkgutil_resolve_name
+Version: 1.3.10
+Summary: Resolve a name to an object.
+Home-page: https://github.com/graingert/pkgutil-resolve-name
+Author: Vinay Sajip
+Author-email: vinay_sajip@yahoo.co.uk
+Maintainer: Thomas Grainger
+Maintainer-email: pkgutil-resolve-name@graingert.co.uk
+Requires-Python: >=3.6
+Description-Content-Type: text/x-rst
+Classifier: License :: OSI Approved :: MIT License
+
+pkgutil-resolve-name
+====================
+
+A backport of Python 3.9's ``pkgutil.resolve_name``.
+See the `Python 3.9 documentation <https://docs.python.org/3.9/library/pkgutil.html#pkgutil.resolve_name>`__.
+
diff --git a/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/RECORD b/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/RECORD
new file mode 100644
index 0000000000..775ec2bd67
--- /dev/null
+++ b/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/RECORD
@@ -0,0 +1,5 @@
+pkgutil_resolve_name.py,sha256=vH1SKMtmjviGJ2AIUvZVyYQ11fsvfRdhWhh5rQYKYbw,4391
+pkgutil_resolve_name-1.3.10.dist-info/LICENSE,sha256=v4kmc0kkUzDmazjSCeKSyu_oypRpN3oVPKcL1Fmhfng,3790
+pkgutil_resolve_name-1.3.10.dist-info/WHEEL,sha256=o-Q2E8s7BKkCJ1EC2uQdaymZVVu2aUt1e8uTTFpzHVs,81
+pkgutil_resolve_name-1.3.10.dist-info/METADATA,sha256=D8-pgw1aFU9HTIkjloHLKncKWsCGNYFYhzmn6qmjDe0,624
+pkgutil_resolve_name-1.3.10.dist-info/RECORD,,
diff --git a/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/WHEEL b/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/WHEEL
new file mode 100644
index 0000000000..c71ae61dfb
--- /dev/null
+++ b/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name-1.3.10.dist-info/WHEEL
@@ -0,0 +1,4 @@
+Wheel-Version: 1.0
+Generator: flit 3.2.0
+Root-Is-Purelib: true
+Tag: py3-none-any
diff --git a/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name.py b/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name.py
new file mode 100644
index 0000000000..10bb99c362
--- /dev/null
+++ b/third_party/python/pkgutil_resolve_name/pkgutil_resolve_name.py
@@ -0,0 +1,112 @@
+"""
+Resolve a name to an object.
+
+It is expected that `name` will be a string in one of the following
+formats, where W is shorthand for a valid Python identifier and dot stands
+for a literal period in these pseudo-regexes:
+
+W(.W)*
+W(.W)*:(W(.W)*)?
+
+The first form is intended for backward compatibility only. It assumes that
+some part of the dotted name is a package, and the rest is an object
+somewhere within that package, possibly nested inside other objects.
+Because the place where the package stops and the object hierarchy starts
+can't be inferred by inspection, repeated attempts to import must be done
+with this form.
+
+In the second form, the caller makes the division point clear through the
+provision of a single colon: the dotted name to the left of the colon is a
+package to be imported, and the dotted name to the right is the object
+hierarchy within that package. Only one import is needed in this form. If
+it ends with the colon, then a module object is returned.
+
+The function will return an object (which might be a module), or raise one
+of the following exceptions:
+
+ValueError - if `name` isn't in a recognised format
+ImportError - if an import failed when it shouldn't have
+AttributeError - if a failure occurred when traversing the object hierarchy
+ within the imported package to get to the desired object)
+"""
+
+import importlib
+import re
+
+__version__ = "1.3.10"
+
+
+_NAME_PATTERN = None
+
+def resolve_name(name):
+ """
+ Resolve a name to an object.
+
+ It is expected that `name` will be a string in one of the following
+ formats, where W is shorthand for a valid Python identifier and dot stands
+ for a literal period in these pseudo-regexes:
+
+ W(.W)*
+ W(.W)*:(W(.W)*)?
+
+ The first form is intended for backward compatibility only. It assumes that
+ some part of the dotted name is a package, and the rest is an object
+ somewhere within that package, possibly nested inside other objects.
+ Because the place where the package stops and the object hierarchy starts
+ can't be inferred by inspection, repeated attempts to import must be done
+ with this form.
+
+ In the second form, the caller makes the division point clear through the
+ provision of a single colon: the dotted name to the left of the colon is a
+ package to be imported, and the dotted name to the right is the object
+ hierarchy within that package. Only one import is needed in this form. If
+ it ends with the colon, then a module object is returned.
+
+ The function will return an object (which might be a module), or raise one
+ of the following exceptions:
+
+ ValueError - if `name` isn't in a recognised format
+ ImportError - if an import failed when it shouldn't have
+ AttributeError - if a failure occurred when traversing the object hierarchy
+ within the imported package to get to the desired object)
+ """
+ global _NAME_PATTERN
+ if _NAME_PATTERN is None:
+ # Lazy import to speedup Python startup time
+ import re
+ dotted_words = r'(?!\d)(\w+)(\.(?!\d)(\w+))*'
+ _NAME_PATTERN = re.compile(f'^(?P<pkg>{dotted_words})'
+ f'(?P<cln>:(?P<obj>{dotted_words})?)?$',
+ re.UNICODE)
+
+ m = _NAME_PATTERN.match(name)
+ if not m:
+ raise ValueError(f'invalid format: {name!r}')
+ gd = m.groupdict()
+ if gd.get('cln'):
+ # there is a colon - a one-step import is all that's needed
+ mod = importlib.import_module(gd['pkg'])
+ parts = gd.get('obj')
+ parts = parts.split('.') if parts else []
+ else:
+ # no colon - have to iterate to find the package boundary
+ parts = name.split('.')
+ modname = parts.pop(0)
+ # first part *must* be a module/package.
+ mod = importlib.import_module(modname)
+ while parts:
+ p = parts[0]
+ s = f'{modname}.{p}'
+ try:
+ mod = importlib.import_module(s)
+ parts.pop(0)
+ modname = s
+ except ImportError:
+ break
+ # if we reach this point, mod is the module, already imported, and
+ # parts is the list of parts in the object hierarchy to be traversed, or
+ # an empty list if just the module is wanted.
+ result = mod
+ for p in parts:
+ result = getattr(result, p)
+ return result