Add an UMA stat to be able to see if the User pods are show on start screen,
[chromium-blink-merge.git] / components / webui_generator / generator / util.py
blob28a20db448091b53c5e0962d53107507c93df51e
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.
5 import argparse
6 import os.path
7 import re
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
17 def ToUpperCamelCase(underscore_name):
18 return re.sub(r'(?:_|^)(.)', lambda m: m.group(1).upper(), underscore_name)
20 def ToLowerCamelCase(underscore_name):
21 return re.sub(r'_(.)', lambda m: m.group(1).upper(), underscore_name)
23 def PathToIncludeGuard(path):
24 return re.sub(r'[/.]', '_', path.upper()) + '_'
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)