Migrate scripts from pipeable.output to pipeable.stdout.
This commit is contained in:
parent
7936f15f27
commit
0f2dc36a6b
13 changed files with 15 additions and 15 deletions
2
crlf.py
2
crlf.py
|
@ -21,7 +21,7 @@ def crlf(filename):
|
||||||
def main(args):
|
def main(args):
|
||||||
for line in pipeable.go(args, strip=True, skip_blank=True):
|
for line in pipeable.go(args, strip=True, skip_blank=True):
|
||||||
for filename in winglob.glob(line):
|
for filename in winglob.glob(line):
|
||||||
pipeable.output(filename)
|
pipeable.stdout(filename)
|
||||||
crlf(filename)
|
crlf(filename)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -7,8 +7,8 @@ from voussoirkit import winglob
|
||||||
for pattern in pipeable.go(skip_blank=True):
|
for pattern in pipeable.go(skip_blank=True):
|
||||||
for name in winglob.glob(pattern):
|
for name in winglob.glob(pattern):
|
||||||
if os.path.isfile(name):
|
if os.path.isfile(name):
|
||||||
pipeable.output(name)
|
pipeable.stdout(name)
|
||||||
os.remove(name)
|
os.remove(name)
|
||||||
elif os.path.isdir(name):
|
elif os.path.isdir(name):
|
||||||
pipeable.output(name)
|
pipeable.stdout(name)
|
||||||
shutil.rmtree(name)
|
shutil.rmtree(name)
|
||||||
|
|
2
eval.py
2
eval.py
|
@ -23,7 +23,7 @@ def random_hex(length=12):
|
||||||
def eval_argparse(args):
|
def eval_argparse(args):
|
||||||
for line in pipeable.input(args.lines):
|
for line in pipeable.input(args.lines):
|
||||||
x = line
|
x = line
|
||||||
pipeable.output(eval(args.eval_string))
|
pipeable.stdout(eval(args.eval_string))
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
|
|
@ -10,7 +10,7 @@ def groupsof_argparse(args):
|
||||||
chunks = gentools.chunk_generator(lines, args.chunk_size)
|
chunks = gentools.chunk_generator(lines, args.chunk_size)
|
||||||
for chunk in chunks:
|
for chunk in chunks:
|
||||||
chunk = args.separator.join(chunk)
|
chunk = args.separator.join(chunk)
|
||||||
pipeable.output(chunk)
|
pipeable.stdout(chunk)
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
|
|
@ -2,4 +2,4 @@ from voussoirkit import pipeable
|
||||||
|
|
||||||
|
|
||||||
for line in pipeable.go():
|
for line in pipeable.go():
|
||||||
pipeable.output(line.lower())
|
pipeable.stdout(line.lower())
|
||||||
|
|
|
@ -36,7 +36,7 @@ def moveall_argparse(args):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
for (file, new_path) in pairs:
|
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)
|
shutil.move(file.absolute_path, new_path.absolute_path)
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
|
|
@ -7,5 +7,5 @@ from voussoirkit import winglob
|
||||||
for pattern in pipeable.go(skip_blank=True):
|
for pattern in pipeable.go(skip_blank=True):
|
||||||
for name in winglob.glob(pattern):
|
for name in winglob.glob(pattern):
|
||||||
name = os.path.abspath(name)
|
name = os.path.abspath(name)
|
||||||
pipeable.output(name)
|
pipeable.stdout(name)
|
||||||
send2trash.send2trash(name)
|
send2trash.send2trash(name)
|
||||||
|
|
|
@ -8,4 +8,4 @@ replace_from = sys.argv[2]
|
||||||
replace_to = sys.argv[3]
|
replace_to = sys.argv[3]
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
pipeable.output(line.replace(replace_from, replace_to))
|
pipeable.stdout(line.replace(replace_from, replace_to))
|
||||||
|
|
|
@ -12,7 +12,7 @@ def sorted_argparse(args):
|
||||||
lines.sort()
|
lines.sort()
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
pipeable.output(line)
|
pipeable.stdout(line)
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
|
2
sum.py
2
sum.py
|
@ -2,4 +2,4 @@ from voussoirkit import pipeable
|
||||||
|
|
||||||
|
|
||||||
total = sum(float(x) for x in pipeable.go() if x.strip())
|
total = sum(float(x) for x in pipeable.go() if x.strip())
|
||||||
pipeable.output(f'{total}\n')
|
pipeable.stdout(f'{total}\n')
|
||||||
|
|
|
@ -72,7 +72,7 @@ def tempeditor_argparse(args):
|
||||||
initial_text = '\n'.join(pipeable.input(args.initial_text)) if args.initial_text else None
|
initial_text = '\n'.join(pipeable.input(args.initial_text)) if args.initial_text else None
|
||||||
try:
|
try:
|
||||||
text = tempeditor(initial_text=initial_text)
|
text = tempeditor(initial_text=initial_text)
|
||||||
pipeable.output(text)
|
pipeable.stdout(text)
|
||||||
return 0
|
return 0
|
||||||
except NoEditor as exc:
|
except NoEditor as exc:
|
||||||
pipeable.stderr(exc)
|
pipeable.stderr(exc)
|
||||||
|
|
4
touch.py
4
touch.py
|
@ -15,11 +15,11 @@ def touch_argparse(args):
|
||||||
|
|
||||||
if len(filenames) == 0 and not winglob.is_glob(pattern):
|
if len(filenames) == 0 and not winglob.is_glob(pattern):
|
||||||
open(pattern, 'a').close()
|
open(pattern, 'a').close()
|
||||||
print(pattern)
|
pipeable.stdout(pattern)
|
||||||
|
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
os.utime(filename)
|
os.utime(filename)
|
||||||
print(filename)
|
pipeable.stdout(filename)
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
parser = argparse.ArgumentParser(description=__doc__)
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
|
|
@ -8,7 +8,7 @@ def unique_argparse(args):
|
||||||
seen = set()
|
seen = set()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line not in seen:
|
if line not in seen:
|
||||||
pipeable.output(line)
|
pipeable.stdout(line)
|
||||||
seen.add(line)
|
seen.add(line)
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
|
Loading…
Reference in a new issue