forked from jaraco/pip-run
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread-deps.py
34 lines (27 loc) · 881 Bytes
/
read-deps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Emit parameters to pip extracted from a script.
"""
import pathlib
import autocommand
import path
from .scripts import DepsReader
def separator(input) -> str:
lookup = dict(space=' ', newline='\n', null='\0')
return lookup.get(input, input)
@autocommand.autocommand(__name__)
def run(
script: path.ExtantFile,
separator: separator = ' ', # type: ignore[valid-type]
):
"""
>>> run(['examples/test-mongodb-covered-query.py'])
pytest jaraco.mongodb>=3.10
>>> run(['does-not-exist'])
Traceback (most recent call last):
FileNotFoundError: does-not-exist does not exist as a file.
>>> run(['examples/test-mongodb-covered-query.py', '--separator', 'newline'])
pytest
jaraco.mongodb>=3.10
"""
joiner = separator.join # type: ignore[attr-defined]
print(joiner(DepsReader.try_read(pathlib.Path(script)).params()))