Ejemplo n.º 1
0
    def run(self):
        L.d("running")
        self.stopvar = False
        rex = re.compile(".*\[(\d{7})\]$")
        imdb_db = imdb.IMDb()
        db = get_user_db()
        tp = QThreadPool.globalInstance()
        writer = IndexWriter()
        count = 0

        it = QDirIterator(self.media_path, QDirIterator.Subdirectories)
        while it.hasNext():
            dir = it.next()
            try:
                directory = unicode(dir)
                match = rex.match(directory)
                if match:
                    count += 1
                    imdb_id = match.group(1)
                    movie = db.get_doc(imdb_id)
                    if movie:
                        L.d("%s already in db - skipping" % imdb_id)
                    else:
                        j = Job(imdb_db, imdb_id, self)
                        j.obj.finished.connect(writer.index_movie,
                                               Qt.QueuedConnection)
                        tp.start(j)
            except:
                pass
        print count
        self.exec_()
Ejemplo n.º 2
0
    def run(self):
        L.d("running")
        self.stopvar = False
        rex = re.compile(".*\[(\d{7})\]$")
        imdb_db = imdb.IMDb()
        db = get_user_db()
        tp = QThreadPool.globalInstance()
        writer = IndexWriter()
        count = 0

        it = QDirIterator(self.media_path, QDirIterator.Subdirectories)
        while it.hasNext():
            dir = it.next()
            try:
                directory = unicode(dir)
                match = rex.match(directory)
                if match:
                    count += 1
                    imdb_id = match.group(1)
                    movie = db.get_doc(imdb_id)
                    if movie:
                        L.d("%s already in db - skipping" % imdb_id)
                    else:
                        j = Job(imdb_db, imdb_id, self) 
                        j.obj.finished.connect(writer.index_movie,
                                Qt.QueuedConnection)
                        tp.start(j) 
            except:
                pass
        print count
        self.exec_()
Ejemplo n.º 3
0
def pack(directory, quiet, algorithm, size):
    cprint('working directory {}'.format(directory), color='green')
    cprint('quiet {}'.format(quiet), color='green')
    cprint('algorithm {}'.format(algorithm), color='green')
    cprint('size {}'.format(size))

    folder = QDir(path=directory)
    folder.setNameFilters(['*.png'])
    folder.setFilter(QDir.Files or QDir.NoDotAndDotDot)

    dit = QDirIterator(folder, flags=QDirIterator.Subdirectories, filters=QDir.Files)

    filenames = []

    while dit.hasNext():
        im = folder.relativeFilePath(dit.next())
        if not re.search('atlas', im):
            filenames.append(im)

    images = [Image(directory, filename) for filename in filenames]

    BinPacking.bin_packing_progress = MyBinPackingProgress()

    bin_packer = FirstFitShelfBinPacking(Size(2048, 2048), images, bin_parameters={})
    bin_packer.saveAtlases(directory)

    print ''
Ejemplo n.º 4
0
    def load_icons(self):
        for format in QImageReader.supportedImageFormats():
            self.supported_image_formats.add('.' + str(format))

        it = QDirIterator(":", QDirIterator.Subdirectories)
        while it.hasNext():
            path = it.next()
            fn, ext = os.path.splitext(path)
            if ext in self.supported_image_formats:
                image = QImage(path)
                self.icons.append(image)
                self.paths.append(path)
 def harvestDirectory(self, directory):
     folder = QDir(path=directory)
     folder.setNameFilters(["*.png"])
     folder.setFilter(QDir.Files or QDir.NoDotAndDotDot)
     dit = QDirIterator(folder, flags=QDirIterator.Subdirectories, filters=QDir.Files)
     while dit.hasNext():
         im = folder.relativeFilePath(dit.next())
         if not re.search("atlas", im):
             self.images.append(im)
     self.bin_packing_thread.setDirectory(self.directory)
     self.bin_packing_thread.setImages(self.images)
     self.updateImages(self.images)
Ejemplo n.º 6
0
    def open_folder(self):
        self.imagesList.clear()
        if not self.current_directory:
            self.current_directory = QFileDialog.getExistingDirectory(parent=self,
                                                                      caption=u'Add images from directory')

        folder = QDir(self.current_directory)
        folder.setNameFilters(['*.png'])
        folder.setFilter(QDir.Files or QDir.NoDotAndDotDot)

        dir_iterator = QDirIterator(folder, flags=QDirIterator.Subdirectories, filters=QDir.Files)

        images = []

        while dir_iterator.hasNext():
            images.append(folder.relativeFilePath(dir_iterator.next()))

        self.white_albatross.addImages(folder, images)
        self.imagesList.addItems(images)
Ejemplo n.º 7
0
    def open_folder(self):
        self.imagesList.clear()
        if not self.current_directory:
            self.current_directory = QFileDialog.getExistingDirectory(
                parent=self, caption=u'Add images from directory')

        folder = QDir(self.current_directory)
        folder.setNameFilters(['*.png'])
        folder.setFilter(QDir.Files or QDir.NoDotAndDotDot)

        dir_iterator = QDirIterator(folder,
                                    flags=QDirIterator.Subdirectories,
                                    filters=QDir.Files)

        images = []

        while dir_iterator.hasNext():
            images.append(folder.relativeFilePath(dir_iterator.next()))

        self.white_albatross.addImages(folder, images)
        self.imagesList.addItems(images)