summaryrefslogtreecommitdiff
path: root/bvggrabber/api/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'bvggrabber/api/__init__.py')
-rw-r--r--bvggrabber/api/__init__.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/bvggrabber/api/__init__.py b/bvggrabber/api/__init__.py
index 36c913b..c489e8b 100644
--- a/bvggrabber/api/__init__.py
+++ b/bvggrabber/api/__init__.py
@@ -30,6 +30,37 @@ class QueryApi(object):
"the call() method!")
+class Response(object):
+
+ def __init__(self, state, departures, error=None):
+ self._state = state
+ self._departures = departures
+ self._error = error
+
+ def merge(self, other):
+ if isinstance(other, Response):
+ if not other.state:
+ raise ValueError("The response contains errors: " + str(other.error))
+ elif not self.state:
+ raise ValueError("The response contains errors: " + str(self.error))
+ else:
+ self.departures.extend(other.departures)
+ else:
+ raise TypeError("The given object is not a response object")
+
+ @property
+ def state(self):
+ return self._state
+
+ @property
+ def departures(self):
+ return self._departures
+
+ @property
+ def error(self):
+ return self._error
+
+
@total_ordering
class Departure(object):