project-stats

keep track of your projects
git clone https://git.ce9e.org/project-stats.git

commit
f333028142ad5adcde486b970ef7d38d8692c666
parent
0f6103d1896e6b5ef427aca94569f6f04bdfd1ee
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2015-03-22 15:43
Gardening

Diffstat

M projects.py 55 +++++++++++++++++++++++++++++++------------------------

1 files changed, 31 insertions, 24 deletions


diff --git a/projects.py b/projects.py

@@ -334,6 +334,29 @@ def parse_args():
  334   334     return parser.parse_args()
  335   335 
  336   336 
   -1   337 def get_projects(projects_config):
   -1   338     projects = {}
   -1   339     for key, config in projects_config.items():
   -1   340         try:
   -1   341             claims = ClaimsDict(KEYS)
   -1   342             for source in SOURCES:
   -1   343                 if source in config:
   -1   344                     fn = globals()['get_' + source]
   -1   345                     if source == 'github':
   -1   346                         data = fn(
   -1   347                             config[source],
   -1   348                             user=r_get(config, 'github', 'user'),
   -1   349                             password=r_get(config, 'github', 'password'))
   -1   350                     else:
   -1   351                         data = fn(config[source])
   -1   352                     claims.update(data, source)
   -1   353 
   -1   354             projects[key] = claims
   -1   355         except Exception as e:
   -1   356             logging.error("Error while gathering stats for %s: %s" % (key, e))
   -1   357     return projects
   -1   358 
   -1   359 
  337   360 def main():
  338   361     args = parse_args()
  339   362     config = load_config(os.path.expanduser(args.config))
@@ -342,33 +365,17 @@ def main():
  342   365     if args.query is not None:
  343   366         keys = filter(lambda k: args.query.lower() in k.lower(), keys)
  344   367 
   -1   368     projects = get_projects({key: config['projects'][key] for key in keys})
   -1   369 
  345   370     if args.list:
  346   371         for key in keys:
  347   372             print key
  348    -1         return
  349    -1 
  350    -1     for key in keys:
  351    -1         try:
  352    -1             project = config['projects'][key]
  353    -1             claims = ClaimsDict(KEYS)
  354    -1             if not args.list:
  355    -1                 for source in SOURCES:
  356    -1                     if source in project:
  357    -1                         fn = globals()['get_' + source]
  358    -1                         if source == 'github':
  359    -1                             data = fn(
  360    -1                                 project[source],
  361    -1                                 user=r_get(config, 'github', 'user'),
  362    -1                                 password=r_get(config, 'github', 'password'))
  363    -1                         else:
  364    -1                             data = fn(project[source])
  365    -1                         claims.update(data, source)
  366    -1                 print('%s\n%s\n' % (key, claims.format(
  367    -1                     indent=2,
  368    -1                     short=args.short,
  369    -1                     show_sources=args.show_sources)))
  370    -1         except Exception as e:
  371    -1             logging.error("Error while gathering stats for %s: %s" % (key, e))
   -1   373     else:
   -1   374         for key, claims in projects.items():
   -1   375             print('%s\n%s\n' % (key, claims.format(
   -1   376                 indent=2,
   -1   377                 short=args.short,
   -1   378                 show_sources=args.show_sources)))
  372   379 
  373   380 
  374   381 if __name__ == '__main__':