aboutsummaryrefslogtreecommitdiff
path: root/src/ee/part
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-03-15 07:58:06 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2019-03-15 08:30:07 +0100
commitb67aa2b41247991e361dec0963670b4e5108410a (patch)
tree67591b0f4cc6e767d0097c1afc3f08ad40ee19ea /src/ee/part
parent8d17fb5bc4b0dae0758e01a44d77d87acf2e686a (diff)
downloadee-python-b67aa2b41247991e361dec0963670b4e5108410a.tar.gz
ee-python-b67aa2b41247991e361dec0963670b4e5108410a.tar.bz2
ee-python-b67aa2b41247991e361dec0963670b4e5108410a.tar.xz
ee-python-b67aa2b41247991e361dec0963670b4e5108410a.zip
o Merging XSD files into one.
Diffstat (limited to 'src/ee/part')
-rw-r--r--src/ee/part/__init__.py20
-rw-r--r--src/ee/part/create_distributor_search_list.py4
2 files changed, 12 insertions, 12 deletions
diff --git a/src/ee/part/__init__.py b/src/ee/part/__init__.py
index 26bc26c..27b6619 100644
--- a/src/ee/part/__init__.py
+++ b/src/ee/part/__init__.py
@@ -2,7 +2,7 @@ from pathlib import Path
from typing import List, MutableMapping, Optional, Iterator
from ee import EeException
-from ee.xml import bomFile, indexFile
+from ee.xml import types
from ee.xml.bom_file_utils import find_pn, find_dpn, find_root_tag
__all__ = [
@@ -13,7 +13,7 @@ __all__ = [
class Entry(object):
- def __init__(self, new: bool, part: bomFile.Part):
+ def __init__(self, new: bool, part: types.Part):
self.new = new
self.part = part
@@ -30,7 +30,7 @@ class PartDb(object):
self.dpn_indexes = {} # type: MutableMapping[str, MutableMapping[str, Entry]]
self.new_entries = 0
- def add_entry(self, part: bomFile.Part, new: bool):
+ def add_entry(self, part: types.Part, new: bool):
e = Entry(new, part)
self.parts.append(e)
@@ -40,18 +40,18 @@ class PartDb(object):
if e.new:
self.new_entries = self.new_entries + 1
- def iterparts(self, sort=False) -> Iterator[bomFile.Part]:
+ def iterparts(self, sort=False) -> Iterator[types.Part]:
it = (e.part for e in self.parts)
return sorted(it, key=lambda p: p.idProp) if sort else it
def size(self) -> int:
return len(self.parts)
- def find_by_pn(self, pn: str) -> Optional[bomFile.Part]:
+ def find_by_pn(self, pn: str) -> Optional[types.Part]:
entry = self.pn_index.get(pn, None)
return entry.part if entry else None
- def find_by_dpn(self, distributor: str, pn: str) -> bomFile.Part:
+ def find_by_dpn(self, distributor: str, pn: str) -> types.Part:
idx = self.dpn_indexes.get(distributor)
if idx is None:
@@ -69,7 +69,7 @@ def load_db(dir_path: Path) -> PartDb:
if not file.is_file() or not file.name.endswith(".xml") or file.name == "index.xml":
continue
- part = bomFile.parse(str(file), silence=True) # type: bomFile.Part
+ part = types.parse(str(file), silence=True) # type: types.Part
db.add_entry(part, False)
return db
@@ -94,8 +94,8 @@ def save_db(dir_path: Path, db: PartDb):
dir_path.mkdir(parents=True, exist_ok=True)
- idx = indexFile.IndexFile()
- idx.filesProp = indexFile.FileList()
+ idx = types.IndexFile()
+ idx.filesProp = types.FileList()
files = idx.filesProp.fileProp
parts = db.iterparts()
@@ -107,7 +107,7 @@ def save_db(dir_path: Path, db: PartDb):
with path.open("w") as f:
part.export(outfile=f, level=0, name_=find_root_tag(part))
- files.append(indexFile.File(path=str(path)))
+ files.append(types.File(path=str(path)))
with (dir_path / "index.xml").open("w") as f:
idx.export(f, level=0, name_=find_root_tag(idx))
diff --git a/src/ee/part/create_distributor_search_list.py b/src/ee/part/create_distributor_search_list.py
index cfbe0d5..bd5f69e 100644
--- a/src/ee/part/create_distributor_search_list.py
+++ b/src/ee/part/create_distributor_search_list.py
@@ -1,7 +1,7 @@
from pathlib import Path
from ee.part import PartDb, load_db, save_db
-from ee.xml import bomFile
+from ee.xml import types
from ee.xml.bom_file_utils import *
__all__ = ["create_distributor_search_list"]
@@ -27,7 +27,7 @@ def create_distributor_search_list(in_dir: Path, out_dir: Path):
if entry is not None:
continue
- new_part = bomFile.Part(id=pn_value)
+ new_part = types.Part(id=pn_value)
new_part.part_numbersProp = part.part_numbersProp
out_parts.add_entry(new_part, True)