Esempio n. 1
0
    def __addPhoto(self, nodeDir, file, tags, filesInBasket):
        assert type(file) == str

        newNode = Element("photo")
        nodeDir.append(newNode)

        node = PhotoNode(newNode)

        try:
            iii = PhotoCmd(
                file,
                needAutoRename=DbPhotos.normalizeName,
                needAutoRotation=DbPhotos.autorotAtImport,
            )
            if iii.exifdate == "":
                # exif is not present, and photocmd can't reach
                # to recreate minimal exif tags (because it's readonly ?)
                # we can't continue to import this photo
                raise Exception(
                    "Exif couldn't be set in this picture (readonly?)")
        except Exception as m:
            # remove the bad node
            nodeDir.remove(newNode)

            return m
        else:
            importedTags = node.updateInfo(iii)
            for i in importedTags:
                tags[i] = i  # feed the dict of tags

            return None
Esempio n. 2
0
    def __addPhoto(self, nodeDir, file, tags, filesInBasket):
        assert type(file) == str

        newNode = Element("photo")
        nodeDir.append(newNode)

        node = PhotoNode(newNode)

        try:
            iii = PhotoCmd(file,
                           needAutoRename=DbPhotos.normalizeName,
                           needAutoRotation=DbPhotos.autorotAtImport,
                           )
            if iii.exifdate == "":
                # exif is not present, and photocmd can't reach
                # to recreate minimal exif tags (because it's readonly ?)
                # we can't continue to import this photo
                raise Exception(
                    "Exif couldn't be set in this picture (readonly?)")
        except Exception as m:
            # remove the bad node
            nodeDir.remove(newNode)

            return m
        else:
            importedTags = node.updateInfo(iii)
            for i in importedTags:
                tags[i] = i  # feed the dict of tags

            return None
Esempio n. 3
0
 def redoIPTC(self):
     """ refresh IPTC in file and db """
     ln = self.root.xpath(u"""//photo[t]""")
     for i in ln:
         p = PhotoNode(i)
         print(p.name)
         pc = PhotoCmd(p.file)
         pc.__maj()  # rewrite iptc in file
         p.updateInfo(pc)  # rewrite iptc in db.xml
Esempio n. 4
0
 def redoIPTC(self):
     """ refresh IPTC in file and db """
     ln = self.root.xpath(u"""//photo[t]""")
     for i in ln:
         p = PhotoNode(i)
         print(p.name)
         pc = PhotoCmd(p.file)
         pc.__maj()              # rewrite iptc in file
         p.updateInfo(pc)      # rewrite iptc in db.xml
Esempio n. 5
0
    def getPhotosByPath(self, path):
        path = os.path.normpath(path)

        node = self.root.xpath('//folder[@name="%s"]' % (path, ))
        photos = node[0].xpath('photo')
        photoNodes = [PhotoNode(p) for p in photos]
        return photoNodes
Esempio n. 6
0
 def select(self, xpath, fromNode=None):
     ln = self.root.xpath(xpath)
     if ln:
         return [PhotoNode(i) for i in ln]
     else:
         return []