MCPcopy Index your code
hub / github.com/PyTables/PyTables / check_name_validity

Function check_name_validity

tables/path.py:119–155  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

117
118
119def 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
158def join_path(parentpath: str, name: str) -> str:

Callers 2

__init__Method · 0.85
_g_refnodeMethod · 0.85

Calls 1

check_attribute_nameFunction · 0.85

Tested by

no test coverage detected