MCPcopy Index your code
hub / github.com/google/python-fire / _is_arg_name

Function _is_arg_name

fire/docstrings.py:302–319  ·  view source on GitHub ↗

Returns whether name is a valid arg name. This is used to prevent multiple words (plaintext) from being misinterpreted as an argument name. Any line that doesn't match the pattern for a valid argument is treated as not being an argument. Args: name: The name of the potential arg. Ret

(name)

Source from the content-addressed store, hash-verified

300
301
302def _is_arg_name(name):
303 """Returns whether name is a valid arg name.
304
305 This is used to prevent multiple words (plaintext) from being misinterpreted
306 as an argument name. Any line that doesn't match the pattern for a valid
307 argument is treated as not being an argument.
308
309 Args:
310 name: The name of the potential arg.
311 Returns:
312 True if name looks like an arg name, False otherwise.
313 """
314 name = name.strip()
315 # arg_pattern is a letter or underscore followed by
316 # zero or more letters, numbers, or underscores.
317 arg_pattern = r'^[a-zA-Z_]\w*$'
318 re.match(arg_pattern, name)
319 return re.match(arg_pattern, name) is not None
320
321
322def _as_arg_name_and_type(text):

Callers 4

_as_arg_name_and_typeFunction · 0.85
_as_arg_namesFunction · 0.85
_consume_lineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected