added IGNORE_FILES setting for autoreload

This commit is contained in:
Rıdvan Örsvuran 2012-12-19 16:26:00 +02:00 committed by Bruno Binet
commit 0288bf1f68
3 changed files with 9 additions and 6 deletions

View file

@ -44,6 +44,7 @@ class Pelican(object):
self.theme = settings['THEME'] self.theme = settings['THEME']
self.output_path = settings['OUTPUT_PATH'] self.output_path = settings['OUTPUT_PATH']
self.markup = settings['MARKUP'] self.markup = settings['MARKUP']
self.ignore_files = settings['IGNORE_FILES']
self.delete_outputdir = settings['DELETE_OUTPUT_DIRECTORY'] self.delete_outputdir = settings['DELETE_OUTPUT_DIRECTORY']
self.init_path() self.init_path()
@ -292,8 +293,8 @@ def main():
# restriction; all files are recursively checked if they # restriction; all files are recursively checked if they
# have changed, no matter what extension the filenames # have changed, no matter what extension the filenames
# have. # have.
if files_changed(pelican.path, pelican.markup) or \ if files_changed(pelican.path, pelican.markup, pelican.ignore_files) or \
files_changed(pelican.theme, ['']): files_changed(pelican.theme, [''], pelican.ignore_files):
if not files_found_error: if not files_found_error:
files_found_error = True files_found_error = True
pelican.run() pelican.run()

View file

@ -80,7 +80,8 @@ _DEFAULT_CONFIG = {'PATH': '.',
'TYPOGRIFY': False, 'TYPOGRIFY': False,
'SUMMARY_MAX_LENGTH': 50, 'SUMMARY_MAX_LENGTH': 50,
'PLUGINS': [], 'PLUGINS': [],
'TEMPLATE_PAGES': {} 'TEMPLATE_PAGES': {},
'IGNORE_FILES': []
} }

View file

@ -10,6 +10,7 @@ import traceback
import logging import logging
import errno import errno
import locale import locale
import fnmatch
from collections import defaultdict, Hashable from collections import defaultdict, Hashable
from functools import partial from functools import partial
@ -406,8 +407,7 @@ def process_translations(content_list):
LAST_MTIME = 0 LAST_MTIME = 0
def files_changed(path, extensions, ignores=[]):
def files_changed(path, extensions):
"""Return True if the files have changed since the last check""" """Return True if the files have changed since the last check"""
def file_times(path): def file_times(path):
@ -415,7 +415,8 @@ def files_changed(path, extensions):
for root, dirs, files in os.walk(path): for root, dirs, files in os.walk(path):
dirs[:] = [x for x in dirs if x[0] != '.'] dirs[:] = [x for x in dirs if x[0] != '.']
for f in files: for f in files:
if any(f.endswith(ext) for ext in extensions): if any(f.endswith(ext) for ext in extensions) \
and not any(fnmatch.fnmatch(f, ignore) for ignore in ignores):
yield os.stat(os.path.join(root, f)).st_mtime yield os.stat(os.path.join(root, f)).st_mtime
global LAST_MTIME global LAST_MTIME