MCPcopy Index your code
hub / github.com/DeepL/deepl-python / main

Function main

examples/json/__main__.py:63–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61
62
63def main():
64 # Create a parser, reusing most of the arguments from the main CLI
65 parser = get_parser(prog_name=None)
66 args = parser.parse_args()
67 auth_key = args.auth_key or os.getenv(env_auth_key)
68 server_url = args.server_url or os.getenv(env_server_url)
69 if auth_key is None:
70 raise Exception(
71 f"Please provide authentication key via the {env_auth_key} "
72 "environment variable or --auth_key argument"
73 )
74
75 # Create a Translator object, and call get_usage() to validate connection
76 translator = deepl.Translator(auth_key, server_url=server_url)
77 translator.get_usage()
78
79 for json in args.json:
80 output = translate_json(
81 json,
82 translator=translator,
83 source_lang=args.source_lang,
84 target_lang=args.target_lang,
85 )
86 print(output)
87
88
89if __name__ == "__main__":

Callers 1

__main__.pyFile · 0.70

Calls 3

get_usageMethod · 0.95
translate_jsonFunction · 0.90
get_parserFunction · 0.70

Tested by

no test coverage detected