diff --git a/cognite/pygen/_core/templates/typed_classes.py.jinja b/cognite/pygen/_core/templates/typed_classes.py.jinja index 50fe318f4..652b03056 100644 --- a/cognite/pygen/_core/templates/typed_classes.py.jinja +++ b/cognite/pygen/_core/templates/typed_classes.py.jinja @@ -25,10 +25,9 @@ class {{ cls.typed_properties_name }}:{% for field in cls.container_fields_sort class {{ cls.read_name }}Apply({{ cls.typed_properties_name }}, {{ cls.typed_write_bases_classes }}): """This represents the writing format of {{ cls.doc_name }}. - It is used to when data is written to CDF.{% if cls.description %} - + It is used to when data is written to CDF. +{% if cls.description %} {{ cls.description }}{% endif %} - Args: space: The space where the node is located. external_id: The external id of the {{ cls.doc_name }}.{% for field in cls.container_fields_sorted() %} @@ -58,10 +57,9 @@ class {{ cls.read_name }}Apply({{ cls.typed_properties_name }}, {{ cls.typed_wri class {{ cls.read_name }}({{ cls.typed_properties_name }}, {{ cls.typed_read_bases_classes }}): """This represents the reading format of {{ cls.doc_name }}. - It is used to when data is read from CDF.{% if cls.description %} - + It is used to when data is read from CDF. +{% if cls.description %} {{ cls.description }}{% endif %} - Args: space: The space where the node is located. external_id: The external id of the {{ cls.doc_name }}. @@ -112,10 +110,9 @@ class {{ cls.typed_properties_name }}:{% for field in cls.container_fields_sort class {{ cls.read_name }}Apply({{ cls.typed_properties_name }}, {{ cls.typed_write_bases_classes }}): """This represents the writing format of {{ cls.doc_name }}. - It is used to when data is written to CDF.{% if cls.description %} - + It is used to when data is written to CDF. +{% if cls.description %} {{ cls.description }}{% endif %} - Args: space: The space where the node is located. external_id: The external id of the {{ cls.doc_name }}. @@ -150,10 +147,9 @@ class {{ cls.read_name }}Apply({{ cls.typed_properties_name }}, {{ cls.typed_wri class {{ cls.read_name }}({{ cls.typed_properties_name }}, {{ cls.typed_read_bases_classes }}): """This represents the reading format of {{ cls.doc_name }}. - It is used to when data is read from CDF.{% if cls.description %} - + It is used to when data is read from CDF. +{% if cls.description %} {{ cls.description }}{% endif %} - Args: space: The space where the node is located. external_id: The external id of the {{ cls.doc_name }}. diff --git a/cognite/pygen/utils/text.py b/cognite/pygen/utils/text.py index 3eb64c345..14cfabeb0 100644 --- a/cognite/pygen/utils/text.py +++ b/cognite/pygen/utils/text.py @@ -210,9 +210,17 @@ def to_words(string: str, pluralize: bool = False, singularize: bool = False): >>> to_words('APM_Activities', singularize=True) 'apm activity' """ - return to_snake(string, pluralize, singularize).replace("_", " ") + words = to_snake(string, pluralize, singularize).replace("_", " ") + for word, fix in _SPECIAL_WORD_FIXES.items(): + words = words.replace(word, fix) + return words +_SPECIAL_WORD_FIXES = { + "cognite": "Cognite", + " 3 d ": " 3D ", +} + # These are words which are not pluralized as we want to by inflect # Fox example, "person" becomes "people" instead of "persons", which is more grammatically correct, however, # "persons" is more consistent with the rest of the API.