Walk tree of properties and extract identifiers and associated values
543984
def walk_tree_and_extract(self, data, target):
        ''
        if isinstance(data, dict):
            for key in ['children', 'props',]:
                self.walk_tree_and_extract(data.get(key, None), target)
            ident = data.get('id', None)
            if ident is not None:
                idVals = target.get(ident, {})
                for key, value in data.items():
                    if key not in ['props', 'options', 'children', 'id']:
                        idVals[key] = value
                if idVals:
                    target[ident] = idVals
        if isinstance(data, list):
            for element in data:
                self.walk_tree_and_extract(element, target)
125206
def extract_table_identifiers(token_stream):
    """"""

    for item in token_stream:
        if isinstance(item, IdentifierList):
            for identifier in item.get_identifiers():
                # Sometimes Keywords (such as FROM ) are classified as
                # identifiers which don't have the get_real_name() method.
                try:
                    schema_name = identifier.get_parent_name()
                    real_name = identifier.get_real_name()
                except AttributeError:
                    continue
                if real_name:
                    yield (schema_name, real_name, identifier.get_alias())
        elif isinstance(item, Identifier):
            real_name = item.get_real_name()
            schema_name = item.get_parent_name()

            if real_name:
                yield (schema_name, real_name, item.get_alias())
            else:
                name = item.get_name()
                yield (None, name, item.get_alias() or name)
        elif isinstance(item, Function):
            yield (None, item.get_name(), item.get_name())
841147
def get_properties(self, obj):
        """"""
        properties = {}

        for field_name, field in sorted(obj.fields.items()):
            schema = self._get_schema_for_field(obj, field)
            properties[field.name] = schema

        return properties
255720
def all_properties(self):
        """"""

        properties = {}
        r = self.requests.get(self.index_url + "/_mapping", headers=HEADER_JSON, verify=False)
        try:
            r.raise_for_status()
            r_json = r.json()

            if 'items' not in r_json[self.index]['mappings']:
                return properties

            if 'properties' not in r_json[self.index]['mappings']['items']:
                return properties

            properties = r_json[self.index]['mappings']['items']['properties']
        except requests.exceptions.HTTPError as ex:
            logger.error("Error all attributes for %s.", self.anonymize_url(self.index_url))
            logger.error(ex)
            return

        return properties
582288
function scopedNodes(ast, matching, flat) {
    		if (!flat) flat = ['isScope','isLoop'] ;
        var matches = [];
        treeWalk(ast, function (node, descend, path) {
            if (node === ast) 
                return descend();
            if (matching(node, path)) {
                matches.push([].concat(path));
                return;
            }
            if (flat === true) return ;
            var x = examine(node) ;
            for (var i=0; i<flat.length; i++) 
                if (x[flat[i]]) 
            		   return ;
            descend();
        });
        return matches;
    }
1096168
def walk(value, walker, path=None, seen=None):
  
  seen = seen or set()
  path = path or []

  # Recursion
  if id(value) in seen:
    walker.visitRecursion(path)
    return

  # Error
  if isinstance(value, Exception):
    walker.visitError(path, value)
    return

  # List
  if isinstance(value, list):
    # Not actually a tuple, but okay
    recurse = walker.enterList(value, path)
    if not recurse: return
    next_walker = walker if recurse is True else recurse

    with TempSetAdd(seen, id(value)):
      for i, x in enumerate(value):
        walk(x, next_walker, path=path + ['[%d]' % i], seen=seen)

      walker.leaveList(value, path)
    return

  # Scalar
  if not isinstance(value, framework.TupleLike):
    walker.visitScalar(path, value)
    return

  # Tuple
  recurse = walker.enterTuple(value, path)
  if not recurse: return
  next_walker = walker if recurse is True else recurse

  with TempSetAdd(seen, id(value)):
    keys = sorted(value.keys())
    for key in keys:
      key_path = path + [key]
      elm = get_or_error(value, key)
      walk(elm, next_walker, path=key_path, seen=seen)

    walker.leaveTuple(value, path)
273638
private void extractValues(String path, Map<String, Object> values, CompositeData obj) {
    for (String key : obj.getCompositeType().keySet()) {
      String newPath = (path == null) ? key : path + "." + key;
      Object value = obj.get(key);
      if (value instanceof CompositeData) {
        extractValues(newPath, values, (CompositeData) value);
      } else if (value != null) {
        values.put(newPath, value);
      }
    }
  }
45866
private void extractNestedValuesPrivate(XAttribute element,
			Map<List<String>, Type> nestedValues, List<String> keys) {
		Type value = extractValue(element);
		if (value != null) {
			nestedValues.put(keys, value);
		}
		for (XAttribute attr : element.getAttributes().values()) {
			List<String> newKeys = new ArrayList<String>(keys);
			newKeys.add(element.getKey());
			extractNestedValuesPrivate(attr, nestedValues, newKeys);
		}
	}
899078
def walk_tree_and_replace(self, data, overrides):
        '''
        
        '''
        if isinstance(data, dict):
            response = {}
            replacements = {}
            # look for id entry
            thisID = data.get('id', None)
            if thisID is not None:
                replacements = overrides.get(thisID, None) if overrides else None
                if not replacements:
                    replacements = self._replacements.get(thisID, {})
            # walk all keys and replace if needed
            for k, v in data.items():
                r = replacements.get(k, None)
                if r is None:
                    r = self.walk_tree_and_replace(v, overrides)
                response[k] = r
            return response
        if isinstance(data, list):
            # process each entry in turn and return
            return [self.walk_tree_and_replace(x, overrides) for x in data]
        return data
558313
def traverse_tree(cls, static_dir):
        """"""
        for root, dirs, files in os.walk(static_dir):
            for filename in files:
                if cls._pattern.match(filename):
                    APPS_INCLUDE_DIRS.append(static_dir)
                    return
201352
def walktree(classes, children, parent):
    """"""
    results = []
    classes.sort(lambda a, b: cmp(a.__name__, b.__name__))
    for c in classes:
        results.append((c, c.__bases__))
        if children.has_key(c):
            results.append(walktree(children[c], children, c))
    return results
107288
function extractNormalizedKeys(path) {
    const props = path.node.properties;
    const keys = [];
    let allLiteral = true;

    for (const prop of props) {
      if (t.isIdentifier(prop.key) && !prop.computed) {
        // since a key {a: 3} is equivalent to {"a": 3}, use the latter
        keys.push(t.stringLiteral(prop.key.name));
      } else if (t.isTemplateLiteral(prop.key)) {
        keys.push(t.cloneNode(prop.key));
      } else if (t.isLiteral(prop.key)) {
        keys.push(t.stringLiteral(String(prop.key.value)));
      } else {
        keys.push(t.cloneNode(prop.key));
        allLiteral = false;
      }
    }

    return { keys, allLiteral };
  }
787546
def traverse(self, id_=None):
        """"""
        if id_ is None:
            id_ = self.group

        nodes = r_client.smembers(_children_key(id_))
        while nodes:
            current_id = nodes.pop()

            details = r_client.get(current_id)
            if details is None:
                # child has expired or been deleted, remove from :children
                r_client.srem(_children_key(id_), current_id)
                continue

            details = self._decode(details)
            if details['type'] == 'group':
                children = r_client.smembers(_children_key(details['id']))
                if children is not None:
                    nodes.update(children)

            yield details
1230705
function getBoundaries(graph, config, level, orn, prop) {
    var dim = config.Node;
    var multitree = config.multitree;
    if (dim.overridable) {
      var w = -1, h = -1;
      graph.eachNode(function(n) {
        if (n._depth == level
            && (!multitree || ('$orn' in n.data) && n.data.$orn == orn)) {
          var dw = n.getData('width', prop);
          var dh = n.getData('height', prop);
          w = (w < dw) ? dw : w;
          h = (h < dh) ? dh : h;
        }
      });
      return {
        'width' : w < 0 ? dim.width : w,
        'height' : h < 0 ? dim.height : h
      };
    } else {
      return dim;
    }
  }
13848
def walk(fn, obj, *args, **kwargs):
    """"""
    if type(obj) in [list, tuple]:
        return list(walk(fn, o, *args) for o in obj)
    if type(obj) is dict:
        return dict((walk(fn, k, *args), walk(fn, v, *args)) for k, v in
                    obj.items())
    return fn(obj, *args, **kwargs)
70578
function parsePropertyList( root, libs, com, indent ) {
  var first = true;
  var out = '[';
  libs.compileChildren( root );
  root.children.forEach( function( child ) {
    if ( child.type != libs.Tree.TAG ) {
      if ( child.type == libs.Tree.TEXT || child.type == libs.Tree.ENTITY ) {
        if ( child.text.trim( ).length === 0 ) {
          return;
        }
        if ( first ) {
          first = false;
        } else {
          out += ",";
        }
        out += "\n" + indent + JSON.stringify( child.text );
      }
      return;
    }
    if ( first ) {
      first = false;
    } else {
      out += ",";
    }
    out += "\n" + indent;
    if (isWidget( child )) {
      out += parseWidget( child, libs, com, indent + '  ' );
    } else {
      out += parseElement( child, libs, com, indent + '  ' );
    }
  });

  out += ']';
  com.prop[root.name] = out;
}
87798
function extractPaths(obj, newKeys, ...paths) {
  const nkLen = newKeys.length;
  const pLen = paths.length;

  const curried = curry(assignKeysAtPaths, obj, newKeys, paths);

  return nkLen > pLen ? curried(nkLen) : curried(pLen);
}