diff options
author | Magnus Hagander | 2019-01-03 10:04:29 +0000 |
---|---|---|
committer | Magnus Hagander | 2019-01-03 10:04:29 +0000 |
commit | bb5775efe5f938461537e0c95c7c110875e4718b (patch) | |
tree | d6159fc5773caa5fe50c113c3790bd1bc63a7653 /loader/lib/mbox.py | |
parent | 46372add400ffa5295969aa2e4e8c468d4ada937 (diff) |
Update loader scripts to use python3 syntax
Some minor cleanups as well, but mostly just the output of the 2to3 tool
and some manual changes.
Diffstat (limited to 'loader/lib/mbox.py')
-rw-r--r-- | loader/lib/mbox.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/loader/lib/mbox.py b/loader/lib/mbox.py index c4982ed..77c83b0 100644 --- a/loader/lib/mbox.py +++ b/loader/lib/mbox.py @@ -1,5 +1,5 @@ from subprocess import Popen, PIPE -import cStringIO as StringIO +from io import BytesIO # The hack of all hacks... # The python mbox parser fails to split some messages from mj2 @@ -8,6 +8,7 @@ import cStringIO as StringIO # reassemble it to one long stream with a unique separator, # and then split it apart again in python.. Isn't it cute? SEPARATOR = "ABCARCHBREAK123" * 50 +bSEPARATOR = bytes(SEPARATOR, 'ascii') class MailboxBreakupParser(object): def __init__(self, fn): @@ -27,21 +28,21 @@ class MailboxBreakupParser(object): def stderr_output(self): return self.pipe.stderr.read() - def next(self): - sio = StringIO.StringIO() + def __next__(self): + sio = BytesIO() while True: try: - l = self.pipe.stdout.next() + l = next(self.pipe.stdout) except StopIteration: # End of file! self.EOF = True if sio.tell() == 0: # Nothing read yet, so return None instead of an empty - # stringio + # bytesio return None sio.seek(0) return sio - if l.rstrip() == SEPARATOR: + if l.rstrip() == bSEPARATOR: # Reached a separator. Meaning we're not at end of file, # but we're at end of message. sio.seek(0) |