Skip to content

Commit

Permalink
first ideas for entities
Browse files Browse the repository at this point in the history
  • Loading branch information
camillebrianceau committed Nov 20, 2024
1 parent 9b60aff commit 5890bc7
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/clinicaio/hello.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
__all__ = [
"greet",
"say_goodbye",
]


def greet(name: str):
"""Greet the person with provided name.
class Label(UserString):
def __init__(self, value: str):
super().__init__(self.validate(value))
Parameters
----------
name : str
The name of the person to greet.
"""
print(_build_greeting_message(name))

@classmethod
def validate(cls, value: str) -> str:
if value.isalnum():
return value
raise ValueError(
f"Label '{value}' is not a valid BIDS label: it must be composed only by letters and/or numbers."
)

class Index:
value: PositiveInt
length_as_string: PositiveInt # for padding with zeros

# Implement the constraint and the string representation taking into account the padding...
class Entity:
key: Label
value : Label | Index
def _build_greeting_message(name: str) -> str:
return f"Hello {name} !"

def __str__(self) -> str:
return f"{self.key}-{self.value}"

class SubjectEntity(Entity):
key = Label("sub")
def say_goodbye(name: str):
"""Say goodbye to the person with the provided name.
def __init__(self, value: str):
self.value = Label(value)
Parameters
----------
name : str
The name of the person to say goodbye to.
"""
print(_build_good_bye_message(name))

...

def _build_good_bye_message(name: str) -> str:
return f"Goodbye {name} !"

0 comments on commit 5890bc7

Please sign in to comment.