misc/scripts/detect_cycle.py
author Rémi Cardona <remi.cardona@logilab.fr>
Fri, 13 Nov 2015 14:29:48 +0100
changeset 10895 90c55e27aa87
parent 6198 f8dea560703f
child 10589 7c23b7de2b8d
permissions -rw-r--r--
[data] Use correct syntax to unset CSS attributes (closes #8602446) 'default' is actually a recognized CSS cursor name (the regular pointer). Using this value doesn't revert to whatever cursor DOM elements have by default ('pointer' on links, 'text' on text, etc). The proper way to unset a CSS attribute on DOM elements is to set it to an empty string. http://stackoverflow.com/questions/2027935/how-to-remove-css-property-using-javascript


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)