| OLD | NEW |
| (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) | |
| OLD | NEW |