+"""This module provides access to user's settings on Diaspora*.
+"""
+
+
import json
import re
import urllib
-"""This module provides access to user's settings on Diaspora*.
-"""
-
-
class Settings():
"""This object is used to get access to user's settings on
Diaspora* and provides interface for downloading user's stuff.
"""Returns a list of tuples containing ('Language name', 'identifier').
One of the Black Magic(tm) methods.
"""
- select_start = '<select id="user_language" name="user[language]"')
+ select_start = '<select id="user_language" name="user[language]">'
select_end = '</select>'
languages = []
request = self._connection.get('user/edit')
- data = request.text[request.text.find(select_start):]
- data = data[:data.find(select_end)]
- print(data)
+ data = request.text[request.text.find(select_start)+len(select_start):]
+ data = data[:data.find(select_end)].split('\n')
+ for item in data:
+ name = item[item.find('>')+1:item.rfind('<')]
+ identifier = item[item.find('"')+1:]
+ identifier = identifier[:identifier.find('"')]
+ languages.append((name, identifier))
return languages
else:
warnings.warn('test not sufficient: no unread notifications were found')
+
+class SettingsTests(unittest.TestCase):
+ def testGettingLanguages(self):
+ settings = diaspy.settings.Settings(test_connection)
+ self.assertIn(('English', 'en'), settings.getLanguages())
+
if __name__ == '__main__':
print('Hello World!')
print('It\'s testing time!')