-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile_json.py
More file actions
35 lines (28 loc) · 853 Bytes
/
file_json.py
File metadata and controls
35 lines (28 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Standard Imports
import argparse
import json
# 3rd Party Imports
import boto3
# Arguments
parser = argparse.ArgumentParser(description="Provides translation between one source language and another of the same set of languages.")
parser.add_argument(
'--file',
dest='filename',
help="The path to the input file. The file should be valid json",
required=True)
args = parser.parse_args()
# Functions
def open_input():
with open(args.filename) as file_object:
contents = json.load(file_object)
return contents['Input'][0]
def translate_text(**kwargs):
client = boto3.client('translate')
response = client.translate_text(**kwargs)
print(response)
# Main Function - use to call other functions
def main():
kwargs = open_input()
translate_text(**kwargs)
if __name__ == "__main__":
main()