def get_person(self, table, name, cur): """try to figure out if person is a legal_person or a natural person""" result_id = 0 if len(name) > 0: legal_person = False legal_lst = (",", "-","/", "S.A.","S.R.L", "SA", "SRL") match = Combine(Optional(Literal(",")) | Optional(Literal("-")) | \ Optional(Literal("/")) | Optional(Keyword("S.A.")) | \ Optional(Keyword("S.R.L"))) res = match.searchString(name) for token in res: if token[0] in legal_lst: legal_person = True break sql = """SELECT id FROM PERSONS WHERE person_name = ? """ person_id = self.check_id(sql, cur, (name, )) if not person_id: sql_insert = """ INSERT INTO PERSONS (person_name, legal_person) VALUES (?, ?)""" person_id = cur.execute(sql_insert, (name, legal_person)).lastrowid sql_find = """ SELECT id FROM """ + table + """ WHERE person_id = ?""" result_id = self.check_id(sql_find,cur, (person_id,)) if not result_id: sql_insert = "INSERT INTO " + table + """ (person_id) VALUES (?)""" result_id = cur.execute(sql_insert, (person_id, )).lastrowid return result_id
greeting = greet.parseString("Hello, World!") print(greeting) numeric_const_pattern = r""" [-+]? # optional sign (?: (?: \d* \. \d+ ) | (?: \d+ \.? ) ) (?: [Ee] [+-]? \d+ ) ? """ txt = """ x = (0:0.2:10)'; y1 = trimf(x, [3 4 5]); y2 = trimf(x, [2 4 7]); y3 = trimf(x, [1 4 9]); subplot(211), plot(x, [y1 y2 y3]); y1 = trimf(x, [2 3 5]); y2 = trimf(x, [3 4 7]); y3 = trimf(x, [4 5 9]); subplot(212), plot(x, [y1 y2 y3]); set(gcf, 'name', 'trimf', 'numbertitle', 'off' """ # floatt = Word(FLOAT) print(floatnumber.searchString(txt)) #rx = re.compile(numeric_const_pattern, re.VERBOSE)