Skip to content

Commit

Permalink
moved LoadedComicInfo into its own module in package
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePromidius committed Feb 28, 2024
1 parent 5e6455a commit b39c3ab
Show file tree
Hide file tree
Showing 24 changed files with 30 additions and 35 deletions.
3 changes: 1 addition & 2 deletions MangaManager/Extensions/WebpConverter/WebpConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import logging
import os
import pathlib
import threading
import tkinter
import tkinter.ttk as ttk
from concurrent.futures import ProcessPoolExecutor
from tkinter import filedialog

from Extensions.IExtensionApp import IExtensionApp
from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.Common.utils import ShowPathTreeAsDict
from MangaManager.MetadataManager.GUI.widgets import ScrolledFrameWidget, ProgressBarWidget
from MangaManager.Settings.Settings import Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .ILoadedComicInfo import ILoadedComicInfo
from .LoadedFileCoverData import LoadedFileCoverData
from .LoadedFileMetadata import LoadedFileMetadata
from ...Settings import Settings, SettingHeading
from MangaManager.Settings import Settings, SettingHeading

logger = logging.getLogger("LoadedCInfo")
COMICINFO_FILE = 'ComicInfo.xml'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .ArchiveFile import ArchiveFile
from .CoverActions import CoverActions
from .ILoadedComicInfo import ILoadedComicInfo
from ...Settings import Settings, SettingHeading
from MangaManager.Settings import Settings, SettingHeading

logger = logging.getLogger("LoadedCInfo")
COMICINFO_FILE = 'ComicInfo.xml'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from lxml.etree import XMLSyntaxError

from ComicInfo import ComicInfo
from MangaManager.Common.LoadedComicInfo.ILoadedComicInfo import ILoadedComicInfo
from MangaManager.LoadedComicInfo.ILoadedComicInfo import ILoadedComicInfo
from MangaManager.Common.errors import MissingRarTool

logger = logging.getLogger("LoadedCInfo")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
from PIL import Image, ImageTk

from MangaManager.Common import ResourceLoader
from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import CoverActions, LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import CoverActions, LoadedComicInfo
from MangaManager.MetadataManager.CoverManager import torchlib
from MangaManager.MetadataManager.GUI import MessageBox
from MangaManager.MetadataManager.GUI.MessageBox import MessageBoxWidgetFactory as mb
from MangaManager.MetadataManager.GUI.scrolledframe import ScrolledFrame
from MangaManager.MetadataManager.GUI.widgets import ButtonWidget
from MangaManager.MetadataManager.GUI.widgets.CanvasCoverWidget import CoverFrame, CanvasCoverWidget
from MangaManager.MetadataManager.GUI.widgets.MessageBoxWidget import MessageBoxWidget, MessageBoxButton
from MangaManager.MetadataManager.GUI.windows.LoadingWindow import LoadingWindow
from MangaManager.MetadataManager.MetadataManagerGUI import GUIApp
from MangaManager.Settings import SettingHeading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from tkinter.font import Font
from tkinter.ttk import Treeview, Style

from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo

logger = logging.getLogger()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
import pathlib
import tkinter
from idlelib.tooltip import Hovertip
from os.path import basename
from tkinter import Frame, Label, StringVar, Event, Canvas, NW, CENTER, Button
Expand All @@ -10,8 +9,8 @@
from PIL import Image, ImageTk

from MangaManager.Common import ResourceLoader
from MangaManager.Common.LoadedComicInfo.CoverActions import CoverActions
from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.LoadedComicInfo.CoverActions import CoverActions
from MangaManager.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.Settings import SettingHeading
from MangaManager.Settings.Settings import Settings

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tkinter
from tkinter.ttk import Treeview

from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo

logger = logging.getLogger()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import re
import tkinter
from tkinter import ttk, Frame
from tkinter.ttk import LabelFrame, Label, Notebook, Combobox
from tkinter.ttk import LabelFrame, Notebook, Combobox

from ExternalSources.MetadataSources import ScraperFactory
from ComicInfo import ComicInfo
from MangaManager import MM_PATH
from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.Common.utils import open_folder
from MangaManager.DynamicLibController.models import IMetadataSource
from MangaManager.MetadataManager.GUI.utils import center
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from prompt_toolkit.validation import Validator

from ComicInfo import ComicInfo
from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.Common.utils import ShowPathTreeAsDict
from MangaManager.MetadataManager.MetadataManagerLib import MetadataManagerLib

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import os
import tkinter
from tkinter import Tk, Frame
from tkinter import Frame

from ComicInfo import ComicInfo
from MangaManager.Common import ResourceLoader
Expand All @@ -23,7 +23,7 @@
from tkinter.filedialog import askopenfiles, askdirectory
from _tkinter import TclError
from tkinterdnd2.TkinterDnD import Tk
from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.MetadataManager.GUI.widgets import ComboBoxWidget, OptionMenuWidget, WidgetManager, ButtonWidget
from MangaManager.MetadataManager.GUI.windows.SettingsWindow import SettingsWindow
from MangaManager.MetadataManager.MetadataManagerLib import MetadataManagerLib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ExternalSources.MetadataSources import ScraperFactory
from ComicInfo import ComicInfo
from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.Common.errors import EditedCinfoNotSet, MangaNotFoundError, MissingRarTool
from MangaManager.Common.errors import NoComicInfoLoaded, CorruptedComicInfo, BadZipFile
from MangaManager.Common.terminalcolors import TerminalColors as TerCol
Expand Down
2 changes: 1 addition & 1 deletion MangaManager/tests/LoadedComicInfo/test_Covers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from PIL import Image

from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import CoverActions, LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import CoverActions, LoadedComicInfo
from MangaManager.Common.utils import obtain_cover_filename
from tests.common import CBZManipulationTests, create_test_cbz

Expand Down
2 changes: 1 addition & 1 deletion MangaManager/tests/LoadedComicInfo/test_LoadedCInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from unittest import skip

from ComicInfo import ComicInfo
from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo

TEST_COMIC_INFO_STRING = """
<ComicInfo>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import zipfile

from ComicInfo import ComicInfo
from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.Settings import Settings, SettingHeading

TEST_COMIC_INFO_STRING = """
Expand Down
2 changes: 1 addition & 1 deletion MangaManager/tests/LoadedComicInfo/test_moveto.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest

from ComicInfo import ComicInfo
from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo


class MoveToTemplate(unittest.TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ComicInfo import ComicInfo
from logging_setup import add_trace_level
from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.MetadataManager import MetadataManagerGUI
from MangaManager.MetadataManager.MetadataManagerLib import MetadataManagerLib
from tests.common import create_dummy_files, TKinterTestCase, parameterized_class, create_test_cbz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import zipfile
from unittest.mock import patch, MagicMock

import MangaManager.Common.LoadedComicInfo.LoadedComicInfo
import MangaManager.LoadedComicInfo.LoadedComicInfo
from ComicInfo import ComicInfo
from logging_setup import add_trace_level
from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import LoadedComicInfo
from MangaManager.Common.errors import CorruptedComicInfo, NoComicInfoLoaded
from MangaManager.Common.errors import EditedCinfoNotSet, BadZipFile
from MangaManager.MetadataManager import MetadataManagerLib
Expand All @@ -27,7 +27,7 @@ def setUp(self) -> None:

def tearDown(self) -> None:
# Some cases patch LoadedComicInfo. patchin back just in case
MangaManager.Common.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = LoadedComicInfo
MangaManager.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = LoadedComicInfo
print("Teardown:")
for filename in self.test_files_names:
print(f" Deleting: {filename}") # , self._testMethodName)
Expand Down Expand Up @@ -117,7 +117,7 @@ def setUp(self) -> None:

def tearDown(self) -> None:
# Some cases patch LoadedComicInfo. patchin back just in case
MangaManager.Common.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = LoadedComicInfo
MangaManager.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = LoadedComicInfo
print("Teardown:")
for filename in self.test_files_names:
print(f" Deleting: {filename}") # , self._testMethodName)
Expand All @@ -137,7 +137,7 @@ def raise_badzip(*_, **__):
raise BadZipFile()

RaiseBadZip.__init__ = raise_badzip
MangaManager.Common.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = RaiseBadZip
MangaManager.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = RaiseBadZip

self.instance.selected_files_path = self.test_files_names = create_dummy_files(2)

Expand All @@ -156,11 +156,11 @@ class RaiseCorruptedMeta:
def raise_badzip(*_, **__):
# Exception raised but then we create a new object with a brand new comicinfo.
# Fix back patched class and raise exception
MangaManager.Common.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = LoadedComicInfo
MangaManager.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = LoadedComicInfo
raise CorruptedComicInfo("")

RaiseCorruptedMeta.__init__ = raise_badzip
MangaManager.Common.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = RaiseCorruptedMeta
MangaManager.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = RaiseCorruptedMeta

self.instance.selected_files_path = self.test_files_names = create_dummy_files(2)

Expand All @@ -184,7 +184,7 @@ def write_metadata(self, auto_unmark_changes=False):
super().write_metadata(auto_unmark_changes)


MangaManager.Common.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = RaisePermissionError
MangaManager.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = RaisePermissionError

self.instance.selected_files_path = self.test_files_names = create_dummy_files(2)
self.instance.loaded_cinfo_list = [RaisePermissionError(path) for path in self.test_files_names]
Expand All @@ -205,7 +205,7 @@ def __init__(self, *args, **kwargs):
def write_metadata(self, auto_unmark_changes=False):
raise Exception("Exception. This exception is raised as part of one unit test. Safe to ignore")

MangaManager.Common.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = RaisePermissionError
MangaManager.LoadedComicInfo.LoadedComicInfo.LoadedComicInfo = RaisePermissionError

self.instance.selected_files_path = self.test_files_names = create_dummy_files(2)
self.instance.loaded_cinfo_list = [RaisePermissionError(path) for path in self.test_files_names]
Expand Down
2 changes: 1 addition & 1 deletion MangaManager/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from PIL import Image
from lxml import etree

from MangaManager.Common.LoadedComicInfo.LoadedComicInfo import COMICINFO_FILE, LoadedComicInfo
from MangaManager.LoadedComicInfo.LoadedComicInfo import COMICINFO_FILE, LoadedComicInfo


def create_dummy_files(nfiles):
Expand Down
2 changes: 1 addition & 1 deletion MangaManager/tests/data/test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from MangaManager.Common.LoadedComicInfo.ArchiveFile import ArchiveFile
from MangaManager.LoadedComicInfo.ArchiveFile import ArchiveFile

if __name__ == '__main__':
with ArchiveFile("!00_SAMPLE_FILE.rar", "r") as rfile:
Expand Down

0 comments on commit b39c3ab

Please sign in to comment.