Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
3f14f4a3
Kaydet (Commit)
3f14f4a3
authored
Eyl 24, 1995
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Changed the way .rsrc and template are copied: hopefully this will
finally get the bundle stuff right.
üst
9722ad88
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
36 deletions
+53
-36
BuildApplet.py
Mac/scripts/BuildApplet.py
+53
-36
No files found.
Mac/scripts/BuildApplet.py
Dosyayı görüntüle @
3f14f4a3
...
...
@@ -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