def testWrite(): from photofilmstrip.core.Picture import Picture p1 = Picture(None) p1.SetComment("this is my first picture") p1.SetDuration(7) p2 = Picture(None) p2.SetComment("this is my second picture") p2.SetDuration(12) p3 = Picture(None) p3.SetComment("this is my third picture") p3.SetDuration(2) s = SubtitleSrt(".") s.Start([p1, p2, p3])
def testWrite(): from photofilmstrip.core.Picture import Picture p1 = Picture(None) p1.SetComment("this is my first picture") p1.SetDuration(25) p2 = Picture(None) p2.SetComment("this is my second picture") p2.SetDuration(10) p3 = Picture(None) p3.SetComment("this is my third picture") p3.SetDuration(20) p4 = Picture(None) p4.SetComment("this is my third picture") p4.SetDuration(3740) s = SubtitleSrt("output") s.Start([p1, p2, p3, p4])
def Load(self, importPath=None): filename = self._filename if not os.path.isfile(filename): return False self.__Connect() cur = self.__GetCursor() fileRev = 1 try: # at the beginning we had no property table cur.execute("SELECT value FROM `property` WHERE name=?", ("rev",)) result = cur.fetchone() if result: fileRev = int(result[0]) except sqlite3.DatabaseError: pass try: cur.execute("SELECT * FROM `picture`") except sqlite3.DatabaseError: self.__Close() return False picList = [] for row in cur: imgFile = row["filename"] imgPath = os.path.dirname(imgFile) self._StepProgress(_(u"Loading '%s' ...") % (os.path.basename(imgFile))) picData = self.__LoadSafe(row, 'data', None) if picData is None: if not (os.path.exists(imgPath) and os.path.isfile(imgFile)): if imgPath not in self.__altPaths: self._SelectAlternatePath(imgPath) imgFile = os.path.join(self.__altPaths.get(imgPath, imgPath), os.path.basename(imgFile)) pic = Picture(imgFile) else: if importPath is None: importPath = os.path.dirname(filename) tmpImg = os.path.join(importPath, os.path.basename(imgFile)) if os.path.isfile(tmpImg): logging.debug('overwrite existing file: %s', tmpImg) if not os.path.isdir(importPath): os.makedirs(importPath) fd = open(tmpImg, 'wb') fd.write(picData) fd.close() pic = Picture(tmpImg) pic.SetWidth(self.__LoadSafe(row, 'width', -1)) pic.SetHeight(self.__LoadSafe(row, 'height', -1)) rect = (row["start_left"], row["start_top"], row["start_width"], row["start_height"]) pic.SetStartRect(rect) rect = (row["target_left"], row["target_top"], row["target_width"], row["target_height"]) pic.SetTargetRect(rect) pic.SetDuration(row["duration"]) pic.SetMovement(self.__LoadSafe(row, "movement", Picture.MOVE_LINEAR)) pic.SetComment(row["comment"]) pic.SetRotation(row['rotation']) pic.SetEffect(self.__LoadSafe(row, 'effect', Picture.EFFECT_NONE)) pic.SetTransition(self.__LoadSafe(row, 'transition', Picture.TRANS_FADE)) pic.SetTransitionDuration(self.__LoadSafe(row, 'transition_duration', 1.0)) self.__LoadThumbnail(pic, row["picture_id"]) picList.append(pic) project = Project(self._filename) project.SetPictures(picList) if fileRev >= 2: project.SetAudioFiles(self.__LoadProperties(cur, "audiofile", str)) project.SetDuration(self.__LoadProperty(cur, "duration", float)) project.SetAspect(self.__LoadProperty(cur, "aspect", str, Aspect.ASPECT_16_9)) project.SetTimelapse(self.__LoadProperty(cur, "timelapse", int, False)) self.__Close() self._project = project return True