def get_or_set_hash(name, length=8, chars='abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'):
 ret = get(name, None)
 if (ret is None):
  val = ''.join([random.SystemRandom().choice(chars) for _ in range(length)])
  if (DEFAULT_TARGET_DELIM in name):
   (root, rest) = name.split(DEFAULT_TARGET_DELIM, 1)
   curr = get(root, _infinitedict())
   val = _dict_from_path(rest, val)
   curr.update(val)
   setval(root, curr)
  else:
   setval(name, val)
 return get(name)

def get_or_set_hash ( name , length = 8 , chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' ) : ret = get ( name , None ) if ( ret is None ) : val = '' . join ( [ random . SystemRandom ( ) . choice ( chars ) for _ in range ( length ) ] ) if ( DEFAULT_TARGET_DELIM in name ) : ( root , rest ) = name . split ( DEFAULT_TARGET_DELIM , 1 ) curr = get ( root , _infinitedict ( ) ) val = _dict_from_path ( rest , val ) curr . update ( val ) setval ( root , curr ) else : setval ( name , val ) return get ( name )
perform a one-time generation of a hash and write it to the local grains .