[GRASS-SVN] r65376 - grass/branches/releasebranch_7_0/lib/python/pygrass
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jun 4 22:51:31 PDT 2015
Author: zarch
Date: 2015-06-04 22:51:31 -0700 (Thu, 04 Jun 2015)
New Revision: 65376
Modified:
grass/branches/releasebranch_7_0/lib/python/pygrass/utils.py
Log:
pygrass: remove duplicated code (pygrass/modules/interface/docstring
Modified: grass/branches/releasebranch_7_0/lib/python/pygrass/utils.py
===================================================================
--- grass/branches/releasebranch_7_0/lib/python/pygrass/utils.py 2015-06-05 05:35:47 UTC (rev 65375)
+++ grass/branches/releasebranch_7_0/lib/python/pygrass/utils.py 2015-06-05 05:51:31 UTC (rev 65376)
@@ -344,57 +344,3 @@
return False
one = cursor.fetchone() if cursor else None
return True if one and one[0] else False
-
-
-def docstring_property(class_doc):
- """Property attribute for docstrings.
- Took from: https://gist.github.com/bfroehle/4041015
-
- >>> class A(object):
- ... '''Main docstring'''
- ... def __init__(self, x):
- ... self.x = x
- ... @docstring_property(__doc__)
- ... def __doc__(self):
- ... return "My value of x is %s." % self.x
-
- >>> A.__doc__
- 'Main docstring'
-
- >>> a = A(10)
- >>> a.__doc__
- 'My value of x is 10.'
- """
- def wrapper(fget):
- return DocstringProperty(class_doc, fget)
- return wrapper
-
-
-class DocstringProperty(object):
- """Property for the `__doc__` attribute.
-
- Different than `property` in the following two ways:
-
- * When the attribute is accessed from the main class, it returns the value
- of `class_doc`, *not* the property itself. This is necessary so Sphinx
- and other documentation tools can access the class docstring.
-
- * Only supports getting the attribute; setting and deleting raise an
- `AttributeError`.
- """
-
- def __init__(self, class_doc, fget):
- self.class_doc = class_doc
- self.fget = fget
-
- def __get__(self, obj, type=None):
- if obj is None:
- return self.class_doc
- else:
- return self.fget(obj)
-
- def __set__(self, obj, value):
- raise AttributeError("can't set attribute")
-
- def __delete__(self, obj):
- raise AttributeError("can't delete attribute")
More information about the grass-commit
mailing list