Skip to content

Commit 18a4586

Browse files
committed
Initial Commit
0 parents  commit 18a4586

File tree

11 files changed

+1168
-0
lines changed

11 files changed

+1168
-0
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/linters.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: linters
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
paths:
9+
- 'exitcode'
10+
- 'poetry.lock'
11+
- '.github/**'
12+
- 'tests/**'
13+
14+
jobs:
15+
linters:
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ['3.10', '3.11']
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v3
25+
- uses: actions/setup-python@v4
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
- uses: Gr1N/setup-poetry@v8
29+
- uses: actions/cache@v3
30+
with:
31+
path: ~/.cache/pypoetry/virtualenvs
32+
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
33+
34+
- name: Install Dependencies
35+
run: |
36+
poetry install
37+
- name: Run ruff
38+
run: |
39+
poetry run ruff check exitcode
40+
- name: Run mypy
41+
run: |
42+
poetry run mypy exitcode
43+
- name: Run black
44+
run: |
45+
poetry run black --check --verbose exitcode
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Upload Python Package
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
deploy:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.10'
20+
- uses: Gr1N/setup-poetry@v8
21+
- uses: actions/cache@v3
22+
with:
23+
path: ~/.cache/pypoetry/virtualenvs
24+
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
25+
26+
- name: Install Dependencies
27+
run: |
28+
poetry install
29+
- name: Build package
30+
run: |
31+
poetry build
32+
- name: Publish a Python distribution to PyPI
33+
uses: pypa/gh-action-pypi-publish@release/v1
34+
with:
35+
user: __token__
36+
password: ${{ secrets.PYPI_API_TOKEN }}

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) Stefan Tatschner <stefan@rumpelsepp.org>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# exitcode
2+
3+
Preferred system exit codes as defined by [`sysexits.h`](https://man.openbsd.org/sysexits).
4+
This library is inspired by this [rust library](https://docs.rs/exitcode).
5+
6+
## Example
7+
8+
All constants from the manpage [sysexits(3)](https://man.openbsd.org/sysexits) are available without the `EX_` prefix.
9+
10+
``` python
11+
import exitcode
12+
import sys
13+
14+
sys.exit(exitcode.OK)
15+
```

exitcode/__init__.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# SPDX-FileCopyrightText: Stefan Tatschner
2+
#
3+
# SPDX-License-Identifier: MIT
4+
#
5+
# Preferred system exit codes as defined by sysexits.h
6+
#
7+
# Exit code constants intended to be passed to `sys.exit()`;
8+
# inspired by https://docs.rs/exitcode.
9+
10+
# Successful exit
11+
OK = 0
12+
13+
# The command was used incorrectly, e.g., with the
14+
# wrong number of arguments, a bad flag, a bad syntax
15+
# in a parameter, etc.
16+
USAGE = 64
17+
18+
# The input data was incorrect in some way. This
19+
# should only be used for user's data and not system
20+
# files.
21+
DATAERR = 65
22+
23+
# An input file (not a system file) did not exist or
24+
# was not readable. This could also include errors
25+
# like "No message" to a mailer (if it cared to
26+
# catch it).
27+
NOINPUT = 66
28+
29+
# The user specified did not exist. This might be
30+
# used for mail addresses or remote logins.
31+
NOUSER = 67
32+
33+
# The host specified did not exist. This is used in
34+
# mail addresses or network requests.
35+
NOHOST = 68
36+
37+
# A service is unavailable. This can occur if a
38+
# support program or file does not exist. This can also
39+
# be used as a catchall message when something you
40+
# wanted to do doesn't work, but you don't know why.
41+
UNAVAILABLE = 69
42+
43+
# An internal software error has been detected. This
44+
# should be limited to non-operating system related
45+
# errors as possible.
46+
SOFTWARE = 70
47+
48+
# An operating system error has been detected. This
49+
# is intended to be used for such things as "cannot
50+
# fork", "cannot create pipe", or the like. It
51+
# includes things like getuid returning a user that
52+
# does not exist in the passwd file.
53+
OSERR = 71
54+
55+
# Some system file (e.g., /etc/passwd, /var/run/utmp,
56+
# etc.) does not exist, cannot be opened, or has some
57+
# sort of error (e.g., syntax error).
58+
OSFILE = 72
59+
60+
# A (user specified) output file cannot be created.
61+
CANTCREAT = 73
62+
63+
# An error occurred while doing I/O on some file.
64+
IOERR = 74
65+
66+
# Temporary failure, indicating something that is not
67+
# really an error. In sendmail, this means that a
68+
# mailer (e.g.) could not create a connection, and
69+
# the request should be reattempted later.
70+
TEMPFAIL = 75
71+
72+
# The remote system returned something that was
73+
# "not possible" during a protocol exchange.
74+
PROTOCOL = 76
75+
76+
# You did not have sufficient permission to perform
77+
# the operation. This is not intended for file system
78+
# problems, which should use `NOINPUT` or `CANTCREAT`,
79+
# but rather for higher level permissions.
80+
NOPERM = 77
81+
82+
# Something was found in an unconfigured or misconfigured state.
83+
CONFIG = 78

exitcode/py.typed

Whitespace-only changes.

flake.lock

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-FileCopyrightText: AISEC Pentesting Team
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
{
6+
inputs = {
7+
nixpkgs.url = "github:nixos/nixpkgs";
8+
};
9+
10+
outputs = { self, nixpkgs }:
11+
with import nixpkgs { system = "x86_64-linux"; };
12+
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
13+
in {
14+
devShell.x86_64-linux = pkgs.mkShell {
15+
buildInputs = with pkgs; [
16+
poetry
17+
python310
18+
python311
19+
];
20+
shellHook = ''
21+
LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [stdenv.cc.cc]}
22+
'';
23+
};
24+
formatter.x86_64-linux = pkgs.nixpkgs-fmt;
25+
};
26+
}

0 commit comments

Comments
 (0)