Skip to content

Commit 3dda8c5

Browse files
committed
Added dosctrings
1 parent e584d3f commit 3dda8c5

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

scripts/fill_masterdata.py

+38-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,38 @@ def __init__(self):
2525
)
2626

2727
def _format_class_name(self, code: str) -> str:
28+
"""
29+
Format the class name based on the `code` of the entity to follow Python snake case conventions.
30+
31+
Args:
32+
code (str): The code of the entity.
33+
34+
Returns:
35+
str: The formatted class name.
36+
"""
2837
if "." in code:
2938
code = code.split(".")[-1]
3039
return code.title().replace("_", "").replace("$", "")
3140

3241
def determine_parent_class(
3342
self, code: str, class_names: dict, default: str, lines: list
3443
) -> tuple:
35-
# Determine parent class
44+
"""
45+
Determine the parent class information of the entity based on its `code`. It returns
46+
the `parent_code` and `parent class`, as well as the `class_name` of the entity. The
47+
class will inherit from `parent_class`.
48+
49+
If the parent class does not exist, a note is added to the `lines` list for debugging purposes.
50+
51+
Args:
52+
code (str): The code of the entity.
53+
class_names (dict): A dictionary with the class names of the entities.
54+
default (str): The default parent class if the parent class does not exist.
55+
lines (list): A list of strings to be printed to the Python module.
56+
57+
Returns:
58+
tuple: The parent code, parent class, and class name of the entity.
59+
"""
3660
parent_code = ""
3761
if "." in code:
3862
parent_code = code.rsplit(".", 1)[0]
@@ -50,7 +74,19 @@ def determine_parent_class(
5074

5175
return parent_code, parent_class, class_name
5276

53-
def add_properties(self, entities, parent_code, data, lines):
77+
def add_properties(
78+
self, entities: dict, parent_code: str, data: str, lines: list
79+
) -> None:
80+
"""
81+
Add the properties of the entity to the `lines` list. The properties are added as
82+
`PropertyTypeAssignment` objects.
83+
84+
Args:
85+
entities (dict): The dictionary of entities (objects, collections, datasets, vocabularies).
86+
parent_code (code): The code of the parent class.
87+
data (str): The data information for the entity as obtained from openBIS.
88+
lines (list): A list of strings to be printed to the Python module.
89+
"""
5490
parent_properties = entities.get(parent_code, {}).get("properties", {}).keys()
5591
for prop_code, prop_data in data.get("properties", {}).items():
5692
# Skip "UNKNOWN" properties

0 commit comments

Comments
 (0)