parent
9a090012a6
commit
4872a6d366
|
|
@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Components with mounting hole where excluded (#201)
|
- Components with mounting hole where excluded (#201)
|
||||||
- GenCAD output targets.
|
- GenCAD output targets.
|
||||||
- Problems expanding multiple KiCad variables in the same value.
|
- Problems expanding multiple KiCad variables in the same value.
|
||||||
|
- XML BoM: Fixed problems with fields containing / (#206)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- KiCad environment variables: more variables detected, native KiCad 6 names,
|
- KiCad environment variables: more variables detected, native KiCad 6 names,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (c) 2020-2021 Salvador E. Tropea
|
# Copyright (c) 2020-2022 Salvador E. Tropea
|
||||||
# Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial
|
# Copyright (c) 2020-2022 Instituto Nacional de Tecnología Industrial
|
||||||
# Copyright (c) 2016-2020 Oliver Henry Walters (@SchrodingersGat)
|
# Copyright (c) 2016-2020 Oliver Henry Walters (@SchrodingersGat)
|
||||||
# License: MIT
|
# License: MIT
|
||||||
# Project: KiBot (formerly KiPlot)
|
# Project: KiBot (formerly KiPlot)
|
||||||
|
|
@ -55,16 +55,16 @@ def write_xml(filename, groups, headings, head_names, cfg):
|
||||||
for i, h in enumerate(head_names):
|
for i, h in enumerate(head_names):
|
||||||
# Adapt the column name to a valid XML attribute name
|
# Adapt the column name to a valid XML attribute name
|
||||||
h = h.replace(' ', '_')
|
h = h.replace(' ', '_')
|
||||||
|
h = h.replace('/', '_')
|
||||||
h = h.replace('"', '')
|
h = h.replace('"', '')
|
||||||
h = h.replace("'", '')
|
h = h.replace("'", '')
|
||||||
h = h.replace('#', '_num')
|
h = h.replace('#', '_num')
|
||||||
attrib[h] = str(row[i])
|
attrib[h] = str(row[i])
|
||||||
ElementTree.SubElement(xml, "group", attrib=attrib)
|
ElementTree.SubElement(xml, "group", attrib=attrib)
|
||||||
|
|
||||||
# Most of the UTF-8 enforcement here is for Windows
|
with open(filename, "wb") as output:
|
||||||
# Selecting it in the tostring call is enough for Linux
|
out = ElementTree.tostring(xml, encoding="utf8")
|
||||||
with open(filename, "wt", encoding="utf-8") as output:
|
reparsed = minidom.parseString(out.decode('utf8'))
|
||||||
out = ElementTree.tostring(xml, encoding="utf-8")
|
output.write(reparsed.toprettyxml(indent="\t", encoding="utf8"))
|
||||||
output.write(minidom.parseString(out).toprettyxml(indent="\t", encoding="utf-8").decode("utf-8"))
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue