def createSubFolder(self,nodeFolder): l=nodeFolder.getPhotos() fold={} for image in l: newFolderName = os.path.join(image.folder,cd2d(image.date).strftime(str(_("Day_%Y%m%d")))) # fill a temp dict to store foldernode if newFolderName not in fold: fold[newFolderName] = nodeFolder.createNewFolder(unicode(newFolderName)) newFolderNode = fold[newFolderName] if newFolderNode: image.moveToFolder(newFolderNode) else: print "can't move",image,"to",newFolderName return True
def createSubFolder(self, nodeFolder): l = nodeFolder.getPhotos() fold = {} for image in l: newFolderName = os.path.join( image.folder, cd2d(image.date).strftime(str(_("Day_%Y%m%d")))) # fill a temp dict to store foldernode if newFolderName not in fold: fold[newFolderName] = nodeFolder.createNewFolder( unicode(newFolderName)) newFolderNode = fold[newFolderName] if newFolderNode: image.moveToFolder(newFolderNode) else: print "can't move", image, "to", newFolderName return True
def redate(self, list): from redate import Winredate Winredate.defaultDate = cd2d(list[0].date) win = Winredate() ret = win.loop()[0] if ret: method, value = ret if method == 'relative': vw, vd, vh, vi, vs = value try: for i in list: self.showProgress(list.index(i), len(list), _("Redating")) if method == 'relative': i.redate(vw, vd, vh, vi, vs) else: i.setDate(value) finally: self.showProgress() return True else: return False
def nd(d): delta = timedelta(weeks=1, days=1, hours=1, minutes=1, seconds=1) return (cd2d(d) + delta).strftime("%Y%m%d%H%M%S")
#================================================================== # test NormalizeName, format, and renaming according dates # without modification of attributes #================================================================== PhotoCmd.setNormalizeNameFormat(format) for f in l: p = PhotoCmd(f, needAutoRename=True) attrsBefore = la(p) if p.exifdate: d = p.exifdate else: # if not exif date date file is taken d = p.filedate newNameShouldBe = cd2d(d).strftime(format) assert newNameShouldBe in p.file attrsAfter = la(p) assert _compare_(attrsAfter, attrsBefore) #================================================================== # test autorotation, # without modification of attributes #================================================================== l = [ os.path.join(folder, i).decode(sys.getfilesystemencoding()) for i in os.listdir(folder) if i.lower().endswith(".jpg") ] for f in l: p = PhotoCmd(f, needAutoRotation=True)
#================================================================== # test NormalizeName, format, and renaming according dates # without modification of attributes #================================================================== PhotoCmd.setNormalizeNameFormat(format) for f in l: p = PhotoCmd(f, needAutoRename=True) attrsBefore = la(p) if p.exifdate: d = p.exifdate else: # if not exif date date file is taken d = p.filedate newNameShouldBe = cd2d(d).strftime(format) assert newNameShouldBe in p.file attrsAfter = la(p) assert _compare_(attrsAfter, attrsBefore) #================================================================== # test autorotation, # without modification of attributes #================================================================== l = [os.path.join(folder, i).decode(sys.getfilesystemencoding()) for i in os.listdir(folder) if i.lower().endswith(".jpg")] for f in l: p = PhotoCmd(f, needAutoRotation=True) p.addTags([u"àùù", ]) p.addComment(u"àçç")
#================================================================== # assert photos are readable #================================================================== for f in l: p = PhotoCmd(f) assert not p.readonly assert p.file == f # are not renamed assert p.exifdate # and got exifdate #================================================================== # tests renaming #================================================================== for f in l: p = PhotoCmd(f, needAutoRename=True) assert p.file != f # are renamed newNameShouldBe = cd2d(p.exifdate).strftime(PhotoCmd.format) assert newNameShouldBe in p.file # right new name l = [ os.path.join(folder, i).decode(sys.getfilesystemencoding()) for i in os.listdir(folder) if i.lower().endswith(".jpg") ] #================================================================== # tests Exifthumb after AUTOROTATE #================================================================== for f in l: p = PhotoCmd(f, needAutoRotation=True) if p.isThumbOk() == -1: p.rebuildExifTB() assert p.isThumbOk() == 1
#================================================================== # assert photos are readable #================================================================== for f in l: p = PhotoCmd(f) assert not p.readonly assert p.file == f # are not renamed assert p.exifdate # and got exifdate #================================================================== # tests renaming #================================================================== for f in l: p = PhotoCmd(f, needAutoRename=True) assert p.file != f # are renamed newNameShouldBe = cd2d(p.exifdate).strftime(PhotoCmd.format) assert newNameShouldBe in p.file # right new name l = [os.path.join(folder, i).decode(sys.getfilesystemencoding()) for i in os.listdir(folder) if i.lower().endswith(".jpg")] #================================================================== # tests Exifthumb after AUTOROTATE #================================================================== for f in l: p = PhotoCmd(f, needAutoRotation=True) if p.isThumbOk() == -1: p.rebuildExifTB() assert p.isThumbOk() == 1 #================================================================== # tests Exifthumb after ROTATE