Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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 updateImageRegistries(self):
        self.imageRegistry = []
        self.hiResRegistry = []
        self.imageEntryList = self.imageDir.entryList(['??????????'], QDir.Dirs)
        for i in self.imageEntryList:
            if self.killed is True:
                # kill request received, exit loop early
                break
            iDir = QDir(self.imageDir.path() + '\\' + i)
            #FIXME implement solution for not just jpg but values from ini
            iEntryList = iDir.entryList([i + '_???.jpg'], QDir.Files)
            self.imageRegistry = self.imageRegistry + iEntryList

            hiResEntryList = iDir.entryList(["highres*", "mrsid", "raw"], QDir.Dirs)
            hiResFilters = [i + '_???.' + ext for ext in self.hiResFormats]
            for hr in hiResEntryList:
                if self.killed is True:
                    # kill request received, exit loop early
                    break
                hrDir = QDir(iDir.path() + '\\' + hr)
                hrEntryList = hrDir.entryList(hiResFilters, QDir.Files)
                self.hiResRegistry = self.hiResRegistry + hrEntryList

        if self.killed is False:
            self.imageRegistryNE = [img[:14].replace('_','.') for img in self.imageRegistry]
            self.hiResRegistryNE = [img[:14].replace('_','.') for img in self.hiResRegistry]
Ejemplo n.º 4
0
def readFile(path, default=None, encoding=None):
	if not os.path.supports_unicode_filenames:
		path = path.encode("utf-8")
	if QFile.exists(path):
		f = QFile(path,parent)
		if f.open(QIODevice.ReadOnly):
			data=f.readAll().__str__()
		else:
			raise ErrorRead(u'Couldn\'t open file %s with code error %d'%path,f.error())
		f.close()
		if encoding:
			data = data.decode(encoding)
		return data
	else:
		dir = QDir(os.path.dirname(path))
		if not dir.exists():
			if not dir.mkpath(dir.path()):
				raise ErrorCreatePath(u'impossible to create a path!')
		writeFile(path, default)
		return default