summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1997-06-12 10:50:47 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1997-06-12 10:50:47 (GMT)
commitd3b06a871f8bb6bec1b02fd1f5ddb1225c26cb34 (patch)
tree0b6ed299e8ef640c14d8efa9c2fe64116707bf2d /Mac
parent7fb76e0f8af58d437dc4801e1899eba4d633a31d (diff)
downloadcpython-d3b06a871f8bb6bec1b02fd1f5ddb1225c26cb34.zip
cpython-d3b06a871f8bb6bec1b02fd1f5ddb1225c26cb34.tar.gz
cpython-d3b06a871f8bb6bec1b02fd1f5ddb1225c26cb34.tar.bz2
Added optional preload arg to some routines (which creates reloaded
resources when set)
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Lib/py_resource.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Mac/Lib/py_resource.py b/Mac/Lib/py_resource.py
index 8530b59..3c1343e 100644
--- a/Mac/Lib/py_resource.py
+++ b/Mac/Lib/py_resource.py
@@ -28,30 +28,34 @@ def open(dst):
Res.UseResFile(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."""
# XXXX Check that it doesn't exist
res = Res.Resource(data)
res.AddResource(type, id, name)
+ if preload:
+ attrs = res.GetResAttrs()
+ attrs = attrs | 0x04
+ res.SetResAttrs(attrs)
res.WriteResource()
res.ReleaseResource()
-def frompycfile(file, name=None):
+def frompycfile(file, name=None, preload=0):
"""Copy one pyc file to the open resource file"""
if name == None:
d, name = os.path.split(file)
name = name[:-4]
id = findfreeid()
- writemodule(name, id, __builtin__.open(file, 'rb').read())
+ writemodule(name, id, __builtin__.open(file, 'rb').read(), preload=preload)
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"""
import py_compile
py_compile.compile(file)
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....