From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 2A38E138334 for ; Thu, 5 Dec 2019 16:51:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1BA5EE087B; Thu, 5 Dec 2019 16:51:30 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 043F2E087B for ; Thu, 5 Dec 2019 16:51:30 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C9B9534D79E for ; Thu, 5 Dec 2019 16:51:28 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E06AC778 for ; Thu, 5 Dec 2019 16:51:26 +0000 (UTC) From: "Matt Turner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matt Turner" Message-ID: <1575512600.af21727e35249aceda111b345b50c9dbf95de805.mattst88@gentoo> Subject: [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/eclean/ X-VCS-Repository: proj/gentoolkit X-VCS-Files: pym/gentoolkit/eclean/clean.py X-VCS-Directories: pym/gentoolkit/eclean/ X-VCS-Committer: mattst88 X-VCS-Committer-Name: Matt Turner X-VCS-Revision: af21727e35249aceda111b345b50c9dbf95de805 X-VCS-Branch: master Date: Thu, 5 Dec 2019 16:51:26 +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-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 2c1c4099-d5e5-43ce-9bd9-8a633c362b0a X-Archives-Hash: abe46403067f81daa1cb08ec8178bf1b commit: af21727e35249aceda111b345b50c9dbf95de805 Author: Matt Turner gentoo org> AuthorDate: Mon Dec 2 20:28:15 2019 +0000 Commit: Matt Turner gentoo org> CommitDate: Thu Dec 5 02:23:20 2019 +0000 URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=af21727e eclean: Inline _sort_keys method The boilerplate for calling this method was larger than what it actually contained. Additionally I think this change will allow the loop to run on a generator rather than a full list. Signed-off-by: Matt Turner gentoo.org> pym/gentoolkit/eclean/clean.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/pym/gentoolkit/eclean/clean.py b/pym/gentoolkit/eclean/clean.py index fd59976..e00bcc0 100644 --- a/pym/gentoolkit/eclean/clean.py +++ b/pym/gentoolkit/eclean/clean.py @@ -36,10 +36,9 @@ class CleanUp(object): @return: total size that was cleaned """ file_type = 'file' - clean_keys = self._sort_keys(clean_dict) clean_size = 0 - # clean all entries one by one - for key in clean_keys: + # clean all entries one by one; sorting helps reading + for key in sorted(clean_dict): clean_size += self._clean_files(clean_dict[key], key, file_type) # return total size of deleted or to delete files return clean_size @@ -57,10 +56,9 @@ class CleanUp(object): @return: total size that was cleaned """ file_type = 'binary package' - clean_keys = self._sort_keys(clean_dict) clean_size = 0 - # clean all entries one by one - for key in clean_keys: + # clean all entries one by one; sorting helps reading + for key in sorted(clean_dict): clean_size += self._clean_files(clean_dict[key], key, file_type) # run 'emaint --fix' here @@ -83,10 +81,9 @@ class CleanUp(object): @return: total size that would be cleaned """ file_type = 'file' - clean_keys = self._sort_keys(clean_dict) clean_size = 0 - # tally all entries one by one - for key in clean_keys: + # tally all entries one by one; sorting helps reading + for key in sorted(clean_dict): key_size = self._get_size(clean_dict[key]) self.controller(key_size, key, clean_dict[key], file_type) clean_size += key_size @@ -110,12 +107,6 @@ class CleanUp(object): print( pp.error("Error: %s" %str(er)), file=sys.stderr) return key_size - def _sort_keys(self, clean_dict): - """Returns a list of sorted dictionary keys.""" - # sorting helps reading - clean_keys = sorted(clean_dict) - return clean_keys - def _clean_files(self, files, key, file_type): """File removal function.""" clean_size = 0