# Copyright (C) 2006-2012 Mortal Coil Games # See LICENSE for details. """ """ def getarg(args, name, defval=0): """ You need to add a docstring here ! """ ret = defval if args.has_key(name): ret = args[name] return ret def parseInstanceId(sid): """ this function takes a tuple of any length that is in string format and has all int values. It converts it back to a tuple. """ if sid.isdigit(): return int(sid) #if sid[0]=="D": # for a directory entry nevermind #sid=sid[1:] if sid[0] == "(" and sid[ -1] == ")": # parse tuple t = sid[1:-1] nums = t.split(",") arr = [] for n in nums: arr.append(int(n)) return tuple(arr) return sid def getmembers(object, predicate=None): """ Since inspect.getmembers is retarded about some zope stuff, fix that here. Return all members of an object as (name, value) pairs sorted by name. Optionally, only return members that satisfy a given predicate. """ results = [] for key in dir(object): if key.startswith("__"): continue value = getattr(object, key) if not predicate or predicate(value): results.append((key, value)) results.sort() return results