shelltastic 0.8.0__tar.gz → 0.8.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {shelltastic-0.8.0 → shelltastic-0.8.1}/PKG-INFO +1 -1
  2. {shelltastic-0.8.0 → shelltastic-0.8.1}/pyproject.toml +1 -1
  3. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/backend/__init__.py +2 -0
  4. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/backend/base.py +18 -2
  5. {shelltastic-0.8.0 → shelltastic-0.8.1}/LICENSE +0 -0
  6. {shelltastic-0.8.0 → shelltastic-0.8.1}/README.md +0 -0
  7. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/__init__.py +0 -0
  8. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/backend/default/__init__.py +0 -0
  9. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/backend/default/common.py +0 -0
  10. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/backend/default/local.py +0 -0
  11. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/backend/default/remote.py +0 -0
  12. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/display.py +0 -0
  13. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/enum.py +0 -0
  14. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/exception.py +0 -0
  15. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/frontend/__init__.py +0 -0
  16. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/frontend/common.py +0 -0
  17. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/frontend/git.py +0 -0
  18. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/frontend/scp.py +0 -0
  19. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/frontend/shell.py +0 -0
  20. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/host.py +0 -0
  21. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/io.py +0 -0
  22. {shelltastic-0.8.0 → shelltastic-0.8.1}/src/shelltastic/result.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shelltastic
3
- Version: 0.8.0
3
+ Version: 0.8.1
4
4
  Summary: A fantastic shell command runner for python
5
5
  Author: Bearmine
6
6
  License-Expression: MPL-2.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "shelltastic"
3
- version = "0.8.0"
3
+ version = "0.8.1"
4
4
  description = "A fantastic shell command runner for python"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -4,6 +4,7 @@ from shelltastic.backend.base import (
4
4
  RemoteShellBackend,
5
5
  ShellBackend,
6
6
  add_shim,
7
+ clear_shims,
7
8
  )
8
9
  from shelltastic.backend.default.local import DefaultLocalBackend
9
10
  from shelltastic.backend.default.remote import DefaultRemoteBackend
@@ -17,6 +18,7 @@ __all__ = [
17
18
  "register_default_local_backend",
18
19
  "register_default_remote_backend",
19
20
  "add_shim",
21
+ "clear_shims",
20
22
  "get_local_backend",
21
23
  "get_remote_backend",
22
24
  ]
@@ -90,6 +90,10 @@ class BackendShim(ABC):
90
90
 
91
91
  _backend_shims: list[BackendShim] = []
92
92
 
93
+ def clear_shims():
94
+ """Clear all shims"""
95
+ global _backend_shims
96
+ _backend_shims.clear()
93
97
 
94
98
  def add_shim(shim: BackendShim):
95
99
  """Add a shim to manipulate `ShellBackend` params before any `ShellBackend` runs"""
@@ -103,7 +107,19 @@ def _shim_run(f, backend_type: type):
103
107
  result: BackendShimResult = BackendShimResult(*args, **kwargs)
104
108
  for shim in _backend_shims:
105
109
  result = shim.run_shim(
106
- backend_type, f.__name__, *result.args, **result.kwargs
110
+ backend_type, *result.args, **result.kwargs
111
+ )
112
+ return f(*result.args, **result.kwargs)
113
+
114
+ return wrapper
115
+
116
+ def _shim_run_async(f, backend_type: type):
117
+ @wraps(f)
118
+ def wrapper(*args, **kwargs):
119
+ result: BackendShimResult = BackendShimResult(*args, **kwargs)
120
+ for shim in _backend_shims:
121
+ result = shim.run_async_shim(
122
+ backend_type, *result.args, **result.kwargs
107
123
  )
108
124
  return f(*result.args, **result.kwargs)
109
125
 
@@ -114,7 +130,7 @@ class _InstallShims(ABCMeta):
114
130
  def __call__(self, *args: Any, **kwds: Any) -> Any:
115
131
  instance = super().__call__(*args, **kwds)
116
132
  instance.run = _shim_run(instance.run, instance.__class__)
117
- instance.run_async = _shim_run(instance.run_async, instance.__class__)
133
+ instance.run_async = _shim_run_async(instance.run_async, instance.__class__)
118
134
  return instance
119
135
 
120
136
 
File without changes
File without changes