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
# /usr/bin/python3 | |
"""Players info.""" | |
import json | |
from dataclasses import dataclass, field | |
from typing import Iterator, List | |
@dataclass | |
class PlayerInfo: | |
email: str |
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
# /usr/bin/python3 | |
"""Email sender.""" | |
import smtplib | |
from dataclasses import dataclass | |
from email.mime.text import MIMEText | |
from typing import Tuple, List | |
from players_info import ListOfPlayerInfo | |
@dataclass | |
class EmailSender: |
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
from players_info import ListOfPlayerInfo | |
from typing import List | |
def _init_possible_recipients(players: ListOfPlayerInfo) -> List[List[int]]: | |
""" | |
Apply inclusion and exclusion lists | |
to get all possible recipients for each player. | |
""" | |
all_names = [player.name for player in players] | |
possible_ids: List[List[int]] = [ |
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
from typing import List | |
from players_info import ListOfPlayerInfo | |
def _refine_possible_recipients(possible_ids: List[List[int]]) -> List[List[int]]: | |
""" | |
Find players with a single possible recipient | |
and remove this recipient from the possibilities of the other players | |
""" | |
known_players = [idx for idx, list_ids in enumerate(possible_ids) | |
if len(list_ids) == 1] |
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
from typing import List, Optional | |
from players_info import ListOfPlayerInfo | |
def _backtrack(possible_ids: List[List[int]], | |
current_id_chain: List[int]) -> bool: | |
""" | |
Explore all possible paths by iterating over players' possibilities. | |
""" | |
if len(current_id_chain) == len(possible_ids): |
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
import fire | |
from email_sender import EmailSender | |
from players_info import ListOfPlayerInfo | |
def main(players_json: str, | |
mail_address: str, | |
mail_pwd: str, | |
mail_txt: str): | |
""" |
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
import json | |
from typing import Dict | |
from typing import List | |
from typing import Union | |
def export_profiling_events(output_path: str): | |
""" | |
Dump profiling events into a JSON file that can be provided | |
to the Chrome Tracing Viewer |
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
# /usr/bin/python3 | |
"""Profile Image rotation""" | |
import cv2 | |
import numpy as np | |
from profiler import export_profiling_events | |
from profiler import profile | |
@profile |
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
import math | |
import multiprocessing | |
from typing import Optional | |
import imagesize | |
import psutil | |
from psutil._common import bytes2human | |
def bytes_of_uint8_img(img_path: str, colored: bool) -> int: |
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
# /usr/bin/python3 | |
"""Process files in parallel.""" | |
import math | |
from typing import Callable | |
from typing import Dict | |
from typing import List | |
from typing import Optional | |
from typing import Union | |
import numpy as np |
OlderNewer