project_folder/
โโโ app/
โ โโโ static/
โ โ โโโ ...
โ โโโ templates/
โ โ โโโ ...
โ โโโ extensions/
โ โ โโโ __init__.py
โ โโโ __init__.py
This file contains hidden or 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
| from datetime import datetime, date | |
| import typing as t | |
| from sqlalchemy import ( | |
| Result, | |
| Select, | |
| Insert, | |
| Update, | |
| Delete, | |
| select, |
This file contains hidden or 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
| def reverse_dict(input_dict: dict) -> dict: | |
| """ | |
| Swaps the values with keys of a dict | |
| """ | |
| return {v: k for k, v in input_dict.items()} |
This file contains hidden or 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
| def money_to_int(value): | |
| """ | |
| Converts a money value, commonly in float format 100.00 to an int value 10000 | |
| """ | |
| if not value: | |
| return 0 | |
| if isinstance(value, str): | |
| if not value[0].isdigit(): | |
| value = value[1:] # Remove potential currency symbol |
This file contains hidden or 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
| import typing as t | |
| from datetime import datetime | |
| def calculate_days_between_dates(date: t.Union[str, datetime]) -> int: | |
| """ | |
| Calculates the days between a date and now | |
| Date format must be in the format of %Y-%m-%d if date is a string | |
| """ | |
| if isinstance(date, datetime): |
This file contains hidden or 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
| import re | |
| from typing import Literal, Optional, List | |
| def clean_string( | |
| string: str, | |
| remove_these: Optional[ | |
| List[Literal["new_line", "tab", "dead_space"]] | |
| ] = None | |
| ) -> str: |
This file contains hidden or 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
| class Colors: | |
| @classmethod | |
| def color_names(cls): | |
| return cls.colors.keys() | |
| @classmethod | |
| def color_values(cls): | |
| return cls.colors.values() |
This file contains hidden or 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
| def camel_case_to_snake_case(value: str) -> str: | |
| """ | |
| Switches name of the class CamelCase to snake_case | |
| """ | |
| special_characters = [ | |
| " ", | |
| "-", | |
| "(", | |
| ")", | |
| ".", |
This file contains hidden or 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
| import typing as t | |
| def is_truly(value: t.Optional[t.Union[str, bool, int]]) -> bool: | |
| if isinstance(value, int): | |
| return True if value > 0 else False | |
| if isinstance(value, bool): | |
| return value |
This file contains hidden or 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
| """ | |
| requirements: | |
| python-dotenv | |
| requests | |
| """ | |
| import os | |
| from json import JSONDecodeError |