개정판 fd721a9b
issue #49: allowable auto gen and testing regular expression
Change-Id: If73d69acbcca2cf7ee281e409588502eb21c993b
DTI_PID/DTI_PID/CodeTables.py | ||
---|---|---|
12 | 12 |
TABLES = {} |
13 | 13 |
DEFAULTS = ['NOMINALDIAMETER', 'FLUIDCODE', 'PIPINGMATERIALSCLASS', 'UNITNUMBER', 'INSULATIONPURPOSE', 'PNIDNUMBER', \ |
14 | 14 |
'VALVEOPERCODES', 'RESERVEDWORDS', 'DICTIONARY', 'EQPTAGNAMES'] |
15 |
ALLOWABLES = [('1', 'I', 'l'), ('0', 'O'), ('8', 'B'), ('2', 'Z')] # must sort long string first ex ('II', '"') for multi-chars, now possible single |
|
15 |
ALLOWABLES = [('1', 'I', 'l'), ('0', 'O'), ('8', 'B'), ('2', 'Z'), ('S', 's', '5')] # must sort long string first ex ('II', '"') for multi-chars, now possible single
|
|
16 | 16 |
|
17 | 17 |
def __init__(self, name, values): |
18 | 18 |
self.name = name |
... | ... | |
23 | 23 |
|
24 | 24 |
def find_starts_with(self, text, size_unit='Inch'): |
25 | 25 |
""" find text in table """ |
26 |
import re |
|
26 | 27 |
try: |
27 | 28 |
if self.name == "NOMINALDIAMETER": |
28 | 29 |
""" uid, code, metric, inch, inchstr, allowable_inch_str, metricstr, allowable_metric_str """ |
... | ... | |
39 | 40 |
return value[1], value[1] |
40 | 41 |
else: |
41 | 42 |
matches = [x for x in value[3] if x and text.startswith(x)] |
42 |
if matches: return value[1], matches[0] |
|
43 |
if matches: |
|
44 |
return value[1], matches[0] |
|
45 |
else: |
|
46 |
if value[3][0]: |
|
47 |
match = re.search(value[3][0], text) |
|
48 |
if match: |
|
49 |
return value[1], value[1] |
|
43 | 50 |
|
44 | 51 |
return None, None |
45 | 52 |
except Exception as ex: |
내보내기 Unified diff