Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2f7bc74f
Commit
2f7bc74f
authored
Sep 24, 1995
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed the way .rsrc and template are copied: hopefully this will
finally get the bundle stuff right.
parent
5f867ee8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
36 deletions
+53
-36
Mac/scripts/BuildApplet.py
Mac/scripts/BuildApplet.py
+53
-36
No files found.
Mac/scripts/BuildApplet.py
View file @
2f7bc74f
...
...
@@ -31,6 +31,7 @@ RESTYPE = 'PYC '
RESNAME
=
'__main__'
# A resource with this name sets the "owner" (creator) of the destination
# XXXX Should look for id=0
OWNERNAME
=
"owner resource"
# OpenResFile mode parameters
...
...
@@ -60,7 +61,8 @@ def main():
# (there's no point in proceeding if we can't find it)
template
=
findtemplate
()
print
'Using template'
,
template
if
DEBUG
:
print
'Using template'
,
template
# Ask for source text if not specified in sys.argv[1:]
...
...
@@ -83,8 +85,6 @@ def main():
for
filename
in
sys
.
argv
[
1
:]:
process
(
template
,
filename
,
''
)
undefs
=
(
'Atmp'
,
'????'
,
' '
,
'
\
0
\
0
\
0
\
0
'
,
'BINA'
)
def
process
(
template
,
filename
,
output
):
if
DEBUG
:
...
...
@@ -113,12 +113,22 @@ def process(template, filename, output):
if
output
:
destname
=
output
# Copy the data from the template (creating the file as well)
# Try removing the output file
try
:
os
.
unlink
(
output
)
except
os
.
error
:
pass
# Create FSSpecs for the various files
template_fss
=
macfs
.
FSSpec
(
template
)
template_fss
,
d1
,
d2
=
macfs
.
ResolveAliasFile
(
template_fss
)
dest_fss
=
macfs
.
FSSpec
(
destname
)
# Copy data (not resources, yet) from the template
tmpl
=
open
(
template
,
"rb"
)
dest
=
open
(
destname
,
"wb"
)
data
=
tmpl
.
read
()
...
...
@@ -127,14 +137,6 @@ def process(template, filename, output):
dest
.
close
()
tmpl
.
close
()
# Copy the creator of the template to the destination
# unless it already got one. Set type to APPL
tctor
,
ttype
=
template_fss
.
GetCreatorType
()
ctor
,
type
=
dest_fss
.
GetCreatorType
()
if
type
in
undefs
:
type
=
'APPL'
if
ctor
in
undefs
:
ctor
=
tctor
# Open the output resource fork
try
:
...
...
@@ -144,30 +146,38 @@ def process(template, filename, output):
print
"Creating resource fork..."
CreateResFile
(
destname
)
output
=
FSpOpenResFile
(
dest_fss
,
WRITE
)
# Copy the resources from the template
input
=
FSpOpenResFile
(
template_fss
,
READ
)
newctor
=
copyres
(
input
,
output
)
CloseResFile
(
input
)
if
newctor
:
ctor
=
newctor
# Copy the resources from the target specific resource template, if any
typesfound
,
ownertype
=
[],
None
try
:
input
=
FSpOpenResFile
(
rsrcname
,
READ
)
except
(
MacOS
.
Error
,
ValueError
):
print
'No resource file'
,
rsrcname
pass
else
:
newctor
=
copyres
(
input
,
output
)
typesfound
,
ownertype
=
copyres
(
input
,
output
,
[],
0
)
CloseResFile
(
input
)
if
newctor
:
ctor
=
newctor
# Check which resource-types we should not copy from the template
skiptypes
=
[]
if
'SIZE'
in
typesfound
:
skiptypes
.
append
(
'SIZE'
)
if
'BNDL'
in
typesfound
:
skiptypes
=
skiptypes
+
[
'BNDL'
,
'FREF'
,
'icl4'
,
'icl8'
,
'ics4'
,
'ics8'
,
'ICN#'
,
'ics#'
]
skipowner
=
(
ownertype
<>
None
)
# Copy the resources from the template
input
=
FSpOpenResFile
(
template_fss
,
READ
)
dummy
,
tmplowner
=
copyres
(
input
,
output
,
skiptypes
,
skipowner
)
if
ownertype
==
None
:
ownertype
=
tmplowner
CloseResFile
(
input
)
if
ownertype
==
None
:
die
(
"No owner resource found in either resource file or template"
)
# Now set the creator, type and bundle bit of the destination
dest_finfo
=
dest_fss
.
GetFInfo
()
dest_finfo
.
Creator
=
ctor
dest_finfo
.
Type
=
type
dest_finfo
.
Creator
=
ownertype
dest_finfo
.
Type
=
'APPL'
dest_finfo
.
Flags
=
dest_finfo
.
Flags
|
MACFS
.
kHasBundle
dest_finfo
.
Flags
=
dest_finfo
.
Flags
&
~
MACFS
.
kHasBeenInited
dest_fss
.
SetFInfo
(
dest_finfo
)
...
...
@@ -176,7 +186,7 @@ def process(template, filename, output):
UseResFile
(
output
)
# Delete any existing 'PYC 'resource named __main__
# Delete any existing 'PYC '
resource named __main__
try
:
res
=
Get1NamedResource
(
RESTYPE
,
RESNAME
)
...
...
@@ -210,16 +220,19 @@ def process(template, filename, output):
# Copy resources between two resource file descriptors.
# Exception: don't copy a __main__ resource.
# If a resource's name is "owner resource", its type is returned
# (so the caller can use it to set the destination's creator)
def
copyres
(
input
,
output
):
# skip a resource named '__main__' or (if skipowner is set) 'Owner resource'.
# Also skip resources with a type listed in skiptypes.
#
def
copyres
(
input
,
output
,
skiptypes
,
skipowner
):
ctor
=
None
alltypes
=
[]
UseResFile
(
input
)
ntypes
=
Count1Types
()
for
itype
in
range
(
1
,
1
+
ntypes
):
type
=
Get1IndType
(
itype
)
if
type
in
skiptypes
:
continue
alltypes
.
append
(
type
)
nresources
=
Count1Resources
(
type
)
for
ires
in
range
(
1
,
1
+
nresources
):
res
=
Get1IndResource
(
type
,
ires
)
...
...
@@ -227,7 +240,12 @@ def copyres(input, output):
lcname
=
string
.
lower
(
name
)
if
(
type
,
lcname
)
==
(
RESTYPE
,
RESNAME
):
continue
# Don't copy __main__ from template
if
lcname
==
OWNERNAME
:
ctor
=
type
# XXXX should look for id=0
if
lcname
==
OWNERNAME
:
if
skipowner
:
continue
# Skip this one
else
:
ctor
=
type
size
=
res
.
size
attrs
=
res
.
GetResAttrs
()
if
DEBUG
:
...
...
@@ -250,7 +268,7 @@ def copyres(input, output):
print
"New attrs ="
,
hex
(
attrs
)
res
.
SetResAttrs
(
attrs
)
UseResFile
(
input
)
return
ctor
return
alltypes
,
ctor
# Show a message and exit
...
...
@@ -279,4 +297,3 @@ def message(str, id = 256):
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment