diff --git a/pelican/__init__.py b/pelican/__init__.py index a2bdefa4..a57ecb4c 100644 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -17,7 +17,7 @@ from pelican.generators import (ArticlesGenerator, PagesGenerator, from pelican.log import init from pelican.settings import read_settings from pelican.utils import (clean_output_dir, files_changed, file_changed, - NoFilesError) + file_exists, NoFilesError) from pelican.writers import Writer __major__ = 3 @@ -25,6 +25,8 @@ __minor__ = 2 __micro__ = 0 __version__ = "{0}.{1}.{2}".format(__major__, __minor__, __micro__) +DEFAULT_CONFIG_NAME = 'pelicanconf.py' + logger = logging.getLogger(__name__) @@ -269,7 +271,11 @@ def get_config(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') if isinstance(cls, six.string_types): diff --git a/pelican/utils.py b/pelican/utils.py index 3ae88402..36d2995c 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -268,6 +268,14 @@ def copy(path, source, destination, destination_path=None, overwrite=False): 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): """Remove all the files from the output directory"""