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

Side by Side Diff: third_party/WebKit/Source/build/scripts/name_utilities.py

Issue 2589143003: Add 'get' prefix for Settings.in generated code. (Closed)
Patch Set: Only get prefix and no capitalization. Created 3 years, 11 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
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 E.g., 'SetURL' becomes 'setURL', but 'URLFoo' becomes 'urlFoo'. 53 E.g., 'SetURL' becomes 'setURL', but 'URLFoo' becomes 'urlFoo'.
54 """ 54 """
55 for acronym in ACRONYMS: 55 for acronym in ACRONYMS:
56 if name.startswith(acronym): 56 if name.startswith(acronym):
57 return name.replace(acronym, acronym.lower(), 1) 57 return name.replace(acronym, acronym.lower(), 1)
58 return name[0].lower() + name[1:] 58 return name[0].lower() + name[1:]
59 59
60 60
61 def upper_first(name): 61 def upper_first(name):
62 """Return name with first letter or initial acronym uppercased.""" 62 """Return name with first letter or initial acronym uppercased.
63 The acronym must have a capital letter following it to be considered.
64 """
63 for acronym in ACRONYMS: 65 for acronym in ACRONYMS:
64 if name.startswith(acronym.lower()): 66 if name.startswith(acronym.lower()):
65 return name.replace(acronym.lower(), acronym, 1) 67 if len(name) == len(acronym) or name[len(acronym)].isupper():
68 return name.replace(acronym.lower(), acronym, 1)
66 return upper_first_letter(name) 69 return upper_first_letter(name)
67 70
68 71
69 def upper_first_letter(name): 72 def upper_first_letter(name):
70 """Return name with first letter uppercased.""" 73 """Return name with first letter uppercased."""
71 if not name: 74 if not name:
72 return '' 75 return ''
73 return name[0].upper() + name[1:] 76 return name[0].upper() + name[1:]
74 77
75 78
(...skipping 21 matching lines...) Expand all
97 def enum_for_css_keyword(keyword): 100 def enum_for_css_keyword(keyword):
98 return 'CSSValue' + ''.join(camel_case(keyword)) 101 return 'CSSValue' + ''.join(camel_case(keyword))
99 102
100 103
101 def enum_for_css_property(property_name): 104 def enum_for_css_property(property_name):
102 return 'CSSProperty' + ''.join(camel_case(property_name)) 105 return 'CSSProperty' + ''.join(camel_case(property_name))
103 106
104 107
105 def enum_for_css_property_alias(property_name): 108 def enum_for_css_property_alias(property_name):
106 return 'CSSPropertyAlias' + camel_case(property_name) 109 return 'CSSPropertyAlias' + camel_case(property_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698