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
f4803aa6
Kaydet (Commit)
f4803aa6
authored
Mar 08, 2010
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
set svn:eol-style on various files
üst
d22557cf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
145 additions
and
145 deletions
+145
-145
cp720.py
Lib/encodings/cp720.py
+0
-0
merge.py
Tools/msi/merge.py
+84
-84
genwincodec.py
Tools/unicode/genwincodec.py
+61
-61
No files found.
Lib/encodings/cp720.py
Dosyayı görüntüle @
f4803aa6
This diff is collapsed.
Click to expand it.
Tools/msi/merge.py
Dosyayı görüntüle @
f4803aa6
import
msilib
,
os
,
win32com
,
tempfile
,
sys
PCBUILD
=
"PCBuild"
certname
=
None
from
config
import
*
Win64
=
"amd64"
in
PCBUILD
mod_dir
=
os
.
path
.
join
(
os
.
environ
[
"ProgramFiles"
],
"Common Files"
,
"Merge Modules"
)
msi
=
None
if
len
(
sys
.
argv
)
==
2
:
msi
=
sys
.
argv
[
1
]
if
Win64
:
modules
=
[
"Microsoft_VC90_CRT_x86_x64.msm"
,
"policy_9_0_Microsoft_VC90_CRT_x86_x64.msm"
]
if
not
msi
:
msi
=
"python-
%
s.amd64.msi"
%
full_current_version
else
:
modules
=
[
"Microsoft_VC90_CRT_x86.msm"
,
"policy_9_0_Microsoft_VC90_CRT_x86.msm"
]
if
not
msi
:
msi
=
"python-
%
s.msi"
%
full_current_version
for
i
,
n
in
enumerate
(
modules
):
modules
[
i
]
=
os
.
path
.
join
(
mod_dir
,
n
)
def
merge
(
msi
,
feature
,
rootdir
,
modules
):
cab_and_filecount
=
[]
# Step 1: Merge databases, extract cabfiles
m
=
msilib
.
MakeMerge2
()
m
.
OpenLog
(
"merge.log"
)
print
"Opened Log"
m
.
OpenDatabase
(
msi
)
print
"Opened DB"
for
module
in
modules
:
print
module
m
.
OpenModule
(
module
,
0
)
print
"Opened Module"
,
module
m
.
Merge
(
feature
,
rootdir
)
print
"Errors:"
for
e
in
m
.
Errors
:
print
e
.
Type
,
e
.
ModuleTable
,
e
.
DatabaseTable
print
" Modkeys:"
,
for
s
in
e
.
ModuleKeys
:
print
s
,
print
print
" DBKeys:"
,
for
s
in
e
.
DatabaseKeys
:
print
s
,
print
cabname
=
tempfile
.
mktemp
(
suffix
=
".cab"
)
m
.
ExtractCAB
(
cabname
)
cab_and_filecount
.
append
((
cabname
,
len
(
m
.
ModuleFiles
)))
m
.
CloseModule
()
m
.
CloseDatabase
(
True
)
m
.
CloseLog
()
# Step 2: Add CAB files
i
=
msilib
.
MakeInstaller
()
db
=
i
.
OpenDatabase
(
msi
,
win32com
.
client
.
constants
.
msiOpenDatabaseModeTransact
)
v
=
db
.
OpenView
(
"SELECT LastSequence FROM Media"
)
v
.
Execute
(
None
)
maxmedia
=
-
1
while
1
:
r
=
v
.
Fetch
()
if
not
r
:
break
seq
=
r
.
IntegerData
(
1
)
if
seq
>
maxmedia
:
maxmedia
=
seq
print
"Start of Media"
,
maxmedia
for
cabname
,
count
in
cab_and_filecount
:
stream
=
"merged
%
d"
%
maxmedia
msilib
.
add_data
(
db
,
"Media"
,
[(
maxmedia
+
1
,
maxmedia
+
count
,
None
,
"#"
+
stream
,
None
,
None
)])
msilib
.
add_stream
(
db
,
stream
,
cabname
)
os
.
unlink
(
cabname
)
maxmedia
+=
count
# The merge module sets ALLUSERS to 1 in the property table.
# This is undesired; delete that
v
=
db
.
OpenView
(
"DELETE FROM Property WHERE Property='ALLUSERS'"
)
v
.
Execute
(
None
)
v
.
Close
()
db
.
Commit
()
merge
(
msi
,
"SharedCRT"
,
"TARGETDIR"
,
modules
)
# certname (from config.py) should be (a substring of)
# the certificate subject, e.g. "Python Software Foundation"
if
certname
:
os
.
system
(
'signtool sign /n "
%
s" /t http://timestamp.verisign.com/scripts/timestamp.dll
%
s'
%
(
certname
,
msi
))
import
msilib
,
os
,
win32com
,
tempfile
,
sys
PCBUILD
=
"PCBuild"
certname
=
None
from
config
import
*
Win64
=
"amd64"
in
PCBUILD
mod_dir
=
os
.
path
.
join
(
os
.
environ
[
"ProgramFiles"
],
"Common Files"
,
"Merge Modules"
)
msi
=
None
if
len
(
sys
.
argv
)
==
2
:
msi
=
sys
.
argv
[
1
]
if
Win64
:
modules
=
[
"Microsoft_VC90_CRT_x86_x64.msm"
,
"policy_9_0_Microsoft_VC90_CRT_x86_x64.msm"
]
if
not
msi
:
msi
=
"python-
%
s.amd64.msi"
%
full_current_version
else
:
modules
=
[
"Microsoft_VC90_CRT_x86.msm"
,
"policy_9_0_Microsoft_VC90_CRT_x86.msm"
]
if
not
msi
:
msi
=
"python-
%
s.msi"
%
full_current_version
for
i
,
n
in
enumerate
(
modules
):
modules
[
i
]
=
os
.
path
.
join
(
mod_dir
,
n
)
def
merge
(
msi
,
feature
,
rootdir
,
modules
):
cab_and_filecount
=
[]
# Step 1: Merge databases, extract cabfiles
m
=
msilib
.
MakeMerge2
()
m
.
OpenLog
(
"merge.log"
)
print
"Opened Log"
m
.
OpenDatabase
(
msi
)
print
"Opened DB"
for
module
in
modules
:
print
module
m
.
OpenModule
(
module
,
0
)
print
"Opened Module"
,
module
m
.
Merge
(
feature
,
rootdir
)
print
"Errors:"
for
e
in
m
.
Errors
:
print
e
.
Type
,
e
.
ModuleTable
,
e
.
DatabaseTable
print
" Modkeys:"
,
for
s
in
e
.
ModuleKeys
:
print
s
,
print
print
" DBKeys:"
,
for
s
in
e
.
DatabaseKeys
:
print
s
,
print
cabname
=
tempfile
.
mktemp
(
suffix
=
".cab"
)
m
.
ExtractCAB
(
cabname
)
cab_and_filecount
.
append
((
cabname
,
len
(
m
.
ModuleFiles
)))
m
.
CloseModule
()
m
.
CloseDatabase
(
True
)
m
.
CloseLog
()
# Step 2: Add CAB files
i
=
msilib
.
MakeInstaller
()
db
=
i
.
OpenDatabase
(
msi
,
win32com
.
client
.
constants
.
msiOpenDatabaseModeTransact
)
v
=
db
.
OpenView
(
"SELECT LastSequence FROM Media"
)
v
.
Execute
(
None
)
maxmedia
=
-
1
while
1
:
r
=
v
.
Fetch
()
if
not
r
:
break
seq
=
r
.
IntegerData
(
1
)
if
seq
>
maxmedia
:
maxmedia
=
seq
print
"Start of Media"
,
maxmedia
for
cabname
,
count
in
cab_and_filecount
:
stream
=
"merged
%
d"
%
maxmedia
msilib
.
add_data
(
db
,
"Media"
,
[(
maxmedia
+
1
,
maxmedia
+
count
,
None
,
"#"
+
stream
,
None
,
None
)])
msilib
.
add_stream
(
db
,
stream
,
cabname
)
os
.
unlink
(
cabname
)
maxmedia
+=
count
# The merge module sets ALLUSERS to 1 in the property table.
# This is undesired; delete that
v
=
db
.
OpenView
(
"DELETE FROM Property WHERE Property='ALLUSERS'"
)
v
.
Execute
(
None
)
v
.
Close
()
db
.
Commit
()
merge
(
msi
,
"SharedCRT"
,
"TARGETDIR"
,
modules
)
# certname (from config.py) should be (a substring of)
# the certificate subject, e.g. "Python Software Foundation"
if
certname
:
os
.
system
(
'signtool sign /n "
%
s" /t http://timestamp.verisign.com/scripts/timestamp.dll
%
s'
%
(
certname
,
msi
))
Tools/unicode/genwincodec.py
Dosyayı görüntüle @
f4803aa6
"""This script generates a Python codec module from a Windows Code Page.
It uses the function MultiByteToWideChar to generate a decoding table.
"""
import
ctypes
from
ctypes
import
wintypes
from
gencodec
import
codegen
import
unicodedata
def
genwinmap
(
codepage
):
MultiByteToWideChar
=
ctypes
.
windll
.
kernel32
.
MultiByteToWideChar
MultiByteToWideChar
.
argtypes
=
[
wintypes
.
UINT
,
wintypes
.
DWORD
,
wintypes
.
LPCSTR
,
ctypes
.
c_int
,
wintypes
.
LPWSTR
,
ctypes
.
c_int
]
MultiByteToWideChar
.
restype
=
ctypes
.
c_int
enc2uni
=
{}
for
i
in
range
(
32
)
+
[
127
]:
enc2uni
[
i
]
=
(
i
,
'CONTROL CHARACTER'
)
for
i
in
range
(
256
):
buf
=
ctypes
.
create_unicode_buffer
(
2
)
ret
=
MultiByteToWideChar
(
codepage
,
0
,
chr
(
i
),
1
,
buf
,
2
)
assert
ret
==
1
,
"invalid code page"
assert
buf
[
1
]
==
'
\x00
'
try
:
name
=
unicodedata
.
name
(
buf
[
0
])
except
ValueError
:
try
:
name
=
enc2uni
[
i
][
1
]
except
KeyError
:
name
=
''
enc2uni
[
i
]
=
(
ord
(
buf
[
0
]),
name
)
return
enc2uni
def
genwincodec
(
codepage
):
import
platform
map
=
genwinmap
(
codepage
)
encodingname
=
'cp
%
d'
%
codepage
code
=
codegen
(
""
,
map
,
encodingname
)
# Replace first lines with our own docstring
code
=
'''
\
"""Python Character Mapping Codec
%
s generated on Windows:
%
s with the command:
python Tools/unicode/genwincodec.py
%
s
"""#"
'''
%
(
encodingname
,
' '
.
join
(
platform
.
win32_ver
()),
codepage
)
+
code
.
split
(
'"""#"'
,
1
)[
1
]
print
code
if
__name__
==
'__main__'
:
import
sys
genwincodec
(
int
(
sys
.
argv
[
1
]))
"""This script generates a Python codec module from a Windows Code Page.
It uses the function MultiByteToWideChar to generate a decoding table.
"""
import
ctypes
from
ctypes
import
wintypes
from
gencodec
import
codegen
import
unicodedata
def
genwinmap
(
codepage
):
MultiByteToWideChar
=
ctypes
.
windll
.
kernel32
.
MultiByteToWideChar
MultiByteToWideChar
.
argtypes
=
[
wintypes
.
UINT
,
wintypes
.
DWORD
,
wintypes
.
LPCSTR
,
ctypes
.
c_int
,
wintypes
.
LPWSTR
,
ctypes
.
c_int
]
MultiByteToWideChar
.
restype
=
ctypes
.
c_int
enc2uni
=
{}
for
i
in
range
(
32
)
+
[
127
]:
enc2uni
[
i
]
=
(
i
,
'CONTROL CHARACTER'
)
for
i
in
range
(
256
):
buf
=
ctypes
.
create_unicode_buffer
(
2
)
ret
=
MultiByteToWideChar
(
codepage
,
0
,
chr
(
i
),
1
,
buf
,
2
)
assert
ret
==
1
,
"invalid code page"
assert
buf
[
1
]
==
'
\x00
'
try
:
name
=
unicodedata
.
name
(
buf
[
0
])
except
ValueError
:
try
:
name
=
enc2uni
[
i
][
1
]
except
KeyError
:
name
=
''
enc2uni
[
i
]
=
(
ord
(
buf
[
0
]),
name
)
return
enc2uni
def
genwincodec
(
codepage
):
import
platform
map
=
genwinmap
(
codepage
)
encodingname
=
'cp
%
d'
%
codepage
code
=
codegen
(
""
,
map
,
encodingname
)
# Replace first lines with our own docstring
code
=
'''
\
"""Python Character Mapping Codec
%
s generated on Windows:
%
s with the command:
python Tools/unicode/genwincodec.py
%
s
"""#"
'''
%
(
encodingname
,
' '
.
join
(
platform
.
win32_ver
()),
codepage
)
+
code
.
split
(
'"""#"'
,
1
)[
1
]
print
code
if
__name__
==
'__main__'
:
import
sys
genwincodec
(
int
(
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