コード例 #1
0
 def _prepare(self):
     self.set_total(self.db.get_number_of_media_objects())
     with self.db.get_media_cursor() as cursor:
         for handle, data in cursor:
             obj = MediaObject()
             obj.unserialize(data)
             if os.path.isabs(obj.path):
                 self.handle_list.append(handle)
                 self.path_list.append(obj.path)
             self.update()
     self.reset()
コード例 #2
0
 def _prepare(self):
     from_text = unicode(self.from_entry.get_text())
     self.set_total(self.db.get_number_of_media_objects())
     with self.db.get_media_cursor() as cursor:
         for handle, data in cursor:
             obj = MediaObject()
             obj.unserialize(data)
             if obj.get_path().find(from_text) != -1:
                 self.handle_list.append(handle)
                 self.path_list.append(obj.path)
             self.update()
     self.reset()
     self.prepared = True
コード例 #3
0
 def _run(self):
     """
     Go through directories that are mentioned in the database via
     media files, and include all images that are not all ready
     included.
     """
     if not self.prepared:
         self.prepare()
     self.set_total(len(self.dir_list))
     for directory in self.dir_list:
         for (dirpath, dirnames, filenames) in os.walk(directory):
             if ".git" in dirnames:
                 dirnames.remove('.git')  # don't visit .git directories
             for filename in filenames:
                 media_full_path = os.path.join(dirpath, filename)
                 if media_full_path not in self.path_list:
                     self.path_list.append(media_full_path)
                     mime_type = gen.mime.get_type(media_full_path)
                     if gen.mime.is_image_type(mime_type):
                         obj = MediaObject()
                         obj.set_path(media_full_path)
                         obj.set_mime_type(mime_type)
                         (root, ext) = os.path.splitext(filename)
                         obj.set_description(root)
                         self.db.add_object(obj, self.trans)
         self.update()
     return True
コード例 #4
0
 def _prepare(self):
     """
     Get all of the fullpaths, and the directories of media
     objects in the database.
     """
     self.dir_list = set()
     self.set_total(self.db.get_number_of_media_objects())
     with self.db.get_media_cursor() as cursor:
         for handle, data in cursor:
             obj = MediaObject()
             obj.unserialize(data)
             self.handle_list.append(handle)
             full_path = media_path_full(self.db, obj.path)
             self.path_list.append(full_path)
             directory, filename = os.path.split(full_path)
             if directory not in self.dir_list:
                 self.dir_list.add(directory)
             self.update()
     self.reset()
コード例 #5
0
 def call_editor(self, obj=None):
     if obj is None:
         object = MediaObject()
         func = self.obj_added
     else:
         object = obj
         func = self.after_edit
     try:
         EditMedia(self.dbstate, self.uistate, self.track, 
                   object, func)
     except WindowActiveError:
         pass
コード例 #6
0
def sanitize_media(db, media):
    """
    Create a new MediaObject instance based off the passed Media
    instance. The returned instance has all private records
    removed from it.
    
    @param db: GRAMPS database to which the Person object belongs
    @type db: DbBase
    @param media: source Media object that will be copied with
    privacy records removed
    @type media: MediaObject
    @returns: 'cleansed' Media object
    @rtype: MediaObject
    """
    new_media = MediaObject()

    new_media.set_mime_type(media.get_mime_type())
    new_media.set_path(media.get_path())
    new_media.set_description(media.get_description())
    new_media.set_gramps_id(media.get_gramps_id())
    new_media.set_handle(media.get_handle())
    new_media.set_change_time(media.get_change_time())
    new_media.set_date_object(media.get_date_object())
    new_media.set_tag_list(media.get_tag_list())

    copy_citation_ref_list(db, media, new_media)
    copy_attributes(db, media, new_media)
    copy_notes(db, media, new_media)

    return new_media