pypitoken-cli 1.0__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.
@@ -0,0 +1,33 @@
1
+ import sys
2
+ import argparse
3
+ import pypitoken
4
+
5
+
6
+ def run():
7
+ parser = argparse.ArgumentParser("pypitoken-cli", description="""
8
+ Tool for adding restrictions to PyPI tokens. The token is provided on standard input (only),
9
+ to ensure that it is not left in shell history.
10
+ """)
11
+ parser.add_argument(
12
+ "-p", "--project-name", dest="project_names", metavar="NAME", nargs="+", action="extend",
13
+ help="restrict to project(s) NAME only"
14
+ )
15
+ args = parser.parse_args()
16
+
17
+ print("Enter token: ", file=sys.stderr, end="")
18
+ raw_token = input()
19
+ try:
20
+ token = pypitoken.Token.load(raw_token)
21
+ except pypitoken.LoaderError as err:
22
+ print(f"Malformed token: {err}", file=sys.stderr)
23
+ sys.exit(1)
24
+
25
+ token = token.restrict(
26
+ project_names=args.project_names,
27
+ )
28
+
29
+ print("New restrictions:", file=sys.stderr)
30
+ for restriction in token.restrictions:
31
+ print(f" - {restriction}", file=sys.stderr)
32
+
33
+ print(token.dump())
@@ -0,0 +1,8 @@
1
+ Metadata-Version: 2.1
2
+ Name: pypitoken-cli
3
+ Version: 1.0
4
+ Author-Email: Catherine <whitequark@whitequark.org>
5
+ License: 0BSD
6
+ Requires-Python: <4,>=3.10
7
+ Requires-Dist: pypitoken~=7.1
8
+
@@ -0,0 +1,6 @@
1
+ pypitoken_cli-1.0.dist-info/METADATA,sha256=MhEHstzHZkmidaSdTaDof4zR9v97bJhJN8R9qwLanlU,179
2
+ pypitoken_cli-1.0.dist-info/WHEEL,sha256=Z36eTX6lG3PITRleSd5hAZHCcz52yg3c0JQVxKBbLW0,90
3
+ pypitoken_cli-1.0.dist-info/entry_points.txt,sha256=-kpqg9oYJuoJ8LfFjB8t3jS_T3K5kQQ0RNPdIB5Rxfw,68
4
+ pypitoken_cli-1.0.dist-info/licenses/LICENSE-0BSD.txt,sha256=ajj4VpBbV47qDl5tIlduTMQbeOVr-pnV1LN5UJdQj_I,662
5
+ pypitoken_cli/__init__.py,sha256=lwVRPn4ndxjUXq-rMFAlDce5acOy6qEyKkR4o9mnN58,992
6
+ pypitoken_cli-1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: pdm-backend (2.4.8)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,5 @@
1
+ [console_scripts]
2
+ pypitoken-cli = pypitoken_cli:run
3
+
4
+ [gui_scripts]
5
+
@@ -0,0 +1,13 @@
1
+ Copyright (C) Catherine <whitequark@whitequark.org>
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for
4
+ any purpose with or without fee is hereby granted.
5
+
6
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
7
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
8
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
9
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
10
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
11
+ AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
12
+ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
13
+