def main(importer_class=None, args=None):
parser = argparse.ArgumentParser(<EOL>description='<STR_LIT>')<EOL>parser.add_argument('<STR_LIT>', metavar='<STR_LIT:path>', default='<STR_LIT:.>',<EOL>help='<STR_LIT>')<EOL>parser.add_argument('<STR_LIT>', metavar='<STR_LIT:path>', default='<STR_LIT:.>',<EOL>help='<STR_LIT>')<EOL>parser.add_argument('<STR_LIT>', action='<STR_LIT:store_true>',<EOL>help=('<STR_LIT>'<EOL>'<STR_LIT>'))<EOL>parser.add_argument('<STR_LIT>', action='<STR_LIT:store_true>',<EOL>help='<STR_LIT>')<EOL>parser.add_argument('<STR_LIT>', action='<STR_LIT:store_true>',<EOL>help=('<STR_LIT>'<EOL>'<STR_LIT>'))<EOL>parser.add_argument('<STR_LIT>', action='<STR_LIT:store_true>',<EOL>help='<STR_LIT>')<EOL>if importer_class is None:<EOL><INDENT>parser.add_argument(<EOL>'<STR_LIT>', help='<STR_LIT>')<EOL><DEDENT>args = parser.parse_args(args)<EOL>if '<STR_LIT>' in os.environ:<EOL><INDENT>level = getattr(logging, os.environ['<STR_LIT>'].upper(), None)<EOL>if level is not None:<EOL><INDENT>logging.basicConfig(level=level)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>logging.basicConfig(<EOL>level=logging.INFO, format='<STR_LIT>')<EOL><DEDENT>if importer_class is None:<EOL><INDENT>importers = {}<EOL>for importer_entry in pkg_resources.iter_entry_points(<EOL>'<STR_LIT>'):<EOL><INDENT>canonical = importer_entry.name.lower()<EOL>if canonical not in importers:<EOL><INDENT>importers[canonical] = importer_entry<EOL><DEDENT>else:<EOL><INDENT>logger.warning('<STR_LIT>'.format(<EOL>importer_entry.name))<EOL><DEDENT><DEDENT>if args.format in ('<STR_LIT:list>', '<STR_LIT>'):<EOL><INDENT>if len(importers) == <NUM_LIT:0>:<EOL><INDENT>logger.error('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>importer_classes = []<EOL>for name, entry in iteritems(importers):<EOL><INDENT>importer_class = entry.load()<EOL>title = getattr(importer_class, '<STR_LIT:title>', None)<EOL>generic = getattr(importer_class, '<STR_LIT>', False)<EOL>if title is not None:<EOL><INDENT>importer_classes.append(<EOL>(title, generic, name, importer_class))<EOL><DEDENT><DEDENT>print('<STR_LIT>')<EOL>for title, _, name, importer_class in sorted(<EOL>c for c in importer_classes if c[<NUM_LIT:1>]):<EOL><INDENT>print('<STR_LIT>'.format(name, title))<EOL><DEDENT>print()<EOL>print('<STR_LIT>')<EOL>for title, _, name, importer_class in sorted(<EOL>c for c in importer_classes if not c[<NUM_LIT:1>]):<EOL><INDENT>print('<STR_LIT>'.format(name, title))<EOL><DEDENT><DEDENT>sys.exit(<NUM_LIT:0>)<EOL><DEDENT>importer_name = args.format.lower()<EOL>if importer_name not in importers:<EOL><INDENT>logger.error('<STR_LIT>'.format(importer_name))<EOL>logger.info('<STR_LIT>')<EOL>sys.exit(-<NUM_LIT:1>)<EOL><DEDENT>importer_class = importers[importer_name].load()<EOL><DEDENT>importer = importer_class()<EOL>try:<EOL><INDENT>model = importer.import_model(args.source)<EOL><DEDENT>except ModelLoadError as e:<EOL><INDENT>logger.error('<STR_LIT>', exc_info=True)<EOL>importer.help()<EOL>parser.error(text_type(e))<EOL><DEDENT>except ParseError as e:<EOL><INDENT>logger.error('<STR_LIT>', exc_info=True)<EOL>logger.error(text_type(e))<EOL>sys.exit(-<NUM_LIT:1>)<EOL><DEDENT>if args.merge_compounds:<EOL><INDENT>compounds_before = len(model.compounds)<EOL>sbml.merge_equivalent_compounds(model)<EOL>if len(model.compounds) < compounds_before:<EOL><INDENT>logger.info(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>compounds_before, len(model.compounds)))<EOL><DEDENT><DEDENT>print('<STR_LIT>'.format(model.name))<EOL>print('<STR_LIT>'.format(model.biomass_reaction))<EOL>print('<STR_LIT>'.format(len(model.compartments)))<EOL>print('<STR_LIT>'.format(len(model.compounds)))<EOL>print('<STR_LIT>'.format(len(model.reactions)))<EOL>print('<STR_LIT>'.format(count_genes(model)))<EOL>dest_is_empty = False<EOL>try:<EOL><INDENT>dest_is_empty = len(os.listdir(args.dest)) == <NUM_LIT:0><EOL><DEDENT>except OSError:<EOL><INDENT>dest_is_empty = True<EOL><DEDENT>if not dest_is_empty:<EOL><INDENT>if not args.force:<EOL><INDENT>logger.error('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(args.dest))<EOL>return <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>logger.warning('<STR_LIT>'<EOL>'<STR_LIT>'.format(args.dest))<EOL><DEDENT><DEDENT>dest = args.dest<EOL>mkdir_p(dest)<EOL>convert_exchange = not args.no_exchange<EOL>write_yaml_model(model, dest, convert_exchange=convert_exchange,<EOL>split_subsystem=args.split_subsystem)<EOL>
Entry point for import program.

    If the ``args`` are provided, these should be a list of strings that will
    be used instead of ``sys.argv[1:]``. This is mostly useful for testing.