From f2b0f5db230e8fdfec3f5fa0fcc53766582daf6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Tue, 7 Apr 2009 23:48:55 +0200 Subject: Removed the obsolete single unittest and the unique_array function --- portato/TEST_helper.py | 32 -------------------------------- portato/backend/flags.py | 8 ++++---- portato/backend/portage/system.py | 4 ++-- portato/helper.py | 35 ----------------------------------- 4 files changed, 6 insertions(+), 73 deletions(-) delete mode 100644 portato/TEST_helper.py diff --git a/portato/TEST_helper.py b/portato/TEST_helper.py deleted file mode 100644 index f0b069b..0000000 --- a/portato/TEST_helper.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/python - -import unittest -import helper - -class HelperTest (unittest.TestCase): - - def testFlatten(self): - list = [[1,2],[3,4],[[5],[6,7,8], 9]] - flist = helper.flatten(list) - self.assertEqual(flist, [1,2,3,4,5,6,7,8,9], "List not flattend correctly.") - - def testUniqueArray(self): - - def equal (l1, l2): - for i in l1: - if i not in l2: - return False - l2.remove(i) - return True - - list1 = [1,4,5,2,1,7,9,11,2,4,7,12] - result1 = [1,4,5,2,7,9,11,12] - - list2 = [[x] for x in list1] - result2 = [[x] for x in result1] - - self.assert_(equal(helper.unique_array(list1), result1), "Make hashable list unique does not work.") - self.assert_(equal(helper.unique_array(list2), result2), "Make unhashable list unique does not work.") - -if __name__ == "__main__": - unittest.main() diff --git a/portato/backend/flags.py b/portato/backend/flags.py index 8f5723d..f23e245 100644 --- a/portato/backend/flags.py +++ b/portato/backend/flags.py @@ -17,7 +17,7 @@ import itertools as itt from subprocess import Popen, PIPE # needed for grep from . import system, is_package -from ..helper import debug, error, warning, unique_array +from ..helper import debug, error, warning CONFIG = { "usefile" : "portato", @@ -298,7 +298,7 @@ def set_use_flag (pkg, flag): except ValueError: # not in UseFlags newUseFlags[cpv].append((path, -1, flag, False)) - newUseFlags[cpv] = unique_array(newUseFlags[cpv]) + newUseFlags[cpv] = list(set(newUseFlags[cpv])) debug("newUseFlags: %s", str(newUseFlags)) def remove_new_use_flags (cpv): @@ -497,7 +497,7 @@ def set_masked (pkg, masked = True): file = path link_neq[cpv].append((file, "-1")) - link_neq[cpv] = unique_array(link_neq[cpv]) + link_neq[cpv] = list(set(link_neq[cpv])) debug("new_(un)masked: %s",str(link_neq)) def remove_new_masked (cpv): @@ -700,7 +700,7 @@ def set_testing (pkg, enable): file = CONST.testing_path() newTesting[cpv].append((file, "-1")) - newTesting[cpv] = unique_array(newTesting[cpv]) + newTesting[cpv] = list(set(newTesting[cpv])) debug("newTesting: %s",str(newTesting)) def write_testing (): diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py index eae8465..7470fdc 100644 --- a/portato/backend/portage/system.py +++ b/portato/backend/portage/system.py @@ -23,7 +23,7 @@ from . import sets as syssets from .package import PortagePackage from .settings import PortageSettings from ..system_interface import SystemInterface -from ...helper import debug, info, warning, unique_array +from ...helper import debug, info, warning class PortageSystem (SystemInterface): """This class provides access to the portage-system.""" @@ -193,7 +193,7 @@ class PortageSystem (SystemInterface): t += self.find_packages(search_key, self.SET_INSTALLED, only_cpv=True) if t: - t = unique_array(t) + t = list(set(t)) return self.find_best(t, only_cpv) return None diff --git a/portato/helper.py b/portato/helper.py index 1861ae6..d271611 100644 --- a/portato/helper.py +++ b/portato/helper.py @@ -115,41 +115,6 @@ def flatten (listOfLists): return ret -def unique_array(s): - """Stolen from portage_utils: - lifted from python cookbook, credit: Tim Peters - Return a list of the elements in s in arbitrary order, sans duplicates""" - # assume all elements are hashable, if so, it's linear - try: - return list(set(s)) - except TypeError: - pass - - # so much for linear. abuse sort. - try: - t = list(s) - t.sort() - except TypeError: - pass - else: - n = len(s) - assert n > 0 - last = t[0] - lasti = i = 1 - while i < n: - if t[i] != last: - t[lasti] = last = t[i] - lasti += 1 - i += 1 - return t[:lasti] - - # blah. back to original portage.unique_array - u = [] - for x in s: - if x not in u: - u.append(x) - return u - def detect_desktop_environment(): # stolen from wicd :) -- cgit v1.2.3