Add argument read_files so that arg may be a filepath.
This commit is contained in:
parent
1cf2209910
commit
10a447cd07
1 changed files with 12 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
# import pyperclip moved to stay lazy.
|
# import pyperclip moved to stay lazy.
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
builtin_input = input
|
builtin_input = input
|
||||||
|
@ -49,7 +50,14 @@ def multi_line_input(prompt=None):
|
||||||
if has_eof:
|
if has_eof:
|
||||||
break
|
break
|
||||||
|
|
||||||
def input(arg=None, *, input_prompt=None, skip_blank=False, strip=False):
|
def input(
|
||||||
|
arg=None,
|
||||||
|
*,
|
||||||
|
input_prompt=None,
|
||||||
|
read_files=False,
|
||||||
|
skip_blank=False,
|
||||||
|
strip=False,
|
||||||
|
):
|
||||||
if arg is not None:
|
if arg is not None:
|
||||||
arg_lower = arg.lower()
|
arg_lower = arg.lower()
|
||||||
|
|
||||||
|
@ -72,6 +80,9 @@ def input(arg=None, *, input_prompt=None, skip_blank=False, strip=False):
|
||||||
import pyperclip
|
import pyperclip
|
||||||
lines = pyperclip.paste().splitlines()
|
lines = pyperclip.paste().splitlines()
|
||||||
|
|
||||||
|
elif read_files and os.path.isfile(arg):
|
||||||
|
lines = open(arg, 'r', encoding='utf-8')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
lines = arg.splitlines()
|
lines = arg.splitlines()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue