You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
DRY redundant custom rule checking code
This commit is contained in:
@@ -28,6 +28,17 @@ nop_func = lambda self, args: None
|
||||
|
||||
class PythonParser(GenericASTBuilder):
|
||||
|
||||
def add_unique_rule(self, rule, opname, count, customize):
|
||||
"""Add rule to grammar, but only if it hasn't been added previously
|
||||
"""
|
||||
if rule not in self.new_rules:
|
||||
# print("XXX ", rule) # debug
|
||||
self.new_rules.add(rule)
|
||||
self.addRule(rule, nop_func)
|
||||
customize[opname] = count
|
||||
pass
|
||||
return
|
||||
|
||||
def cleanup(self):
|
||||
"""
|
||||
Remove recursive references to allow garbage
|
||||
|
Reference in New Issue
Block a user