def process_input_file(inputfile):
""" Figure out whether we're being passed a file, a description of a file, or just raw JSON
"""
try:
jsraw = _get_json(inputfile)
except ValueError:
pass
else:
print jsraw
inputjson = json.loads(jsraw)
return inputjson
ext = inputfile.split('.')[-1]
if ext in ('js', 'json', 'yml', 'yaml'):
with open(inputfile, 'r') as infile:
inputjson = yaml.load(infile)
else:
with open(inputfile, 'r') as infile:
inputjson = {'filename': inputfile,
'content': infile.read()}
return inputjson
评论列表
文章目录