lib folder removed

This commit is contained in:
d1str4ught
2026-02-08 23:41:02 +01:00
parent 36602f7ad9
commit 97ca2365a4
51 changed files with 80 additions and 58 deletions

View File

@@ -1,8 +1,17 @@
import sys import sys
import app import app
import dbg import dbg
import builtins
import _frozen_importlib as _bootstrap
import _frozen_importlib_external as _bootstrap_external
import marshal
import pack
import __main__
sys.path.append("lib") # Keep import paths deterministic for the embedded runtime.
sys.path = [p for p in sys.path if isinstance(p, str)]
if "lib" not in sys.path:
sys.path.append("lib")
class TraceFile: class TraceFile:
def write(self, msg): def write(self, msg):
@@ -38,10 +47,6 @@ sys.stderr = TraceErrorFile()
# pack file support (must move to system.py, systemrelease.pyc) # pack file support (must move to system.py, systemrelease.pyc)
# #
import marshal
import imp
import pack
class pack_file_iterator(object): class pack_file_iterator(object):
def __init__(self, packfile): def __init__(self, packfile):
self.pack_file = packfile self.pack_file = packfile
@@ -52,7 +57,7 @@ class pack_file_iterator(object):
return tmp return tmp
raise StopIteration raise StopIteration
_chr = __builtins__.chr _chr = builtins.chr
class pack_file(object): class pack_file(object):
@@ -67,12 +72,12 @@ class pack_file(object):
def __iter__(self): def __iter__(self):
return pack_file_iterator(self) return pack_file_iterator(self)
def read(self, len = None): def read(self, length = None):
if not self.data: if not self.data:
return '' return ''
if len: if length:
tmp = self.data[:len] tmp = self.data[:length]
self.data = self.data[len:] self.data = self.data[length:]
return tmp return tmp
else: else:
tmp = self.data tmp = self.data
@@ -85,57 +90,66 @@ class pack_file(object):
def readlines(self): def readlines(self):
return [x for x in self] return [x for x in self]
__builtins__.pack_open = pack_open = pack_file builtins.pack_open = pack_open = pack_file
old_open = open
def open(filename, mode = 'rb'):
try:
if mode in ('r', 'rb') and pack.Exist(filename):
return pack_file(filename, mode)
except Exception:
pass
return old_open(filename, mode)
builtins.open = open
builtins.old_open = old_open
builtins.new_open = open
_ModuleType = type(sys) _ModuleType = type(sys)
old_import = __import__
def _process_result(code, fqname):
# did get_code() return an actual module? (rather than a code object)
is_module = isinstance(code, _ModuleType)
# use the returned module, or create a new one to exec code into
if is_module:
module = code
else:
module = imp.new_module(fqname)
# insert additional values into the module (before executing the code)
#module.__dict__.update(values)
# the module is almost ready... make it visible
sys.modules[fqname] = module
# execute the code within the module's namespace
if not is_module:
exec(code, module.__dict__)
# fetch from sys.modules instead of returning module directly.
# also make module's __name__ agree with fqname, in case
# the "exec code in module.__dict__" played games on us.
module = sys.modules[fqname]
module.__name__ = fqname
return module
module_do = lambda x:None module_do = lambda x:None
currentExecName = ""
def __pack_import(name,globals=None,locals=None,fromlist=None): class custom_import_hook(object):
if name in sys.modules: def _pack_filename(self, name):
return sys.modules[name] filename = name + ".py"
if pack.Exist(filename):
return filename
return None
filename = name + '.py' def find_spec(self, fullname, path=None, target=None):
filename = self._pack_filename(fullname)
if not filename:
return None
return _bootstrap.spec_from_loader(fullname, self, origin=filename)
if pack.Exist(filename): def create_module(self, spec):
return None
def exec_module(self, module):
global currentExecName
name = module.__name__
filename = self._pack_filename(name)
if not filename:
raise ImportError(name)
dbg.Trace('importing from pack %s\\n' % name) dbg.Trace('importing from pack %s\\n' % name)
currentExecName = name
execfile(filename, module.__dict__)
module_do(module)
newmodule = _process_result(compile(pack_file(filename,'r').read(),filename,'exec'),name) def find_module(self, name, path=None):
if self._pack_filename(name):
return self
return None
module_do(newmodule) def load_module(self, name):
return newmodule if name in sys.modules:
#return imp.load_module(name, pack_file(filename,'r'),filename,('.py','r',imp.PY_SOURCE)) return sys.modules[name]
else:
dbg.Trace('importing from lib %s\\n' % name) module = _ModuleType(name)
return old_import(name,globals,locals,fromlist) sys.modules[name] = module
self.exec_module(module)
return sys.modules[name]
def splitext(p): def splitext(p):
root, ext = '', '' root, ext = '', ''
@@ -180,12 +194,18 @@ class PythonExecutioner:
def __LoadCompiledFile__(kPESelf, sFileName): def __LoadCompiledFile__(kPESelf, sFileName):
kFile=pack_open(sFileName) kFile=pack_open(sFileName)
if kFile.read(4)!=imp.get_magic(): magic = kFile.read(4)
if isinstance(magic, str):
magic = magic.encode("latin1")
if magic != _bootstrap_external.MAGIC_NUMBER:
raise raise
kFile.read(4) kFile.read(4)
kData=kFile.read() kData=kFile.read()
if isinstance(kData, str):
kData = kData.encode("latin1")
return marshal.loads(kData) return marshal.loads(kData)
def execfile(fileName, dict): def execfile(fileName, dict):
@@ -196,10 +216,12 @@ def exec_add_module_do(mod):
global execfile global execfile
mod.__dict__['execfile'] = execfile mod.__dict__['execfile'] = execfile
import builtins
builtins.__import__ = __pack_import
module_do = exec_add_module_do module_do = exec_add_module_do
meta_hook = custom_import_hook()
if meta_hook not in sys.meta_path:
sys.meta_path.insert(0, meta_hook)
""" """
# #
# PSYCO installation (must move to system.py, systemrelease.pyc) # PSYCO installation (must move to system.py, systemrelease.pyc)
@@ -287,7 +309,10 @@ def RunMainScript(name):
dbg.LogBox(msg) dbg.LogBox(msg)
app.Abort() app.Abort()
import debugInfo try:
import debugInfo
except ImportError:
import debuginfo as debugInfo
debugInfo.SetDebugMode(__DEBUG__) debugInfo.SetDebugMode(__DEBUG__)
loginMark = "-cs" loginMark = "-cs"

View File

@@ -2750,9 +2750,6 @@ class PythonScriptLoader(object):
def LoadScriptFile(self, window, FileName): def LoadScriptFile(self, window, FileName):
import exception import exception
import exceptions
import os
import errno
self.Clear() self.Clear()
print(("===== Load Script File : %s" % (FileName))) print(("===== Load Script File : %s" % (FileName)))

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.