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)
| 300 | |
| 301 | |
| 302 | def _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 | |
| 322 | def _as_arg_name_and_type(text): |
no outgoing calls
no test coverage detected