extract POI nodes from osm pbf extract
558658
def extract(self, pbf, output):
        
        logging.info("Extracting POI nodes from {0} to {1}".format(pbf, output))
        with open(output, 'w') as f:
            # define callback for each node that is processed
            def nodes_callback(nodes):
                for node in nodes:
                    node_id, tags, coordinates = node
                    # if any tags have a matching key then write record
                    if any([t in tags for t in POI_TAGS]):
                        f.write(json.dumps(dict(tags=tags, coordinates=coordinates)))
                        f.write('\n')
            parser = OSMParser(concurrency=4, nodes_callback=nodes_callback)
            parser.parse(pbf)
        return output
439574
def extract_subtree(self, node):
        '''
        '''
        if not isinstance(node, Node):
            raise TypeError("node must be a Node")
        r = self.root; self.root = node; o = copy(self); self.root = r; return o
732041
public static void extractPlaceholders(ClassNode node, Map<GenericsTypeName, GenericsType> map) {
        if (node == null) return;

        if (node.isArray()) {
            extractPlaceholders(node.getComponentType(), map);
            return;
        }

        if (!node.isUsingGenerics() || !node.isRedirectNode()) return;
        GenericsType[] parameterized = node.getGenericsTypes();
        if (parameterized == null || parameterized.length == 0) return;
        GenericsType[] redirectGenericsTypes = node.redirect().getGenericsTypes();
        if (redirectGenericsTypes == null ||
                (node.isGenericsPlaceHolder() && redirectGenericsTypes.length != parameterized.length) /* GROOVY-8609 */ ) {
            redirectGenericsTypes = parameterized;
        }
        if (redirectGenericsTypes.length != parameterized.length) {
            throw new GroovyBugError("Expected earlier checking to detect generics parameter arity mismatch" +
                    "\nExpected: " + node.getName() + toGenericTypesString(redirectGenericsTypes) +
                    "\nSupplied: " + node.getName() + toGenericTypesString(parameterized));
        }

        List<GenericsType> valueList = new LinkedList<>();
        for (int i = 0; i < redirectGenericsTypes.length; i++) {
            GenericsType redirectType = redirectGenericsTypes[i];
            if (redirectType.isPlaceholder()) {
                GenericsTypeName name = new GenericsTypeName(redirectType.getName());
                if (!map.containsKey(name)) {
                    GenericsType value = parameterized[i];
                    map.put(name, value);

                    valueList.add(value);
                }
            }
        }

        for (GenericsType value : valueList) {
            if (value.isWildcard()) {
                ClassNode lowerBound = value.getLowerBound();
                if (lowerBound != null) {
                    extractPlaceholders(lowerBound, map);
                }
                ClassNode[] upperBounds = value.getUpperBounds();
                if (upperBounds != null) {
                    for (ClassNode upperBound : upperBounds) {
                        extractPlaceholders(upperBound, map);
                    }
                }
            } else if (!value.isPlaceholder()) {
                extractPlaceholders(value.getType(), map);
            }
        }
    }
1213476
private void extractMbeanConfiguration(NodeList pNodes,MBeanPolicyConfig pConfig) throws MalformedObjectNameException {
        for (int i = 0;i< pNodes.getLength();i++) {
            Node node = pNodes.item(i);
            if (node.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }
            extractPolicyConfig(pConfig, node.getChildNodes());
        }
    }
698317
@Override
    public R visitIndex(IndexTree node, P p) {
        R r = scan(node.getSearchTerm(), p);
        r = scanAndReduce(node.getDescription(), p, r);
        return r;
    }
1091737
def extract_cells(self, ind):
        
        if not isinstance(ind, np.ndarray):
            ind = np.array(ind, np.ndarray)

        if ind.dtype == np.bool:
            ind = ind.nonzero()[0].astype(vtki.ID_TYPE)

        if ind.dtype != vtki.ID_TYPE:
            ind = ind.astype(vtki.ID_TYPE)

        if not ind.flags.c_contiguous:
            ind = np.ascontiguousarray(ind)

        vtk_ind = numpy_to_vtkIdTypeArray(ind, deep=False)

        # Create selection objects
        selectionNode = vtk.vtkSelectionNode()
        selectionNode.SetFieldType(vtk.vtkSelectionNode.CELL)
        selectionNode.SetContentType(vtk.vtkSelectionNode.INDICES)
        selectionNode.SetSelectionList(vtk_ind)

        selection = vtk.vtkSelection()
        selection.AddNode(selectionNode)

        # extract
        extract_sel = vtk.vtkExtractSelection()
        extract_sel.SetInputData(0, self)
        extract_sel.SetInputData(1, selection)
        extract_sel.Update()
        subgrid = _get_output(extract_sel)

        # extracts only in float32
        if self.points.dtype is not np.dtype('float32'):
            ind = subgrid.point_arrays['vtkOriginalPointIds']
            subgrid.points = self.points[ind]

        return subgrid
640903
def get_node(self, index):
        

        index = self.mapToSource(index)
        if not index.isValid():
            return self.sourceModel().root_node

        return index.internalPointer() or self.sourceModel().root_node
623914
def pbf(self, bbox, geo_col=None, scale=4096):
        
        col = geo_col or self.geo_field.name
        w, s, e, n = bbox.extent
        trans = self._trans_scale(col, -w, -s,
                                  scale / (e - w),
                                  scale / (n - s))
        g = AsText(trans)
        return self.annotate(pbf=g)
909832
private Map<PyExpr, PyExpr> collectVarNameListAndToPyExprMap() {
    Map<PyExpr, PyExpr> nodePyVarToPyExprMap = new LinkedHashMap<>();
    for (Map.Entry<String, MsgSubstUnitNode> entry : msgNode.getVarNameToRepNodeMap().entrySet()) {
      MsgSubstUnitNode substUnitNode = entry.getValue();
      PyExpr substPyExpr = null;

      if (substUnitNode instanceof MsgPlaceholderNode) {
        SoyNode phInitialNode = ((AbstractParentSoyNode<?>) substUnitNode).getChild(0);

        if (phInitialNode instanceof PrintNode
            || phInitialNode instanceof CallNode
            || phInitialNode instanceof RawTextNode) {
          substPyExpr =
              PyExprUtils.concatPyExprs(genPyExprsVisitor.exec(phInitialNode)).toPyString();
        }

        // when the placeholder is generated by HTML tags
        if (phInitialNode instanceof MsgHtmlTagNode) {
          substPyExpr =
              PyExprUtils.concatPyExprs(
                      genPyExprsVisitor.execOnChildren((ParentSoyNode<?>) phInitialNode))
                  .toPyString();
        }
      } else if (substUnitNode instanceof MsgPluralNode) {
        // Translates {@link MsgPluralNode#pluralExpr} into a Python lookup expression.
        // Note that {@code pluralExpr} represents the soy expression of the {@code plural} attr,
        // i.e. the {@code $numDrafts} in {@code {plural $numDrafts}...{/plural}}.
        substPyExpr = translateToPyExprVisitor.exec(((MsgPluralNode) substUnitNode).getExpr());
      } else if (substUnitNode instanceof MsgSelectNode) {
        substPyExpr = translateToPyExprVisitor.exec(((MsgSelectNode) substUnitNode).getExpr());
      }

      if (substPyExpr != null) {
        nodePyVarToPyExprMap.put(new PyStringExpr("'" + entry.getKey() + "'"), substPyExpr);
      }
    }

    return nodePyVarToPyExprMap;
  }
1135490
def _get_node_pos(self, key):
        """"""
        if not self._hashring:
            return

        k = md5_bytes(key)
        key = (k[3] << 24) | (k[2] << 16) | (k[1] << 8) | k[0]

        nodes = self._sorted_keys
        pos = bisect(nodes, key)

        if pos == len(nodes):
            return 0
        return pos
1227652
def extract_files(ubifs, out_path, perms=False):
    
    try:
        inodes = {}
        bad_blocks = []

        walk.index(ubifs, ubifs.master_node.root_lnum, ubifs.master_node.root_offs, inodes, bad_blocks)

        if len(inodes) < 2:
            raise Exception('No inodes found')

        for dent in inodes[1]['dent']:
            extract_dents(ubifs, inodes, dent, out_path, perms)

        if len(bad_blocks):
            error(extract_files, 'Warning', 'Data may be missing or corrupted, bad blocks, LEB [%s]' % ','.join(map(str, bad_blocks)))

    except Exception as e:
        error(extract_files, 'Error', '%s' % e)
452419
function extractBemJsonNode(bemJson) {
  let result = JSON.parse(JSON.stringify(bemJson));

  Object.keys(result).forEach((key) => {
    result[key] = result[key].toString();
  });

  return JSON.stringify(result, null, 2);
}
1271667
@Override
	protected List<Object> extractValues(String thePaths, IBaseResource theResource) {
		FHIRPathEngine fp = new FHIRPathEngine(myWorkerContext);

		List<Object> values = new ArrayList<>();
		String[] nextPathsSplit = SPLIT.split(thePaths);
		for (String nextPath : nextPathsSplit) {
			List<Base> allValues;
			try {
				allValues = fp.evaluate((Base) theResource, trim(nextPath));
			} catch (FHIRException e) {
				String msg = getContext().getLocalizer().getMessage(BaseSearchParamExtractor.class, "failedToExtractPaths", nextPath, e.toString());
				throw new InternalErrorException(msg, e);
			}
			if (allValues.isEmpty() == false) {
				values.addAll(allValues);
			}
		}

		for (int i = 0; i < values.size(); i++) {
			Object nextObject = values.get(i);
			if (nextObject instanceof Extension) {
				Extension nextExtension = (Extension) nextObject;
				nextObject = nextExtension.getValue();
				values.set(i, nextObject);
			}
		}

		return values;
	}
465744
function extractJavadoc(str) {
  var lines = str
    .replace(/^[ \t]+|[ \t]+$/g, '') // Trim whitespace.
    .split('\n').map(function (line, i) {
      return i ? line.replace(/^\s*\*\s?/, '') : line;
    });
  while (!lines[0]) {
    lines.shift();
  }
  while (!lines[lines.length - 1]) {
    lines.pop();
  }
  return lines.join('\n');
}
256817
function getMarkerLines(
  loc: NodeLocation,
  source: Array<string>,
  opts: Object,
): { start: number, end: number, markerLines: Object }
929801
def get_nodes(environment=None):
    """"""
    if not os.path.exists('nodes'):
        return []
    nodes = []
    for filename in sorted(
            [f for f in os.listdir('nodes')
             if (not os.path.isdir(f)
                 and f.endswith(".json") and not f.startswith('.'))]):
        fqdn = ".".join(filename.split('.')[:-1])  # Remove .json from name
        node = get_node(fqdn)
        if environment is None or node.get('chef_environment') == environment:
            nodes.append(node)
    return nodes
1361386
function readRawFeature(pbf, layer, i) {
  pbf.pos = layer.features[i];
  const end = pbf.readVarint() + pbf.pos;

  const feature = {
    layer: layer,
    type: 0,
    properties: {}
  };
  pbf.readFields(featurePBFReader, feature, end);
  return feature;
}