aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sitemap/sitemap.py
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/sitemap/sitemap.py')
-rw-r--r--plugins/sitemap/sitemap.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/plugins/sitemap/sitemap.py b/plugins/sitemap/sitemap.py
index 0cf7227..327ca2b 100644
--- a/plugins/sitemap/sitemap.py
+++ b/plugins/sitemap/sitemap.py
@@ -54,6 +54,7 @@ def format_date(date):
tz = "-00:00"
return date.strftime("%Y-%m-%dT%H:%M:%S") + tz
+
class SitemapGenerator(object):
def __init__(self, context, settings, path, theme, output_path, *null):
@@ -63,7 +64,6 @@ class SitemapGenerator(object):
self.now = datetime.now()
self.siteurl = settings.get('SITEURL')
-
self.default_timezone = settings.get('TIMEZONE', 'UTC')
self.timezone = getattr(self, 'timezone', self.default_timezone)
self.timezone = timezone(self.timezone)
@@ -103,7 +103,7 @@ class SitemapGenerator(object):
valid_keys = ('articles', 'indexes', 'pages')
valid_chfreqs = ('always', 'hourly', 'daily', 'weekly', 'monthly',
- 'yearly', 'never')
+ 'yearly', 'never')
if isinstance(pris, dict):
# We use items for Py3k compat. .iteritems() otherwise
@@ -169,7 +169,7 @@ class SitemapGenerator(object):
pageurl = '' if page.url == 'index.html' else page.url
- #Exclude URLs from the sitemap:
+ # Exclude URLs from the sitemap:
if self.format == 'xml':
flag = False
for regstr in self.sitemapExclude:
@@ -177,7 +177,8 @@ class SitemapGenerator(object):
flag = True
break
if not flag:
- fd.write(XML_URL.format(self.siteurl, pageurl, lastmod, chfreq, pri))
+ fd.write(XML_URL.format(
+ self.siteurl, pageurl, lastmod, chfreq, pri))
else:
fd.write(self.siteurl + '/' + pageurl + '\n')
@@ -193,9 +194,11 @@ class SitemapGenerator(object):
for (wrapper, articles) in wrappers:
lastmod = datetime.min.replace(tzinfo=self.timezone)
for article in articles:
- lastmod = max(lastmod, article.date.replace(tzinfo=self.timezone))
+ lastmod = max(lastmod,
+ article.date.replace(tzinfo=self.timezone))
try:
- modified = self.get_date_modified(article, datetime.min).replace(tzinfo=self.timezone)
+ modified = self.get_date_modified(
+ article, datetime.min).replace(tzinfo=self.timezone)
lastmod = max(lastmod, modified)
except ValueError:
# Supressed: user will be notified.
@@ -203,12 +206,13 @@ class SitemapGenerator(object):
setattr(wrapper, 'modified', str(lastmod))
def generate_output(self, writer):
- path = os.path.join(self.output_path, 'sitemap.{0}'.format(self.format))
+ path = os.path.join(
+ self.output_path, 'sitemap.{0}'.format(self.format))
pages = self.context['pages'] + self.context['articles'] \
- + [ c for (c, a) in self.context['categories']] \
- + [ t for (t, a) in self.context['tags']] \
- + [ a for (a, b) in self.context['authors']]
+ + [c for (c, a) in self.context['categories']] \
+ + [t for (t, a) in self.context['tags']] \
+ + [a for (a, b) in self.context['authors']]
self.set_url_wrappers_modification_date(self.context['categories'])
self.set_url_wrappers_modification_date(self.context['tags'])