Commit d3b06a87 authored by Jack Jansen's avatar Jack Jansen

Added optional preload arg to some routines (which creates reloaded

resources when set)
parent 7fb76e0f
...@@ -28,30 +28,34 @@ def open(dst): ...@@ -28,30 +28,34 @@ def open(dst):
Res.UseResFile(output) Res.UseResFile(output)
return output return output
def writemodule(name, id, data, type='PYC '): def writemodule(name, id, data, type='PYC ', preload=0):
"""Write pyc code to a PYC resource with given name and id.""" """Write pyc code to a PYC resource with given name and id."""
# XXXX Check that it doesn't exist # XXXX Check that it doesn't exist
res = Res.Resource(data) res = Res.Resource(data)
res.AddResource(type, id, name) res.AddResource(type, id, name)
if preload:
attrs = res.GetResAttrs()
attrs = attrs | 0x04
res.SetResAttrs(attrs)
res.WriteResource() res.WriteResource()
res.ReleaseResource() res.ReleaseResource()
def frompycfile(file, name=None): def frompycfile(file, name=None, preload=0):
"""Copy one pyc file to the open resource file""" """Copy one pyc file to the open resource file"""
if name == None: if name == None:
d, name = os.path.split(file) d, name = os.path.split(file)
name = name[:-4] name = name[:-4]
id = findfreeid() id = findfreeid()
writemodule(name, id, __builtin__.open(file, 'rb').read()) writemodule(name, id, __builtin__.open(file, 'rb').read(), preload=preload)
return id, name return id, name
def frompyfile(file, name=None): def frompyfile(file, name=None, preload=0):
"""Compile python source file to pyc file and add to resource file""" """Compile python source file to pyc file and add to resource file"""
import py_compile import py_compile
py_compile.compile(file) py_compile.compile(file)
file = file +'c' file = file +'c'
return frompycfile(file, name) return frompycfile(file, name, preload=preload)
# XXXX Note this is incorrect, it only handles one type and one file.... # XXXX Note this is incorrect, it only handles one type and one file....
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment