forked from github/pelican
Merge branch 'hacks' of https://github.com/RonnyPfannschmidt/pelican
This commit is contained in:
commit
b7daed2ce3
4 changed files with 21 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import argparse
|
||||
import os
|
||||
import time
|
||||
|
||||
from pelican.generators import (ArticlesGenerator, PagesGenerator,
|
||||
StaticGenerator, PdfGenerator)
|
||||
|
|
@ -140,6 +141,7 @@ def main():
|
|||
try:
|
||||
if files_changed(pelican.path, pelican.markup):
|
||||
pelican.run()
|
||||
time.sleep(.5) # sleep to avoid cpu load
|
||||
except KeyboardInterrupt:
|
||||
break
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
from logging import *
|
||||
from logging import CRITICAL, ERROR, WARN, INFO, DEBUG
|
||||
from logging import critical, error, info, warning, warn, debug
|
||||
from logging import Formatter, getLogger, StreamHandler
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ try:
|
|||
from docutils import core
|
||||
|
||||
# import the directives to have pygments support
|
||||
import rstdirectives
|
||||
from pelican import rstdirectives
|
||||
except ImportError:
|
||||
core = False
|
||||
try:
|
||||
|
|
@ -11,15 +11,14 @@ try:
|
|||
except ImportError:
|
||||
Markdown = False
|
||||
import re
|
||||
import string
|
||||
|
||||
from pelican.utils import get_date, open
|
||||
|
||||
|
||||
_METADATAS_PROCESSORS = {
|
||||
'tags': lambda x: map(string.strip, x.split(',')),
|
||||
'tags': lambda x: map(unicode.strip, x.split(',')),
|
||||
'date': lambda x: get_date(x),
|
||||
'status': string.strip,
|
||||
'status': unicode.strip,
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -46,7 +45,9 @@ class RstReader(Reader):
|
|||
metadatas = self._parse_metadata(text)
|
||||
extra_params = {'input_encoding': 'unicode',
|
||||
'initial_header_level': '2'}
|
||||
rendered_content = core.publish_parts(text, writer_name='html',
|
||||
rendered_content = core.publish_parts(text,
|
||||
source_path=filename,
|
||||
writer_name='html',
|
||||
settings_overrides=extra_params)
|
||||
title = rendered_content.get('title')
|
||||
content = rendered_content.get('body')
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from datetime import datetime
|
|||
from codecs import open as _open
|
||||
from itertools import groupby
|
||||
from operator import attrgetter
|
||||
from pelican.log import *
|
||||
from pelican.log import warning, info
|
||||
|
||||
|
||||
def get_date(string):
|
||||
|
|
@ -62,7 +62,7 @@ def clean_output_dir(path):
|
|||
|
||||
# remove all the existing content from the output folder
|
||||
try:
|
||||
shutil.rmtree(path)
|
||||
pass # WEEEEE dont kill
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
|
@ -164,9 +164,13 @@ def process_translations(content_list):
|
|||
len_ = len(default_lang_items)
|
||||
if len_ > 1:
|
||||
warning(u'there are %s variants of "%s"' % (len_, slug))
|
||||
for x in default_lang_items:
|
||||
warning(' %s' % x.filename)
|
||||
elif len_ == 0:
|
||||
default_lang_items = items[:1]
|
||||
|
||||
if not slug:
|
||||
warning('empty slug for %r' %( default_lang_items[0].filename,))
|
||||
index.extend(default_lang_items)
|
||||
translations.extend(filter(
|
||||
lambda x: x not in default_lang_items,
|
||||
|
|
@ -188,9 +192,10 @@ def files_changed(path, extensions):
|
|||
|
||||
def file_times(path):
|
||||
"""Return the last time files have been modified"""
|
||||
for top_level in os.listdir(path):
|
||||
for root, dirs, files in os.walk(top_level):
|
||||
for file in filter(with_extension, files):
|
||||
for root, dirs, files in os.walk(path):
|
||||
dirs[:] = [x for x in dirs if x[0] != '.']
|
||||
for file in files:
|
||||
if any(file.endswith(ext) for ext in extensions):
|
||||
yield os.stat(os.path.join(root, file)).st_mtime
|
||||
|
||||
global LAST_MTIME
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue