equal
deleted
inserted
replaced
659 for s in tree[1:]: |
659 for s in tree[1:]: |
660 funcs |= funcsused(s) |
660 funcs |= funcsused(s) |
661 if tree[0] == 'func': |
661 if tree[0] == 'func': |
662 funcs.add(tree[1][1]) |
662 funcs.add(tree[1][1]) |
663 return funcs |
663 return funcs |
|
664 |
|
665 _hashre = util.re.compile('[0-9a-fA-F]{1,40}$') |
|
666 |
|
667 def _ishashlikesymbol(symbol): |
|
668 """returns true if the symbol looks like a hash""" |
|
669 return _hashre.match(symbol) |
|
670 |
|
671 def gethashlikesymbols(tree): |
|
672 """returns the list of symbols of the tree that look like hashes |
|
673 |
|
674 >>> gethashlikesymbols(('dagrange', ('symbol', '3'), ('symbol', 'abe3ff'))) |
|
675 ['3', 'abe3ff'] |
|
676 >>> gethashlikesymbols(('func', ('symbol', 'precursors'), ('symbol', '.'))) |
|
677 [] |
|
678 >>> gethashlikesymbols(('func', ('symbol', 'precursors'), ('symbol', '34'))) |
|
679 ['34'] |
|
680 >>> gethashlikesymbols(('symbol', 'abe3ffZ')) |
|
681 [] |
|
682 """ |
|
683 if not tree: |
|
684 return [] |
|
685 |
|
686 if tree[0] == "symbol": |
|
687 if _ishashlikesymbol(tree[1]): |
|
688 return [tree[1]] |
|
689 elif len(tree) >= 3: |
|
690 results = [] |
|
691 for subtree in tree[1:]: |
|
692 results += gethashlikesymbols(subtree) |
|
693 return results |
|
694 return [] |