8000 Fixes linting by domna · Pull Request #137 · FAIRmat-NFDI/pynxtools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixes linting #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2023
Merged
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
4 changes: 2 additions & 2 deletions pynxtools/dataconverter/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ def get_all_defined_required_children_for_elem(xml_element):
visited_paths.append(nxdlpath)
children = get_all_defined_required_children(nxdlpath, nx_name)
further_children = set()
for child in children:
further_children.add(f"{name_to_add}/{child}")
for further_child in children:
further_children.add(f"{name_to_add}/{further_child}")
list_of_children_to_add.update(further_children)
return list_of_children_to_add

Expand Down
14 changes: 7 additions & 7 deletions pynxtools/nexus/nexus.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import h5py
import click

from .nxdl_utils import *
from pynxtools.nexus.nxdl_utils import * # pylint: disable=wildcard-import, unused-wildcard-import


def get_nxdl_entry(hdf_info):
Expand Down Expand Up @@ -196,8 +196,8 @@ def get_nxdl_doc(hdf_info, logger, doc, attr=False):
# new way: retrieve multiple inherited base classes
(class_path, nxdl_path, elist) = \
get_inherited_hdf_nodes(nx_name=get_nxdl_entry(hdf_info), hdf_node=hdf_node,
hdf_path=hdf_info['hdf_path'] if 'hdf_path' in hdf_info else None,
hdf_root=hdf_info['hdf_root'] if 'hdf_root' in hdf_info else None)
hdf_path=hdf_info['hdf_path'] if 'hdf_path' in hdf_info else None,
hdf_root=hdf_info['hdf_root'] if 'hdf_root' in hdf_info else None)
elem = elist[0] if class_path and elist else None
if doc:
logger.debug("classpath: " + str(class_path))
Expand Down Expand Up @@ -259,8 +259,8 @@ def get_hdf_path(hdf_info):


@lru_cache(maxsize=None)
def get_inherited_hdf_nodes(nx_name: str = None, elem: ET.Element = None,# pylint: disable=too-many-arguments,too-many-locals
hdf_node=None, hdf_path=None, hdf_root=None, attr=False):
def get_inherited_hdf_nodes(nx_name: str = None, elem: ET.Element = None, # pylint: disable=too-many-arguments,too-many-locals
hdf_node=None, hdf_path=None, hdf_root=None, attr=False):
"""Returns a list of ET.Element for the given path."""
# let us start with the given definition file
if hdf_node is None:
Expand Down Expand Up @@ -541,8 +541,8 @@ def get_all_is_a_rel_from_hdf_node(hdf_node, hdf_path):
hdf_info = {'hdf_path': hdf_path, 'hdf_node': hdf_node}
(_, _, elist) = \
get_inherited_hdf_nodes(nx_name=get_nxdl_entry(hdf_info), hdf_node=hdf_node,
hdf_path=hdf_info['hdf_path'] if 'hdf_path' in hdf_info else None,
hdf_root=hdf_info['hdf_root'] if 'hdf_root' in hdf_info else None)
hdf_path=hdf_info['hdf_path'] if 'hdf_path' in hdf_info else None,
hdf_root=hdf_info['hdf_root'] if 'hdf_root' in hdf_info else None)
return elist


Expand Down
8 changes: 3 additions & 5 deletions pynxtools/nexus/nxdl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import xml.etree.ElementTree as ET
from functools import lru_cache
from glob import glob
import sys
import logging
import textwrap


Expand Down Expand Up @@ -373,6 +371,7 @@ def get_required_string(nxdl_elem):
return "<<REQUIRED>>"
return "<<REQUIRED>>"


# below there are some functions used in get_nxdl_doc function:
def write_doc_string(logger, doc, attr):
"""Simple function that prints a line in the logger if doc exists"""
Expand Down Expand Up @@ -671,11 +670,10 @@ def walk_elist(elist, html_name):
return elist, html_name



@lru_cache(maxsize=None)
def get_inherited_nodes(nxdl_path: str = None, # pylint: disable=too-many-arguments,too-many-locals
nx_name: str = None, elem: ET.Element = None,
attr=False):
attr=False): # pylint: disable=unused-argument
"""Returns a list of ET.Element for the given path."""
# let us start with the given definition file
elist = [] # type: ignore[var-annotated]
Expand All @@ -687,6 +685,7 @@ def get_inherited_nodes(nxdl_path: str = None, # pylint: disable=too-many-argum
path = html_path
for pind in range(len(path)):
html_name = html_path[pind]
# pylint: disable=duplicate-code
elist, html_name = walk_elist(elist, html_name)
if elist:
class_path.append(get_nx_class(elist[0]))
Expand Down Expand Up @@ -717,4 +716,3 @@ def get_node_at_nxdl_path(nxdl_path: str = None,
raise NxdlAttributeError(f"Attributes were not found for {nxdl_path}. "
"Please check this entry in the template dictionary.")
return elem

0