Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
add {{PARAM}} for repair rule
Browse files Browse the repository at this point in the history
  • Loading branch information
FeeiCN committed Sep 10, 2016
1 parent 1219b02 commit 091936d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion engine/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(self, rule, file_path, line, code):
logging.info(file_path)
self.line = line
self.code = code
self.param_name = None

def functions(self):
logging.info('---------------------- [-]. Functions --------------------------------------')
Expand Down Expand Up @@ -147,8 +148,9 @@ def get_code(self, line_rule):
def is_controllable_param(self):
logging.info('---------------------- [2]. Param is controllable --------------------------------------')
param_name = re.findall(self.rule, self.code)
param_name = param_name[0].strip()
self.param_name = param_name
if len(param_name) == 1:
param_name = param_name[0].strip()
logging.info('P: {0}'.format(param_name))
# controllable param
# exclude class const (maybe misuse)
Expand Down Expand Up @@ -225,6 +227,9 @@ def is_repair(self, repair_rule, block_repair):
if code is False:
logging.debug("R: Un Repair (repair code not match)")
return False
# replace repair {{PARAM}} const
if '{{PARAM}' in repair_rule:
repair_rule = repair_rule.replace('{{PARAM}', self.param_name)
repair_result = re.findall(repair_rule, code)
logging.debug(code)
logging.debug(repair_result)
Expand Down

0 comments on commit 091936d

Please sign in to comment.