1
0
Fork 0
forked from github/pelican

PEP8-ify.

Wrap to 80 chars, sanitize imports.
This commit is contained in:
Alexis Metaireau 2012-03-09 16:21:38 +01:00
commit 6cde7fd27a
8 changed files with 142 additions and 110 deletions

View file

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import os
from os.path import isabs
import locale
from pelican import log
@ -10,8 +11,8 @@ _DEFAULT_CONFIG = {'PATH': None,
'THEME': DEFAULT_THEME,
'OUTPUT_PATH': 'output/',
'MARKUP': ('rst', 'md'),
'STATIC_PATHS': ['images',],
'THEME_STATIC_PATHS': ['static',],
'STATIC_PATHS': ['images', ],
'THEME_STATIC_PATHS': ['static', ],
'FEED': 'feeds/all.atom.xml',
'CATEGORY_FEED': 'feeds/%s.atom.xml',
'TRANSLATION_FEED': 'feeds/all-%s.atom.xml',
@ -44,7 +45,7 @@ _DEFAULT_CONFIG = {'PATH': None,
'DEFAULT_DATE_FORMAT': '%a %d %B %Y',
'DATE_FORMATS': {},
'JINJA_EXTENSIONS': [],
'LOCALE': '', # default to user locale
'LOCALE': '', # default to user locale
'DEFAULT_PAGINATION': False,
'DEFAULT_ORPHANS': 0,
'DEFAULT_METADATA': (),
@ -53,6 +54,7 @@ _DEFAULT_CONFIG = {'PATH': None,
'ARTICLE_PERMALINK_STRUCTURE': ''
}
def read_settings(filename):
"""Load a Python file into a dictionary.
"""
@ -67,9 +69,10 @@ def read_settings(filename):
# Make the paths relative to the settings file
for path in ['PATH', 'OUTPUT_PATH']:
if path in context:
if context[path] is not None and not os.path.isabs(context[path]):
# FIXME:
context[path] = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(filename), context[path])))
if context[path] is not None and not isabs(context[path]):
context[path] = os.path.abspath(os.path.normpath(
os.path.join(os.path.dirname(filename), context[path]))
)
# if locales is not a list, make it one
locales = context['LOCALE']
@ -84,17 +87,17 @@ def read_settings(filename):
for locale_ in locales:
try:
locale.setlocale(locale.LC_ALL, locale_)
break # break if it is successfull
break # break if it is successfull
except locale.Error:
pass
else:
log.warn("LOCALE option doesn't contain a correct value")
if not 'TIMEZONE' in context:
log.warn("No timezone information specified in the settings. Assuming your "\
"timezone is UTC for feed generation. "\
"Check http://docs.notmyidea.org/alexis/pelican/settings.html#timezone "\
"for more information")
log.warn("No timezone information specified in the settings. Assuming"
" your timezone is UTC for feed generation. Check "
"http://docs.notmyidea.org/alexis/pelican/settings.html#timezone "
"for more information")
# set the locale
return context