Skip to content

Commit

Permalink
Merge pull request #22 from Commonists/simplemetadata
Browse files Browse the repository at this point in the history
Ok merging Simplemetadata
  • Loading branch information
PierreSelim committed Oct 13, 2015
2 parents 2358b9b + 223b486 commit 6135c01
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
11 changes: 11 additions & 0 deletions surfaceimagecontentgap/contentgap.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,14 @@ def reset(self):
"""Reset filter and ranking to None."""
self.filtered_articles = None
self.ranked_articles = None

def metadata(self):
"""Informations about the number of articles and filtered articles."""
len_articles = 0
if self.articles:
len_articles = len(self.articles)
len_filtered_articles = 0
if self.filtered_articles:
len_filtered_articles = len(self.filtered_articles)
return {'articles': len_articles,
'filtered': len_filtered_articles}
5 changes: 4 additions & 1 deletion surfaceimagecontentgap/imagegap.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ def callback(self):
def callback_function(gap):
"""The call back function to call in order to save result."""
LOG.info("Saving reports to %s", self.reportname)
content = report.create(gap.ranked_articles) # report content
info = gap.metadata()
content = report.create(gap.ranked_articles,
articles=info['articles'],
filtered_articles=info['filtered'])
report.save(self.site, self.reportname, content)
return {'timer': self.timer, 'function': callback_function}

Expand Down
8 changes: 7 additions & 1 deletion surfaceimagecontentgap/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
"""Reports for image content gap."""


def create(articlelist):
def create(articlelist, articles=None, filtered_articles=None):
"""Create a report from article list with views
Args:
articlelist (list): list of dictionnaries with article and evaluation
for each article [{'article': 'Foo', 'evaluation': 42}, ...]
articles (optional: int): number of articles to process
filtered_articles (optional: int): number of articles filtered
Returns:
str: wiki code for the report
"""
Expand All @@ -18,6 +20,10 @@ def create(articlelist):
reportcode += "|-\n| [[{0}]]\n| {1}\n".format(article['article'],
article['evaluation'])
reportcode += "|}\n"
if articles and filtered_articles:
reportcode += "== Data ==\n"
reportcode += "* total articles: %d\n" % articles
reportcode += "* filtered articles: %d\n" % filtered_articles
return reportcode


Expand Down

0 comments on commit 6135c01

Please sign in to comment.