svn commit: samba-web r340 - in trunk/scripts: .
deryck at samba.org
deryck at samba.org
Mon Sep 20 20:36:17 GMT 2004
Author: deryck
Date: 2004-09-20 20:36:17 +0000 (Mon, 20 Sep 2004)
New Revision: 340
WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba-web&path=/trunk/scripts&rev=340&nolog=1
Log:
Get incrementing to 10 headlines right. Also, only open
headlines.html for writing one time.
--deryck
Modified:
trunk/scripts/updateNews.py
Changeset:
Modified: trunk/scripts/updateNews.py
===================================================================
--- trunk/scripts/updateNews.py 2004-09-20 19:33:53 UTC (rev 339)
+++ trunk/scripts/updateNews.py 2004-09-20 20:36:17 UTC (rev 340)
@@ -155,10 +155,6 @@
# 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)
@@ -174,25 +170,22 @@
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()
More information about the samba-cvs
mailing list