Skip to content
Draft
Show file tree
Hide file tree
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
26 changes: 14 additions & 12 deletions irods/message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from typing import Optional
from warnings import warn

import defusedxml.ElementTree as ET_secure_xml

import irods.exception as ex

from . import quasixml as ET_quasi_xml
Expand Down Expand Up @@ -105,24 +103,18 @@

def current_XML_parser(get_module=False):
d = getattr(_thrlocal, "xml_type", _default_XML)
return d if not get_module else _XML_parsers[d]
return d if not get_module else _XML_parser_for(d)


def default_XML_parser(get_module=False):
d = _default_XML
return d if not get_module else _XML_parsers[d]
return d if not get_module else _XML_parser_for(d)


def string_for_XML_parser(parser_enum):
return PARSER_TYPE_STRINGS[parser_enum]


_XML_parsers = {
XML_Parser_Type.STANDARD_XML: ET_xml,
XML_Parser_Type.QUASI_XML: ET_quasi_xml,
XML_Parser_Type.SECURE_XML: ET_secure_xml,
}

_reversed_XML_strings_lookup = {v: k for k, v in _XML_strings.items()}


Expand Down Expand Up @@ -178,9 +170,9 @@
_thrlocal.irods_server_version = tuple(
server_version
) # A default server version for Quasi-XML parsing is set (from the environment) and
return _XML_parsers[
return _XML_parser_for(
current_XML_parser()
] # applies to all threads in which ET() has not been called to update the value.
) # applies to all threads in which ET() has not been called to update the value.


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -1286,3 +1278,13 @@
]
gqo = GenQueryResponse(rowCnt=0, attriCnt=len(cols), SqlResult_PI=sql_results)
return gqo


def _XML_parser_for(d: XML_Parser_Type):

Check failure on line 1283 in irods/message/__init__.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-check

Ruff N802

N802: Function name `_XML_parser_for` should be lowercase [pep8-naming:invalid-function-name]
import defusedxml.ElementTree as ET_secure_xml
return {
XML_Parser_Type.STANDARD_XML: ET_xml,
XML_Parser_Type.QUASI_XML: ET_quasi_xml,
XML_Parser_Type.SECURE_XML: ET_secure_xml,
}[d]

Check failure on line 1290 in irods/message/__init__.py

View workflow job for this annotation

GitHub Actions / ruff-lint / ruff-format

Ruff format

Improper formatting
3 changes: 2 additions & 1 deletion irods/results.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from prettytable import PrettyTable
from irods.models import ModelBase


Expand All @@ -15,13 +14,15 @@ def __init__(self, raw):
self.continue_index = 0

def __str__(self):
from prettytable import PrettyTable
table = PrettyTable()
for col in self.cols:
table.add_column(ModelBase.columns()[col.attriInx].icat_key, col.value)
table.align = "l"
return table.get_string()

def get_html_string(self, *args, **kwargs):
from prettytable import PrettyTable
table = PrettyTable()
for col in self.cols:
table.add_column(ModelBase.columns()[col.attriInx].icat_key, col.value)
Expand Down
Loading