Ejemplo n.º 1
0
    def rescan_files(self, handler=None):
        """
            :type handler: FileDfsHandler or None
        """
        dir_stack = []
        if handler:
            handler.project = self
            handler.setup()

        project_root = self.abs_path
        for r, d, files in os.walk(project_root):
            dir_path = self.build_relative_path(r)
            ignored = False
            for ignored_dir in self.ignored_dirs:
                if dir_path.startswith(ignored_dir):
                    ignored = True
                    break
            if ignored:
                continue
            if handler:
                while dir_stack and not dir_path.startswith(dir_stack[-1]):
                    handler.exit_dir(dir_stack.pop())
                dir_stack.append(dir_path)
                handler.enter_dir(dir_path)
            for f in files:
                path = self.build_relative_path(os.path.join(r, f))
                self.file_extensions.add(get_extension(path))
                self._files[path] = None
                if handler:
                    handler.handle_file(path)

        if handler:
            while dir_stack:
                handler.exit_dir(dir_stack.pop())
            handler.tear_down()
Ejemplo n.º 2
0
    def rescan_files(self, handler=None):
        """
            :type handler: FileDfsHandler or None
        """
        dir_stack = []
        if handler:
            handler.project = self
            handler.setup()

        project_root = self.abs_path
        for r, d, files in os.walk(project_root):
            dir_path = self.build_relative_path(r)
            ignored = False
            for ignored_dir in self.ignored_dirs:
                if dir_path.startswith(ignored_dir):
                    ignored = True
                    break
            if ignored:
                continue
            if handler:
                while dir_stack and not dir_path.startswith(dir_stack[-1]):
                    handler.exit_dir(dir_stack.pop())
                dir_stack.append(dir_path)
                handler.enter_dir(dir_path)
            for f in files:
                path = self.build_relative_path(os.path.join(r, f))
                self.file_extensions.add(get_extension(path))
                self._files[path] = None
                if handler:
                    handler.handle_file(path)

        if handler:
            while dir_stack:
                handler.exit_dir(dir_stack.pop())
            handler.tear_down()
Ejemplo n.º 3
0
    def filter_files(self, cond=None, extension=None):
        """ Return filenames of files in this project that satisfy the condition function

            :param str or None extension: the file extensions to filter, e.g. 'java' or 'java,xml'
        """
        if cond is not None:
            return (f for f in self._files.iterkeys() if cond(f))

        if extension is not None:
            return self.filter_files(cond=lambda f: get_extension(f) in [e.strip() for e in extension.split(',')])
Ejemplo n.º 4
0
    def filter_files(self, cond=None, extension=None):
        """ Return filenames of files in this project that satisfy the condition function

            :param str or None extension: the file extensions to filter, e.g. 'java' or 'java,xml'
        """
        if cond is not None:
            return (f for f in self._files.iterkeys() if cond(f))

        if extension is not None:
            return self.filter_files(cond=lambda f: get_extension(f) in [e.strip() for e in extension.split(",")])