Skip to content

Commit

Permalink
Change: Allow passing an UUID to XmlCommand.add_filter as filter_id
Browse files Browse the repository at this point in the history
Start to support using UUIDs in our API.
  • Loading branch information
bjoernricks authored and greenbonebot committed Jun 14, 2024
1 parent bb57e35 commit 6fb277c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gvm/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import sys
from io import IOBase
from typing import AnyStr, List, Optional, TextIO, Union
from typing import AnyStr, Optional, TextIO, Union
from uuid import UUID

from lxml.etree import Element as create_element
from lxml.etree import Error as EtreeError
Expand Down Expand Up @@ -102,19 +103,19 @@ def __init__(self, name: str) -> None:
def add_filter(
self,
filter_string: Optional[str],
filter_id: Optional[str],
filter_id: Optional[Union[str, UUID]],
) -> "XmlCommand":
if filter_string:
self.set_attribute("filter", filter_string)

if filter_id:
self.set_attribute("filt_id", filter_id)
self.set_attribute("filt_id", str(filter_id))

return self


def pretty_print(
xml: Union[str, List[Union[Element, str]], Element],
xml: Union[str, list[Union[Element, str]], Element],
file: Union[TextIO, IOBase] = sys.stdout,
):
"""Prints beautiful XML-Code
Expand Down

0 comments on commit 6fb277c

Please sign in to comment.