Skip to content

Commit b31d347

Browse files
authored
Dom new (#148)
* updating docstrings
1 parent d2360ab commit b31d347

File tree

8 files changed

+42
-42
lines changed

8 files changed

+42
-42
lines changed

ptmd/database/models/file.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ def __validate_time(self, at: str | None, field: str) -> datetime:
198198
""" Validate the time of the shipment or reception of the file to make sure it is after the start and end date
199199
of the collection steps.
200200
201-
:@param at: the date the samples were shipped
202-
:@param field: the field to be validated
203-
:@return: the date the samples were shipped
201+
:param at: the date the samples were shipped
202+
:param field: the field to be validated
203+
:return: the date the samples were shipped
204204
205-
:@raise ValueError: if the date is before the start or end date of the collection steps
205+
:raise ValueError: if the date is before the start or end date of the collection steps
206206
"""
207207
start_date: datetime = datetime.strptime(self.start_date.strftime('%Y-%m-%d'), '%Y-%m-%d')
208208
end_date: datetime = datetime.strptime(self.end_date.strftime('%Y-%m-%d'), '%Y-%m-%d')

ptmd/database/models/token_blocklist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ def __init__(self, jti: str):
2020

2121
@jwt.token_in_blocklist_loader
2222
def check_if_token_revoked(jwt_header: dict, jwt_payload: dict) -> bool:
23-
""" Check if a JWT exists in the database blocklist
23+
"""Check if a JWT exists in the database blocklist
2424
25-
@param jwt_header: JWT header
26-
@param jwt_payload: JWT payload
25+
:param jwt_header: JWT header
26+
:param jwt_payload: JWT payload
2727
"""
2828
return session.query(TokenBlocklist.id).filter_by(jti=jwt_payload["jti"]).scalar() is not None # type: ignore

ptmd/database/queries/files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def get_shipped_file(species: str, batch: str) -> File | None: # pragma: no cov
8383
:param batch: the batch of the file
8484
:return: the first received file with the given batch and species if it exists or None
8585
86-
@note: This function is excluded from coverage report because it is just a wrapper around a database query
86+
:note: This function is excluded from coverage report because it is just a wrapper around a database query
8787
"""
8888
return File.query.join(Organism).filter(
8989
Organism.ptox_biosystem_name == species,

ptmd/database/queries/users.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
def login_user(username: str, password: str) -> tuple[Response, int]:
1515
""" Login a user and return a JWT token. The username and password are retrieved from the request body.
1616
17-
@param username
18-
@param password
19-
@return: Response, int: the response message and the response code
17+
:param username
18+
:param password
19+
:return: Response, int: the response message and the response code
2020
"""
2121
raw_user = User.query.filter(User.username == username).first()
2222
user = dict(raw_user) if raw_user and raw_user.validate_password(password) else None

ptmd/lib/creator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
""" This module contains the Model class and functions that, given a list of fields, will generate the dataframe and
22
ISA objects.
33
4-
@author: Terazus (D. Batista)
4+
:author: Terazus (D. Batista)
55
"""
66
from .core import DataframeCreator

ptmd/lib/email/core.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
def send_confirmation_mail(username: str, email: str, token: str) -> str:
2323
""" Send the account activation email to the user.
2424
25-
@param username: the name of the user
26-
@param email: the email of the user
27-
@param token: the token to be used to activate the account
28-
@return: the message sent to the user
25+
:param username: the name of the user
26+
:param email: the email of the user
27+
:param token: the token to be used to activate the account
28+
:return: the message sent to the user
2929
"""
3030
service: Any = build('gmail', 'v1', credentials=Credentials.from_authorized_user_file(get_config()))
3131
message: MIMEMultipart = build_email_core(title='PTMD - Account activation', email=email)
@@ -36,9 +36,9 @@ def send_confirmation_mail(username: str, email: str, token: str) -> str:
3636
def send_validated_account_mail(username: str, email: str) -> str:
3737
""" Send the notification to the user that the account is now active.
3838
39-
@param username: the name of the user
40-
@param email: the email of the user
41-
@return: the message sent to the user
39+
:param username: the name of the user
40+
:param email: the email of the user
41+
:return: the message sent to the user
4242
"""
4343
service: Any = build('gmail', 'v1', credentials=Credentials.from_authorized_user_file(get_config()))
4444
message: MIMEMultipart = build_email_core(title='PTMD - Your account is now active', email=email)
@@ -49,8 +49,8 @@ def send_validated_account_mail(username: str, email: str) -> str:
4949
def send_validation_mail(user: object) -> str:
5050
""" Send the notification to the admin that a user account needs activation.
5151
52-
@param user: the User class to be used to get the user information
53-
@return: the message sent to the user
52+
:param user: the User class to be used to get the user information
53+
:return: the message sent to the user
5454
"""
5555
service: Any = build('gmail', 'v1', credentials=Credentials.from_authorized_user_file(get_config()))
5656
message: MIMEMultipart = build_email_core(title='PTMD - An account needs to be activated', email=ADMIN_EMAIL)
@@ -61,9 +61,9 @@ def send_validation_mail(user: object) -> str:
6161
def build_email_core(title: str, email: str) -> MIMEMultipart:
6262
""" Build the core of the email and return a MIMEMultipart object.
6363
64-
@param title: the title of the email
65-
@param email: the email of the user
66-
@return: the core of the email
64+
:param title: the title of the email
65+
:param email: the email of the user
66+
:return: the core of the email
6767
"""
6868
message: MIMEMultipart = MIMEMultipart()
6969
message['Subject'] = title
@@ -75,9 +75,9 @@ def build_email_core(title: str, email: str) -> MIMEMultipart:
7575
def send_email(message: MIMEMultipart, service: Any, body: str) -> str:
7676
""" Send the email to the user.
7777
78-
@param message: the MIMEMultipart object to be used to send the email
79-
@param service: the service to be used to send the email
80-
@param body: the body of the email
78+
:param message: the MIMEMultipart object to be used to send the email
79+
:param service: the service to be used to send the email
80+
:param body: the body of the email
8181
"""
8282
message.attach(MIMEText(body, 'html'))
8383
create_message = {'raw': urlsafe_b64encode(message.as_bytes()).decode()}
@@ -88,10 +88,10 @@ def send_email(message: MIMEMultipart, service: Any, body: str) -> str:
8888
def send_reset_pwd_email(username: str, email: str, token: str) -> str:
8989
""" Send the reset password token to the user.
9090
91-
@param username: the name of the user
92-
@param email: the email of the user
93-
@param token: the token to be used to reset the account password
94-
@return: the message sent to the user
91+
:param username: the name of the user
92+
:param email: the email of the user
93+
:param token: the token to be used to reset the account password
94+
:return: the message sent to the user
9595
"""
9696
service: Any = build('gmail', 'v1', credentials=Credentials.from_authorized_user_file(get_config()))
9797
message: MIMEMultipart = build_email_core(title='PTMD -Reset Password', email=email)

ptmd/lib/email/load_templates.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
def create_confirmation_email_content(username: str, token: str) -> str:
1313
""" Create the content of the confirmation email to be sent to the user.
1414
15-
@param username: the name of the user
16-
@param token: the token to be used to activate the account
17-
@return: the content of the email
15+
:param username: the name of the user
16+
:param token: the token to be used to activate the account
17+
:return: the content of the email
1818
"""
1919
with open(path.join(TEMPLATES_PATH, 'enable_account.html'), 'r') as template_data:
2020
template: Template = Template(template_data.read())
@@ -24,8 +24,8 @@ def create_confirmation_email_content(username: str, token: str) -> str:
2424
def create_validated_email_content(username: str) -> str:
2525
""" Create the content of the email to be sent to the user when his account has been validated by an admin.
2626
27-
@param username: the name of the user
28-
@return: the content of the email
27+
:param username: the name of the user
28+
:return: the content of the email
2929
"""
3030
with open(path.join(TEMPLATES_PATH, 'activated_account.html'), 'r') as template_data:
3131
template: Template = Template(template_data.read())
@@ -35,8 +35,8 @@ def create_validated_email_content(username: str) -> str:
3535
def create_validation_mail_content(user: Any) -> str:
3636
""" Create the content of the email to be sent to the user.
3737
38-
@param user: the user account to activate
39-
@return: the content of the email
38+
:param user: the user account to activate
39+
:return: the content of the email
4040
"""
4141
with open(path.join(TEMPLATES_PATH, 'activate_account.html'), 'r') as template_data:
4242
template: Template = Template(template_data.read())
@@ -46,9 +46,9 @@ def create_validation_mail_content(user: Any) -> str:
4646
def create_reset_pwd_mail_content(username: str, token: str) -> str:
4747
""" Create the content of the email to be sent to the user.
4848
49-
@param username: the name of the user
50-
@param token: the token to be used to activate the account
51-
@return: the content of the email
49+
:param username: the name of the user
50+
:param token: the token to be used to activate the account
51+
:return: the content of the email
5252
"""
5353
with open(path.join(TEMPLATES_PATH, 'reset_password.html'), 'r') as template_data:
5454
template: Template = Template(template_data.read())

ptmd/lib/email/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
def get_config() -> str:
1010
""" Get the configuration file for the Google Drive API.
1111
12-
@return: the path to the credentials file
12+
:return: the path to the credentials file
1313
"""
1414
with open(GOOGLE_DRIVE_SETTINGS_FILE_PATH, 'r') as settings_file:
1515
settings = safe_load(settings_file)

0 commit comments

Comments
 (0)