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
eaa1959c
Kaydet (Commit)
eaa1959c
authored
May 31, 1996
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Use py_resource module
üst
0acb7f7a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
46 deletions
+10
-46
PackLibDir.py
Mac/scripts/PackLibDir.py
+10
-46
No files found.
Mac/scripts/PackLibDir.py
Dosyayı görüntüle @
eaa1959c
...
@@ -6,69 +6,33 @@ from Resources import *
...
@@ -6,69 +6,33 @@ from Resources import *
import
os
import
os
import
macfs
import
macfs
import
sys
import
sys
import
py_resource
READ
=
1
WRITE
=
2
smAllScripts
=
-
3
error
=
'mkpycresourcefile.error'
error
=
'mkpycresourcefile.error'
def
Pstring
(
str
):
if
len
(
str
)
>
255
:
raise
ValueError
,
'String too large'
return
chr
(
len
(
str
))
+
str
def
createoutput
(
dst
):
"""Create output file. Return handle and first id to use."""
FSpCreateResFile
(
dst
,
'Pyth'
,
'rsrc'
,
smAllScripts
)
output
=
FSpOpenResFile
(
dst
,
WRITE
)
UseResFile
(
output
)
num
=
128
return
output
,
num
def
writemodule
(
name
,
id
,
data
):
"""Write pyc code to a PYC resource with given name and id."""
# XXXX Check that it doesn't exist
res
=
Resource
(
data
)
res
.
AddResource
(
'PYC '
,
id
,
name
)
res
.
WriteResource
()
res
.
ReleaseResource
()
def
mkpycresourcefile
(
src
,
dst
):
def
mkpycresourcefile
(
src
,
dst
):
"""Copy pyc file/dir src to resource file dst."""
"""Copy pyc file/dir src to resource file dst."""
if
not
os
.
path
.
isdir
(
src
)
and
src
[
-
4
:]
<>
'.pyc'
:
if
not
os
.
path
.
isdir
(
src
)
and
src
[
-
4
:]
<>
'.pyc'
:
raise
error
,
'I can only handle .pyc files or directories'
raise
error
,
'I can only handle .pyc files or directories'
handle
,
oid
=
createoutput
(
dst
)
fsid
=
py_resource
.
create
(
dst
)
if
os
.
path
.
isdir
(
src
):
if
os
.
path
.
isdir
(
src
):
id
=
handlesubdir
(
handle
,
oid
,
src
)
handlesubdir
(
src
)
else
:
else
:
id
=
handleonepycfile
(
handle
,
oid
,
src
)
id
,
name
=
py_resource
.
frompycfile
(
src
)
print
'Wrote'
,
id
-
oid
,
'PYC resources to'
,
dst
print
'Wrote
%
d:
%
s
%
s'
%
(
id
,
name
,
src
)
CloseResFile
(
handle
)
CloseResFile
(
fsid
)
def
handleonepycfile
(
handle
,
id
,
file
):
def
handlesubdir
(
srcdir
):
"""Copy one pyc file to the open resource file"""
d
,
name
=
os
.
path
.
split
(
file
)
name
=
name
[:
-
4
]
print
' module'
,
name
writemodule
(
name
,
id
,
open
(
file
,
'rb'
)
.
read
())
return
id
+
1
def
handlesubdir
(
handle
,
id
,
srcdir
):
"""Recursively scan a directory for pyc files and copy to resources"""
"""Recursively scan a directory for pyc files and copy to resources"""
print
'Directory'
,
srcdir
src
=
os
.
listdir
(
srcdir
)
src
=
os
.
listdir
(
srcdir
)
for
file
in
src
:
for
file
in
src
:
file
=
os
.
path
.
join
(
srcdir
,
file
)
file
=
os
.
path
.
join
(
srcdir
,
file
)
if
os
.
path
.
isdir
(
file
):
if
os
.
path
.
isdir
(
file
):
id
=
handlesubdir
(
handle
,
id
,
file
)
handlesubdir
(
file
)
elif
file
[
-
4
:]
==
'.pyc'
:
elif
file
[
-
4
:]
==
'.pyc'
:
id
=
handleonepycfile
(
handle
,
id
,
file
)
id
,
name
=
py_resource
.
frompycfile
(
file
)
return
id
print
'Wrote
%
d:
%
s
%
s'
%
(
id
,
name
,
file
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
args
=
sys
.
argv
[
1
:]
args
=
sys
.
argv
[
1
:]
...
...
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