def render_docs(doc_list, file_type, use_markdown=False, source_is_repo_root=False): if source_is_repo_root: doc_path = os.path.join(currentdir) else: doc_path = docs_src docs_templates = PageTemplateLoader(doc_path, format="text") for doc_name in doc_list: template = docs_templates[ doc_name + ".pt"] # .pt is the conventional extension for chameleon page templates doc = template( registered_cargos=registered_cargos, registered_industries=registered_industries, registered_economies=registered_economies, economy_schemas=economy_schemas, incompatible_grfs=incompatible_grfs, global_constants=global_constants, makefile_args=makefile_args, git_info=git_info, metadata=metadata, utils=utils, doc_helper=DocHelper(), doc_name=doc_name, ) if use_markdown: # the doc might be in markdown format, if so we need to render markdown to html, and wrap the result in some boilerplate html markdown_wrapper = PageTemplateLoader( docs_src, format="text")["markdown_wrapper.pt"] doc = markdown_wrapper( content=markdown.markdown(doc), global_constants=global_constants, makefile_args=makefile_args, git_info=git_info, metadata=metadata, utils=utils, doc_helper=DocHelper(), doc_name=doc_name, ) if file_type == "html": subdir = "html" elif file_type == "css": subdir = os.path.join("html", "static", "css") else: subdir = "" # save the results of templating doc_file = codecs.open( os.path.join(docs_output_path, subdir, doc_name + "." + file_type), "w", "utf8", ) doc_file.write(doc) doc_file.close()
def main(target_lang, res_folder, out_tmx): eng_resx = os.path.join(res_folder, ENG_RESX_FILE) target_resx = os.path.join(res_folder, RESX_FILE_FMT.format(target_lang)) print("Using {} to create a TMX file {}".format(target_resx, out_tmx)) if not os.path.exists(eng_resx): print("File '{}' does not exist.".format(eng_resx)) return if not os.path.exists(target_resx): print("File '{}' does not exist.".format(target_resx)) return templates = PageTemplateLoader(os.path.abspath(TEMPLATE_DIR)) tmx_template = templates[TEMPLATE] doc = Document(target_resx) src_items = read_source(eng_resx) trans_units = build_trans_units(src_items, target_lang, target_resx) tmx_str = tmx_template(items=trans_units, document=doc) with open(out_tmx, 'w', encoding='utf8') as outfile: print(tmx_str, file=outfile)
class ChameleonTemplatePlugin(plugins.SimplePlugin): def __init__(self, bus, config): super(ChameleonTemplatePlugin, self).__init__(bus) self.config = config def start(self): self.bus.log('ChameleonTemplatePlugin: Starting template engine') loader_config = {} loader_search_path = self.config.get('loader.search_path') loader_default_extension = self.config.get('loader.default_extension') for (key, value) in self.config.iteritems(): key_without_prefix = key.rsplit('.')[-1] if key.startswith('chameleon.config.'): os.environ['CHAMELEON_%s' % key_without_prefix.upper()] = value elif key.startswith('loader.config.'): loader_config[key_without_prefix] = value from chameleon import PageTemplateLoader self.loader = PageTemplateLoader(loader_search_path, loader_default_extension, **loader_config) self.bus.subscribe('lookup-template', self.get_template) def stop(self): self.bus.log('ChameleonTemplatePlugin: Stopping template engine') self.bus.unsubscribe('lookup-template', self.get_template) def get_template(self, filename, format=None): return self.loader.load(filename, format)
def build_toc(toc_path): proot = os.path.join(os.path.dirname(__file__)) with tempfile.NamedTemporaryFile() as f: with tempfile.NamedTemporaryFile() as tf: templates_dir = os.path.join(proot, 'templates') with open(toc_path, 'r') as tp: body = asciidoc_to_html(tp.read()) tf.write(( # sidebar.pt '<metal:macro use-macro="load:{0:s}">' '<metal:slot fill-slot="toc">' '{1:s}' '</metal:slot>' '</metal:macro>').format( os.path.join(templates_dir, 'toc.pt'), body).encode()) tf.seek(0) templates = PageTemplateLoader([ templates_dir, os.path.dirname(tf.name), ]) tmpl = templates[tf.name] f.write(tmpl().encode()) f.seek(0) yield f
def render_docs_vehicle_details(consist, docs_output_path, consists): # imports inside functions are generally avoided # but PageTemplateLoader is expensive to import and causes unnecessary overhead for Pool mapping when processing docs graphics from chameleon import PageTemplateLoader docs_templates = PageTemplateLoader(docs_src, format="text") template = docs_templates["vehicle_details.pt"] doc_name = consist.id doc = template( consist=consist, consists=consists, global_constants=global_constants, registered_rosters=iron_horse.registered_rosters, makefile_args=makefile_args, git_info=git_info, base_lang_strings=base_lang_strings, metadata=metadata, utils=utils, doc_helper=DocHelper(), doc_name=doc_name, ) doc_file = codecs.open( os.path.join(docs_output_path, "html", doc_name + ".html"), "w", "utf8") doc_file.write(doc) doc_file.close()
def getTemplate(name): templates = PageTemplateLoader(os.path.join('templates'),'.pt') print(templates) return TemplateWrapper(templates[name], flask=flask, templates=templates, db=db, request=request)
def __init__(self, *args, **kwargs): from chameleon import PageTemplateLoader from chameleon.loader import TemplateLoader if (not kwargs and len(args) == 1 and isinstance(args[0], TemplateLoader)): self.loader = args[0] else: self.loader = PageTemplateLoader(*args, **kwargs)
def templated_report(**kwargs): import os path = os.path.dirname(__file__) from chameleon import PageTemplateLoader templates = PageTemplateLoader(os.path.join(path, "templates")) template = templates['report.pt'] return template(**kwargs)
def save_html_report(output_dir, smalitree, app_name, granularity): templates = PageTemplateLoader(config.templates_path) resources_dir = os.path.join(output_dir, '.resources') Utils2.copytree(config.html_resources_dir_path, resources_dir) class_template = templates['class.pt'] for cl in smalitree.classes: save_class(cl, class_template, output_dir, app_name, granularity) save_coverage(smalitree, templates, output_dir, app_name, granularity)
def __init__(self, config): super().__init__(config) self.output_path = Path(config.output_path) scribe_queue = self.ctx.socket(zmq.PULL) scribe_queue.hwm = 100 scribe_queue.connect(const.SCRIBE_QUEUE) self.register(scribe_queue, self.handle_index) self.db = DbClient(config) self.package_cache = None self.statistics = {} self.templates = PageTemplateLoader(search_path=[ pkg_resources.resource_filename(__name__, 'templates') ], default_extension='.pt')
class Templates(TemplatesBase): def __init__(self, dir): self.dir = dir self.loader = PageTemplateLoader(dir) def get(self, name, extension=None): # default the name to "home" if name is None: name = "home" elif extension is None and "." in name: # split name name, extension = name.split(".") src, filename = find_template(self.dir, name, extension) return RoundupPageTemplate(self.loader.load(src))
def global_init(template_folder: str, auto_reload=False, cache_init=True): global __templates, template_path if __templates and cache_init: return if not template_folder: msg = f'The template_folder must be specified.' raise FastAPIChameleonException(msg) if not os.path.isdir(template_folder): msg = f"The specified template folder must be a folder, it's not: {template_folder}" raise FastAPIChameleonException(msg) template_path = template_folder __templates = PageTemplateLoader(template_folder, auto_reload=auto_reload)
async def create_app(): app = web.Application(middlewares=[babel_middleware]) app.update(name='Testing aiohttp TAL') tal_loader = PageTemplateLoader( str(THIS_DIR / 'templates'), translate=translate, auto_reload=True # debugging ) aiohttp_tal.setup(app, loader=tal_loader) app.add_routes([web.static('/static', str(THIS_DIR / 'static'))]) app['static_root_url'] = '/static' app.router.add_get('/', index, name='index') app.router.add_get('/translation', translation, name='translation') return app
def start(self): self.bus.log("ChameleonTemplatePlugin: Starting template engine") loader_config = {} loader_search_path = self.config.get("loader.search_path") loader_default_extension = self.config.get("loader.default_extension") for (key, value) in self.config.iteritems(): key_without_prefix = key.rsplit(".")[-1] if key.startswith("chameleon.config."): os.environ["CHAMELEON_%s" % key_without_prefix.upper()] = value elif key.startswith("loader.config."): loader_config[key_without_prefix] = value self.loader = PageTemplateLoader(loader_search_path, loader_default_extension, **loader_config) self.bus.subscribe("lookup-template", self.get_template)
async def create_app(): app = web.Application() app.update(name='Testing aiohttp TAL') tal_loader = PageTemplateLoader( str(THIS_DIR / 'templates'), enable_data_attributes=True, # data-tal-* auto_reload=True # debugging ) aiohttp_tal.setup(app, loader=tal_loader) app.add_routes([web.static('/static', str(THIS_DIR / 'static'))]) app['static_root_url'] = '/static' app.router.add_get('/', index, name='index') app.router.add_get('/page', page, name='translation') return app
def __init__(self, propinquity_dir, supertree_output_dir, config_filepath): self.top_output_dir = supertree_output_dir self.propinquity_dir = propinquity_dir subprocess.call([ 'make', os.path.join(self.top_output_dir, 'assessments', 'summary.json') ]) templates_dir = os.path.join(propinquity_dir, 'doc', 'templates') self.templates = PageTemplateLoader(templates_dir) self.config = get_runtime_configuration(config_filepath) self.phylo_input = self.read_phylo_input() self.phylo_snapshot = self.read_phylo_snapshot() self.cleaned_ott = self.read_cleaned_ott() self.exemplified_phylo = self.read_exemplified_phylo() self.subproblem_solutions = self.read_subproblem_solutions() self.subproblems = self.read_subproblems() self.labelled_supertree = self.read_labelled_supertree() self.assessments = self.read_assessments()
def __init__(self, config): super().__init__(config) self.output_path = Path(config.output_path) scribe_queue = self.socket(transport.PULL, protocol=protocols.the_scribe) scribe_queue.hwm = 100 scribe_queue.bind(const.SCRIBE_QUEUE) self.register(scribe_queue, self.handle_index) self.db = DbClient(config, self.logger) self.package_cache = None self.statistics = {} with pkg_resources.resource_stream(__name__, 'default_libs.txt') as s: with io.TextIOWrapper(s, encoding='ascii') as t: self.default_libs = set(line.strip() for line in t) self.templates = PageTemplateLoader(search_path=[ pkg_resources.resource_filename(__name__, 'templates') ], default_extension='.pt')
def build_article(src_path, base_dir, toc=None): """Generates output html through master template via temporary file. This function creates named temporary file which is deleted after run. """ try: os.makedirs(base_dir) except FileExistsError: pass proot = os.path.join(os.path.dirname(__file__)) dst_path = os.path.join( base_dir, os.path.splitext(os.path.basename(src_path))[0] + '.html') with tempfile.NamedTemporaryFile() as tf: templates_dir = os.path.join(proot, 'templates') with open(src_path, 'r') as sf: args = [os.path.join(templates_dir, 'master.pt')] if toc: toc.seek(0) args.append(toc.read().decode()) args.append(asciidoc_to_html(sf.read())) tf.write(( # article.pt '<metal:macro use-macro="load:{0:s}">' '<metal:slot fill-slot="sidebar">' '{1:s}' '</metal:slot>' '<metal:slot fill-slot="content">' '<article>{2:s}</article>' '</metal:slot>' '</metal:macro>').format(*args).encode()) tf.seek(0) templates = PageTemplateLoader([ templates_dir, os.path.dirname(tf.name), ]) tmpl = templates[tf.name] with open(dst_path, 'w+') as df: df.write((tmpl(title='title', description='description')))
def render_docs(doc_list, file_type, docs_output_path, iron_horse, consists, use_markdown=False): # imports inside functions are generally avoided # but PageTemplateLoader is expensive to import and causes unnecessary overhead for Pool mapping when processing docs graphics from chameleon import PageTemplateLoader docs_templates = PageTemplateLoader(docs_src, format='text') for doc_name in doc_list: # .pt is the conventional extension for chameleon page templates template = docs_templates[doc_name + '.pt'] doc = template(consists=consists, global_constants=global_constants, registered_rosters=iron_horse.registered_rosters, makefile_args=makefile_args, base_lang_strings=base_lang_strings, metadata=metadata, utils=utils, doc_helper=DocHelper(), doc_name=doc_name) if use_markdown: # the doc might be in markdown format, if so we need to render markdown to html, and wrap the result in some boilerplate html markdown_wrapper = docs_templates['markdown_wrapper.pt'] doc = markdown_wrapper(content=markdown.markdown(doc), global_constants=global_constants, makefile_args=makefile_args, metadata=metadata, utils=utils, doc_helper=DocHelper(), doc_name=doc_name) if file_type == 'html': subdir = 'html' else: subdir = '' # save the results of templating doc_file = codecs.open( os.path.join(docs_output_path, subdir, doc_name + '.' + file_type), 'w', 'utf8') doc_file.write(doc) doc_file.close()
def start(self): self.bus.log('ChameleonTemplatePlugin: Starting template engine') loader_config = {} loader_search_path = self.config.get('loader.search_path') loader_default_extension = self.config.get('loader.default_extension') for (key, value) in self.config.iteritems(): key_without_prefix = key.rsplit('.')[-1] if key.startswith('chameleon.config.'): os.environ['CHAMELEON_%s' % key_without_prefix.upper()] = value elif key.startswith('loader.config.'): loader_config[key_without_prefix] = value from chameleon import PageTemplateLoader self.loader = PageTemplateLoader(loader_search_path, loader_default_extension, **loader_config) self.bus.subscribe('lookup-template', self.get_template)
def display_project_as_html(project, output): path = os.path.dirname(__file__) static_path = pathlib.Path(path) / 'static' templates = PageTemplateLoader(path) templates.registry userinfo = project.credentials def resolve_ref(ref_string): return get_model_obj_from_ref(ref_string, project) html_files = {} for tmpl in ['index.pt', 'accounts.pt', 'globalresources.pt', 'netenvs.pt', 'monitoring.pt']: fname = tmpl[:-2] + 'html' html_files[fname] = templates[tmpl]( project=project, userinfo=userinfo, resolve_ref=resolve_ref, templates=templates, output=output, ) # Environments envs_html = {} env_tmpl = templates['env.pt'] for netenv in project['netenv'].values(): for env in netenv.values(): envs_html[f'ne-{netenv.name}-{env.name}.html'] = env_tmpl( project=project, netenv=netenv, env=env, userinfo=userinfo, templates=templates, has_alarms=has_alarms, has_logs=has_logs, resolve_ref=resolve_ref, parent_obj=parent_obj, prefixed_name=prefixed_name, output=output, ) return static_path, html_files, envs_html
def __init__(self, **kwargs): super().__init__() self.library = PicroscopyLibrary(**kwargs) self.helpers = WebHelpers(self.library) self.clients = kwargs.get('clients', IPv4Network('0.0.0.0/0')) logging.info('Clients must be on network %s', self.clients) self.static_dir = os.path.abspath( os.path.normpath( kwargs.get('static_dir', os.path.join(HERE, 'static')))) logging.info('Static files: %s', self.static_dir) self.templates_dir = os.path.abspath( os.path.normpath( kwargs.get('templates_dir', os.path.join(HERE, 'templates')))) logging.info('Chameleon templates: %s', self.templates_dir) self.templates = PageTemplateLoader(self.templates_dir, default_extension='.pt') self.layout = self.templates['layout'] # No need to make flashes a per-session thing - it's a single user app! self.flashes = [] self.router = PathRouter() # XXX Add handler for exiting system # XXX Make exit code conditional? (upgrade/reboot/shutdown/etc.) self.router.add_routes([ url('/', self.do_template, kwargs={'page': 'library'}, name='home'), url('/{page}.html', self.do_template, name='template'), url('/view/{image}.html', self.do_template, kwargs={'page': 'image'}, name='view'), url('/static/{path:any}', self.do_static, name='static'), url('/images/{image}', self.do_image, name='image'), url('/thumbs/{image}', self.do_thumb, name='thumb'), url('/delete/{image}', self.do_delete, name='delete'), url('/config', self.do_config, name='config'), url('/reset', self.do_reset, name='reset'), url('/capture', self.do_capture, name='capture'), url('/download', self.do_download, name='download'), url('/send', self.do_send, name='send'), url('/logout', self.do_logout, name='logout'), ])
def build_index(src_path, base_dir, toc=None): try: os.makedirs(base_dir) except FileExistsError: pass proot = os.path.join(os.path.dirname(__file__)) dst_path = os.path.join(base_dir, 'index.html') with tempfile.NamedTemporaryFile() as tf: templates_dir = os.path.join(proot, 'templates') with open(src_path, 'r') as sf: args = [os.path.join(templates_dir, 'master.pt')] if toc: toc.seek(0) args.append(toc.read().decode()) args.append(asciidoc_to_html(sf.read())) tf.write(( # index.pt '<metal:macro use-macro="load:{0:s}">' '<metal:slot fill-slot="sidebar">' '{1:s}' '</metal:slot>' '<metal:slot fill-slot="content">' '<div class="content">{2:s}</div>' '</metal:slot>' '</metal:macro>').format(*args).encode()) tf.seek(0) templates = PageTemplateLoader([ templates_dir, os.path.dirname(tf.name), ]) tmpl = templates[tf.name] with open(dst_path, 'w+') as df: df.write((tmpl(title='title', description='description')))
def __init__(self, dir): self.dir = dir self.loader = PageTemplateLoader(dir)
currentdir = os.curdir from time import time import iron_horse import utils import global_constants from polar_fox import git_info # get args passed by makefile makefile_args = utils.get_makefile_args(sys) # chameleon used in most template cases from chameleon import PageTemplateLoader # setup the places we look for templates templates = PageTemplateLoader(os.path.join(currentdir, "src", "templates")) # setting up a cache for compiled chameleon templates can significantly speed up template rendering chameleon_cache_path = os.path.join(currentdir, global_constants.chameleon_cache_dir) if not os.path.exists(chameleon_cache_path): os.mkdir(chameleon_cache_path) os.environ["CHAMELEON_CACHE"] = chameleon_cache_path generated_files_path = iron_horse.generated_files_path def render_header_item_nml(header_item, consists): template = templates[header_item + ".pynml"] return utils.unescape_chameleon_output( template( consists=consists,
import shutil import os currentdir = os.curdir from time import time import sys sys.path.append(os.path.join('src')) # add to the module search path import codecs # used for writing files - more unicode friendly than standard open() module from chameleon import PageTemplateLoader # chameleon used in most template cases # setup the places we look for templates lang_templates = PageTemplateLoader( os.path.join(currentdir, 'src', 'lang_templates')) # get args passed by makefile makefile_args = utils.get_makefile_args(sys) lang_src = os.path.join(currentdir, 'src', 'lang') lang_dst = os.path.join(firs.generated_files_path, 'lang') if os.path.exists(lang_dst): shutil.rmtree(lang_dst) shutil.copytree(lang_src, lang_dst) hint_file = codecs.open( os.path.join(lang_dst, '_lang_files_here_are_generated.txt'), 'w', 'utf8') hint_file.write( "Don't edit the lang files here. They're generated by the build script. \n Edit the ones in lang_src instead." )
docs_src = os.path.join(currentdir, 'src', 'docs_templates') docs_output_path = os.path.join(currentdir, 'docs') if os.path.exists(docs_output_path): shutil.rmtree(docs_output_path) os.mkdir(docs_output_path) shutil.copy(os.path.join(docs_src, 'index.html'), docs_output_path) static_dir_src = os.path.join(docs_src, 'html', 'static') static_dir_dst = os.path.join(docs_output_path, 'html', 'static') shutil.copytree(static_dir_src, static_dir_dst) from chameleon import PageTemplateLoader # chameleon used in most template cases # setup the places we look for templates docs_templates = PageTemplateLoader(docs_src, format='text') import utils as utils import markdown # get args passed by makefile repo_vars = utils.get_repo_vars(sys) # get the strings from base lang file so they can be used in docs base_lang_strings = utils.parse_base_lang() import fish from ship import Trawler, MixinRefittableCapacity ships = fish.get_ships_in_buy_menu_order() # default sort for docs is by ship intro date
def getTemplate(name): templates = PageTemplateLoader('templates', '.pt') return TemplateWrapper(templates[name], flask=flask, templates=templates, displayName=displayName)
return authfunc(username, password) from mslib.mswms import mss_plot_driver from mslib.utils import get_projection_params # Logging the Standard Output, which will be added to the Apache Log Files logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(funcName)19s || %(message)s", datefmt="%Y-%m-%d %H:%M:%S") # Chameleon XMl template base_dir = os.path.abspath(os.path.dirname(__file__)) xml_template_location = os.path.join(base_dir, "xml_templates") templates = PageTemplateLoader( mss_wms_settings.__dict__.get("xml_template_location", xml_template_location)) class WMSServer(object): def __init__(self): """ init method for wms server """ data_access_dict = mss_wms_settings.data for key in data_access_dict: data_access_dict[key].setup() self.hsec_drivers = {} for key in data_access_dict:
def render_docs( doc_list, file_type, docs_output_path, iron_horse, consists, use_markdown=False, source_is_repo_root=False, ): if source_is_repo_root: doc_path = os.path.join(currentdir) else: doc_path = docs_src # imports inside functions are generally avoided # but PageTemplateLoader is expensive to import and causes unnecessary overhead for Pool mapping when processing docs graphics from chameleon import PageTemplateLoader docs_templates = PageTemplateLoader(doc_path, format="text") for doc_name in doc_list: # .pt is the conventional extension for chameleon page templates template = docs_templates[doc_name + ".pt"] doc = template( consists=consists, global_constants=global_constants, registered_rosters=iron_horse.registered_rosters, makefile_args=makefile_args, git_info=git_info, base_lang_strings=base_lang_strings, metadata=metadata, utils=utils, doc_helper=DocHelper(), doc_name=doc_name, ) if use_markdown: # the doc might be in markdown format, if so we need to render markdown to html, and wrap the result in some boilerplate html markdown_wrapper = PageTemplateLoader( docs_src, format="text")["markdown_wrapper.pt"] doc = markdown_wrapper( content=markdown.markdown(doc), consists=consists, global_constants=global_constants, makefile_args=makefile_args, git_info=git_info, metadata=metadata, utils=utils, doc_helper=DocHelper(), doc_name=doc_name, ) if file_type == "html": subdir = "html" else: subdir = "" # save the results of templating doc_file = codecs.open( os.path.join(docs_output_path, subdir, doc_name + "." + file_type), "w", "utf8", ) doc_file.write(doc) doc_file.close()
from chameleon import PageTemplateLoader import os import logging from wtforms import validators logger = logging.getLogger('wtforms_extras') path = os.path.dirname(__file__) templates = os.path.join(path, "templates") template_styles = { 'default': PageTemplateLoader(os.path.join(templates, "default")), 'bootstrap': PageTemplateLoader(os.path.join(templates, "bootstrap")), 'foundation': PageTemplateLoader(os.path.join(templates, "foundation")) } def _getLoader(style): try: template_loader = template_styles[style] except KeyError: logger.warn('error loading field style %s, loading default' % style) template_loader = template_styles['default'] return template_loader def _getTemplate(style, *names): loader = _getLoader(style) template = None for name in names: try:
FIRS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. FIRS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FIRS. If not, see <http://www.gnu.org/licenses/>. """ import os.path currentdir = os.curdir # add to the module search path src_path = os.path.join(currentdir, 'src') import utils as utils from chameleon import PageTemplateLoader # chameleon used in most template cases # setup the places we look for templates templates = PageTemplateLoader(os.path.join(src_path, 'templates'), format='text') industry_templates = PageTemplateLoader(os.path.join(src_path, 'industries'), format='text') from economies import registered_economies from cargos import registered_cargos class Cargo(object): """ Base class to hold cargos""" def __init__(self, id, **kwargs): self.id = id self.cargo_label = kwargs['cargo_label'] self.type_name = kwargs['type_name'] self.unit_name = kwargs['unit_name'] self.type_abbreviation = kwargs['type_abbreviation']
def _get_chameleon_templates(): template_path = os.path.join(app_path, 'templates') template_loader = PageTemplateLoader(template_path) return template_loader
#!/usr/bin/env python print "build_bandit.py" import os.path currentdir = os.curdir import sys sys.path.append(os.path.join('src')) # add to the module search path import codecs #used for writing files - more unicode friendly than standard open() module from chameleon import PageTemplateLoader # setup the places we look for templates templates = PageTemplateLoader(os.path.join(currentdir, 'src', 'templates'), format='text') lang_templates = PageTemplateLoader(os.path.join(currentdir, 'lang'), format='text') docs_templates = PageTemplateLoader(os.path.join(currentdir, 'docs'), format='text') # the parser handles config file formats; provides a custom utility function for parsing to a list import ConfigParser import re pattern = re.compile('\\d+$') #regular expressions magic: pattern of digits def config_option_to_list_of_ints(txt): result = [ ] # we always want at minimum an empty list here or other code will be sad
def load(self, config=None, state=None): """ """ PlugableProgram.load(self, config, state) self.templates = PageTemplateLoader(self.config.get("templates"))