Skip to content

Commit

Permalink
chore:switch to poetry as build tool and package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Benex254 committed Jun 23, 2024
1 parent 4b5ff63 commit 3b8a565
Show file tree
Hide file tree
Showing 59 changed files with 355 additions and 313 deletions.
30 changes: 22 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
default_language_version:
python: python3.10

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1 # You can replace this with the latest version
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.10.0
- id: isort
name: isort
args: ["--profile", "black"] # Ensure compatibility with Black

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.10
hooks:
- id: black
# Run the linter.
- id: ruff
args: [ --fix ]

- repo: https://github.com/psf/black
rev: 23.3.0 # You can replace this with the latest version
hooks:
- id: black
name: black
language_version: python3.10 # Specify your Python version
5 changes: 3 additions & 2 deletions fastanime/Utility/downloader/downloader.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from threading import Thread
from queue import Queue
from threading import Thread

import yt_dlp

from ... import downloads_dir
from ..utils import sanitize_filename
from ..show_notification import show_notification
from ..utils import sanitize_filename


class MyLogger:
Expand Down
1 change: 0 additions & 1 deletion fastanime/Utility/user_data_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from kivy.logger import Logger


today = date.today()
now = datetime.now()

Expand Down
3 changes: 2 additions & 1 deletion fastanime/Utility/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import re
import shutil
from datetime import datetime
import re

# TODO: make it use color_text instead of fixed vals
# from .kivy_markup_helper import color_text

Expand Down
7 changes: 3 additions & 4 deletions fastanime/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import logging
import os
import sys
import logging

import plyer
from rich import print
from rich.traceback import install

import plyer

install()
# Create a logger instance
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -55,7 +54,7 @@ def FastAnime(gui=False, log=False):
handlers=[RichHandler()], # Use RichHandler to format the logs
)

print(f"Hello {os.environ.get("USERNAME")} from the fastanime team")
print(f"Hello {os.environ.get('USERNAME','User')} from the fastanime team")
if gui:
print(__name__)
from .gui.gui import run_gui
Expand Down
2 changes: 1 addition & 1 deletion fastanime/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import os
import sys

if __package__ is None and not getattr(sys, "frozen", False):
# direct call of __main__.py
Expand Down
3 changes: 2 additions & 1 deletion fastanime/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import click
from rich import print
from .commands import search, download, anilist

from .commands import anilist, download, search

commands = {"search": search, "download": download, "anilist": anilist}

Expand Down
3 changes: 0 additions & 3 deletions fastanime/cli/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .anilist import anilist
from .download import download
from .search import search
3 changes: 1 addition & 2 deletions fastanime/cli/commands/anilist/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import click

from .favourites import favourites
from .popular import popular
from .recent import recent
from .search import search
from .popular import popular
from .trending import trending
from .upcoming import upcoming


commands = {
"favourites": favourites,
"recent": recent,
Expand Down
3 changes: 2 additions & 1 deletion fastanime/cli/commands/anilist/search.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import click

from ....libs.anilist.anilist import AniList
from .utils import get_search_result
from ...interfaces.anime_interface import anime_interface
from .utils import get_search_result


@click.command()
Expand Down
3 changes: 2 additions & 1 deletion fastanime/cli/commands/anilist/trending.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import click

from ....libs.anilist.anilist import AniList
from .utils import get_search_result
from ...interfaces.anime_interface import anime_interface
from .utils import get_search_result


@click.command()
Expand Down
4 changes: 2 additions & 2 deletions fastanime/cli/commands/anilist/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from ...utils.fzf import fzf
from ....libs.anilist.anilist_data_schema import (
AnilistDataSchema,
AnilistBaseMediaDataSchema,
AnilistDataSchema,
)
from ...utils.fzf import fzf


def get_search_result(
Expand Down
10 changes: 4 additions & 6 deletions fastanime/cli/interfaces/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from .stream_interface import stream_interface
from .info_interface import info_interface
from .binge_interface import binge_interface
from .download_interface import download_interface
from .quit import bye
from .watchlist_interface import watchlist_interface
def bye():
import sys

sys.exit()
7 changes: 3 additions & 4 deletions fastanime/cli/interfaces/anime_interface.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import rich
from ..utils.fzf import fzf
from . import (
info_interface,
stream_interface,
binge_interface,
bye,
download_interface,
info_interface,
stream_interface,
watchlist_interface,
bye,
)

options = {
Expand Down
3 changes: 0 additions & 3 deletions fastanime/cli/interfaces/binge_interface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from ..utils import fzf


def binge_interface(anime, back):
print(anime)
3 changes: 0 additions & 3 deletions fastanime/cli/interfaces/download_interface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from ..utils import fzf


def download_interface(anime, back):
print(anime)
3 changes: 0 additions & 3 deletions fastanime/cli/interfaces/info_interface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from ..utils import fzf


def info_interface(anime, back):
print(anime)
1 change: 1 addition & 0 deletions fastanime/cli/interfaces/quit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys

from rich import print


Expand Down
8 changes: 5 additions & 3 deletions fastanime/cli/interfaces/stream_interface.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from ..utils.fzf import fzf
import logging

from fuzzywuzzy import fuzz

from ...libs.anime_provider.allanime.api import anime_provider
from ...Utility.data import anime_normalizer
from ..utils.fzf import fzf
from ..utils.mpv import mpv
from fuzzywuzzy import fuzz
import logging

logger = logging.getLogger(__name__)

Expand Down
3 changes: 0 additions & 3 deletions fastanime/cli/interfaces/watchlist_interface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
from ..utils import fzf


def watchlist_interface(anime, back):
print(anime)
22 changes: 12 additions & 10 deletions fastanime/cli/utils/fzf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import subprocess
import logging
import shutil
import subprocess

logger = logging.getLogger(__name__)

Expand All @@ -19,15 +19,17 @@ def fzf(options, prompt="Select Anime: ", *custom_commands):
return None

result = subprocess.run(
[
FZF,
"--reverse",
"--cycle",
"--prompt",
prompt,
]
if not custom_commands
else [FZF, *custom_commands],
(
[
FZF,
"--reverse",
"--cycle",
"--prompt",
prompt,
]
if not custom_commands
else [FZF, *custom_commands]
),
input=options_str,
text=True,
stdout=subprocess.PIPE,
Expand Down
2 changes: 1 addition & 1 deletion fastanime/cli/utils/mpv.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import subprocess
import shutil
import subprocess
import sys


Expand Down
6 changes: 1 addition & 5 deletions fastanime/gui/Controller/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
from .anime_screen import AnimeScreenController
from .downloads_screen import DownloadsScreenController
from .home_screen import HomeScreenController
from .my_list_screen import MyListScreenController
from .search_screen import SearchScreenController

7 changes: 5 additions & 2 deletions fastanime/gui/Controller/anime_screen.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from kivy.cache import Cache

from ..Model import AnimeScreenModel
from ..View import AnimeScreenView
from ..Model.anime_screen import AnimeScreenModel
from ..View.AnimeScreen.anime_screen import AnimeScreenView

Cache.register("data.anime", limit=20, timeout=600)

Expand Down Expand Up @@ -33,3 +33,6 @@ def update_anime_view(self, id, title, caller_screen_name):
self.fetch_streams(title)
self.view.current_title = title
self.view.caller_screen_name = caller_screen_name


__all__ = ["AnimeScreenController"]
7 changes: 5 additions & 2 deletions fastanime/gui/Controller/downloads_screen.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ..Model import DownloadsScreenModel
from ..View import DownloadsScreenView
from ..Model.download_screen import DownloadsScreenModel
from ..View.DownloadsScreen.download_screen import DownloadsScreenView


class DownloadsScreenController:
Expand All @@ -11,3 +11,6 @@ def __init__(self, model: DownloadsScreenModel):

def get_view(self) -> DownloadsScreenView:
return self.view


__all__ = ["DownloadsScreenController"]
13 changes: 7 additions & 6 deletions fastanime/gui/Controller/home_screen.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from inspect import isgenerator


from kivy.clock import Clock
from kivy.logger import Logger


from ..Model import HomeScreenModel
from ..Utility import show_notification
from ..View import HomeScreenView
from ..View.components import MediaCardsContainer
from ...Utility.show_notification import show_notification
from ..Model.home_screen import HomeScreenModel
from ..View.components.media_card.media_card import MediaCardsContainer
from ..View.HomeScreen.home_screen import HomeScreenView


# TODO:Move the update home screen to homescreen.py
Expand Down Expand Up @@ -141,3 +139,6 @@ def get_more_anime(self):
f"Theres probably a problem with your internet connection or anilist servers are down.\nFailed include:{', '.join(self.populate_errors)}",
)
self.populate_errors = []


__all__ = ["HomeScreenController"]
10 changes: 7 additions & 3 deletions fastanime/gui/Controller/my_list_screen.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from inspect import isgenerator
from math import ceil

from kivy.logger import Logger

# from kivy.clock import Clock
from kivy.utils import difference

from ..Model import MyListScreenModel
from ..Utility import user_data_helper
from ..View import MyListScreenView
from ...Utility import user_data_helper
from ..Model.my_list_screen import MyListScreenModel
from ..View.MylistScreen.my_list_screen import MyListScreenView


class MyListScreenController:
Expand Down Expand Up @@ -44,3 +45,6 @@ def requested_update_my_list_screen(self):
self.view.update_layout(result_card)
self.model.already_in_user_anime_list = _user_anime_list
return animes_to_add


__all__ = ["MyListScreenController"]
7 changes: 5 additions & 2 deletions fastanime/gui/Controller/search_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from kivy.clock import Clock
from kivy.logger import Logger

from ..Model import SearchScreenModel
from ..View import SearchScreenView
from ..Model.search_screen import SearchScreenModel
from ..View.SearchScreen.search_screen import SearchScreenView


class SearchScreenController:
Expand Down Expand Up @@ -43,3 +43,6 @@ def requested_search_for_anime(self, anime_title, **kwargs):
else:
Logger.error(f"Home Screen:Failed to search for {anime_title}")
self.view.is_searching = False


__all__ = ["SearchScreenController"]
6 changes: 1 addition & 5 deletions fastanime/gui/Model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
from .anime_screen import AnimeScreenModel
from .download_screen import DownloadsScreenModel
from .home_screen import HomeScreenModel
from .my_list_screen import MyListScreenModel
from .search_screen import SearchScreenModel

Loading

0 comments on commit 3b8a565

Please sign in to comment.