From baa89efdfcbdb4e1e108862d96d79be13f5cf114 Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Thu, 8 Jan 2015 14:18:00 +0100 Subject: reproducible: reproducible_html_notes.py: add purge_old_notes() --- bin/reproducible_html_notes.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/reproducible_html_notes.py b/bin/reproducible_html_notes.py index 28081ffa..e7b28d07 100755 --- a/bin/reproducible_html_notes.py +++ b/bin/reproducible_html_notes.py @@ -170,6 +170,16 @@ def gen_html_issue(issue): return issue_html.substitute(issue=issue, urls=url, description=desc, affected_pkgs=affected) + +def purge_old_notes(notes): + presents = os.listdir(NOTES_PATH) + for page in presents: + pkg = page.rsplit('_')[0] + log.debug('checking if ' + page + ' (from ' + pkg + ') is still needed') + if pkg not in notes: + log.info('There are no notes for ' + pkg + '. Removing old page.') + os.remove(NOTES_PATH + '/' + page) + def iterate_over_notes(notes): num_notes = str(len(notes)) i = 0 @@ -226,4 +236,4 @@ if __name__ == '__main__': iterate_over_notes(notes) iterate_over_issues(issues) index_issues(issues) - + purge_old_notes(notes) -- cgit v1.2.3-70-g09d2