Skip to content

Commit

Permalink
cleanup: sort import statements
Browse files Browse the repository at this point in the history
  • Loading branch information
IoeCmcomc committed Jun 11, 2024
1 parent 13ba2a3 commit 7f42174
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 42 deletions.
35 changes: 20 additions & 15 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,23 @@


import asyncio
import inspect
import json
import logging
import os
import platform
import re
import sys
import platform
import inspect
import warnings
import tkinter as tk
import tkinter.ttk as ttk
import uuid
import warnings
import webbrowser
from ast import literal_eval
from asyncio import CancelledError, sleep
from copy import copy, deepcopy
from datetime import timedelta
from itertools import repeat
from math import floor, log2
from os import path as os_path
from pathlib import Path
Expand All @@ -60,17 +63,11 @@
from tkinter.messagebox import showerror, showwarning
from typing import (Any, Callable, Coroutine, Deque, Iterable, List, Literal,
Optional, Union)
import uuid
from itertools import repeat
import logging
import sys

# logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

from loguru import logger
import pygubu
import pygubu.widgets.combobox
from jsonschema import validate
from loguru import logger
from pygubu import Builder
# Explict imports for PyInstaller
# from pygubu.builder import tkstdwidgets, ttkstdwidgets
Expand All @@ -80,20 +77,23 @@
import customwidgets.builder
from common import BASE_RESOURCE_PATH, resource_path

# logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)


if os.name == 'nt': # Windows
# Add the path of the ffmpeg before the first pydub import statement
os.environ["PATH"] += resource_path('ffmpeg', 'bin')

from pydub.utils import which

from lyric_parser import lyric2captions
from mcsp2nbs import mcsp2nbs
from midi2nbs import midi2nbs
from musescore2nbs import musescore2nbs
from nbs2audio import nbs2audio
from nbs2impulsetracker import nbs2it
from nbs2midi import nbs2midi
from nbsio import NBS_VERSION, VANILLA_INSTS, Instrument, Layer, NbsSong, Note
from lyric_parser import lyric2captions
from nbs2impulsetracker import nbs2it

__version__ = '1.3.0'

Expand Down Expand Up @@ -1345,7 +1345,7 @@ def __init__(self, master, parent):

if not checkFFmpeg():
self.d.close()
self.d.toplevel.after(1, self.d.destroy) # type: ignore
self.d.toplevel.after(1, self.d.destroy) # type: ignore


def parseFilePaths(string: str) -> tuple:
Expand Down Expand Up @@ -1938,17 +1938,22 @@ def emit(self, record: logging.LogRecord) -> None:
level, record.getMessage())


logger.add(resource_path("logs", "latest.log"), retention=10, compression='bz2')
logging.basicConfig(handlers=[InterceptHandler()], level=logging.INFO, force=True)
logger.add(resource_path("logs", "latest.log"),
retention=10, compression='bz2')
logging.basicConfig(handlers=[InterceptHandler()],
level=logging.INFO, force=True)

showwarning_ = warnings.showwarning


def _showwarning(message, *args, **kwargs):
logger.warning(message)
showwarning_(message, *args, **kwargs)


warnings.showwarning = _showwarning


@logger.catch
def main() -> None:
logger.info("NBSTool v{}", __version__)
Expand Down
11 changes: 6 additions & 5 deletions midi2nbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@


from asyncio import sleep
from math import gcd
from os.path import basename
from collections import namedtuple
from typing import Optional, Tuple
from dataclasses import dataclass
from math import gcd
from os.path import basename
from traceback import print_exc
from typing import Optional, Tuple

from mido import MidiFile, merge_tracks, tempo2bpm
from numpy import interp

from common import MIDI_DRUMS, MidiInstrument, MIDI_INSTRUMENTS, NBS_PITCH_IN_MIDI_PITCHBEND
from nbsio import Layer, NbsSong, Note, PERC_INSTS
from common import (MIDI_DRUMS, MIDI_INSTRUMENTS, NBS_PITCH_IN_MIDI_PITCHBEND,
MidiInstrument)
from nbsio import PERC_INSTS, Layer, NbsSong, Note

MIDI_DRUMS_BY_MIDI_PITCH = {obj.pitch: obj for obj in MIDI_DRUMS}

Expand Down
15 changes: 5 additions & 10 deletions nbs2audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,16 @@


from asyncio import sleep
from os import environ
from os import name as os_name
from typing import Optional, Sequence

from pydub import AudioSegment
from pynbs import File, Header, Instrument, Layer, Note
from typing import Sequence

from nbswave import SongRenderer, audio, nbs
from nbswave.main import MissingInstrumentException

from nbsio import VANILLA_INSTS, NbsSong
from pydub import AudioSegment
from pynbs import File, Header, Instrument, Layer, Note

from audio_common import load_sound
from common import resource_path, SOUND_FOLDER

from common import SOUND_FOLDER
from nbsio import NbsSong

audio.load_sound = load_sound

Expand Down
22 changes: 10 additions & 12 deletions nbs2impulsetracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,26 @@
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾


from asyncio import sleep
from collections.abc import Iterable
from struct import Struct
from typing import BinaryIO, Optional
from math import ceil
from dataclasses import asdict, dataclass
from enum import Enum, Flag, IntFlag, auto
from pprint import pprint
from itertools import groupby
from dataclasses import dataclass, asdict
from functools import total_ordering
from itertools import groupby
from math import ceil
from os import path
from asyncio import sleep
from pprint import pprint
from struct import Struct
from typing import BinaryIO, Optional
from warnings import warn

from pydub import AudioSegment
from pydub.effects import normalize

from nbsio import Note as NbsNote
from nbsio import NbsSong, Layer, Instrument, VANILLA_INSTS

from common import SOUND_FOLDER
from audio_common import load_sound

from common import SOUND_FOLDER
from nbsio import VANILLA_INSTS, Instrument, Layer, NbsSong
from nbsio import Note as NbsNote

DEFAULT_PATTERN_LENGTH = 64
TRACKER_VERSION = 0xa00a
Expand Down

0 comments on commit 7f42174

Please sign in to comment.