-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b60aff
commit 5890bc7
Showing
1 changed file
with
25 additions
and
25 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 |
---|---|---|
@@ -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} !" |