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

Unified Diff: tools/telemetry/telemetry/core/chrome/camel_case_converter.py

Issue 22889009: [telemetry] Move camel_case_converter out of chrome/ and use it for discover, as well. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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: tools/telemetry/telemetry/core/chrome/camel_case_converter.py
diff --git a/tools/telemetry/telemetry/core/chrome/camel_case_converter.py b/tools/telemetry/telemetry/core/chrome/camel_case_converter.py
deleted file mode 100644
index 868250cfa474f0c01719ef1308a5998eb82cae0c..0000000000000000000000000000000000000000
--- a/tools/telemetry/telemetry/core/chrome/camel_case_converter.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2013 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.
-
-class CamelCaseConverter(object):
- """Helper class which helps convert between the camel case and
- underscore naming conventions.
- """
-
- @classmethod
- def FromCamelCase(cls, obj):
- """Descends recursively into the object obj, converting all
- attributes' names from camelCase to underscore naming
- convention. Returns a newly allocated object of the same
- structure as the input. Handles nested structures of
- dictionaries and lists.
- """
-
- output = None
- if isinstance(obj, dict):
- output = dict()
- for k, v in obj.iteritems():
- output[cls.__CamelCaseToUnderscore(k)] = cls.FromCamelCase(v)
- elif isinstance(obj, list):
- output = []
- for item in obj:
- output.append(cls.FromCamelCase(item))
- else:
- output = obj
- return output
-
- @classmethod
- def __CamelCaseToUnderscore(cls, input_string):
- result = ""
- for c in input_string:
- if c.isupper():
- result += "_" + c.lower()
- else:
- result += c
- return result

Powered by Google App Engine
This is Rietveld 408576698