From 62041d067fee709a688626618409513a16e0813f Mon Sep 17 00:00:00 2001 From: Marek Marecki Date: Sun, 23 Apr 2017 15:46:25 +0200 Subject: [PATCH] Do not guess --- diaspy/models.py | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/diaspy/models.py b/diaspy/models.py index e908097..38f9c78 100644 --- a/diaspy/models.py +++ b/diaspy/models.py @@ -19,37 +19,9 @@ class Aspect(): parameters. If both are missing, an exception will be raised. """ - def __init__(self, connection, id=None, name=None): + def __init__(self, connection, id, name=None): self._connection = connection self.id, self.name = id, name - if id and not name: - self.name = self._findname() - elif name and not id: - self.id = self._findid() - elif not id and not name: - raise Exception('Aspect must be initialized with either an id or name') - - def _findname(self): - """Finds name for aspect. - """ - name = None - aspects = self._connection.getUserData()['aspects'] - for a in aspects: - if a['id'] == self.id: - name = a['name'] - break - return name - - def _findid(self): - """Finds id for aspect. - """ - id = None - aspects = self._connection.getUserData()['aspects'] - for a in aspects: - if a['name'] == self.name: - id = a['id'] - break - return id def _getajax(self): """Returns HTML returned when editing aspects via web UI. -- 2.25.1