def linux_id(student): global linux_ids fullname = student.fullname() splitter = re.compile("(\\s|[-_'])") elements = splitter.split(fullname) elements = [element for element in elements if element != ' '] per_element = 2 if len(elements) > 2 else 3 elements = [element[0:per_element] for element in elements] _id = "".join(elements) _id = _id.lower() _id = replace_special_chars(_id) _id = make_unique(linux_ids, _id) linux_ids[_id] = True return _id
def dirname(self): elements = self.url.split('/') dirname = elements[-1] if dirname.endswith('.git'): dirname = dirname[0:-4] dirname = replace_special_chars(dirname) return dirname
parser.add_argument('-b', metavar='BROWSER', type=str, help='Path to browser executable') args, unkonwn_args = parser.parse_known_args() if args.i is None or args.p is None: parser.print_usage() print("\n NOTE: any extra argument is passed to jplag") exit(0) ENCODING = 'utf-8' INPUT_PATH = args.i PATTERN = args.p if args.o is not None: OUTPUT_DIR = args.o else: OUTPUT_DIR = replace_special_chars(deregexify(PATTERN)) FILES_DIR = 'files' RESULT_DIR = 'result' JAVAPATH = args.j JPLAGPATH = args.jplag JPLAGARGS = " ".join(unkonwn_args) EXCLUDE_PATTERN = args.e BROWSER_PATH = args.b INDEX_NAME='index.html' JAVA_PATTERN='[Jj][Aa][Vv][Aa]$' courses = {} def initialize_course(course): global courses if not course in courses:
def if_strictly_matches(self, string): match_ratio = fuzz.ratio(self.target, replace_special_chars(string)) return match_ratio >= self.ratio
def __init__(self, pattern, ratio): super(FuzzyMatcher, self).__init__(pattern) self.target = replace_special_chars(deregexify(pattern)) self.ratio = ratio
def if_very_strictly_matches(self, string): matches = self.matcher.match(replace_special_chars(string)) return matches is not None
def if_matches(self, string): matches = self.matcher.search(replace_special_chars(string)) return matches is not None
def dirname(self): dirname = "%s_%s" % (self.name, self.surname) dirname = replace_special_chars(dirname) return dirname
def student_dirname(student): student_dirname = "%s_%s" % (student.name, student.surname) student_dirname = replace_special_chars(student_dirname) return student_dirname