Skip to content

Commit

Permalink
Add separator argument to read-deps. Fixes #53.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Oct 2, 2021
1 parent dd480c5 commit 0a89ee2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
v8.6.0
======

#53: ``read-deps`` script now accepts a ``--separator`` argument
accepting arbitrary separators or any of the named separators:

- newline
- space
- null

v8.5.1
======

Expand Down
15 changes: 13 additions & 2 deletions pip_run/read-deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@
from .scripts import DepsReader


def separator(input):
lookup = dict(space=' ', newline='\n', null='\0')
return lookup.get(input, input)


@autocommand.autocommand(__name__)
def run(script: path.ExtantFile):
def run(
script: path.ExtantFile,
separator: separator = ' ', # type: ignore
):
"""
>>> 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
"""
print(' '.join(DepsReader.try_read(script).params()))
print(separator.join(DepsReader.try_read(script).params())) # type: ignore

0 comments on commit 0a89ee2

Please sign in to comment.