from .base import NameMixin, ID_CmpMixin
+TEMPLATE_DIRS = [
+ './templates',
+ '~/share/pyrisk/templates',
+ '/usr/share/pyrisk/templates/',
+ ]
+
class Template (NameMixin):
"""Setup regions for a particular world.
"""
TODO: explain template data format.
"""
- def __init__(self, template_dir='share/templates/'):
- self.template_dir = os.path.abspath(os.path.expanduser(template_dir))
+ def __init__(self, template_dirs=None):
+ if template_dirs == None:
+ template_dirs = TEMPLATE_DIRS
+ self.template_dirs = [os.path.abspath(os.path.expanduser(d))
+ for d in template_dirs]
def get(self, name):
region_pointlists,route_pointlists,continent_colors,line_colors, \
player_colors = \
return Template(name, regions, continent_colors, line_colors,
player_colors)
def _get_data(self, name):
- dirname = os.path.join(self.template_dir, name.lower())
- try:
- files = os.listdir(dirname)
- except IOError:
+ files = None
+ for d in self.template_dirs:
+ dirname = os.path.join(d, name.lower())
+ try:
+ files = os.listdir(dirname)
+ break
+ except IOError:
+ pass
+ if files == None:
return None
region_pointlists = {}
route_pointlists = {}
author='W. Trevor King',
author_email='wking@drexel.edu',
package_dir={'pyrisk': 'pyrisk'},
- data_files=recursive_file_list('share/pyrisk', 'share/'),
+ data_files=recursive_file_list('share/pyrisk/templates', 'templates'),
classifiers = [
'Development Status :: 3 - Alpha',
#'Environment :: Console',