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 8A08D138202 for ; Fri, 2 Aug 2013 10:34:46 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A29A3E0931; Fri, 2 Aug 2013 10:34:44 +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 0198FE0931 for ; Fri, 2 Aug 2013 10:34:43 +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 C09A833EBB1 for ; Fri, 2 Aug 2013 10:34:42 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 5F8B8E5463 for ; Fri, 2 Aug 2013 10:34:41 +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: <1375438804.a343c180f2d22c0411086c3dbca5eb2d85da235e.dywi@gentoo> Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/stats/ X-VCS-Repository: proj/R_overlay X-VCS-Files: roverlay/stats/abstract.py roverlay/stats/base.py roverlay/stats/collector.py X-VCS-Directories: roverlay/stats/ X-VCS-Committer: dywi X-VCS-Committer-Name: André Erdmann X-VCS-Revision: a343c180f2d22c0411086c3dbca5eb2d85da235e X-VCS-Branch: master Date: Fri, 2 Aug 2013 10:34:41 +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: 78a854ef-9ff6-49a5-acf6-ec1073601cd6 X-Archives-Hash: b0fc6ae7300f0eeaaddee2c2cb88b4ff commit: a343c180f2d22c0411086c3dbca5eb2d85da235e Author: André Erdmann mailerd de> AuthorDate: Fri Aug 2 10:20:04 2013 +0000 Commit: André Erdmann mailerd de> CommitDate: Fri Aug 2 10:20:04 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=a343c180 stats collection: has_changes(), count imports * overlay_has_changes() * count imported ebuilds --- roverlay/stats/abstract.py | 54 ++++++++++++++++++++++++++++++++++++++++----- roverlay/stats/base.py | 36 ++++++++++++++++++++++++------ roverlay/stats/collector.py | 7 ++++++ 3 files changed, 84 insertions(+), 13 deletions(-) diff --git a/roverlay/stats/abstract.py b/roverlay/stats/abstract.py index 68728f4..5ac87bc 100644 --- a/roverlay/stats/abstract.py +++ b/roverlay/stats/abstract.py @@ -9,7 +9,8 @@ from __future__ import division import collections import time -from roverlay.util.objects import MethodNotImplementedError +import roverlay.util.objects +from roverlay.util.objects import MethodNotImplementedError, abstractmethod class RoverlayStatsBase ( object ): @@ -47,15 +48,15 @@ class RoverlayStatsBase ( object ): getattr ( self, member ).merge_with ( getattr ( other, member ) ) # --- end of merge_members (...) --- - def _iter_members ( self, nofail=False ): + def iter_members ( self, nofail=False ): if not nofail or hasattr ( self, '_MEMBERS' ): for member in self.__class__._MEMBERS: yield getattr ( self, member ) - # --- end of _iter_members (...) --- + # --- end of iter_members (...) --- def has_nonzero ( self ): if hasattr ( self, '_MEMBERS' ): - for member in self._iter_members(): + for member in self.iter_members(): if int ( member ) != 0: return member else: @@ -63,7 +64,7 @@ class RoverlayStatsBase ( object ): # --- end of has_nonzero (...) --- def reset_members ( self ): - for member in self._iter_members(): + for member in self.iter_members(): member.reset() # --- end of reset_members (...) --- @@ -86,7 +87,7 @@ class RoverlayStatsBase ( object ): if desc: yield desc - for member in self._iter_members( nofail=True ): + for member in self.iter_members( nofail=True ): yield str ( member ) # --- end of gen_str (...) --- @@ -103,6 +104,15 @@ class RoverlayStatsBase ( object ): class RoverlayStats ( RoverlayStatsBase ): pass + + @abstractmethod + def has_changes ( self ): + """Returns True if this stats item has any numbers indicating that + the overlay has changes. + """ + return False + # --- end of has_changes (...) --- + # --- end of RoverlayStats --- @@ -143,6 +153,10 @@ class TimeStats ( RoverlayStats ): self._timestats = collections.OrderedDict() # --- end of __init__ (...) --- + def has_changes ( self ): + return False + # --- end of has_changes (...) --- + def merge_with ( self, other ): self._timestats.update ( other._timestats ) # --- end of merge_with (...) --- @@ -225,6 +239,10 @@ class Counter ( RoverlayStatsBase ): return float ( self.total_count ) # --- end of __float__ (...) --- + def __bool__ ( self ): + return bool ( self.total_count ) + # --- end of __bool__ (...) --- + def __add__ ( self, other ): return self.total_count + int ( other ) # --- end of __add__ (...) --- @@ -233,6 +251,30 @@ class Counter ( RoverlayStatsBase ): return self.total_count - int ( other ) # --- end of __sub__ (...) --- + def __gt__ ( self, other ): + return self.total_count > int ( other ) + # --- end of __gt__ (...) --- + + def __ge__ ( self, other ): + return self.total_count >= int ( other ) + # --- end of __ge__ (...) --- + + def __lt__ ( self, other ): + return self.total_count < int ( other ) + # --- end of __lt__ (...) --- + + def __le__ ( self, other ): + return self.total_count <= int ( other ) + # --- end of __le__ (...) --- + + def __eq__ ( self, other ): + return self.total_count == int ( other ) + # --- end of __eq__ (...) --- + + def __ne__ ( self, other ): + return self.total_count != int ( other ) + # --- end of __ne__ (...) --- + def has_details ( self ): return False # --- end of has_details (...) --- diff --git a/roverlay/stats/base.py b/roverlay/stats/base.py index 28531c2..282ff78 100644 --- a/roverlay/stats/base.py +++ b/roverlay/stats/base.py @@ -19,6 +19,10 @@ class RepoStats ( abstract.RoverlayStats ): ) # --- end of __init__ (...) --- + def has_changes ( self ): + return False + # --- end of has_changes (...) --- + def package_file_found ( self, repo ): self.pkg_count.inc ( repo.name ) # --- end of add_package (...) --- @@ -37,6 +41,10 @@ class DistmapStats ( abstract.RoverlayStats ): ) # --- end of __init__ (...) --- + def has_changes ( self ): + return False + # --- end of has_changes (...) --- + def file_added ( self, *origin ): self.pkg_count.inc ( *origin ) # --- end of file_added (...) --- @@ -58,6 +66,10 @@ class OverlayCreationWorkerStats ( abstract.RoverlayStats ): self.pkg_success = abstract.Counter ( "success" ) # --- end of __init__ (...) --- + def has_changes ( self ): + return bool ( self.pkg_success ) + # --- end of has_changes (...) --- + # --- end of OverlayCreationWorkerStats --- @@ -103,24 +115,34 @@ class OverlayStats ( abstract.RoverlayStats ): _MEMBERS = ( 'scan_time', 'write_time', - 'ebuilds_scanned', 'ebuild_count', 'revbump_count', 'ebuilds_written', + 'ebuilds_scanned', 'ebuild_count', 'revbump_count', + 'ebuilds_imported', 'ebuilds_written', ) def __init__ ( self ): super ( OverlayStats, self ).__init__() # ebuilds_scanned: ebuild count prior to running overlay creation - self.ebuilds_scanned = abstract.Counter ( "pre" ) + self.ebuilds_scanned = abstract.Counter ( "pre" ) # ebuild count: ebuild count after writing the overlay - self.ebuild_count = abstract.Counter ( "post" ) + self.ebuild_count = abstract.Counter ( "post" ) - self.revbump_count = abstract.Counter ( "revbumps" ) - self.ebuilds_written = abstract.Counter ( "written" ) + self.revbump_count = abstract.Counter ( "revbumps" ) + self.ebuilds_written = abstract.Counter ( "written" ) + self.ebuilds_imported = abstract.Counter ( "imported" ) - self.write_time = abstract.TimeStats ( "write_time" ) - self.scan_time = abstract.TimeStats ( "scan_time" ) + self.write_time = abstract.TimeStats ( "write_time" ) + self.scan_time = abstract.TimeStats ( "scan_time" ) # --- end of __init__ (...) --- + def has_changes ( self ): + return ( + ( self.ebuild_count - self.ebuilds_scanned ) != 0 or + self.ebuilds_written > 0 or + self.revbump_count > 0 + ) + # --- end of has_changes (...) --- + def set_ebuild_written ( self, p_info ): self.ebuilds_written.inc() # direct dict access diff --git a/roverlay/stats/collector.py b/roverlay/stats/collector.py index 85eb358..ebae1a6 100644 --- a/roverlay/stats/collector.py +++ b/roverlay/stats/collector.py @@ -26,6 +26,13 @@ class StatsCollector ( abstract.RoverlayStatsBase ): return cls._instance # --- end of instance (...) --- + def overlay_has_any_changes ( self ): + """Returns True if the resulting overlay has any changes (according to + stats). + """ + return any ( x.has_changes() for x in self.iter_members() ) + # --- end of overlay_has_any_changes (...) --- + def get_success_ratio ( self ): # success ratio for "this" run: # new ebuilds / relevant package count (new packages - unsuitable,