Skip to content

Commit

Permalink
Merge pull request #294 from mraniki/dev
Browse files Browse the repository at this point in the history
📝 🔥 remove emoji dep and improve docs.
  • Loading branch information
mraniki committed Sep 7, 2023
2 parents bca8ecc + ccb4af3 commit f247018
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ updates:
directory: "/"
target-branch: "dev"
schedule:
interval: "daily"
interval: "weekly"
commit-message:
prefix: "⬆️ 🤖 Dependencies"
1 change: 0 additions & 1 deletion .requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32"
dynaconf==3.2.2 ; python_version >= "3.10" and python_version < "4.0"
emoji==2.8.0 ; python_version >= "3.10" and python_version < "4.0"
loguru==0.6.0 ; python_version >= "3.10" and python_version < "4.0"
pyparsing==3.1.1 ; python_version >= "3.10" and python_version < "4.0"
win32-setctime==1.1.0 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32"
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 and parse trading 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
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)
Returns:
str
"""
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
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ 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]
python-semantic-release = "^8.0.2"
ruff = ">=0.0.287,<0.0.288"
python-semantic-release = "^8.0.7"
ruff = "*"

[tool.ruff]
select = [
Expand Down
12 changes: 0 additions & 12 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,4 @@ async def test_mapping_order(
assert type(result["timestamp"] is datetime)


@pytest.mark.asyncio
async def test_contains_no_emoji(fmo, order):
"""check emoji"""
result = await fmo.contains_emoji(order)
assert result is False


@pytest.mark.asyncio
async def test_contains_emoji(fmo,order_with_emoji):
"""check emoji"""
result = await fmo.contains_emoji(order_with_emoji)
assert result is True

0 comments on commit f247018

Please sign in to comment.