def _update_happened(infofile_filepath, release_notes_dirpath): infofile_content = Helper2.assert_jsonfile_exists(infofile_filepath, _default_infofile_content()) release_notes_files = _release_notes(release_notes_dirpath) release_notes_to_display = set(release_notes_files.keys()) - set(infofile_content['release_notes_displayed']) h = [] datestr_format = '%Y%m%d%H%M%S' for datestr in release_notes_to_display: heapq.heappush(h, datetime.datetime.strptime(datestr, datestr_format)) newly_displayed = [] for i in range(len(h)): datestr = heapq.heappop(h).strftime(datestr_format) filepath_to_display = release_notes_files.get(datestr) if filepath_to_display is not None: newly_displayed.append(datestr) with open(filepath_to_display) as file: print "--------------------------- %s ---------------------------" % filepath_to_display print file.read() if len(newly_displayed) > 0: infofile_content['release_notes_displayed'].extend(newly_displayed) Helper2.write_dict_to_file(infofile_filepath, infofile_content)