Ejemplo n.º 1
0
"""codecache holds the CodeCache and CppFile classes, and the YAML object."""

import os
from collections import deque, defaultdict
from ruamel.yaml import YAML
from clonedcodechecker.matcher import Matcher

YA_ML = YAML(typ="safe")
YA_ML.default_style = False


def cache_filename(path):
    """Turn absolute path into filename used in filecache."""
    return path.replace("/", ".")[1:] + ".yaml"


class CodeCache:
    """The CodeCache holds CppFiles, the Matcher, and controls filecache.

    Slots:
    search_set: Absolute paths of all files to search. Comes from codechecker
    filecache: Directory of the filecache. It's always in ~/.filecache
    matcher: The CodeCache owns an instance of the Matcher class
    output_dir: Set externally (in codechecker) on program launch
    """

    __slots__ = [
        "search_set", "filecache", "filelist", "matcher", "output_dir"
    ]

    def __init__(self, filecache="./.filecache/"):
Ejemplo n.º 2
0
from __future__ import print_function, absolute_import, unicode_literals, division

__version__ = '3.0.3'

#from ruamel.yaml import MarkedYAMLError, safe_load, safe_load_all, safe_dump
from ruamel.yaml import YAML, MarkedYAMLError
yaml = YAML()
yaml.default_style = '"'
import sys

import glob
import os
import logging
import six


class NoDefault(object):
    def __str__(self):
        return "No default data"


NO_DEFAULT = NoDefault()


class YamlReaderError(Exception):
    pass


def data_merge(a, b):
    """merges b into a and return merged result
    based on http://stackoverflow.com/questions/7204805/python-dictionaries-of-dictionaries-merge
def run(*, src: str) -> None:
    yaml = YAML(typ="rt")
    yaml.default_style = "'"
    with open(src) as rf:
        data = yaml.load(rf)
    yaml.dump(data, sys.stdout)