Rename database methods: _object to _media

This commit is contained in:
Doug Blank 2016-01-24 18:15:50 -05:00
parent b472d6a8b1
commit c19f4b47a9
21 changed files with 110 additions and 110 deletions

View File

@ -162,7 +162,7 @@ class DbReadBase(object):
"""
raise NotImplementedError
def find_next_object_gramps_id(self):
def find_next_media_gramps_id(self):
"""
Return the next available Gramps ID for a Media object based
off the media object ID prefix.
@ -628,7 +628,7 @@ class DbReadBase(object):
"""
raise NotImplementedError
def get_raw_object_data(self, handle):
def get_raw_media_data(self, handle):
"""
Return raw (serialized and pickled) Family object from handle
"""
@ -917,7 +917,7 @@ class DbReadBase(object):
"""
raise NotImplementedError
def has_object_handle(self, handle):
def has_media_handle(self, handle):
"""
Return True if the handle exists in the current Mediadatabase.
"""
@ -1127,7 +1127,7 @@ class DbReadBase(object):
"""
raise NotImplementedError
def set_object_id_prefix(self, val):
def set_media_id_prefix(self, val):
"""
Set the naming template for Gramps Media ID values.
@ -1283,7 +1283,7 @@ class DbWriteBase(DbReadBase):
"""
raise NotImplementedError
def add_object(self, obj, transaction, set_gid=True):
def add_media(self, obj, transaction, set_gid=True):
"""
Add a Media to the database, assigning internal IDs if they have
not already been defined.
@ -1505,7 +1505,7 @@ class DbWriteBase(DbReadBase):
"""
raise NotImplementedError
def remove_object(self, handle, transaction):
def remove_media(self, handle, transaction):
"""
Remove the MediaPerson specified by the database handle from the
database, preserving the change in the passed transaction.
@ -1869,7 +1869,7 @@ class DbWriteBase(DbReadBase):
elif instance.__class__.__name__ == "Source":
self.remove_source(instance.handle, transaction)
elif instance.__class__.__name__ == "Media":
self.remove_object(instance.handle, transaction)
self.remove_media(instance.handle, transaction)
elif instance.__class__.__name__ == "Note":
self.remove_note(instance.handle, transaction)
elif instance.__class__.__name__ == "Family":

View File

@ -531,7 +531,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
"class_func": Media,
"cursor_func": self.get_media_cursor,
"handles_func": self.get_media_handles,
"add_func": self.add_object,
"add_func": self.add_media,
"commit_func": self.commit_media,
"iter_func": self.iter_media,
"ids_func": self.get_media_gramps_ids,
@ -540,7 +540,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
"count_func": self.get_number_of_media,
"raw_func": self._get_raw_media_data,
"raw_id_func": self._get_raw_media_from_id_data,
"del_func": self.remove_object,
"del_func": self.remove_media,
})
self._tables['Place'].update(
{
@ -629,7 +629,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
self.media_bookmarks = Bookmarks()
self.note_bookmarks = Bookmarks()
self.set_person_id_prefix('I%04d')
self.set_object_id_prefix('O%04d')
self.set_media_id_prefix('O%04d')
self.set_family_id_prefix('F%04d')
self.set_citation_id_prefix('C%04d')
self.set_source_id_prefix('S%04d')
@ -912,7 +912,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
self.source_prefix = self._validated_id_prefix(val, "S")
self.sid2user_format = self.__id2user_format(self.source_prefix)
def set_object_id_prefix(self, val):
def set_media_id_prefix(self, val):
"""
Set the naming template for GRAMPS Media ID values.
@ -1018,7 +1018,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
self.event_id_map)
return gid
def find_next_object_gramps_id(self):
def find_next_media_gramps_id(self):
"""
Return the next available GRAMPS' ID for a Media object based
off the media object ID prefix.
@ -1276,7 +1276,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
def has_tag_handle(self, handle):
return handle in self.tag_map
def has_object_handle(self, handle):
def has_media_handle(self, handle):
return handle in self.media_map
def get_raw_person_data(self, handle):
@ -1300,7 +1300,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
def get_raw_place_data(self, handle):
return self.place_map[handle]
def get_raw_object_data(self, handle):
def get_raw_media_data(self, handle):
return self.media_map[handle]
def get_raw_tag_data(self, handle):
@ -1403,7 +1403,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
self.commit_tag(tag, trans)
return tag.handle
def add_object(self, obj, transaction, set_gid=True):
def add_media(self, obj, transaction, set_gid=True):
"""
Add a Media to the database, assigning internal IDs if they have
not already been defined.
@ -1413,7 +1413,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
if not obj.handle:
obj.handle = create_id()
if (not obj.gramps_id) and set_gid:
obj.gramps_id = self.find_next_object_gramps_id()
obj.gramps_id = self.find_next_media_gramps_id()
if (not obj.gramps_id):
# give it a random value for the moment:
obj.gramps_id = str(random.random())
@ -1563,7 +1563,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
self._do_remove(handle, transaction, self.event_map,
self.event_id_map, EVENT_KEY)
def remove_object(self, handle, transaction):
def remove_media(self, handle, transaction):
"""
Remove the MediaPerson specified by the database handle from the
database, preserving the change in the passed transaction.
@ -1871,7 +1871,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
def set_prefixes(self, person, media, family, source, citation,
place, event, repository, note):
self.set_person_id_prefix(person)
self.set_object_id_prefix(media)
self.set_media_id_prefix(media)
self.set_family_id_prefix(family)
self.set_source_id_prefix(source)
self.set_citation_id_prefix(citation)

View File

@ -93,4 +93,4 @@ class MergeMediaQuery(object):
else:
raise MergeError("Encounter an object of type % s that has "
"a media object reference." % class_name)
self.database.remove_object(old_handle, trans)
self.database.remove_media(old_handle, trans)

View File

@ -115,7 +115,7 @@ class ProxyDbBase(DbReadBase):
self.get_source_handles)
self.repository_map = ProxyMap(self, self.get_raw_repository_data,
self.get_repository_handles)
self.media_map = ProxyMap(self, self.get_raw_object_data,
self.media_map = ProxyMap(self, self.get_raw_media_data,
self.get_media_handles)
self.note_map = ProxyMap(self, self.get_raw_note_data,
self.get_note_handles)
@ -181,7 +181,7 @@ class ProxyDbBase(DbReadBase):
self.get_place_handles)
def get_media_cursor(self):
return ProxyCursor(self.get_raw_object_data,
return ProxyCursor(self.get_raw_media_data,
self.get_media_handles)
def get_repository_cursor(self):
@ -805,7 +805,7 @@ class ProxyDbBase(DbReadBase):
def get_raw_family_data(self, handle):
return self.get_family_from_handle(handle).serialize()
def get_raw_object_data(self, handle):
def get_raw_media_data(self, handle):
return self.get_media_from_handle(handle).serialize()
def get_raw_place_data(self, handle):
@ -871,7 +871,7 @@ class ProxyDbBase(DbReadBase):
return self.gfilter(self.include_place,
self.db.get_place_from_handle(handle)) is not None
def has_object_handle(self, handle):
def has_media_handle(self, handle):
"""
returns True if the handle exists in the current Mediadatabase.
"""

View File

@ -529,7 +529,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
photo.set_description(root)
with DbTxn(_("Drag Media Object"),
self.dbstate.db) as trans:
self.dbstate.db.add_object(photo, trans)
self.dbstate.db.add_media(photo, trans)
oref = MediaRef()
oref.set_reference_handle(photo.get_handle())
self.get_data().append(oref)

View File

@ -84,7 +84,7 @@ class EditMedia(EditPrimary):
AddMedia(dbstate, self.uistate, self.track, self.obj,
self._update_addmedia)
def empty_object(self):
def empty_media(self):
return Media()
def get_menu_title(self):
@ -323,11 +323,11 @@ class EditMedia(EditPrimary):
with DbTxn('', self.db) as trans:
if not self.obj.get_handle():
self.db.add_object(self.obj, trans)
self.db.add_media(self.obj, trans)
msg = _("Add Media Object (%s)") % self.obj.get_description()
else:
if not self.obj.get_gramps_id():
self.obj.set_gramps_id(self.db.find_next_object_gramps_id())
self.obj.set_gramps_id(self.db.find_next_media_gramps_id())
self.db.commit_media(self.obj, trans)
msg = _("Edit Media Object (%s)") % self.obj.get_description()
trans.set_description(msg)
@ -351,10 +351,10 @@ class EditMedia(EditPrimary):
if orig:
cmp_obj = orig
else:
cmp_obj = self.empty_object()
cmp_obj = self.empty_media()
return cmp_obj.serialize(True)[1:] != self.obj.serialize(True)[1:]
else:
cmp_obj = self.empty_object()
cmp_obj = self.empty_media()
return cmp_obj.serialize(True)[1:] != self.obj.serialize()[1:]
class DeleteMediaQuery(object):
@ -415,4 +415,4 @@ class DeleteMediaQuery(object):
self.db.commit_citation(citation, trans)
self.db.enable_signals()
self.db.remove_object(self.media_handle, trans)
self.db.remove_media(self.media_handle, trans)

View File

@ -522,7 +522,7 @@ class EditMediaRef(EditReference):
return
with DbTxn(_("Add Media Object (%s)") %
self.source.get_description(), self.db) as trans:
self.db.add_object(self.source, trans)
self.db.add_media(self.source, trans)
#save reference object in memory
coord = (

View File

@ -56,7 +56,7 @@ class MediaModel(FlatBaseModel):
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
skip=set(), sort_map=None):
self.gen_cursor = db.get_media_cursor
self.map = db.get_raw_object_data
self.map = db.get_raw_media_data
self.fmap = [
self.column_description,

View File

@ -372,7 +372,7 @@ class DbBsddbRead(DbReadBase, Callback):
})
self.set_person_id_prefix('I%04d')
self.set_object_id_prefix('O%04d')
self.set_media_id_prefix('O%04d')
self.set_family_id_prefix('F%04d')
self.set_source_id_prefix('S%04d')
self.set_citation_id_prefix('C%04d')
@ -467,7 +467,7 @@ class DbBsddbRead(DbReadBase, Callback):
def set_prefixes(self, person, media, family, source, citation, place,
event, repository, note):
self.set_person_id_prefix(person)
self.set_object_id_prefix(media)
self.set_media_id_prefix(media)
self.set_family_id_prefix(family)
self.set_source_id_prefix(source)
self.set_citation_id_prefix(citation)
@ -622,7 +622,7 @@ class DbBsddbRead(DbReadBase, Callback):
self.emap_index, self.eid_trans)
return gid
def find_next_object_gramps_id(self):
def find_next_media_gramps_id(self):
"""
Return the next available Gramps ID for a Media object based
off the media object ID prefix.
@ -1371,7 +1371,7 @@ class DbBsddbRead(DbReadBase, Callback):
self.citation_prefix = self._validated_id_prefix(val, "C")
self.cid2user_format = self.__id2user_format(self.citation_prefix)
def set_object_id_prefix(self, val):
def set_media_id_prefix(self, val):
"""
Set the naming template for Gramps Media ID values.
@ -1682,7 +1682,7 @@ class DbBsddbRead(DbReadBase, Callback):
def get_raw_family_data(self, handle):
return self.__get_raw_data(self.family_map, handle)
def get_raw_object_data(self, handle):
def get_raw_media_data(self, handle):
return self.__get_raw_data(self.media_map, handle)
def get_raw_place_data(self, handle):
@ -1730,7 +1730,7 @@ class DbBsddbRead(DbReadBase, Callback):
"""
return self.__has_handle(self.family_map, handle)
def has_object_handle(self, handle):
def has_media_handle(self, handle):
"""
Return True if the handle exists in the current Mediadatabase.
"""

View File

@ -34,7 +34,7 @@ class DbTest(unittest.TestCase):
"find_next_event_gramps_id",
"find_next_family_gramps_id",
"find_next_note_gramps_id",
"find_next_object_gramps_id",
"find_next_media_gramps_id",
"find_next_person_gramps_id",
"find_next_place_gramps_id",
"find_next_repository_gramps_id",
@ -98,7 +98,7 @@ class DbTest(unittest.TestCase):
"get_raw_event_data",
"get_raw_family_data",
"get_raw_note_data",
"get_raw_object_data",
"get_raw_media_data",
"get_raw_person_data",
"get_raw_place_data",
"get_raw_repository_data",
@ -133,7 +133,7 @@ class DbTest(unittest.TestCase):
"has_gramps_id",
"has_name_group_key",
"has_note_handle",
"has_object_handle",
"has_media_handle",
"has_person_handle",
"has_place_handle",
"has_repository_handle",
@ -165,7 +165,7 @@ class DbTest(unittest.TestCase):
"set_event_id_prefix",
"set_family_id_prefix",
"set_note_id_prefix",
"set_object_id_prefix",
"set_media_id_prefix",
"set_person_id_prefix",
"set_place_id_prefix",
"set_prefixes",
@ -184,7 +184,7 @@ class DbTest(unittest.TestCase):
"add_event",
"add_family",
"add_note",
"add_object",
"add_media",
"add_person",
"add_place",
"add_repository",
@ -210,7 +210,7 @@ class DbTest(unittest.TestCase):
"remove_family",
"remove_from_surname_list",
"remove_note",
"remove_object",
"remove_media",
"remove_person",
"remove_place",
"remove_repository",

View File

@ -159,5 +159,5 @@ class GrampsDbBaseTest(unittest.TestCase):
return self._add_object_with_source(citations,
Media,
self._db.add_object,
self._db.add_media,
self._db.commit_media)

View File

@ -307,10 +307,10 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
"class_func": Media,
"cursor_func": self.get_media_cursor,
"handles_func": self.get_media_handles,
"add_func": self.add_object,
"add_func": self.add_media,
"commit_func": self.commit_media,
"count_func": self.get_number_of_media,
"del_func": self.remove_object,
"del_func": self.remove_media,
})
self._tables['Place'].update(
{
@ -1629,15 +1629,15 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.find_next_place_gramps_id if set_gid else None,
self.commit_place)
def add_object(self, obj, transaction, set_gid=True):
def add_media(self, media, transaction, set_gid=True):
"""
Add a Media to the database, assigning internal IDs if they have
not already been defined.
If not set_gid, then gramps_id is not set.
"""
return self.__add_object(obj, transaction,
self.find_next_object_gramps_id if set_gid else None,
return self.__add_object(media, transaction,
self.find_next_media_gramps_id if set_gid else None,
self.commit_media)
def add_repository(self, obj, transaction, set_gid=True):
@ -1735,7 +1735,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
self.__do_remove(handle, transaction, self.event_map,
EVENT_KEY)
def remove_object(self, handle, transaction):
def remove_media(self, handle, transaction):
"""
Remove the MediaPerson specified by the database handle from the
database, preserving the change in the passed transaction.

View File

@ -143,7 +143,7 @@ class PackageWriter(object):
# nl.remove(o)
# p.set_media_list(nl)
# self.db.commit_event(p,None)
# self.db.remove_object(m_id,None)
# self.db.remove_media(m_id,None)
# def leave_clicked():
# # File is lost => do nothing, leave as is

View File

@ -650,7 +650,7 @@ class GrampsParser(UpdateCallback):
"person": (self.start_person, self.stop_person),
"img": (self.start_photo, self.stop_photo),
"objref": (self.start_objref, self.stop_objref),
"object": (self.start_object, self.stop_object),
"object": (self.start_media, self.stop_media),
"file": (self.start_file, None),
"page": (None, self.stop_page),
"place": (self.start_place, self.stop_place),
@ -744,7 +744,7 @@ class GrampsParser(UpdateCallback):
"source": self.db.get_raw_source_data,
"citation": self.db.get_raw_citation_data,
"repository": self.db.get_raw_repository_data,
"media": self.db.get_raw_object_data,
"media": self.db.get_raw_media_data,
"note": self.db.get_raw_note_data,
"tag": self.db.get_raw_tag_data}[target]
raw = get_raw_obj_data(handle)
@ -772,7 +772,7 @@ class GrampsParser(UpdateCallback):
"source": self.db.has_source_handle,
"citation": self.db.get_raw_citation_data,
"repository": self.db.has_repository_handle,
"media": self.db.has_object_handle,
"media": self.db.has_media_handle,
"note": self.db.has_note_handle,
"tag": self.db.has_tag_handle}[target]
while has_handle_func(handle):
@ -793,7 +793,7 @@ class GrampsParser(UpdateCallback):
"source": self.db.add_source,
"citation": self.db.add_citation,
"repository": self.db.add_repository,
"media": self.db.add_object,
"media": self.db.add_media,
"note": self.db.add_note}[target]
add_func(prim_obj, self.trans, set_gid=False)
return handle
@ -813,7 +813,7 @@ class GrampsParser(UpdateCallback):
self.db.has_family_handle,
self.db.has_source_handle,
self.db.has_event_handle,
self.db.has_object_handle,
self.db.has_media_handle,
self.db.has_place_handle,
self.db.has_repository_handle,
'reference',
@ -822,7 +822,7 @@ class GrampsParser(UpdateCallback):
self.db.add_family,
self.db.add_source,
self.db.add_event,
self.db.add_object,
self.db.add_media,
self.db.add_place,
self.db.add_repository,
'reference',
@ -831,7 +831,7 @@ class GrampsParser(UpdateCallback):
self.db.get_raw_family_data,
self.db.get_raw_source_data,
self.db.get_raw_event_data,
self.db.get_raw_object_data,
self.db.get_raw_media_data,
self.db.get_raw_place_data,
self.db.get_raw_repository_data,
'reference', self.db.get_raw_note_data][key]
@ -847,7 +847,7 @@ class GrampsParser(UpdateCallback):
self.db.find_next_family_gramps_id,
self.db.find_next_source_gramps_id,
self.db.find_next_event_gramps_id,
self.db.find_next_object_gramps_id,
self.db.find_next_media_gramps_id,
self.db.find_next_place_gramps_id,
self.db.find_next_repository_gramps_id,
'reference',
@ -2180,7 +2180,7 @@ class GrampsParser(UpdateCallback):
int(attrs.get('corner2_y')) )
self.objref.set_rectangle(rect)
def start_object(self, attrs):
def start_media(self, attrs):
"""
Add a media object to db if it doesn't exist yet and assign
id, privacy and changetime.
@ -2189,15 +2189,15 @@ class GrampsParser(UpdateCallback):
if 'handle' in attrs:
orig_handle = attrs['handle'].replace('_', '')
is_merge_candidate = (self.replace_import_handle and
self.db.has_object_handle(orig_handle))
self.db.has_media_handle(orig_handle))
self.inaugurate(orig_handle, "media", self.object)
gramps_id = self.legalize_id(attrs.get('id'), MEDIA_KEY,
self.oidswap, self.db.oid2user_format,
self.db.find_next_object_gramps_id)
self.db.find_next_media_gramps_id)
self.object.set_gramps_id(gramps_id)
if is_merge_candidate:
orig_object = self.db.get_media_from_handle(orig_handle)
self.info.add('merge-candidate', MEDIA_KEY, orig_object,
orig_media = self.db.get_media_from_handle(orig_handle)
self.info.add('merge-candidate', MEDIA_KEY, orig_media,
self.object)
else:
self.inaugurate_id(attrs.get('id'), MEDIA_KEY, self.object)
@ -2249,7 +2249,7 @@ class GrampsParser(UpdateCallback):
def stop_database(self, *tag):
self.update(self.p.CurrentLineNumber)
def stop_object(self, *tag):
def stop_media(self, *tag):
self.db.commit_media(self.object, self.trans,
self.object.get_change_time())
self.object = None
@ -2285,7 +2285,7 @@ class GrampsParser(UpdateCallback):
attr.set_value(attrs[key])
self.photo.add_attribute(attr)
self.photo.set_mime_type(get_type(self.photo.get_path()))
self.db.add_object(self.photo, self.trans)
self.db.add_media(self.photo, self.trans)
#set correct change time
self.db.commit_media(self.photo, self.trans, self.change)
self.info.add('new-object', MEDIA_KEY, self.photo)

View File

@ -1938,7 +1938,7 @@ class GedcomParser(UpdateCallback):
self.dbase.sid2user_format)
self.oid_map = IdMapper(
self.dbase.oid_trans,
self.dbase.find_next_object_gramps_id,
self.dbase.find_next_media_gramps_id,
self.dbase.oid2user_format)
self.rid_map = IdMapper(
self.dbase.rid_trans,
@ -2300,12 +2300,12 @@ class GedcomParser(UpdateCallback):
}
self.func_list.append(self.citation_parse_tbl)
self.object_parse_tbl = {
TOKEN_FORM : self.__object_ref_form,
TOKEN_TITL : self.__object_ref_titl,
TOKEN_FILE : self.__object_ref_file,
TOKEN_NOTE : self.__object_ref_note,
TOKEN_RNOTE : self.__object_ref_note,
self.media_parse_tbl = {
TOKEN_FORM : self.__media_ref_form,
TOKEN_TITL : self.__media_ref_titl,
TOKEN_FILE : self.__media_ref_file,
TOKEN_NOTE : self.__media_ref_note,
TOKEN_RNOTE : self.__media_ref_note,
TOKEN_IGNORE : self.__ignore,
}
self.func_list.append(self.object_parse_tbl)
@ -2771,7 +2771,7 @@ class GedcomParser(UpdateCallback):
"""
return self.__find_from_handle(gramps_id, self.fid2id)
def __find_object_handle(self, gramps_id):
def __find_media_handle(self, gramps_id):
"""
Return the database handle associated with the media object's GRAMPS ID
"""
@ -2817,7 +2817,7 @@ class GedcomParser(UpdateCallback):
family.set_gramps_id(gramps_id)
return family
def __find_or_create_object(self, gramps_id):
def __find_or_create_media(self, gramps_id):
"""
Finds or creates a media object based on the GRAMPS ID. If the ID is
already used (is in the db), we return the item in the db. Otherwise,
@ -2825,8 +2825,8 @@ class GedcomParser(UpdateCallback):
"""
obj = Media()
intid = self.oid2id.get(gramps_id)
if self.dbase.has_object_handle(intid):
obj.unserialize(self.dbase.get_raw_object_data(intid))
if self.dbase.has_media_handle(intid):
obj.unserialize(self.dbase.get_raw_media_data(intid))
else:
intid = self.__find_from_handle(gramps_id, self.oid2id)
obj.set_handle(intid)
@ -3171,7 +3171,7 @@ class GedcomParser(UpdateCallback):
self.dbase.commit_family, self.fid2id, "FAM")
__check(self.sid_map, self.dbase.sid_trans, self.__find_or_create_source,
self.dbase.commit_source, self.sid2id, "SOUR")
__check(self.oid_map, self.dbase.oid_trans, self.__find_or_create_object,
__check(self.oid_map, self.dbase.oid_trans, self.__find_or_create_media,
self.dbase.commit_media, self.oid2id, "OBJE")
__check(self.rid_map, self.dbase.rid_trans, self.__find_or_create_repository,
self.dbase.commit_repository, self.rid2id, "REPO")
@ -3761,7 +3761,7 @@ class GedcomParser(UpdateCallback):
# Reference to a named multimedia object defined elsewhere
gramps_id = self.oid_map[line.data]
handle = self.__find_object_handle(gramps_id)
handle = self.__find_media_handle(gramps_id)
ref = MediaRef()
ref.set_reference_handle(handle)
state.person.add_media_reference(ref)
@ -5092,7 +5092,7 @@ class GedcomParser(UpdateCallback):
# Reference to a named multimedia object defined elsewhere
gramps_id = self.oid_map[line.data]
handle = self.__find_object_handle(gramps_id)
handle = self.__find_media_handle(gramps_id)
ref = MediaRef()
ref.set_reference_handle(handle)
state.family.add_media_reference(ref)
@ -5183,7 +5183,7 @@ class GedcomParser(UpdateCallback):
return (sub_state.form, sub_state.filename, sub_state.title,
sub_state.note)
def __object_ref_form(self, line, state):
def __media_ref_form(self, line, state):
"""
+1 FORM <MULTIMEDIA_FORMAT> {1:1}
@ -5194,7 +5194,7 @@ class GedcomParser(UpdateCallback):
"""
state.form = line.data
def __object_ref_titl(self, line, state):
def __media_ref_titl(self, line, state):
"""
+1 TITL <DESCRIPTIVE_TITLE> {0:1}
@ -5205,7 +5205,7 @@ class GedcomParser(UpdateCallback):
"""
state.title = line.data
def __object_ref_file(self, line, state):
def __media_ref_file(self, line, state):
"""
+1 FILE <MULTIMEDIA_FILE_REFERENCE> {1:1}
@ -5216,7 +5216,7 @@ class GedcomParser(UpdateCallback):
"""
state.filename = line.data
def __object_ref_note(self, line, state):
def __media_ref_note(self, line, state):
"""
+1 <<NOTE_STRUCTURE>> {0:M}
@ -5320,7 +5320,7 @@ class GedcomParser(UpdateCallback):
# Reference to a named multimedia object defined elsewhere
gramps_id = self.oid_map[line.data]
handle = self.__find_object_handle(gramps_id)
handle = self.__find_media_handle(gramps_id)
ref = MediaRef()
ref.set_reference_handle(handle)
state.event.add_media_reference(ref)
@ -5448,7 +5448,7 @@ class GedcomParser(UpdateCallback):
# Reference to a named multimedia object defined elsewhere
gramps_id = self.oid_map[line.data]
handle = self.__find_object_handle(gramps_id)
handle = self.__find_media_handle(gramps_id)
ref = MediaRef()
ref.set_reference_handle(handle)
state.place.add_media_reference(ref)
@ -6116,7 +6116,7 @@ class GedcomParser(UpdateCallback):
# Reference to a named multimedia object defined elsewhere
gramps_id = self.oid_map[line.data]
handle = self.__find_object_handle(gramps_id)
handle = self.__find_media_handle(gramps_id)
ref = MediaRef()
ref.set_reference_handle(handle)
state.citation.add_media_reference(ref)
@ -6269,7 +6269,7 @@ class GedcomParser(UpdateCallback):
# Reference to a named multimedia object defined elsewhere
gramps_id = self.oid_map[line.data]
handle = self.__find_object_handle(gramps_id)
handle = self.__find_media_handle(gramps_id)
ref = MediaRef()
ref.set_reference_handle(handle)
state.source.add_media_reference(ref)
@ -6483,7 +6483,7 @@ class GedcomParser(UpdateCallback):
+1 <<CHANGE_DATE>> {0:1} p.*
"""
gid = line.token_text.strip()
media = self.__find_or_create_object(self.oid_map[gid])
media = self.__find_or_create_media(self.oid_map[gid])
state = CurrentState()
state.media = media
@ -7540,7 +7540,7 @@ class GedcomParser(UpdateCallback):
photo.set_mime_type(get_type(full_path))
else:
photo.set_mime_type(MIME_MAP.get(form.lower(), 'unknown'))
self.dbase.add_object(photo, self.trans)
self.dbase.add_media(photo, self.trans)
self.media_map[path] = photo.handle
else:
photo = self.dbase.get_media_from_handle(photo_handle)

View File

@ -76,7 +76,7 @@ class SimpleBookTitle(Report):
self.image_size = menu.get_option_by_name('imgsize').get_value()
self.subtitle_string = menu.get_option_by_name('subtitle').get_value()
self.footer_string = menu.get_option_by_name('footer').get_value()
self.object_id = menu.get_option_by_name('imgid').get_value()
self.media_id = menu.get_option_by_name('imgid').get_value()
def write_report(self):
""" Generate the contents of the report """
@ -88,8 +88,8 @@ class SimpleBookTitle(Report):
self.doc.write_text(self.subtitle_string)
self.doc.end_paragraph()
if self.object_id:
the_object = self.database.get_media_from_gramps_id(self.object_id)
if self.media_id:
the_object = self.database.get_media_from_gramps_id(self.media_id)
filename = media_path_full(self.database, the_object.get_path())
if os.path.exists(filename):
if self.image_size:

View File

@ -661,7 +661,7 @@ class CheckIntegrity(object):
self.db.commit_place(place, self.trans)
self.removed_photo.append(ObjectId)
self.db.remove_object(ObjectId,self.trans)
self.db.remove_media(ObjectId,self.trans)
logging.warning(' FAIL: media object and all references to '
'it removed')
@ -855,7 +855,7 @@ class CheckIntegrity(object):
_db.get_number_of_media,
_('Looking for empty media records'),
_empty(empty_media_data, CHANGE_MEDIA),
_db.remove_object,
_db.remove_media,
),
('repos',
_db.get_repository_from_handle,
@ -1640,7 +1640,7 @@ class CheckIntegrity(object):
for bad_handle in self.invalid_media_references:
make_unknown(bad_handle, self.explanation.handle,
self.class_object, self.commit_object, self.trans)
self.class_media, self.commit_media, self.trans)
if len (self.invalid_media_references) == 0:
logging.info(' OK: no media reference problems found')
@ -2043,13 +2043,13 @@ class CheckIntegrity(object):
def commit_repo(self, repo, trans, change):
self.db.add_repository(repo, trans, set_gid=True)
def class_object(self, handle):
def class_media(self, handle):
object = Media()
object.set_handle(handle)
return object
def commit_object(self, object, trans, change):
self.db.add_object(object, trans, set_gid=True)
def commit_media(self, object, trans, change):
self.db.add_media(object, trans, set_gid=True)
def class_note(self, handle):
note = Note()

View File

@ -686,7 +686,7 @@ class ImagesNotIncluded(BatchOp):
obj.set_mime_type(mime_type)
(root, ext) = os.path.splitext(filename)
obj.set_description(root)
self.db.add_object(obj, self.trans)
self.db.add_media(obj, self.trans)
self.update()
return True

View File

@ -109,7 +109,7 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback):
'icon' : 'gramps-place',
'name_ix' : 2},
'media' : {'get_func': self.db.get_media_from_handle,
'remove' : self.db.remove_object,
'remove' : self.db.remove_media,
'get_text': None,
'editor' : 'EditMedia',
'icon' : 'gramps-media',

View File

@ -416,14 +416,14 @@ class TestcaseGenerator(tool.BatchTool):
m.set_description("leave this media object invalid description\x9f")
m.set_path("/tmp/click_on_keep_reference.png\x9f")
m.set_mime_type("image/png\x9f")
self.db.add_object(m, self.trans)
self.db.add_media(m, self.trans)
m = Media()
self.fill_object(m)
m.set_description("reselect this media object invalid description\x9f")
m.set_path("/tmp/click_on_select_file.png\x9f")
m.set_mime_type("image/png\x9f")
self.db.add_object(m, self.trans)
self.db.add_media(m, self.trans)
# setup media attached to Source and Citation to be removed
@ -432,7 +432,7 @@ class TestcaseGenerator(tool.BatchTool):
m.set_description('remove this media object')
m.set_path("/tmp/click_on_remove_object.png")
m.set_mime_type("image/png")
self.db.add_object(m, self.trans)
self.db.add_media(m, self.trans)
s = Source()
s.set_title('media should be removed from this source')
@ -494,7 +494,7 @@ class TestcaseGenerator(tool.BatchTool):
self.db.add_citation( c, self.trans)
m = Media()
self.db.add_object( m, self.trans)
self.db.add_media( m, self.trans)
r = Repository()
self.db.add_repository( r, self.trans)
@ -953,7 +953,7 @@ class TestcaseGenerator(tool.BatchTool):
a.set_value(message)
a.add_citation(choice(c_h_list))
m.add_attribute(a)
self.db.add_object(m, self.trans)
self.db.add_media(m, self.trans)
person1_h = self.generate_person(Person.MALE,name,None)
person2_h = self.generate_person(Person.FEMALE,name,None)
@ -1638,7 +1638,7 @@ class TestcaseGenerator(tool.BatchTool):
if not self.generated_media or randint(0,10) == 1:
m = Media()
self.fill_object(m)
self.db.add_object( m, self.trans)
self.db.add_media( m, self.trans)
self.generated_media.append( m.get_handle())
o.set_reference_handle( choice( self.generated_media))
if randint(0,1) == 1:

View File

@ -194,7 +194,7 @@ class MediaView(ListView):
(root, ext) = os.path.splitext(basename)
photo.set_description(root)
with DbTxn(_("Drag Media Object"), self.dbstate.db) as trans:
self.dbstate.db.add_object(photo, trans)
self.dbstate.db.add_media(photo, trans)
widget.emit_stop_by_name('drag_data_received')
def define_actions(self):
@ -317,7 +317,7 @@ class MediaView(ListView):
def remove(self, obj):
self.remove_selected_objects()
def remove_object_from_handle(self, handle):
def remove_media_from_handle(self, handle):
"""
Remove the selected objects from the database after getting
user verification.