Skip to content

Commit

Permalink
impl: Add logging to the program
Browse files Browse the repository at this point in the history
  • Loading branch information
IoeCmcomc committed Jun 11, 2024
1 parent 1c604bd commit 13ba2a3
Show file tree
Hide file tree
Showing 9 changed files with 309 additions and 182 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ Downloaded song/

*build/
dist/
logs/
main.dist/
.mscbackup/

Expand Down
12 changes: 12 additions & 0 deletions audio_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from functools import lru_cache

from pydub import AudioSegment


@lru_cache(maxsize=32)
def load_sound(path: str) -> AudioSegment:
"""A patched version of nbswave.audio.load_song() which caches loaded sounds"""
if not path:
return AudioSegment.empty()
else:
return AudioSegment.from_file(path)
16 changes: 2 additions & 14 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
import sys
from collections import namedtuple
from os.path import abspath, dirname, join, normpath
from functools import lru_cache
from typing import Optional

from pydub import AudioSegment

# from main import __file__ as __mainfile__

Expand Down Expand Up @@ -232,7 +228,7 @@
SOUND_FOLDER = "sounds"

BASE_RESOURCE_PATH = ''
if getattr(sys, 'frozen', False): # PyInstaller
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): # PyInstaller
BASE_RESOURCE_PATH = sys._MEIPASS # type: ignore
elif '__compiled__' in globals(): # Nuitka
BASE_RESOURCE_PATH = dirname(__file__)
Expand All @@ -241,12 +237,4 @@
assert BASE_RESOURCE_PATH != ''

def resource_path(*args: str):
return normpath(join(BASE_RESOURCE_PATH, *args))

@lru_cache(maxsize=32)
def load_sound(path: str) -> AudioSegment:
"""A patched version of nbswave.audio.load_song() which caches loaded sounds"""
if not path:
return AudioSegment.empty()
else:
return AudioSegment.from_file(path)
return normpath(join(BASE_RESOURCE_PATH, *args))
8 changes: 6 additions & 2 deletions customwidgets/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@
except ImportError as e:
from pygubu import BuilderObject, register_widget # type: ignore

from wrapmessage import WrapMessage
from checkablelabelframe import CheckableLabelFrame
try:
from wrapmessage import WrapMessage
from checkablelabelframe import CheckableLabelFrame
except ModuleNotFoundError:
from .wrapmessage import WrapMessage
from .checkablelabelframe import CheckableLabelFrame

class WrapMessageBuilder(BuilderObject): # type: ignore
class_ = WrapMessage
Expand Down
Loading

0 comments on commit 13ba2a3

Please sign in to comment.