Utils

class SupportsStr
__init__(*args, **kwargs)
class TypesDict

For dot.notation access to dictionary attributes

check_command_status(xml)

Check gmp response

Look into the gmp response and check for the status in the root element

Parameters:

xml (str) – XML-Source

Returns:

True if valid, otherwise False

Return type:

bool

deprecated(_func_or_cls=None, *, since=None, reason=None)

A decorator to mark functions, classes and methods as deprecated

Parameters:
  • since (str | None) – An optional version since the referenced item is deprecated.

  • reason (str | None) – An optional reason why the references item is deprecated.

Examples

from gvm.utils import deprecated

@deprecated
def my_function(*args, **kwargs):
    ...

@deprecated("The function is obsolete. Please use my_func instead.")
def my_function(*args, **kwargs):
    ...

@deprecated(
    since="1.2.3",
    reason="The function is obsolete. Please use my_func instead."
)
def my_function(*args, **kwargs):
    ...

@deprecated(reason="The class will be removed in version 3.4.5")
class Foo:
    ...

class Foo:
    @deprecated(since="2.3.4")
    def bar(self, *args, **kwargs):
        ...
to_dotted_types_dict(types)

Create a dictionary accessible via dot notation

XML

Element

alias of _Element

parse_xml(xml)

Parse an XML string and return the root element

Raises an XmlError if the XML is invalid.

pretty_print(xml, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)

Prints beautiful XML-Code

This function gets a string containing the xml, an object of List[lxml.etree.Element] or directly a lxml element.

Print it with good readable format.

Parameters:
  • xml (str, List[lxml.etree.Element] or lxml.etree.Element) – xml as string, List[lxml.etree.Element] or directly a lxml element.

  • file (TextIO | IOBase) – A IOBase type. Can be a File, StringIO, …