main: enable using files as input
This commit is contained in:
parent
368629caa5
commit
4f63fb9dfc
1 changed files with 5 additions and 0 deletions
|
|
@ -33,6 +33,7 @@ def main():
|
|||
valid_mock_inputs = list(filter(lambda x: x[0] != "_", dir(mock)))
|
||||
parser.add_argument("--mock-input", dest="mock_input", type=str, choices=valid_mock_inputs, default="legacy_mock",
|
||||
help="Specify mock input")
|
||||
parser.add_argument(dest="sources", metavar="SOURCE_FILES", help="Input files", type=Path, nargs="*")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
@ -43,6 +44,10 @@ def main():
|
|||
print("Source:\n", data)
|
||||
_input_stream = io.StringIO(data)
|
||||
|
||||
if len(args.sources):
|
||||
assert len(args.sources) == 1
|
||||
_input_stream = io.open(args.sources[0])
|
||||
|
||||
input_stream = TextIOWithMemory(_input_stream)
|
||||
|
||||
tokens = \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue