Show More
@@ -293,8 +293,6 b' def checkmod(mod, imports):' | |||||
293 | while visit: |
|
293 | while visit: | |
294 | path = visit.pop(0) |
|
294 | path = visit.pop(0) | |
295 | for i in sorted(imports.get(path[-1], [])): |
|
295 | for i in sorted(imports.get(path[-1], [])): | |
296 | if i not in stdlib_modules and not i.startswith('mercurial.'): |
|
|||
297 | i = mod.rsplit('.', 1)[0] + '.' + i |
|
|||
298 | if len(path) < shortest.get(i, 1000): |
|
296 | if len(path) < shortest.get(i, 1000): | |
299 | shortest[i] = len(path) |
|
297 | shortest[i] = len(path) | |
300 | if i in path: |
|
298 | if i in path: | |
@@ -316,10 +314,12 b' def rotatecycle(cycle):' | |||||
316 | def find_cycles(imports): |
|
314 | def find_cycles(imports): | |
317 | """Find cycles in an already-loaded import graph. |
|
315 | """Find cycles in an already-loaded import graph. | |
318 |
|
316 | |||
319 | >>> imports = {'top.foo': ['bar', 'os.path', 'qux'], |
|
317 | All module names recorded in `imports` should be absolute one. | |
320 | ... 'top.bar': ['baz', 'sys'], |
|
318 | ||
321 | ... 'top.baz': ['foo'], |
|
319 | >>> imports = {'top.foo': ['top.bar', 'os.path', 'top.qux'], | |
322 |
... 'top. |
|
320 | ... 'top.bar': ['top.baz', 'sys'], | |
|
321 | ... 'top.baz': ['top.foo'], | |||
|
322 | ... 'top.qux': ['top.foo']} | |||
323 | >>> print '\\n'.join(sorted(find_cycles(imports))) |
|
323 | >>> print '\\n'.join(sorted(find_cycles(imports))) | |
324 | top.bar -> top.baz -> top.foo -> top.bar |
|
324 | top.bar -> top.baz -> top.foo -> top.bar | |
325 | top.foo -> top.qux -> top.foo |
|
325 | top.foo -> top.qux -> top.foo |
General Comments 0
You need to be logged in to leave comments.
Login now