Skip to content

Commit ea7a4bb

Browse files
authored
Merge pull request #466 from python-cmd2/delete_cmdresult
Deleted the CmdResult helper class
2 parents e10afbe + 3225099 commit ea7a4bb

File tree

5 files changed

+15
-40
lines changed

5 files changed

+15
-40
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ install:
44
build: off
55

66
test_script:
7-
- python -m tox -e py35-win,py36-win
7+
- python -m tox -e py35-win,py36-win,py37-win

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
* Bug Fixes
33
* Fixed bug when StatementParser ``__init__()`` was called with ``terminators`` equal to ``None``
44
* Fixed bug when ``Cmd.onecmd()`` was called with a raw ``str``
5+
* Deletions
6+
* The ``CmdResult`` helper class which was *deprecated* in the previous release has now been deleted
7+
* It has been replaced by the improved ``CommandResult`` class
58

69
## 0.9.2 (June 28, 2018)
710
* Bug Fixes

cmd2/cmd2.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,25 +3220,3 @@ def restore(self) -> None:
32203220
if self.obj:
32213221
for attrib in self.attribs:
32223222
setattr(self.obj, attrib, getattr(self, attrib))
3223-
3224-
3225-
class CmdResult(utils.namedtuple_with_two_defaults('CmdResult', ['out', 'err', 'war'])):
3226-
"""DEPRECATED: Derive a class to store results from a named tuple so we can tweak dunder methods for convenience.
3227-
3228-
This is provided as a convenience and an example for one possible way for end users to store results in
3229-
the self._last_result attribute of cmd2.Cmd class instances. See the "python_scripting.py" example for how it can
3230-
be used to enable conditional control flow.
3231-
3232-
Named tuple attributes
3233-
----------------------
3234-
out - this is intended to store normal output data from the command and can be of any type that makes sense
3235-
err: str - (optional) this is intended to store an error message and it being non-empty indicates there was an error
3236-
Defaults to an empty string
3237-
war: str - (optional) this is intended to store a warning message which isn't quite an error, but of note
3238-
Defaults to an empty string.
3239-
3240-
NOTE: Named tuples are immutable. So the contents are there for access, not for modification.
3241-
"""
3242-
def __bool__(self) -> bool:
3243-
"""If err is an empty string, treat the result as a success; otherwise treat it as a failure."""
3244-
return not self.err

cmd2/utils.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,6 @@ def namedtuple_with_defaults(typename: str, field_names: Union[str, List[str]],
6161
return T
6262

6363

64-
def namedtuple_with_two_defaults(typename: str, field_names: Union[str, List[str]],
65-
default_values: collections.Iterable=('', '')):
66-
"""Wrapper around namedtuple which lets you treat the last value as optional.
67-
68-
:param typename: str - type name for the Named tuple
69-
:param field_names: List[str] or space-separated string of field names
70-
:param default_values: (optional) 2-element tuple containing the default values for last 2 parameters in named tuple
71-
Defaults to an empty string for both of them
72-
:return: namedtuple type
73-
"""
74-
T = collections.namedtuple(typename, field_names)
75-
# noinspection PyUnresolvedReferences
76-
T.__new__.__defaults__ = default_values
77-
return T
78-
79-
8064
def cast(current: Any, new: str) -> Any:
8165
"""Tries to force a new value into the same type as the current when trying to set the value for a parameter.
8266

tox.ini

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py34,py35,py36,py37,py35-win,py36-win
2+
envlist = py34,py35,py36,py37,py35-win,py36-win,py37-win
33

44
[pytest]
55
testpaths = tests
@@ -73,3 +73,13 @@ deps =
7373
wcwidth
7474
commands = py.test -v
7575

76+
[testenv:py37-win]
77+
deps =
78+
codecov
79+
pyperclip
80+
pyreadline
81+
pytest
82+
pytest-cov
83+
commands =
84+
py.test {posargs} --cov
85+
codecov

0 commit comments

Comments
 (0)