From 9558c616ac4c08b826c2a67a709727f433cee00d Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 15 Mar 2006 14:53:53 +0000 Subject: [PATCH] Split get_news() into get_news_header() and get_news_items(). git-svn-id: file:///home/phd/archive/SVN/phdru.name/scripts@26 7bb0bf08-9e0d-0410-b083-99cee3bf18b8 --- news.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/news.py b/news.py index 7d0977c..9e47cb3 100644 --- a/news.py +++ b/news.py @@ -16,18 +16,14 @@ class NewsItem(object): self.title = title self.rel_link = rel_link -def get_news(lang): - """Get news - - @param lang: langauge - @type lang: a string 'en' or 'ru' - @return: a tuple of (lnaguge-dependent header, a list of new items) - - """ +def get_news_header(lang): news_tmpl_file = open("news.tmpl-%s" % lang, 'r') header = news_tmpl_file.read() news_tmpl_file.close() + return header + +def get_news_items(lang): news_items_file = open("news_%s" % lang, 'r') news_text = news_items_file.read() news_items_file.close() @@ -38,7 +34,17 @@ def get_news(lang): date, rel_link, title = line.split(None, 2) news_items.append(NewsItem(date, title, rel_link)) - return header, news_items + return news_items + +def get_news(lang): + """Get news + + @param lang: langauge + @type lang: a string 'en' or 'ru' + @return: a tuple of (lnaguge-dependent header, a list of new items) + + """ + return get_news_header(), get_news_items() def write_if_changed(filename, new_text): -- 2.39.5