def HasConfigData(key): """ Check if the given key exists, either already loaded in the Registry dict or as a file in the script data config dir. @type key: string @param key: a given key name. @returns: - 0: key does not exist; - 1: key exists in the Registry dict only; - 2: key exists as a file only; - 3: key exists in the Registry dict and also as a file. @note: for readability it's better to check against the constant bitmasks BPY_KEY_MISSING = 0, BPY_KEY_IN_REGISTRY = 1 and BPY_KEY_IN_FILE = 2. """ fname = bsys.join(_CFG_DIR, "%s%s" % (key, _EXT)) result = BPY_KEY_MISSING if key in Registry.Keys(): result |= BPY_KEY_IN_REGISTRY if bsys.exists(fname): result |= BPY_KEY_IN_FILE return result
def get_keys(): LoadConfigData() # loads all data from files in (u)scripts/bpydata/config/ return [k for k in Registry.Keys() if k[0] != "_"]
#MAX_STR_LEN = 300 # max string length (remember this is just for config data) _CFG_DIR = '' if Blender.Get('udatadir'): _CFG_DIR = Blender.sys.join(Blender.Get('udatadir'), 'config') if not _CFG_DIR or not bsys.exists(_CFG_DIR): _CFG_DIR = Blender.sys.join(Blender.Get('datadir'), 'config') if not bsys.exists(_CFG_DIR): _CFG_DIR = '' # to compare against, so we don't write to a cvs tree: _CVS_SUBPATH = 'release/scripts/bpydata/config/' if bsys.dirsep == '\\': _CVS_SUBPATH = _CVS_SUBPATH.replace('/', '\\') _KEYS = [k for k in Registry.Keys() if k[0] != '_'] # _ITEMS_NUM = 0 def _sanitize(o): "Check recursively that all objects are valid, set invalid ones to None" # global MAX_ITEMS_NUM, MAX_STR_LEN, _ITEMS_NUM valid_types = [int, float, bool, long, type] valid_checked_types = [str, unicode] # Only very simple types are considered valid for configuration data, # functions, methods and Blender objects (use their names instead) aren't. t = type(o)