Skip to content

Commit

Permalink
varia
Browse files Browse the repository at this point in the history
  • Loading branch information
mokko committed Feb 10, 2024
1 parent 0cc5119 commit 406f22c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/mpapi/data/xsd/search_1_6.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@
-->
<xs:simpleType name="Path">
<xs:restriction base="xs:string">
<xs:pattern value="__orgUnit|__id|__lastModified|__lastModifiedUser|__created|__createdUser|[a-zA-Z][a-zA-Z0-9_$]*(\.[a-zA-Z][a-zA-Z0-9_$]*)*(\[[a-zA-Z][a-zA-Z0-9_$]*\]|\.(__attributes\.[a-zA-Z][a-zA-Z0-9_$]*|__id|__lastModified|__lastModifiedUser|__created|__createdUser|__parent(((\.[a-zA-Z][a-zA-Z0-9_$]*)+((\[[a-zA-Z][a-zA-Z0-9_$]*\]|(\.__attributes\.[a-zA-Z][a-zA-Z0-9_$]*))|\.__id|\.__lastModified|\.__lastModifiedUser|\.__created|\.__createdUser)?)|(\.(__id|__lastModified|__lastModifiedUser|__created|__createdUser)))?))?" />
<xs:pattern value="__attachment|__orgUnit|__id|__lastModified|__lastModifiedUser|__created|__createdUser|[a-zA-Z][a-zA-Z0-9_$]*(\.[a-zA-Z][a-zA-Z0-9_$]*)*(\[[a-zA-Z][a-zA-Z0-9_$]*\]|\.(__attributes\.[a-zA-Z][a-zA-Z0-9_$]*|__id|__lastModified|__lastModifiedUser|__created|__createdUser|__parent(((\.[a-zA-Z][a-zA-Z0-9_$]*)+((\[[a-zA-Z][a-zA-Z0-9_$]*\]|(\.__attributes\.[a-zA-Z][a-zA-Z0-9_$]*))|\.__id|\.__lastModified|\.__lastModifiedUser|\.__created|\.__createdUser)?)|(\.(__id|__lastModified|__lastModifiedUser|__created|__createdUser)))?))?" />
</xs:restriction>
</xs:simpleType>

Expand Down
1 change: 1 addition & 0 deletions src/mpapi/data/xsd/search_1_8.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@
the EqualsField element with fieldPath: "Surname".
3.9.2023 __orgUnit added by Maurice
28.1.2024 __attachment added by Maurice. Cant get it to work
-->
<xs:simpleType name="Path">
<xs:restriction base="xs:string">
Expand Down
4 changes: 3 additions & 1 deletion src/mpapi/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def toFile(self, *, path: Union[Path, str]) -> None:
self._write(path=str(path), doc=doc)
except:
# print("WARNING: Trouble writing file")
doc = etree.ElementTree(self.etree)
doc = etree.ElementTree(
self.etree,
)
self._write(path=str(path), doc=doc)

def toET(self) -> ET:
Expand Down
6 changes: 5 additions & 1 deletion src/mpapi/mink.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,11 @@ def getPack(self, args: list) -> None:
def join(self, args: list) -> Path:
Type = args[0]
Id = args[1]
label = args[2]
try:
label = args[2]
except:
label = "nolabel"

try:
since = args[4]
except:
Expand Down
18 changes: 12 additions & 6 deletions src/mpapi/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,7 @@ def filter(self, *, xpath: str, mtype: str = "Object") -> Self:
For an xpath that returns a list of moduleItems, return a new Module object with
only those items. Note: You need to set the mtype manually.
"""
moduleItemL = self.xpath(xpath)
ET = etree.XML(
newET = etree.XML(
f"""
<application xmlns="http://www.zetcom.com/ria/ws/module">
<modules>
Expand All @@ -533,14 +532,21 @@ def filter(self, *, xpath: str, mtype: str = "Object") -> Self:
parser=parser,
)

moduleN: Any = ET.xpath("/m:application/m:modules/m:module", namespaces=NSMAP)[
0
]
moduleN: Any = newET.xpath(
f"/m:application/m:modules/m:module", namespaces=NSMAP
)[0]
moduleItemL = self.xpath(xpath)
print(f"FOUND ITEMS: {len(moduleItemL)}")
[moduleN.append(moduleItemN) for moduleItemN in moduleItemL]
m = Module(tree=ET)
m = Module(tree=newET)
m.updateTotalSize()
return m

def filter2(self, *, xpath: str) -> Self:
"""Version of filter that uses the first mtype from orignal module"""
mtype = self.extract_mtypes()[0]
return self.filter(xpath=xpath, mtype=mtype)

def module(self, *, name: str) -> ET:
"""
Return module element with that name or make a new one if it
Expand Down

0 comments on commit 406f22c

Please sign in to comment.