Files
pelican-plugins/touch/__init__.py
Alexis Métaireau 99ee27bd35 Add a touch plugin
2013-08-17 12:51:38 +02:00

21 lines
441 B
Python

from pelican import signals
import logging
import os
import time
logger = logging.getLogger(__name__)
def touch_file(path, context):
content = context.get('article', context.get('page'))
if content and hasattr(content, 'date'):
mtime = time.mktime(content.date.timetuple())
logger.info('touching %s', path)
os.utime(path, (mtime, mtime))
def register():
signals.content_written.connect(touch_file)