Replace clipext.resolve with pipeable.input(split_lines=False).
This commit is contained in:
parent
f2003beabf
commit
02518a96a3
5 changed files with 11 additions and 19 deletions
2
cup.py
2
cup.py
|
@ -2,5 +2,5 @@ import pyperclip
|
||||||
|
|
||||||
from voussoirkit import pipeable
|
from voussoirkit import pipeable
|
||||||
|
|
||||||
text = '\n'.join(pipeable.input('!i'))
|
text = pipeable.input('!i', split_lines=False)
|
||||||
pyperclip.copy(text)
|
pyperclip.copy(text)
|
||||||
|
|
|
@ -7,11 +7,10 @@ Repeat the input as many times as you want.
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from voussoirkit import clipext
|
|
||||||
from voussoirkit import pipeable
|
from voussoirkit import pipeable
|
||||||
|
|
||||||
def repeat_argparse(args):
|
def repeat_argparse(args):
|
||||||
text = clipext.resolve(args.text)
|
text = pipeable.input(args.text, split_lines=False)
|
||||||
if args.times == 'inf':
|
if args.times == 'inf':
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import argparse
|
import argparse
|
||||||
|
import inspect
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -10,7 +11,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
winshell = None
|
winshell = None
|
||||||
|
|
||||||
from voussoirkit import clipext
|
|
||||||
from voussoirkit import expressionmatch
|
from voussoirkit import expressionmatch
|
||||||
from voussoirkit import pathclass
|
from voussoirkit import pathclass
|
||||||
from voussoirkit import pipeable
|
from voussoirkit import pipeable
|
||||||
|
@ -38,7 +38,6 @@ class HeaderedText:
|
||||||
def with_header(self):
|
def with_header(self):
|
||||||
return f'{self.header}: {self.text}'
|
return f'{self.header}: {self.text}'
|
||||||
|
|
||||||
|
|
||||||
def all_terms_match(search_text, terms, match_function):
|
def all_terms_match(search_text, terms, match_function):
|
||||||
matches = (
|
matches = (
|
||||||
(not terms['yes_all'] or all(match_function(search_text, term) for term in terms['yes_all'])) and
|
(not terms['yes_all'] or all(match_function(search_text, term) for term in terms['yes_all'])) and
|
||||||
|
@ -170,7 +169,7 @@ def search(
|
||||||
recurse=not local_only,
|
recurse=not local_only,
|
||||||
yield_directories=True,
|
yield_directories=True,
|
||||||
)
|
)
|
||||||
elif isinstance(text, (list, tuple)):
|
elif isinstance(text, (list, tuple)) or inspect.isgenerator(text):
|
||||||
search_objects = text
|
search_objects = text
|
||||||
else:
|
else:
|
||||||
search_objects = text.splitlines()
|
search_objects = text.splitlines()
|
||||||
|
@ -217,9 +216,9 @@ def search(
|
||||||
def argparse_to_dict(args):
|
def argparse_to_dict(args):
|
||||||
text = args.text
|
text = args.text
|
||||||
if text is not None:
|
if text is not None:
|
||||||
text = clipext.resolve(text)
|
text = pipeable.input(text)
|
||||||
elif STDIN_MODE == 'pipe':
|
elif STDIN_MODE == 'pipe':
|
||||||
text = clipext.resolve('!i')
|
text = pipeable.multi_line_input()
|
||||||
|
|
||||||
if hasattr(args, 'content_args') and args.content_args is not None:
|
if hasattr(args, 'content_args') and args.content_args is not None:
|
||||||
content_args = argparse_to_dict(args.content_args)
|
content_args = argparse_to_dict(args.content_args)
|
||||||
|
|
|
@ -69,7 +69,9 @@ def tempeditor(initial_text=None):
|
||||||
raise BadStatus(subproctools.format_command(command), status)
|
raise BadStatus(subproctools.format_command(command), status)
|
||||||
|
|
||||||
def tempeditor_argparse(args):
|
def tempeditor_argparse(args):
|
||||||
initial_text = '\n'.join(pipeable.input(args.initial_text)) if args.initial_text else None
|
if args.initial_text is not None:
|
||||||
|
initial_text = pipeable.input(args.initial_text, split_lines=False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
text = tempeditor(initial_text=initial_text)
|
text = tempeditor(initial_text=initial_text)
|
||||||
pipeable.stdout(text)
|
pipeable.stdout(text)
|
||||||
|
|
|
@ -6,9 +6,8 @@ import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from voussoirkit import bytestring
|
from voussoirkit import bytestring
|
||||||
from voussoirkit import clipext
|
|
||||||
from voussoirkit import downloady
|
from voussoirkit import downloady
|
||||||
|
from voussoirkit import pipeable
|
||||||
|
|
||||||
def clean_url_list(urls):
|
def clean_url_list(urls):
|
||||||
for url in urls:
|
for url in urls:
|
||||||
|
@ -108,14 +107,7 @@ def threaded_dl(
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
def threaded_dl_argparse(args):
|
def threaded_dl_argparse(args):
|
||||||
if os.path.isfile(args.url_file):
|
urls = pipeable.input(args.url_file, read_files=True, skip_blank=True, strip=True)
|
||||||
f = open(args.url_file, 'r')
|
|
||||||
with f:
|
|
||||||
urls = f.read()
|
|
||||||
else:
|
|
||||||
urls = clipext.resolve(args.url_file)
|
|
||||||
urls = urls.replace('\r', '').split('\n')
|
|
||||||
|
|
||||||
urls = [u.split(' ', 1) if ' ' in u else u for u in urls]
|
urls = [u.split(' ', 1) if ' ' in u else u for u in urls]
|
||||||
|
|
||||||
headers = args.headers
|
headers = args.headers
|
||||||
|
|
Loading…
Reference in a new issue