7335: Cleanup code, filenames, and documentation
First part of cleanup, changes: MediaObject -> Media mediaobj -> media mediaobject -> media
This commit is contained in:
parent
186c2bcfef
commit
ee05e0b451
@ -219,7 +219,7 @@ Citation
|
||||
Media Object
|
||||
====================================
|
||||
.. automodule:: gramps.gen.lib.mediaobj
|
||||
.. autoclass:: MediaObject
|
||||
.. autoclass:: Media
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
@ -164,7 +164,7 @@ class DbReadBase(object):
|
||||
|
||||
def find_next_object_gramps_id(self):
|
||||
"""
|
||||
Return the next available Gramps ID for a MediaObject object based
|
||||
Return the next available Gramps ID for a Media object based
|
||||
off the media object ID prefix.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
@ -367,7 +367,7 @@ class DbReadBase(object):
|
||||
|
||||
def get_media_object_handles(self, sort_handles=False):
|
||||
"""
|
||||
Return a list of database handles, one handle for each MediaObject in
|
||||
Return a list of database handles, one handle for each Media in
|
||||
the database.
|
||||
|
||||
If sort_handles is True, the list is sorted by title.
|
||||
@ -505,9 +505,9 @@ class DbReadBase(object):
|
||||
|
||||
def get_object_from_gramps_id(self, val):
|
||||
"""
|
||||
Find a MediaObject in the database from the passed Gramps ID.
|
||||
Find a Media in the database from the passed Gramps ID.
|
||||
|
||||
If no such MediaObject exists, None is returned.
|
||||
If no such Media exists, None is returned.
|
||||
Needs to be overridden by the derived class.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
@ -919,7 +919,7 @@ class DbReadBase(object):
|
||||
|
||||
def has_object_handle(self, handle):
|
||||
"""
|
||||
Return True if the handle exists in the current MediaObjectdatabase.
|
||||
Return True if the handle exists in the current Mediadatabase.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
@ -991,7 +991,7 @@ class DbReadBase(object):
|
||||
|
||||
def iter_media_objects(self):
|
||||
"""
|
||||
Return an iterator over objects for MediaObjects in the database
|
||||
Return an iterator over objects for Medias in the database
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
@ -1129,7 +1129,7 @@ class DbReadBase(object):
|
||||
|
||||
def set_object_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for Gramps MediaObject ID values.
|
||||
Set the naming template for Gramps Media ID values.
|
||||
|
||||
The string is expected to be in the form of a simple text string, or
|
||||
in a format that contains a C/Python style format string using %d,
|
||||
@ -1285,7 +1285,7 @@ class DbWriteBase(DbReadBase):
|
||||
|
||||
def add_object(self, obj, transaction, set_gid=True):
|
||||
"""
|
||||
Add a MediaObject to the database, assigning internal IDs if they have
|
||||
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.
|
||||
@ -1382,7 +1382,7 @@ class DbWriteBase(DbReadBase):
|
||||
|
||||
def commit_media_object(self, obj, transaction, change_time=None):
|
||||
"""
|
||||
Commit the specified MediaObject to the database, storing the changes
|
||||
Commit the specified Media to the database, storing the changes
|
||||
as part of the transaction.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
@ -1507,7 +1507,7 @@ class DbWriteBase(DbReadBase):
|
||||
|
||||
def remove_object(self, handle, transaction):
|
||||
"""
|
||||
Remove the MediaObjectPerson specified by the database handle from the
|
||||
Remove the MediaPerson specified by the database handle from the
|
||||
database, preserving the change in the passed transaction.
|
||||
|
||||
This method must be overridden in the derived class.
|
||||
|
@ -76,7 +76,7 @@ CLASS_TO_KEY_MAP = {"Person": PERSON_KEY,
|
||||
"Source": SOURCE_KEY,
|
||||
"Citation": CITATION_KEY,
|
||||
"Event": EVENT_KEY,
|
||||
"MediaObject": MEDIA_KEY,
|
||||
"Media": MEDIA_KEY,
|
||||
"Place": PLACE_KEY,
|
||||
"Repository": REPOSITORY_KEY,
|
||||
"Note" : NOTE_KEY,
|
||||
@ -87,7 +87,7 @@ KEY_TO_CLASS_MAP = {PERSON_KEY: "Person",
|
||||
SOURCE_KEY: "Source",
|
||||
CITATION_KEY: "Citation",
|
||||
EVENT_KEY: "Event",
|
||||
MEDIA_KEY: "MediaObject",
|
||||
MEDIA_KEY: "Media",
|
||||
PLACE_KEY: "Place",
|
||||
REPOSITORY_KEY: "Repository",
|
||||
NOTE_KEY: "Note",
|
||||
|
@ -61,7 +61,7 @@ from gramps.gen.db import (PERSON_KEY,
|
||||
|
||||
from gramps.gen.utils.id import create_id
|
||||
from gramps.gen.lib.researcher import Researcher
|
||||
from gramps.gen.lib import (Tag, MediaObject, Person, Family, Source, Citation, Event,
|
||||
from gramps.gen.lib import (Tag, Media, Person, Family, Source, Citation, Event,
|
||||
Place, Repository, Note, NameOriginType)
|
||||
from gramps.gen.lib.genderstats import GenderStats
|
||||
|
||||
@ -527,7 +527,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
||||
{
|
||||
"handle_func": self.get_object_from_handle,
|
||||
"gramps_id_func": self.get_object_from_gramps_id,
|
||||
"class_func": MediaObject,
|
||||
"class_func": Media,
|
||||
"cursor_func": self.get_media_cursor,
|
||||
"handles_func": self.get_media_object_handles,
|
||||
"add_func": self.add_object,
|
||||
@ -913,14 +913,14 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
||||
|
||||
def set_object_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for GRAMPS MediaObject ID values.
|
||||
Set the naming template for GRAMPS Media ID values.
|
||||
|
||||
The string is expected to be in the form of a simple text string, or
|
||||
in a format that contains a C/Python style format string using %d,
|
||||
such as O%d or O%04d.
|
||||
"""
|
||||
self.mediaobject_prefix = self._validated_id_prefix(val, "O")
|
||||
self.oid2user_format = self.__id2user_format(self.mediaobject_prefix)
|
||||
self.media_prefix = self._validated_id_prefix(val, "O")
|
||||
self.oid2user_format = self.__id2user_format(self.media_prefix)
|
||||
|
||||
def set_place_id_prefix(self, val):
|
||||
"""
|
||||
@ -1019,10 +1019,10 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
||||
|
||||
def find_next_object_gramps_id(self):
|
||||
"""
|
||||
Return the next available GRAMPS' ID for a MediaObject object based
|
||||
Return the next available GRAMPS' ID for a Media object based
|
||||
off the media object ID prefix.
|
||||
"""
|
||||
self.omap_index, gid = self._find_next_gramps_id(self.mediaobject_prefix,
|
||||
self.omap_index, gid = self._find_next_gramps_id(self.media_prefix,
|
||||
self.omap_index,
|
||||
self.media_id_map)
|
||||
return gid
|
||||
@ -1126,10 +1126,10 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
||||
def get_object_from_handle(self, handle):
|
||||
if isinstance(handle, bytes):
|
||||
handle = str(handle, "utf-8")
|
||||
return MediaObject.create(self._get_raw_media_data(handle))
|
||||
return Media.create(self._get_raw_media_data(handle))
|
||||
|
||||
def get_object_from_gramps_id(self, gramps_id):
|
||||
return MediaObject.create(self.media_id_map[gramps_id])
|
||||
return Media.create(self.media_id_map[gramps_id])
|
||||
|
||||
def get_tag_from_handle(self, handle):
|
||||
if isinstance(handle, bytes):
|
||||
@ -1165,7 +1165,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
||||
return Event.create(self.event_id_map[gramps_id])
|
||||
|
||||
def get_media_from_gramps_id(self, gramps_id):
|
||||
return MediaObject.create(self.media_id_map[gramps_id])
|
||||
return Media.create(self.media_id_map[gramps_id])
|
||||
|
||||
def get_place_from_gramps_id(self, gramps_id):
|
||||
return Place.create(self.place_id_map[gramps_id])
|
||||
@ -1379,7 +1379,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
||||
|
||||
def add_object(self, obj, transaction, set_gid=True):
|
||||
"""
|
||||
Add a MediaObject to the database, assigning internal IDs if they have
|
||||
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.
|
||||
@ -1539,7 +1539,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
||||
|
||||
def remove_object(self, handle, transaction):
|
||||
"""
|
||||
Remove the MediaObjectPerson specified by the database handle from the
|
||||
Remove the MediaPerson specified by the database handle from the
|
||||
database, preserving the change in the passed transaction.
|
||||
"""
|
||||
self._do_remove(handle, transaction, self.media_map,
|
||||
@ -1824,7 +1824,7 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
|
||||
return (Event.create(data[1]) for data in self.get_event_cursor())
|
||||
|
||||
def iter_media_objects(self):
|
||||
return (MediaObject.create(data[1]) for data in self.get_media_cursor())
|
||||
return (Media.create(data[1]) for data in self.get_media_cursor())
|
||||
|
||||
def iter_notes(self):
|
||||
return (Note.create(data[1]) for data in self.get_note_cursor())
|
||||
|
@ -37,7 +37,7 @@ from ..lib.citation import Citation
|
||||
from ..lib.event import Event
|
||||
from ..lib.place import Place
|
||||
from ..lib.repo import Repository
|
||||
from ..lib.mediaobj import MediaObject
|
||||
from ..lib.media import Media
|
||||
from ..lib.note import Note
|
||||
from ..lib.tag import Tag
|
||||
|
||||
@ -328,7 +328,7 @@ class GenericMediaFilter(GenericFilter):
|
||||
return db.get_media_cursor()
|
||||
|
||||
def make_obj(self):
|
||||
return MediaObject()
|
||||
return Media()
|
||||
|
||||
def find_from_handle(self, db, handle):
|
||||
return db.get_object_from_handle(handle)
|
||||
|
@ -49,7 +49,7 @@ from .family import Family
|
||||
from .event import Event
|
||||
from .place import Place
|
||||
from .src import Source
|
||||
from .mediaobj import MediaObject
|
||||
from .media import Media
|
||||
from .repo import Repository
|
||||
from .note import Note
|
||||
from .citation import Citation
|
||||
|
@ -218,7 +218,7 @@ class AttributeRoot(SecondaryObject, PrivacyBase):
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Attribute for Person/Family/MediaObject/MediaRef
|
||||
# Attribute for Person/Family/Media/MediaRef
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Attribute(AttributeRoot, CitationBase, NoteBase):
|
||||
|
@ -163,7 +163,7 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
|
||||
from .note import Note
|
||||
from .date import Date
|
||||
from .tag import Tag
|
||||
from .mediaobj import MediaObject
|
||||
from .media import Media
|
||||
return {
|
||||
"handle": Handle("Event", "EVENT-HANDLE"),
|
||||
"gramps_id": str,
|
||||
@ -173,7 +173,7 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
|
||||
"place": Handle("Place", "PLACE-HANDLE"),
|
||||
"citation_list": [Citation],
|
||||
"note_list": [Note],
|
||||
"media_list": [MediaObject],
|
||||
"media_list": [Media],
|
||||
"attribute_list": [Attribute],
|
||||
"change": float,
|
||||
"tag_list": [Tag],
|
||||
|
@ -28,14 +28,14 @@ class HandleClass(str):
|
||||
@classmethod
|
||||
def get_schema(cls):
|
||||
from gramps.gen.lib import (Person, Family, Event, Place, Source,
|
||||
MediaObject, Repository, Note, Citation)
|
||||
Media, Repository, Note, Citation)
|
||||
tables = {
|
||||
"Person": Person,
|
||||
"Family": Family,
|
||||
"Event": Event,
|
||||
"Place": Place,
|
||||
"Source": Source,
|
||||
"Media": MediaObject,
|
||||
"Media": Media,
|
||||
"Repository": Repository,
|
||||
"Note": Note,
|
||||
"Citation": Citation,
|
||||
|
@ -51,10 +51,10 @@ LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MediaObject class
|
||||
# Media class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MediaObject(CitationBase, NoteBase, DateBase, AttributeBase,
|
||||
class Media(CitationBase, NoteBase, DateBase, AttributeBase,
|
||||
PrimaryObject):
|
||||
"""
|
||||
Container for information about an image file, including location,
|
||||
@ -63,13 +63,13 @@ class MediaObject(CitationBase, NoteBase, DateBase, AttributeBase,
|
||||
|
||||
def __init__(self, source=None):
|
||||
"""
|
||||
Initialize a MediaObject.
|
||||
Initialize a Media.
|
||||
|
||||
If source is not None, then object is initialized from values of the
|
||||
source object.
|
||||
|
||||
:param source: Object used to initialize the new object
|
||||
:type source: MediaObject
|
||||
:type source: Media
|
||||
"""
|
||||
PrimaryObject.__init__(self, source)
|
||||
CitationBase.__init__(self, source)
|
||||
@ -138,7 +138,7 @@ class MediaObject(CitationBase, NoteBase, DateBase, AttributeBase,
|
||||
:returns: Returns a struct containing the data of the object.
|
||||
:rtype: dict
|
||||
"""
|
||||
return {"_class": "MediaObject",
|
||||
return {"_class": "Media",
|
||||
"handle": Handle("Media", self.handle),
|
||||
"gramps_id": self.gramps_id,
|
||||
"path": self.path,
|
||||
@ -215,7 +215,7 @@ class MediaObject(CitationBase, NoteBase, DateBase, AttributeBase,
|
||||
|
||||
:returns: Returns a serialized object
|
||||
"""
|
||||
default = MediaObject()
|
||||
default = Media()
|
||||
return (Handle.from_struct(struct.get("handle", default.handle)),
|
||||
struct.get("gramps_id", default.gramps_id),
|
||||
struct.get("path", default.path),
|
||||
@ -233,7 +233,7 @@ class MediaObject(CitationBase, NoteBase, DateBase, AttributeBase,
|
||||
def unserialize(self, data):
|
||||
"""
|
||||
Convert the data held in a tuple created by the serialize method
|
||||
back into the data in a MediaObject structure.
|
||||
back into the data in a Media structure.
|
||||
|
||||
:param data: tuple containing the persistent data associated the object
|
||||
:type data: tuple
|
||||
@ -316,7 +316,7 @@ class MediaObject(CitationBase, NoteBase, DateBase, AttributeBase,
|
||||
Lost: handle, id, file, date of acquisition.
|
||||
|
||||
:param acquisition: The media object to merge with the present object.
|
||||
:type acquisition: MediaObject
|
||||
:type acquisition: Media
|
||||
"""
|
||||
self._merge_privacy(acquisition)
|
||||
self._merge_attribute_list(acquisition)
|
||||
@ -326,7 +326,7 @@ class MediaObject(CitationBase, NoteBase, DateBase, AttributeBase,
|
||||
|
||||
def set_mime_type(self, mime_type):
|
||||
"""
|
||||
Set the MIME type associated with the MediaObject.
|
||||
Set the MIME type associated with the Media.
|
||||
|
||||
:param mime_type: MIME type to be assigned to the object
|
||||
:type mime_type: str
|
||||
@ -335,7 +335,7 @@ class MediaObject(CitationBase, NoteBase, DateBase, AttributeBase,
|
||||
|
||||
def get_mime_type(self):
|
||||
"""
|
||||
Return the MIME type associated with the MediaObject.
|
||||
Return the MIME type associated with the Media.
|
||||
|
||||
:returns: Returns the associated MIME type
|
||||
:rtype: str
|
@ -41,7 +41,7 @@ from .handle import Handle
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MediaObject References for Person/Place/Source
|
||||
# Media References for Person/Place/Source
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MediaRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase,
|
||||
@ -189,7 +189,7 @@ class MediaRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase,
|
||||
ret = self.get_referenced_note_handles() + \
|
||||
self.get_referenced_citation_handles()
|
||||
if self.ref:
|
||||
ret += [('MediaObject', self.ref)]
|
||||
ret += [('Media', self.ref)]
|
||||
return ret
|
||||
|
||||
def get_handle_referents(self):
|
||||
|
@ -525,7 +525,7 @@ class PrimaryObject(BasicPrimaryObject):
|
||||
"""
|
||||
if classname == 'Citation' and isinstance(self, CitationBase):
|
||||
return self.has_citation_reference(handle)
|
||||
elif classname == 'MediaObject' and isinstance(self, MediaBase):
|
||||
elif classname == 'Media' and isinstance(self, MediaBase):
|
||||
return self.has_media_reference(handle)
|
||||
else:
|
||||
return self._has_handle_reference(classname, handle)
|
||||
@ -541,7 +541,7 @@ class PrimaryObject(BasicPrimaryObject):
|
||||
"""
|
||||
if classname == 'Citation' and isinstance(self, CitationBase):
|
||||
self.remove_citation_references(handle_list)
|
||||
elif classname == 'MediaObject' and isinstance(self, MediaBase):
|
||||
elif classname == 'Media' and isinstance(self, MediaBase):
|
||||
self.remove_media_references(handle_list)
|
||||
else:
|
||||
self._remove_handle_references(classname, handle_list)
|
||||
@ -559,7 +559,7 @@ class PrimaryObject(BasicPrimaryObject):
|
||||
"""
|
||||
if classname == 'Citation' and isinstance(self, CitationBase):
|
||||
self.replace_citation_references(old_handle, new_handle)
|
||||
elif classname == 'MediaObject' and isinstance(self, MediaBase):
|
||||
elif classname == 'Media' and isinstance(self, MediaBase):
|
||||
self.replace_media_references(old_handle, new_handle)
|
||||
else:
|
||||
self._replace_handle_reference(classname, old_handle, new_handle)
|
||||
|
@ -324,7 +324,7 @@ class Struct(object):
|
||||
self is class when called as a classmethod.
|
||||
"""
|
||||
from gramps.gen.lib import (Person, Family, Event, Source, Place, Citation,
|
||||
Repository, MediaObject, Note, Tag, Date)
|
||||
Repository, Media, Note, Tag, Date)
|
||||
if isinstance(struct, dict):
|
||||
if "_class" in struct.keys():
|
||||
if struct["_class"] == "Person":
|
||||
@ -341,8 +341,8 @@ class Struct(object):
|
||||
return Citation.create(Citation.from_struct(struct))
|
||||
elif struct["_class"] == "Repository":
|
||||
return Repository.create(Repository.from_struct(struct))
|
||||
elif struct["_class"] == "MediaObject":
|
||||
return MediaObject.create(MediaObject.from_struct(struct))
|
||||
elif struct["_class"] == "Media":
|
||||
return Media.create(Media.from_struct(struct))
|
||||
elif struct["_class"] == "Note":
|
||||
return Note.create(Note.from_struct(struct))
|
||||
elif struct["_class"] == "Tag":
|
||||
|
@ -26,7 +26,7 @@ from gramps.plugins.database.dictionarydb import DictionaryDb
|
||||
|
||||
from ..import (Person, Surname, Name, NameType, Family, FamilyRelType,
|
||||
Event, EventType, Source, Place, PlaceName, Citation, Date,
|
||||
Repository, RepositoryType, MediaObject, Note, NoteType,
|
||||
Repository, RepositoryType, Media, Note, NoteType,
|
||||
StyledText, StyledTextTag, StyledTextTagType, Tag,
|
||||
ChildRef, ChildRefType, Attribute, MediaRef, AttributeType,
|
||||
Url, UrlType, Address, EventRef, EventRoleType, RepoRef,
|
||||
|
@ -24,7 +24,7 @@ import unittest
|
||||
|
||||
from .. import (Person, Surname, Name, NameType, Family, FamilyRelType,
|
||||
Event, EventType, Source, Place, PlaceName, Citation, Date,
|
||||
Repository, RepositoryType, MediaObject, Note, NoteType,
|
||||
Repository, RepositoryType, Media, Note, NoteType,
|
||||
StyledText, StyledTextTag, StyledTextTagType, Tag,
|
||||
ChildRef, ChildRefType, Attribute, MediaRef, AttributeType,
|
||||
Url, UrlType, Address, EventRef, EventRoleType, RepoRef,
|
||||
@ -900,13 +900,13 @@ class MediaBaseCheck(unittest.TestCase):
|
||||
self.phoenix.replace_media_references('123456','654321')
|
||||
self.assertEqual(self.phoenix.serialize(), self.ref_list.serialize())
|
||||
|
||||
class MediaObjectCheck(unittest.TestCase, PrivacyBaseTest, AttrBaseTest,
|
||||
class MediaCheck(unittest.TestCase, PrivacyBaseTest, AttrBaseTest,
|
||||
NoteBaseTest, CitationBaseTest):
|
||||
def setUp(self):
|
||||
self.phoenix = MediaObject()
|
||||
self.phoenix = Media()
|
||||
self.phoenix.set_path('example.png')
|
||||
self.titanic = MediaObject(self.phoenix)
|
||||
self.ref_obj = MediaObject(self.phoenix)
|
||||
self.titanic = Media(self.phoenix)
|
||||
self.ref_obj = Media(self.phoenix)
|
||||
|
||||
class MediaRefCheck(unittest.TestCase, PrivacyBaseTest, AttrBaseTest,
|
||||
CitationBaseTest, NoteBaseTest):
|
||||
|
@ -23,7 +23,7 @@
|
||||
import unittest
|
||||
|
||||
from .. import (Person, Family, Event, Source, Place, Citation,
|
||||
Repository, MediaObject, Note, Tag)
|
||||
Repository, Media, Note, Tag)
|
||||
from gramps.gen.lib.struct import Struct
|
||||
from gramps.gen.merge.diff import import_as_dict
|
||||
from gramps.cli.user import User
|
||||
@ -74,9 +74,9 @@ class RepositoryCheck(unittest.TestCase, BaseCheck):
|
||||
self.cls = Repository
|
||||
self.object = self.cls()
|
||||
|
||||
class MediaObjectCheck(unittest.TestCase, BaseCheck):
|
||||
class MediaCheck(unittest.TestCase, BaseCheck):
|
||||
def setUp(self):
|
||||
self.cls = MediaObject
|
||||
self.cls = Media
|
||||
self.object = self.cls()
|
||||
|
||||
class NoteCheck(unittest.TestCase, BaseCheck):
|
||||
|
@ -29,7 +29,7 @@ Provide merge capabilities for citations.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from ..lib import (Person, Family, Event, Place,
|
||||
MediaObject, Repository, Citation, Source)
|
||||
Media, Repository, Citation, Source)
|
||||
from ..db import DbTxn
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
@ -82,7 +82,7 @@ class MergeCitationQuery(object):
|
||||
assert(place.has_citation_reference(old_handle))
|
||||
place.replace_citation_references(old_handle, new_handle)
|
||||
self.database.commit_place(place, trans)
|
||||
elif class_name == MediaObject.__name__:
|
||||
elif class_name == Media.__name__:
|
||||
obj = self.database.get_object_from_handle(handle)
|
||||
assert(obj.has_citation_reference(old_handle))
|
||||
obj.replace_citation_references(old_handle, new_handle)
|
||||
|
@ -28,7 +28,7 @@ Provide merge capabilities for notes.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from ..lib import (Person, Family, Event, Place, Source, Citation, Repository,
|
||||
MediaObject)
|
||||
Media)
|
||||
from ..db import DbTxn
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
@ -89,7 +89,7 @@ class MergeNoteQuery(object):
|
||||
assert(place.has_note_reference(old_handle))
|
||||
place.replace_note_references(old_handle, new_handle)
|
||||
self.database.commit_place(place, trans)
|
||||
elif class_name == MediaObject.__name__:
|
||||
elif class_name == Media.__name__:
|
||||
obj = self.database.get_object_from_handle(handle)
|
||||
assert(obj.has_note_reference(old_handle))
|
||||
obj.replace_note_references(old_handle, new_handle)
|
||||
|
@ -30,7 +30,7 @@ Provide merge capabilities for sources.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from ..lib import (Person, Family, Event, Place, Source, Repository,
|
||||
MediaObject, Citation)
|
||||
Media, Citation)
|
||||
from ..db import DbTxn
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
|
@ -160,7 +160,7 @@ class FilterProxyDb(ProxyDbBase):
|
||||
|
||||
def get_object_from_handle(self, handle):
|
||||
"""
|
||||
Finds a MediaObject in the database from the passed Gramps handle.
|
||||
Finds a Media in the database from the passed Gramps handle.
|
||||
If no such Object exists, None is returned.
|
||||
"""
|
||||
media = self.db.get_object_from_handle(handle)
|
||||
@ -352,8 +352,8 @@ class FilterProxyDb(ProxyDbBase):
|
||||
|
||||
def get_object_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a MediaObject in the database from the passed Gramps ID.
|
||||
If no such MediaObject exists, None is returned.
|
||||
Finds a Media in the database from the passed Gramps ID.
|
||||
If no such Media exists, None is returned.
|
||||
"""
|
||||
media = self.db.get_object_from_gramps_id(val)
|
||||
if media:
|
||||
|
@ -29,7 +29,7 @@ Proxy class for the Gramps databases. Filter out all living people.
|
||||
#-------------------------------------------------------------------------
|
||||
from .proxybase import ProxyDbBase
|
||||
from ..lib import (Date, Person, Name, Surname, NameOriginType, Family, Source,
|
||||
Citation, Event, MediaObject, Place, Repository, Note, Tag)
|
||||
Citation, Event, Media, Place, Repository, Note, Tag)
|
||||
from ..utils.alive import probably_alive
|
||||
from ..config import config
|
||||
|
||||
|
@ -40,7 +40,7 @@ LOG = logging.getLogger(".citation")
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from ..lib import (MediaRef, Attribute, Address, EventRef,
|
||||
Person, Name, Source, RepoRef, MediaObject, Place, Event,
|
||||
Person, Name, Source, RepoRef, Media, Place, Event,
|
||||
Family, ChildRef, Repository, LdsOrd, Surname, Citation,
|
||||
SrcAttribute, Note, Tag)
|
||||
from .proxybase import ProxyDbBase
|
||||
@ -209,8 +209,8 @@ class PrivateProxyDb(ProxyDbBase):
|
||||
|
||||
def get_object_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a MediaObject in the database from the passed Gramps ID.
|
||||
If no such MediaObject exists, None is returned.
|
||||
Finds a Media in the database from the passed Gramps ID.
|
||||
If no such Media exists, None is returned.
|
||||
"""
|
||||
obj = self.db.get_object_from_gramps_id(val)
|
||||
if obj and not obj.get_privacy():
|
||||
@ -374,7 +374,7 @@ class PrivateProxyDb(ProxyDbBase):
|
||||
|
||||
def has_object_handle(self, handle):
|
||||
"""
|
||||
Return True if the handle exists in the current MediaObjectdatabase.
|
||||
Return True if the handle exists in the current Mediadatabase.
|
||||
"""
|
||||
object = self.db.get_object_from_handle(handle)
|
||||
if object and not object.get_privacy():
|
||||
@ -432,7 +432,7 @@ class PrivateProxyDb(ProxyDbBase):
|
||||
'Source' : self.db.get_source_from_handle,
|
||||
'Citation' : self.db.get_citation_from_handle,
|
||||
'Place' : self.db.get_place_from_handle,
|
||||
'MediaObject' : self.db.get_object_from_handle,
|
||||
'Media' : self.db.get_object_from_handle,
|
||||
'Note' : self.db.get_note_from_handle,
|
||||
'Repository' : self.db.get_repository_from_handle,
|
||||
}
|
||||
@ -930,7 +930,7 @@ def sanitize_source(db, source):
|
||||
|
||||
def sanitize_media(db, media):
|
||||
"""
|
||||
Create a new MediaObject instance based off the passed Media
|
||||
Create a new Media instance based off the passed Media
|
||||
instance. The returned instance has all private records
|
||||
removed from it.
|
||||
|
||||
@ -938,11 +938,11 @@ def sanitize_media(db, media):
|
||||
:type db: DbBase
|
||||
:param media: source Media object that will be copied with
|
||||
privacy records removed
|
||||
:type media: MediaObject
|
||||
:type media: Media
|
||||
:returns: 'cleansed' Media object
|
||||
:rtype: MediaObject
|
||||
:rtype: Media
|
||||
"""
|
||||
new_media = MediaObject()
|
||||
new_media = Media()
|
||||
|
||||
new_media.set_mime_type(media.get_mime_type())
|
||||
new_media.set_path(media.get_path())
|
||||
|
@ -258,7 +258,7 @@ class ProxyDbBase(DbReadBase):
|
||||
|
||||
def get_media_object_handles(self, sort_handles=False):
|
||||
"""
|
||||
Return a list of database handles, one handle for each MediaObject in
|
||||
Return a list of database handles, one handle for each Media in
|
||||
the database.
|
||||
"""
|
||||
if self.db.is_open:
|
||||
@ -605,8 +605,8 @@ class ProxyDbBase(DbReadBase):
|
||||
|
||||
def get_object_from_gramps_id(self, val):
|
||||
"""
|
||||
Finds a MediaObject in the database from the passed gramps' ID.
|
||||
If no such MediaObject exists, None is returned.
|
||||
Finds a Media in the database from the passed gramps' ID.
|
||||
If no such Media exists, None is returned.
|
||||
"""
|
||||
return self.gfilter(self.include_media_object,
|
||||
self.db.get_object_from_gramps_id(val))
|
||||
@ -873,7 +873,7 @@ class ProxyDbBase(DbReadBase):
|
||||
|
||||
def has_object_handle(self, handle):
|
||||
"""
|
||||
returns True if the handle exists in the current MediaObjectdatabase.
|
||||
returns True if the handle exists in the current Mediadatabase.
|
||||
"""
|
||||
return self.gfilter(self.include_media_object,
|
||||
self.db.get_object_from_handle(handle)) is not None
|
||||
|
@ -31,7 +31,7 @@ a person.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from .proxybase import ProxyDbBase
|
||||
from ..lib import (Person, Family, Source, Citation, Event, MediaObject,
|
||||
from ..lib import (Person, Family, Source, Citation, Event, Media,
|
||||
Place, Repository, Note, Tag)
|
||||
|
||||
class ReferencedBySelectionProxyDb(ProxyDbBase):
|
||||
@ -95,7 +95,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
|
||||
"Source": set(),
|
||||
"Citation": set(),
|
||||
"Repository": set(),
|
||||
"MediaObject": set(),
|
||||
"Media": set(),
|
||||
"Note": set(),
|
||||
"Tag": set(),
|
||||
}
|
||||
@ -129,7 +129,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
|
||||
obj = self.db.get_repository_from_handle(handle)
|
||||
if obj:
|
||||
self.process_repository(obj)
|
||||
elif class_name == "MediaObject":
|
||||
elif class_name == "Media":
|
||||
obj = self.db.get_object_from_handle(handle)
|
||||
if obj:
|
||||
self.process_media(obj)
|
||||
@ -323,9 +323,9 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
|
||||
Follow the media object and find all of the primary objects
|
||||
that it references.
|
||||
"""
|
||||
if media is None or media.handle in self.referenced["MediaObject"]:
|
||||
if media is None or media.handle in self.referenced["Media"]:
|
||||
return
|
||||
self.referenced["MediaObject"].add(media.handle)
|
||||
self.referenced["Media"].add(media.handle)
|
||||
self.process_citation_ref_list(media)
|
||||
self.process_attributes(media)
|
||||
self.process_notes(media)
|
||||
@ -344,7 +344,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
|
||||
if tag.value.startswith("gramps://"):
|
||||
obj_class, prop, value = tag.value[9:].split("/")
|
||||
if obj_class == "Media": # bug6493
|
||||
obj_class = "MediaObject"
|
||||
obj_class = "Media"
|
||||
if prop == "handle":
|
||||
self.queue_object(obj_class, value)
|
||||
self.process_tags(note)
|
||||
@ -478,7 +478,7 @@ class ReferencedBySelectionProxyDb(ProxyDbBase):
|
||||
"""
|
||||
Filter for media objects
|
||||
"""
|
||||
return handle in self.referenced["MediaObject"]
|
||||
return handle in self.referenced["Media"]
|
||||
|
||||
def include_event(self, handle):
|
||||
"""
|
||||
|
@ -24,7 +24,7 @@
|
||||
Provide a simplified database access interface to the Gramps database.
|
||||
"""
|
||||
from ..lib import (Person, Family, Event, Source, Place, Citation,
|
||||
MediaObject, Repository, Note, Date, Tag)
|
||||
Media, Repository, Note, Date, Tag)
|
||||
from ..lib.handle import Handle
|
||||
from ..datehandler import displayer
|
||||
from ..utils.string import gender as gender_map
|
||||
@ -977,7 +977,7 @@ class SimpleAccess(object):
|
||||
self.name(self.mother(obj)),
|
||||
self.name(self.father(obj)),
|
||||
self.gid(obj))
|
||||
elif isinstance(obj, MediaObject):
|
||||
elif isinstance(obj, Media):
|
||||
return "%s: %s [%s]" % (_(object_class),
|
||||
obj.desc,
|
||||
self.gid(obj))
|
||||
@ -1030,7 +1030,7 @@ class SimpleAccess(object):
|
||||
return "%s/%s [%s]" % (self.name(self.mother(obj)),
|
||||
self.name(self.father(obj)),
|
||||
self.gid(obj))
|
||||
elif isinstance(obj, MediaObject):
|
||||
elif isinstance(obj, Media):
|
||||
return "%s [%s]" % (obj.desc,
|
||||
self.gid(obj))
|
||||
elif isinstance(obj, Source):
|
||||
|
@ -28,7 +28,7 @@ from html import escape
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
from ..lib import (Person, Family, Event, Source, Place, Citation,
|
||||
Repository, MediaObject, Note, Date, Span)
|
||||
Repository, Media, Note, Date, Span)
|
||||
from ..config import config
|
||||
from ..datehandler import displayer
|
||||
|
||||
@ -131,7 +131,7 @@ class SimpleTable(object):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Event', item.handle)
|
||||
elif isinstance(item, MediaObject):
|
||||
elif isinstance(item, Media):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self._link_col == col or link is None):
|
||||
link = ('Media', item.handle)
|
||||
|
@ -64,7 +64,7 @@ PERSONCLASS = 'Person'
|
||||
FAMILYCLASS = 'Family'
|
||||
EVENTCLASS = 'Event'
|
||||
PLACECLASS = 'Place'
|
||||
MEDIACLASS = 'MediaObject'
|
||||
MEDIACLASS = 'Media'
|
||||
SOURCECLASS = 'Source'
|
||||
CITATIONCLASS = 'Citation'
|
||||
REPOCLASS = 'Repository'
|
||||
|
@ -361,7 +361,7 @@ def navigation_label(db, nav_type, handle):
|
||||
obj = db.get_repository_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get_name()
|
||||
elif nav_type == 'Media' or nav_type == 'MediaObject':
|
||||
elif nav_type == 'Media' or nav_type == 'Media':
|
||||
obj = db.get_object_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get_description()
|
||||
@ -586,7 +586,7 @@ def get_citation_referents(citation_handle, db):
|
||||
|
||||
"""
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place',
|
||||
'Source', 'MediaObject', 'Repository')
|
||||
'Source', 'Media', 'Repository')
|
||||
|
||||
return (get_referents(citation_handle, db, _primaries))
|
||||
|
||||
@ -660,6 +660,6 @@ def get_note_referents(note_handle, db):
|
||||
|
||||
"""
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place',
|
||||
'Source', 'Citation', 'MediaObject', 'Repository')
|
||||
'Source', 'Citation', 'Media', 'Repository')
|
||||
|
||||
return (get_referents(note_handle, db, _primaries))
|
||||
|
@ -828,7 +828,7 @@ class GrampsLocale(object):
|
||||
return _("the repository")
|
||||
elif objclass == "note":
|
||||
return _("the note")
|
||||
elif objclass in ["media", "mediaobject"]:
|
||||
elif objclass == "media":
|
||||
return _("the media")
|
||||
elif objclass == "source":
|
||||
return _("the source")
|
||||
|
@ -39,7 +39,7 @@ import os
|
||||
#-------------------------------------------------------------------------
|
||||
from ..lib import (Person, Surname, Name, NameType, Family, FamilyRelType,
|
||||
Event, EventType, Source, Place, Citation,
|
||||
Repository, RepositoryType, MediaObject, Note, NoteType,
|
||||
Repository, RepositoryType, Media, Note, NoteType,
|
||||
StyledText, StyledTextTag, StyledTextTagType, Tag,
|
||||
ChildRef, ChildRefType)
|
||||
from .id import create_id
|
||||
@ -130,7 +130,7 @@ def make_unknown(class_arg, explanation, class_func, commit_func, transaction,
|
||||
elif isinstance(obj, Repository):
|
||||
obj.set_name(_('Unknown'))
|
||||
obj.set_type(RepositoryType.UNKNOWN)
|
||||
elif isinstance(obj, MediaObject):
|
||||
elif isinstance(obj, Media):
|
||||
obj.set_path(os.path.join(IMAGE_DIR, "image-missing.png"))
|
||||
obj.set_mime_type('image/png')
|
||||
obj.set_description(_('Unknown'))
|
||||
|
@ -112,7 +112,7 @@ def map2class(target):
|
||||
'repo-link': ClipRepositoryLink,
|
||||
'pevent': ClipEvent,
|
||||
'eventref': ClipEventRef,
|
||||
'mediaobj': ClipMediaObj,
|
||||
'media': ClipMediaObj,
|
||||
'mediaref': ClipMediaRef,
|
||||
'place-link': ClipPlace,
|
||||
'placeref': ClipPlaceRef,
|
||||
@ -139,7 +139,7 @@ OBJ2TARGET = {"Person": Gdk.atom_intern('person-link', False),
|
||||
'Citation': Gdk.atom_intern('citation-link', False),
|
||||
'Repository': Gdk.atom_intern('repo-link', False),
|
||||
'Event': Gdk.atom_intern('pevent', False),
|
||||
'Media': Gdk.atom_intern('mediaobj', False),
|
||||
'Media': Gdk.atom_intern('media', False),
|
||||
'Place': Gdk.atom_intern('place-link', False),
|
||||
'Note': Gdk.atom_intern('note-link', False),
|
||||
}
|
||||
@ -281,7 +281,7 @@ class ClipObjWrapper(ClipWrapper):
|
||||
'Family': self._db.get_family_from_handle,
|
||||
'Event': self._db.get_event_from_handle,
|
||||
'Place': self._db.get_place_from_handle,
|
||||
'MediaObject': self._db.get_object_from_handle,
|
||||
'Media': self._db.get_object_from_handle,
|
||||
'Source': self._db.get_source_from_handle}
|
||||
|
||||
for (classname, handle) in self._obj.get_referenced_handles_recursively():
|
||||
@ -1064,7 +1064,7 @@ class ClipboardListView(object):
|
||||
self._db.connect('event-delete',
|
||||
gen_del_obj(self.delete_object_ref, 'eventref'))
|
||||
self._db.connect('media-delete',
|
||||
gen_del_obj(self.delete_object, 'mediaobj'))
|
||||
gen_del_obj(self.delete_object, 'media'))
|
||||
self._db.connect('media-delete',
|
||||
gen_del_obj(self.delete_object_ref, 'mediaref'))
|
||||
self._db.connect('place-delete',
|
||||
@ -1644,7 +1644,7 @@ class MultiTreeView(Gtk.TreeView):
|
||||
self.uistate, [], ref)
|
||||
except WindowActiveError:
|
||||
pass
|
||||
elif objclass in ['Media', 'MediaObject']:
|
||||
elif objclass in ['Media', 'Media']:
|
||||
ref = self.dbstate.db.get_object_from_handle(handle)
|
||||
if ref:
|
||||
try:
|
||||
|
@ -133,7 +133,7 @@ class _DdTargets(object):
|
||||
self.FAMILY_ATTRIBUTE = _DdType(self, 'fattr')
|
||||
self.FAMILY_EVENT = _DdType(self, 'fevent')
|
||||
self.LOCATION = _DdType(self, 'location')
|
||||
self.MEDIAOBJ = _DdType(self, 'mediaobj')
|
||||
self.MEDIAOBJ = _DdType(self, 'media')
|
||||
self.MEDIAREF = _DdType(self, 'mediaref')
|
||||
self.NAME = _DdType(self, 'name')
|
||||
self.NOTE_LINK = _DdType(self, 'note-link')
|
||||
|
@ -71,27 +71,27 @@ WIKI_HELP_SEC = _('manual|Select_a_media_object_selector')
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# AddMediaObject
|
||||
# AddMedia
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class AddMediaObject(ManagedWindow):
|
||||
class AddMedia(ManagedWindow):
|
||||
"""
|
||||
Displays the Add Media Dialog window, allowing the user to select
|
||||
a file from the file system, while providing a description.
|
||||
"""
|
||||
|
||||
def __init__(self, dbstate, uistate, track, mediaobj, callback=None):
|
||||
def __init__(self, dbstate, uistate, track, media, callback=None):
|
||||
"""
|
||||
Create and displays the dialog box
|
||||
|
||||
db - the database in which the new object is to be stored
|
||||
The mediaobject is updated with the information, and on save, the
|
||||
The media is updated with the information, and on save, the
|
||||
callback function is called
|
||||
"""
|
||||
ManagedWindow.__init__(self, uistate, track, self)
|
||||
|
||||
self.dbase = dbstate.db
|
||||
self.obj = mediaobj
|
||||
self.obj = media
|
||||
self.callback = callback
|
||||
|
||||
self.last_directory = config.get('behavior.addmedia-image-dir')
|
||||
|
@ -49,7 +49,7 @@ from gi.repository import GLib
|
||||
from ...utils import is_right_click, open_file_with_default_application
|
||||
from ...dbguielement import DbGUIElement
|
||||
from ...selectors import SelectorFactory
|
||||
from gramps.gen.lib import MediaObject, MediaRef
|
||||
from gramps.gen.lib import Media, MediaRef
|
||||
from gramps.gen.db import DbTxn
|
||||
from gramps.gen.utils.file import (media_path_full, media_path, relative_path,
|
||||
create_checksum)
|
||||
@ -100,8 +100,8 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
||||
"""
|
||||
#note: media-rebuild closes the editors, so no need to connect to it
|
||||
self.callman.register_callbacks(
|
||||
{'media-delete': self.media_delete, # delete a mediaobj we track
|
||||
'media-update': self.media_update, # change a mediaobj we track
|
||||
{'media-delete': self.media_delete, # delete a media we track
|
||||
'media-update': self.media_update, # change a media we track
|
||||
})
|
||||
self.callman.connect_all(keys=['media'])
|
||||
|
||||
@ -285,7 +285,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
||||
try:
|
||||
from .. import EditMediaRef
|
||||
EditMediaRef(self.dbstate, self.uistate, self.track,
|
||||
MediaObject(), MediaRef(),
|
||||
Media(), MediaRef(),
|
||||
self.add_callback)
|
||||
except WindowActiveError:
|
||||
pass
|
||||
@ -322,7 +322,7 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
||||
This function should be overridden by the derived class.
|
||||
|
||||