Skip to content

Commit

Permalink
更新model_name抽取方式 (#657)
Browse files Browse the repository at this point in the history
* 更新model_name抽取方式

* update

* update

* update

* update

---------

Co-authored-by: yinjiaqi <[email protected]>
  • Loading branch information
C9luster and yinjiaqi authored Dec 12, 2024
1 parent 5138b79 commit 214c5eb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/utils/json_schema_to_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


NON_ALPHANUMERIC = re.compile(r"[^a-zA-Z0-9]+")
STARTS_WITH_NUMBER = re.compile(r'[0-9]+')
UPPER_CAMEL_CASE = re.compile(r"[A-Z][a-zA-Z0-9]+")
LOWER_CAMEL_CASE = re.compile(r"[a-z][a-zA-Z0-9]+")

Expand All @@ -22,7 +23,7 @@ class BadJsonSchema(Exception):

def _to_camel_case(name: str) -> str:
if any(NON_ALPHANUMERIC.finditer(name)):
return "".join(term.lower().title() for term in NON_ALPHANUMERIC.split(name))
return "".join(term.lower().title() if not STARTS_WITH_NUMBER.match(term) else term.lower() for term in NON_ALPHANUMERIC.split(name))
if UPPER_CAMEL_CASE.match(name):
return name
if LOWER_CAMEL_CASE.match(name):
Expand Down

0 comments on commit 214c5eb

Please sign in to comment.