|
|
@ -64,14 +64,14 @@ class FileFcts(tools.file_abstract.FileFcts): |
|
|
|
keyPur = keyPur[keyPur.find("-")+1:] |
|
|
|
if verify: print("isBlock "+a[0] + "=" + keyPur +" , " + blockPur + " , " + status) |
|
|
|
if (keyPur+"s" in D.LIST_SUBTABLES or keyPur in D.LIST_SUBTABLES) \ |
|
|
|
and block == D.CSV_BLOCK_SUBTABLES: |
|
|
|
and block == D.CSV_BLOCK_SUBTABLES and keyPur != B.SUBJECT_STEP: |
|
|
|
return True |
|
|
|
if block == D.CSV_BLOCK_SUBTABLES \ |
|
|
|
and status not in [D.CSV_BLOCK_OPTION, D.CSV_BLOCK_HEAD, D.CSV_BLOCK_STEP, D.CSV_BLOCK_TABLES, "status"] \ |
|
|
|
and status not in [D.CSV_BLOCK_OPTION, D.CSV_BLOCK_HEAD, D.CSV_BLOCK_TABLES, "status"] \ |
|
|
|
and keyPur in D.LIST_SUBTABLES_ATTR: |
|
|
|
return True |
|
|
|
if (keyPur + "s" in D.LIST_SUBTABLES or keyPur in D.LIST_SUBTABLES) \ |
|
|
|
and block == D.CSV_BLOCK_SUBTABLES: |
|
|
|
and block == D.CSV_BLOCK_SUBTABLES and keyPur != B.SUBJECT_STEP: |
|
|
|
return True |
|
|
|
elif "_"+a[0] == block or a[0] == block or "_"+a[0] == block: |
|
|
|
return True |
|
|
@ -101,12 +101,14 @@ class FileFcts(tools.file_abstract.FileFcts): |
|
|
|
g) data-table: array: field - values # spec.data, comp.artifacts |
|
|
|
:return: |
|
|
|
""" |
|
|
|
verify = True |
|
|
|
tdata = {} |
|
|
|
status = "start" |
|
|
|
verbose = False |
|
|
|
tableAttr = {} # table |
|
|
|
tableDict = {} # table |
|
|
|
subtable = {} |
|
|
|
steps = {} |
|
|
|
# Zeilen parsen |
|
|
|
for l in lines: |
|
|
|
fields = splitFields(l, D.CSV_DELIMITER, job) |
|
|
@ -115,11 +117,13 @@ class FileFcts(tools.file_abstract.FileFcts): |
|
|
|
# keywords option, step, table |
|
|
|
# subtable-Block |
|
|
|
if self.isBlock(msg, job, fields[0], D.CSV_BLOCK_SUBTABLES, status): # a[0].lower() in D.LIST_DATA_ATTR: |
|
|
|
if verify: print("block "+D.CSV_BLOCK_SUBTABLES+" :: "+l) |
|
|
|
subtable = setSubTable(job, subtable, a[0], fields) |
|
|
|
tdata[subtable["actTable"]] = subtable[subtable["actTable"]] |
|
|
|
status = subtable["actTable"] |
|
|
|
# attribute-Block |
|
|
|
elif self.isBlock(msg, job, fields[0], D.CSV_BLOCK_ATTR, status): # a[0].lower() in D.LIST_DATA_ATTR: |
|
|
|
if verify: print("block "+D.CSV_BLOCK_ATTR+" :: "+l) |
|
|
|
tableAttr = setTableAttribute(job, tableAttr, a[0], fields) |
|
|
|
if ttype == "" and D.DATA_ATTR_TYPE in tableAttr: |
|
|
|
ttype = tableAttr[D.DATA_ATTR_TYPE] |
|
|
@ -129,26 +133,31 @@ class FileFcts(tools.file_abstract.FileFcts): |
|
|
|
continue |
|
|
|
# head-Block |
|
|
|
elif self.isBlock(msg, job, fields[0], D.CSV_BLOCK_HEAD, status): |
|
|
|
if verify: print("block "+D.CSV_BLOCK_HEAD+" :: "+l) |
|
|
|
setTdataLine(tdata, fields, D.CSV_BLOCK_HEAD, job) |
|
|
|
status = "start" |
|
|
|
continue |
|
|
|
# option-Block |
|
|
|
elif self.isBlock(msg, job, fields[0], D.CSV_BLOCK_OPTION, status): |
|
|
|
if verify: print("block "+D.CSV_BLOCK_OPTION+" :: "+l) |
|
|
|
setTdataLine(tdata, fields, D.CSV_BLOCK_OPTION, job) |
|
|
|
status = "start" |
|
|
|
continue |
|
|
|
# step-Block |
|
|
|
elif (status != D.CSV_BLOCK_STEP) \ |
|
|
|
and self.isBlock(msg, job, fields[0], D.CSV_BLOCK_STEP, status): |
|
|
|
h = [] |
|
|
|
h.append(B.DATA_NODE_STEPS) |
|
|
|
if verify: print("block "+D.CSV_BLOCK_STEP+" :: "+l) |
|
|
|
#h = [] |
|
|
|
steps = setStepAttribute(job, steps, "", fields) |
|
|
|
#h.append(B.DATA_NODE_STEPS) |
|
|
|
if verbose: print(">> step "+l) |
|
|
|
tableDict = getTdataContent(msg, tdata, h) |
|
|
|
setTableHeader(tableDict, tableAttr, fields, ttype, job) |
|
|
|
#tableDict = getTdataContent(msg, tdata, h) |
|
|
|
#setTableHeader(tableDict, tableAttr, fields, ttype, job) |
|
|
|
status = D.CSV_BLOCK_STEP |
|
|
|
continue |
|
|
|
# table-Header Block |
|
|
|
elif self.isBlock(msg, job, fields[0], D.CSV_BLOCK_TABLES, status): |
|
|
|
if verify: print("block "+D.CSV_BLOCK_TABLES+" :: "+l) |
|
|
|
if verbose: print(">> tables " + l) |
|
|
|
h = a |
|
|
|
h[0] = B.DATA_NODE_TABLES |
|
|
@ -159,21 +168,26 @@ class FileFcts(tools.file_abstract.FileFcts): |
|
|
|
status = D.CSV_SPECTYPE_DATA |
|
|
|
# table-data-Block |
|
|
|
elif (status == D.CSV_SPECTYPE_DATA): |
|
|
|
if verify: print("block "+D.CSV_SPECTYPE_DATA+" :: "+l) |
|
|
|
tableDict = getTdataContent(msg, tdata, h) |
|
|
|
if verbose: print(">> setTableData " + str(h) + " " + str(tableDict)) |
|
|
|
setTableData(tableDict, fields, ttype, job) |
|
|
|
# step-data-Block |
|
|
|
elif (status == D.CSV_BLOCK_STEP): |
|
|
|
if verify: print("block "+D.CSV_BLOCK_STEP+"2 :: "+l) |
|
|
|
print("step-line "+status+": "+l) |
|
|
|
h = [] |
|
|
|
h.append(B.DATA_NODE_STEPS) |
|
|
|
tableDict = getTdataContent(msg, tdata, h) |
|
|
|
if verbose: print(">> setTableData " + str(h) + " " + str(tableDict)) |
|
|
|
setTableData(tableDict, fields, ttype, job) |
|
|
|
#h = [] |
|
|
|
steps = setStepAttribute(job, steps, fields[1], fields) |
|
|
|
tdata[B.SUBJECT_STEPS] = steps |
|
|
|
#h.append(B.DATA_NODE_STEPS) |
|
|
|
#tableDict = getTdataContent(msg, tdata, h) |
|
|
|
#if verbose: print(">> setTableData " + str(h) + " " + str(tableDict)) |
|
|
|
#setTableData(tableDict, fields, ttype, job) |
|
|
|
#tableDict = getTdataContent(msg, tdata, h) |
|
|
|
#if verbose: print(">> setTableData " + str(h) + " " + str(tableDict)) |
|
|
|
#setTableData(tableDict, fields, ttype, job) |
|
|
|
else: |
|
|
|
if verify: print("block else :: "+l) |
|
|
|
print("unbekannter Block "+status+": "+l) |
|
|
|
|
|
|
|
if D.DATA_ATTR_TYPE not in tableAttr: |
|
|
@ -385,32 +399,58 @@ def setSubTable(job, subtable, key, val): |
|
|
|
# stories => new subtable |
|
|
|
# stories-descriptiom => attribute of actual subtable |
|
|
|
# descriptiom => attribute of actual subtable |
|
|
|
key = key.lower() |
|
|
|
key = key.lower() # tools.data_tool.getPluralKeyword(key) |
|
|
|
subkey = "" |
|
|
|
newSubtable = False |
|
|
|
print("setSubtable "+key+", "+str(val)) |
|
|
|
if "actTable" in subtable and subtable["actTable"]+"-" in key: |
|
|
|
subkey = key[key.find("-")+1:] |
|
|
|
if subkey == "" and key not in subtable: |
|
|
|
keyword = tools.data_tool.getPluralKeyword(key) |
|
|
|
if subkey == "" and keyword not in subtable: |
|
|
|
newSubtable = True |
|
|
|
subtable[key] = {} |
|
|
|
subtable["actTable"] = key |
|
|
|
subtable[keyword] = {} |
|
|
|
subtable["actTable"] = keyword |
|
|
|
actTable = subtable["actTable"] |
|
|
|
purKey = tools.data_tool.getPurKeyword(key) |
|
|
|
print("setSubtable "+key+" =? "+actTable+ " + "+ purKey +" , "+str(val)) |
|
|
|
actKeys = list(subtable[actTable].keys()) |
|
|
|
for i in range(1, len(val)): |
|
|
|
if newSubtable and val[i] not in subtable[key]: |
|
|
|
if newSubtable and val[i] not in subtable[actTable]: |
|
|
|
if val[i] == "": |
|
|
|
break |
|
|
|
subtable[actTable][val[i]] = {} |
|
|
|
subtable[actTable][val[i]]["name"] = val[i] |
|
|
|
else: |
|
|
|
if i >= len(actKeys): |
|
|
|
if i > len(actKeys): |
|
|
|
break |
|
|
|
subtable[actTable][actKeys[i]][purKey] = val[i] |
|
|
|
subtable[actTable][actKeys[i-1]][purKey] = val[i] |
|
|
|
return subtable |
|
|
|
|
|
|
|
def setStepAttribute(job, stepAttr, key, val): |
|
|
|
if key == "": |
|
|
|
stepAttr[B.DATA_NODE_HEADER] = [] |
|
|
|
for i in range(1, len(val)): |
|
|
|
if len(val[i]) < 1: |
|
|
|
continue |
|
|
|
stepAttr[B.DATA_NODE_HEADER].append(val[i]) |
|
|
|
else: |
|
|
|
if B.DATA_NODE_HEADER not in stepAttr: |
|
|
|
print("Error: header is missing ") |
|
|
|
i = 1 |
|
|
|
step = {} |
|
|
|
for h in stepAttr[B.DATA_NODE_HEADER]: |
|
|
|
if len(h) < 1: |
|
|
|
continue |
|
|
|
if tools.data_tool.isStrDict(val[i]): |
|
|
|
step[h] = tools.data_tool.getStrDict(val[i]) |
|
|
|
else: |
|
|
|
step[h] = val[i] |
|
|
|
i += 1 |
|
|
|
key = "{:0>2d}_{}".format(int(step["sortnr"]), step["variant"]) |
|
|
|
step["name"] = step["variant"] |
|
|
|
stepAttr[key] = step |
|
|
|
return stepAttr |
|
|
|
|
|
|
|
def setTableAttribute(job, tableAttr, key, val): |
|
|
|
key = key.lower() |
|
|
|
if key in D.LIST_DATA_ATTR: |
|
|
|