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 send2trash
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from voussoirkit import pipeable
|
||||||
from voussoirkit import winglob
|
from voussoirkit import winglob
|
||||||
|
|
||||||
for pattern in sys.argv[1:]:
|
for pattern in pipeable.go(skip_blank=True):
|
||||||
for file in winglob.glob(pattern):
|
for name in winglob.glob(pattern):
|
||||||
print(file)
|
name = os.path.abspath(name)
|
||||||
send2trash.send2trash(file)
|
pipeable.output(name)
|
||||||
|
send2trash.send2trash(name)
|
||||||
|
|
18
size.py
18
size.py
|
@ -1,16 +1,20 @@
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from voussoirkit import spinal
|
|
||||||
from voussoirkit import pathclass
|
from voussoirkit import pathclass
|
||||||
|
from voussoirkit import pipeable
|
||||||
|
from voussoirkit import spinal
|
||||||
|
|
||||||
paths = sys.argv[1:]
|
@pipeable.ctrlc_return1
|
||||||
paths = [pathclass.Path(p) for p in paths]
|
def main(argv):
|
||||||
|
total = 0
|
||||||
total = 0
|
for path in pipeable.go():
|
||||||
for path in paths:
|
path = pathclass.Path(path)
|
||||||
if path.is_file:
|
if path.is_file:
|
||||||
total += path.size
|
total += path.size
|
||||||
elif path.is_dir:
|
elif path.is_dir:
|
||||||
total += spinal.get_dir_size(path)
|
total += spinal.get_dir_size(path)
|
||||||
|
|
||||||
print(total)
|
print(total)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
raise SystemExit(main(sys.argv[1:]))
|
||||||
|
|
Loading…
Reference in a new issue