138 |
138 |
delimiter = configs[0].value if 1 == len(configs) else '-'
|
139 |
139 |
# line config
|
140 |
140 |
configs = docData.getConfigs('Line No', 'Configuration')
|
141 |
|
lineNoConfig = configs[0].value.split(self.delimiter)
|
|
141 |
if configs and configs[0].value:
|
|
142 |
lineNoConfig = configs[0].value.split(self.delimiter)
|
142 |
143 |
|
143 |
|
res = []
|
|
144 |
res = []
|
144 |
145 |
|
145 |
|
if lineNoConfig is None or len(lineNoConfig) == 0:
|
146 |
|
return (False,)
|
147 |
|
|
148 |
|
tokens = text.split(delimiter)
|
149 |
|
patternText = configs[0].value.replace(self.delimiter, '').split(self.delimiter)
|
150 |
|
#Line Number에 Delimiter가 있을 수 있음
|
151 |
|
if configs[0].value != 'None' and len(tokens) >= len(patternText):
|
152 |
|
loopText = text.replace(' ','')
|
153 |
|
|
154 |
|
for propertyName in lineNoConfig:
|
155 |
|
isStartWord = False
|
156 |
|
loopList = []
|
157 |
|
|
158 |
|
lineProp = docData.getLinePropertiesByUID(propertyName)
|
159 |
|
# Line property인 경우
|
160 |
|
if lineProp:
|
161 |
|
lineType = lineProp[0].AttributeType
|
162 |
|
if lineType == 'Code Table':
|
163 |
|
tableName = lineProp[0].Attribute
|
164 |
|
if tableName == 'NominalDiameter':
|
165 |
|
loopListOri = docData.getCodeTable(tableName, True)
|
166 |
|
for loop in loopListOri:
|
167 |
|
loopList.append((loop, loop))
|
|
146 |
if lineNoConfig is None or len(lineNoConfig) == 0:
|
|
147 |
return (False,)
|
|
148 |
|
|
149 |
tokens = text.split(delimiter)
|
|
150 |
patternText = configs[0].value.replace(self.delimiter, '').split(self.delimiter)
|
|
151 |
#Line Number에 Delimiter가 있을 수 있음
|
|
152 |
if configs[0].value != 'None' and len(tokens) >= len(patternText):
|
|
153 |
loopText = text.replace(' ','')
|
|
154 |
|
|
155 |
for propertyName in lineNoConfig:
|
|
156 |
isStartWord = False
|
|
157 |
loopList = []
|
|
158 |
|
|
159 |
lineProp = docData.getLinePropertiesByUID(propertyName)
|
|
160 |
# Line property인 경우
|
|
161 |
if lineProp:
|
|
162 |
lineType = lineProp[0].AttributeType
|
|
163 |
if lineType == 'Code Table':
|
|
164 |
tableName = lineProp[0].Attribute
|
|
165 |
if tableName == 'NominalDiameter':
|
|
166 |
loopListOri = docData.getCodeTable(tableName, True)
|
|
167 |
for loop in loopListOri:
|
|
168 |
loopList.append((loop, loop))
|
|
169 |
else:
|
|
170 |
allAllows = docData.getCodeTable(tableName)
|
|
171 |
for index in range(len(allAllows)):
|
|
172 |
loopList.append((allAllows[index][1], allAllows[index][1]))
|
|
173 |
if allAllows[index][3] != '' and allAllows[index][3] != None:
|
|
174 |
allows = allAllows[index][3].split(',')
|
|
175 |
for allow in allows:
|
|
176 |
loopList.append((allow, allAllows[index][1]))
|
|
177 |
|
|
178 |
isStartWord = True
|
|
179 |
|
|
180 |
elif lineType == 'Int':
|
|
181 |
length = lineProp[0].Length
|
|
182 |
loopList.append((length, True))
|
|
183 |
|
|
184 |
elif lineType == 'String':
|
|
185 |
length = lineProp[0].Length
|
|
186 |
loopList.append((length, False))
|
|
187 |
|
|
188 |
# 못찾은 경우 (ex. delimiter)
|
|
189 |
else:
|
|
190 |
if propertyName == delimiter:
|
|
191 |
loopList.append((delimiter, delimiter))
|
|
192 |
isStartWord = True
|
168 |
193 |
else:
|
169 |
|
allAllows = docData.getCodeTable(tableName)
|
170 |
|
for index in range(len(allAllows)):
|
171 |
|
loopList.append((allAllows[index][1], allAllows[index][1]))
|
172 |
|
if allAllows[index][3] != '' and allAllows[index][3] != None:
|
173 |
|
allows = allAllows[index][3].split(',')
|
174 |
|
for allow in allows:
|
175 |
|
loopList.append((allow, allAllows[index][1]))
|
176 |
|
|
177 |
|
isStartWord = True
|
178 |
|
|
179 |
|
elif lineType == 'Int':
|
180 |
|
length = lineProp[0].Length
|
181 |
|
loopList.append((length, True))
|
182 |
|
|
183 |
|
elif lineType == 'String':
|
184 |
|
length = lineProp[0].Length
|
185 |
|
loopList.append((length, False))
|
|
194 |
return (False,)
|
|
195 |
|
|
196 |
find = False
|
|
197 |
for loop in loopList:
|
|
198 |
if isStartWord:
|
|
199 |
result = self.isStartWithWord(loopText, loop)
|
|
200 |
else:
|
|
201 |
result = self.isLimitWord(loopText, loop)
|
|
202 |
if result[0]:
|
|
203 |
loopText = result[1]
|
|
204 |
res.append(result[2])
|
|
205 |
find = True
|
|
206 |
break
|
|
207 |
if not find:
|
|
208 |
return (False,)
|
186 |
209 |
|
187 |
|
# 못찾은 경우 (ex. delimiter)
|
|
210 |
if loopText == '':
|
|
211 |
return (True, res)
|
188 |
212 |
else:
|
189 |
|
if propertyName == delimiter:
|
190 |
|
loopList.append((delimiter, delimiter))
|
191 |
|
isStartWord = True
|
192 |
|
else:
|
193 |
|
return (False,)
|
194 |
|
|
195 |
|
find = False
|
196 |
|
for loop in loopList:
|
197 |
|
if isStartWord:
|
198 |
|
result = self.isStartWithWord(loopText, loop)
|
199 |
|
else:
|
200 |
|
result = self.isLimitWord(loopText, loop)
|
201 |
|
if result[0]:
|
202 |
|
loopText = result[1]
|
203 |
|
res.append(result[2])
|
204 |
|
find = True
|
205 |
|
break
|
206 |
|
if not find:
|
207 |
213 |
return (False,)
|
208 |
214 |
|
209 |
|
if loopText == '':
|
210 |
|
return (True, res)
|
211 |
|
else:
|
212 |
|
return (False,)
|
213 |
|
|
214 |
215 |
return (False,)
|
215 |
216 |
except Exception as ex:
|
216 |
|
print('error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno))
|
|
217 |
from App import App
|
|
218 |
|
|
219 |
message = 'error occured({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename, sys.exc_info()[-1].tb_lineno)
|
|
220 |
App.mainWnd().addMessage.emit(MessageType.Error, message)
|
|
221 |
finally:
|
|
222 |
return (False,)
|
217 |
223 |
|
218 |
224 |
'''
|
219 |
225 |
@brief Check Text startwith word
|