GEP18: add deprecated decorator to gramps, use in src and citation
Usage: python -W all Gramps.py svn: r22622
This commit is contained in:
parent
85cc487ee9
commit
6c04f8b151
@ -35,6 +35,14 @@ perform a translation on import, eg Gtk.
|
||||
import platform
|
||||
import sys
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# set up logging
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import warnings
|
||||
import functools
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Platforms
|
||||
@ -159,3 +167,25 @@ def mod_key():
|
||||
return "<ctrl>"
|
||||
|
||||
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 .tagbase import TagBase
|
||||
from .srcattrbase import SrcAttributeBase
|
||||
from ..constfunc import cuni
|
||||
from ..constfunc import cuni, deprecated
|
||||
from .handle import Handle
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -288,6 +288,7 @@ class Citation(MediaBase, NoteBase, SrcAttributeBase, PrimaryObject, DateBase):
|
||||
"""Set the page indicator of the Citation."""
|
||||
self.page = page
|
||||
|
||||
@deprecated
|
||||
def get_page(self):
|
||||
"""Get the page indicator of the Citation."""
|
||||
return self.page
|
||||
|
@ -39,7 +39,7 @@ from .srcattrbase import SrcAttributeBase
|
||||
from .srctemplate import SrcTemplate
|
||||
from .reporef import RepoRef
|
||||
from .const import DIFFERENT, EQUAL, IDENTICAL
|
||||
from ..constfunc import cuni
|
||||
from ..constfunc import cuni, deprecated
|
||||
from .handle import Handle
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -273,6 +273,7 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, PrimaryObject):
|
||||
"""
|
||||
self.title = title
|
||||
|
||||
@deprecated
|
||||
def get_title(self):
|
||||
"""
|
||||
Return the descriptive title of the Place object.
|
||||
@ -286,6 +287,7 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, PrimaryObject):
|
||||
## """Set the author of the Source."""
|
||||
## self.author = author
|
||||
|
||||
@deprecated
|
||||
def get_author(self):
|
||||
"""Return the author of the Source.
|
||||
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."""
|
||||
## self.pubinfo = text
|
||||
|
||||
@deprecated
|
||||
def get_publication_info(self):
|
||||
"""Return the publication information of the Source.
|
||||
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."""
|
||||
self.abbrev = abbrev
|
||||
|
||||
@deprecated
|
||||
def get_abbreviation(self):
|
||||
"""Return the title abbreviation of the Source."""
|
||||
print 'test'
|
||||
return self.abbrev
|
||||
|
||||
def add_repo_reference(self, repo_ref):
|
||||
|
Loading…
Reference in New Issue
Block a user