From: magnussonl Date: Thu, 9 Jul 2020 14:30:41 +0000 (+0200) Subject: Include j2 files in MANIFEST.in. X-Git-Tag: release-v9.0-start~1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F9375%2F1;p=osm%2FPLA.git Include j2 files in MANIFEST.in. Updated mechanism to load jinja templates. 1134 Change-Id: Idfbdb4de0f90e63b49c4b27d8d5190eb1fa069c3 Signed-off-by: magnussonl --- diff --git a/MANIFEST.in b/MANIFEST.in index 22675f6..60da55a 100755 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -16,5 +16,5 @@ # under the License. include requirements.txt include README.md -recursive-include osm_pla *.py *.sh *.yaml +recursive-include osm_pla *.py *.sh *.yaml *.j2 recursive-include devops-stages * diff --git a/osm_pla/placement/mznplacement.py b/osm_pla/placement/mznplacement.py index 56a448d..3dcf0bc 100755 --- a/osm_pla/placement/mznplacement.py +++ b/osm_pla/placement/mznplacement.py @@ -18,7 +18,7 @@ import itertools import pymzn from jinja2 import Environment -from jinja2.loaders import FileSystemLoader +from jinja2.loaders import FileSystemLoader, PackageLoader, ChoiceLoader class MznPlacementConductor(object): @@ -88,7 +88,8 @@ class MznModelGenerator(object): NsPlacementData objects. Uses jinja2 as templating language for the model ''' default_j2_template = "osm_pla_dynamic_template.j2" - template_search_path = ['osm_pla/placement', '../placement', '/pla/osm_pla/placement'] + template_search_path = ['osm_pla/placement', '../placement', '/pla/osm_pla/placement', + './', '/usr/lib/python3/dist-packages/osm_pla/placement'] def __init__(self, log): ''' @@ -111,7 +112,9 @@ class MznModelGenerator(object): def _load_jinja_template(self, template_name=default_j2_template): """loads the jinja template used for model generation""" - env = Environment(loader=FileSystemLoader(MznModelGenerator.template_search_path)) + loader1 = FileSystemLoader(MznModelGenerator.template_search_path) + loader2 = PackageLoader('osm_pla', '.') + env = Environment(loader=ChoiceLoader([loader1, loader2])) return env.get_template(template_name)