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

Side by Side Diff: components/wug/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: Fixed problems with component build. 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import argparse
6 import os.path
7 import re
8
9 def CreateArgumentParser():
10 parser = argparse.ArgumentParser()
11 parser.add_argument('declaration', help='Path to declaration file.')
12 parser.add_argument('--root', default='.', help='Path to src/ dir.')
13 parser.add_argument('--destination',
14 help='Root directory for generated files.')
15 return parser
16
17 def ToUpperCamelCase(underscore_name):
18 return re.sub(r'(?:_|^)(.)', lambda m: m.group(1).upper(), underscore_name)
19
20 def ToLowerCamelCase(underscore_name):
21 return re.sub(r'_(.)', lambda m: m.group(1).upper(), underscore_name)
22
23 def PathToIncludeGuard(path):
24 return re.sub(r'[/.]', '_', path.upper()) + '_'
25
26 def CreateDirIfNotExists(path):
27 if not os.path.isdir(path):
28 if os.path.exists(path):
29 raise Exception('%s exists and is not a directory.' % path)
30 os.makedirs(path)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698