Update eval.py, do_cmd.py, delete forline.py.
Forline can be achieved by eval | do_cmd.
This commit is contained in:
parent
35281c81ab
commit
34cb53474a
3 changed files with 19 additions and 23 deletions
|
@ -2,6 +2,5 @@ import os
|
|||
|
||||
from voussoirkit import pipeable
|
||||
|
||||
|
||||
for line in pipeable.go():
|
||||
for line in pipeable.go(strip=True, skip_blank=True):
|
||||
os.system(line)
|
||||
|
|
23
eval.py
23
eval.py
|
@ -1,3 +1,4 @@
|
|||
import argparse
|
||||
import glob
|
||||
import math
|
||||
import os
|
||||
|
@ -7,10 +8,6 @@ import sys
|
|||
|
||||
from voussoirkit import pipeable
|
||||
|
||||
|
||||
lines = pipeable.input(sys.argv[1])
|
||||
pattern = sys.argv[2]
|
||||
|
||||
def quote(s):
|
||||
return '"%s"' % s
|
||||
|
||||
|
@ -23,6 +20,20 @@ def random_hex(length=12):
|
|||
token = token[:length]
|
||||
return token
|
||||
|
||||
for line in lines:
|
||||
def eval_argparse(args):
|
||||
for line in pipeable.input(args.lines):
|
||||
x = line
|
||||
pipeable.output(eval(pattern))
|
||||
pipeable.output(eval(args.eval_string))
|
||||
|
||||
def main(argv):
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
|
||||
parser.add_argument('lines')
|
||||
parser.add_argument('eval_string')
|
||||
parser.set_defaults(func=eval_argparse)
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
return args.func(args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main(sys.argv[1:]))
|
||||
|
|
14
forline.py
14
forline.py
|
@ -1,14 +0,0 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
from voussoirkit import clipext
|
||||
|
||||
text = sys.argv[1]
|
||||
command = sys.argv[2:]
|
||||
command = ['"%s"' % x if (' ' in x or x == '%x') else x for x in command]
|
||||
command = ' '.join(command)
|
||||
text = clipext.resolve(text)
|
||||
|
||||
for line in text.splitlines():
|
||||
thiscomm = command.replace('%x', line)
|
||||
os.system(thiscomm)
|
Loading…
Reference in a new issue