Пример #1
0
def parse_yaml(filepath, loaded_from=__file__):

    abspath = os.path.abspath(os.path.dirname(loaded_from))
    path = "/".join([abspath, filepath])
    try:
        yaml_data = yaml.load(open(path, 'r', 'utf-8'))
    except IOError, e:
        log("No yaml file found: %s" % e)
        raise IOError
Пример #2
0
def create_element_pattern(mode, markup):
    """Create the basic element pattern based on mode and markup.
    :param markup:
    :param mode:
    """

    try:
        markup = markup[mode]

        if mode == 'tag':
            pattern = create_bs4tag(markup)

        elif mode == 'highlight':
            pattern = create_highlight(markup)

        else:
            raise NotImplementedError

    except KeyError, e:
        log("KeyError: %s" % e)
        raise KeyError
Пример #3
0
import yaml
from codecs import open
from anchorman.logger import log


def parse_yaml(filepath, loaded_from=__file__):

    abspath = os.path.abspath(os.path.dirname(loaded_from))
    path = "/".join([abspath, filepath])
    try:
        yaml_data = yaml.load(open(path, 'r', 'utf-8'))
    except IOError, e:
        log("No yaml file found: %s" % e)
        raise IOError
    except yaml.YAMLError, e:
        log("Error in configuration file: %s" % e)
        raise yaml.YAMLError
    return yaml_data


def get_config(include_project_config=True):
    """Load default configuration.
    :param include_project_config:
    """

    default = parse_yaml("../etc/description.yaml")

    if include_project_config:
        conf = parse_yaml("../etc/config.yaml")
        default.update(conf)