@@ -4255,7 +4255,7 @@ def to_context(self):
42554255 return ret_value
42564256
42574257
4258- def camelize_string (src_str , delim = '_' ):
4258+ def camelize_string (src_str , delim = '_' , upper_camel = True ):
42594259 """
42604260 Transform snake_case to CamelCase
42614261
@@ -4265,11 +4265,22 @@ def camelize_string(src_str, delim='_'):
42654265 :type delim: ``str``
42664266 :param delim: indicator category.
42674267
4268+ :type upper_camel: ``bool``
4269+ :param upper_camel: When True then transforms string to camel case with the first letter capitalised
4270+ (for example: demisto_content to DemistoContent), otherwise the first letter will not be capitalised
4271+ (for example: demisto_content to demistoContent).
4272+
42684273 :return: A CammelCase string.
42694274 :rtype: ``str``
42704275 """
4276+ if not src_str : # empty string
4277+ return ""
42714278 components = src_str .split (delim )
4272- return '' .join (map (lambda x : x .title (), components ))
4279+ camelize_without_first_char = '' .join (map (lambda x : x .title (), components [1 :]))
4280+ if upper_camel :
4281+ return components [0 ].title () + camelize_without_first_char
4282+ else :
4283+ return components [0 ].lower () + camelize_without_first_char
42734284
42744285
42754286class IndicatorsTimeline :
@@ -5157,7 +5168,7 @@ def return_warning(message, exit=False, warning='', outputs=None, ignore_auto_ex
51575168 sys .exit (0 )
51585169
51595170
5160- def camelize (src , delim = ' ' ):
5171+ def camelize (src , delim = ' ' , upper_camel = True ):
51615172 """
51625173 Convert all keys of a dictionary (or list of dictionaries) to CamelCase (with capital first letter)
51635174
@@ -5167,6 +5178,11 @@ def camelize(src, delim=' '):
51675178 :type delim: ``str``
51685179 :param delim: The delimiter between two words in the key (e.g. delim=' ' for "Start Date"). Default ' '.
51695180
5181+ :type upper_camel: ``bool``
5182+ :param upper_camel: When True then transforms dictionary keys to camel case with the first letter capitalised
5183+ (for example: demisto_content to DemistoContent), otherwise the first letter will not be capitalised
5184+ (for example: demisto_content to demistoContent).
5185+
51705186 :return: The dictionary (or list of dictionaries) with the keys in CamelCase.
51715187 :rtype: ``dict`` or ``list``
51725188 """
@@ -5175,10 +5191,14 @@ def camelize_str(src_str):
51755191 if callable (getattr (src_str , "decode" , None )):
51765192 src_str = src_str .decode ('utf-8' )
51775193 components = src_str .split (delim )
5178- return '' .join (map (lambda x : x .title (), components ))
5194+ camelize_without_first_char = '' .join (map (lambda x : x .title (), components [1 :]))
5195+ if upper_camel :
5196+ return components [0 ].title () + camelize_without_first_char
5197+ else :
5198+ return components [0 ].lower () + camelize_without_first_char
51795199
51805200 if isinstance (src , list ):
5181- return [camelize (phrase , delim ) for phrase in src ]
5201+ return [camelize (phrase , delim , upper_camel = upper_camel ) for phrase in src ]
51825202 return {camelize_str (key ): value for key , value in src .items ()}
51835203
51845204
@@ -5249,21 +5269,30 @@ def replace_str(src_str):
52495269# ############################## REGEX FORMATTING end ###############################
52505270
52515271
5252- def underscoreToCamelCase (s ):
5272+ def underscoreToCamelCase (s , upper_camel = True ):
52535273 """
52545274 Convert an underscore separated string to camel case
52555275
52565276 :type s: ``str``
52575277 :param s: The string to convert (e.g. hello_world) (required)
52585278
5279+ :type upper_camel: ``bool``
5280+ :param upper_camel: When True then transforms dictionarykeys to camel case with the first letter capitalised
5281+ (for example: demisto_content to DemistoContent), otherwise the first letter will not be capitalised
5282+ (for example: demisto_content to demistoContent).
5283+
52595284 :return: The converted string (e.g. HelloWorld)
52605285 :rtype: ``str``
52615286 """
52625287 if not isinstance (s , STRING_OBJ_TYPES ):
52635288 return s
52645289
52655290 components = s .split ('_' )
5266- return '' .join (x .title () for x in components )
5291+ camel_without_first_char = '' .join (x .title () for x in components [1 :])
5292+ if upper_camel :
5293+ return components [0 ].title () + camel_without_first_char
5294+ else :
5295+ return components [0 ].lower () + camel_without_first_char
52675296
52685297
52695298def camel_case_to_underscore (s ):
0 commit comments