Loading list_files/rules.py +20 −1 Original line number Diff line number Diff line from os import path import sys from os import path, environ from warnings import warn DEBUG_MATCH = ' : {0}\033[;1m matches\033[m\n' DEBUG_FAIL = ' : {0}\033[;1m failed\033[m\n' def add_attr(attrs, obj, name): try: attrs.append("{0}={1}".format(name, repr(getattr(obj, name)))) Loading Loading @@ -40,10 +45,14 @@ class Rule(object): def check_path(self, testpath, testname=None): if not testpath.startswith(self.pattern_root): if __debug__ and 'DEBUG' in environ: sys.stderr.write(DEBUG_FAIL.format(self)) return self.next_if_fail fullpath = path.join(self.project_root, testpath) if self.directory_only and not path.isdir(fullpath): if __debug__ and 'DEBUG' in environ: sys.stderr.write(DEBUG_FAIL.format(self)) return self.next_if_fail # strip off pattern_root Loading @@ -57,6 +66,9 @@ class Rule(object): check_path = testname match = self.pattern.match(check_path) if __debug__ and 'DEBUG' in environ: sys.stderr.write((DEBUG_MATCH if match else DEBUG_FAIL) .format(self)) return self.next_if_match if match else self.next_if_fail Loading @@ -69,6 +81,9 @@ def run_rules(rules_head, testpath, testname=None): if rules_head is None: return if __debug__ and 'DEBUG' in environ: sys.stderr.write("Testing \033[35;1m{0}\033[m:\n".format(testpath)) prev_rule = None rule = rules_head while rule: Loading @@ -76,8 +91,12 @@ def run_rules(rules_head, testpath, testname=None): try: rule = rule.check_path(path.normpath(testpath), testname) except Exclude: if __debug__ and 'DEBUG' in environ: sys.stderr.write("\033[31;1mExcluded\033[m\n") return False except Include: if __debug__ and 'DEBUG' in environ: sys.stderr.write("\033[33;1mIncluded\033[m\n") return True raise RuntimeError("An unterminated rules graph ended") Loading Loading
list_files/rules.py +20 −1 Original line number Diff line number Diff line from os import path import sys from os import path, environ from warnings import warn DEBUG_MATCH = ' : {0}\033[;1m matches\033[m\n' DEBUG_FAIL = ' : {0}\033[;1m failed\033[m\n' def add_attr(attrs, obj, name): try: attrs.append("{0}={1}".format(name, repr(getattr(obj, name)))) Loading Loading @@ -40,10 +45,14 @@ class Rule(object): def check_path(self, testpath, testname=None): if not testpath.startswith(self.pattern_root): if __debug__ and 'DEBUG' in environ: sys.stderr.write(DEBUG_FAIL.format(self)) return self.next_if_fail fullpath = path.join(self.project_root, testpath) if self.directory_only and not path.isdir(fullpath): if __debug__ and 'DEBUG' in environ: sys.stderr.write(DEBUG_FAIL.format(self)) return self.next_if_fail # strip off pattern_root Loading @@ -57,6 +66,9 @@ class Rule(object): check_path = testname match = self.pattern.match(check_path) if __debug__ and 'DEBUG' in environ: sys.stderr.write((DEBUG_MATCH if match else DEBUG_FAIL) .format(self)) return self.next_if_match if match else self.next_if_fail Loading @@ -69,6 +81,9 @@ def run_rules(rules_head, testpath, testname=None): if rules_head is None: return if __debug__ and 'DEBUG' in environ: sys.stderr.write("Testing \033[35;1m{0}\033[m:\n".format(testpath)) prev_rule = None rule = rules_head while rule: Loading @@ -76,8 +91,12 @@ def run_rules(rules_head, testpath, testname=None): try: rule = rule.check_path(path.normpath(testpath), testname) except Exclude: if __debug__ and 'DEBUG' in environ: sys.stderr.write("\033[31;1mExcluded\033[m\n") return False except Include: if __debug__ and 'DEBUG' in environ: sys.stderr.write("\033[33;1mIncluded\033[m\n") return True raise RuntimeError("An unterminated rules graph ended") Loading