Skip to content

Commit

Permalink
📝 🔥 remove emoji dep and improve docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
mraniki committed Sep 7, 2023
1 parent a446810 commit d20f901
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 13 deletions.
78 changes: 67 additions & 11 deletions findmyorder/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
FindMyOrder Main
"""
from datetime import datetime

import emoji
from loguru import logger
from pyparsing import (
Combine,
Expand All @@ -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,
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit d20f901

Please sign in to comment.