summaryrefslogtreecommitdiff
path: root/portato/helper.py
diff options
context:
space:
mode:
authornecoro <>2007-02-19 23:04:14 +0000
committernecoro <>2007-02-19 23:04:14 +0000
commitfba60a84b9a838ad32def950210a6b62d9bcdbff (patch)
treed581e4fa141851323a05d4500ad95afe50ed6e02 /portato/helper.py
parentb4c88233aa6dabd2d9301350a240b8ddcf09255a (diff)
downloadportato-fba60a84b9a838ad32def950210a6b62d9bcdbff.tar.gz
portato-fba60a84b9a838ad32def950210a6b62d9bcdbff.tar.bz2
portato-fba60a84b9a838ad32def950210a6b62d9bcdbff.zip
Back to our own revision solution as the eclass-one checks _before_ updating
Diffstat (limited to '')
-rw-r--r--portato/helper.py37
1 files changed, 36 insertions, 1 deletions
diff --git a/portato/helper.py b/portato/helper.py
index fab8aa5..d66e256 100644
--- a/portato/helper.py
+++ b/portato/helper.py
@@ -3,7 +3,7 @@
# File: portato/helper.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
-# Copyright (C) 2006 René 'Necoro' Neumann
+# Copyright (C) 2006-2007 René 'Necoro' Neumann
# This is free software. You may redistribute copies of it under the terms of
# the GNU General Public License version 2.
# There is NO WARRANTY, to the extent permitted by law.
@@ -66,3 +66,38 @@ def am_i_root ():
return True
else:
return False
+
+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"""
+ n = len(s)
+ # 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:
+ 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