# interpret options and arguments for option, argument in myopts: if option in ('-f', '--find'): # search for video files find = True elif option in ('-r', '--recursive'): # search reccursively recursive = True elif option in ('-i', '--info'): # present info on videos info = True elif option in ('-p', '--path'): # search in specified path path = argument elif option == '--vbr': # search after specified video bitrate videoBitrate = argument elif option in ('-v', '--verbose'): # verbose output verbose = True elif option in ('-h', '--help'): # display help text usage(0) if path: # argument -p --path passed if not os.path.isdir(path): # not a valid path onError(4, "%s is not a valid path" % path) else: path = os.path.abspath(path) # construct absolute path else: path = os.path.abspath(os.getcwd()) # set path to current path onError(5, "\nNo path given.\nUsing current dir") if find: # search for videos if recursive: # search recursively print("\nSearching recursively for video files in \n%s ..." % path) else: print("\nSearching for video files in \n%s ..." % path)
elif option in ('-p', '--path'): searchPath = os.path.abspath(argument) elif option in ('-r', '--recursive'): recursive = True elif option in ('-o', '--oldpattern'): oldPattern = argument elif option in ('-n', '--newpattern'): newPattern = argument elif option in ('-e', '--extensions'): extensions = argument elif option in ('-y', '--yes'): yesToQuestions = True elif option in ('-v', '--verbose'): # verbose output verbose = True elif option in ('-h', '--help'): # display help text usage(0) if configFileName: # argument -c --configfile passed if not isfile(configFileName): # config file does not exist onError(3, "%s is not a valid file" % configFileName) if verbose: print "\nReading config file...\n" myConfig = {} with open(configFileName, 'r') as configFile: fileContent = configFile.readlines() for line in fileContent: if verbose: print "Line: %s" % line.rstrip("\n") line = line.lstrip(" ") #line = line.lower() if line.lower().startswith("oldpattern"):