mirror of
https://github.com/nikdoof/tvorganise.git
synced 2025-12-14 07:12:18 +00:00
Added --always option (when used, will not prompt y/n before copying)
This commit is contained in:
@@ -224,12 +224,15 @@ def processNames(names, verbose=False):
|
|||||||
def confirm(question="Rename files?"):
|
def confirm(question="Rename files?"):
|
||||||
ans = None
|
ans = None
|
||||||
while ans not in ["q", "quit"]:
|
while ans not in ["q", "quit"]:
|
||||||
print "y/n/q?",
|
print "y/n/a/q?",
|
||||||
ans = raw_input()
|
ans = raw_input()
|
||||||
|
print ans
|
||||||
if ans.lower() in ["y", "yes"]:
|
if ans.lower() in ["y", "yes"]:
|
||||||
return True
|
return True
|
||||||
elif ans.lower() in ["n", "no"]:
|
elif ans.lower() in ["n", "no"]:
|
||||||
return False
|
return False
|
||||||
|
elif ans.lower() in ["a", "always"]:
|
||||||
|
return "always"
|
||||||
else:
|
else:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
#end confirm
|
#end confirm
|
||||||
@@ -257,15 +260,18 @@ def same_partition(f1, f2):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
parser = OptionParser(usage="%prog [options] <file or directories>")
|
parser = OptionParser(usage="%prog [options] <file or directories>")
|
||||||
|
parser.add_option("-a", "--always", dest = "always",
|
||||||
|
action="store_true", default = False,
|
||||||
|
help="Do not ask for confirmation before copying")
|
||||||
|
|
||||||
opts, args = parser.parse_args()
|
opts, args = parser.parse_args()
|
||||||
|
|
||||||
files = findFiles(args)
|
files = findFiles(args)
|
||||||
files = processNames(files)
|
files = processNames(files)
|
||||||
|
|
||||||
# Warn if no files are found, then exit
|
# Warn if no files are found, then exit
|
||||||
if files.__len__() == 0:
|
if len(files) == 0:
|
||||||
print colour('No files found','red')
|
print colour('No files found','red')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
#end if files == 0
|
#end if files == 0
|
||||||
@@ -278,7 +284,9 @@ def main():
|
|||||||
print "Old path:", oldfile
|
print "Old path:", oldfile
|
||||||
print "New path:", newfile
|
print "New path:", newfile
|
||||||
ans=confirm()
|
ans=confirm()
|
||||||
if ans:
|
if ans == "always": opts.always = True
|
||||||
|
|
||||||
|
if ans or opts.always:
|
||||||
make_path(newpath)
|
make_path(newpath)
|
||||||
file_exists = does_file_exist(newfile)
|
file_exists = does_file_exist(newfile)
|
||||||
if file_exists:
|
if file_exists:
|
||||||
|
|||||||
Reference in New Issue
Block a user