Commits

Vasilij Schneidermann committed 6304135

made output directory optional, refactored folders to directories

Comments (0)

Files changed (1)

 PARSER_EPILOG = "example usage: fug qc images"
 PLUGIN_LISTER = 'Plugins:\n{}'
 PLUGIN_MISSING = '{}'
-FOLDER_MISSING = "The following folder wasn't found: {}"
+DIRECTORY_MISSING = "The following directory wasn't found: {}"
 STATUS = '#{}: {} -> {}'
 STATUS_VERBOSE = '{} = {} + \'.\' + {}'
 STATUS2 = '{} -> {}'
 
 PARSER_ARGUMENTS = [
     ('plugin', {'help': "webcomic plugin to use"}),
-    ('folder', {'help': "output folder"}),
     ('--list', {'action': ListPlugins, 'nargs': 0,
                 'help': "list available plugins"}),
+    ('-o', {'action': 'store', 'nargs': '?', 'default': os.getcwd(),
+            'dest': 'directory', 'help': "output directory (default: ./)"}),
     ('-v', {'action': 'store_true', 'default': False, 'dest': 'verbose',
             'help': "turn verbose mode on"}),
-    ('-d', {'action': 'store', 'dest': 'dump_file',
-            'help': "dump urls to specified file instead of downloading"}),
+    ('-d', {'action': 'store', 'dest': 'dump_file', 'help':
+            "dump urls to specified file instead of downloading images"}),
     ('-f', {'action': 'store', 'dest': 'filename_format',
             'help': "override filename format"}),
     ('-s', {'action': 'store', 'dest': 'start_url', 'help':
             "override start url"}),
     ('-e', {'action': 'store', 'dest': 'end_url', 'help': "override end url"}),
     ('-i', {'action': 'store', 'default': 1, 'type': int, 'dest': 'offset',
-            'help': "override offset (use with -s and -e to resume)"})]
+            'help': "override offset (default: 1), "
+            "use with -s and -e to resume"})]
 
 
 def main():
     plugin_name = args.plugin
     plugin = __import__("{}.{}".format(RELATIVE_PLUGIN_DIRECTORY, plugin_name),
                         fromlist=[RELATIVE_PLUGIN_DIRECTORY]).plugin()
-    # for now the script won't create folders by itself
-    if not os.path.exists(args.folder):
-        sys.exit(FOLDER_MISSING.format(args.folder))
+    # for now the script won't create directories by itself
+    if not os.path.exists(args.directory):
+        sys.exit(DIRECTORY_MISSING.format(args.directory))
 
     logging.info("Creating TODO list...")
     todo_list = fetch_general_info(plugin, args)
         image_url, full_filename = row['image_url'], row['full_filename']
         full_filename = filename_format.format(**row)
         logging.info(STATUS2.format(image_url, full_filename))
-        plugin.fetch_image(image_url, args.folder, full_filename)
+        plugin.fetch_image(image_url, args.directory, full_filename)
 
 
 def fetch_content(url):