misc/scripts/detect_cycle.py
author Pierre-Yves David <pierre-yves.david@logilab.fr>
Fri, 18 Jan 2013 18:48:15 +0100
changeset 8661 4d24ac49f90d
parent 6198 f8dea560703f
child 10589 7c23b7de2b8d
permissions -rw-r--r--
[entity] add a "repo_side" parameter to `_cw_dont_cache_attribute` This parameter (defaulting to `False`) is used to inform cubicweb that we really really do not want to cache a value during creation or update. This will be used by a storage that may do very specific processing on attribute values that result in a stored value different than the provided one (e.g. BFSS `fs_importing` mode).


try:
    rtype, = __args__
except ValueError:
    print 'USAGE: cubicweb-ctl shell <instance> detect_cycle.py -- <relation type>'
    print

graph = {}
for fromeid, toeid in rql('Any X,Y WHERE X %s Y' % rtype):
    graph.setdefault(fromeid, []).append(toeid)

from logilab.common.graph import get_cycles

for cycle in get_cycles(graph):
    print 'cycle', '->'.join(str(n) for n in cycle)