From d20f9015a3141a46c88d773ea7c3bf7016bc44a4 Mon Sep 17 00:00:00 2001 From: mraniki <8766259+mraniki@users.noreply.github.com> Date: Thu, 7 Sep 2023 21:23:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20=F0=9F=94=A5=20remove=20emoji=20?= =?UTF-8?q?dep=20and=20improve=20docs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- findmyorder/main.py | 78 ++++++++++++++++++++++++++++++++++++++------- pyproject.toml | 3 +- 2 files changed, 68 insertions(+), 13 deletions(-) diff --git a/findmyorder/main.py b/findmyorder/main.py index 5ea8cf6a..cdc35c27 100644 --- a/findmyorder/main.py +++ b/findmyorder/main.py @@ -1,9 +1,9 @@ """ FindMyOrder Main + """ from datetime import datetime -import emoji from loguru import logger from pyparsing import ( Combine, @@ -22,7 +22,23 @@ class FindMyOrder: - """find an order class""" + """ + Class to find an order + + Args: + None + + Returns: + None + + Methods: + search(my_string: str) -> bool + get_info() -> str + identify_order(my_string: str) -> dict + get_order(msg: str) -> dict + replace_instrument(order: dict) -> None + + """ def __init__( self, @@ -33,7 +49,16 @@ async def search( self, my_string: str, ) -> bool: - """Search an order.""" + """ + Search an order. + + Args: + my_string (str): Message + + Returns: + bool + + """ if my_string: string_check = my_string.split()[0].lower() self.logger.debug("Searching order identifier in {}", string_check) @@ -42,18 +67,30 @@ async def search( return False async def get_info(self): - """get info about the class""" - return f"{__class__.__name__} {__version__}\n" + """ + get info about the class + + Returns: + str - async def contains_emoji(self, input_string: str) -> bool: - """Check if the input string contains an emoji.""" - return any(emoji.is_emoji(character) for character in input_string) + """ + return f"{__class__.__name__} {__version__}\n" async def identify_order( self, my_string: str, ) -> dict: - """Identify an order.""" + """ + Identify an order and return a dictionary + with the order parameters + + Args: + my_string (str): Message + + Returns: + dict + + """ try: action = ( one_of(settings.action_identifier, caseless=True) @@ -105,7 +142,17 @@ async def get_order( self, msg: str, ): - """get an order.""" + """ + Get an order from a message. The message can be + an order or an order identifier + + Args: + msg (str): Message + + Returns: + dict + + """ if not await self.search(msg): self.logger.debug("No order identified") return None @@ -122,7 +169,16 @@ async def get_order( return order async def replace_instrument(self, order): - """replace instrument by an alternative instrument""" + """ + Replace instrument by an alternative instrument, if the + instrument is not in the mapping, it will be ignored. + + Args: + order (dict): + + Returns: + dict + """ instrument = order["instrument"] for item in settings.mapping: if item["id"] == instrument: diff --git a/pyproject.toml b/pyproject.toml index ac37f60b..2aaa85ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,10 +24,9 @@ packages = [ [tool.poetry.dependencies] python = "^3.10" -dynaconf = "^3.1.12" +dynaconf = "^3.2.0" loguru = "^0.6.0" pyparsing = "^3.0.9" -emoji = "^2.5.1" [tool.poetry.group.dev.dependencies]