Find templates if package is installed

Find templates if the package is installed on the system.

Change-Id: Iefe71e9ea3e43cf2fce55307d698600bed0ef9f3
This commit is contained in:
Andreas Jaeger 2016-04-14 20:52:56 +02:00
parent 16fef44f00
commit 14f7705d0c
1 changed files with 9 additions and 1 deletions

View File

@ -78,8 +78,16 @@ def get_options():
'dasbhoard files')
parser.add_argument('--template', default='single.txt',
help='Name of template')
# Find path to template_dir
# We need to support running with and without installation
if os.path.exists('templates'):
template_dir = 'templates'
else:
template_dir = os.path.join(sys.prefix, 'share',
'gerrit-dash-creator', 'templates')
parser.add_argument('--template-directory',
default="templates",
default=template_dir,
help='Directory to scan for template files')
parser.add_argument('--template-file', default=None,
help='Location of a specific template file')