Skip to content

Commit

Permalink
module imports cleaned up
Browse files Browse the repository at this point in the history
  • Loading branch information
BombasticTom committed Jun 1, 2024
1 parent 0354f6c commit 08a265a
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 42 deletions.
14 changes: 8 additions & 6 deletions psychtobase/main.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
from base64 import b64decode
import json
import logging
import shutil
import threading
import time

from base64 import b64decode
from pathlib import Path
from PIL import Image
from src import Constants, log, Paths, Utils, files, window, FileContents

from src import Constants, FileContents, files, log, Utils, window

from src.tools import StageLuaParse, StageTool, VocalSplit, WeekTools
from src.tools import ModConvertTools as ModTools
import threading

from src.tools.CharacterTools import CharacterObject
from src.tools.ChartTools import ChartObject
from src.tools import VocalSplit, WeekTools, StageTool, StageLuaParse
from src import Utils

if __name__ == '__main__':
log.setup()
Expand Down Expand Up @@ -143,7 +145,7 @@ def convert(psych_mod_folder, result_folder, options):
logging.warning(f"{song} data not found! Skipping...")
continue
except Exception as e:
logging.warning("ERROR!" + e)
logging.warning("ERROR: " + str(e))
continue
else:
logging.info(f'{song} successfully initialized! Converting')
Expand Down
3 changes: 2 additions & 1 deletion psychtobase/src/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"""

import time
from src import Constants

from . import Constants
from re import sub

# modPath = ""
Expand Down
4 changes: 3 additions & 1 deletion psychtobase/src/files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from glob import glob
import logging

from glob import glob
from pathlib import Path

def removeTrail(filename):
Expand All @@ -9,6 +10,7 @@ def findAll(folder):
# return all files inside of a directory
# currently only used by the main
# update this!

logging.info(f'Finding all files or directories with glob: {folder}')
return glob(folder)

Expand Down
4 changes: 2 additions & 2 deletions psychtobase/src/log.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Utility tool for configuring the logger"""

import logging
import src.window as window
import sys

from time import strftime
from . import window
from pathlib import Path
from time import strftime

class CustomHandler(logging.StreamHandler):
def emit(self, record):
Expand Down
13 changes: 7 additions & 6 deletions psychtobase/src/tools/CharacterTools.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import copy
import json
import logging
import copy

from .. import Constants, files
from pathlib import Path
from src import Constants
from src import files
import lxml.etree as ET
from src import Utils
from src.Paths import Paths

# import lxml.etree as ET
# from src import Utils
# from src.Paths import Paths

class CharacterObject:
def __init__(self, path, resultPath):
Expand Down
8 changes: 5 additions & 3 deletions psychtobase/src/tools/ChartTools.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from src import Utils, Constants, files, window
import logging
from pathlib import Path
from src.Paths import Paths

from .. import Constants, files, Utils
from ..Paths import Paths

from copy import deepcopy
from pathlib import Path

class ChartObject:
"""
Expand Down
2 changes: 1 addition & 1 deletion psychtobase/src/tools/ModConvertTools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import src.Constants as Constants
from .. import Constants

def convertPack(packJson):
return {
Expand Down
6 changes: 3 additions & 3 deletions psychtobase/src/tools/StageLuaParse.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
import logging

from . import StageTool
from luaparser import ast
from luaparser.astnodes import *
import logging
import src.tools.StageTool as StageTool

def parseStage(lua_script_path):
lua_script = open(lua_script_path, 'r').read()
Expand Down
4 changes: 2 additions & 2 deletions psychtobase/src/tools/StageTool.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import copy
import logging
import src.Constants as Constants
import src.window as window

from .. import Constants

def convert(stageJSON, assetName, luaProps):
stageTemplate = copy.deepcopy(Constants.STAGE)
Expand Down
1 change: 1 addition & 0 deletions psychtobase/src/tools/VocalSplit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import numpy as np

from pydub import AudioSegment

def vocalsplit(chart, bpm, origin, path, key, characters):
Expand Down
5 changes: 3 additions & 2 deletions psychtobase/src/tools/WeekTools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from copy import deepcopy
import json
import logging
import src.Constants as Constants

from .. import Constants
from copy import deepcopy

def convert(weekJSON, modfolder, week_filename):
level = deepcopy(Constants.LEVEL)
Expand Down
31 changes: 16 additions & 15 deletions psychtobase/src/window.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
from base64 import b64decode
from pathlib import Path
import platform
import subprocess
import time



import logging
import src.log as log
import src.Constants as Constants
import main

import platform
import subprocess
import webbrowser

from . import log, Constants
from base64 import b64decode
from pathlib import Path

from PyQt6.QtCore import QSize
from PyQt6.QtGui import QIcon, QPixmap, QImage
from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton, QCheckBox, QLabel, QLineEdit, QFileDialog, QDialog, QVBoxLayout, QRadioButton, QTextBrowser, QWidget
from PyQt6.QtGui import QIcon, QImage, QPixmap
from PyQt6.QtWidgets import QApplication, QCheckBox, QDialog, QFileDialog, QLabel, QLineEdit, QMainWindow, QPushButton, QRadioButton, QTextBrowser, QVBoxLayout

icon = b64decode(Constants.BASE64_IMAGES.get('windowIcon'))
_windowTitleSuffix = "v0.1 [BETA]"

_windowTitleSuffix = f"v{Constants.VERSION} [BETA]"
_defaultsFile = '.defaults'
_vocalSplitEnabledByDefault = False

Expand Down Expand Up @@ -117,7 +119,6 @@ def closeEvent(self, event):
def __init__(self):
super().__init__()

_windowTitleSuffix = f"v{Constants.VERSION} [BETA]"
self.setWindowTitle(f"FNF Porter {_windowTitleSuffix}")
wid = 750
hei = 650
Expand Down Expand Up @@ -551,10 +552,10 @@ def convertCallback(self, what):
logging.error(f'Problems with your save file: {e}')

if psych_mod_folder_path != None and result_path != None:
try:
# try:
main.convert(psych_mod_folder_path, result_path, options)
except Exception as e:
self.throwError('Exception ocurred', f'{e}')
# except Exception as e:
# self.throwError('Exception ocurred', f'{e}')
else:
logging.warn('Select an input folder or output folder first!')

Expand Down

0 comments on commit 08a265a

Please sign in to comment.