MCPcopy Create free account
hub / github.com/DeepL/deepl-python / main

Function main

examples/mustache/__main__.py:63–87  ·  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 template in args.template:
80 # Call translate_mustache() to translate the Mustache template
81 output = translate_mustache(
82 template,
83 translator=translator,
84 source_lang=args.source_lang,
85 target_lang=args.target_lang,
86 )
87 print(output)
88
89
90if __name__ == "__main__":

Callers 1

__main__.pyFile · 0.70

Calls 3

get_usageMethod · 0.95
translate_mustacheFunction · 0.90
get_parserFunction · 0.70

Tested by

no test coverage detected