Beispiel #1
0
 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)
Beispiel #2
0
Datei: git.py Projekt: tosky/did
 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)
Beispiel #3
0
 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)
Beispiel #4
0
Datei: cli.py Projekt: mfrodl/did
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.")
Beispiel #5
0
Datei: cli.py Projekt: thrix/did
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.")
Beispiel #6
0
 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)
Beispiel #7
0
 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)
Beispiel #8
0
 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)
Beispiel #9
0
 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)
Beispiel #10
0
 def show(self):
     """ Name only for empty stats """
     utils.item(self.name, options=self.options)
Beispiel #11
0
 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)
Beispiel #12
0
 def show(self):
     """ Name only for empty stats """
     utils.item(self.name, options=self.options)
Beispiel #13
0
Datei: items.py Projekt: psss/did
 def header(self):
     """ Simple header for custom stats (no item count) """
     item(self.name, 0, options=self.options)
Beispiel #14
0
 def header(self):
     """ Simple header for custom stats (no item count) """
     item(self.name, 0, options=self.options)