in functions/source/table-generator-lambda.py [0:0]
def getTemplateText(file_url):
try:
if file_url.startswith('http') or file_url.startswith('file:/'):
template_raw_data = urllib.request.urlopen(file_url).read().decode('utf-8')
elif file_url.startswith('s3:/'):
s3 = boto3.resource('s3')
s3_parse = urlparse(file_url)
bucket = s3_parse.netloc
s3_key = s3_parse.path.lstrip('/')
s3_obj = s3.Object(bucket, s3_key)
template_raw_data = s3_obj.get()["Body"].read().decode('utf-8')
else:
with open(file_url, 'rU') as template:
template_raw_data = template.read()
template.close()
return template_raw_data.strip()
except:
return "ERROR"