浏览代码

HUE-3880 [core] Add importlib directly for Python 2.6

Jenny Kim 9 年之前
父节点
当前提交
65c6463

+ 31 - 0
desktop/core/ext-py/importlib-1.0.3/PKG-INFO

@@ -0,0 +1,31 @@
+Metadata-Version: 1.1
+Name: importlib
+Version: 1.0.3
+Summary: Backport of importlib.import_module() from Python 2.7
+Home-page: UNKNOWN
+Author: Brett Cannon
+Author-email: brett@python.org
+License: UNKNOWN
+Description: Purpose
+        ========
+        
+        This package contains the code from importlib as found in Python 2.7. It is
+        provided so that people who wish to use ``importlib.import_module()`` with a
+        version of Python prior to 2.7 or in 3.0 have the function readily available.
+        The code in no way deviates from what can be found in the Python 2.7 standard
+        library.
+        
+        For documentation, see the `importlib docs`_ for Python 2.7.
+        
+        .. _importlib docs: http://docs.python.org/2.7/library/importlib.html
+        
+Platform: UNKNOWN
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.3
+Classifier: Programming Language :: Python :: 2.4
+Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.0
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: License :: OSI Approved :: Python Software Foundation License

+ 12 - 0
desktop/core/ext-py/importlib-1.0.3/README

@@ -0,0 +1,12 @@
+Purpose
+========
+
+This package contains the code from importlib as found in Python 2.7. It is
+provided so that people who wish to use ``importlib.import_module()`` with a
+version of Python prior to 2.7 or in 3.0 have the function readily available.
+The code in no way deviates from what can be found in the Python 2.7 standard
+library.
+
+For documentation, see the `importlib docs`_ for Python 2.7.
+
+.. _importlib docs: http://docs.python.org/2.7/library/importlib.html

+ 38 - 0
desktop/core/ext-py/importlib-1.0.3/importlib/__init__.py

@@ -0,0 +1,38 @@
+"""Backport of importlib.import_module from 3.x."""
+# While not critical (and in no way guaranteed!), it would be nice to keep this
+# code compatible with Python 2.3.
+import sys
+
+def _resolve_name(name, package, level):
+    """Return the absolute name of the module to be imported."""
+    if not hasattr(package, 'rindex'):
+        raise ValueError("'package' not set to a string")
+    dot = len(package)
+    for x in xrange(level, 1, -1):
+        try:
+            dot = package.rindex('.', 0, dot)
+        except ValueError:
+            raise ValueError("attempted relative import beyond top-level "
+                              "package")
+    return "%s.%s" % (package[:dot], name)
+
+
+def import_module(name, package=None):
+    """Import a module.
+
+    The 'package' argument is required when performing a relative import. It
+    specifies the package to use as the anchor point from which to resolve the
+    relative import to an absolute import.
+
+    """
+    if name.startswith('.'):
+        if not package:
+            raise TypeError("relative imports require the 'package' argument")
+        level = 0
+        for character in name:
+            if character != '.':
+                break
+            level += 1
+        name = _resolve_name(name[level:], package, level)
+    __import__(name)
+    return sys.modules[name]

+ 36 - 0
desktop/core/ext-py/importlib-1.0.3/setup.py

@@ -0,0 +1,36 @@
+from distutils.core import setup
+import sys
+
+
+packages = []
+if ((sys.version_info[0] == 2 and sys.version_info[1] < 7) or
+        (sys.version_info[0] == 3 and sys.version_info[1] < 1)):
+    packages.append('importlib')
+
+
+version_classifiers = ['Programming Language :: Python :: %s' % version
+                        for version in ['2', '2.3', '2.4', '2.5', '2.6',
+                                        '3', '3.0']]
+other_classifiers = [
+        'Development Status :: 5 - Production/Stable',
+        'License :: OSI Approved :: Python Software Foundation License',
+    ]
+
+readme_file = open('README', 'r')
+try:
+    detailed_description = readme_file.read()
+finally:
+    readme_file.close()
+
+
+setup(
+        name='importlib',
+        version='1.0.3',
+        description='Backport of importlib.import_module() from Python 2.7',
+        long_description=detailed_description,
+        author='Brett Cannon',
+        author_email='brett@python.org',
+        #url='',
+        packages=packages,
+        classifiers=version_classifiers + other_classifiers,
+    )