def show(self): """ Display indented statistics. """ if not self._error and not self.stats: return self.header() for stat in self.stats: utils.item(stat, level=1, options=self.options)
def header(self): """ Show summary header. """ # A bit different header for git stats: Work on xxx: x commit(s) item("{0}: {1} commit{2}".format(self.name, len(self.stats), "" if len(self.stats) == 1 else "s"), level=0, options=self.options)
def main(arguments=None): """ Parse options, gather stats and show the results Takes optional parameter ``arguments`` which can be either command line string or list of options. This is very useful for testing purposes. Function returns a tuple of the form:: ([user_stats], team_stats) with the list of all gathered stats objects. """ try: # Parse options, initialize gathered stats options, header = Options().parse(arguments) gathered_stats = [] # Check for user email addresses (command line or config) emails = options.emails or did.base.Config().email emails = utils.split(emails, separator=re.compile(r"\s*,\s*")) users = [did.base.User(email=email) for email in emails] # Print header and prepare team stats object for data merging utils.eprint(header) team_stats = UserStats(options=options) if options.merge: utils.header("Total Report") utils.item("Users: {0}".format(len(users)), options=options) # Check individual user stats for user in users: if options.merge: utils.item(user, 1, options=options) else: utils.header(user) user_stats = UserStats(user=user, options=options) user_stats.check() team_stats.merge(user_stats) gathered_stats.append(user_stats) # Display merged team report if options.merge or options.total: if options.total: utils.header("Total Report") team_stats.show() # Return all gathered stats objects return gathered_stats, team_stats except did.base.ConfigFileError as error: utils.info( "Create at least a minimum config file {0}:\n{1}".format( did.base.Config.path(), did.base.Config.example().strip() ) ) raise except kerberos.GSSError as error: log.debug(error) raise did.base.ConfigError("Kerberos authentication failed. Try kinit.")
def main(arguments=None): """ Parse options, gather stats and show the results Takes optional parameter ``arguments`` which can be either command line string or list of options. This is very useful for testing purposes. Function returns a tuple of the form:: ([user_stats], team_stats) with the list of all gathered stats objects. """ try: # Parse options, initialize gathered stats options, header = Options().parse(arguments) gathered_stats = [] # Check for user email addresses (command line or config) emails = options.emails or did.base.Config().email emails = utils.split(emails, separator=re.compile(r"\s*,\s*")) users = [did.base.User(email=email) for email in emails] # Print header and prepare team stats object for data merging utils.eprint(header) team_stats = UserStats(options=options) if options.merge: utils.header("Total Report") utils.item("Users: {0}".format(len(users)), options=options) # Check individual user stats for user in users: if options.merge: utils.item(user, 1, options=options) else: utils.header(user) user_stats = UserStats(user=user, options=options) user_stats.check() team_stats.merge(user_stats) gathered_stats.append(user_stats) # Display merged team report if options.merge or options.total: if options.total: utils.header("Total Report") team_stats.show() # Return all gathered stats objects return gathered_stats, team_stats except did.base.ConfigFileError as error: utils.info("Create at least a minimum config file {0}:\n{1}".format( did.base.Config.path(), did.base.Config.example().strip())) raise except kerberos.GSSError as error: log.debug(error) raise did.base.ConfigError( "Kerberos authentication failed. Try kinit.")
def header(self): """ Show summary header. """ # A bit different header for git stats: Work on xxx: x commit(s) item( "{0}: {1} commit{2}".format( self.name, len(self.stats), "" if len(self.stats) == 1 else "s"), level=0, options=self.options)
def header(self): """ Show summary header. """ # Different header for wiki: Updates on xxx: x changes of y pages item( "{0}: {1} change{2} of {3} page{4}".format( self.name, self.changes, "" if self.changes == 1 else "s", len(self.stats), "" if len(self.stats) == 1 else "s"), level=0, options=self.options)
def header(self): """ Show summary header. """ # Different header for wiki: Updates on xxx: x changes of y pages item("{0}: {1} change{2} of {3} page{4}".format( self.name, self.changes, "" if self.changes == 1 else "s", len(self.stats), "" if len(self.stats) == 1 else "s"), level=0, options=self.options)
def header(self): """ Show summary header. """ # Show question mark instead of count when errors encountered count = "? (error encountered)" if self._error else len(self.stats) utils.item("{0}: {1}".format(self.name, count), options=self.options)
def show(self): """ Name only for empty stats """ utils.item(self.name, options=self.options)
def header(self): """ Simple header for custom stats (no item count) """ item(self.name, 0, options=self.options)