mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
mssgen: preserve existing camel cases
an edge case like MultifundchannelChannel_idsChannel_type was previously converted to MultifundchannelChannelIdschannelType instead of the correct MultifundchannelChannelIdsChannelType
This commit is contained in:
parent
c4edec8e22
commit
4d306e2691
1 changed files with 9 additions and 2 deletions
|
@ -362,8 +362,15 @@ class GrpcConverterGenerator(IGenerator):
|
|||
def to_camel_case(self, snake_str):
|
||||
components = snake_str.split('_')
|
||||
# We capitalize the first letter of each component except the first one
|
||||
# with the 'title' method and join them together.
|
||||
return components[0] + ''.join(x.title() for x in components[1:])
|
||||
# with the 'capitalize' method and join them together, while preserving
|
||||
# existing camel cases.
|
||||
camel_case = components[0]
|
||||
for word in components[1:]:
|
||||
if not word.isupper():
|
||||
camel_case += word[0].upper() + word[1:]
|
||||
else:
|
||||
camel_case += word.capitalize()
|
||||
return camel_case
|
||||
|
||||
def generate_requests(self, service):
|
||||
for meth in service.methods:
|
||||
|
|
Loading…
Add table
Reference in a new issue