Skip to content

Commit

Permalink
Parser updates to support additional packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
awicenec committed Nov 14, 2024
1 parent f11bfb2 commit c95cd21
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 23 deletions.
10 changes: 4 additions & 6 deletions dlg_paletteGen/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
The main classes used by this module.
"""

from __future__ import annotations

import inspect
import re
import xml.etree.ElementTree as ET
Expand Down Expand Up @@ -124,9 +126,7 @@ def __init__(self, descr: Union[str | None], name=None):
self.format = ""
self._identify_format()
self.main_descr, self.params = self.process_descr()
self.brief_descr = (
self.main_descr.split(".")[0] + "." if self.main_descr else ""
)
self.brief_descr = self.main_descr.split(".")[0] + "." if self.main_descr else ""
self.returns = None

def _process_rEST(self, dd="") -> tuple:
Expand Down Expand Up @@ -335,9 +335,7 @@ def _process_casa(self, dd: str):
dList = dStr.split("\n")
try:
start_ind = [
idx
for idx, s in enumerate(dList)
if re.findall(r"-{1,20} parameter", s)
idx for idx, s in enumerate(dList) if re.findall(r"-{1,20} parameter", s)
][0] + 1
except IndexError:
start_ind = 0
Expand Down
4 changes: 2 additions & 2 deletions dlg_paletteGen/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import os
import sys
import tempfile
from typing import Any
from typing import Any, Tuple

import pkg_resources

Expand Down Expand Up @@ -168,7 +168,7 @@ def check_environment_variables() -> bool:
return True


def nodes_from_module(module_path, recursive=True) -> tuple[list, Any]:
def nodes_from_module(module_path, recursive=True) -> Tuple[list, Any]:
"""
Extract nodes from specified module.
Expand Down
10 changes: 2 additions & 8 deletions dlg_paletteGen/source_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,7 @@ def create_palette_node_from_params(params) -> tuple:
# check that type is a known value
if not FieldType.has_key(field_type):
logger.warning(
text
+ " '"
+ internal_name
+ "' field_type is Unknown: "
+ field_type
text + " '" + internal_name + "' field_type is Unknown: " + field_type
)

# check that usage is a known value
Expand Down Expand Up @@ -1019,9 +1015,7 @@ def params_to_nodes(params: dict, tag: str) -> list:

# if a construct is found, add to nodes
if data["construct"] != "":
logger.info(
"Adding component: " + data["construct"] + "/" + node["text"]
)
logger.info("Adding component: " + data["construct"] + "/" + node["text"])
construct_node = create_construct_node(data["construct"], node)
construct_node["repositoryUrl"] = git_repo
construct_node["commitHash"] = version
Expand Down
8 changes: 2 additions & 6 deletions dlg_paletteGen/support_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,7 @@ def populateFields(parameters: dict, dd) -> dict:
logger.debug("Final type of parameter %s: %s", p, field[p]["type"])
if isinstance(field[p]["value"], numpy.ndarray):
try:
field[p]["value"] = field[p]["defaultValue"] = field[p][
"value"
].tolist()
field[p]["value"] = field[p]["defaultValue"] = field[p]["value"].tolist()
except NotImplementedError:
field[p]["value"] = []
if repr(field[p]["value"]) == "nan" and numpy.isnan(field[p]["value"]):
Expand Down Expand Up @@ -786,9 +784,7 @@ def populateDefaultFields(Node): # pylint: disable=invalid-name
et[n]["value"] = 2
et[n]["defaultValue"] = 2
et[n]["type"] = "Integer"
et[n][
"description"
] = "Estimate of execution time (in seconds) for this application."
et[n]["description"] = "Estimate of execution time (in seconds) for this application."
et[n]["parameterType"] = "ConstraintParameter"
Node["fields"].update(et)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,4 +681,4 @@ def test_full_numpy():
for members in modules.values():
for node in members.values():
nodes.append(node)
assert len(modules) in [651, 654]
assert len(modules) in [651, 652, 654]

0 comments on commit c95cd21

Please sign in to comment.