Commits

Jason R. Coombs committed 6f1b7fa

Use importlib for programmatic imports (not imported for their namesake). Fixes pylint warnings

Comments (0)

Files changed (2)

paradocx/package.py

+import importlib
+
 from openpack.basepack import ContentType
 from openpack.officepack import OfficePackage
 
-# these modules must be imported for their Parts to be properly recognized
-import document
-import numbering
-import styles
-import headerfooter
+def initialize():
+	"""
+	Import various modules so their Part classes are present.
+	"""
+	for mod in 'document numbering styles headerfooter'.split():
+		importlib.import_module('paradocx.' + mod)
+
+initialize()
 
 class WordPackage(OfficePackage):
 	def __init__(self):
 import os
+import sys
 
 with open(os.path.join(os.path.dirname(__file__), 'README')) as f:
     long_description = f.read()
 
+importlib_req = ['importlib'] if sys.version_info < (2,7) else []
+
 setup_params = dict(
     name="paradocx",
     use_hg_version=True,
     long_description=long_description,
     install_requires=[
         'openpack>=1.0',
-    ],
+    ] + importlib_req,
     tests_require=[
         'pytest',
     ],