mirror of
https://github.com/python/cpython.git
synced 2025-09-11 11:17:16 +00:00
BuildApplet will now also update old applets
This commit is contained in:
parent
ebe914af7a
commit
8554e302a5
2 changed files with 96 additions and 68 deletions
|
@ -67,7 +67,7 @@ def main():
|
||||||
# Ask for source text if not specified in sys.argv[1:]
|
# Ask for source text if not specified in sys.argv[1:]
|
||||||
|
|
||||||
if not sys.argv[1:]:
|
if not sys.argv[1:]:
|
||||||
srcfss, ok = macfs.PromptGetFile('Select Python source file:', 'TEXT')
|
srcfss, ok = macfs.PromptGetFile('Select Python source or applet:', 'TEXT', 'APPL')
|
||||||
if not ok:
|
if not ok:
|
||||||
return
|
return
|
||||||
filename = srcfss.as_pathname()
|
filename = srcfss.as_pathname()
|
||||||
|
@ -75,15 +75,24 @@ def main():
|
||||||
if tf[-3:] == '.py':
|
if tf[-3:] == '.py':
|
||||||
tf = tf[:-3]
|
tf = tf[:-3]
|
||||||
else:
|
else:
|
||||||
tf = tf + '.applet'
|
tf = tf + '.out'
|
||||||
dstfss, ok = macfs.StandardPutFile('Save application as:', tf)
|
dstfss, ok = macfs.StandardPutFile('Save application as:', tf)
|
||||||
if not ok: return
|
if not ok: return
|
||||||
process(template, filename, dstfss.as_pathname())
|
dstfilename = dstfss.as_pathname()
|
||||||
|
cr, tp = MacOS.GetCreatorAndType(filename)
|
||||||
|
if tp == 'APPL':
|
||||||
|
update(template, filename, dstfilename)
|
||||||
|
else:
|
||||||
|
process(template, filename, dstfilename)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
# Loop over all files to be processed
|
# Loop over all files to be processed
|
||||||
for filename in sys.argv[1:]:
|
for filename in sys.argv[1:]:
|
||||||
process(template, filename, '')
|
cr, tp = MacOS.GetCreatorAndType(filename)
|
||||||
|
if tp == 'APPL':
|
||||||
|
update(template, filename, '')
|
||||||
|
else:
|
||||||
|
process(template, filename, '')
|
||||||
|
|
||||||
def process(template, filename, output):
|
def process(template, filename, output):
|
||||||
|
|
||||||
|
@ -116,10 +125,23 @@ def process(template, filename, output):
|
||||||
|
|
||||||
if output:
|
if output:
|
||||||
destname = output
|
destname = output
|
||||||
|
|
||||||
|
process_common(template, progress, code, rsrcname, destname, 0)
|
||||||
|
|
||||||
|
def update(template, filename, output):
|
||||||
|
if DEBUG:
|
||||||
|
progress = EasyDialogs.ProgressBar("Updating %s..."%os.path.split(filename)[1], 120)
|
||||||
|
else:
|
||||||
|
progress = None
|
||||||
|
if not output:
|
||||||
|
output = filename + ' (updated)'
|
||||||
|
process_common(template, progress, None, filename, output, 1)
|
||||||
|
|
||||||
|
|
||||||
|
def process_common(template, progress, code, rsrcname, destname, is_update):
|
||||||
# Try removing the output file
|
# Try removing the output file
|
||||||
try:
|
try:
|
||||||
os.unlink(output)
|
os.unlink(destname)
|
||||||
except os.error:
|
except os.error:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -163,7 +185,11 @@ def process(template, filename, output):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
progress.inc(50)
|
progress.inc(50)
|
||||||
else:
|
else:
|
||||||
typesfound, ownertype = copyres(input, output, [], 0, progress)
|
if is_update:
|
||||||
|
skip_oldfile = ['cfrg']
|
||||||
|
else:
|
||||||
|
skip_oldfile = []
|
||||||
|
typesfound, ownertype = copyres(input, output, skip_oldfile, 0, progress)
|
||||||
CloseResFile(input)
|
CloseResFile(input)
|
||||||
|
|
||||||
# Check which resource-types we should not copy from the template
|
# Check which resource-types we should not copy from the template
|
||||||
|
@ -195,32 +221,33 @@ def process(template, filename, output):
|
||||||
|
|
||||||
UseResFile(output)
|
UseResFile(output)
|
||||||
|
|
||||||
# Delete any existing 'PYC ' resource named __main__
|
if code:
|
||||||
|
# Delete any existing 'PYC ' resource named __main__
|
||||||
|
|
||||||
|
try:
|
||||||
|
res = Get1NamedResource(RESTYPE, RESNAME)
|
||||||
|
res.RemoveResource()
|
||||||
|
except Error:
|
||||||
|
pass
|
||||||
|
|
||||||
try:
|
# Create the raw data for the resource from the code object
|
||||||
res = Get1NamedResource(RESTYPE, RESNAME)
|
if DEBUG:
|
||||||
res.RemoveResource()
|
progress.label("Write PYC resource...")
|
||||||
except Error:
|
progress.set(120)
|
||||||
pass
|
|
||||||
|
data = marshal.dumps(code)
|
||||||
# Create the raw data for the resource from the code object
|
del code
|
||||||
if DEBUG:
|
data = (MAGIC + '\0\0\0\0') + data
|
||||||
progress.label("Write PYC resource...")
|
|
||||||
progress.set(120)
|
# Create the resource and write it
|
||||||
|
|
||||||
data = marshal.dumps(code)
|
id = 0
|
||||||
del code
|
while id < 128:
|
||||||
data = (MAGIC + '\0\0\0\0') + data
|
id = Unique1ID(RESTYPE)
|
||||||
|
res = Resource(data)
|
||||||
# Create the resource and write it
|
res.AddResource(RESTYPE, id, RESNAME)
|
||||||
|
res.WriteResource()
|
||||||
id = 0
|
res.ReleaseResource()
|
||||||
while id < 128:
|
|
||||||
id = Unique1ID(RESTYPE)
|
|
||||||
res = Resource(data)
|
|
||||||
res.AddResource(RESTYPE, id, RESNAME)
|
|
||||||
res.WriteResource()
|
|
||||||
res.ReleaseResource()
|
|
||||||
|
|
||||||
# Close the output file
|
# Close the output file
|
||||||
|
|
||||||
|
@ -252,8 +279,8 @@ def copyres(input, output, skiptypes, skipowner, progress=None):
|
||||||
res = Get1IndResource(type, ires)
|
res = Get1IndResource(type, ires)
|
||||||
id, type, name = res.GetResInfo()
|
id, type, name = res.GetResInfo()
|
||||||
lcname = string.lower(name)
|
lcname = string.lower(name)
|
||||||
if (type, lcname) == (RESTYPE, RESNAME):
|
## if (type, lcname) == (RESTYPE, RESNAME):
|
||||||
continue # Don't copy __main__ from template
|
## continue # Don't copy __main__ from template
|
||||||
# XXXX should look for id=0
|
# XXXX should look for id=0
|
||||||
if lcname == OWNERNAME:
|
if lcname == OWNERNAME:
|
||||||
if skipowner:
|
if skipowner:
|
||||||
|
|
|
@ -1,37 +1,38 @@
|
||||||
(This file must be converted with BinHex 4.0)
|
(This file must be converted with BinHex 4.0)
|
||||||
|
|
||||||
:%%*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