🚧 find-junk: reformat
This commit is contained in:
parent
b69b268933
commit
132efe16e1
1 changed files with 16 additions and 9 deletions
25
find-junk
25
find-junk
|
@ -8,19 +8,26 @@ import os
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
M = 1024*1024
|
M = 1024 * 1024
|
||||||
|
|
||||||
|
|
||||||
def junk_dirs():
|
def junk_dirs():
|
||||||
"""Return directories which potentially contain junk"""
|
"""Return directories which potentially contain junk"""
|
||||||
|
|
||||||
for d in ['~/tmp', '~/.local/share/Trash', '~/rpmbuild', '~/RPM',
|
static_junk_dirs = [
|
||||||
'~/.cache/tracker', '~/.local/share/apt-dater/history']:
|
"~/tmp",
|
||||||
|
"~/.local/share/Trash",
|
||||||
|
"~/rpmbuild",
|
||||||
|
"~/RPM",
|
||||||
|
"~/.cache/tracker",
|
||||||
|
"~/.local/share/apt-dater/history",
|
||||||
|
]
|
||||||
|
for d in static_junk_dirs:
|
||||||
d = os.path.expanduser(d)
|
d = os.path.expanduser(d)
|
||||||
if os.path.exists(d):
|
if os.path.exists(d):
|
||||||
yield d
|
yield d
|
||||||
for d, _, _ in os.walk(os.path.expanduser('~')):
|
for d, _, _ in os.walk(os.path.expanduser("~")):
|
||||||
if d.endswith('.sync/Archive'):
|
if d.endswith(".sync/Archive"):
|
||||||
yield d
|
yield d
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,17 +56,17 @@ def main():
|
||||||
if os.path.isdir(d):
|
if os.path.isdir(d):
|
||||||
du_d = du(d)
|
du_d = du(d)
|
||||||
|
|
||||||
if du_d < 5*M:
|
if du_d < 5 * M:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if du_d > 100*M:
|
if du_d > 100 * M:
|
||||||
fore = Fore.RED
|
fore = Fore.RED
|
||||||
elif du_d > 50*M:
|
elif du_d > 50 * M:
|
||||||
fore = Fore.YELLOW
|
fore = Fore.YELLOW
|
||||||
else:
|
else:
|
||||||
fore = Fore.RESET
|
fore = Fore.RESET
|
||||||
|
|
||||||
print(fore + str(du_d//M) + 'M\t' + d + Fore.RESET)
|
print(fore + str(du_d // M) + "M\t" + d + Fore.RESET)
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue