# Create headlines for samba.org from last ten news items
-headlines = open('headlines.html', 'w')
-headlines.write('<ul class="news">\n')
-headlines.close()
-
all_news = {}
for file in topics_files.keys():
os.chdir(file)
news_dates.reverse()
news_for_headlines = {}
-x = 10
for date in news_dates:
- while x:
- x = x - 1
for line in all_news[date]:
- if line.find('<h3>') > -1:
+ if line.find('<h3>') > -1 and len(news_for_headlines) < 10:
# Search for text between quotes
link = re.search('(?<=\")\S+(?=\")', line)
# Search for text between > and </a
title = re.search('(?<=\"\>).+(?=\<\/a)', line)
- news_for_headlines[date] = (link.group(0), title.group(0))
+ news_for_headlines[date] = (link.group(0), title.group(0))
headline_dates = news_for_headlines.keys()
headline_dates.sort()
headline_dates.reverse()
-headlines = open('headlines.html', 'a')
+headlines = open('headlines.html', 'w')
+headlines.write('<ul class="news">\n')
for date in headline_dates:
headlines.write('<li>' + date_to_str(time.gmtime(date)[:3]) + ' <a href="/samba/news/#' + news_for_headlines[date][0] + '">' + news_for_headlines[date][1] + '</a></li>\n')
-
headlines.write('</ul>\n')
-headlines.close()
\ No newline at end of file
+headlines.close()