Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0b569bb3
Commit
0b569bb3
authored
May 04, 2004
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stacks based on lists work better and read more clearly when they
grow and shrink on the right.
parent
2d5914b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
Lib/multifile.py
Lib/multifile.py
+7
-8
No files found.
Lib/multifile.py
View file @
0b569bb3
...
...
@@ -38,13 +38,13 @@ class MultiFile:
def
__init__
(
self
,
fp
,
seekable
=
1
):
self
.
fp
=
fp
self
.
stack
=
[]
# Grows down
self
.
stack
=
[]
self
.
level
=
0
self
.
last
=
0
if
seekable
:
self
.
seekable
=
1
self
.
start
=
self
.
fp
.
tell
()
self
.
posstack
=
[]
# Grows down
self
.
posstack
=
[]
def
tell
(
self
):
if
self
.
level
>
0
:
...
...
@@ -88,8 +88,7 @@ class MultiFile:
marker
=
line
.
rstrip
()
# 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
]
for
i
,
sep
in
enumerate
(
reversed
(
self
.
stack
)):
if
marker
==
self
.
section_divider
(
sep
):
self
.
last
=
0
break
...
...
@@ -130,9 +129,9 @@ class MultiFile:
def
push
(
self
,
sep
):
if
self
.
level
>
0
:
raise
Error
,
'bad MultiFile.push() call'
self
.
stack
.
insert
(
0
,
sep
)
self
.
stack
.
append
(
sep
)
if
self
.
seekable
:
self
.
posstack
.
insert
(
0
,
self
.
start
)
self
.
posstack
.
append
(
self
.
start
)
self
.
start
=
self
.
fp
.
tell
()
def
pop
(
self
):
...
...
@@ -143,9 +142,9 @@ class MultiFile:
else
:
abslastpos
=
self
.
lastpos
+
self
.
start
self
.
level
=
max
(
0
,
self
.
level
-
1
)
del
self
.
stack
[
0
]
self
.
stack
.
pop
()
if
self
.
seekable
:
self
.
start
=
self
.
posstack
.
pop
(
0
)
self
.
start
=
self
.
posstack
.
pop
()
if
self
.
level
>
0
:
self
.
lastpos
=
abslastpos
-
self
.
start
...
...
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