Exemple #1
0
def get_builder(project_folder):
    """Runs the builder for the given project folder."""
    config_filename = os.path.join(project_folder, "config.yml")
    config = Config()
    if not os.path.isfile(config_filename):
        raise ValueError('root config file "%s" is required' % config_filename)
    with open(config_filename) as f:
        config = config.add_from_file(f)
    return Builder(project_folder, config)
Exemple #2
0
def get_builder(project_folder):
    """Runs the builder for the given project folder."""
    config_filename = os.path.join(project_folder, 'config.yml')
    config = Config()
    if not os.path.isfile(config_filename):
        raise ValueError('root config file "%s" is required' % config_filename)
    with open(config_filename) as f:
        config = config.add_from_file(f)
    return Builder(project_folder, config)
Exemple #3
0
 def add_from_dict(self, d):
     """Returns a new config from this config with another layer added
     from a given dictionary.
     """
     layer = {}
     rv = Config()
     rv.stack = self.stack + [layer]
     def _walk(d, prefix):
         for key, value in d.iteritems():
             if isinstance(value, dict):
                 _walk(value, prefix + key + '.')
             else:
                 layer[prefix + key] = value
     _walk(d, '')
     return rv
Exemple #4
0
    def add_from_dict(self, d):
        """Returns a new config from this config with another layer added
        from a given dictionary.
        """
        layer = {}
        rv = Config()
        rv.stack = self.stack + [layer]

        def _walk(d, prefix):
            for key, value in d.iteritems():
                if isinstance(value, dict):
                    _walk(value, prefix + key + ".")
                else:
                    layer[prefix + key] = value

        _walk(d, "")
        return rv
Exemple #5
0
"""
from __future__ import with_statement
import os, sys

from rstblog.builder import Builder
from rstblog.config import Config
from rstblog.modules import add_module_path

HERE = os.path.dirname(os.path.abspath(__file__))
MODULES = os.path.join(HERE, "modules")
LIB = os.path.join(HERE, "lib")
PROJECT = os.path.join(HERE, "content")

if __name__ == "__main__":
    sys.path.insert(0, LIB)
    add_module_path(MODULES)

    main_config_filename = os.path.join(PROJECT, 'config.yml')
    config = Config()
    with open(main_config_filename) as f:
        config = config.add_from_file(f)
    if len(sys.argv) > 1:
        additional_config = os.path.join(PROJECT, 'config-%s.yml' % sys.argv[1])
        with open(additional_config) as f:
            config = config.add_from_file(f)
        # merge these into a single "root" config
        config.stack[0].update(config.stack.pop())

    builder = Builder(PROJECT, config)
    builder.run()
Exemple #6
0
from __future__ import with_statement
import os, sys

from rstblog.builder import Builder
from rstblog.config import Config
from rstblog.modules import add_module_path

HERE = os.path.dirname(os.path.abspath(__file__))
MODULES = os.path.join(HERE, "modules")
LIB = os.path.join(HERE, "lib")
PROJECT = os.path.join(HERE, "content")

if __name__ == "__main__":
    sys.path.insert(0, LIB)
    add_module_path(MODULES)

    main_config_filename = os.path.join(PROJECT, 'config.yml')
    config = Config()
    with open(main_config_filename) as f:
        config = config.add_from_file(f)
    if len(sys.argv) > 1:
        additional_config = os.path.join(PROJECT,
                                         'config-%s.yml' % sys.argv[1])
        with open(additional_config) as f:
            config = config.add_from_file(f)
        # merge these into a single "root" config
        config.stack[0].update(config.stack.pop())

    builder = Builder(PROJECT, config)
    builder.run()