Package Ganga :: Package Utility :: Module util
[hide private]
[frames] | no frames]

Module util

source code

This file contains general-purpose utilities, mainly Python Cookbook recipes.

Classes [hide private]
  Borg
*Python Cookbook recipe 6.16* Borg implementation
  GenericWrapper
  Proxy
  IList
Proxy class for list objects that enables breaking the elements iteration if the condition flag (sentinel) is set to False during this process All the other operations are delegated to the list object itself #note: the same functionality could be achieved by extending list object #and overriding the __iter__() method but unfortunately this is not exposed in Python2.2 #TODO: review this implementation in a more OO way when min Python version in Ganga is 2.3
Functions [hide private]
 
empty_obj(klass) source code
 
empty_class(klass) source code
 
unique(s)
Return a list of elements in s in arbitrary order, but without duplicates.
source code
 
canLoopOver(maybeIterable) source code
 
isStringLike(obj) source code
 
containsGangaObjects(obj)
Recursive call to find GangaObjects
source code
 
isNestedList(obj) source code
 
execute_once()
Return True if this function was not yet executed from a certain line in the program code.
source code
 
hostname()
Try to get the hostname in the most possible reliable way as described in the Python LibRef.
source code
 
setAttributesFromDict(d, prefix=None)
*Python Cookbook recipe 6.18* Helper function to automatically initialises instance variables from __init_ arguments.
source code
 
wrap_callable(any_callable, before, after) source code
 
wrap_callable_filter(any_callable, before, after) source code
 
make_binder(unbounded_method) source code
 
proxy(obj, *specials) source code
 
importName(modulename, name) source code
Variables [hide private]
  __executed_frames = {}
  known_proxy_classes = {}
  __package__ = None
hash(x)
Function Details [hide private]

execute_once()

source code 
Return True if this function was not yet executed from a certain line in the program code.
Example:
 execute_once() # -> True
 execute_once() # -> True

 for i in range(2):
  execute_once() # -> True (1st), False (2nd)

 if execute_once() and execute_once():  # -> False