iripau 1.1.1__py3-none-any.whl → 1.1.2__py3-none-any.whl
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.
- iripau/executable.py +75 -7
- iripau/logging.py +2 -2
- iripau/subprocess.py +3 -3
- {iripau-1.1.1.dist-info → iripau-1.1.2.dist-info}/METADATA +1 -1
- iripau-1.1.2.dist-info/RECORD +14 -0
- iripau-1.1.1.dist-info/RECORD +0 -14
- {iripau-1.1.1.dist-info → iripau-1.1.2.dist-info}/WHEEL +0 -0
- {iripau-1.1.1.dist-info → iripau-1.1.2.dist-info}/licenses/LICENSE +0 -0
- {iripau-1.1.1.dist-info → iripau-1.1.2.dist-info}/top_level.txt +0 -0
iripau/executable.py
CHANGED
@@ -10,7 +10,11 @@ from iripau.command import host_run
|
|
10
10
|
|
11
11
|
|
12
12
|
class Command:
|
13
|
-
""" Run an executable command as a Python callable
|
13
|
+
""" Run an executable command as a Python callable
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
"""
|
14
18
|
|
15
19
|
def __init__(self, parent, command):
|
16
20
|
self._parent = parent
|
@@ -27,16 +31,63 @@ class Command:
|
|
27
31
|
|
28
32
|
|
29
33
|
def make_command(command):
|
34
|
+
""" Replace underscore with dash.
|
35
|
+
|
36
|
+
Suitable for a CLI that uses dashes as word-separator in their
|
37
|
+
positional arguments.
|
38
|
+
|
39
|
+
Args:
|
40
|
+
command (str): Python identifier referring to a CLI command or
|
41
|
+
sub-command.
|
42
|
+
|
43
|
+
Returns:
|
44
|
+
str: Final token to be used as a CLI positional argument.
|
45
|
+
"""
|
30
46
|
return command.replace("_", "-")
|
31
47
|
|
32
48
|
|
33
49
|
def make_option(option):
|
50
|
+
""" Replace underscore with dash and prepend two more dashes.
|
51
|
+
|
52
|
+
Suitable for a CLI that uses dashes as word-separator in their
|
53
|
+
positional arguments.
|
54
|
+
|
55
|
+
Args:
|
56
|
+
option (str): Python identifier referring to a CLI optional
|
57
|
+
argument.
|
58
|
+
|
59
|
+
Returns:
|
60
|
+
Tuple[str]: The tokens that could be used as a CLI positional argument.
|
61
|
+
"""
|
34
62
|
return "--" + option.replace("_", "-"),
|
35
63
|
|
36
64
|
|
37
65
|
class Executable:
|
38
|
-
""" Run an executable as a Python callable
|
39
|
-
|
66
|
+
""" Run an executable as a Python callable.
|
67
|
+
|
68
|
+
Args:
|
69
|
+
executable (str): Path to an executable file or just the name if it
|
70
|
+
exists in the ``PATH``.
|
71
|
+
make_command (Callable[[str], str]): Function to convert a Python
|
72
|
+
identifier to the corresponding command positional argument for
|
73
|
+
the CLI.
|
74
|
+
make_option (Callable[str], Tuple[str]): Function to convert a Python
|
75
|
+
identifier into the corresponding optional argument for the CLI.
|
76
|
+
randomly, and
|
77
|
+
alias (str, list(str)): Alias for ``executable``. See ``alias`` in
|
78
|
+
`iripau.subprocess.Popen`_.
|
79
|
+
run_args_prefix (str): When calling an instance of this class, all
|
80
|
+
of the ``**kwargs`` starting with this prefix will be passed to
|
81
|
+
the ``run_function`` after removing the prefix.
|
82
|
+
run_function (Callable[List[str] *Any], subprocess.CompletedProcess):
|
83
|
+
The function that will actually run the process, wait for it and
|
84
|
+
return a ``CompletedProcess``.
|
85
|
+
|
86
|
+
If ``None``, the default function is `iripau.command.host_run`_.
|
87
|
+
**kwargs: Keyword arguments to be passed to ``run_function`` every
|
88
|
+
time an instance of this object is called.
|
89
|
+
The ``run_args_prefix`` is not needed here.
|
90
|
+
"""
|
40
91
|
def __init__(
|
41
92
|
self, executable, make_command=make_command, make_option=make_option,
|
42
93
|
alias=None, run_args_prefix="_", run_function=None, **kwargs
|
@@ -84,10 +135,27 @@ class Executable:
|
|
84
135
|
return hasattr(value, "__iter__")
|
85
136
|
|
86
137
|
@classmethod
|
87
|
-
def _make_arg(cls, options, value
|
88
|
-
""" Return a list of tokens.
|
89
|
-
|
90
|
-
|
138
|
+
def _make_arg(cls, options, value):
|
139
|
+
""" Return a list of tokens.
|
140
|
+
|
141
|
+
Args:
|
142
|
+
options (Tuple[str]): One of this strings will be randomly chosen.
|
143
|
+
|
144
|
+
If the chosen option starts with ``--``, there will be a
|
145
|
+
single token with the option and the value: ``["--option=value"]``
|
146
|
+
|
147
|
+
If not, there will be two tokens: ``["-o", "value"]``.
|
148
|
+
value: The value of the optional argument for the CLI.
|
149
|
+
|
150
|
+
If ``True``, the option will be treated as a flag, with no
|
151
|
+
value: ``["--option"]``.
|
152
|
+
|
153
|
+
If ``False`` or ``None``, the option will be ignored: ``[]``.
|
154
|
+
|
155
|
+
If an iterable and not a string, the option will be repeated
|
156
|
+
for each item: ``["--option=value1", "--option=value2"]
|
157
|
+
|
158
|
+
Otherwise, it will be converted to a string before using it.
|
91
159
|
"""
|
92
160
|
if cls._is_iterable(value):
|
93
161
|
return chain.from_iterable(
|
iripau/logging.py
CHANGED
@@ -50,8 +50,8 @@ class LoggerFile:
|
|
50
50
|
|
51
51
|
|
52
52
|
class SimpleThreadNameFormatter(logging.Formatter):
|
53
|
-
""" The same logging.Formatter but threadName is just the first token
|
54
|
-
splitting it: record.threadName.split(maxsplit=1)[0]
|
53
|
+
""" The same ``logging.Formatter`` but threadName is just the first token
|
54
|
+
after splitting it: ``record.threadName.split(maxsplit=1)[0]``.
|
55
55
|
"""
|
56
56
|
|
57
57
|
def format(self, record):
|
iripau/subprocess.py
CHANGED
@@ -459,17 +459,17 @@ def set_global_echo(value):
|
|
459
459
|
|
460
460
|
def set_global_stdout_files(*files: TeeStream):
|
461
461
|
global GLOBAL_STDOUTS
|
462
|
-
GLOBAL_STDOUTS = set(
|
462
|
+
GLOBAL_STDOUTS = set(files)
|
463
463
|
|
464
464
|
|
465
465
|
def set_global_stderr_files(*files: TeeStream):
|
466
466
|
global GLOBAL_STDERRS
|
467
|
-
GLOBAL_STDERRS = set(
|
467
|
+
GLOBAL_STDERRS = set(files)
|
468
468
|
|
469
469
|
|
470
470
|
def set_global_prompt_files(*files: TeeStream):
|
471
471
|
global GLOBAL_PROMPTS
|
472
|
-
GLOBAL_PROMPTS = set(
|
472
|
+
GLOBAL_PROMPTS = set(files)
|
473
473
|
|
474
474
|
|
475
475
|
def _output_context(kwargs, key, encoding, errors, text):
|
@@ -0,0 +1,14 @@
|
|
1
|
+
iripau/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
iripau/executable.py,sha256=aJ1adOGbviQa5IJvLvwlUtK7a9V_k8iDhDLvI29W3mI,5889
|
3
|
+
iripau/functools.py,sha256=Jyi0LdOx36Ih6s9TF4aFS3Xk-RW78YE2znB1PBWTAIo,2901
|
4
|
+
iripau/logging.py,sha256=SFKHDspnfNL4qEIpZ_3LMXjbjAqdf5o_4lnk8L9Beg8,2551
|
5
|
+
iripau/random.py,sha256=zC5GxmBdfVa6nAUZcv5gCLwBpZU3sA1TB71Cn311lHo,1023
|
6
|
+
iripau/requests.py,sha256=MIf1I7jhHk3-8R36VpRSng8aoefdsSTHHW11HApmoDw,3108
|
7
|
+
iripau/shutil.py,sha256=HwU4sUrStzAZjqbIMK7xm-NfjxMXHZx4lWAjwfBf4rw,2558
|
8
|
+
iripau/subprocess.py,sha256=AafUuFNZ8i5Y1PxAIqbYTit5sVwz2t4enSRxYmMtrz4,17681
|
9
|
+
iripau/threading.py,sha256=q-a6OuDrz3hg_5u2Q0eMG3hzu_IgGNBfEw-cI_pyaDo,8955
|
10
|
+
iripau-1.1.2.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
|
11
|
+
iripau-1.1.2.dist-info/METADATA,sha256=J0or7nlpcPnXt487qp0oiYKZVimRkUhLgmIft01fhBM,810
|
12
|
+
iripau-1.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
13
|
+
iripau-1.1.2.dist-info/top_level.txt,sha256=y2HMFLCoP2EP7kbRIqkyCVIf_YRZfA0cYYLNK28U9cY,7
|
14
|
+
iripau-1.1.2.dist-info/RECORD,,
|
iripau-1.1.1.dist-info/RECORD
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
iripau/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
iripau/executable.py,sha256=W00UNJfMWwZ7cZkEvppwVWy8GaGfbr36eRx0BwaI6mA,3109
|
3
|
-
iripau/functools.py,sha256=Jyi0LdOx36Ih6s9TF4aFS3Xk-RW78YE2znB1PBWTAIo,2901
|
4
|
-
iripau/logging.py,sha256=dA-69y5MN8a_c95e_DOlULO0tc7t267okFi9iqJzrmg,2542
|
5
|
-
iripau/random.py,sha256=zC5GxmBdfVa6nAUZcv5gCLwBpZU3sA1TB71Cn311lHo,1023
|
6
|
-
iripau/requests.py,sha256=MIf1I7jhHk3-8R36VpRSng8aoefdsSTHHW11HApmoDw,3108
|
7
|
-
iripau/shutil.py,sha256=HwU4sUrStzAZjqbIMK7xm-NfjxMXHZx4lWAjwfBf4rw,2558
|
8
|
-
iripau/subprocess.py,sha256=mQDLrBgTOEJ_Ueb1nqIbRkrzMlnYWjfXS8kJsspMcsE,17684
|
9
|
-
iripau/threading.py,sha256=q-a6OuDrz3hg_5u2Q0eMG3hzu_IgGNBfEw-cI_pyaDo,8955
|
10
|
-
iripau-1.1.1.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
|
11
|
-
iripau-1.1.1.dist-info/METADATA,sha256=7IUERIMs_JNTZKxzuNBLgjqOB_68Pp_gIwoH7Zn4rMI,810
|
12
|
-
iripau-1.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
13
|
-
iripau-1.1.1.dist-info/top_level.txt,sha256=y2HMFLCoP2EP7kbRIqkyCVIf_YRZfA0cYYLNK28U9cY,7
|
14
|
-
iripau-1.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|