massage datatypes for configparser

workspace
Brendan Howell 5 years ago
parent 8812123baf
commit 0dd6bc979b

@ -185,23 +185,21 @@ class Bureau(object):
try:
printcfg.read("printers.cfg")
self.smprint = object()
self.smprint["vendorid"] = printcfg["smallprinter"]["vendorid"]
self.smprint["prodid"] = printcfg["smallprinter"]["productid"]
self.smprint["in_ep"] = printcfg["smallprinter"]["inep"]
self.smprint["out_ep"] = printcfg["smallprinter"]["outep"]
self.smprint["vendorid"] = int(printcfg["smallprinter"]["vendorid"], 16)
self.smprint["prodid"] = int(printcfg["smallprinter"]["productid"], 16)
self.smprint["in_ep"] = int(printcfg["smallprinter"]["inep"], 16)
self.smprint["out_ep"] = int(printcfg["smallprinter"]["outep"], 16)
self.smprint["width"] = int(printcfg["smallprinter"]["width"])
self.smprint["textwidth"] = int(printcfg["smallprinter"]["textwidth"])
self.lp["name"] = printcfg["largeprinter"]["name"]
self.lp["papersize"] = printcfg["largeprinter"]["papersize"]
self.lp["duplex"] = printcfg["largeprinter"]["duplex"]
self.lp["duplex"] = printcfg["largeprinter"].getboolean("duplex")
except KeyError:
# TODO: eventually refactor this since it could overwrite a half-broken config
sp_dict = {"vendorid": None, "productid": None,
"inep": None, "outep": None, "width": "384",
"textwidth": "32"}
lp_dict = {"name": None, "papersize": "A4",
"duplex": False}
sp_dict = {"vendorid": "", "productid": "", "inep": "",
"outep": "", "width": "384", "textwidth": "32"}
lp_dict = {"name": "", "papersize": "A4", "duplex": "False"}
printcfg["smallprinter"] = sp_dict
printcfg["largeprinter"] = lp_dict
with open("printers.cfg", "w") as print_conf_file:

Loading…
Cancel
Save