Mercurial > hg > config
comparison python/unroll_deps.py @ 679:da62e6411ab7
STUB: python/unroll_deps.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 13 May 2014 12:57:57 -0700 |
parents | f7cfd58eafe6 |
children | bc1f4762027b |
comparison
equal
deleted
inserted
replaced
678:a5fcde6b474a | 679:da62e6411ab7 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 def cycle_check(order, dependencies): | 3 def cycle_check(order, dependencies): |
4 """ensure no cyclic dependencies""" | 4 """ensure no cyclic dependencies""" |
5 order_dict = dict([(j, i) for i, j in enumerate(order)]) | 5 order_dict = dict([(j, i) for i, j in enumerate(order)]) |
6 for package, deps in dependencies.items(): | 6 for package, deps in dependencies.items(): |
49 order.append(package) | 49 order.append(package) |
50 break | 50 break |
51 else: | 51 else: |
52 raise AssertionError("Cyclic dependencies detected") | 52 raise AssertionError("Cyclic dependencies detected") |
53 | 53 |
54 cycle_check(order, dependencies) | 54 cycle_check(order, dependencies) # sanity |
55 | 55 |
56 return order | 56 return order |
57 | 57 |
58 if __name__ == '__main__': | 58 if __name__ == '__main__': |
59 deps = {'packageA': set(['packageB', 'packageC', 'packageF']), | 59 deps = {'packageA': set(['packageB', 'packageC', 'packageF']), |
60 'packageB': set(['packageC', 'packageD', 'packageE', 'packageG']), | 60 'packageB': set(['packageC', 'packageD', 'packageE', 'packageG']), |