Skip to content

Commit 1ccc30d

Browse files
committed
Backport ModuleInfo into py35
1 parent b1690e5 commit 1ccc30d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

dwave_networkx.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,27 @@ def alias_subpackages():
2828
import pkgutil
2929
import sys
3030

31+
if sys.version_info[1] <= 5:
32+
# in python 3.5, we need a named tuple
33+
from collections import namedtuple
34+
35+
Module = namedtuple('Module', ['module_finder', 'name', 'ispkg'])
36+
37+
def walk_packages(*args, **kwargs):
38+
for module in pkgutil.walk_packages(*args, **kwargs):
39+
yield Module(*module)
40+
41+
else:
42+
walk_packages = pkgutil.walk_packages
43+
3144
import warnings
3245
warnings.warn("the dwave_networkx namespace was deprecated in "
3346
"dwave-networkx 0.9.0, please use "
3447
"dwave.plugins.networkx instead.",
3548
DeprecationWarning, stacklevel=3)
3649

37-
for module in pkgutil.walk_packages(dwave.plugins.networkx.__path__,
38-
dwave.plugins.networkx.__name__ + '.'):
50+
for module in walk_packages(dwave.plugins.networkx.__path__,
51+
dwave.plugins.networkx.__name__ + '.'):
3952
# only want the subpackages
4053
if not module.ispkg:
4154
continue

0 commit comments

Comments
 (0)