|
39 | 39 | from .helpers import wasm_type_from_image_type, image_type_from_wasm_type |
40 | 40 | from .helpers import wasm_type_from_mesh_type, mesh_type_from_wasm_type, python_to_js |
41 | 41 | from .helpers import wasm_type_from_pointset_type, pointset_type_from_wasm_type |
| 42 | +from .helpers import snake_to_camel_case |
42 | 43 |
|
43 | 44 | from .xarray import xarray_from_image, image_from_xarray |
44 | 45 |
|
@@ -1552,17 +1553,6 @@ def search(s: str, case_sensitive: bool = False) -> List[str]: # , fuzzy=True): |
1552 | 1553 | return res |
1553 | 1554 |
|
1554 | 1555 |
|
1555 | | -def _snake_to_camel(keyword: str): |
1556 | | - # Helpers for set_inputs snake case to CamelCase keyword argument conversion |
1557 | | - _snake_underscore_re = re.compile("(_)([a-z0-9A-Z])") |
1558 | | - |
1559 | | - def _underscore_upper(match_obj): |
1560 | | - return match_obj.group(2).upper() |
1561 | | - |
1562 | | - camel = keyword[0].upper() |
1563 | | - if _snake_underscore_re.search(keyword[1:]): |
1564 | | - return camel + _snake_underscore_re.sub(_underscore_upper, keyword[1:]) |
1565 | | - return camel + keyword[1:] |
1566 | 1556 |
|
1567 | 1557 |
|
1568 | 1558 | def set_inputs( |
@@ -1656,7 +1646,7 @@ def SetInputs(self, *args, **kargs): |
1656 | 1646 | # (Ex: itk.ImageFileReader.UC2.New(SetFileName='image.png')) |
1657 | 1647 | if attribName not in ["auto_progress", "template_parameters"]: |
1658 | 1648 | if attribName.islower(): |
1659 | | - attribName = _snake_to_camel(attribName) |
| 1649 | + attribName = snake_to_camel_case(attribName) |
1660 | 1650 | attrib = getattr(new_itk_object, "Set" + attribName) |
1661 | 1651 |
|
1662 | 1652 | # Do not use try-except mechanism as this leads to |
@@ -2162,7 +2152,7 @@ def ipython_kw_matches(text: str): |
2162 | 2152 | namespace = split_name_parts[:-1] |
2163 | 2153 | function_name = split_name_parts[-1] |
2164 | 2154 | # Find corresponding object name |
2165 | | - object_name = _snake_to_camel(function_name) |
| 2155 | + object_name = snake_to_camel_case(function_name) |
2166 | 2156 | # Check that this object actually exists |
2167 | 2157 | try: |
2168 | 2158 | object_callable_match = ".".join(namespace + [object_name]) |
|
0 commit comments