Skip to content

Commit

Permalink
VisitingCode-1
Browse files Browse the repository at this point in the history
  • Loading branch information
RubelMozumder committed Oct 17, 2024
1 parent de56834 commit 9bcad38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/pynxtools/dataconverter/nexus_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,24 @@ class NexusNode(NodeMixin):
The inverse of the above `is_a`. In the example case
`DATA` `parent_of` `my_data`.
"""

# TODO rename type to nx_type in every place
name: str
type: Literal["group", "field", "attribute", "choice"]
optionality: Literal["required", "recommended", "optional"] = "required"
name_type: Literal["any", "partial"]
variadic: bool = False
inheritance: List[ET._Element]
is_a: List["NexusNode"]
parent_of: List["NexusNode"]
occurrence_limits: Tuple[
# TODO: Use Annotated[int, Field(strict=True, ge=0)] for py>3.8
Optional[int],
Optional[int],
] = (None, None)

def _set_optionality(self):
"""
Sets the optionality of the current node
Sets the optionality of the current node based on the inheritance chain.
if `recommended`, `required` or `optional` is set.
Also sets the field to optional if `maxOccurs == 0` or to required
if `maxOccurs > 0`.
Expand All @@ -179,6 +185,7 @@ def __init__(
type: Literal["group", "field", "attribute", "choice"],
optionality: Literal["required", "recommended", "optional"] = "required",
variadic: Optional[bool] = None,
name_type: Optional[Literal["any", "partial"]] = None,
parent: Optional["NexusNode"] = None,
inheritance: Optional[List[Any]] = None,
) -> None:
Expand All @@ -187,6 +194,7 @@ def __init__(
self.type = type
self.optionality = optionality
self.variadic = contains_uppercase(self.name)
self.name_type = name_type
if variadic is not None:
self.variadic = variadic
if inheritance is not None:
Expand Down
2 changes: 1 addition & 1 deletion src/pynxtools/dataconverter/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def validate_dict_against(
appdef (str): The appdef name to validate against.
mapping (Mapping[str, Any]):
The mapping containing the data to validate.
This should be a dict of `/` separated paths.
This should be a dict of `/` separated paths elements.
Attributes are denoted with `@` in front of the last element.
ignore_undocumented (bool, optional):
Ignore all undocumented keys in the verification
Expand Down

0 comments on commit 9bcad38

Please sign in to comment.