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
3ad9dd55
Kaydet (Commit)
3ad9dd55
authored
Haz 29, 1998
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Improved by Eric Raymond.
üst
950ff292
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
18 deletions
+29
-18
multifile.py
Lib/multifile.py
+29
-18
No files found.
Lib/multifile.py
Dosyayı görüntüle @
3ad9dd55
...
...
@@ -18,9 +18,6 @@
#
# The latter sequence may be used recursively at (A).
# It is also allowed to use multiple push()...pop() sequences.
# Note that if a nested multipart message is terminated by a separator
# for an outer message, this is not reported, even though it is really
# illegal input.
#
# If seekable is given as 0, the class code will not do the bookeeping
# it normally attempts in order to make seeks relative to the beginning of the
...
...
@@ -30,13 +27,12 @@
import
sys
import
string
err
=
sys
.
stderr
.
write
Error
=
'multifile.Error'
class
MultiFile
:
#
seekable
=
0
#
def
__init__
(
self
,
fp
,
seekable
=
1
):
self
.
fp
=
fp
self
.
stack
=
[]
# Grows down
...
...
@@ -70,37 +66,44 @@ class MultiFile:
self
.
last
=
0
#
def
readline
(
self
):
if
self
.
level
>
0
:
return
''
if
self
.
level
>
0
:
return
''
line
=
self
.
fp
.
readline
()
# Real EOF?
if
not
line
:
self
.
level
=
len
(
self
.
stack
)
self
.
last
=
(
self
.
level
>
0
)
if
self
.
last
:
err
(
'*** Sudden EOF in MultiFile.readline()
\n
'
)
raise
Error
,
'sudden EOF in MultiFile.readline()'
return
''
if
line
[:
2
]
<>
'--'
:
return
line
n
=
len
(
line
)
k
=
n
while
k
>
0
and
line
[
k
-
1
]
in
string
.
whitespace
:
k
=
k
-
1
mark
=
line
[
2
:
k
]
if
mark
[
-
2
:]
==
'--'
:
mark1
=
mark
[:
-
2
]
else
:
mark1
=
None
assert
self
.
level
==
0
# Fast check to see if this is just data
if
self
.
is_data
(
line
):
return
line
else
:
# Ignore trailing whitespace on marker lines
k
=
len
(
line
)
-
1
;
while
line
[
k
]
in
string
.
whitespace
:
k
=
k
-
1
marker
=
line
[:
k
+
1
]
# No? OK, try to match a boundary.
# Return the line (unstripped) if we don't.
for
i
in
range
(
len
(
self
.
stack
)):
sep
=
self
.
stack
[
i
]
if
sep
==
mark
:
if
marker
==
self
.
section_divider
(
sep
)
:
self
.
last
=
0
break
elif
mark
1
<>
None
and
sep
==
mark1
:
elif
mark
er
==
self
.
end_marker
(
sep
)
:
self
.
last
=
1
break
else
:
return
line
#
Get here after break out of loop
#
We only get here if we see a section divider or EOM line
if
self
.
seekable
:
self
.
lastpos
=
self
.
tell
()
-
len
(
line
)
self
.
level
=
i
+
1
if
self
.
level
>
1
:
err
(
'*** Missing endmarker in MultiFile.readline()
\n
'
)
raise
Error
,
'Missing endmarker in MultiFile.readline()'
return
''
#
def
readlines
(
self
):
...
...
@@ -147,3 +150,11 @@ class MultiFile:
if
self
.
level
>
0
:
self
.
lastpos
=
abslastpos
-
self
.
start
#
def
is_data
(
self
,
line
):
return
line
[:
2
]
<>
'--'
#
def
section_divider
(
self
,
str
):
return
"--"
+
str
#
def
end_marker
(
self
,
str
):
return
"--"
+
str
+
"--"
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