Skip to content

Commit

Permalink
Fix some bug with wrong naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
feluxe committed Oct 12, 2017
1 parent 811834a commit dc6c12f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CONFIG.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"public_name": "cmdinter"
"interal_name": "cmdinter"
"version": "1.0.2"
"version": "1.0.4"
"license": "unlicensed"
"author": "Felix Meyer-Wolters"
"author_email": "felix@meyerwolters.de"
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Description

This is a library that can be used to apply a *command interface* to functions.
It's main purpose is to apply the *return_code* convention to python functions
It's main purpose is to apply the *returncode* convention to python functions
and to give you some control on how to run these functions. E.g. if you need to
run a function silently (no stdout), if you need to return the stdout that a
function produces or if you need to prevent a function from throwing errors.
Expand Down Expand Up @@ -33,9 +33,9 @@ E.g.:
[Skip] Mount hard drive. Drive alrady mounted.
```

`return_code` Unix return_code convention...
`returncode` Unix returncode convention...

`return_val` The value the function returns. That would be what you usually
`returnvalue` The value the function returns. That would be what you usually
return via the `return` keyword.

### Status
Expand Down Expand Up @@ -101,8 +101,8 @@ object.

```python
class CmdResult(NamedTuple):
return_val: Any
return_code: int
returnvalue: Any
returncode: int
return_msg: str
output: Optional[str]
error: Optional[str]
Expand Down
12 changes: 6 additions & 6 deletions cmdinter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def _silent_call(
kwargs: dict = kwargs if kwargs else {}

with redirect_stdout(open(os.devnull, 'w')):
return_val = func(*args, **kwargs)
returnvalue = func(*args, **kwargs)

return return_val
return returnvalue


def _catch_func_output(
Expand All @@ -68,11 +68,11 @@ def _catch_func_output(
streams.append(sys.stdout)

with redirect_stdout(_get_multi_writer(streams)):
func_return_val: Any = func(*args, **kwargs)
func_returnvalue: Any = func(*args, **kwargs)

output: Optional[str] = streams[0].getvalue()

return func_return_val, output
return func_returnvalue, output


def _handle_cmd_function(
Expand Down Expand Up @@ -132,8 +132,8 @@ def _handle_cmd_function(
raise e

return CmdResult(
returnvalue=func_result and getattr(func_result, 'return_val'),
returncode=func_result and getattr(func_result, 'return_code'),
returnvalue=func_result and getattr(func_result, 'returnvalue'),
returncode=func_result and getattr(func_result, 'returncode'),
summary=func_result and getattr(func_result, 'return_msg'),
stdout=output,
stderr=error,
Expand Down

0 comments on commit dc6c12f

Please sign in to comment.