Skip to content

Commit

Permalink
fix: remove print from caching method
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreSenpai committed Apr 6, 2024
1 parent 95c34da commit db041f8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion enma/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from enma.application.core.utils.logger import LogMode, logger
from enma.application.use_cases.download_chapter import Threaded
from enma.infra.entrypoints.lib import Enma, SourcesEnum
from enma.infra.entrypoints.lib import Enma, Sources
from enma.infra.adapters.repositories.nhentai import CloudFlareConfig, NHentai, Sort as NHentaiSort
from enma.infra.adapters.repositories.mangadex import Mangadex, Sort as MangadexSort
from enma.infra.adapters.repositories.manganato import Manganato
Expand Down
2 changes: 0 additions & 2 deletions enma/infra/core/utils/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ def wrapper(*args, **kwargs):
else:
_args = list([*list(kwargs.values()), *args[1:]])

print(_args)

if self._CACHE.get(str(_args)) is not None:
logger.debug(f'Retrieving cached object with key {str(_args)}')
return self._CACHE.get(str(_args))
Expand Down
16 changes: 8 additions & 8 deletions enma/infra/entrypoints/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
from enma.infra.adapters.repositories.nhentai import NHentai, CloudFlareConfig
from enma.infra.core.interfaces.lib import IEnma

class SourcesEnum(Enum):
class Sources(Enum):
NHENTAI = 'nhentai'
MANGADEX = 'mangadex'
MANGANATO = 'manganato'

class ExtraConfigs(TypedDict):
cloudflare_config: CloudFlareConfig

AvailableSources = TypeVar('AvailableSources', bound=SourcesEnum)
AvailableSources = TypeVar('AvailableSources', bound=Sources)

class SourceManager(Generic[AvailableSources]):
"""
Expand All @@ -59,7 +59,7 @@ def get_source(self,
Retrieves a source repository by name.
Args:
source_name (Union[AvailableSources, str]): The name of the source to retrieve, either as a string or an enum.
source_name (Union[Sources, str]): The name of the source to retrieve, either as a string or an enum.
Returns:
IMangaRepository: The manga repository source.
Expand Down Expand Up @@ -89,13 +89,13 @@ def set_source(self,
self.source_name = source_name

def add_source(self,
source_name: Union[str, SourcesEnum],
source_name: Union[str, Sources],
source: IMangaRepository) -> None:
"""
Adds a new source repository to the available sources.
Args:
source_name (Union[str, SourcesEnum]): The name of the source to add.
source_name (Union[str, Sources]): The name of the source to add.
source (IMangaRepository): The manga repository source instance.
Raises:
Expand Down Expand Up @@ -160,9 +160,9 @@ def __create_default_sources(self) -> None:
"""
Creates and adds the default manga sources to the source manager. Currently, NHentai, Manganato, and Mangadex are added.
"""
self.source_manager.add_source(SourcesEnum.NHENTAI, NHentai())
self.source_manager.add_source(SourcesEnum.MANGANATO, Manganato())
self.source_manager.add_source(SourcesEnum.MANGADEX, Mangadex())
self.source_manager.add_source(Sources.NHENTAI, NHentai())
self.source_manager.add_source(Sources.MANGANATO, Manganato())
self.source_manager.add_source(Sources.MANGADEX, Mangadex())

def __initialize_use_case(self, source: IMangaRepository) -> None:
"""
Expand Down
1 change: 0 additions & 1 deletion tests/test_mangadex_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def test_response_when_it_could_not_get_doujin(self):

@patch('requests.get')
def test_raise_forbidden_in_case_of_403_status_code(self, mock_method: MagicMock):
print()
mock = Mock()
mock.status_code = 403
mock_method.return_value = mock
Expand Down

0 comments on commit db041f8

Please sign in to comment.