scripts: assume dl/ the default dir for dl_cleanup script
Assume dl/ the default dl dir and make it configurable if someone have that in a different place. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
This commit is contained in:
parent
428c5bf3d1
commit
69760d415d
1 changed files with 12 additions and 8 deletions
|
@ -185,6 +185,9 @@ def usage():
|
||||||
print(" -d|--dry-run Do a dry-run. Don't delete any files")
|
print(" -d|--dry-run Do a dry-run. Don't delete any files")
|
||||||
print(" -B|--show-blacklist Show the blacklist and exit")
|
print(" -B|--show-blacklist Show the blacklist and exit")
|
||||||
print(" -w|--whitelist ITEM Remove ITEM from blacklist")
|
print(" -w|--whitelist ITEM Remove ITEM from blacklist")
|
||||||
|
print(
|
||||||
|
" -D|--download-dir Provide path to dl dir to clean also the build directory"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
@ -193,25 +196,20 @@ def main(argv):
|
||||||
try:
|
try:
|
||||||
(opts, args) = getopt.getopt(
|
(opts, args) = getopt.getopt(
|
||||||
argv[1:],
|
argv[1:],
|
||||||
"hdBw:",
|
"hdBwD:",
|
||||||
[
|
[
|
||||||
"help",
|
"help",
|
||||||
"dry-run",
|
"dry-run",
|
||||||
"show-blacklist",
|
"show-blacklist",
|
||||||
"whitelist=",
|
"whitelist=",
|
||||||
|
"download-dir=",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
if len(args) != 1:
|
|
||||||
usage()
|
|
||||||
return 1
|
|
||||||
except getopt.GetoptError as e:
|
except getopt.GetoptError as e:
|
||||||
usage()
|
usage()
|
||||||
return 1
|
return 1
|
||||||
directory = args[0]
|
|
||||||
|
|
||||||
if not os.path.exists(directory):
|
directory = "dl/"
|
||||||
print("Can't find dl path", directory)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
for (o, v) in opts:
|
for (o, v) in opts:
|
||||||
if o in ("-h", "--help"):
|
if o in ("-h", "--help"):
|
||||||
|
@ -235,6 +233,12 @@ def main(argv):
|
||||||
sep = "\t"
|
sep = "\t"
|
||||||
print("%s%s(%s)" % (name, sep, regex.pattern))
|
print("%s%s(%s)" % (name, sep, regex.pattern))
|
||||||
return 0
|
return 0
|
||||||
|
if o in ("-D", "--download-dir"):
|
||||||
|
directory = v
|
||||||
|
|
||||||
|
if not os.path.exists(directory):
|
||||||
|
print("Can't find dl path", directory)
|
||||||
|
return 1
|
||||||
|
|
||||||
# Create a directory listing and parse the file names.
|
# Create a directory listing and parse the file names.
|
||||||
entries = []
|
entries = []
|
||||||
|
|
Loading…
Reference in a new issue