62 # __autogenerated__ attribute is just a marker |
63 # __autogenerated__ attribute is just a marker |
63 return type(str(clsname), (cls,), {'__autogenerated__': True, |
64 return type(str(clsname), (cls,), {'__autogenerated__': True, |
64 '__doc__': cls.__doc__, |
65 '__doc__': cls.__doc__, |
65 '__module__': cls.__module__}) |
66 '__module__': cls.__module__}) |
66 |
67 |
|
68 def support_args(callable, *argnames): |
|
69 """return true if the callable support given argument names""" |
|
70 argspec = getargspec(callable) |
|
71 if argspec[2]: |
|
72 return True |
|
73 for argname in argnames: |
|
74 if argname not in argspec[0]: |
|
75 return False |
|
76 return True |
67 |
77 |
68 # use networkX instead ? |
78 # use networkX instead ? |
69 # http://networkx.lanl.gov/reference/algorithms.traversal.html#module-networkx.algorithms.traversal.astar |
79 # http://networkx.lanl.gov/reference/algorithms.traversal.html#module-networkx.algorithms.traversal.astar |
70 def transitive_closure_of(entity, relname, _seen=None): |
80 def transitive_closure_of(entity, relname, _seen=None): |
71 """return transitive closure *for the subgraph starting from the given |
81 """return transitive closure *for the subgraph starting from the given |