Skip to content

Commit

Permalink
Now attempts to find template whether installed via 'git clone' or PyPi
Browse files Browse the repository at this point in the history
  • Loading branch information
jorvis committed Jun 22, 2017
1 parent b1a7d38 commit faee877
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions genbank/convert_gff3_to_gbk.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,20 @@
from biocode import utils, genbank, gff
from jinja2 import Environment, FileSystemLoader

PATH = os.path.dirname(os.path.abspath(__file__))
from pkg_resources import Requirement, resource_filename

# If biocode is installed via a GitHub checkout, the path to the template will be referential
template_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../data/genbank_flat_file_header.template')

# if referential discovery didn't work, this was probably a PyPi install. Use pkg_resources to find it instead.
if not os.path.isfile(template_path):
template_path = resource_filename(Requirement.parse("biocode"), "genbank_flat_file_header.template")

template_dir = os.path.dirname(template_path)

TEMPLATE_ENVIRONMENT = Environment(
autoescape=False,
loader=FileSystemLoader(os.path.join(PATH, '../data')),
loader=FileSystemLoader(template_dir),
trim_blocks=False)

def main():
Expand Down

0 comments on commit faee877

Please sign in to comment.