Skip to content

Commit 9907434

Browse files
committed
test_custom_templates / replace jinja2 marcro with call to utils module
1 parent 8edfaa6 commit 9907434

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed
+4-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
""" Contains methods for accessing the API """
22

3-
{% macro snake_to_pascal_case(name) %}
4-
{%- for part in name.split('_') -%}
5-
{{ part | capitalize }}
6-
{%- endfor -%}
7-
{% endmacro %}
8-
93
from typing import Type
104
{% for tag, collection in endpoint_collections_by_tag %}
11-
from {{ package_name }}.api.{{ tag }} import {{ snake_to_pascal_case(tag) }}Endpoints
5+
from {{ package_name }}.api.{{ tag }} import {{ utils.pascal_case(tag) }}Endpoints
126
{% endfor %}
137

14-
class {{ snake_to_pascal_case(package_name) }}Api:
8+
class {{ utils.pascal_case(package_name) }}Api:
159
{% for tag, collection in endpoint_collections_by_tag %}
1610
@classmethod
17-
def {{ tag }}(cls) -> Type[{{ snake_to_pascal_case(tag) }}Endpoints]:
18-
return {{ snake_to_pascal_case(tag) }}Endpoints
11+
def {{ tag }}(cls) -> Type[{{ utils.pascal_case(tag) }}Endpoints]:
12+
return {{ utils.pascal_case(tag) }}Endpoints
1913
{% endfor %}
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
11
""" Contains methods for accessing the API Endpoints """
22

3-
{% macro snake_to_pascal_case(name) %}
4-
{%- for part in name.split('_') -%}
5-
{{ part | capitalize }}
6-
{%- endfor -%}
7-
{% endmacro %}
8-
9-
{% macro to_snake_name(name) %}
10-
{% set last_snakize = {'at': 0} %}
11-
{%- for part in name -%}
12-
{{ '_' if not loop.first and part in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' and (loop.index - last_snakize.at) > 1 and not last_snakize.update({'at': loop.index}) }}{{ part | lower }}
13-
{%- endfor -%}
14-
{% endmacro %}
15-
163
import types
174
{% for endpoint in endpoints %}
18-
from {{ package_name }}.api.{{ tag }} import {{ to_snake_name(endpoint.name) }}
5+
from {{ package_name }}.api.{{ tag }} import {{ utils.snake_case(endpoint.name) }}
196
{% endfor %}
207

21-
class {{ snake_to_pascal_case(tag) }}Endpoints:
8+
class {{ utils.pascal_case(tag) }}Endpoints:
229

2310
{% for endpoint in endpoints %}
2411

2512
@classmethod
26-
def {{ to_snake_name(endpoint.name) }}(cls) -> types.ModuleType:
13+
def {{ utils.snake_case(endpoint.name) }}(cls) -> types.ModuleType:
2714
{% if endpoint.description %}
2815
"""
2916
{{ endpoint.description }}
@@ -33,5 +20,5 @@ class {{ snake_to_pascal_case(tag) }}Endpoints:
3320
{{ endpoint.summary }}
3421
"""
3522
{% endif %}
36-
return {{ to_snake_name(endpoint.name) }}
23+
return {{ utils.snake_case(endpoint.name) }}
3724
{% endfor %}

0 commit comments

Comments
 (0)