1717Support import of old camel-case module names with DeprecationWarning.
1818
1919The imported camel-case modules are aliases for the current module
20- instances. Their `__name__` attributes are thus all in lower-case.
20+ instances. Their `__name__` attributes are thus all in lower-case.
2121
22- This module is deprecated and will be removed in the future.
22+ Note
23+ ----
24+ this module must be only imported from `diffpy.Structure`.
2325
24- NOTE: this module must be only imported from `diffpy.Structure`.
26+ Warning
27+ -------
28+ This module is deprecated and will be removed in the future.
2529"""
2630
2731
32+ import importlib .abc
2833import sys
2934from warnings import warn
3035
31- import six
32-
33- if six .PY2 :
34- import importlib
35-
36- class mock_importlib_abc (object ):
37- MetaPathFinder = object
38- Loader = object
39-
40- importlib .abc = mock_importlib_abc
41- sys .modules .setdefault ("importlib.abc" , mock_importlib_abc )
42- del mock_importlib_abc
43-
44- import importlib .abc
45-
46- WMSG = "Module {!r} is deprecated. Use {!r} instead."
36+ WMSG = "Module {!r} is deprecated. Use {!r} instead."
4737
4838# ----------------------------------------------------------------------------
4939
@@ -63,25 +53,14 @@ def find_spec(self, fullname, path=None, target=None):
6353 spec .loader = MapRenamedStructureModule ()
6454 return spec
6555
66- if six .PY2 :
67-
68- def find_module (self , fullname , path ):
69- # only handle submodules of diffpy.Structure
70- loader = None
71- if fullname .startswith (self .prefix ):
72- loader = MapRenamedStructureModule ()
73- return loader
74-
7556
7657# end of class FindRenamedStructureModule
7758
7859# ----------------------------------------------------------------------------
7960
8061
8162class MapRenamedStructureModule (importlib .abc .Loader ):
82- """
83- Loader for old camel-case module names.
84-
63+ """Loader for old camel-case module names.
8564 Import the current module and alias it under the old name.
8665 """
8766
@@ -95,15 +74,6 @@ def create_module(self, spec):
9574 def exec_module (self , module ):
9675 return
9776
98- if six .PY2 :
99- from collections import namedtuple
100-
101- ModuleSpec = namedtuple ("ModuleSpec" , "name" )
102-
103- def load_module (self , fullname ):
104- spec = self .ModuleSpec (fullname )
105- return self .create_module (spec )
106-
10777
10878# end of class MapRenamedStructureModule
10979
0 commit comments