How to use the prospector.profiles.profile.ProfileNotFound function in prospector

To help you get started, we’ve selected a few prospector examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PyCQA / prospector / prospector / config / __init__.py View on Github external
prospector_dir = os.path.join(path, '.prospector')
        if os.path.exists(prospector_dir) and os.path.isdir(prospector_dir):
            profile_path.append(prospector_dir)

        profile_path.append(path)
        profile_path.append(BUILTIN_PROFILE_PATH)

        try:
            forced_inherits = cmdline_implicit + extra_profiles
            profile = ProspectorProfile.load(profile_name, profile_path, forced_inherits=forced_inherits)
        except CannotParseProfile as cpe:
            sys.stderr.write("Failed to run:\nCould not parse profile %s as it is not valid YAML\n%s\n" %
                             (cpe.filepath, cpe.get_parse_message()))
            sys.exit(1)
        except ProfileNotFound as nfe:
            sys.stderr.write("Failed to run:\nCould not find profile %s. Search path: %s\n" %
                             (nfe.name, ':'.join(nfe.profile_path)))
            sys.exit(1)
        else:
            return profile, strictness
github PyCQA / prospector / prospector / profiles / profile.py View on Github external
def _load_content(name_or_path, profile_path):
    filename = None

    if _is_valid_extension(name_or_path):
        for path in profile_path:
            filepath = os.path.join(path, name_or_path)
            if os.path.exists(filepath):
                # this is a full path that we can load
                filename = filepath
                break

        if filename is None:
            raise ProfileNotFound(name_or_path, profile_path)
    else:
        for path in profile_path:
            for ext in ('yml', 'yaml'):
                filepath = os.path.join(path, '%s.%s' % (name_or_path, ext))
                if os.path.exists(filepath):
                    filename = filepath
                    break

        if filename is None:
            raise ProfileNotFound(name_or_path, profile_path)

    with open(filename) as fct:
        try:
            return yaml.safe_load(fct) or {}
        except yaml.parser.ParserError as parse_error:
            raise CannotParseProfile(filename, parse_error)
github PyCQA / prospector / prospector / profiles / profile.py View on Github external
# this is a full path that we can load
                filename = filepath
                break

        if filename is None:
            raise ProfileNotFound(name_or_path, profile_path)
    else:
        for path in profile_path:
            for ext in ('yml', 'yaml'):
                filepath = os.path.join(path, '%s.%s' % (name_or_path, ext))
                if os.path.exists(filepath):
                    filename = filepath
                    break

        if filename is None:
            raise ProfileNotFound(name_or_path, profile_path)

    with open(filename) as fct:
        try:
            return yaml.safe_load(fct) or {}
        except yaml.parser.ParserError as parse_error:
            raise CannotParseProfile(filename, parse_error)
github PyCQA / prospector / prospector / profiles / profile.py View on Github external
def __init__(self, name, profile_path):
        super(ProfileNotFound, self).__init__()
        self.name = name
        self.profile_path = profile_path