From 02518a96a306fee0b9832ff6fabed5e21dbb914e Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 17 Aug 2021 14:06:07 -0700 Subject: [PATCH] Replace clipext.resolve with pipeable.input(split_lines=False). --- cup.py | 2 +- repeat.py | 3 +-- search.py | 9 ++++----- tempeditor.py | 4 +++- threaded_dl.py | 12 ++---------- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/cup.py b/cup.py index 5af1e6d..ae72b1c 100644 --- a/cup.py +++ b/cup.py @@ -2,5 +2,5 @@ import pyperclip from voussoirkit import pipeable -text = '\n'.join(pipeable.input('!i')) +text = pipeable.input('!i', split_lines=False) pyperclip.copy(text) diff --git a/repeat.py b/repeat.py index f73e0c5..fd47dad 100644 --- a/repeat.py +++ b/repeat.py @@ -7,11 +7,10 @@ Repeat the input as many times as you want. import argparse import sys -from voussoirkit import clipext from voussoirkit import pipeable def repeat_argparse(args): - text = clipext.resolve(args.text) + text = pipeable.input(args.text, split_lines=False) if args.times == 'inf': try: while True: diff --git a/search.py b/search.py index 2f65ea4..a00b556 100644 --- a/search.py +++ b/search.py @@ -1,4 +1,5 @@ import argparse +import inspect import itertools import os import re @@ -10,7 +11,6 @@ try: except ImportError: winshell = None -from voussoirkit import clipext from voussoirkit import expressionmatch from voussoirkit import pathclass from voussoirkit import pipeable @@ -38,7 +38,6 @@ class HeaderedText: def with_header(self): return f'{self.header}: {self.text}' - def all_terms_match(search_text, terms, match_function): matches = ( (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, yield_directories=True, ) - elif isinstance(text, (list, tuple)): + elif isinstance(text, (list, tuple)) or inspect.isgenerator(text): search_objects = text else: search_objects = text.splitlines() @@ -217,9 +216,9 @@ def search( def argparse_to_dict(args): text = args.text if text is not None: - text = clipext.resolve(text) + text = pipeable.input(text) 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: content_args = argparse_to_dict(args.content_args) diff --git a/tempeditor.py b/tempeditor.py index 778e605..6dfc53e 100644 --- a/tempeditor.py +++ b/tempeditor.py @@ -69,7 +69,9 @@ def tempeditor(initial_text=None): raise BadStatus(subproctools.format_command(command), status) 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: text = tempeditor(initial_text=initial_text) pipeable.stdout(text) diff --git a/threaded_dl.py b/threaded_dl.py index 7921101..5f4d0ef 100644 --- a/threaded_dl.py +++ b/threaded_dl.py @@ -6,9 +6,8 @@ import threading import time from voussoirkit import bytestring -from voussoirkit import clipext from voussoirkit import downloady - +from voussoirkit import pipeable def clean_url_list(urls): for url in urls: @@ -108,14 +107,7 @@ def threaded_dl( time.sleep(0.1) def threaded_dl_argparse(args): - if os.path.isfile(args.url_file): - 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 = pipeable.input(args.url_file, read_files=True, skip_blank=True, strip=True) urls = [u.split(' ', 1) if ' ' in u else u for u in urls] headers = args.headers