aboutsummaryrefslogtreecommitdiff
path: root/src/ee/xml/bom_file_utils.py
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-02-26 23:08:19 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2019-02-26 23:08:19 +0100
commit97c8bb9db96e27051f8746865f657408263db0b8 (patch)
tree604cb6e9b87e79f43e54940adbc83520e89940fe /src/ee/xml/bom_file_utils.py
parent80e0623913e87c6480049520590e424a831e0401 (diff)
downloadee-python-97c8bb9db96e27051f8746865f657408263db0b8.tar.gz
ee-python-97c8bb9db96e27051f8746865f657408263db0b8.tar.bz2
ee-python-97c8bb9db96e27051f8746865f657408263db0b8.tar.xz
ee-python-97c8bb9db96e27051f8746865f657408263db0b8.zip
o Creating a PartDb that manages a file system directory with one xml
file per part. o Switching xml-based code to use PartDb.
Diffstat (limited to 'src/ee/xml/bom_file_utils.py')
-rw-r--r--src/ee/xml/bom_file_utils.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ee/xml/bom_file_utils.py b/src/ee/xml/bom_file_utils.py
index f09a3dd..15f99b2 100644
--- a/src/ee/xml/bom_file_utils.py
+++ b/src/ee/xml/bom_file_utils.py
@@ -1,14 +1,23 @@
from typing import List, Optional
-from ee.xml import bomFile
+from ee.xml import bomFile, indexFile
__all__ = [
- "part_numbers",
+ "find_root_tag",
"find_pn",
"find_dpn",
]
+def find_root_tag(root):
+ tag = next((tag for tag, klass in bomFile.GDSClassesMapping.items() if klass == type(root)), None)
+
+ if tag is not None:
+ return tag
+
+ return next((tag for tag, klass in indexFile.GDSClassesMapping.items() if klass == type(root)))
+
+
def part_numbers(part: bomFile.Part) -> List[bomFile.PartNumber]:
pns = part.part_numbersProp # type: bomFile.PartNumberList