Skip to content

Commit

Permalink
fixed bug with curly braces in template. code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbrandyn committed Jan 24, 2024
1 parent 6dfe6fb commit f14a6e6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions plotting/scriptGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def generatePython(url: str, plot_type: str, script_Type: str) -> BytesIO:
template = str(f.read())

if script_Type == "plot":
template = template.format(q=query, p=plot_type, var=var, f=fname+' + ".png"')
template = template.format(q=query, p=plot_type, var=var, f=fname)
elif script_Type == "csv":
template = template.format(q=query, p=plot_type, var=var, f=fname+' + ".csv"')
template = template.format(q=query, p=plot_type, var=var, f=fname)
else:
template = template.format(q=query, var=var, f=fname)

Expand Down
2 changes: 1 addition & 1 deletion plotting/templates/python_csv_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def requestFile():
dump = data_file.raw
# change this if you want a different save location
location = os.getcwd()
fname = {f}
fname = {f} + ".png"
with open(fname, "wb") as location:
print('Saving File')
shutil.copyfileobj(dump, location)
Expand Down
4 changes: 2 additions & 2 deletions plotting/templates/python_plot_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def requestFile():

# Assemble full request
base_url = "https://navigator.oceansdata.ca/api/v2.0/plot/{p}?"
url = base_url + urlencode({"query": json.dumps(query)}) + "&format=png&size=10x7&dpi=" + str(dpi)
url = base_url + urlencode({{"query": json.dumps(query)}}) + "&format=png&size=10x7&dpi=" + str(dpi)
print(url)


#Open URL and save response
with closing(urlopen(url)) as f:
img = Image.open(f)
fname = {f}
fname = {f} + ".png"
print("Saving as " + fname + " and exiting...")
img.save(fname , "PNG")

Expand Down

0 comments on commit f14a6e6

Please sign in to comment.