Skip to content

Commit

Permalink
Backport ModuleInfo into py35
Browse files Browse the repository at this point in the history
  • Loading branch information
arcondello committed Dec 10, 2020
1 parent c50f7f0 commit 5a02ddb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions dwave_networkx.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,27 @@ def alias_subpackages():
import pkgutil
import sys

if sys.version_info[1] <= 5:
# in python 3.5, we need a named tuple
from collections import namedtuple

Module = namedtuple('Module', ['module_finder', 'name', 'ispkg'])

def walk_packages(*args, **kwargs):
for module in pkgutil.walk_packages(*args, **kwargs):
yield Module(*module)

else:
walk_packages = pkgutil.walk_packages

import warnings
warnings.warn("the dwave_networkx namespace was deprecated in "
"dwave-networkx 0.9.0, please use "
"dwave.plugins.networkx instead.",
DeprecationWarning, stacklevel=3)

for module in pkgutil.walk_packages(dwave.plugins.networkx.__path__,
dwave.plugins.networkx.__name__ + '.'):
for module in walk_packages(dwave.plugins.networkx.__path__,
dwave.plugins.networkx.__name__ + '.'):
# only want the subpackages
if not module.ispkg:
continue
Expand Down

0 comments on commit 5a02ddb

Please sign in to comment.