Chromium Code Reviews| Index: tools/json_schema_compiler/model.py |
| diff --git a/tools/json_schema_compiler/model.py b/tools/json_schema_compiler/model.py |
| index 967e9abec0041ef9d2d7c7de6378d7abbd7ee1e3..58fe5b9d37b0be59ac942ea238ee1a586b384b76 100644 |
| --- a/tools/json_schema_compiler/model.py |
| +++ b/tools/json_schema_compiler/model.py |
| @@ -410,6 +410,10 @@ class EnumValue(object): |
| self.name = json |
| self.description = None |
| + |
|
not at google - send to devlin
2014/05/14 16:18:14
no blank line
David Tseng
2014/05/14 18:11:31
Done.
|
| + def CamelName(self): |
| + return CamelName(self.name) |
| + |
| class _Enum(object): |
| """Superclass for enum types with a "name" field, setting up repr/eq/ne. |
| Enums need to do this so that equality/non-equality work over pickling. |
| @@ -483,6 +487,20 @@ def UnixName(name): |
| unix_name.append(c.lower()) |
| return ''.join(unix_name) |
|
not at google - send to devlin
2014/05/14 16:18:14
extra blank line
(the pep8 rule is 2 blank lines
David Tseng
2014/05/14 18:11:31
Done.
|
| +@memoize |
| +def CamelName(snake): |
| + ''' Converts a snake_cased_string to a camelCasedOne. ''' |
| + camel = [] |
| + i = 0 |
| + while i < len(snake): |
| + if snake[i] == '_' and (i + 1) < len(snake): |
| + camel.append(snake[i + 1].upper()) |
| + i += 2 |
| + else: |
| + camel.append(snake[i]) |
| + i += 1 |
| + return ''.join(camel) |
| + |
| def _StripNamespace(name, namespace): |
| if name.startswith(namespace.name + '.'): |