Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: client/dom/scripts/dartgenerator.py

Issue 9706084: Add conditional feature to templates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/dom/scripts/all_tests.py ('k') | client/dom/scripts/dartgenerator_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dom/scripts/dartgenerator.py
diff --git a/client/dom/scripts/dartgenerator.py b/client/dom/scripts/dartgenerator.py
index 6966f6b34771af4cee02d6d36482535bfcf33551..7e3d246ec89ce8dcb2be9c44ec308bb2091b3c2b 100755
--- a/client/dom/scripts/dartgenerator.py
+++ b/client/dom/scripts/dartgenerator.py
@@ -19,6 +19,7 @@ from systemhtml import *
from systeminterface import *
from systemnative import *
from systemwrapping import *
+from templateloader import TemplateLoader
_logger = logging.getLogger('dartgenerator')
@@ -282,7 +283,8 @@ class DartGenerator(object):
if 'htmlfrog' in systems:
html_system = HtmlFrogSystem(
TemplateLoader(self._template_dir,
- ['html/frog', 'html/impl', 'html', '']),
+ ['html/frog', 'html/impl', 'html', ''],
+ {'DARTIUM': False, 'FROG': True}),
self._database, self._emitters, self._output_dir, self)
html_system._interface_system = html_interface_system
@@ -291,7 +293,8 @@ class DartGenerator(object):
if 'htmldartium' in systems:
html_system = HtmlDartiumSystem(
TemplateLoader(self._template_dir,
- ['html/dartium', 'html/impl', 'html', '']),
+ ['html/dartium', 'html/impl', 'html', ''],
+ {'DARTIUM': True, 'FROG': False}),
self._database, self._emitters, self._output_dir, self)
html_system._interface_system = html_interface_system
@@ -543,44 +546,6 @@ def _PairUpAttributes(attributes):
# ------------------------------------------------------------------------------
-class TemplateLoader(object):
- """Loads template files from a path."""
-
- def __init__(self, root, subpaths):
- """Initializes loader.
-
- Args:
- root - a string, the directory under which the templates are stored.
- subpaths - a list of strings, subpaths of root in search order.
- """
- self._root = root
- self._subpaths = subpaths
- self._cache = {}
-
- def TryLoad(self, name):
- """Returns content of template file as a string, or None of not found."""
- if name in self._cache:
- return self._cache[name]
-
- for subpath in self._subpaths:
- template_file = os.path.join(self._root, subpath, name)
- if os.path.exists(template_file):
- template = ''.join(open(template_file).readlines())
- self._cache[name] = template
- return template
-
- return None
-
- def Load(self, name):
- """Returns contents of template file as a string, or raises an exception."""
- template = self.TryLoad(name)
- if template is not None: # Can be empty string
- return template
- raise Exception("Could not find template '%s' on %s / %s" % (
- name, self._root, self._subpaths))
-
-# ------------------------------------------------------------------------------
-
class DummyImplementationSystem(System):
"""Generates a dummy implementation for use by the editor analysis.
« no previous file with comments | « client/dom/scripts/all_tests.py ('k') | client/dom/scripts/dartgenerator_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698