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

Unified Diff: components/webui_generator/generator/util.py

Issue 928163002: Initial implementation of WebUI generator (WUG) toolkit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 10 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
Index: components/webui_generator/generator/util.py
diff --git a/components/webui_generator/generator/util.py b/components/webui_generator/generator/util.py
new file mode 100644
index 0000000000000000000000000000000000000000..28a20db448091b53c5e0962d53107507c93df51e
--- /dev/null
+++ b/components/webui_generator/generator/util.py
@@ -0,0 +1,30 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import argparse
+import os.path
+import re
+
+def CreateArgumentParser():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('declaration', help='Path to declaration file.')
+ parser.add_argument('--root', default='.', help='Path to src/ dir.')
+ parser.add_argument('--destination',
+ help='Root directory for generated files.')
+ return parser
+
+def ToUpperCamelCase(underscore_name):
+ return re.sub(r'(?:_|^)(.)', lambda m: m.group(1).upper(), underscore_name)
+
+def ToLowerCamelCase(underscore_name):
+ return re.sub(r'_(.)', lambda m: m.group(1).upper(), underscore_name)
+
+def PathToIncludeGuard(path):
+ return re.sub(r'[/.]', '_', path.upper()) + '_'
+
+def CreateDirIfNotExists(path):
+ if not os.path.isdir(path):
+ if os.path.exists(path):
+ raise Exception('%s exists and is not a directory.' % path)
+ os.makedirs(path)
« no previous file with comments | « components/webui_generator/generator/html_view.py ('k') | components/webui_generator/generator/view_model.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698