Migrate scripts from pipeable.output to pipeable.stdout.

This commit is contained in:
voussoir 2021-05-25 01:35:46 -07:00
parent 7936f15f27
commit 0f2dc36a6b
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB
13 changed files with 15 additions and 15 deletions

View file

@ -21,7 +21,7 @@ def crlf(filename):
def main(args):
for line in pipeable.go(args, strip=True, skip_blank=True):
for filename in winglob.glob(line):
pipeable.output(filename)
pipeable.stdout(filename)
crlf(filename)
if __name__ == '__main__':

View file

@ -7,8 +7,8 @@ from voussoirkit import winglob
for pattern in pipeable.go(skip_blank=True):
for name in winglob.glob(pattern):
if os.path.isfile(name):
pipeable.output(name)
pipeable.stdout(name)
os.remove(name)
elif os.path.isdir(name):
pipeable.output(name)
pipeable.stdout(name)
shutil.rmtree(name)

View file

@ -23,7 +23,7 @@ def random_hex(length=12):
def eval_argparse(args):
for line in pipeable.input(args.lines):
x = line
pipeable.output(eval(args.eval_string))
pipeable.stdout(eval(args.eval_string))
def main(argv):
parser = argparse.ArgumentParser(description=__doc__)

View file

@ -10,7 +10,7 @@ def groupsof_argparse(args):
chunks = gentools.chunk_generator(lines, args.chunk_size)
for chunk in chunks:
chunk = args.separator.join(chunk)
pipeable.output(chunk)
pipeable.stdout(chunk)
def main(argv):
parser = argparse.ArgumentParser(description=__doc__)

View file

@ -2,4 +2,4 @@ from voussoirkit import pipeable
for line in pipeable.go():
pipeable.output(line.lower())
pipeable.stdout(line.lower())

View file

@ -36,7 +36,7 @@ def moveall_argparse(args):
return 1
for (file, new_path) in pairs:
pipeable.output(new_path.absolute_path)
pipeable.stdout(new_path.absolute_path)
shutil.move(file.absolute_path, new_path.absolute_path)
def main(argv):

View file

@ -7,5 +7,5 @@ from voussoirkit import winglob
for pattern in pipeable.go(skip_blank=True):
for name in winglob.glob(pattern):
name = os.path.abspath(name)
pipeable.output(name)
pipeable.stdout(name)
send2trash.send2trash(name)

View file

@ -8,4 +8,4 @@ replace_from = sys.argv[2]
replace_to = sys.argv[3]
for line in lines:
pipeable.output(line.replace(replace_from, replace_to))
pipeable.stdout(line.replace(replace_from, replace_to))

View file

@ -12,7 +12,7 @@ def sorted_argparse(args):
lines.sort()
for line in lines:
pipeable.output(line)
pipeable.stdout(line)
def main(argv):
parser = argparse.ArgumentParser(description=__doc__)

2
sum.py
View file

@ -2,4 +2,4 @@ from voussoirkit import pipeable
total = sum(float(x) for x in pipeable.go() if x.strip())
pipeable.output(f'{total}\n')
pipeable.stdout(f'{total}\n')

View file

@ -72,7 +72,7 @@ def tempeditor_argparse(args):
initial_text = '\n'.join(pipeable.input(args.initial_text)) if args.initial_text else None
try:
text = tempeditor(initial_text=initial_text)
pipeable.output(text)
pipeable.stdout(text)
return 0
except NoEditor as exc:
pipeable.stderr(exc)

View file

@ -15,11 +15,11 @@ def touch_argparse(args):
if len(filenames) == 0 and not winglob.is_glob(pattern):
open(pattern, 'a').close()
print(pattern)
pipeable.stdout(pattern)
for filename in filenames:
os.utime(filename)
print(filename)
pipeable.stdout(filename)
def main(argv):
parser = argparse.ArgumentParser(description=__doc__)

View file

@ -8,7 +8,7 @@ def unique_argparse(args):
seen = set()
for line in lines:
if line not in seen:
pipeable.output(line)
pipeable.stdout(line)
seen.add(line)
def main(argv):