Inspired by programs that return 1 on success, exesexe lets you wrap a call
to an executable and selectively override its return codes. This allows you,
for example, to use an aberrant installer with configuration management
software that expects programs to return 0 when successful.
exesexe will use the first argument it receives as its own directive, but all
other arguments will be executed without modification. The directive is a
comma-separated list, where each segment may have one of these forms:
```
1 whitelist 1 (convert to 0)
-1=2 substitute -1 with 2
5:8=9 substitute 5, 6, 7, and 8 with 9
!1 blacklist 1 (don't convert 1 at all; convert everything else to 0)
*=3 substitute all others with 3
```
Examples:
* `1,-1,2=3`
* Convert 1 and -1 to 0.
* Convert 2 to 3.
* `!2`
* Don't convert 2.
* Convert everything else to 0.
* `!-4=2`
* Don't convert -4.
* Convert everything else to 2.
* `*=10`
* Return 10 no matter what.
The precedence order is whitelists, specific substitutions, blacklists,
then *-substitutions, so `*=4,1=2,!3` would convert 1 to 2 rather than 4 or 0.
The lexical order only matters for overlapping segments, like `1=0,1=2`,
where the rightmost segment overrides the left segments.
Suppose you want to run the executable `foo`. You could issue any of these:
```
exesexe 1 foo # return 0 if foo returns 1
exesexe 3=4 foo # return 4 if foo returns 3
exesexe *=0 foo # always return 0
exesexe !2 foo # return 0 if foo does not return 2
exesexe !2,3=4 foo # if foo returns 3, return 4;
# else, if foo does not return 2, return 0;
# else, pass back foo's real return code
```
You can also use exesexe as a library:
```python
import exesexe
whitelist, blacklist, substitutions = exesexe.parse_directive("1,!2,3=4")
exesexe.interpret(
"foo --bar",
whitelist=[1],
blacklist=[2],
substitutions={3: 4, "*": 1}
)
```
to an executable and selectively override its return codes. This allows you,
for example, to use an aberrant installer with configuration management
software that expects programs to return 0 when successful.
exesexe will use the first argument it receives as its own directive, but all
other arguments will be executed without modification. The directive is a
comma-separated list, where each segment may have one of these forms:
```
1 whitelist 1 (convert to 0)
-1=2 substitute -1 with 2
5:8=9 substitute 5, 6, 7, and 8 with 9
!1 blacklist 1 (don't convert 1 at all; convert everything else to 0)
*=3 substitute all others with 3
```
Examples:
* `1,-1,2=3`
* Convert 1 and -1 to 0.
* Convert 2 to 3.
* `!2`
* Don't convert 2.
* Convert everything else to 0.
* `!-4=2`
* Don't convert -4.
* Convert everything else to 2.
* `*=10`
* Return 10 no matter what.
The precedence order is whitelists, specific substitutions, blacklists,
then *-substitutions, so `*=4,1=2,!3` would convert 1 to 2 rather than 4 or 0.
The lexical order only matters for overlapping segments, like `1=0,1=2`,
where the rightmost segment overrides the left segments.
Suppose you want to run the executable `foo`. You could issue any of these:
```
exesexe 1 foo # return 0 if foo returns 1
exesexe 3=4 foo # return 4 if foo returns 3
exesexe *=0 foo # always return 0
exesexe !2 foo # return 0 if foo does not return 2
exesexe !2,3=4 foo # if foo returns 3, return 4;
# else, if foo does not return 2, return 0;
# else, pass back foo's real return code
```
You can also use exesexe as a library:
```python
import exesexe
whitelist, blacklist, substitutions = exesexe.parse_directive("1,!2,3=4")
exesexe.interpret(
"foo --bar",
whitelist=[1],
blacklist=[2],
substitutions={3: 4, "*": 1}
)
```
Metadata
Release files for exesexe 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| exesexe-1.0.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Release files / exesexe-1.0.1-py2.py3-none-any.whl
| Download URL | exesexe-1.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
32760a70e8a13d316df9587f765d6fa3c36a01f6c66c999a181fb3412183be7b
|
|
BLAKE2b-256 checksum How to use checksums |
8a1ea590983ead1be6de845007d0fee45acd2423daa5d411c60a335eb68da5b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for exesexe 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.