mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 20:31:35 +00:00
Fix Chrome schema enum processing (#1582)
Prefix should not include anything after ENUM_
```
name: RollbackToTargetVersionEnum
value:
name: ROLLBACK_TO_TARGET_VERSION_ENUM_ROLLBACK_DISABLED
number: 1
name: ROLLBACK_TO_TARGET_VERSION_ENUM_ROLLBACK_AND_RESTORE_IF_POSSIBLE
number: 3
```
This commit is contained in:
@@ -167,7 +167,7 @@ def build_schemas(svc=None, sfilter=None):
|
|||||||
for an_enum in schema['definition']['enumType']:
|
for an_enum in schema['definition']['enumType']:
|
||||||
if an_enum['name'] == type_name:
|
if an_enum['name'] == type_name:
|
||||||
setting_dict['enums'] = [enum['name'] for enum in an_enum['value']]
|
setting_dict['enums'] = [enum['name'] for enum in an_enum['value']]
|
||||||
setting_dict['enum_prefix'] = utils.commonprefix(setting_dict['enums'])
|
setting_dict['enum_prefix'] = utils.commonprefix(setting_dict['enums'], True)
|
||||||
prefix_len = len(setting_dict['enum_prefix'])
|
prefix_len = len(setting_dict['enum_prefix'])
|
||||||
setting_dict['enums'] = [enum[prefix_len:] for enum \
|
setting_dict['enums'] = [enum[prefix_len:] for enum \
|
||||||
in setting_dict['enums'] \
|
in setting_dict['enums'] \
|
||||||
|
|||||||
@@ -96,9 +96,13 @@ class _DeHTMLParser(HTMLParser):
|
|||||||
re.sub(r'\n +', '\n', ''.join(self.__text))).strip()
|
re.sub(r'\n +', '\n', ''.join(self.__text))).strip()
|
||||||
|
|
||||||
|
|
||||||
def commonprefix(m):
|
def commonprefix(m, checkEnum=False):
|
||||||
'''Given a list of strings m, return string which is prefix common to all'''
|
'''Given a list of strings m, return string which is prefix common to all'''
|
||||||
s1 = min(m)
|
s1 = min(m)
|
||||||
|
if checkEnum:
|
||||||
|
loc = s1.find('ENUM_')
|
||||||
|
if loc > 0:
|
||||||
|
return s1[:loc+5]
|
||||||
s2 = max(m)
|
s2 = max(m)
|
||||||
for i, c in enumerate(s1):
|
for i, c in enumerate(s1):
|
||||||
if c != s2[i]:
|
if c != s2[i]:
|
||||||
|
|||||||
Reference in New Issue
Block a user