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
98516a69
Kaydet (Commit)
98516a69
authored
Agu 01, 2012
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix findnocoding.p and pysource.py scripts
I suppose that these scripts didn't work since Python 3.0.
üst
7c7ea62e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
findnocoding.py
Tools/scripts/findnocoding.py
+11
-11
pysource.py
Tools/scripts/pysource.py
+3
-3
No files found.
Tools/scripts/findnocoding.py
Dosyayı görüntüle @
98516a69
...
@@ -32,7 +32,7 @@ except ImportError:
...
@@ -32,7 +32,7 @@ except ImportError:
"no sophisticated Python source file search will be done."
,
file
=
sys
.
stderr
)
"no sophisticated Python source file search will be done."
,
file
=
sys
.
stderr
)
decl_re
=
re
.
compile
(
r"coding[=:]\s*([-\w.]+)"
)
decl_re
=
re
.
compile
(
r
b
"coding[=:]
\
s*([-
\
w.]+)"
)
def
get_declaration
(
line
):
def
get_declaration
(
line
):
match
=
decl_re
.
search
(
line
)
match
=
decl_re
.
search
(
line
)
...
@@ -50,21 +50,21 @@ def has_correct_encoding(text, codec):
...
@@ -50,21 +50,21 @@ def has_correct_encoding(text, codec):
def
needs_declaration
(
fullpath
):
def
needs_declaration
(
fullpath
):
try
:
try
:
infile
=
open
(
fullpath
)
infile
=
open
(
fullpath
,
'rb'
)
except
IOError
:
# Oops, the file was removed - ignore it
except
IOError
:
# Oops, the file was removed - ignore it
return
None
return
None
line1
=
infile
.
readline
()
with
infile
:
line2
=
infile
.
readline
()
line1
=
infile
.
readline
()
line2
=
infile
.
readline
()
if
get_declaration
(
line1
)
or
get_declaration
(
line2
):
if
get_declaration
(
line1
)
or
get_declaration
(
line2
):
# the file does have an encoding declaration, so trust it
# the file does have an encoding declaration, so trust it
infile
.
close
()
infile
.
close
()
return
False
return
False
# check the whole file for non utf-8 characters
# check the whole file for non utf-8 characters
rest
=
infile
.
read
()
rest
=
infile
.
read
()
infile
.
close
()
if
has_correct_encoding
(
line1
+
line2
+
rest
,
"utf-8"
):
if
has_correct_encoding
(
line1
+
line2
+
rest
,
"utf-8"
):
return
False
return
False
...
...
Tools/scripts/pysource.py
Dosyayı görüntüle @
98516a69
...
@@ -22,7 +22,7 @@ __all__ = ["has_python_ext", "looks_like_python", "can_be_compiled", "walk_pytho
...
@@ -22,7 +22,7 @@ __all__ = ["has_python_ext", "looks_like_python", "can_be_compiled", "walk_pytho
import
os
,
re
import
os
,
re
binary_re
=
re
.
compile
(
'[
\x00
-
\x08\x0E
-
\x1F\x7F
]'
)
binary_re
=
re
.
compile
(
br
'[
\x00
-
\x08\x0E
-
\x1F\x7F
]'
)
debug
=
False
debug
=
False
...
@@ -42,7 +42,7 @@ def _open(fullpath):
...
@@ -42,7 +42,7 @@ def _open(fullpath):
return
None
return
None
try
:
try
:
return
open
(
fullpath
)
return
open
(
fullpath
,
"rb"
)
except
IOError
as
err
:
# Access denied, or a special file - ignore it
except
IOError
as
err
:
# Access denied, or a special file - ignore it
print_debug
(
"
%
s: access denied:
%
s"
%
(
fullpath
,
err
))
print_debug
(
"
%
s: access denied:
%
s"
%
(
fullpath
,
err
))
return
None
return
None
...
@@ -65,7 +65,7 @@ def looks_like_python(fullpath):
...
@@ -65,7 +65,7 @@ def looks_like_python(fullpath):
if
fullpath
.
endswith
(
".py"
)
or
fullpath
.
endswith
(
".pyw"
):
if
fullpath
.
endswith
(
".py"
)
or
fullpath
.
endswith
(
".pyw"
):
return
True
return
True
elif
"python"
in
line
:
elif
b
"python"
in
line
:
# disguised Python script (e.g. CGI)
# disguised Python script (e.g. CGI)
return
True
return
True
...
...
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