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
97157798
Commit
97157798
authored
Oct 23, 1995
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added class MHMailbox
Added optional third parameter to seek.
parent
173c8bd3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
5 deletions
+35
-5
Lib/mailbox.py
Lib/mailbox.py
+35
-5
No files found.
Lib/mailbox.py
View file @
97157798
...
...
@@ -4,6 +4,8 @@
# Jack Jansen, CWI, March 1994.
#
import
rfc822
import
os
import
regex
class
_Mailbox
:
def
__init__
(
self
,
fp
):
...
...
@@ -59,8 +61,13 @@ class _Subfile:
def
tell
(
self
):
return
self
.
pos
-
self
.
start
def
seek
(
self
,
pos
):
self
.
pos
=
pos
+
self
.
start
def
seek
(
self
,
pos
,
whence
=
0
):
if
whence
==
0
:
self
.
pos
=
self
.
start
+
pos
elif
whence
==
1
:
self
.
pos
=
self
.
pos
+
pos
elif
whence
==
2
:
self
.
pos
=
self
.
stop
+
pos
def
close
(
self
):
pass
...
...
@@ -103,14 +110,37 @@ class MmdfMailbox(_Mailbox):
self
.
fp
.
seek
(
pos
)
return
class
MHMailbox
:
def
__init__
(
self
,
dirname
):
pat
=
regex
.
compile
(
'^[0-9][0-9]*$'
)
self
.
dirname
=
dirname
files
=
os
.
listdir
(
self
.
dirname
)
self
.
boxes
=
[]
for
f
in
files
:
if
pat
.
match
(
f
)
==
len
(
f
):
self
.
boxes
.
append
(
f
)
def
next
(
self
):
if
not
self
.
boxes
:
return
None
fn
=
self
.
boxes
[
0
]
del
self
.
boxes
[
0
]
fp
=
open
(
os
.
path
.
join
(
self
.
dirname
,
fn
))
return
rfc822
.
Message
(
fp
)
if
__name__
==
'__main__'
:
import
posix
import
time
import
sys
import
string
mbox
=
'/usr/mail/'
+
posix
.
environ
[
'USER'
]
fp
=
open
(
mbox
,
'r'
)
mb
=
UnixMailbox
(
fp
)
## mbox = '/usr/mail/'+posix.environ['USER']
## fp = open(mbox, 'r')
## mb = UnixMailbox(fp)
mbox
=
posix
.
environ
[
'HOME'
]
+
'/Mail/inbox'
mb
=
MHMailbox
(
mbox
)
msgs
=
[]
while
1
:
msg
=
mb
.
next
()
...
...
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