def getSRTemplates(self): """ Returns a DisplayList with the available templates found in browser/samplinground/templates/ """ this_dir = os.path.dirname(os.path.abspath(__file__)) templates_dir = os.path.join(this_dir, self._TEMPLATES_DIR) tempath = '%s/%s' % (templates_dir, '*.pt') templates = [t.split('/')[-1] for t in glob.glob(tempath)] out = [] for template in templates: out.append({'id': template, 'title': template[:-3]}) for templates_resource in iterDirectoriesOfType( self._TEMPLATES_ADDON_DIR): prefix = templates_resource.__name__ templates = [ tpl for tpl in templates_resource.listDirectory() if tpl.endswith('.pt') ] for template in templates: out.append({ 'id': '{0}:{1}'.format(prefix, template), 'title': '{0} ({1})'.format(template[:-3], prefix), }) return out
def getAvailableFormats(self): """ Returns the available formats found in templates/reports """ this_dir = os.path.dirname(os.path.abspath(__file__)) templates_dir = os.path.join(this_dir, 'templates/reports') tempath = '%s/%s' % (templates_dir, '*.pt') templates = [t.split('/')[-1] for t in glob.glob(tempath)] out = [] for template in templates: out.append({'id': template, 'title': template[:-3]}) for templates_resource in iterDirectoriesOfType('reports'): prefix = templates_resource.__name__ templates = [tpl for tpl in templates_resource.listDirectory() if tpl.endswith('.pt')] for template in templates: out.append({ 'id': '{0}:{1}'.format(prefix, template), 'title': '{0} ({1})'.format(template[:-3], prefix), }) return out
def getWSTemplates(self): """ Returns a DisplayList with the available templates found in templates/worksheets """ this_dir = os.path.dirname(os.path.abspath(__file__)) templates_dir = os.path.join(this_dir, self._TEMPLATES_DIR) tempath = '%s/%s' % (templates_dir, '*.pt') templates = [t.split('/')[-1] for t in glob.glob(tempath)] out = [] for template in templates: out.append({'id': template, 'title': template[:-3]}) for templates_resource in iterDirectoriesOfType(self._TEMPLATES_ADDON_DIR): prefix = templates_resource.__name__ templates = [tpl for tpl in templates_resource.listDirectory() if tpl.endswith('.pt')] for template in templates: out.append({ 'id': '{0}:{1}'.format(prefix, template), 'title': '{0} ({1})'.format(template[:-3], prefix), }) return out
def getAvailableFormats(self): """ Returns the available formats found in templates/reports """ this_dir = os.path.dirname(os.path.abspath(__file__)) templates_dir = os.path.join(this_dir, 'templates/reports') tempath = '%s/%s' % (templates_dir, '*.pt') templates = [t.split('/')[-1] for t in glob.glob(tempath)] out = [] for template in templates: out.append({'id': template, 'title': template[:-3]}) for templates_resource in iterDirectoriesOfType('reports'): prefix = templates_resource.__name__ templates = [ tpl for tpl in templates_resource.listDirectory() if tpl.endswith('.pt') ] for template in templates: out.append({ 'id': '{0}:{1}'.format(prefix, template), 'title': '{0} ({1})'.format(template[:-3], prefix), }) return out