Skip to content

Commit

Permalink
Add: Allow to convert an XmlCommandElement into bytes
Browse files Browse the repository at this point in the history
This will allow to transfer an XmlCommandElement and therefore a
XmlCommand over a socket.
  • Loading branch information
bjoernricks authored and greenbonebot committed Jun 14, 2024
1 parent fb562e3 commit 6475ff7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion gvm/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,17 @@ def append_xml_str(self, xml_text: str) -> None:
self._element.append(node)

def to_string(self) -> str:
return xmltostring(self._element).decode("utf-8")
return self.to_bytes().decode("utf-8")

def to_bytes(self) -> bytes:
return xmltostring(self._element)

def __str__(self) -> str:
return self.to_string()

def __bytes__(self) -> bytes:
return self.to_bytes()


class XmlCommand(XmlCommandElement):
def __init__(self, name: str) -> None:
Expand Down

0 comments on commit 6475ff7

Please sign in to comment.