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
0acb7f7a
Kaydet (Commit)
0acb7f7a
authored
May 31, 1996
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Module to handle PYC resources
üst
31dd5c08
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
0 deletions
+76
-0
py_resource.py
Mac/Lib/py_resource.py
+76
-0
No files found.
Mac/Lib/py_resource.py
0 → 100644
Dosyayı görüntüle @
0acb7f7a
"""Creation of PYC resources"""
import
os
import
Res
import
__builtin__
READ
=
1
WRITE
=
2
smAllScripts
=
-
3
def
Pstring
(
str
):
"""Return a pascal-style string from a python-style string"""
if
len
(
str
)
>
255
:
raise
ValueError
,
'String too large'
return
chr
(
len
(
str
))
+
str
def
create
(
dst
,
creator
=
'Pyth'
):
"""Create output file. Return handle and first id to use."""
try
:
os
.
unlink
(
dst
)
except
os
.
error
:
pass
Res
.
FSpCreateResFile
(
dst
,
creator
,
'rsrc'
,
smAllScripts
)
return
open
(
dst
)
def
open
(
dst
):
output
=
Res
.
FSpOpenResFile
(
dst
,
WRITE
)
Res
.
UseResFile
(
output
)
return
output
def
writemodule
(
name
,
id
,
data
,
type
=
'PYC '
):
"""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
)
res
.
WriteResource
()
res
.
ReleaseResource
()
def
frompycfile
(
file
,
name
=
None
):
"""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
())
return
id
,
name
def
frompyfile
(
file
,
name
=
None
):
"""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
)
# XXXX Note this is incorrect, it only handles one type and one file....
_firstfreeid
=
None
def
findfreeid
(
type
=
'PYC '
):
"""Find next free id-number for given resource type"""
global
_firstfreeid
if
_firstfreeid
==
None
:
Res
.
SetResLoad
(
0
)
highest
=
511
num
=
Res
.
Count1Resources
(
type
)
for
i
in
range
(
1
,
num
+
1
):
r
=
Res
.
Get1IndResource
(
type
,
i
)
id
,
d1
,
d2
=
r
.
GetResInfo
()
highest
=
max
(
highest
,
id
)
Res
.
SetResLoad
(
1
)
_firstfreeid
=
highest
+
1
id
=
_firstfreeid
_firstfreeid
=
_firstfreeid
+
1
return
id
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