Skip to content

Commit

Permalink
Remove centre setters, add explicit deprecation warning to getters.
Browse files Browse the repository at this point in the history
i.e. This change makes the deprecated aliases read only, and adds an
explicit warning when reading the values. Previously only got a warning
on setting the value via the deprecated alias.
  • Loading branch information
peterjc committed Feb 4, 2013
1 parent 084c898 commit 2424c5c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
30 changes: 13 additions & 17 deletions Bio/Graphics/GenomeDiagram/_AbstractDrawer.py
Expand Up @@ -433,23 +433,19 @@ def __init__(self, parent, pagesize='A3', orientation='landscape',
else:
self.cross_track_links = cross_track_links

def _set_xcentre(self, value):
import warnings
import Bio
warnings.warn("The _set_xcentre method and .xcentre attribute are deprecated; please use the .xcenter attribute instead", Bio.BiopythonDeprecationWarning)
self.xcenter = value
xcentre = property(fget = lambda self : self.xcenter,
fset = _set_xcentre,
doc="Backwards compatible alias for xcenter (DEPRECATED)")

def _set_ycentre(self, value):
import warnings
import Bio
warnings.warn("The _set_ycentre method and .xcentre attribute are deprecated; please use the .ycenter attribute instead", Bio.BiopythonDeprecationWarning)
self.ycenter = value
ycentre = property(fget = lambda self : self.ycenter,
fset = _set_ycentre,
doc="Backwards compatible alias for ycenter (DEPRECATED)")
@property
def xcentre(self):
"""Backwards compatible alias for xcenter (DEPRECATED)"""
warnings.warn("The .xcentre attribute is deprecated, use .xcenter instead",
Bio.BiopythonDeprecationWarning)
return self.xcenter

@property
def ycentre(self):
"""Backwards compatible alias for ycenter (DEPRECATED)"""
warnings.warn("The .ycentre attribute is deprecated, use .ycenter instead",
Bio.BiopythonDeprecationWarning)
return self.ycenter

def set_page_size(self, pagesize, orientation):
""" set_page_size(self, pagesize, orientation)
Expand Down
14 changes: 6 additions & 8 deletions Bio/Graphics/GenomeDiagram/_Graph.py
Expand Up @@ -133,14 +133,12 @@ def __init__(self, id=None, data=None, name=None, style='bar',
self.linewidth = 2 # linewidth to use in line graphs
self.center = center # value at which x-axis crosses y-axis

def _set_centre(self, value):
import warnings
import Bio
warnings.warn("The _set_centre method and .centre attribute are deprecated; please use the .center attribute instead", Bio.BiopythonDeprecationWarning)
self.center = value
centre = property(fget = lambda self : self.center,
fset = _set_centre,
doc="Backwards compatible alias for center (DEPRECATED)")
@property
def centre(self):
"""Backwards compatible alias for center (DEPRECATED)."""
warnings.warn("The .centre attribute is deprecated, use .center instead",
Bio.BiopythonDeprecationWarning)
return self.center

def set_data(self, data):
""" set_data(self, data)
Expand Down

0 comments on commit 2424c5c

Please sign in to comment.