diff --git a/pelican/contents.py b/pelican/contents.py index 6358a34a..a3c6670b 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -6,8 +6,7 @@ class Page(object): """Represents a page Given a content, and metadata, create an adequate object. - :param string: the string to parse, containing the original content. - :param markup: the markup language to use while parsing. + :param content: the string to parse, containing the original content. """ mandatory_properties = ('title',) @@ -93,6 +92,6 @@ def is_valid_content(content, f): try: content.check_properties() return True - except NameError as e: + except NameError, e: error(u"Skipping %s: impossible to find informations about '%s'" % (f, e)) return False diff --git a/pelican/generators.py b/pelican/generators.py index 97c28631..7657261b 100755 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -35,7 +35,7 @@ class Generator(object): loader=FileSystemLoader(self._templates_path), extensions=self.settings.get('JINJA_EXTENSIONS', []), ) - + # get custom Jinja filters from user settings custom_filters = self.settings.get('JINJA_FILTERS', {}) self._env.filters.update(custom_filters) @@ -63,7 +63,13 @@ class Generator(object): extensions = self.markup files = [] - for root, dirs, temp_files in os.walk(path, followlinks=True): + + try: + iter = os.walk(path, followlinks=True) + except TypeError: # python 2.5 does not support followlinks + iter = os.walk(path) + + for root, dirs, temp_files in iter: for e in exclude: if e in dirs: dirs.remove(e) @@ -116,11 +122,11 @@ class ArticlesGenerator(Generator): if 'TAG_FEED' in self.settings: for tag, arts in self.tags.items(): arts.sort(key=attrgetter('date'), reverse=True) - writer.write_feed(arts, self.context, + writer.write_feed(arts, self.context, self.settings['TAG_FEED'] % tag) if 'TAG_FEED_RSS' in self.settings: - writer.write_feed(arts, self.context, + writer.write_feed(arts, self.context, self.settings['TAG_FEED_RSS'] % tag, feed_type='rss') translations_feeds = defaultdict(list) @@ -142,7 +148,7 @@ class ArticlesGenerator(Generator): relative_urls = self.settings.get('RELATIVE_URLS') ) - # to minimize the number of relative path stuff modification + # to minimize the number of relative path stuff modification # in writer, articles pass first article_template = self.get_template('article') for article in chain(self.translations, self.articles): @@ -220,7 +226,7 @@ class ArticlesGenerator(Generator): # sort the articles by date self.articles.sort(key=attrgetter('date'), reverse=True) self.dates = list(self.articles) - self.dates.sort(key=attrgetter('date'), + self.dates.sort(key=attrgetter('date'), reverse=self.context['REVERSE_ARCHIVE_ORDER']) # create tag cloud @@ -236,7 +242,7 @@ class ArticlesGenerator(Generator): if tags: max_count = max(tags) steps = self.settings.get('TAG_CLOUD_STEPS') - + # calculate word sizes self.tag_cloud = [ ( @@ -332,7 +338,7 @@ class PdfGenerator(Generator): # print "Generating pdf for", obj.filename, " in ", output_pdf self.pdfcreator.createPdf(text=open(obj.filename), output=output_pdf) info(u' [ok] writing %s' % output_pdf) - + def generate_context(self): pass diff --git a/pelican/writers.py b/pelican/writers.py index 3679e249..65cfb202 100644 --- a/pelican/writers.py +++ b/pelican/writers.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from __future__ import with_statement import os import re from codecs import open @@ -44,9 +45,8 @@ class Writer(object): Return the feed. If no output_path or filename is specified, just return the feed object. - :param articles: the articles to put on the feed. + :param elements: the articles to put on the feed. :param context: the context to get the feed metadata. - :param output_path: where to output the file. :param filename: the filename to output. :param feed_type: the feed type to use (atom or rss) """ @@ -139,7 +139,7 @@ class Writer(object): '%s_page' % key: page}) if page_num > 0: ext = '.' + paginated_name.rsplit('.')[-1] - paginated_name = paginated_name.replace(ext, + paginated_name = paginated_name.replace(ext, '%s%s' % (page_num + 1, ext)) _write_file(template, paginated_localcontext, self.output_path, @@ -149,7 +149,7 @@ class Writer(object): _write_file(template, localcontext, self.output_path, name) def update_context_contents(self, name, context): - """Recursively run the context to find elements (articles, pages, etc) + """Recursively run the context to find elements (articles, pages, etc) whose content getter needs to be modified in order to deal with relative paths. @@ -188,12 +188,12 @@ class Writer(object): return context def inject_update_method(self, name, item): - """Replace the content attribute getter of an element by a function + """Replace the content attribute getter of an element by a function that will deals with its relatives paths. """ def _update_object_content(name, input): - """Change all the relatives paths of the input content to relatives + """Change all the relatives paths of the input content to relatives paths suitable fot the ouput content :param name: path of the output. diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 936a3171..b90802d8 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python from setuptools import setup import sys @@ -17,7 +18,7 @@ setup( long_description=open('README.rst').read(), packages = ['pelican'], include_package_data = True, - install_requires = requires, + install_requires = requires, scripts = ['bin/pelican'], classifiers = ['Development Status :: 5 - Production/Stable', 'Environment :: Console',