def fetch_tree(client, path):
 (index, items) = consul_fetch(client, path)
 ret = {}
 has_children = re.compile('/$')
 log.debug('Fetched items: %r', format(items))
 if (items is None):
  return ret
 for item in reversed(items):
  key = re.sub((('^' + path) + '/?'), '', item['Key'])
  if (key != ''):
   log.debug('key/path - %s: %s', path, key)
   log.debug('has_children? %r', format(has_children.search(key)))
  if (has_children.search(key) is None):
   ret = pillar_format(ret, key.split('/'), item['Value'])
   log.debug('Fetching subkeys for key: %r', format(item))
 return ret

def fetch_tree ( client , path ) : ( index , items ) = consul_fetch ( client , path ) ret = { } has_children = re . compile ( '/$' ) log . debug ( 'Fetched items: %r' , format ( items ) ) if ( items is None ) : return ret for item in reversed ( items ) : key = re . sub ( ( ( '^' + path ) + '/?' ) , '' , item [ 'Key' ] ) if ( key != '' ) : log . debug ( 'key/path - %s: %s' , path , key ) log . debug ( 'has_children? %r' , format ( has_children . search ( key ) ) ) if ( has_children . search ( key ) is None ) : ret = pillar_format ( ret , key . split ( '/' ) , item [ 'Value' ] ) log . debug ( 'Fetching subkeys for key: %r' , format ( item ) ) return ret
grab data from consul .