Ejemplo n.º 1
0
def mqc_load_config(yaml_config):
    """ Load and parse a config file if we find it """
    if os.path.isfile(yaml_config):
        try:
            with open(yaml_config) as f:
                new_config = yaml.load(f)
                logger.debug("Loading config settings from: {}".format(yaml_config))
                for c, v in new_config.items():
                    if c == 'sp':
                        # Merge filename patterns instead of replacing
                        sp.update(v)
                        logger.debug("Added to filename patterns: {}".format(sp))
                    elif c == 'extra_fn_clean_exts':
                        # Prepend to filename cleaning patterns instead of replacing
                        fn_clean_exts[0:0] = v
                        logger.debug("Added to filename clean extensions. Now looking for: {}".format(fn_clean_exts))
                    else:
                        logger.debug("New config '{}': {}".format(c, v))
                        globals()[c] = v
        except (IOError, AttributeError) as e:
            logger.debug("Config error: {}".format(e))
        except yaml.scanner.ScannerError as e:
            logger.error("Error parsing config YAML: {}".format(e))
            sys.exit(1)
    else:
        logger.debug("No MultiQC config found: {}".format(yaml_config))
Ejemplo n.º 2
0
def mqc_load_config(yaml_config):
    """ Load and parse a config file if we find it """
    if os.path.isfile(yaml_config):
        try:
            with open(yaml_config) as f:
                new_config = yaml.load(f)
                logger.debug(
                    "Loading config settings from: {}".format(yaml_config))
                for c, v in new_config.items():
                    if c == 'sp':
                        # Merge filename patterns instead of replacing
                        sp.update(v)
                        logger.debug(
                            "Added to filename patterns: {}".format(sp))
                    elif c == 'extra_fn_clean_exts':
                        # Prepend to filename cleaning patterns instead of replacing
                        fn_clean_exts[0:0] = v
                        logger.debug(
                            "Added to filename clean extensions. Now looking for: {}"
                            .format(fn_clean_exts))
                    else:
                        logger.debug("New config '{}': {}".format(c, v))
                        globals()[c] = v
        except (IOError, AttributeError) as e:
            logger.debug("Config error: {}".format(e))
        except yaml.scanner.ScannerError as e:
            logger.error("Error parsing config YAML: {}".format(e))
            sys.exit(1)
    else:
        logger.debug("No MultiQC config found: {}".format(yaml_config))