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
812a2b65
Kaydet (Commit)
812a2b65
authored
Eyl 30, 2016
tarafından
Berker Peksag
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #28226: compileall now supports pathlib
üst
b4b55eb5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
0 deletions
+35
-0
compileall.rst
Doc/library/compileall.rst
+6
-0
compileall.py
Lib/compileall.py
+4
-0
test_compileall.py
Lib/test/test_compileall.py
+23
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/compileall.rst
Dosyayı görüntüle @
812a2b65
...
...
@@ -153,6 +153,9 @@ Public functions
The *legacy* parameter only writes out ``.pyc`` files, not ``.pyo`` files
no matter what the value of *optimize* is.
.. versionchanged:: 3.6
Accepts a :term:`path-like object`.
.. function:: compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1)
Compile the file with path *fullname*. Return a true value if the file
...
...
@@ -221,6 +224,9 @@ subdirectory and all its subdirectories::
import re
compileall.compile_dir('Lib/', rx=re.compile(r'[/\\][.]svn'), force=True)
# pathlib.Path objects can also be used.
import pathlib
compileall.compile_dir(pathlib.Path('Lib/'), force=True)
.. seealso::
...
...
Lib/compileall.py
Dosyayı görüntüle @
812a2b65
...
...
@@ -25,6 +25,8 @@ from functools import partial
__all__
=
[
"compile_dir"
,
"compile_file"
,
"compile_path"
]
def
_walk_dir
(
dir
,
ddir
=
None
,
maxlevels
=
10
,
quiet
=
0
):
if
quiet
<
2
and
isinstance
(
dir
,
os
.
PathLike
):
dir
=
os
.
fspath
(
dir
)
if
not
quiet
:
print
(
'Listing {!r}...'
.
format
(
dir
))
try
:
...
...
@@ -105,6 +107,8 @@ def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0,
optimize: optimization level or -1 for level of the interpreter
"""
success
=
True
if
quiet
<
2
and
isinstance
(
fullname
,
os
.
PathLike
):
fullname
=
os
.
fspath
(
fullname
)
name
=
os
.
path
.
basename
(
fullname
)
if
ddir
is
not
None
:
dfile
=
os
.
path
.
join
(
ddir
,
name
)
...
...
Lib/test/test_compileall.py
Dosyayı görüntüle @
812a2b65
...
...
@@ -102,6 +102,22 @@ class CompileallTests(unittest.TestCase):
self
.
assertFalse
(
compileall
.
compile_dir
(
self
.
directory
,
force
=
False
,
quiet
=
2
))
def
test_compile_file_pathlike
(
self
):
self
.
assertFalse
(
os
.
path
.
isfile
(
self
.
bc_path
))
# we should also test the output
with
support
.
captured_stdout
()
as
stdout
:
self
.
assertTrue
(
compileall
.
compile_file
(
pathlib
.
Path
(
self
.
source_path
)))
self
.
assertEqual
(
stdout
.
getvalue
(),
"Compiling '{}'...
\n
"
.
format
(
self
.
source_path
))
self
.
assertTrue
(
os
.
path
.
isfile
(
self
.
bc_path
))
def
test_compile_file_pathlike_ddir
(
self
):
self
.
assertFalse
(
os
.
path
.
isfile
(
self
.
bc_path
))
self
.
assertTrue
(
compileall
.
compile_file
(
pathlib
.
Path
(
self
.
source_path
),
ddir
=
pathlib
.
Path
(
'ddir_path'
),
quiet
=
2
))
self
.
assertTrue
(
os
.
path
.
isfile
(
self
.
bc_path
))
def
test_compile_path
(
self
):
with
test
.
test_importlib
.
util
.
import_state
(
path
=
[
self
.
directory
]):
self
.
assertTrue
(
compileall
.
compile_path
(
quiet
=
2
))
...
...
@@ -138,6 +154,13 @@ class CompileallTests(unittest.TestCase):
optimization
=
opt
)
self
.
assertTrue
(
os
.
path
.
isfile
(
cached3
))
def
test_compile_dir_pathlike
(
self
):
self
.
assertFalse
(
os
.
path
.
isfile
(
self
.
bc_path
))
with
support
.
captured_stdout
()
as
stdout
:
compileall
.
compile_dir
(
pathlib
.
Path
(
self
.
directory
))
self
.
assertIn
(
"Listing '{}'..."
.
format
(
self
.
directory
),
stdout
.
getvalue
())
self
.
assertTrue
(
os
.
path
.
isfile
(
self
.
bc_path
))
@mock.patch
(
'compileall.ProcessPoolExecutor'
)
def
test_compile_pool_called
(
self
,
pool_mock
):
compileall
.
compile_dir
(
self
.
directory
,
quiet
=
True
,
workers
=
5
)
...
...
Misc/NEWS
Dosyayı görüntüle @
812a2b65
...
...
@@ -46,6 +46,8 @@ Core and Builtins
Library
-------
- Issue #28226: compileall now supports pathlib.
- Issue #28314: Fix function declaration (C flags) for the getiterator() method
of xml.etree.ElementTree.Element.
...
...
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