summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2002-02-14 02:49:25 +0000
committercliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a>2002-02-14 02:49:25 +0000
commit1dbe4b6741cf02794d9975680368e010097ddf5a (patch)
tree0c986955faf9298079c5d1e912982849f61c4106
parenta72a94da15788a3132b5114ed6c0183f93c42732 (diff)
downloadpyserial-git-1dbe4b6741cf02794d9975680368e010097ddf5a.tar.gz
fixed missing files for 1.1
-rw-r--r--pyserial/CHANGES.txt4
-rw-r--r--pyserial/MANIFEST2
-rw-r--r--pyserial/serial/serialutil.py65
3 files changed, 70 insertions, 1 deletions
diff --git a/pyserial/CHANGES.txt b/pyserial/CHANGES.txt
index 9772a46..635b264 100644
--- a/pyserial/CHANGES.txt
+++ b/pyserial/CHANGES.txt
@@ -15,4 +15,6 @@ Version 1.1 14 Feb 2002
- readline, readlines, writelines and flush are now supported
see README.txt for deatils.
- \ No newline at end of file
+
+Version 1.11 14 Feb 2002
+ Same as 1.1 but added missing files.
diff --git a/pyserial/MANIFEST b/pyserial/MANIFEST
index 6b348f5..f139e1e 100644
--- a/pyserial/MANIFEST
+++ b/pyserial/MANIFEST
@@ -1,7 +1,9 @@
README.txt
LICENSE.txt
+CHANGES.txt
setup.py
serial\__init__.py
serial\serialjava.py
serial\serialposix.py
serial\serialwin32.py
+serial\serialutil.py
diff --git a/pyserial/serial/serialutil.py b/pyserial/serial/serialutil.py
new file mode 100644
index 0000000..fb3f359
--- /dev/null
+++ b/pyserial/serial/serialutil.py
@@ -0,0 +1,65 @@
+
+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):
+ """read a line which is terminated with '\\n' 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 == '\n':
+ break
+ if size is not None and len(line) >= size:
+ break
+ else:
+ break
+ return line
+
+ def readlines(self, sizehint=None):
+ """read alist 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()
+ if line:
+ lines.append(line)
+ if line[-1] != '\n':
+ break
+ else:
+ break
+ return lines
+
+ def xreadlines(self, sizehint=None):
+ """just call readlines - just here for compatibility"""
+ return self.readlines()
+
+ def writelines(self, sequence):
+ for line in sequence:
+ self.write(line)
+
+ def flush(self):
+ """map flush to flushOutput, ignore exception when that
+ method is not available"""
+ try:
+ self.flushOutput()
+ except NameError:
+ pass
+