From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 248C5138778 for ; Wed, 30 Jan 2013 20:16:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 94B2821C010; Wed, 30 Jan 2013 20:16:34 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0B98D21C010 for ; Wed, 30 Jan 2013 20:16:28 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 10B9A33DC0F for ; Wed, 30 Jan 2013 20:16:28 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 5FDABE4095 for ; Wed, 30 Jan 2013 20:16:25 +0000 (UTC) From: "André Erdmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "André Erdmann" Message-ID: <1359576351.9a715ef8a5c0553b85184b423f977cced4648adb.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/util.py X-VCS-Directories: roverlay/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: 9a715ef8a5c0553b85184b423f977cced4648adb X-VCS-Branch: master Date: Wed, 30 Jan 2013 20:16:25 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 835e0868-3933-488d-9870-d17b779526cf X-Archives-Hash: defb168870b6119ed64133ebefa3fb6e commit: 9a715ef8a5c0553b85184b423f977cced4648adb Author: André Erdmann mailerd de> AuthorDate: Wed Jan 30 20:05:51 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Wed Jan 30 20:05:51 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=9a715ef8 util: priosort() Sorts the items of an iterable by priority. --- roverlay/util.py | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) diff --git a/roverlay/util.py b/roverlay/util.py index be2cd33..8f737c1 100644 --- a/roverlay/util.py +++ b/roverlay/util.py @@ -6,13 +6,32 @@ """provides utility functions commonly used""" -__all__= [ 'dodir', 'keepenv', 'sysnop', ] +__all__= [ 'dodir', 'keepenv', 'sysnop', 'get_dict_hash', 'priosort', ] import os import logging LOGGER = logging.getLogger ( 'util' ) +def priosort ( iterable ): + """Sorts the items of an iterable by priority (lower value means higher + priority). + + arguments: + * iterable + """ + def priokey ( item ): + """Returns the priority of an item. + + arguments: + * item -- + """ + return item.priority + # --- end of priokey (...) --- + + return sorted ( iterable, key=priokey ) +# --- end of priosort (...) --- + def keepenv ( *to_keep ): """Selectively imports os.environ.