diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-07-12 20:37:50 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-07-12 20:37:50 -0400 |
commit | 670f0eb7707b8a7e1e7368346c927244ead46b8b (patch) | |
tree | 80f49c8e379327a1aa9b3d5489c0e9759bf0f95b /cmd2/utils.py | |
parent | 9fc9d196b73838842fb2e3e7d9c84d17e1c7fdec (diff) | |
parent | 625aea03324119b0ed7c2e84afd5575ffc8fa72a (diff) | |
download | cmd2-git-670f0eb7707b8a7e1e7368346c927244ead46b8b.tar.gz |
Resolved merge conflict from merging master into plugin_functions
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r-- | cmd2/utils.py | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py index 11d48b78..d03e7f6f 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -61,22 +61,6 @@ def namedtuple_with_defaults(typename: str, field_names: Union[str, List[str]], return T -def namedtuple_with_two_defaults(typename: str, field_names: Union[str, List[str]], - default_values: collections.Iterable=('', '')): - """Wrapper around namedtuple which lets you treat the last value as optional. - - :param typename: str - type name for the Named tuple - :param field_names: List[str] or space-separated string of field names - :param default_values: (optional) 2-element tuple containing the default values for last 2 parameters in named tuple - Defaults to an empty string for both of them - :return: namedtuple type - """ - T = collections.namedtuple(typename, field_names) - # noinspection PyUnresolvedReferences - T.__new__.__defaults__ = default_values - return T - - def cast(current: Any, new: str) -> Any: """Tries to force a new value into the same type as the current when trying to set the value for a parameter. @@ -143,7 +127,7 @@ def is_text_file(file_path: str) -> bool: # noinspection PyUnusedLocal if sum(1 for line in f) > 0: valid_text_file = True - except IOError: # pragma: no cover + except OSError: # pragma: no cover pass except UnicodeDecodeError: # The file is not ASCII. Check if it is UTF-8. @@ -153,7 +137,7 @@ def is_text_file(file_path: str) -> bool: # noinspection PyUnusedLocal if sum(1 for line in f) > 0: valid_text_file = True - except IOError: # pragma: no cover + except OSError: # pragma: no cover pass except UnicodeDecodeError: # Not UTF-8 |