* accessible.py (_getAndCache): Cleaned up: Fixed indent width and
authoreitani <eitani@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Thu, 13 Dec 2007 05:44:46 +0000 (05:44 +0000)
committereitani <eitani@e2bd861d-eb25-0410-b326-f6ed22b6b98c>
Thu, 13 Dec 2007 05:44:46 +0000 (05:44 +0000)
added epydoc string.

git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@975 e2bd861d-eb25-0410-b326-f6ed22b6b98c

pyatspi/ChangeLog
pyatspi/accessible.py

index 450c5d4..4971361 100644 (file)
@@ -1,3 +1,8 @@
+2007-12-13  Eitan Isaacson  <eitan@ascender.com>
+
+       * accessible.py (_getAndCache): Cleaned up: Fixed indent width and
+       added epydoc string.
+
 2007-11-15  Eitan Isaacson  <eitan@ascender.com>
 
        * accessible.py: Added new caching (bug #495077). Put in a mixin
index 3766985..4413b3b 100644 (file)
@@ -120,31 +120,44 @@ def _updateCache(event):
     return
 
 def _getAndCache(acc, value_name, get_method):
-    if _CACHE_LEVEL != constants.CACHE_PROPERTIES:
-      return get_method()
+  '''
+  If property caching is enabled, use the cached proprty, or get the 
+  property and cache it. If property caching is disabled, simply get the 
+  property.
+
+  @param value_name: The name of the value, like 'role' or 'description'.
+  @type value_name: string
+  @param get_method: Method used to get the property, should not have any 
+  arguments.
+  @type get_method: callable
+  @return: Value of property we are retrieving.
+  @rtype: object
+  '''
+  if _CACHE_LEVEL != constants.CACHE_PROPERTIES:
+    return get_method()
     
-    cache = _ACCESSIBLE_CACHE
-    h = hash(acc)
+  cache = _ACCESSIBLE_CACHE
+  h = hash(acc)
 
+  try:
+    pc = acc._property_cache
+  except AttributeError:
     try:
-      pc = acc._property_cache
-    except AttributeError:
-      try:
-        pc = cache[h]
-      except KeyError:
-        # no cached info for this accessible yet
-        pc = _PropertyCache()
-        cache[h] = pc
-      acc._property_cache = pc  
+      pc = cache[h]
+    except KeyError:
+      # no cached info for this accessible yet
+      pc = _PropertyCache()
+      cache[h] = pc
+    acc._property_cache = pc  
     
-    try:
-      value = getattr(pc, value_name)
-    except AttributeError:
-      # no cached property of this type
-      value = get_method()
-      setattr(pc, value_name, value)
+  try:
+    value = getattr(pc, value_name)
+  except AttributeError:
+    # no cached property of this type
+    value = get_method()
+    setattr(pc, value_name, value)
     
-    return value
+  return value
   
 
 def _makeQuery(interface):