def __locate_code_in_project(self, queue_folders, nproject): file_filter = QDir.Files | QDir.NoDotAndDotDot | QDir.Readable dir_filter = QDir.Dirs | QDir.NoDotAndDotDot | QDir.Readable while not self._cancel and not queue_folders.empty(): current_dir = QDir(queue_folders.get()) #Skip not readable dirs! if not current_dir.isReadable(): continue #Collect all sub dirs! current_sub_dirs = current_dir.entryInfoList(dir_filter) for one_dir in current_sub_dirs: queue_folders.put(one_dir.absoluteFilePath()) #all files in sub_dir first apply the filters current_files = current_dir.entryInfoList( ['*{0}'.format(x) for x in nproject.extensions], file_filter) #process all files in current dir! for one_file in current_files: try: self._grep_file_locate(one_file.absoluteFilePath(), one_file.fileName()) except Exception as reason: logger.error('__locate_code_in_project, error: %r' % reason) logger.error('__locate_code_in_project fail for file: %r' % one_file.absoluteFilePath())
def __locate_code_in_project(self, queue_folders, nproject): file_filter = QDir.Files | QDir.NoDotAndDotDot | QDir.Readable dir_filter = QDir.Dirs | QDir.NoDotAndDotDot | QDir.Readable while not self._cancel and not queue_folders.empty(): current_dir = QDir(queue_folders.get()) #Skip not readable dirs! if not current_dir.isReadable(): continue #Collect all sub dirs! current_sub_dirs = current_dir.entryInfoList(dir_filter) for one_dir in current_sub_dirs: queue_folders.put(one_dir.absoluteFilePath()) #all files in sub_dir first apply the filters current_files = current_dir.entryInfoList( ['*{0}'.format(x) for x in nproject.extensions], file_filter) #process all files in current dir! global files_paths for one_file in current_files: try: self._grep_file_symbols(one_file.absoluteFilePath(), one_file.fileName()) files_paths[nproject.path].append( one_file.absoluteFilePath()) except Exception as reason: logger.error( '__locate_code_in_project, error: %r' % reason) logger.error( '__locate_code_in_project fail for file: %r' % one_file.absoluteFilePath())
def locate_code(self): explorerContainer = explorer_container.ExplorerContainer() projects_obj = explorerContainer.get_opened_projects() projects = [p.path for p in projects_obj] if not projects: return queue = Queue.Queue() for project in projects: queue.put(project) while not self._cancel and not queue.empty(): current_dir = QDir(queue.get()) #Skip not readable dirs! if not current_dir.isReadable(): continue project_data = project = json_manager.read_ninja_project( unicode(current_dir.path())) extensions = project_data.get('supported-extensions', settings.SUPPORTED_EXTENSIONS) queue_folders = Queue.Queue() queue_folders.put(current_dir) self.__locate_code_in_project(queue_folders, extensions) self.dirty = True self.get_locations()
def locate_code(self): explorerContainer = explorer_container.ExplorerContainer() projects_obj = explorerContainer.get_opened_projects() projects = [p.path for p in projects_obj] if not projects: return queue = Queue.Queue() for project in projects: queue.put(project) while not self._cancel and not queue.empty(): current_dir = QDir(queue.get()) #Skip not readable dirs! if not current_dir.isReadable(): continue project_data = project = json_manager.read_ninja_project( current_dir.path()) extensions = project_data.get('supported-extensions', settings.SUPPORTED_EXTENSIONS) queue_folders = Queue.Queue() queue_folders.put(current_dir) self.__locate_code_in_project(queue_folders, extensions) self.dirty = True self.get_locations()
def locate_code(self): explorerContainer = explorer_container.ExplorerContainer() projects_obj = explorerContainer.get_opened_projects() projects = [p.path for p in projects_obj] if not projects: return queue = Queue.Queue() for project in projects: queue.put(project) file_filter = QDir.Files | QDir.NoDotAndDotDot | QDir.Readable dir_filter = QDir.Dirs | QDir.NoDotAndDotDot | QDir.Readable while not self._cancel and not queue.empty(): current_dir = QDir(queue.get()) #Skip not readable dirs! if not current_dir.isReadable(): continue #Collect all sub dirs! current_sub_dirs = current_dir.entryInfoList(dir_filter) for one_dir in current_sub_dirs: queue.put(one_dir.absoluteFilePath()) current_sub_dirs = current_dir.entryInfoList(dir_filter) #all files in sub_dir first apply the filters current_files = current_dir.entryInfoList( ['*{0}'.format(x) for x in settings.SUPPORTED_EXTENSIONS], file_filter) #process all files in current dir! for one_file in current_files: self._grep_file_locate(unicode(one_file.absoluteFilePath()), one_file.fileName()) self.dirty = True self.get_locations()
def locate_code(self): ide = IDE.get_service('ide') projects = ide.get_opened_projects() if not projects: return for path in projects: if self._cancel: break nproject = projects[path] current_dir = QDir(nproject.path) #Skip not readable dirs! if not current_dir.isReadable(): continue queue_folders = Queue.Queue() queue_folders.put(current_dir) self.__locate_code_in_project(queue_folders, nproject) self.dirty = True self.get_locations()
def locate_code(self): self._locator_db = sqlite3.connect(db_path) ide = IDE.get_service('ide') projects = ide.filesystem.get_projects() if not projects: return projects = list(projects.values()) for nproject in projects: if self._cancel: break current_dir = QDir(nproject.path) #Skip not readable dirs! if not current_dir.isReadable(): continue queue_folders = Queue.Queue() queue_folders.put(current_dir) self.__locate_code_in_project(queue_folders, nproject) self.dirty = True self.get_locations()
def run(self): file_filter = QDir.Files | QDir.NoDotAndDotDot | QDir.Readable dir_filter = QDir.Dirs | QDir.NoDotAndDotDot | QDir.Readable while not self._cancel and not self.queue.empty(): current_dir = QDir(self.queue.get()) #Skip not readable dirs! if not current_dir.isReadable(): continue #Collect all sub dirs! if self.recursive: current_sub_dirs = current_dir.entryInfoList(dir_filter) for one_dir in current_sub_dirs: self.queue.put(one_dir.absoluteFilePath()) #all files in sub_dir first apply the filters current_files = current_dir.entryInfoList( self.filters, file_filter) #process all files in current dir! for one_file in current_files: self._grep_file(one_file.absoluteFilePath(), one_file.fileName())
def run(self): file_filter = QDir.Files | QDir.NoDotAndDotDot | QDir.Readable dir_filter = QDir.Dirs | QDir.NoDotAndDotDot | QDir.Readable while not self._cancel and not self.queue.empty(): current_dir = QDir(self.queue.get()) #Skip not readable dirs! if not current_dir.isReadable(): continue #Collect all sub dirs! if self.recursive: current_sub_dirs = current_dir.entryInfoList(dir_filter) for one_dir in current_sub_dirs: self.queue.put(one_dir.absoluteFilePath()) #all files in sub_dir first apply the filters current_files = current_dir.entryInfoList(self.filters, file_filter) #process all files in current dir! for one_file in current_files: self._grep_file(one_file.absoluteFilePath(), one_file.fileName())
def __locate_code_in_project(self, queue_folders, extensions): file_filter = QDir.Files | QDir.NoDotAndDotDot | QDir.Readable dir_filter = QDir.Dirs | QDir.NoDotAndDotDot | QDir.Readable while not self._cancel and not queue_folders.empty(): current_dir = QDir(queue_folders.get()) #Skip not readable dirs! if not current_dir.isReadable(): continue #Collect all sub dirs! current_sub_dirs = current_dir.entryInfoList(dir_filter) for one_dir in current_sub_dirs: queue_folders.put(one_dir.absoluteFilePath()) #all files in sub_dir first apply the filters current_files = current_dir.entryInfoList( ['*{0}'.format(x) for x in extensions], file_filter) #process all files in current dir! for one_file in current_files: self._grep_file_locate(unicode(one_file.absoluteFilePath()), one_file.fileName())
def navigate_code(self): explorerContainer = explorer_container.ExplorerContainer() projects_obj = explorerContainer.get_opened_projects() projects = [p.path for p in projects_obj] project = None for p in projects: if self._filePath.startswith(p): project = p break #Search in files if not project: fileName = file_manager.get_basename(self._filePath) self._grep_file(self._filePath, fileName) return queue = Queue.Queue() queue.put(project) file_filter = QDir.Files | QDir.NoDotAndDotDot | QDir.Readable dir_filter = QDir.Dirs | QDir.NoDotAndDotDot | QDir.Readable while not self._cancel and not queue.empty(): current_dir = QDir(queue.get()) #Skip not readable dirs! if not current_dir.isReadable(): continue #Collect all sub dirs! current_sub_dirs = current_dir.entryInfoList(dir_filter) for one_dir in current_sub_dirs: queue.put(one_dir.absoluteFilePath()) current_sub_dirs = current_dir.entryInfoList(dir_filter) #all files in sub_dir first apply the filters current_files = current_dir.entryInfoList( ['*.py'], file_filter) #process all files in current dir! for one_file in current_files: if one_file.fileName() != '__init__.py': self._grep_file(one_file.absoluteFilePath(), one_file.fileName())
def navigate_code(self): explorerContainer = explorer_container.ExplorerContainer() projects_obj = explorerContainer.get_opened_projects() projects = [p.path for p in projects_obj] project = None for p in projects: if self._filePath.startswith(p): project = p break #Search in files if not project: fileName = file_manager.get_basename(self._filePath) self._grep_file(self._filePath, fileName) return queue = Queue.Queue() queue.put(project) file_filter = QDir.Files | QDir.NoDotAndDotDot | QDir.Readable dir_filter = QDir.Dirs | QDir.NoDotAndDotDot | QDir.Readable while not self._cancel and not queue.empty(): current_dir = QDir(queue.get()) #Skip not readable dirs! if not current_dir.isReadable(): continue #Collect all sub dirs! current_sub_dirs = current_dir.entryInfoList(dir_filter) for one_dir in current_sub_dirs: queue.put(one_dir.absoluteFilePath()) current_sub_dirs = current_dir.entryInfoList(dir_filter) #all files in sub_dir first apply the filters current_files = current_dir.entryInfoList(['*.py'], file_filter) #process all files in current dir! for one_file in current_files: if one_file.fileName() != '__init__.py': self._grep_file(one_file.absoluteFilePath(), one_file.fileName())