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
aa17a7fc
Kaydet (Commit)
aa17a7fc
authored
Nis 29, 2009
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove dependency on the collections module.
üst
df9d4d6c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
3 deletions
+41
-3
tokenize.py
Lib/tokenize.py
+41
-3
No files found.
Lib/tokenize.py
Dosyayı görüntüle @
aa17a7fc
...
@@ -24,7 +24,6 @@ __credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, '
...
@@ -24,7 +24,6 @@ __credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, '
'Skip Montanaro, Raymond Hettinger, Trent Nelson, '
'Skip Montanaro, Raymond Hettinger, Trent Nelson, '
'Michael Foord'
)
'Michael Foord'
)
import
collections
import
re
,
string
,
sys
import
re
,
string
,
sys
from
token
import
*
from
token
import
*
from
codecs
import
lookup
,
BOM_UTF8
from
codecs
import
lookup
,
BOM_UTF8
...
@@ -32,7 +31,7 @@ cookie_re = re.compile("coding[:=]\s*([-\w.]+)")
...
@@ -32,7 +31,7 @@ cookie_re = re.compile("coding[:=]\s*([-\w.]+)")
import
token
import
token
__all__
=
[
x
for
x
in
dir
(
token
)
if
x
[
0
]
!=
'_'
]
+
[
"COMMENT"
,
"tokenize"
,
__all__
=
[
x
for
x
in
dir
(
token
)
if
x
[
0
]
!=
'_'
]
+
[
"COMMENT"
,
"tokenize"
,
"detect_encoding"
,
"NL"
,
"untokenize"
,
"ENCODING"
,
"Token
ize
"
]
"detect_encoding"
,
"NL"
,
"untokenize"
,
"ENCODING"
,
"Token
Info
"
]
del
token
del
token
COMMENT
=
N_TOKENS
COMMENT
=
N_TOKENS
...
@@ -43,7 +42,46 @@ ENCODING = N_TOKENS + 2
...
@@ -43,7 +42,46 @@ ENCODING = N_TOKENS + 2
tok_name
[
ENCODING
]
=
'ENCODING'
tok_name
[
ENCODING
]
=
'ENCODING'
N_TOKENS
+=
3
N_TOKENS
+=
3
TokenInfo
=
collections
.
namedtuple
(
'TokenInfo'
,
'type string start end line'
)
class
TokenInfo
(
tuple
):
'TokenInfo(type, string, start, end, line)'
__slots__
=
()
_fields
=
(
'type'
,
'string'
,
'start'
,
'end'
,
'line'
)
def
__new__
(
cls
,
type
,
string
,
start
,
end
,
line
):
return
tuple
.
__new__
(
cls
,
(
type
,
string
,
start
,
end
,
line
))
@classmethod
def
_make
(
cls
,
iterable
,
new
=
tuple
.
__new__
,
len
=
len
):
'Make a new TokenInfo object from a sequence or iterable'
result
=
new
(
cls
,
iterable
)
if
len
(
result
)
!=
5
:
raise
TypeError
(
'Expected 5 arguments, got
%
d'
%
len
(
result
))
return
result
def
__repr__
(
self
):
return
'TokenInfo(type=
%
r, string=
%
r, start=
%
r, end=
%
r, line=
%
r)'
%
self
def
_asdict
(
self
):
'Return a new dict which maps field names to their values'
return
dict
(
zip
(
self
.
_fields
,
self
))
def
_replace
(
self
,
**
kwds
):
'Return a new TokenInfo object replacing specified fields with new values'
result
=
self
.
_make
(
map
(
kwds
.
pop
,
(
'type'
,
'string'
,
'start'
,
'end'
,
'line'
),
self
))
if
kwds
:
raise
ValueError
(
'Got unexpected field names:
%
r'
%
kwds
.
keys
())
return
result
def
__getnewargs__
(
self
):
return
tuple
(
self
)
type
=
property
(
lambda
t
:
t
[
0
])
string
=
property
(
lambda
t
:
t
[
1
])
start
=
property
(
lambda
t
:
t
[
2
])
end
=
property
(
lambda
t
:
t
[
3
])
line
=
property
(
lambda
t
:
t
[
4
])
def
group
(
*
choices
):
return
'('
+
'|'
.
join
(
choices
)
+
')'
def
group
(
*
choices
):
return
'('
+
'|'
.
join
(
choices
)
+
')'
def
any
(
*
choices
):
return
group
(
*
choices
)
+
'*'
def
any
(
*
choices
):
return
group
(
*
choices
)
+
'*'
...
...
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