Skip to content

Commit

Permalink
- Added dependency checker to give better errors on launch
Browse files Browse the repository at this point in the history
- Fixed issue with PyBIN collapse button
- Updated some imports to use relative imports
- Fixed some cyclical imports
- Removed some "unicode" references to allow running in Python 3 enough to get dependency error
- Updated Hotlink to support opening links in browser by default
- Updated some Tkinter related imports to allow running in Python 3 enough to get dependency error
- Created a shim for start_new_thread to allow running in Python 3 enough to get dependency error
  • Loading branch information
Zach Zahos committed Sep 16, 2022
1 parent 9a29003 commit 394ada9
Show file tree
Hide file tree
Showing 96 changed files with 490 additions and 376 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ PyMS/WORKING/*
PyMS/Logs/*
playground.py
**/__pycache__
.vscode/*
.vscode/*
.python-version
2 changes: 1 addition & 1 deletion Docs/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PyMS = (1,2,1) * 2
import PyMSUtils, re
from . import PyMSUtils, re
infoheaderstart = """<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
Expand Down
18 changes: 10 additions & 8 deletions PyAI.pyw
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python

from PyMS.PyAI.PyAI import PyAI, LONG_VERSION
from PyMS.Utilities.Compatability import check_compat
check_compat('PyAI')

from PyMS.FileFormats import AIBIN
def main():
from PyMS.PyAI.PyAI import PyAI, LONG_VERSION

from PyMS.Utilities import Assets
from PyMS.Utilities.PyMSError import PyMSError
from PyMS.FileFormats import AIBIN

import os, optparse
from PyMS.Utilities import Assets
from PyMS.Utilities.PyMSError import PyMSError

import os, optparse, sys

def main():
import sys
if not sys.argv or (len(sys.argv) == 1 and os.path.basename(sys.argv[0]).lower() in ['','pyai.py','pyai.pyw','pyai.exe']):
gui = PyAI()
gui.startup()
Expand Down
12 changes: 7 additions & 5 deletions PyBIN.pyw
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python

from PyMS.PyBIN.PyBIN import PyBIN, LONG_VERSION

import os, optparse
from PyMS.Utilities.Compatability import check_compat
check_compat('PyBIN')

def main():
import sys
from PyMS.PyBIN.PyBIN import PyBIN, LONG_VERSION

import os, optparse, sys

if not sys.argv or (len(sys.argv) == 1 and os.path.basename(sys.argv[0]).lower() in ['','pybin.py','pybin.pyw','pybin.exe']):
gui = PyBIN()
gui.startup()
Expand Down
20 changes: 11 additions & 9 deletions PyDAT.pyw
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python

from PyMS.PyDAT.PyDAT import PyDAT, LONG_VERSION
from PyMS.Utilities.Compatability import check_compat
check_compat('PyDAT')

from PyMS.FileFormats.DAT import *
def main():
from PyMS.PyDAT.PyDAT import PyDAT, LONG_VERSION

from PyMS.Utilities.utils import BASE_DIR
from PyMS.Utilities.PyMSError import PyMSError
from PyMS.FileFormats import DAT

import os, optparse
from PyMS.Utilities.utils import BASE_DIR
from PyMS.Utilities.PyMSError import PyMSError

import os, optparse, sys

def main():
import sys
if not sys.argv or (len(sys.argv) == 1 and os.path.basename(sys.argv[0]).lower() in ['','pydat.py','pydat.pyw','pydat.exe']):
gui = PyDAT()
gui.startup()
Expand Down Expand Up @@ -43,7 +45,7 @@ def main():
path = os.path.dirname(args[0])
if not path:
path = os.path.abspath('')
dat = [UnitsDAT,WeaponsDAT,FlingyDAT,SpritesDAT,ImagesDAT,UpgradesDAT,TechDAT,SoundsDAT,PortraitsDAT,CampaignDAT,OrdersDAT][opt.type]()
dat = [DAT.UnitsDAT,DAT.WeaponsDAT,DAT.FlingyDAT,DAT.SpritesDAT,DAT.ImagesDAT,DAT.UpgradesDAT,DAT.TechDAT,DAT.SoundsDAT,DAT.PortraitsDAT,DAT.CampaignDAT,DAT.OrdersDAT][opt.type]()
if len(args) == 1:
if opt.convert:
ext = 'txt'
Expand Down
18 changes: 10 additions & 8 deletions PyFNT.pyw
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python

from PyMS.PyFNT.PyFNT import PyFNT, LONG_VERSION
from PyMS.Utilities.Compatability import check_compat, Requirement
check_compat('PyFNT', Requirement.PIL)

from PyMS.FileFormats.FNT import FNT, fnttobmp, bmptofnt
from PyMS.FileFormats.BMP import BMP
def main():
from PyMS.PyFNT.PyFNT import PyFNT, LONG_VERSION

from PyMS.Utilities.PyMSError import PyMSError
from PyMS.FileFormats.FNT import FNT, fnttobmp, bmptofnt
from PyMS.FileFormats.BMP import BMP

import os, optparse
from PyMS.Utilities.PyMSError import PyMSError

import os, optparse, sys

def main():
import sys
if not sys.argv or (len(sys.argv) == 1 and os.path.basename(sys.argv[0]).lower() in ['','pyfnt.py','pyfnt.pyw','pyfnt.exe']):
gui = PyFNT()
gui.startup()
Expand Down
18 changes: 10 additions & 8 deletions PyGOT.pyw
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python

from PyMS.PyGOT.PyGOT import PyGOT, LONG_VERSION
from PyMS.Utilities.Compatability import check_compat
check_compat('PyGOT')

from PyMS.FileFormats.GOT import GOT
from PyMS.FileFormats.TRG import TRG
def main():
from PyMS.PyGOT.PyGOT import PyGOT, LONG_VERSION

from PyMS.Utilities.PyMSError import PyMSError
from PyMS.FileFormats.GOT import GOT
from PyMS.FileFormats.TRG import TRG

import os, optparse
from PyMS.Utilities.PyMSError import PyMSError

import os, optparse, sys

def main():
import sys
if not sys.argv or (len(sys.argv) == 1 and os.path.basename(sys.argv[0]).lower() in ['','pygot.py','pygot.pyw','pygot.exe']):
gui = PyGOT()
gui.startup()
Expand Down
18 changes: 10 additions & 8 deletions PyGRP.pyw
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python

from PyMS.PyGRP.PyGRP import PyGRP, LONG_VERSION
from PyMS.PyGRP.utils import grptobmp, bmptogrp
from PyMS.Utilities.Compatability import check_compat, Requirement
check_compat('PyGRP', Requirement.PIL)

from PyMS.FileFormats.Palette import Palette
def main():
from PyMS.PyGRP.PyGRP import PyGRP, LONG_VERSION
from PyMS.PyGRP.utils import grptobmp, bmptogrp

from PyMS.Utilities.PyMSError import PyMSError
from PyMS.FileFormats.Palette import Palette

import os, optparse
from PyMS.Utilities.PyMSError import PyMSError

import os, optparse, sys

def main():
import sys
if not sys.argv or (len(sys.argv) == 1 and os.path.basename(sys.argv[0]).lower() in ['','pygrp.py','pygrp.pyw','pygrp.exe']):
gui = PyGRP()
gui.startup()
Expand Down
18 changes: 10 additions & 8 deletions PyICE.pyw
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python

from PyMS.PyICE.PyICE import PyICE, LONG_VERSION
from PyMS.Utilities.Compatability import check_compat
check_compat('PyICE')

from PyMS.FileFormats import IScriptBIN
def main():
from PyMS.PyICE.PyICE import PyICE, LONG_VERSION

from PyMS.Utilities.utils import BASE_DIR
from PyMS.Utilities.PyMSError import PyMSError
from PyMS.FileFormats import IScriptBIN

import os, optparse
from PyMS.Utilities.utils import BASE_DIR
from PyMS.Utilities.PyMSError import PyMSError

import os, optparse, sys

def main():
import sys
if not sys.argv or (len(sys.argv) == 1 and os.path.basename(sys.argv[0]).lower() in ['','pyice.py','pyice.pyw','pyice.exe']):
gui = PyICE()
gui.startup()
Expand Down
16 changes: 9 additions & 7 deletions PyLO.pyw
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python

from PyMS.PyLO.PyLO import PyLO, LONG_VERSION
from PyMS.Utilities.Compatability import check_compat
check_compat('PyLO')

from PyMS.FileFormats.LO import LO
def main():
from PyMS.PyLO.PyLO import PyLO, LONG_VERSION

from PyMS.Utilities.PyMSError import PyMSError
from PyMS.FileFormats.LO import LO

import os, optparse
from PyMS.Utilities.PyMSError import PyMSError

import os, optparse, sys

def main():
import sys
if not sys.argv or (len(sys.argv) == 1 and os.path.basename(sys.argv[0]).lower() in ['','pylo.py','pylo.pyw','pylo.exe']):
gui = PyLO()
gui.startup()
Expand Down
12 changes: 7 additions & 5 deletions PyMPQ.pyw
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python

from PyMS.PyMPQ.PyMPQ import PyMPQ, LONG_VERSION

import os, optparse
from PyMS.Utilities.Compatability import check_compat, Requirement
check_compat('PyMPQ', Requirement.MPQ)

def main():
import sys
from PyMS.PyMPQ.PyMPQ import PyMPQ, LONG_VERSION

import os, optparse, sys

if not sys.argv or (len(sys.argv) == 1 and os.path.basename(sys.argv[0]).lower() in ['','pympq.py','pympq.pyw','pympq.exe']):
gui = PyMPQ()
gui.startup()
Expand Down
7 changes: 3 additions & 4 deletions PyMS/FileFormats/AIBIN.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ..Utilities.PyMSWarning import PyMSWarning
from ..Utilities.AtomicWriter import AtomicWriter

import struct, re, os, sys
import struct, re, os
from math import log, floor
from zlib import compress, decompress
from collections import OrderedDict
Expand Down Expand Up @@ -305,7 +305,6 @@ def __init__(self, bwscript=None, units=None, upgrades=None, techs=None, stat_tx
self.externaljumps = [[{},{}],[{},{}]]
self.varinfo = OrderedDict()
self.aiinfo = {}
self.warnings = None
self.bwscript = None
self.warnings = []
self.nobw = bwscript == None
Expand Down Expand Up @@ -498,7 +497,7 @@ def __init__(self, bwscript=None, units=None, upgrades=None, techs=None, stat_tx

def load_file(self, file, addstrings=False):
data = load_file(file, 'aiscript.bin')
self.load_data(data, addstrings)
return self.load_data(data, addstrings)

def load_data(self, data, addstrings=False):
try:
Expand Down Expand Up @@ -1861,7 +1860,7 @@ def __init__(self, units=None, upgrades=None, techs=None, stat_txt=None):

def load_file(self, file):
data = load_file(file, 'bwscript.bin')
self.load_data(data)
return self.load_data(data)

def load_data(self, data):
try:
Expand Down
6 changes: 3 additions & 3 deletions PyMS/FileFormats/CHK/CHK.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

from CHKRequirements import CHKRequirements
from CHKSectionUnknown import CHKSectionUnknown
from Sections import *
from .CHKRequirements import CHKRequirements
from .CHKSectionUnknown import CHKSectionUnknown
from .Sections import *

from ...FileFormats import TBL, AIBIN

Expand Down
4 changes: 2 additions & 2 deletions PyMS/FileFormats/CHK/CHKRequirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CHKRequirements(object):
MODE_ALL = MODE_MELEE | MODE_UMS

def __init__(self, vers=VER_ALL, modes=MODE_ALL):
from Sections.CHKSectionVER import CHKSectionVER
from .Sections.CHKSectionVER import CHKSectionVER
self.vers = []
if vers & CHKRequirements.VER_VANILLA:
self.vers.append(CHKSectionVER.SC100)
Expand All @@ -26,7 +26,7 @@ def __init__(self, vers=VER_ALL, modes=MODE_ALL):
self.modes = modes

def is_required(self, chk, game_mode=MODE_ALL):
from Sections.CHKSectionVER import CHKSectionVER
from .Sections.CHKSectionVER import CHKSectionVER
verSect = chk.get_section(CHKSectionVER.NAME)
if verSect.version in self.vers and game_mode & self.modes:
return True
Expand Down
2 changes: 1 addition & 1 deletion PyMS/FileFormats/CHK/CHKSectionUnknown.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from CHKSection import CHKSection
from .CHKSection import CHKSection

class CHKSectionUnknown(CHKSection):
def __init__(self, chk, name):
Expand Down
2 changes: 1 addition & 1 deletion PyMS/FileFormats/CHK/Sections/CHKSectionIVER.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def VER_NAME(v):
def __init__(self, chk):
CHKSection.__init__(self, chk)
self.version = CHKSectionIVER.RELEASE
from CHKSectionVER import CHKSectionVER
from .CHKSectionVER import CHKSectionVER
verSect = chk.sections.get(CHKSectionVER.NAME)
if verSect and verSect.version == CHKSectionVER.BETA:
self.version = CHKSectionIVER.BETA
Expand Down
2 changes: 1 addition & 1 deletion PyMS/FileFormats/CHK/Sections/CHKSectionMASK.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from CHKSectionDIM import CHKSectionDIM
from .CHKSectionDIM import CHKSectionDIM

from ..CHKSection import CHKSection
from ..CHKRequirements import CHKRequirements
Expand Down
4 changes: 2 additions & 2 deletions PyMS/FileFormats/CHK/Sections/CHKSectionMRGN.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

from CHKSectionSTR import CHKSectionSTR
from CHKSectionVER import CHKSectionVER
from .CHKSectionSTR import CHKSectionSTR
from .CHKSectionVER import CHKSectionVER

from ..CHKSection import CHKSection
from ..CHKRequirements import CHKRequirements
Expand Down
2 changes: 1 addition & 1 deletion PyMS/FileFormats/CHK/Sections/CHKSectionMTXM.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from CHKSectionDIM import CHKSectionDIM
from .CHKSectionDIM import CHKSectionDIM

from ..CHKSection import CHKSection
from ..CHKRequirements import CHKRequirements
Expand Down
2 changes: 1 addition & 1 deletion PyMS/FileFormats/CHK/Sections/CHKSectionPTEx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from CHKSectionPTEC import CHKSectionPTEC
from .CHKSectionPTEC import CHKSectionPTEC

from ..CHKRequirements import CHKRequirements

Expand Down
2 changes: 1 addition & 1 deletion PyMS/FileFormats/CHK/Sections/CHKSectionPUPx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from CHKSectionUPGR import CHKSectionUPGR
from .CHKSectionUPGR import CHKSectionUPGR

from ..CHKRequirements import CHKRequirements

Expand Down
2 changes: 1 addition & 1 deletion PyMS/FileFormats/CHK/Sections/CHKSectionTECx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from CHKSectionTECS import CHKSectionTECS
from .CHKSectionTECS import CHKSectionTECS

from ..CHKRequirements import CHKRequirements

Expand Down
2 changes: 1 addition & 1 deletion PyMS/FileFormats/CHK/Sections/CHKSectionTILE.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from CHKSectionDIM import CHKSectionDIM
from .CHKSectionDIM import CHKSectionDIM

from ..CHKSection import CHKSection
from ..CHKRequirements import CHKRequirements
Expand Down
2 changes: 1 addition & 1 deletion PyMS/FileFormats/CHK/Sections/CHKSectionTYPE.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def TYPE_NAME(t):
def __init__(self, chk):
CHKSection.__init__(self, chk)
self.type = CHKSectionTYPE.BROODWAR
from CHKSectionVER import CHKSectionVER
from .CHKSectionVER import CHKSectionVER
verSect = chk.sections.get(CHKSectionVER.NAME)
if verSect and not verSect.type == CHKSectionVER.BW:
self.type = CHKSectionTYPE.STARCRAFT
Expand Down
2 changes: 1 addition & 1 deletion PyMS/FileFormats/CHK/Sections/CHKSectionUNIx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from CHKSectionUNIS import CHKSectionUNIS
from .CHKSectionUNIS import CHKSectionUNIS

from ..CHKRequirements import CHKRequirements

Expand Down
Loading

0 comments on commit 394ada9

Please sign in to comment.