Remove redundant LESS_COMPILER setting

This commit is contained in:
Meir Kriheli 2012-04-28 03:25:54 +03:00
commit f558389006
5 changed files with 11 additions and 8 deletions

View file

@ -82,9 +82,9 @@ Setting name (default value) What does it do?
generated HTML, using the `Typogrify generated HTML, using the `Typogrify
<http://static.mintchaos.com/projects/typogrify/>`_ <http://static.mintchaos.com/projects/typogrify/>`_
library library
`LESS_GENERATOR` (``FALSE``) Set to True if you want to enable compiling less `LESS_GENERATOR` (``FALSE``) Set to True or complete path to `lessc` (if not
files. Requires installation of `less css`_. found in system PATH) to enable compiling less
`LESS_COMPILER` (``'/usr/bin/lessc'``) The path to less css compiler (`lessc`) css files. Requires installation of `less css`_.
================================================ ===================================================== ================================================ =====================================================
.. [#] Default is the system locale. .. [#] Default is the system locale.

View file

@ -134,7 +134,7 @@ class Pelican(object):
generators = [ArticlesGenerator, PagesGenerator, StaticGenerator] generators = [ArticlesGenerator, PagesGenerator, StaticGenerator]
if self.settings['PDF_GENERATOR']: if self.settings['PDF_GENERATOR']:
generators.append(PdfGenerator) generators.append(PdfGenerator)
if self.settings['LESS_GENERATOR']: if self.settings['LESS_GENERATOR']: # can be True or PATH to lessc
generators.append(LessCSSGenerator) generators.append(LessCSSGenerator)
return generators return generators

View file

@ -418,7 +418,7 @@ class PdfGenerator(Generator):
class LessCSSGenerator(Generator): class LessCSSGenerator(Generator):
"""Compile less css files. This assumes we have `lessc` in our PATH.""" """Compile less css files."""
def _compile(self, less_file, source_dir, dest_dir): def _compile(self, less_file, source_dir, dest_dir):
base = os.path.relpath(less_file, source_dir) base = os.path.relpath(less_file, source_dir)
@ -433,13 +433,18 @@ class LessCSSGenerator(Generator):
logger.error("Couldn't create the pdf output folder in " + logger.error("Couldn't create the pdf output folder in " +
target_dir) target_dir)
cmd = ' '.join([self.settings['LESS_COMPILER'], less_file, target]) cmd = ' '.join([self._lessc, less_file, target])
subprocess.call(cmd, shell=True) subprocess.call(cmd, shell=True)
logger.info(u' [ok] compiled %s' % base) logger.info(u' [ok] compiled %s' % base)
def generate_output(self, writer=None): def generate_output(self, writer=None):
logger.info(u' Compiling less css') logger.info(u' Compiling less css')
# store out compiler here, so it won't be evaulted on each run of
# _compile
lg = self.settings['LESS_GENERATOR']
self._lessc = lg if isinstance(lg, basestring) else 'lessc'
# walk static paths # walk static paths
for static_path in self.settings['STATIC_PATHS']: for static_path in self.settings['STATIC_PATHS']:
for f in self.get_files( for f in self.get_files(

View file

@ -68,7 +68,6 @@ _DEFAULT_CONFIG = {'PATH': '.',
'ARTICLE_PERMALINK_STRUCTURE': '', 'ARTICLE_PERMALINK_STRUCTURE': '',
'TYPOGRIFY': False, 'TYPOGRIFY': False,
'LESS_GENERATOR': False, 'LESS_GENERATOR': False,
'LESS_COMPILER': '/usr/bin/lessc',
} }

View file

@ -68,7 +68,6 @@ class TestLessCSSGenerator(unittest.TestCase):
settings = _DEFAULT_CONFIG.copy() settings = _DEFAULT_CONFIG.copy()
settings['STATIC_PATHS'] = ['static'] settings['STATIC_PATHS'] = ['static']
settings['LESS_GENERATOR'] = True settings['LESS_GENERATOR'] = True
settings['LESS_COMPILER'] = 'lessc'
# we'll nest here for py < 2.7 compat # we'll nest here for py < 2.7 compat
with temporary_folder() as temp_content: with temporary_folder() as temp_content: