Index: Tools/scripts/pdeps.py =================================================================== --- Tools/scripts/pdeps.py (revision 88222) +++ Tools/scripts/pdeps.py (working copy) @@ -76,12 +76,12 @@ nextline = fp.readline() if not nextline: break line = line[:-1] + nextline - if m_import.match(line) >= 0: - (a, b), (a1, b1) = m_import.regs[:2] - elif m_from.match(line) >= 0: - (a, b), (a1, b1) = m_from.regs[:2] - else: continue - words = line[a1:b1].split(',') + match = m_import.match(line) + if not match: + match = m_from.match(line) + if not match: + continue + words = match.group(1).split(',') # print '#', line, words for word in words: word = word.strip() @@ -122,25 +122,13 @@ # def inverse(table): inv = {} - for key in table.keys(): - if not inv.has_key(key): - inv[key] = [] - for item in table[key]: - store(inv, item, key) + for key, items in table.items(): + inv.setdefault(key, []) + for item in items: + inv.setdefault(item, []).append(key) return inv -# Store "item" in "dict" under "key". -# The dictionary maps keys to lists of items. -# If there is no list for the key yet, it is created. -# -def store(dict, key, item): - if key in dict: - dict[key].append(item) - else: - dict[key] = [item] - - # Tabulate results neatly # def printresults(table):