commit e8063623734901524c88544f883a6279302e2902 Author: Arturo Filastò art@fuffa.org Date: Thu Jan 30 21:06:23 2014 +0100
Fix pushFilenameStack --- ooni/tests/test_utils.py | 4 ++-- ooni/utils/__init__.py | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/ooni/tests/test_utils.py b/ooni/tests/test_utils.py index 4a9314f..10aa0cc 100644 --- a/ooni/tests/test_utils.py +++ b/ooni/tests/test_utils.py @@ -8,13 +8,13 @@ class TestUtils(unittest.TestCase): f = open(basefilename, "w+") f.write("0\n") f.close() - for i in xrange(1, 5): + for i in xrange(1, 20): f = open(basefilename+".%s" % i, "w+") f.write("%s\n" % i) f.close()
pushFilenameStack(basefilename) - for i in xrange(1, 5): + for i in xrange(1, 20): f = open(basefilename+".%s" % i) c = f.readlines()[0].strip() self.assertEqual(str(i-1), str(c)) diff --git a/ooni/utils/__init__.py b/ooni/utils/__init__.py index b039c8a..1b6a8e9 100644 --- a/ooni/utils/__init__.py +++ b/ooni/utils/__init__.py @@ -91,18 +91,11 @@ def pushFilenameStack(filename): .3, etc. This is similar to pushing into a LIFO stack.
- XXX: This will not work with stacks bigger than 10 elements because - glob.glob(".*") will return them in the wrong order (a.1, a.11, a.2, a.3, - etc.) - This is probably not an issue since the only thing it causes is that files - will be renamed in the wrong order and you shouldn't have the same report - filename for more than 10 reports anyways, because you should be making - ooniprobe generate the filename for you. - Args: filename (str): the path to filename that you wish to create. """ stack = glob.glob(filename+".*") + stack.sort(key=lambda x: int(x.split('.')[-1])) for f in reversed(stack): c_idx = f.split(".")[-1] c_filename = '.'.join(f.split(".")[:-1])
tor-commits@lists.torproject.org