Skip to content

Commit

Permalink
render based on stem of name
Browse files Browse the repository at this point in the history
  • Loading branch information
hmacdope committed Jun 17, 2024
1 parent ef602eb commit 5982123
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion minimal_molview/render.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import argparse
from jinja2 import Template
from pathlib import Path

from minimal_molview.templates.resources import HTML_TEMPLATE

def render(pdb_file, output_file):
Expand All @@ -15,6 +17,10 @@ def render(pdb_file, output_file):
template_str = open(HTML_TEMPLATE).read()
template = Template(template_str)

if output_file is None:
# take stem of pdb_file and append .html
output_file = Path(pdb_file).stem + ".html"

with open(output_file, "wt") as fout:
fout.write(template.render(data))

Expand All @@ -23,7 +29,7 @@ def render(pdb_file, output_file):
def main():
parser = argparse.ArgumentParser(description="Render PDB file into HTML using Jinja2 template.")
parser.add_argument("pdb_file", type=str, help="Input PDB file")
parser.add_argument("-o", "--output", type=str, default="render.html",
parser.add_argument("-o", "--output", type=str, default=None,
help="Output HTML file (default: render.html)")
args = parser.parse_args()
render(args.pdb_file, args.output)
Expand Down

0 comments on commit 5982123

Please sign in to comment.