Beispiel #1
0
    def is_whitelisted(fpath, project_path, matchlist):
        """
        Check whether an individual file is whitelisted or blacklisted.
        """

        project_path = os.path.abspath(project_path)

        path = fpath

        # Walk each part of the path from top to project root and see
        # that each path part is on the whitelist
        while path and path != "/":

            # Get project root relative presentation of the file
            abspath = os.path.abspath(os.path.join(project_path, path))
            relative = os.path.relpath(abspath, project_path)

            if relative == ".":
                # Reached project_path root
                return True

            if not utils.match_file(relative, matchlist):
                return False

            # Unused var
            # pylint: disable=W0612 

            # http://docs.python.org/library/os.path.html#os.path.split
            path, tail = os.path.split(path)

        return True
Beispiel #2
0
    def is_whitelisted(fpath, project_path, matchlist):
        """
        Check whether an individual file is whitelisted or blacklisted.
        """

        project_path = os.path.abspath(project_path)

        path = fpath

        # Walk each part of the path from top to project root and see
        # that each path part is on the whitelist
        while path and path != "/":

            # Get project root relative presentation of the file
            abspath = os.path.abspath(os.path.join(project_path, path))
            relative = os.path.relpath(abspath, project_path)

            if relative == ".":
                # Reached project_path root
                return True

            if not utils.match_file(relative, matchlist):
                return False

            # Unused var
            # pylint: disable=W0612

            # http://docs.python.org/library/os.path.html#os.path.split
            path, tail = os.path.split(path)

        return True
Beispiel #3
0
        def recurse(path):
            """
            Handle each folder 
            """
            for name in os.listdir(path):

                fpath = os.path.abspath(os.path.join(path, name))

                relative = os.path.relpath(fpath, project_path)

                if relative.startswith("./"):
                    relative = relative[2:]

                self.logger.debug("Scanning %s" % (relative))

                if not utils.match_file(relative, matchlist):
                    if self.debug:
                        self.logger.info("Ignoring %s by global match list",
                                         relative)
                    continue

                if os.path.isdir(fpath):
                    recurse(fpath)
                else:
                    files.append(relative)
Beispiel #4
0
        def recurse(path):
            """
            Handle each folder 
            """
            for name in os.listdir(path):
                
                fpath = os.path.abspath(os.path.join(path, name))

                relative = os.path.relpath(fpath, project_path)

                if relative.startswith("./"):
                    relative = relative[2:]

                self.logger.debug("Scanning %s" % (relative))

                if not utils.match_file(relative, matchlist):
                    if self.debug:
                        self.logger.info("Ignoring %s by global match list", relative)
                    continue
                
                if os.path.isdir(fpath):
                    recurse(fpath)                
                else:
                    files.append(relative)