def main(): """ Parse command-line arguments. Initiate file processing. """ parser = CustomArgumentParser() parser.add_argument("-c", "--config", help="Configuration file.") parser.add_argument("-v", "--verbose", help="Log level to DEBUG.", action="store_true") args = parser.parse_args() if (args.verbose): logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.INFO) config_file = args.config error = False if not config_file: log.error("Configuration file is required.") error = True else: config = configparser.ConfigParser() config.read(config_file) if not error: mk_package_contents(config) mk_archive_contents(config) if error: logger.warn("Not yet implemented.") parser.usage_message() sys.exit(1)
def main(): """ Parse command-line arguments. Initiate file processing. """ parser = CustomArgumentParser() parser.add_argument("-a", "--album", help="Work in album directory. Danger!", action="store_true") parser.add_argument("-c", "--config", help="Configuration file.") parser.add_argument("-p", "--pkgid", help="Package to work on.") parser.add_argument("-v", "--verbose", help="Log level to DEBUG.", action="store_true") args = parser.parse_args() if (args.verbose): logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.INFO) error = False config_file = args.config if not config_file: logger.error("Configuration file is required.") error = True else: config = configparser.ConfigParser() config.read(config_file) pkgid = args.pkgid if not error: # XXX: Note logic negation of --album. Command-line semantics are more # clearly expressed this way. logger.warn("Working in album directory: {}".format(args.album)) if pkgid: mk_gallery_tiff(config, pkgid, not args.album) else: # Worried about accidental operation on entire Album directory. # mk_gallery_tiff_album(config, not args.album) mk_gallery_tiff_album(config) if error: logger.error("Exiting due to errors.") parser.usage_message() sys.exit(1)