Repository: yihong0618/bilingual_book_maker
File: book_maker/cli.py (Python)

Code before:
        dest="retranslate",
        nargs=4,
        type=str,
        help="""--retranslate "$translated_filepath" "file_name_in_epub" "start_str" "end_str"(optional)
        Retranslate from start_str to end_str's tag:
        python3 "make_book.py" --book_name "test_books/animal_farm.epub" --retranslate 'test_books/animal_farm_bilingual.epub' 'index_split_002.html' 'in spite of the present book shortage which' 'This kind of thing is not a good symptom. Obviously'
        Retranslate start_str's tag:
        python3 "make_book.py" --book_name "test_books/animal_farm.epub" --retranslate 'test_books/animal_farm_bilingual.epub' 'index_split_002.html' 'in spite of the present book shortage which'
""",
    )

    parser.add_argument(
        "--chatgptaccount",
        dest="chatgptaccount",
        type=str,
        help="your chatgpt account",
    )

    parser.add_argument(
        "--chatgptpassword",
        dest="chatgptpassword",
        type=str,
        help="your chatgpt password",
    )
    chatgptaccount = ""
    chatgptpassword = ""
    options = parser.parse_args()

    if not os.path.isfile(options.book_name):
        print(f"Error: {options.book_name} does not exist.")
        exit(1)

    PROXY = options.proxy
    if PROXY != "":
        os.environ["http_proxy"] = PROXY
        os.environ["https_proxy"] = PROXY

    translate_model = MODEL_DICT.get(options.model)
    assert translate_model is not None, "unsupported model"
    API_KEY = ""
    if options.model in ["gpt3", "chatgptapi"]:
        OPENAI_API_KEY = (
            options.openai_key
            or env.get(
                "OPENAI_API_KEY"
            )  # XXX: for backward compatability, deprecate soon
            or env.get(
                "BBM_OPENAI_API_KEY"
            )  # suggest adding `BBM_` prefix for all the bilingual_book_maker ENVs.
        )
        if not OPENAI_API_KEY:

Review comment (suggestion):
`chatgptaccount`->`chatgpt_account` `chatgptpassword`->`chatgpt_password` Separating variables with underscores can improve readability.

Code after:
    )
    parser.add_argument(
        "--retranslate",
        dest="retranslate",
        nargs=4,
        type=str,
        help="""--retranslate "$translated_filepath" "file_name_in_epub" "start_str" "end_str"(optional)
        Retranslate from start_str to end_str's tag:
        python3 "make_book.py" --book_name "test_books/animal_farm.epub" --retranslate 'test_books/animal_farm_bilingual.epub' 'index_split_002.html' 'in spite of the present book shortage which' 'This kind of thing is not a good symptom. Obviously'
        Retranslate start_str's tag:
        python3 "make_book.py" --book_name "test_books/animal_farm.epub" --retranslate 'test_books/animal_farm_bilingual.epub' 'index_split_002.html' 'in spite of the present book shortage which'
""",
    )

    parser.add_argument(
        "--chatgptaccount",
        dest="chatgptaccount",
        type=str,
        help="your chatgpt account",
    )

    parser.add_argument(
        "--chatgptpassword",
        dest="chatgptpassword",
        type=str,
        help="your chatgpt password",
    )
    chatgpt_account = ""
    chatgpt_password = ""
    options = parser.parse_args()

    if not os.path.isfile(options.book_name):
        print(f"Error: {options.book_name} does not exist.")
        exit(1)

    PROXY = options.proxy
    if PROXY != "":
        os.environ["http_proxy"] = PROXY
        os.environ["https_proxy"] = PROXY

    translate_model = MODEL_DICT.get(options.model)
    assert translate_model is not None, "unsupported model"
    API_KEY = ""
    if options.model in ["gpt3", "chatgptapi"]:
        if OPENAI_API_KEY := (
            options.openai_key
            or env.get(
                "OPENAI_API_KEY",
            )  # XXX: for backward compatability, deprecate soon
            or env.get(
                "BBM_OPENAI_API_KEY",