from database import models, crud, utils
from .manga_site_enum import MangaSiteEnum
from .manga import Manga
from commons.utils import SingletonDecorator, construct_manga
from typing import Union


@SingletonDecorator
class MangaCatalog(object):
    def __init__(self):
        # self.__data = {site: {} for site in MangaSiteEnum}
        pass    

    def get_manga(self, site: MangaSiteEnum, manga_url: str, manga_name: str = None) -> Union[Manga, None]:
        """Get manga from manga url"""
        with utils.SQLAlchemyDBConnection() as conn:
            db = conn.session
            manga = crud.get_manga_by_url(db, manga_url)
            if manga is None:
                if manga_name is not None:                    
                    manga = crud.create_manga(
                        db, manga_name, manga_url, site)
                else:
                    return None
            return construct_manga(manga)


7752b50f582a958bbcbb8ff047e79a9159cf6a5d
<mask token>


@SingletonDecorator
class MangaCatalog(object):
    <mask token>
    <mask token>

<mask token>


@SingletonDecorator
class MangaCatalog(object):
    <mask token>

    def get_manga(self, site: MangaSiteEnum, manga_url: str, manga_name:
        str=None) ->Union[Manga, None]:
        """Get manga from manga url"""
        with utils.SQLAlchemyDBConnection() as conn:
            db = conn.session
            manga = crud.get_manga_by_url(db, manga_url)
            if manga is None:
                if manga_name is not None:
                    manga = crud.create_manga(db, manga_name, manga_url, site)
                else:
                    return None
            return construct_manga(manga)

<mask token>


@SingletonDecorator
class MangaCatalog(object):

    def __init__(self):
        pass

    def get_manga(self, site: MangaSiteEnum, manga_url: str, manga_name:
        str=None) ->Union[Manga, None]:
        """Get manga from manga url"""
        with utils.SQLAlchemyDBConnection() as conn:
            db = conn.session
            manga = crud.get_manga_by_url(db, manga_url)
            if manga is None:
                if manga_name is not None:
                    manga = crud.create_manga(db, manga_name, manga_url, site)
                else:
                    return None
            return construct_manga(manga)

from database import models, crud, utils
from .manga_site_enum import MangaSiteEnum
from .manga import Manga
from commons.utils import SingletonDecorator, construct_manga
from typing import Union


@SingletonDecorator
class MangaCatalog(object):

    def __init__(self):
        pass

    def get_manga(self, site: MangaSiteEnum, manga_url: str, manga_name:
        str=None) ->Union[Manga, None]:
        """Get manga from manga url"""
        with utils.SQLAlchemyDBConnection() as conn:
            db = conn.session
            manga = crud.get_manga_by_url(db, manga_url)
            if manga is None:
                if manga_name is not None:
                    manga = crud.create_manga(db, manga_name, manga_url, site)
                else:
                    return None
            return construct_manga(manga)

from database import models, crud, utils
from .manga_site_enum import MangaSiteEnum
from .manga import Manga
from commons.utils import SingletonDecorator, construct_manga
from typing import Union


@SingletonDecorator
class MangaCatalog(object):
    def __init__(self):
        # self.__data = {site: {} for site in MangaSiteEnum}
        pass    

    def get_manga(self, site: MangaSiteEnum, manga_url: str, manga_name: str = None) -> Union[Manga, None]:
        """Get manga from manga url"""
        with utils.SQLAlchemyDBConnection() as conn:
            db = conn.session
            manga = crud.get_manga_by_url(db, manga_url)
            if manga is None:
                if manga_name is not None:                    
                    manga = crud.create_manga(
                        db, manga_name, manga_url, site)
                else:
                    return None
            return construct_manga(manga)

