Check the validity of the `name` of a Node object. Validity of Node names is more limited than attribute names. If the name is not valid, a ``ValueError`` is raised. If it is valid but it can not be used with natural naming, a `NaturalNameWarning` is issued. >>> warnings.simp
(name: str)
| 117 | |
| 118 | |
| 119 | def check_name_validity(name: str) -> None: |
| 120 | """Check the validity of the `name` of a Node object. |
| 121 | |
| 122 | Validity of Node names is more limited than attribute names. |
| 123 | |
| 124 | If the name is not valid, a ``ValueError`` is raised. If it is |
| 125 | valid but it can not be used with natural naming, a |
| 126 | `NaturalNameWarning` is issued. |
| 127 | |
| 128 | >>> warnings.simplefilter("ignore") |
| 129 | >>> check_name_validity('a') |
| 130 | >>> check_name_validity('a_b') |
| 131 | >>> check_name_validity('a:b') # NaturalNameWarning |
| 132 | >>> check_name_validity('/a/b') |
| 133 | Traceback (most recent call last): |
| 134 | ... |
| 135 | ValueError: the ``/`` character is not allowed in object names: '/a/b' |
| 136 | >>> check_name_validity('.') |
| 137 | Traceback (most recent call last): |
| 138 | ... |
| 139 | ValueError: ``.`` is not allowed as an object name |
| 140 | >>> check_name_validity('') |
| 141 | Traceback (most recent call last): |
| 142 | ... |
| 143 | ValueError: the empty string is not allowed as an object name |
| 144 | |
| 145 | """ |
| 146 | check_attribute_name(name) |
| 147 | |
| 148 | # Check whether `name` is a valid HDF5 name. |
| 149 | # http://hdfgroup.org/HDF5/doc/UG/03_Model.html#Structure |
| 150 | if name == ".": |
| 151 | raise ValueError("``.`` is not allowed as an object name") |
| 152 | elif "/" in name: |
| 153 | raise ValueError( |
| 154 | "the ``/`` character is not allowed " "in object names: %r" % name |
| 155 | ) |
| 156 | |
| 157 | |
| 158 | def join_path(parentpath: str, name: str) -> str: |
no test coverage detected