[Pkg-privacy-commits] [onionshare] 30/53: Refactored _hsdic2list method. It it much easier to understand now. (fixes #199)

Ulrike Uhlig u-guest at moszumanska.debian.org
Wed Dec 30 00:20:13 UTC 2015


This is an automated email from the git hooks/post-receive script.

u-guest pushed a commit to branch debian
in repository onionshare.

commit 8f8e38b11d8d162cf7eb64802776628a4607d230
Author: Micah Lee <micah at micahflee.com>
Date:   Fri Nov 20 14:20:29 2015 -0800

    Refactored _hsdic2list method. It it much easier to understand now. (fixes #199)
---
 onionshare/hs.py | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/onionshare/hs.py b/onionshare/hs.py
index 13c72ce..27712b4 100644
--- a/onionshare/hs.py
+++ b/onionshare/hs.py
@@ -218,10 +218,32 @@ class HS(object):
         self.cleanup_filenames = []
 
     def _hsdic2list(self, dic):
-        """Convert what we get from get_conf_map to what we need for set_options"""
-        return [
-            pair for pairs in [
-                [('HiddenServiceDir', vals[0]), ('HiddenServicePort', vals[1])]
-                for vals in zip(dic.get('HiddenServiceDir', []), dic.get('HiddenServicePort', []))
-            ] for pair in pairs
+        """
+        Convert what we get from get_conf_map to what we need for set_options.
+
+        For example, if input looks like this:
+        {
+            'HiddenServicePort': [
+                '80 127.0.0.1:47906',
+                '80 127.0.0.1:33302'
+            ],
+            'HiddenServiceDir': [
+                '/tmp/onionshare/tmplTfZZu',
+                '/tmp/onionshare/tmpchDai3'
+            ]
+        }
+
+
+        Output will look like this:
+        [
+            ('HiddenServiceDir', '/tmp/onionshare/tmplTfZZu'),
+            ('HiddenServicePort', '80 127.0.0.1:47906'),
+            ('HiddenServiceDir', '/tmp/onionshare/tmpchDai3'),
+            ('HiddenServicePort', '80 127.0.0.1:33302')
         ]
+        """
+        l = []
+        for i in range(len(dic['HiddenServiceDir'])):
+            l.append(('HiddenServiceDir', dic['HiddenServiceDir'][i]))
+            l.append(('HiddenServicePort', dic['HiddenServicePort'][i]))
+        return l

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list