From: Marek Marecki Date: Wed, 3 Jul 2013 19:02:05 +0000 (+0200) Subject: Fixed and improved models.Aspect().getUsers() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b6061bfa38e54eae61d8331042e99c7d4aeaa4cc;p=diaspy.git Fixed and improved models.Aspect().getUsers() --- 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):