# Copyright 2021 iiPython

# Modules
from typing import Any, Union
from .struct.status import codes
from .struct.client import Client

# Utilities class
class Utils(object):
    def __init__(self, server) -> None:
        self.server = server
        self.print = server.print

        self.codes = codes

    def get_client_from_attr(self, attr: str, value: Any) -> Union[Client, None]:
        client = [cl for cl in self.server.clients if cl.attr[attr] == value]
        if client:
            return client[0]

        return None

# Copyright 2021 iiPython

# Modules
from typing import Any, Union
from .struct.status import codes
from .struct.client import Client

# Utilities class
class Utils(object):
    def __init__(self, server) -> None:
        self.server = server
        self.print = server.print

        self.codes = codes

    def get_client_from_attr(self, attr: str, value: Any) -> Union[Client, None]:
        client = [cl for cl in self.server.clients if cl.attr[attr] == value]
        if client:
            return client[0]

        return None

# Copyright 2021 iiPython # Modules # Utilities class