diff options
author | nobody <nobody@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2003-03-19 02:33:55 +0000 |
---|---|---|
committer | nobody <nobody@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2003-03-19 02:33:55 +0000 |
commit | d753d70c9841174cc935008631012d60b549b3a8 (patch) | |
tree | 210bcfe125f57fb3238f79d43e1a7b491fc4e42c /pyserial/serial/serialutil.py | |
parent | 49a8ecf01ee3800a46ad53f11abef5ebf198d8e4 (diff) | |
download | pyserial-git-release0_1.tar.gz |
This commit was manufactured by cvs2svn to create tag 'release0_1'.release0_1
Diffstat (limited to 'pyserial/serial/serialutil.py')
-rw-r--r-- | pyserial/serial/serialutil.py | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/pyserial/serial/serialutil.py b/pyserial/serial/serialutil.py deleted file mode 100644 index e3a4bdb..0000000 --- a/pyserial/serial/serialutil.py +++ /dev/null @@ -1,65 +0,0 @@ - -class SerialException(Exception): - pass - -class FileLike: - """An abstract file like class. - - This class implements readline and readlines based on read and - writelines based on write. - This class is used to provide the above functions for to Serial - port objects. - - Note that when the serial port was opened with _NO_ timeout that - readline blocks until it sees a newline (or the specified size is - reached) and that readlines would never return and therefore - refuses to work (it raises an exception in this case)! - """ - - def read(self, size): raise NotImplementedError - def write(self, s): raise NotImplementedError - - def readline(self, size=None, eol='\n'): - """read a line which is terminated with end-of-line (eol) character - ('\n' by default) or until timeout""" - line = '' - while 1: - c = self.read(1) - if c: - line += c #not very efficient but lines are usually not that long - if c == eol: - break - if size is not None and len(line) >= size: - break - else: - break - return line - - def readlines(self, sizehint=None, eol='\n'): - """read a list of lines, until timeout - sizehint is ignored""" - if self.timeout is None: - raise ValueError, "Serial port MUST have enabled timeout for this function!" - lines = [] - while 1: - line = self.readline(eol=eol) - if line: - lines.append(line) - if line[-1] != eol: #was the line received with a timeout? - break - else: - break - return lines - - def xreadlines(self, sizehint=None): - """just call readlines - here for compatibility""" - return self.readlines() - - def writelines(self, sequence): - for line in sequence: - self.write(line) - - def flush(self): - """flush of file like objects""" - pass - |