Commits

Jason R. Coombs committed ed67ec8

Moved NonDataProperty from jaraco.util.dictlib to jaraco.util.properties

Comments (0)

Files changed (3)

 * Removed jaraco.util.xml_.
 * Added jaraco.util.exceptions.suppress_exception.
 * Added jaraco.util.itertools.last.
+* Moved `jaraco.util.dictlib.NonDataProperty` to `jaraco.util.properties`.
 
 3.9.2
 ~~~~~

jaraco/util/dictlib.py

 
 from jaraco.lang.python import callable
 import jaraco.util.string
-
-class NonDataProperty(object):
-	"""Much like the property builtin, but only implements __get__,
-	making it a non-data property, and can be subsequently reset.
-
-	See http://users.rcn.com/python/download/Descriptor.htm for more
-	information.
-
-	>>> class X(object):
-	...   @NonDataProperty
-	...   def foo(self):
-	...     return 3
-	>>> x = X()
-	>>> x.foo
-	3
-	>>> x.foo = 4
-	>>> x.foo
-	4
-	"""
-
-	def __init__(self, fget):
-		assert fget is not None, "fget cannot be none"
-		assert callable(fget), "fget must be callable"
-		self.fget = fget
-
-	def __get__(self, obj, objtype=None):
-		if obj is None:
-			return self
-		return self.fget(obj)
+from jaraco.util.properties import NonDataProperty
 
 class DictFilter(object):
 	"""

jaraco/util/properties.py

+class NonDataProperty(object):
+	"""Much like the property builtin, but only implements __get__,
+	making it a non-data property, and can be subsequently reset.
+
+	See http://users.rcn.com/python/download/Descriptor.htm for more
+	information.
+
+	>>> class X(object):
+	...   @NonDataProperty
+	...   def foo(self):
+	...     return 3
+	>>> x = X()
+	>>> x.foo
+	3
+	>>> x.foo = 4
+	>>> x.foo
+	4
+	"""
+
+	def __init__(self, fget):
+		assert fget is not None, "fget cannot be none"
+		assert callable(fget), "fget must be callable"
+		self.fget = fget
+
+	def __get__(self, obj, objtype=None):
+		if obj is None:
+			return self
+		return self.fget(obj)