def process_split_string(s): outls = [] workls = [] inls = s.split() for i in inls: if i == '÷' or i == '×': outls.append(workls) workls = [] continue ival = int(i, 16) if unicode.is_surrogate(ival): return [] workls.append(ival) if workls: outls.append(workls) return outls
def process_split_string(s): outls = [] workls = [] inls = s.split() for i in inls: if i == '÷' or i == '×': outls.append(workls) workls = [] continue ival = int(i,16) if unicode.is_surrogate(ival): return [] workls.append(ival) if workls: outls.append(workls) return outls
def load_test_data(f): outls = [] testRe = re.compile("^(.*?);(.*?);(.*?);(.*?);(.*?);\s+#.*$") unicode.fetch(f) for line in fileinput.input(os.path.basename(f)): # comment and header lines start with # and @ respectively if len(line) < 1 or line[0:1] == '#' or line[0:1] == '@': continue m = testRe.match(line) groups = [] if not m: print "error: no match on line where test was expected: %s" % line continue has_surrogates = False for i in range(1, 6): group = [] chs = m.group(i).split() for ch in chs: intch = int(ch, 16) if unicode.is_surrogate(intch): has_surrogates = True break group.append(intch) if has_surrogates: break groups.append(group) if has_surrogates: continue outls.append(groups) return outls
def load_test_data(f): outls = [] testRe = re.compile("^(.*?);(.*?);(.*?);(.*?);(.*?);\s+#.*$") unicode.fetch(f) for line in fileinput.input(os.path.basename(f)): # comment and header lines start with # and @ respectively if len(line) < 1 or line[0:1] == "#" or line[0:1] == "@": continue m = testRe.match(line) groups = [] if not m: print "error: no match on line where test was expected: %s" % line continue has_surrogates = False for i in range(1, 6): group = [] chs = m.group(i).split() for ch in chs: intch = int(ch, 16) if unicode.is_surrogate(intch): has_surrogates = True break group.append(intch) if has_surrogates: break groups.append(group) if has_surrogates: continue outls.append(groups) return outls