]> arthur.barton.de Git - bup.git/commitdiff
BaseConn: let _read/_readline raise NotImplementedError
authorJohannes Berg <johannes@sipsolutions.net>
Fri, 13 Dec 2019 20:55:53 +0000 (21:55 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sun, 1 Mar 2020 22:54:16 +0000 (16:54 -0600)
This way, it's easier to understand the code, since these
functions aren't referenced without existing in BaseConn.

Also change has_input() to raise NotImplementedError instead
of trying to instantiate NotImplemented - the latter is just
a singleton to return from the rich comparison methods.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/helpers.py

index c77f630f1f0a19e5e628bb41910f355532fc6ab4..f38435557f29c1642609205e3765a1bd64d5647b 100644 (file)
@@ -459,11 +459,17 @@ class BaseConn:
     def close(self):
         while self._read(65536): pass
 
+    def _read(self, size):
+        raise NotImplementedError("Subclasses must implement _read")
+
     def read(self, size):
         """Read 'size' bytes from input stream."""
         self.outp.flush()
         return self._read(size)
 
+    def _readline(self, size):
+        raise NotImplementedError("Subclasses must implement _readline")
+
     def readline(self):
         """Read from input stream until a newline is found."""
         self.outp.flush()
@@ -476,7 +482,7 @@ class BaseConn:
 
     def has_input(self):
         """Return true if input stream is readable."""
-        raise NotImplemented("Subclasses must implement has_input")
+        raise NotImplementedError("Subclasses must implement has_input")
 
     def ok(self):
         """Indicate end of output from last sent command."""