Update some scripts with better pipeable behavior.
This commit is contained in:
parent
4b8f8f6c77
commit
81fc944d10
4 changed files with 36 additions and 24 deletions
15
delete.py
Normal file
15
delete.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from voussoirkit import pipeable
|
||||
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)
|
||||
os.remove(name)
|
||||
elif os.path.isdir(name):
|
||||
pipeable.output(name)
|
||||
shutil.rmtree(name)
|
|
@ -1,10 +0,0 @@
|
|||
import os
|
||||
|
||||
from voussoirkit import pipeable
|
||||
|
||||
for line in pipeable.go():
|
||||
if os.path.isfile(line):
|
||||
print('Deleting', line)
|
||||
os.remove(line)
|
||||
else:
|
||||
print('Not a file', line)
|
11
recycle.py
11
recycle.py
|
@ -1,9 +1,12 @@
|
|||
import os
|
||||
import send2trash
|
||||
import sys
|
||||
|
||||
from voussoirkit import pipeable
|
||||
from voussoirkit import winglob
|
||||
|
||||
for pattern in sys.argv[1:]:
|
||||
for file in winglob.glob(pattern):
|
||||
print(file)
|
||||
send2trash.send2trash(file)
|
||||
for pattern in pipeable.go(skip_blank=True):
|
||||
for name in winglob.glob(pattern):
|
||||
name = os.path.abspath(name)
|
||||
pipeable.output(name)
|
||||
send2trash.send2trash(name)
|
||||
|
|
14
size.py
14
size.py
|
@ -1,16 +1,20 @@
|
|||
import sys
|
||||
|
||||
from voussoirkit import spinal
|
||||
from voussoirkit import pathclass
|
||||
from voussoirkit import pipeable
|
||||
from voussoirkit import spinal
|
||||
|
||||
paths = sys.argv[1:]
|
||||
paths = [pathclass.Path(p) for p in paths]
|
||||
|
||||
@pipeable.ctrlc_return1
|
||||
def main(argv):
|
||||
total = 0
|
||||
for path in paths:
|
||||
for path in pipeable.go():
|
||||
path = pathclass.Path(path)
|
||||
if path.is_file:
|
||||
total += path.size
|
||||
elif path.is_dir:
|
||||
total += spinal.get_dir_size(path)
|
||||
|
||||
print(total)
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main(sys.argv[1:]))
|
||||
|
|
Loading…
Reference in a new issue