def from_line(cls, line: str): parsed = _re_Mainichi95_KEY_VAL.match(line) if parsed: key = jaconv.zen2han(parsed.group("key"), kana=False, ascii=True, digit=True) if key in _Mainichi95_KEY_of_hankaku_val: val = jaconv.zen2han( parsed.group("val"), kana=False, ascii=True, digit=True, ) else: val = parsed.group("val") # === END IF === return cls(key, val) else: raise ValueError
def _q(lookup, val): key = f'{lookup}__contains' val2 = jaconv.zen2han(val) if val2 == val: return Q((key, val)) return Q((key, val)) | Q((key, val2))
def main(): with open(SOURCE, 'r', encoding='utf-8') as file: sourceFile = file.readlines() flow = [] startStopCnt = 0 functionName = '' for line in sourceFile: for comment in REF_COMMENT: if comment in line: # Start and end index of REF_COMMENT _, end = re.search(comment, line).span() # description is parsed line. Everything before reference comment is removed. # description1 converts full-widht characters to half-width if -jap argument. # description2 creates list of strings. description1 is split at " symbol. # description3 in final step and this string is places as label of graph node. comm = '[' + COMMENTS[LANG] + '\n\t]' description = re.sub(comm, '', line[end + 1:]) if JAP: import jaconv description1 = jaconv.zen2han(description, ascii=True, kana=False) else: description1 = description description2 = re.split('"', description1) if len(description2) == 1: description3 = description2[0].replace(' ', '\n') elif len(description2) == 0: description3 = '' else: # Remove all empty strings description2 = [x for x in description2 if x != ''] # Remove all ' ' strings (space) description2 = [x for x in description2 if x != ' '] if len(description2) == 1: description3 = description2[0] else: # We are left with only 2 strings. We merge them an place newline in between. description3 = description2[0] + '\n' + description2[1] # If string has new line '\n' on last place after parsing, remove it. if len(description3): if description3[-1] == '\n': description3 = description3[:-1] dictionary = { 'comment': comment, 'level': None, 'index': None, 'shape': None, 'label': description3, 'connectWith': None } flow.append(dictionary) if comment == 'fc:startStop': startStopCnt += 1 if startStopCnt == 1: functionName = description3.replace('\n', '_') if startStopCnt == 2: startStopCnt = 0 if FUNCS: for func in FUNCS: if func == functionName: generateGraph(functionName, flow) else: generateGraph(functionName, flow) flow = []
'ヨ': 215, 'ラ': 216, 'リ': 217, 'ル': 218, 'レ': 219, 'ロ': 220, 'ワ': 221, 'ン': 222, '゙': 223, '゚': 224, } while True: s = input(">") s = jaconv.hira2kata(s) s = jaconv.zen2han(s, ascii=True, digit=True) print(s) for c in s: code = table[c] - 1 print(hex(code) + ' (' + str(code) + ')') es = '"' print('{ ', end='') for c in s: code = table[c] - 1 if code == 0xa0: code = 0x20 print(f'0x{code:02x}' + ', ', end='')