mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Load a default-named configuration file if present
This commit is contained in:
parent
385a18563c
commit
b06fbd78cc
2 changed files with 16 additions and 2 deletions
|
|
@ -17,7 +17,7 @@ from pelican.generators import (ArticlesGenerator, PagesGenerator,
|
||||||
from pelican.log import init
|
from pelican.log import init
|
||||||
from pelican.settings import read_settings
|
from pelican.settings import read_settings
|
||||||
from pelican.utils import (clean_output_dir, files_changed, file_changed,
|
from pelican.utils import (clean_output_dir, files_changed, file_changed,
|
||||||
NoFilesError)
|
file_exists, NoFilesError)
|
||||||
from pelican.writers import Writer
|
from pelican.writers import Writer
|
||||||
|
|
||||||
__major__ = 3
|
__major__ = 3
|
||||||
|
|
@ -25,6 +25,8 @@ __minor__ = 2
|
||||||
__micro__ = 0
|
__micro__ = 0
|
||||||
__version__ = "{0}.{1}.{2}".format(__major__, __minor__, __micro__)
|
__version__ = "{0}.{1}.{2}".format(__major__, __minor__, __micro__)
|
||||||
|
|
||||||
|
DEFAULT_CONFIG_NAME = 'pelicanconf.py'
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
@ -269,7 +271,11 @@ def get_config(args):
|
||||||
|
|
||||||
def get_instance(args):
|
def get_instance(args):
|
||||||
|
|
||||||
settings = read_settings(args.settings, override=get_config(args))
|
config_file = args.settings
|
||||||
|
if config_file is None and file_exists(DEFAULT_CONFIG_NAME):
|
||||||
|
config_file = DEFAULT_CONFIG_NAME
|
||||||
|
|
||||||
|
settings = read_settings(config_file, override=get_config(args))
|
||||||
|
|
||||||
cls = settings.get('PELICAN_CLASS')
|
cls = settings.get('PELICAN_CLASS')
|
||||||
if isinstance(cls, six.string_types):
|
if isinstance(cls, six.string_types):
|
||||||
|
|
|
||||||
|
|
@ -268,6 +268,14 @@ def copy(path, source, destination, destination_path=None, overwrite=False):
|
||||||
logger.warning('skipped copy %s to %s' % (source_, destination_))
|
logger.warning('skipped copy %s to %s' % (source_, destination_))
|
||||||
|
|
||||||
|
|
||||||
|
def file_exists(path):
|
||||||
|
"""Checks path exists and is a file
|
||||||
|
|
||||||
|
:param path: the path to be checked
|
||||||
|
"""
|
||||||
|
return os.path.exists(path) and os.path.isfile(path)
|
||||||
|
|
||||||
|
|
||||||
def clean_output_dir(path):
|
def clean_output_dir(path):
|
||||||
"""Remove all the files from the output directory"""
|
"""Remove all the files from the output directory"""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue