Skip to content
Permalink
Browse files

Fix tests by making pkgindex loading optional

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 8, 2017
1 parent db6798f commit 0e979a4ca06f643858bfd82d68011f607558302a
@@ -6,7 +6,7 @@

from __future__ import unicode_literals

from nikola.plugin_categories import ConfigPlugin
from nikola.plugin_categories import ConfigPlugin


class PackageIndex(ConfigPlugin):
@@ -163,14 +163,22 @@ class CompilePackageIndexEntries(PageCompiler):
name = "pkgindex_compiler"
friendly_name = "pkgindex_compiler"
markdown_compiler = None
pi_enabled = False

def set_site(self, site):
"""Set site for the compiler."""
self.config = site.config['PKGINDEX_CONFIG']
# Workaround for plugins site (which includes those plugins, and makes
# tests fail)
if 'PKGINDEX_CONFIG' in self.config:
self.config = site.config['PKGINDEX_CONFIG']
self.pi_enabled = True
super(CompilePackageIndexEntries, self).set_site(site)

def read_metadata(self, post, file_metadata_regexp=None, unslugify_titles=False, lang=None):
"""Read the metadata from a post, and return a metadata dict."""
if not self.pi_enabled:
raise Exception("PKGINDEX_CONFIG not found")

pkg_dir = os.path.split(post.source_path)[0]
top_dir = os.path.dirname(pkg_dir)
metadata = {'slug': os.path.basename(pkg_dir)}
@@ -46,6 +46,8 @@ class PackageIndexScanner(PostScanner):

def scan(self):
"""Scan posts in a package index."""
if 'PKGINDEX_CONFIG' not in self.site.config:
return []
config = self.site.config['PKGINDEX_CONFIG']
plugin_compiler = self.site.get_compiler('sample' + config['extension'])
if not self.site.quiet:
@@ -59,6 +59,8 @@ class PackageIndexZip(Task):
name = "pkgindex_zip"

def gen_tasks(self):
if 'PKGINDEX_CONFIG' not in self.site.config:
return
self.kw = {
'output_folder': self.site.config['OUTPUT_FOLDER'],
'filters': self.site.config['FILTERS'],

0 comments on commit 0e979a4

Please sign in to comment.
You can’t perform that action at this time.