Skip to content

Commit

Permalink
Add files to install as module.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewhitfield28 committed Sep 18, 2024
1 parent 9c04219 commit aba7e46
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 13 deletions.
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[options.entry_points]
console_scripts =
victorialyser = victorialyser:app
13 changes: 13 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from setuptools import setup

setup(
name="victorialyser",
packages=["victorialyser"],
package_data={"victorialyser": ["data.json", "main.ui"]},
install_requires=["pillow", "PyQt6"],
entry_points={
'console_scripts': [
'victorialyser = victorialyser:app',
]
}
)
2 changes: 2 additions & 0 deletions setup.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[project.scripts]
victorialyser = "victorialyser:app"
Empty file added victorialyser/__init__.py
Empty file.
21 changes: 11 additions & 10 deletions app.py → victorialyser/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
import sys

from PIL import Image, ImageDraw
Expand All @@ -6,13 +7,13 @@
from PyQt6.QtCore import QRect
from PyQt6.QtGui import QIcon, QPixmap, QTransform

from main import *
from victorialyser import main


class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi("main.ui", self)
uic.loadUi(Path("%s/main.ui" % Path(__file__).parent), self)
self.setFixedWidth(1000)
self.setFixedHeight(580)

Expand Down Expand Up @@ -77,21 +78,21 @@ def _hide_all(self):
def load_file(self, file=None):
if not file:
file = str(QtWidgets.QFileDialog.getOpenFileName(self, "Select File")[0])
if try_file(file):
if main.try_file(file):
self._hide_all()
self.history, self.keys = read_file(file)
self.history, self.keys = main.read_file(file)
self.tag_list.clear()
self.tags = read_tags(self.folder, get_tags(self.history, self.keys))
self.tags = main.read_tags(self.folder, main.get_tags(self.history, self.keys))
for tag in self.tags.keys():
self.tag_list.addItem(tag)
self.war_list.clear()
self.wars = get_wars(self.history, self.keys)
self.wars = main.get_wars(self.history, self.keys)
self.battle_list.clear()

def load_folder(self, folder=None, tries=0):
if not folder:
folder = str(QtWidgets.QFileDialog.getExistingDirectory(self, "Select Folder"))
if try_folder(folder):
if main.try_folder(folder):
self.folder = folder

background = ImageQt(Path("%s/gfx/interface/frontend_ms_bg.dds" % self.folder))
Expand Down Expand Up @@ -163,7 +164,7 @@ def select_tag(self):
wars = []
for key in self.keys:
for war in self.wars[key]:
belligerents, battles = view_war(self.history, war, self.keys)
belligerents, battles = main.view_war(self.history, war, self.keys)
for time in belligerents:
for side in belligerents[time]:
for tag in belligerents[time][side]:
Expand All @@ -178,7 +179,7 @@ def select_war(self):
if self.war_list.currentItem() is None:
pass
else:
self.belligerents, self.battles = view_war(self.history, self.war_list.currentItem().text(), self.keys)
self.belligerents, self.battles = main.view_war(self.history, self.war_list.currentItem().text(), self.keys)
battles = []
for battle, data in self.battles.items():
battles.append(battle)
Expand Down Expand Up @@ -290,7 +291,7 @@ def create_flag(side):

app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
preset_file, preset_folder = load_presets()
preset_file, preset_folder = main.load_presets()
window.load_folder(preset_folder)
window.load_file(preset_file)
window.show()
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions main.py → victorialyser/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def load_presets():
with open("data.json", 'r') as df:
with open(Path("%s/data.json" % Path(__file__).parent), 'r') as df:
data = json.load(df)
return data["file"], data["folder"]

Expand All @@ -13,7 +13,7 @@ def try_file(file):
with open(file, mode='r', encoding="latin_1") as f:
for line in f.readlines():
if line.find("active_war") != -1 or line.find("previous_war") != -1:
with open("data.json", 'r+') as df:
with open(Path("%s/data.json" % Path(__file__).parent), 'r+') as df:
data = json.load(df)
data["file"] = file
df.seek(0)
Expand All @@ -27,7 +27,7 @@ def try_file(file):

def try_folder(folder):
if Path("%s/42960_install.vdf" % folder).is_file():
with open('data.json', 'r+') as df:
with open(Path("%s/data.json" % Path(__file__).parent), 'r+') as df:
data = json.load(df)
data["folder"] = folder
df.seek(0)
Expand Down
File renamed without changes.

0 comments on commit aba7e46

Please sign in to comment.