|
1 | | -from cStringIO import StringIO |
2 | | -from os import SEEK_CUR, SEEK_END, SEEK_SET |
| 1 | +import cStringIO |
| 2 | +import os |
3 | 3 | import struct |
| 4 | + |
4 | 5 | from itertools import groupby |
5 | 6 |
|
6 | 7 | LITTLE_ENDIAN,BIG_ENDIAN = '<','>' |
@@ -50,12 +51,12 @@ class ReplayBuffer(object): |
50 | 51 | def __init__(self, file): |
51 | 52 | #Accept file like objects and string objects |
52 | 53 | if hasattr(file,'read'): |
53 | | - self.io = StringIO(file.read()) |
| 54 | + self.io = cStringIO.StringIO(file.read()) |
54 | 55 | else: |
55 | | - self.io = StringIO(file) |
| 56 | + self.io = cStringIO.StringIO(file) |
56 | 57 |
|
57 | 58 | # get length of stream |
58 | | - self.io.seek(0, SEEK_END) |
| 59 | + self.io.seek(0, os.SEEK_END) |
59 | 60 | self.length = self.io.tell() |
60 | 61 | self.io.seek(0) |
61 | 62 |
|
@@ -85,18 +86,18 @@ def cursor(self): return self.io.tell() |
85 | 86 | Stream manipulation functions |
86 | 87 | ''' |
87 | 88 | def tell(self): return self.io.tell() |
88 | | - def skip(self, amount): self.seek(amount, SEEK_CUR) |
| 89 | + def skip(self, amount): self.seek(amount, os.SEEK_CUR) |
89 | 90 | def reset(self): self.io.seek(0); self.bit_shift = 0 |
90 | 91 | def align(self): self.bit_shift=0 |
91 | | - def seek(self, position, mode=SEEK_SET): |
| 92 | + def seek(self, position, mode=os.SEEK_SET): |
92 | 93 | self.io.seek(position, mode) |
93 | 94 | if self.io.tell()!=0 and self.bit_shift!=0: |
94 | | - self.io.seek(-1, SEEK_CUR) |
| 95 | + self.io.seek(-1, os.SEEK_CUR) |
95 | 96 | self.last_byte = ord(self.read_basic(1)) |
96 | 97 |
|
97 | 98 | def peek(self, length): |
98 | 99 | start,last,ret = self.cursor,self.last_byte,self.read_hex(length) |
99 | | - self.seek(start, SEEK_SET) |
| 100 | + self.seek(start, os.SEEK_SET) |
100 | 101 | self.last_byte = last |
101 | 102 | return ret |
102 | 103 |
|
|
0 commit comments