def query_config(): """Interactively create configuration options by querying the user. Arguments -- none. Asks the user several questions about how they would like the program configured, most importantly "where do you want your shows downloaded to?" Currently, it is neither descriptive or helpful, but functional. """ print 'Enter the desired values for your config options.' print 'The default value in brackets, enter a blank line to keep it.' for key in redrain.DEFAULT_CONFIG.keys(): print key, '[', redrain.DEFAULT_CONFIG[key], ']', user = raw_input('>') if user == '': continue else: redrain.DEFAULT_CONFIG[key] = user # clean up paths redrain.DEFAULT_CONFIG[key] = \ redrain.fixpath(redrain.DEFAULT_CONFIG[key]) # special case; append a '/' to the end of one item. hack :( if key == 'd_download_dir' and redrain.DEFAULT_CONFIG[key][-1]\ != '/': redrain.DEFAULT_CONFIG['d_download_dir'] = \ redrain.DEFAULT_CONFIG['d_download_dir'] + '/'
# special case for directories if rex.group(1)[0:1] == 'd' and rex.group(2)[-1:] != '/': redrain.CONFIG[rex.group(1)] = rex.group(2) + '/' # ---- main program starts here ---- if __name__ == '__main__': # check the command line to see if an alternate configuration file has # been requested. CFG_FILE = None for item in argv[1:]: m = match(r'(.+)=(.+)', item) if m is not None: if m.group(1) == 'config': CFG_FILE = redrain.fixpath(m.group(2)) # load the config file if the user specifed one, else use the default if CFG_FILE is not None: redrain.load_config(CFG_FILE) else: redrain.load_config() # overwrite configuration items with command-line arguments args_config() # load the podcast list redrain.load_podcasts() # if no podcasts were loaded, start asking the user for feed urls if len(redrain.PODCASTS) == 0: