GEP18: add deprecated decorator to gramps, use in src and citation
Usage: python -W all Gramps.py svn: r22622
This commit is contained in:
@ -35,6 +35,14 @@ perform a translation on import, eg Gtk.
|
|||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# set up logging
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
import warnings
|
||||||
|
import functools
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Platforms
|
# Platforms
|
||||||
@ -159,3 +167,25 @@ def mod_key():
|
|||||||
return "<ctrl>"
|
return "<ctrl>"
|
||||||
|
|
||||||
return "<alt>"
|
return "<alt>"
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# DECORATORS
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def deprecated(func):
|
||||||
|
'''This is a decorator which can be used to mark functions
|
||||||
|
as deprecated. It will result in a warning being emitted
|
||||||
|
when the function is used.'''
|
||||||
|
|
||||||
|
@functools.wraps(func)
|
||||||
|
def new_func(*args, **kwargs):
|
||||||
|
warnings.warn_explicit(
|
||||||
|
"Call to deprecated function {}.".format(func.__name__),
|
||||||
|
category=DeprecationWarning,
|
||||||
|
filename=func.func_code.co_filename,
|
||||||
|
lineno=func.func_code.co_firstlineno + 1
|
||||||
|
)
|
||||||
|
return func(*args, **kwargs)
|
||||||
|
return new_func
|
||||||
|
@ -45,7 +45,7 @@ from .notebase import NoteBase
|
|||||||
from .datebase import DateBase
|
from .datebase import DateBase
|
||||||
from .tagbase import TagBase
|
from .tagbase import TagBase
|
||||||
from .srcattrbase import SrcAttributeBase
|
from .srcattrbase import SrcAttributeBase
|
||||||
from ..constfunc import cuni
|
from ..constfunc import cuni, deprecated
|
||||||
from .handle import Handle
|
from .handle import Handle
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -288,6 +288,7 @@ class Citation(MediaBase, NoteBase, SrcAttributeBase, PrimaryObject, DateBase):
|
|||||||
"""Set the page indicator of the Citation."""
|
"""Set the page indicator of the Citation."""
|
||||||
self.page = page
|
self.page = page
|
||||||
|
|
||||||
|
@deprecated
|
||||||
def get_page(self):
|
def get_page(self):
|
||||||
"""Get the page indicator of the Citation."""
|
"""Get the page indicator of the Citation."""
|
||||||
return self.page
|
return self.page
|
||||||
|
@ -39,7 +39,7 @@ from .srcattrbase import SrcAttributeBase
|
|||||||
from .srctemplate import SrcTemplate
|
from .srctemplate import SrcTemplate
|
||||||
from .reporef import RepoRef
|
from .reporef import RepoRef
|
||||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||||
from ..constfunc import cuni
|
from ..constfunc import cuni, deprecated
|
||||||
from .handle import Handle
|
from .handle import Handle
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -273,6 +273,7 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, PrimaryObject):
|
|||||||
"""
|
"""
|
||||||
self.title = title
|
self.title = title
|
||||||
|
|
||||||
|
@deprecated
|
||||||
def get_title(self):
|
def get_title(self):
|
||||||
"""
|
"""
|
||||||
Return the descriptive title of the Place object.
|
Return the descriptive title of the Place object.
|
||||||
@ -286,6 +287,7 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, PrimaryObject):
|
|||||||
## """Set the author of the Source."""
|
## """Set the author of the Source."""
|
||||||
## self.author = author
|
## self.author = author
|
||||||
|
|
||||||
|
@deprecated
|
||||||
def get_author(self):
|
def get_author(self):
|
||||||
"""Return the author of the Source.
|
"""Return the author of the Source.
|
||||||
Author depends on the source template. The logic is:
|
Author depends on the source template. The logic is:
|
||||||
@ -302,6 +304,7 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, PrimaryObject):
|
|||||||
## """Set the publication information of the Source."""
|
## """Set the publication information of the Source."""
|
||||||
## self.pubinfo = text
|
## self.pubinfo = text
|
||||||
|
|
||||||
|
@deprecated
|
||||||
def get_publication_info(self):
|
def get_publication_info(self):
|
||||||
"""Return the publication information of the Source.
|
"""Return the publication information of the Source.
|
||||||
PubInfo depends on the source template. The logic is:
|
PubInfo depends on the source template. The logic is:
|
||||||
@ -318,8 +321,10 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, PrimaryObject):
|
|||||||
"""Set the title abbreviation of the Source."""
|
"""Set the title abbreviation of the Source."""
|
||||||
self.abbrev = abbrev
|
self.abbrev = abbrev
|
||||||
|
|
||||||
|
@deprecated
|
||||||
def get_abbreviation(self):
|
def get_abbreviation(self):
|
||||||
"""Return the title abbreviation of the Source."""
|
"""Return the title abbreviation of the Source."""
|
||||||
|
print 'test'
|
||||||
return self.abbrev
|
return self.abbrev
|
||||||
|
|
||||||
def add_repo_reference(self, repo_ref):
|
def add_repo_reference(self, repo_ref):
|
||||||
|
Reference in New Issue
Block a user