mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Excel Tool: Highlight Obsolete Items with Grey Color
This commit is contained in:
parent
52c40d635b
commit
70c1708dd5
3 changed files with 271 additions and 970 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -273,44 +273,6 @@ def generatelistfromfile(dmobject):
|
|||
pass
|
||||
|
||||
|
||||
def getparammapping(dmobject, dmparam):
|
||||
hasmapping = 0
|
||||
mapping = ""
|
||||
if "tr-104" in sys.argv[1]:
|
||||
param = "Device.Services." + dmobject.get('name') + dmparam.get('name')
|
||||
else:
|
||||
param = dmobject.get('name') + dmparam.get('name')
|
||||
for value in listmapping:
|
||||
if param in value:
|
||||
hasmapping = 1
|
||||
config_type = value.split("!")
|
||||
mapping = config_type[1]
|
||||
mapping = mapping.replace("*/\n", "")
|
||||
break
|
||||
|
||||
return hasmapping, mapping
|
||||
|
||||
|
||||
def getobjmapping(dmobject):
|
||||
hasmapping = 0
|
||||
mapping = ""
|
||||
if "tr-104" in sys.argv[1]:
|
||||
obj = "Device.Services." + dmobject.get('name')
|
||||
else:
|
||||
obj = dmobject.get('name')
|
||||
for value in listmapping:
|
||||
config_type = value.split("!")
|
||||
mapping = config_type[0]
|
||||
mapping = mapping.replace("/*#", "")
|
||||
if obj == mapping:
|
||||
hasmapping = 1
|
||||
mapping = config_type[1]
|
||||
mapping = mapping.replace("*/\n", "")
|
||||
break
|
||||
|
||||
return hasmapping, mapping
|
||||
|
||||
|
||||
def objhaschild(parentname, level, check_obj):
|
||||
hasobj = 0
|
||||
model = model2 if check_obj == 0 else model1
|
||||
|
|
@ -398,69 +360,6 @@ def printOBJMaPPING(mapping):
|
|||
print("}\n}", file=fp)
|
||||
fp.close()
|
||||
|
||||
|
||||
def printPARAMMaPPING(mapping):
|
||||
fp = open('./.json_tmp', 'a', encoding='utf-8')
|
||||
lst = mapping.split("&")
|
||||
print("\"mapping\": [", file=fp)
|
||||
for i in range(len(lst)):
|
||||
config_type = lst[i].split(":", 1)
|
||||
config = config_type[1].split("/")
|
||||
|
||||
print("{", file=fp)
|
||||
print("\"type\": \"%s\"," % config_type[0].lower(), file=fp)
|
||||
|
||||
# SYSFS || PROCFS
|
||||
if config_type[0] == "SYSFS" or config_type[0] == "PROCFS":
|
||||
print("\"file\": \"%s\"" % config_type[1], file=fp)
|
||||
|
||||
# UCI, UBUS, CLI
|
||||
else:
|
||||
# Only for UCI, UBUS, CLI
|
||||
print("\"%s\": {" % config_type[0].lower(), file=fp)
|
||||
|
||||
# UCI
|
||||
if config_type[0] == "UCI":
|
||||
print("\"file\": \"%s\"," % config[0], file=fp)
|
||||
print("\"section\": {", file=fp)
|
||||
var = config[1].split(",")
|
||||
if len(var) == 1:
|
||||
print("\"type\": \"%s\"" % var[0], file=fp)
|
||||
elif len(var) > 1 and "@i" in var[1]:
|
||||
print("\"type\": \"%s\"," % var[0], file=fp)
|
||||
print("\"index\": \"%s\"" % var[1], file=fp)
|
||||
elif len(var) > 1:
|
||||
print("\"type\": \"%s\"," % var[0], file=fp)
|
||||
print("\"name\": \"%s\"" % var[1], file=fp)
|
||||
print("}", file=fp)
|
||||
if len(var) > 1:
|
||||
print("\"option\": {", file=fp)
|
||||
print("\"name\": \"%s\"" % config[2], file=fp)
|
||||
print("}", file=fp)
|
||||
|
||||
# UBUS
|
||||
elif config_type[0] == "UBUS":
|
||||
print("\"object\": \"%s\"," % config[0], file=fp)
|
||||
print("\"method\": \"%s\"," % config[1], file=fp)
|
||||
print("\"args\": {", file=fp)
|
||||
if config[2] != "":
|
||||
args = config[2].split(",")
|
||||
print("\"%s\": \"%s\"" % (args[0], args[1]), file=fp)
|
||||
print("}", file=fp)
|
||||
print("\"key\": \"%s\"" % config[3], file=fp)
|
||||
|
||||
# CLI
|
||||
elif config_type[0] == "CLI":
|
||||
print("\"command\": \"%s\"," % config[0], file=fp)
|
||||
print("\"args\": \"%s\"" % config[1], file=fp)
|
||||
|
||||
print("}", file=fp)
|
||||
|
||||
print("}", file=fp)
|
||||
print("]\n}", file=fp)
|
||||
fp.close()
|
||||
|
||||
|
||||
def removelastline():
|
||||
file = open("./.json_tmp", encoding='utf-8')
|
||||
lines = file.readlines()
|
||||
|
|
@ -502,7 +401,6 @@ def removetmpfiles():
|
|||
|
||||
def printOBJ(dmobject, hasobj, hasparam, bbfdm_type):
|
||||
uniquekeys = getuniquekeys(dmobject)
|
||||
hasmapping, mapping = getobjmapping(dmobject)
|
||||
if (dmobject.get('name')).endswith(".{i}."):
|
||||
fbrowse = "true"
|
||||
else:
|
||||
|
|
@ -511,8 +409,9 @@ def printOBJ(dmobject, hasobj, hasparam, bbfdm_type):
|
|||
fp = open('./.json_tmp', 'a', encoding='utf-8')
|
||||
print("\"type\" : \"object\",", file=fp)
|
||||
|
||||
if dmobject.get('version'):
|
||||
print("\"version\" : \"%s\"," % dmobject.get('version'), file=fp)
|
||||
status = dmobject.get('status')
|
||||
if status in {"deprecated", "obsoleted", "deleted"}:
|
||||
print("\"obsolete\" : true,", file=fp)
|
||||
|
||||
print("\"protocols\" : [%s]," % bbfdm_type, file=fp)
|
||||
print("\"description\" : \"%s\"," % getParamDesc(dmobject, None), file=fp)
|
||||
|
|
@ -527,12 +426,9 @@ def printOBJ(dmobject, hasobj, hasparam, bbfdm_type):
|
|||
else:
|
||||
print("\"array\" : %s" % fbrowse, file=fp)
|
||||
fp.close()
|
||||
if hasmapping:
|
||||
printOBJMaPPING(mapping)
|
||||
|
||||
|
||||
def printPARAM(dmparam, dmobject, bbfdm_type):
|
||||
hasmapping, mapping = getparammapping(dmobject, dmparam)
|
||||
islist, datatype, paramvalrange, paramenum, paramunit, parampattern, listminItem, listmaxItem, listmaxsize = getparamoption(dmparam)
|
||||
|
||||
fp = open('./.json_tmp', 'a', encoding='utf-8')
|
||||
|
|
@ -545,8 +441,9 @@ def printPARAM(dmparam, dmobject, bbfdm_type):
|
|||
if dmparam.get('mandatory') == "true":
|
||||
print("\"mandatory\" : true,", file=fp)
|
||||
|
||||
if dmparam.get('version'):
|
||||
print("\"version\" : \"%s\"," % dmparam.get('version'), file=fp)
|
||||
status = dmobject.get('status') or dmparam.get('status')
|
||||
if status in {"deprecated", "obsoleted", "deleted"}:
|
||||
print("\"obsolete\" : true,", file=fp)
|
||||
|
||||
print("\"protocols\" : [%s]," % bbfdm_type, file=fp)
|
||||
print("\"description\" : \"%s\"," % getParamDesc(dmparam, datatype), file=fp)
|
||||
|
|
@ -561,7 +458,7 @@ def printPARAM(dmparam, dmobject, bbfdm_type):
|
|||
|
||||
# add datatype
|
||||
print(("\"datatype\" : \"%s\"," % datatype) if (listmaxsize is not None or listminItem is not None or listmaxItem is not None or paramvalrange is not None or paramunit is not
|
||||
None or paramenum is not None or parampattern is not None or (hasmapping and islist == 0)) else ("\"datatype\" : \"%s\"" % datatype), file=fp)
|
||||
None or paramenum is not None or parampattern is not None) else ("\"datatype\" : \"%s\"" % datatype), file=fp)
|
||||
|
||||
if islist == 1:
|
||||
# add maximum size of list
|
||||
|
|
@ -609,35 +506,26 @@ def printPARAM(dmparam, dmobject, bbfdm_type):
|
|||
print("\"max\" : %s" % valrange[1], file=fp)
|
||||
print(("},") if (eachvalrange ==
|
||||
valranges[len(valranges)-1]) else ("}"), file=fp)
|
||||
print(("],") if (paramunit is not None or paramenum is not None or parampattern is not None
|
||||
or (hasmapping and islist == 0)) else ("]"), file=fp)
|
||||
print(("],") if (paramunit is not None or paramenum is not None or parampattern is not None) else ("]"), file=fp)
|
||||
|
||||
# add unit
|
||||
if paramunit is not None:
|
||||
print(("\"unit\" : \"%s\"," % paramunit) if (paramenum is not None or parampattern is not None or (
|
||||
hasmapping and islist == 0)) else ("\"unit\" : \"%s\"" % paramunit), file=fp)
|
||||
print(("\"unit\" : \"%s\"," % paramunit) if (paramenum is not None or parampattern is not None) else ("\"unit\" : \"%s\"" % paramunit), file=fp)
|
||||
|
||||
# add enumaration
|
||||
if paramenum is not None:
|
||||
print(("\"enumerations\" : [%s]," % paramenum) if (parampattern is not None or (
|
||||
hasmapping and islist == 0)) else ("\"enumerations\" : [%s]" % paramenum), file=fp)
|
||||
print(("\"enumerations\" : [%s]," % paramenum) if (parampattern is not None) else ("\"enumerations\" : [%s]" % paramenum), file=fp)
|
||||
|
||||
# add pattern
|
||||
if parampattern is not None:
|
||||
print(("\"pattern\" : [%s]," % parampattern.replace("\\", "\\\\")) if (
|
||||
hasmapping and islist == 0) else ("\"pattern\" : [%s]" % parampattern.replace("\\", "\\\\")), file=fp)
|
||||
print(("\"pattern\" : [%s]" % parampattern.replace("\\", "\\\\")), file=fp)
|
||||
|
||||
# close list
|
||||
if islist == 1:
|
||||
print(("},") if hasmapping else ("}"), file=fp)
|
||||
|
||||
# add mapping
|
||||
if hasmapping:
|
||||
fp.close()
|
||||
printPARAMMaPPING(mapping)
|
||||
else:
|
||||
print("}", file=fp)
|
||||
fp.close()
|
||||
|
||||
print("}", file=fp)
|
||||
fp.close()
|
||||
|
||||
|
||||
def printCOMMAND(dmparam, dmobject, _bbfdm_type):
|
||||
|
|
@ -647,9 +535,6 @@ def printCOMMAND(dmparam, dmobject, _bbfdm_type):
|
|||
print("\"async\" : %s," %
|
||||
("true" if dmparam.get('async') is not None else "false"), file=fp)
|
||||
|
||||
if dmparam.get('version'):
|
||||
print("\"version\" : \"%s\"," % dmparam.get('version'), file=fp)
|
||||
|
||||
inputfound = 0
|
||||
outputfound = 0
|
||||
for c in dmparam:
|
||||
|
|
@ -689,9 +574,6 @@ def printEVENT(dmparam, dmobject, _bbfdm_type):
|
|||
print("\"%s\" : {" % dmparam.get('name'), file=fp)
|
||||
print("\"type\" : \"event\",", file=fp)
|
||||
|
||||
if dmparam.get('version'):
|
||||
print("\"version\" : \"%s\"," % dmparam.get('version'), file=fp)
|
||||
|
||||
has_param = 0
|
||||
for c in dmparam:
|
||||
if c.tag == "parameter":
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ def is_dm_supported(supported_dm_list, dmobject):
|
|||
return "No"
|
||||
|
||||
|
||||
def add_data_to_list_dm(dm_list, obj, supported):
|
||||
dm_list.append(obj + "," + supported)
|
||||
def add_data_to_list_dm(dm_list, obj, supported, obsoleted):
|
||||
dm_list.append(obj + "," + supported + "," + obsoleted)
|
||||
|
||||
def parse_standard_object(list_read, list_write, dmobject, value, proto):
|
||||
hasobj = bbf.obj_has_child(value)
|
||||
|
|
@ -33,7 +33,8 @@ def parse_standard_object(list_read, list_write, dmobject, value, proto):
|
|||
|
||||
if bbf.is_proto_exist(value, proto) is True:
|
||||
supported = is_dm_supported(list_read, dmobject)
|
||||
add_data_to_list_dm(list_write, dmobject, supported)
|
||||
obsolete = bbf.get_option_value(value, "obsolete", False)
|
||||
add_data_to_list_dm(list_write, dmobject, supported, "Yes" if obsolete else "No")
|
||||
|
||||
if hasparam:
|
||||
if isinstance(value, dict):
|
||||
|
|
@ -46,7 +47,8 @@ def parse_standard_object(list_read, list_write, dmobject, value, proto):
|
|||
if bbf.is_proto_exist(v, proto) is False:
|
||||
continue
|
||||
supported = is_dm_supported(list_read, dmobject + k)
|
||||
add_data_to_list_dm(list_write, dmobject + k, supported)
|
||||
obsolete = bbf.get_option_value(v, "obsolete", False)
|
||||
add_data_to_list_dm(list_write, dmobject + k, supported, "Yes" if obsolete else "No")
|
||||
break
|
||||
|
||||
if hasobj:
|
||||
|
|
@ -61,7 +63,7 @@ def parse_standard_object(list_read, list_write, dmobject, value, proto):
|
|||
def parse_vendor_object(list_read, list_write):
|
||||
for entry in list_read:
|
||||
param = entry.get("param")
|
||||
add_data_to_list_dm(list_write, param, "Yes")
|
||||
add_data_to_list_dm(list_write, param, "Yes", "No")
|
||||
|
||||
|
||||
def load_json_data(dm_name):
|
||||
|
|
@ -102,6 +104,8 @@ def generate_excel_sheet(sheet, title, data, style_mapping):
|
|||
style_title = style_mapping["title"]
|
||||
style_default = style_mapping["default"]
|
||||
style_suffix = style_mapping["suffix"]
|
||||
style_obsolete_name = style_mapping["obsolete_name"]
|
||||
style_obsolete = style_mapping["obsolete"]
|
||||
|
||||
sheet.write(0, 0, title, style_title)
|
||||
sheet.write(0, 1, 'Supported', style_title)
|
||||
|
|
@ -114,8 +118,11 @@ def generate_excel_sheet(sheet, title, data, style_mapping):
|
|||
if param[0].endswith(suffix_candidate):
|
||||
suffix = suffix_style
|
||||
break
|
||||
|
||||
style_name, style = suffix or (None, style_default)
|
||||
|
||||
if param[2] == "Yes":
|
||||
style_name, style = style_obsolete_name, style_obsolete
|
||||
else:
|
||||
style_name, style = suffix or (None, style_default)
|
||||
|
||||
if style_name is not None:
|
||||
sheet.write(i + 1, 0, param[0], style_name)
|
||||
|
|
@ -139,15 +146,20 @@ def generate_excel_file(output_file):
|
|||
xlwt.add_palette_colour("custom_colour_yellow", 0x10)
|
||||
xlwt.add_palette_colour("custom_colour_green", 0x20)
|
||||
xlwt.add_palette_colour("custom_colour_grey", 0x30)
|
||||
xlwt.add_palette_colour("custom_colour_obsolete", 0x08)
|
||||
|
||||
wb.set_colour_RGB(0x10, 255, 255, 153)
|
||||
wb.set_colour_RGB(0x20, 102, 205, 170)
|
||||
wb.set_colour_RGB(0x30, 153, 153, 153)
|
||||
wb.set_colour_RGB(0x08, 221, 221, 221)
|
||||
|
||||
style_mapping = {
|
||||
"title": xlwt.easyxf('pattern: pattern solid, fore_colour custom_colour_grey;' +
|
||||
'font: bold 1, color black;' + 'alignment: horizontal center;'),
|
||||
"default": xlwt.easyxf('alignment: horizontal center;'),
|
||||
"obsolete_name": xlwt.easyxf('pattern: pattern solid, fore_colour custom_colour_obsolete'),
|
||||
"obsolete": xlwt.easyxf('pattern: pattern solid, fore_colour custom_colour_obsolete;' +
|
||||
'alignment: horizontal center;'),
|
||||
"suffix": {
|
||||
".": (xlwt.easyxf('pattern: pattern solid, fore_colour custom_colour_yellow'),
|
||||
xlwt.easyxf('pattern: pattern solid, fore_colour custom_colour_yellow;' +
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue