import glob from nikola.plugin_categories import Task from nikola import utils from mako.template import Template from mako.lookup import TemplateLookup from nikola.utils import LOGGER # self.site is defined in nikola.nikola.Nikola(object) class Plugin(Task): name = "symlinks" def gen_tasks(self): # This function will be called when the task is executed def say_hi(bye): import os pwd = os.getcwd() os.chdir('output') try: os.symlink('assets/favicon.ico', 'favicon.ico') except FileExistsError as e: pass try: os.symlink('../wp-content/', 'wp-content') except FileExistsError as e: pass os.chdir(pwd) return True # Never fail because a config key is missing. bye = self.site.config.get('BYE_WORLD', False) # Yield a task for Doit return { 'basename': 'symlinks', 'actions': [(say_hi, [bye])], 'uptodate': [False], }