def main():
    """Files extractor command line"""

    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter)
    parser.add_argument('source', help="location of the downloaded repos")
    parser.add_argument('destination', help="location of the extracted files")
    parser.add_argument(
        '-t', '--nb-test-files', help="number of testing files per language",
        type=int, default=5000)
    parser.add_argument(
        '-l', '--nb-learn-files', help="number of learning files per language",
        type=int, default=10000)
    parser.add_argument(
        '-r', '--remove', help="remove repos that cannot be read",
        action='store_true', default=False)
    parser.add_argument(
        '-d', '--debug', default=False, action='store_true',
        help="show debug messages")

    args = parser.parse_args()
    config_logging(args.debug)

    source = Path(args.source)
    destination = Path(args.destination)
    nb_test = args.nb_test_files
    nb_learn = args.nb_learn_files
    remove = args.remove

    repos = _find_repos(source)
    split_repos = _split_repos(repos, nb_test, nb_learn)
    split_files = _find_files(*split_repos, nb_test, nb_learn, remove)
    _unzip_all(*split_files, destination)
    LOGGER.info("Files saved into %s", destination)
    LOGGER.debug("Exit OK")
def main ( ) : parser = argparse . ArgumentParser ( description = __doc__ , formatter_class = argparse . RawDescriptionHelpFormatter ) parser . add_argument ( 'source' , help = "location of the downloaded repos" ) parser . add_argument ( 'destination' , help = "location of the extracted files" ) parser . add_argument ( '-t' , '--nb-test-files' , help = "number of testing files per language" , type = int , default = 5000 ) parser . add_argument ( '-l' , '--nb-learn-files' , help = "number of learning files per language" , type = int , default = 10000 ) parser . add_argument ( '-r' , '--remove' , help = "remove repos that cannot be read" , action = 'store_true' , default = False ) parser . add_argument ( '-d' , '--debug' , default = False , action = 'store_true' , help = "show debug messages" ) args = parser . parse_args ( ) config_logging ( args . debug ) source = Path ( args . source ) destination = Path ( args . destination ) nb_test = args . nb_test_files nb_learn = args . nb_learn_files remove = args . remove repos = _find_repos ( source ) split_repos = _split_repos ( repos , nb_test , nb_learn ) split_files = _find_files ( * split_repos , nb_test , nb_learn , remove ) _unzip_all ( * split_files , destination ) LOGGER . info ( "Files saved into %s" , destination ) LOGGER . debug ( "Exit OK" )
Files extractor command line