Initiali work on retrieving languages list
authorMarek Marecki <marekjm@taistelu.com>
Thu, 8 Aug 2013 17:36:33 +0000 (19:36 +0200)
committerMarek Marecki <marekjm@taistelu.com>
Thu, 8 Aug 2013 17:36:33 +0000 (19:36 +0200)
diaspy/settings.py

index 3f0dd60d84d07ec642dc7e5bd22bbf3c208f1711..391caf8bce98e0125dacd72359c7598410e9c8c8 100644 (file)
@@ -29,3 +29,16 @@ class Settings():
         """
         data = {'_method': 'put', 'utf-8': '✓', 'user[language]': lang, 'authenticity_token': repr(self._connection)}
         request = self._connection.post('user')
+
+    def getLanguages(self):
+        """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_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)
+        return languages