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
21a9c748
Kaydet (Commit)
21a9c748
authored
May 19, 2011
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
packaging: use with open() instead of try/finally: close
üst
0e3f3a70
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
42 additions
and
70 deletions
+42
-70
config.py
Lib/packaging/command/config.py
+18
-20
upload_docs.py
Lib/packaging/command/upload_docs.py
+7
-8
ccompiler.py
Lib/packaging/compiler/ccompiler.py
+1
-4
support.py
Lib/packaging/tests/support.py
+1
-4
test_command_build_scripts.py
Lib/packaging/tests/test_command_build_scripts.py
+1
-4
test_command_install_dist.py
Lib/packaging/tests/test_command_install_dist.py
+1
-4
test_command_install_scripts.py
Lib/packaging/tests/test_command_install_scripts.py
+1
-4
test_create.py
Lib/packaging/tests/test_create.py
+1
-4
test_pypi_server.py
Lib/packaging/tests/test_pypi_server.py
+3
-5
test_util.py
Lib/packaging/tests/test_util.py
+7
-9
util.py
Lib/packaging/util.py
+1
-4
No files found.
Lib/packaging/command/config.py
Dosyayı görüntüle @
21a9c748
...
...
@@ -110,15 +110,14 @@ class config(Command):
def
_gen_temp_sourcefile
(
self
,
body
,
headers
,
lang
):
filename
=
"_configtest"
+
LANG_EXT
[
lang
]
file
=
open
(
filename
,
"w"
)
if
headers
:
for
header
in
headers
:
file
.
write
(
"#include <
%
s>
\n
"
%
header
)
file
.
write
(
"
\n
"
)
file
.
write
(
body
)
if
body
[
-
1
]
!=
"
\n
"
:
file
.
write
(
"
\n
"
)
file
.
close
()
with
open
(
filename
,
"w"
)
as
file
:
if
headers
:
for
header
in
headers
:
file
.
write
(
"#include <
%
s>
\n
"
%
header
)
file
.
write
(
"
\n
"
)
file
.
write
(
body
)
if
body
[
-
1
]
!=
"
\n
"
:
file
.
write
(
"
\n
"
)
return
filename
def
_preprocess
(
self
,
body
,
headers
,
include_dirs
,
lang
):
...
...
@@ -207,17 +206,16 @@ class config(Command):
if
isinstance
(
pattern
,
str
):
pattern
=
re
.
compile
(
pattern
)
file
=
open
(
out
)
match
=
False
while
True
:
line
=
file
.
readline
()
if
line
==
''
:
break
if
pattern
.
search
(
line
):
match
=
True
break
file
.
close
()
with
open
(
out
)
as
file
:
match
=
False
while
True
:
line
=
file
.
readline
()
if
line
==
''
:
break
if
pattern
.
search
(
line
):
match
=
True
break
self
.
_clean
()
return
match
...
...
Lib/packaging/command/upload_docs.py
Dosyayı görüntüle @
21a9c748
...
...
@@ -18,14 +18,13 @@ from packaging.command.cmd import Command
def
zip_dir
(
directory
):
"""Compresses recursively contents of directory into a BytesIO object"""
destination
=
BytesIO
()
zip_file
=
zipfile
.
ZipFile
(
destination
,
"w"
)
for
root
,
dirs
,
files
in
os
.
walk
(
directory
):
for
name
in
files
:
full
=
os
.
path
.
join
(
root
,
name
)
relative
=
root
[
len
(
directory
):]
.
lstrip
(
os
.
path
.
sep
)
dest
=
os
.
path
.
join
(
relative
,
name
)
zip_file
.
write
(
full
,
dest
)
zip_file
.
close
()
with
zipfile
.
ZipFile
(
destination
,
"w"
)
as
zip_file
:
for
root
,
dirs
,
files
in
os
.
walk
(
directory
):
for
name
in
files
:
full
=
os
.
path
.
join
(
root
,
name
)
relative
=
root
[
len
(
directory
):]
.
lstrip
(
os
.
path
.
sep
)
dest
=
os
.
path
.
join
(
relative
,
name
)
zip_file
.
write
(
full
,
dest
)
return
destination
...
...
Lib/packaging/compiler/ccompiler.py
Dosyayı görüntüle @
21a9c748
...
...
@@ -728,8 +728,7 @@ class CCompiler:
if
library_dirs
is
None
:
library_dirs
=
[]
fd
,
fname
=
tempfile
.
mkstemp
(
".c"
,
funcname
,
text
=
True
)
f
=
os
.
fdopen
(
fd
,
"w"
)
try
:
with
os
.
fdopen
(
fd
,
"w"
)
as
f
:
for
incl
in
includes
:
f
.
write
(
"""#include "
%
s"
\n
"""
%
incl
)
f
.
write
(
"""
\
...
...
@@ -737,8 +736,6 @@ main (int argc, char **argv) {
%
s();
}
"""
%
funcname
)
finally
:
f
.
close
()
try
:
objects
=
self
.
compile
([
fname
],
include_dirs
=
include_dirs
)
except
CompileError
:
...
...
Lib/packaging/tests/support.py
Dosyayı görüntüle @
21a9c748
...
...
@@ -146,11 +146,8 @@ class TempdirManager:
"""
if
isinstance
(
path
,
(
list
,
tuple
)):
path
=
os
.
path
.
join
(
*
path
)
f
=
open
(
path
,
'w'
)
try
:
with
open
(
path
,
'w'
)
as
f
:
f
.
write
(
content
)
finally
:
f
.
close
()
def
create_dist
(
self
,
**
kw
):
"""Create a stub distribution object and files.
...
...
Lib/packaging/tests/test_command_build_scripts.py
Dosyayı görüntüle @
21a9c748
...
...
@@ -71,11 +71,8 @@ class BuildScriptsTestCase(support.TempdirManager,
return
expected
def
write_script
(
self
,
dir
,
name
,
text
):
f
=
open
(
os
.
path
.
join
(
dir
,
name
),
"w"
)
try
:
with
open
(
os
.
path
.
join
(
dir
,
name
),
"w"
)
as
f
:
f
.
write
(
text
)
finally
:
f
.
close
()
def
test_version_int
(
self
):
source
=
self
.
mkdtemp
()
...
...
Lib/packaging/tests/test_command_install_dist.py
Dosyayı görüntüle @
21a9c748
...
...
@@ -193,11 +193,8 @@ class InstallTestCase(support.TempdirManager,
# let's check the record file was created with four
# lines, one for each .dist-info entry: METADATA,
# INSTALLER, REQUSTED, RECORD
f
=
open
(
cmd
.
record
)
try
:
with
open
(
cmd
.
record
)
as
f
:
self
.
assertEqual
(
len
(
f
.
readlines
()),
4
)
finally
:
f
.
close
()
# XXX test that fancy_getopt is okay with options named
# record and no-record but unrelated
...
...
Lib/packaging/tests/test_command_install_scripts.py
Dosyayı görüntüle @
21a9c748
...
...
@@ -38,11 +38,8 @@ class InstallScriptsTestCase(support.TempdirManager,
def
write_script
(
name
,
text
):
expected
.
append
(
name
)
f
=
open
(
os
.
path
.
join
(
source
,
name
),
"w"
)
try
:
with
open
(
os
.
path
.
join
(
source
,
name
),
"w"
)
as
f
:
f
.
write
(
text
)
finally
:
f
.
close
()
write_script
(
"script1.py"
,
(
"#! /usr/bin/env python2.3
\n
"
"# bogus script w/ Python sh-bang
\n
"
...
...
Lib/packaging/tests/test_create.py
Dosyayı görüntüle @
21a9c748
...
...
@@ -173,11 +173,8 @@ class CreateTestCase(support.TempdirManager,
dedent
(
"""
# -*- coding: utf-8 -*-
from distutils.core import setup
fp = open('README.txt')
try:
with open('README.txt') as fp:
long_description = fp.read()
finally:
fp.close()
setup(name='pyxfoil',
version='0.2',
...
...
Lib/packaging/tests/test_pypi_server.py
Dosyayı görüntüle @
21a9c748
...
...
@@ -54,11 +54,9 @@ class PyPIServerTest(unittest.TestCase):
url
=
server
.
full_address
+
url_path
request
=
urllib
.
request
.
Request
(
url
)
response
=
urllib
.
request
.
urlopen
(
request
)
file
=
open
(
PYPI_DEFAULT_STATIC_PATH
+
"/test_pypi_server"
+
url_path
)
answer
=
response
.
read
()
.
decode
()
==
file
.
read
()
file
.
close
()
return
answer
with
open
(
PYPI_DEFAULT_STATIC_PATH
+
"/test_pypi_server"
+
url_path
)
as
file
:
return
response
.
read
()
.
decode
()
==
file
.
read
()
server
=
PyPIServer
(
static_uri_paths
=
[
"simple"
,
"external"
],
static_filesystem_paths
=
[
"test_pypi_server"
])
...
...
Lib/packaging/tests/test_util.py
Dosyayı görüntüle @
21a9c748
...
...
@@ -720,17 +720,15 @@ class EggInfoToDistInfoTestCase(support.TempdirManager,
dir_paths
.
append
(
path
)
for
f
in
files
:
path
=
os
.
path
.
join
(
tempdir
,
f
)
_f
=
open
(
path
,
'w'
)
_f
.
write
(
f
)
_f
.
close
()
with
open
(
path
,
'w'
)
as
_f
:
_f
.
write
(
f
)
file_paths
.
append
(
path
)
record_file
=
open
(
record_file_path
,
'w'
)
for
fpath
in
file_paths
:
record_file
.
write
(
fpath
+
'
\n
'
)
for
dpath
in
dir_paths
:
record_file
.
write
(
dpath
+
'
\n
'
)
record_file
.
close
()
with
open
(
record_file_path
,
'w'
)
as
record_file
:
for
fpath
in
file_paths
:
record_file
.
write
(
fpath
+
'
\n
'
)
for
dpath
in
dir_paths
:
record_file
.
write
(
dpath
+
'
\n
'
)
return
(
tempdir
,
record_file_path
)
...
...
Lib/packaging/util.py
Dosyayı görüntüle @
21a9c748
...
...
@@ -350,7 +350,7 @@ def byte_compile(py_files, optimize=0, force=False, prefix=None,
else
:
script
=
open
(
script_name
,
"w"
)
try
:
with
script
:
script
.
write
(
"""
\
from packaging.util import byte_compile
files = [
...
...
@@ -378,9 +378,6 @@ byte_compile(files, optimize=%r, force=%r,
direct=True)
"""
%
(
optimize
,
force
,
prefix
,
base_dir
,
verbose
))
finally
:
script
.
close
()
cmd
=
[
sys
.
executable
,
script_name
]
if
optimize
==
1
:
cmd
.
insert
(
1
,
"-O"
)
...
...
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