Example #1
0
def mock_lint(env, manifest, cmakelist, checks=all, full_result=False, indentation=False):
    linter = CMakeLinter(env)
    if type(cmakelist) is dict:
        tmp = {}
        for key, value in iteritems(cmakelist):
            tmp[os.path.normpath(key)] = value
        cmakelist = tmp
    def get_cmakelist(filename):
        if type(cmakelist) is dict:
            if filename in cmakelist:
                 return cmakelist[filename]
            else:
                return ""
        else:
            if filename == os.path.normpath("/mock-path/CMakeLists.txt"): return cmakelist
            return ""
    linter._read_file = get_cmakelist
    if checks is not None: linter.require(checks)
    linter.lint (os.path.normpath("/mock-path"), manifest)
    if not indentation:
        linter.messages = [ m for m in linter.messages if m.id != "INDENTATION" ]
    if full_result:
        return linter.messages
    else:
        return [ m.id for m in linter.messages ]
Example #2
0
def mock_lint(env, manifest, cmakelist, checks=all, indentation=False, return_var=False):
    linter = CMakeLinter(env)
    if type(cmakelist) is dict:
        tmp = {}
        for key, value in iteritems(cmakelist):
            tmp[os.path.normpath(key)] = value
        cmakelist = tmp
    def get_cmakelist(filename):
        if type(cmakelist) is dict:
            if filename in cmakelist:
                 return cmakelist[filename]
            else:
                return ""
        else:
            if filename == os.path.normpath("/mock-path/CMakeLists.txt"): return cmakelist
            return ""
    linter._read_file = get_cmakelist
    if checks is not None: linter.require(checks)
    info = LintInfo(env)
    linter.lint (os.path.normpath("/mock-path"), manifest, info)
    if not indentation:
        linter.messages = [ m for m in linter.messages if m.id != "INDENTATION" ]
    if return_var:
        return info.var
    else:
        return [ m.id for m in linter.messages ]
Example #3
0
def mock_lint(env, manifest, cmakelist, checks=all, indentation=False, return_var=False, package_path=None):
    linter = CMakeLinter(env)
    if package_path is None:
        package_path = "/package-path/%s" % manifest.name
    if type(cmakelist) is dict:
        tmp = {}
        for key, value in iteritems(cmakelist):
            tmp[os.path.normpath(key)] = value
        cmakelist = tmp
    def get_cmakelist(filename):
        if type(cmakelist) is dict:
            if filename in cmakelist:
                 return cmakelist[filename]
            else:
                raise OSError("Mock CMake file not found: %s" % filename)
        else:
            if filename == os.path.normpath(package_path + "/CMakeLists.txt"): return cmakelist
            raise OSError("Mock CMake file not found: %s" % filename)
    linter._read_file = get_cmakelist
    if checks is not None: linter.require(checks)
    info = LintInfo(env)
    linter.lint (os.path.normpath(package_path), manifest, info)
    if not indentation:
        linter.messages = [ m for m in linter.messages if m.id != "INDENTATION" ]
    if return_var:
        return info.var
    else:
        return [ m.id for m in linter.messages ]
Example #4
0
def mock_lint(env,
              manifest,
              cmakelist,
              checks=all_checks,
              indentation=False,
              return_var=False,
              package_path=None):
    linter = CMakeLinter(env)
    if package_path is None:
        package_path = "/package-path/%s" % manifest.name
    if type(cmakelist) is dict:
        tmp = {}
        for key, value in iteritems(cmakelist):
            tmp[os.path.normpath(key)] = value
        cmakelist = tmp

    def get_cmakelist(filename):
        if type(cmakelist) is dict:
            if filename in cmakelist:
                return cmakelist[filename]
            else:
                raise OSError("Mock CMake file not found: %s" % filename)
        else:
            assert filename == os.path.normpath(package_path +
                                                "/CMakeLists.txt")
            return cmakelist

    linter._read_file = get_cmakelist
    if checks is not None:
        linter.require(checks)
    info = LintInfo(env)
    linter.lint(os.path.normpath(package_path), manifest, info=info)
    if not indentation:
        linter.messages = [m for m in linter.messages if m.id != "INDENTATION"]
    if return_var:
        return info.var
    else:
        return [m.id for m in linter.messages]