aboutsummaryrefslogtreecommitdiff
path: root/sgdfi/_db.py
diff options
context:
space:
mode:
Diffstat (limited to 'sgdfi/_db.py')
-rwxr-xr-xsgdfi/_db.py41
1 files changed, 10 insertions, 31 deletions
diff --git a/sgdfi/_db.py b/sgdfi/_db.py
index d1dc6aa..4d33f4a 100755
--- a/sgdfi/_db.py
+++ b/sgdfi/_db.py
@@ -6,6 +6,10 @@
""" This submodule defines the local database (or data manager) for managing
our knowledge of the intranet. """
+from ._repr import Structure as _Structure, Adherent as _Adherent, \
+ RallyRegistration as _RallyRegistration, Camp as _Camp, \
+ Place as _Place, Operation as _Operation, Event as _Event
+
__all__ = ["Database"]
class Database:
@@ -34,38 +38,13 @@ class Database:
# Feed the database with fetched (and possibly incomplete) data.
# ---
- def add_structure(self, st):
- """ Add a structure. """
-
- # TODO
- pass
-
- def add_adherent(self, ad):
- """ Add an adherent. """
-
- # TODO
- pass
-
- def add_rally_registration(self, rreg):
- """ Add a rally registration. """
-
- # TODO
- pass
-
- def add_camp(self, cp):
- """ Add a camp. """
-
- # TODO
- pass
-
- def add_place(self, pl):
- """ Add a place. """
-
- # TODO
- pass
+ def add(self, obj):
+ """ Add or update an object to the database. """
- def add_op(self, op):
- """ Add an operation. """
+ accepted = (_Structure, _Adherent, _RallyRegistration, _Camp, _Place,
+ _Operation, _Event)
+ if all(not isinstance(obj, x) for x in accepted):
+ raise TypeError("Unaccepted object in the database.")
# TODO
pass