Changeset 10079:d7eae0603efb in orange


Ignore:
Timestamp:
02/08/12 15:24:38 (2 years ago)
Author:
ales_erjavec
Branch:
default
Message:

Added deprecated_class_attribute utility.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/misc/__init__.py

    r10056 r10079  
    831831    return prop  
    832832 
     833class class_property(object): 
     834    def __init__(self, fget=None, fset=None, fdel=None, doc="class property"): 
     835        self.fget = fget 
     836        self.fset = fset 
     837        self.fdel = fdel 
     838        self.__doc__ = doc 
     839         
     840    def __get__(self, instance, owner): 
     841        if instance is None: 
     842            return self.fget(owner) 
     843        else: 
     844            return self.fget(instance)                 
     845             
     846def deprecated_class_attribute(old_name, new_name): 
     847    if environ.orange_no_deprecated_members: 
     848        return None 
     849     
     850    def fget(self): 
     851        deprecation_warning(old_name, new_name, stacklevel=3) 
     852        return getattr(self, new_name) 
     853         
     854    prop = class_property(fget, 
     855                    doc="A deprecated class member '%s'. Use '%s' instead." % (old_name, new_name)) 
     856    return prop 
    833857 
    834858def deprecated_function_name(func): 
Note: See TracChangeset for help on using the changeset viewer.