예제 #1
0
def main(prog, args):
    parser = argparse.ArgumentParser(
        prog=prog,
        formatter_class=argparse.RawTextHelpFormatter)

    parser.add_argument("contest_id",
                        help="Contest ID (e.g. arc001)")

    parser.add_argument("--without-login",
                        action="store_true",
                        help="Download data without login")

    parser.add_argument("--workspace",
                        help="Path to workspace's root directory. This script will create files"
                             " in {{WORKSPACE}}/{{contest_name}}/{{alphabet}}/ e.g. ./your-workspace/arc001/A/\n"
                             "[Default] {}".format(DEFAULT_WORKSPACE_DIR_PATH))

    parser.add_argument("--lang",
                        help="Programming language of your template code, {}.\n"
                        .format(" or ".join(SUPPORTED_LANGUAGES)) + "[Default] {}".format(DEFAULT_LANG))

    parser.add_argument("--template",
                        help="File path to your template code\n{0}{1}".format(
                            "[Default (C++)] {}\n".format(
                                get_default_template_path('cpp')),
                            "[Default (Java)] {}".format(
                                get_default_template_path('java')))
                        )

    # Deleted functionality
    parser.add_argument('--replacement', help=argparse.SUPPRESS)

    parser.add_argument("--parallel",
                        action="store_true",
                        help="Prepare problem directories asynchronously using multi processors.",
                        default=None)

    parser.add_argument("--save-no-session-cache",
                        action="store_true",
                        help="Save no session cache to avoid security risk",
                        default=None)

    parser.add_argument("--config",
                        help="File path to your config file\n{0}{1}".format("[Default (Primary)] {}\n".format(
                            USER_CONFIG_PATH),
                            "[Default (Secondary)] {}\n".format(
                                get_default_config_path()))
                        )

    args = parser.parse_args(args)

    if args.replacement is not None:
        logging.error(with_color("Sorry! --replacement argument no longer exists"
                                 " and you can only use --template."
                                 " See the official document for details.", Fore.LIGHTRED_EX))
        raise DeletedFunctionalityError

    config = get_config(args)

    try:
        import AccountInformation  # noqa
        raise BannedFileDetectedError(
            "We abolished the logic with AccountInformation.py. Please delete the file.")
    except ImportError:
        pass

    client = AtCoderClient()
    if not config.etc_config.download_without_login:
        try:
            client.login(
                save_session_cache=not config.etc_config.save_no_session_cache)
            logging.info("Login successful.")
        except LoginError:
            logging.error(
                "Failed to login (maybe due to wrong username/password combination?)")
            sys.exit(-1)
    else:
        logging.info("Downloading data without login.")

    prepare_contest(client,
                    args.contest_id,
                    config)
예제 #2
0
    @classmethod
    def from_name(cls, name: str):
        for l in ALL_LANGUAGES:
            if l.name == name:
                return l
        raise LanguageNotFoundError(
            "No language support for '{}'".format(ALL_LANGUAGE_NAMES))


CPP = Language(
    name="cpp",
    display_name="C++",
    extension="cpp",
    submission_lang_pattern=re.compile(".*C\\+\\+14 \\(GCC.*"),
    default_code_generator=cpp.main,
    default_template_path=get_default_template_path('cpp'),
    compile_command="g++ {filename}.cpp -o {filename} -std=c++14",
    test_command="{exec_filename}",
    exec_filename="{filename}{exec_extension}"
)

JAVA = Language(
    name="java",
    display_name="Java",
    extension="java",
    submission_lang_pattern=re.compile(".*Java8.*"),
    default_code_generator=java.main,
    default_template_path=get_default_template_path('java'),
    compile_command="javac {filename}.java",
    test_command="java {capitalized_filename}",
    exec_filename="{capitalized_filename}.class"
예제 #3
0
    @classmethod
    def from_name(cls, name: str):
        for l in ALL_LANGUAGES:
            if l.name == name:
                return l
        raise LanguageNotFoundError(
            "No language support for '{}'".format(ALL_LANGUAGE_NAMES))


CPP = Language(
    name="cpp",
    display_name="C++",
    extension="cpp",
    submission_lang_pattern=re.compile(".*C\\+\\+14 \\(GCC.*"),
    default_code_generator=cpp.main,
    default_template_path=get_default_template_path('cpp'),
)

JAVA = Language(
    name="java",
    display_name="Java",
    extension="java",
    submission_lang_pattern=re.compile(".*Java8.*"),
    default_code_generator=java.main,
    default_template_path=get_default_template_path('java'),
)

RUST = Language(
    name="rust",
    display_name="Rust",
    extension="rs",