Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions clixon/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


class Element(object):
_creatortag = None
def __init__(
self,
name: Optional[str] = "root",
Expand Down Expand Up @@ -466,6 +467,29 @@ def findall(self, name: str) -> list:

return self.get_elements(name=name, recursive=True)

def set_creator(self,creator: str) -> None:
"""
Set the creator tag to all class instances
:creator string: Valid XPath creator tag
:return: None
:rtype: None
"""
Element._creatortag = creator

def tag_creator(self) -> None:
"""
Apply creator tag to Element
:return: self
:rtype: Element
"""
if Element._creatortag:
attribs = self.get_attributes()
attribs['cl:creator'] = Element._creatortag
self.set_attributes(attribs)
return self
else:
raise("Creator tag not defined")

def __getitem__(self, key: str) -> Optional[dict]:
"""
Return the attributes of the element.
Expand Down
Loading