Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def plot_geo(geo, coastline, symbol, legend, title):
with NamedTemporaryFile(suffix=".png") as png, NamedTemporaryFile(
delete=False, suffix=".pdf"
) as pdf:
png_obj = mv.png_output(output_name=png.name.replace(".png", ""))
mv.setoutput(png_obj)
mv.plot(coastline, symbol, legend, title, geo)
pdf_obj = mv.pdf_output(output_name=pdf.name.replace(".pdf", ""))
mv.setoutput(pdf_obj)
mv.plot(coastline, symbol, legend, title, geo)
os.chmod(pdf.name, 0o444)
with open(png.name.replace(".png", ".1.png"), "rb") as img:
return {"preview": b64encode(img.read()).decode(), "pdf": pdf.name}
def plot_geo(geo, coastline, symbol, legend, title):
with NamedTemporaryFile(suffix=".png") as png, NamedTemporaryFile(
delete=False, suffix=".pdf"
) as pdf:
png_obj = mv.png_output(output_name=png.name.replace(".png", ""))
mv.setoutput(png_obj)
mv.plot(coastline, symbol, legend, title, geo)
pdf_obj = mv.pdf_output(output_name=pdf.name.replace(".pdf", ""))
mv.setoutput(pdf_obj)
mv.plot(coastline, symbol, legend, title, geo)
os.chmod(pdf.name, 0o444)
with open(png.name.replace(".png", ".1.png"), "rb") as img:
return {"preview": b64encode(img.read()).decode(), "pdf": pdf.name}