=== modified file 'bugHelper/infoFiles.py' --- bugHelper/infoFiles.py 2007-04-23 09:41:59 +0000 +++ bugHelper/infoFiles.py 2007-04-24 14:07:35 +0000 @@ -9,6 +9,33 @@ from infoFilesDefinitions import clueCondition as clueCondition from infoFilesDefinitions import bugClue as bugClue +def search_ng(cond,attribute,case_sensitive=None): + if type(attribute) == str: + if case_sensitive: + if cond.startswith("r'") and cond.endswith("'"): + res = re.search(cond, attribute, re.MULTILINE) is not None + else: + res = attribute.count(cond)>0 + else: + low_text =attribute.lower() + a = re.search(r"^r'(.*)'$",cond) + if a: + res = re.search(a.group(1), low_text, re.MULTILINE|re.IGNORECASE) is not None + else: + low_cond = cond.lower() + res = low_text.count(cond.lower())>0 + return res + + elif type(attribute) == list or type(attribute) == tuple: + a = [search_ng(cond,l) for l in attribute] + #print a + if True in a: return True + return False + + else: + assert None, "Unknown type of attribute: %s" % type(attribute) + + class InfoFiles(object): def __init__(self, packages_dirs): self.files = dict() @@ -80,23 +107,21 @@ def condition_matches(self, cond, bug_or_attachment, case_sensitive=False): if cond.simple_cond: - if case_sensitive: + #print "tags:",getattr(bug_or_attachment,"proptags",None) + #print type(getattr(bug_or_attachment,"text",None)) + if cond.cond_field: + # search only in attribute given by cond.cond_field + # if the bug_or_attachment-object does not have the given attribute + # search the whole .text instead and prints a warning + if hasattr(bug_or_attachment,cond.cond_field): + search_text = getattr(bug_or_attachment,cond.cond_field) + else: + print "Unknown attribute <%s>, use instead" % cond.cond_field + search_text = bug_or_attachment.text + else: search_text = bug_or_attachment.text - if cond.cond_field == 'title' and instanceof(bug_or_attachment, Bug): - search_text = bug_or_attachment.title - - if cond.simple_cond.startswith("r'") and cond.simple_cond.endswith("'"): - res = re.search(cond.simple_cond, bug_or_attachment.text, re.MULTILINE) is not None - else: - res = bug_or_attachment.text.count(cond.simple_cond)>0 - else: - low_text = bug_or_attachment.text.lower() - a = re.search(r"^r'(.*)'$",cond.simple_cond) - if a: - res = re.search(a.group(1), low_text, re.MULTILINE|re.IGNORECASE) is not None - else: - low_cond = cond.simple_cond.lower() - res = low_text.count(cond.simple_cond.lower())>0 + + res = search_ng(cond.simple_cond, search_text,case_sensitive) return cond.not_cond != res if cond.and_cond: