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
0aa9782d
Kaydet (Commit)
0aa9782d
authored
Şub 25, 1998
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Helper routines to create standalone Python applications.
üst
f7d8f454
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
0 deletions
+91
-0
findmodulefiles.py
Mac/Lib/findmodulefiles.py
+91
-0
No files found.
Mac/Lib/findmodulefiles.py
0 → 100644
Dosyayı görüntüle @
0aa9782d
"""Findmodulefiles - Find out where modules are loaded from.
Run findmodulefiles() after running a program with "python -i". The
resulting file list can be given to mkfrozenresources or to a
(non-existent) freeze-like application.
findmodulefiles will create a file listing all modules and where they have
been imported from.
findunusedbuiltins takes a list of (modules, file) and prints all builtin modules
that are _not_ in the list. The list is created by opening the findmodulefiles
output, reading it and eval()ing that.
mkpycresource takes a list of (module, file) and creates a resourcefile with all those
modules and (optionally) a main module.
"""
def
findmodulefiles
(
output
=
None
):
"""Produce a file containing a list of (modulename, filename-or-None)
tuples mapping module names to source files"""
# Immedeately grab the names
import
sys
module_names
=
sys
.
modules
.
keys
()[:]
import
os
if
not
output
:
if
os
.
name
==
'mac'
:
import
macfs
output
,
ok
=
macfs
.
StandardPutFile
(
'Module file listing output:'
)
if
not
ok
:
sys
.
exit
(
0
)
output
=
output
.
as_pathname
()
if
not
output
:
output
=
sys
.
stdout
elif
type
(
output
)
==
type
(
''
):
output
=
open
(
output
,
'w'
)
output
.
write
(
'[
\n
'
)
for
name
in
module_names
:
try
:
source
=
sys
.
modules
[
name
]
.
__file__
except
AttributeError
:
source
=
None
else
:
source
=
`source`
output
.
write
(
'
\t
(
%
s,
\t
%
s),
\n
'
%
(
`name`
,
source
))
output
.
write
(
']
\n
'
)
del
output
def
findunusedbuiltins
(
list
):
"""Produce (on stdout) a list of unused builtin modules"""
import
sys
dict
=
{}
for
name
,
location
in
list
:
if
location
==
None
:
dict
[
name
]
=
1
for
name
in
sys
.
builtin_module_names
:
if
not
dict
.
has_key
(
name
):
print
'Unused builtin module:'
,
name
def
mkpycresourcefile
(
list
,
main
=
''
,
dst
=
None
):
"""Copy list-of-modules to resource file dst."""
import
py_resource
import
Res
import
sys
if
dst
==
None
:
import
macfs
fss
,
ok
=
macfs
.
StandardPutFile
(
"PYC Resource output file"
)
if
not
ok
:
sys
.
exit
(
0
)
dst
=
fss
.
as_pathname
()
if
main
==
''
:
import
macfs
fss
,
ok
=
macfs
.
PromptGetFile
(
"Main program:"
,
"TEXT"
)
if
ok
:
main
=
fss
.
as_pathname
()
fsid
=
py_resource
.
create
(
dst
)
if
main
:
id
,
name
=
py_resource
.
frompyfile
(
main
,
'__main__'
,
preload
=
1
)
print
'
%5
d
\t
%
s
\t
%
s'
%
(
id
,
name
,
main
)
for
name
,
location
in
list
:
if
not
location
:
continue
if
location
[
-
3
:]
!=
'.py'
:
print
'*** skipping'
,
location
continue
id
,
name
=
py_resource
.
frompyfile
(
location
,
name
,
preload
=
1
)
print
'
%5
d
\t
%
s
\t
%
s'
%
(
id
,
name
,
location
)
Res
.
CloseResFile
(
fsid
)
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