-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"Documentation and refactoring class name "
- Loading branch information
1 parent
99a2188
commit f142ff7
Showing
12 changed files
with
386 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import yaml | ||
|
||
|
||
def _load_data_types(yaml_path="ressources/schema/objects/datatypes.yaml"): | ||
""" | ||
Load data types from a YAML file. | ||
Args: | ||
yaml_path (str): The path to the YAML file containing data type data. | ||
Returns: | ||
dict: A dictionary containing data type data. | ||
""" | ||
with open(yaml_path, 'r') as file: | ||
data_types_data = yaml.safe_load(file) | ||
return data_types_data | ||
|
||
|
||
class DataTypes: | ||
def __init__(self): | ||
""" | ||
Initialize a DataTypes object and load data types from a YAML file. | ||
""" | ||
self.data_types = _load_data_types() | ||
|
||
def get_data_type_value(self, data_type_name): | ||
""" | ||
Get the value of a specific data type. | ||
Args: | ||
data_type_name (str): The name of the data type to retrieve. | ||
Returns: | ||
str: The value of the data type, or None if the data type does not exist. | ||
""" | ||
return self.data_types.get(data_type_name, {}).get("value") | ||
|
||
|
||
def main(): | ||
""" | ||
Main function to demonstrate the usage of the DataTypes class. | ||
""" | ||
data_types = DataTypes() | ||
data_type_name = "anat" | ||
data_type = data_types.get_data_type_value(data_type_name) | ||
if data_type: | ||
print(f"Données de type '{data_type_name}':") | ||
print(data_type) | ||
else: | ||
print(f"Le type de données '{data_type_name}' n'existe pas.") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import sys | ||
from Createfile import CreatFile | ||
from Createdirectory import Createdirectory | ||
|
||
|
||
class Generator: | ||
def __init__(self, output, sub_id=1, session_id=1, modality=None): | ||
""" | ||
Initialize a Generator object. | ||
Args: | ||
output (str): The output folder path. | ||
sub_id (int): Subject ID. | ||
session_id (int): Session ID. | ||
modality (str, optional): The modality name. | ||
""" | ||
self.output = output | ||
self.modality = modality.strip() if modality else None | ||
if self.modality: | ||
self.directory_builder = Createdirectory(output, sub_id, session_id, self.modality) | ||
self.file_builder = CreatFile(output) | ||
self.generate() | ||
else: | ||
print("No modality provided. Please specify a modality.") | ||
|
||
def generate(self): | ||
"""Generate files and directories.""" | ||
self.directory_builder.build() | ||
self.file_builder.build() | ||
|
||
|
||
if __name__ == "__main__": | ||
output = input("Enter the output folder path: ").strip() | ||
if output: | ||
sub_id = input("Enter the subject ID (default is 1): ").strip() | ||
session_id = input("Enter the session ID (default is 1): ").strip() | ||
modality = input("Enter the modality (optional): ").strip() | ||
sub_id = int(sub_id) if sub_id.isdigit() else 1 | ||
session_id = int(session_id) if session_id.isdigit() else 1 | ||
generator = Generator(output, sub_id, session_id, modality) | ||
else: | ||
print("Output folder path is required.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.