~ubuntu-branches/ubuntu/precise/python-keyring/precise-updates

« back to all changes in this revision

Viewing changes to keyring/util/properties.py

  • Committer: Package Import Robot
  • Author(s): Carl Chenet
  • Date: 2012-02-14 12:07:30 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120214120730-ekuysup9a2s5yl9d
Tags: 0.7.1-1
* New upstream version (Closes: #656680, #624690)
* debian/control
  - Add X-Python-Version for Python 3.2
  - Add B-D for Python 3.2
  - Add unzip for B-D to repack upstream sources
  - Add python3-keyring description
  - Recommends python3-crypto for Python3 binary package
* Add python-keyring.install and python3-keyring.install files
* debian/rules
  - Execute unit tests if available
  - repack upstream sources
* debian/watch
  - New URL to catch upstream sources

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# borrowed from jaraco.util.dictlib
 
2
class NonDataProperty(object):
 
3
        """Much like the property builtin, but only implements __get__,
 
4
        making it a non-data property, and can be subsequently reset.
 
5
 
 
6
        See http://users.rcn.com/python/download/Descriptor.htm for more
 
7
        information.
 
8
 
 
9
        >>> class X(object):
 
10
        ...   @NonDataProperty
 
11
        ...   def foo(self):
 
12
        ...     return 3
 
13
        >>> x = X()
 
14
        >>> x.foo
 
15
        3
 
16
        >>> x.foo = 4
 
17
        >>> x.foo
 
18
        4
 
19
        """
 
20
 
 
21
        def __init__(self, fget):
 
22
                assert fget is not None, "fget cannot be none"
 
23
                assert callable(fget), "fget must be callable"
 
24
                self.fget = fget
 
25
 
 
26
        def __get__(self, obj, objtype=None):
 
27
                if obj is None:
 
28
                        return self
 
29
                return self.fget(obj)