From b6061bfa38e54eae61d8331042e99c7d4aeaa4cc Mon Sep 17 00:00:00 2001 From: Marek Marecki Date: Wed, 3 Jul 2013 21:02:05 +0200 Subject: [PATCH] Fixed and improved models.Aspect().getUsers() --- diaspy/models.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/diaspy/models.py b/diaspy/models.py index e568138..c412d51 100644 --- a/diaspy/models.py +++ b/diaspy/models.py @@ -59,18 +59,15 @@ class Aspect(): ajax = self._connection.get('aspects/{0}/edit'.format(self.id)).text - #print(ajax) - begin = ajax.find(start_regexp.search(ajax).group(0)) - #print(0) end = ajax.find('') ajax = ajax[begin:end] - #print(ajax) - usernames = [(line[17:33], line[35:-4]) for line in userline_regexp.findall(ajax)] - for guid, name in usernames: - print(name, guid) + for i, data in enumerate(usernames): + guid, name = data + for char in ['(', ')', '.']: name = name.replace(char, '\\'+char) + usernames[i] = (guid, name) personids = [re.compile(personid_regexp.format(name)).search(ajax).group(0) for guid, name in usernames] for n, line in enumerate(personids): i, id = -2, '' @@ -86,8 +83,7 @@ class Aspect(): users = [] for i, user in enumerate(usernames): guid, name = user - if name in users_in_aspect: - users.append(guid) + if name in users_in_aspect: users.append(guid) return users def addUser(self, user_id): -- 2.25.1