xpath find function abbreviation
967117
def xpath(self, xpath, dom=None):
        """"""
        if dom is None:
            dom = self.browser
        return expect(dom.find_by_xpath, args=[xpath])
215926
function escapeXml (string) {
    return String(string).replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
  }
1266915
function parseSectionFunction( $funcName, &$args, $tpl, &$text, &$text_len, &$cur_pos,
                                   $relatedTemplateName, $startLine, $startColumn, $rootNamespace )
    {
        while ( $cur_pos < $text_len )
        {
            // parse parameter name
            $wordEndPos = $this->ElementParser->identifierEndPosition( $tpl, $text, $cur_pos, $text_len );
            $paramName  = substr( $text, $cur_pos, $wordEndPos-$cur_pos );
            $cur_pos    = $wordEndPos;
            if ( !$paramName )
            {
                $this->showParseErrorMessage( $tpl, $text, $text_len, $cur_pos, $relatedTemplateName, $startLine, $startColumn,
                                              $funcName, 'Empty parameter name' );
                return;
            }

            // skip whitespaces
            $cur_pos = $this->ElementParser->whitespaceEndPos( $tpl, $text, $cur_pos, $text_len );

            // skip (=)
            if ( $cur_pos >= $text_len || $text[$cur_pos] != '=' ) // if the parameter has no value, i.e. not followed by '=<value>'
            {
                // the parameter gets boolean true value.
                $args[$paramName] = array( array( eZTemplate::TYPE_NUMERIC, // type
                                                  true, // content
                                                  false // debug
                                                  ) );
                continue;
            }
            $cur_pos++;

            // skip whitespaces
            $cur_pos = $this->ElementParser->whitespaceEndPos( $tpl, $text, $cur_pos, $text_len );

            // skip optional dollar sign that is allowed in value of 'var' parameter
            if ( $paramName == 'var' && $cur_pos < $text_len && $text[$cur_pos] == '$' )
            {
                $cur_pos++;
            }

            // parse parameter value
            $args[$paramName] = $this->ElementParser->parseVariableTag( $tpl, $relatedTemplateName, $text, $cur_pos, $cur_pos, $text_len, $rootNamespace );

            // skip whitespaces
            $cur_pos = $this->ElementParser->whitespaceEndPos( $tpl, $text, $cur_pos, $text_len );
        }
    }
836509
function getRxInfo(rxNode,prefix, optStop) {

    if( !rxNode ) return unit(prefix);
    if( optStop && rxNode === n_head(optStop) )  { // if we should match stop node, then pop the stop node 
                                                   // (usually its because we found a loop). Remove the node from the stack {n_tail(optStrop)},
                                                   // and procees with the next element 
      return getRxInfo(rxNode.nextNode,addOpt(rxNode, prefix),n_tail(optStop));
    }
    if(rxNode === DONE ) return unit(prefix);
    if( dot(rxNode) ) { // this is a node that concat of two regexp /AB/ => dot(A,B) - where A and B are regexp themselves
      //console.log("getMaskListOLD-dot");
      return getRxInfo(rxNode.left,prefix, optStop);
    } else if( or(rxNode) ) { //  /A|B/ => or(A,B)
        //console.log("getMaskListOLD - or");
        let LL = getRxInfo(rxNode.left,prefix,optStop);
        let RL = getRxInfo(rxNode.right,prefix,optStop);
        return merge(LL,RL); 
    }
    else if(zero_or_one(rxNode)) { // /A?/  => zero_or_one(A)
        if( optional ) {
          return optional(rxNode, prefix, getRxInfo, optStop );
        }  
        else return getRxInfo(rxNode.nextNode,addElem(prefix,HOLDER_ZERO_OR_ONE), optStop);
    }
    else if(zero_or_more(rxNode)) { //  / A* / => zero_or_more(A)        
        if( optional ){
           return optional(rxNode, prefix, getRxInfo,optStop );
        }
        else return getRxInfo(rxNode.nextNode,addElem(prefix,HOLDER_ZERO_OR_MORE),optStop);;
    }
    else if( matchable(rxNode) ) {
        let res = matchable(rxNode)(undefined);
        let v = res[1] || (mapper?mapper(rxNode,HOLDER_ANY):HOLDER_ANY);
        //console.log("getMaskListOLD", v);
        return getRxInfo(rxNode.nextNode,addElem(prefix,v),optStop);
    } 
    else if( boundary(rxNode) ) {
        return getRxInfo(rxNode.nextNode,prefix, optStop);
    } 
    return unit(prefix);
  }
24079
function _findTag(src, skip) {
        var from, to, inc;
        from = _find(src, [/<[a-z!\/]/i, 2], skip);
        if (from < 0) {
            return null;
        }
        if (src.substr(from, 4) === "<!--") {
            // html comments
            to = _find(src, "-->", from + 4);
            inc = 3;
        } else if (src.substr(from, 7).toLowerCase() === "<script") {
            // script tag
            to = _find(src.toLowerCase(), "</script>", from + 7);
            inc = 9;
        } else if (src.substr(from, 6).toLowerCase() === "<style") {
            // style tag
            to = _find(src.toLowerCase(), "</style>", from + 6);
            inc = 8;
        } else {
            to = _find(src, ">", from + 1, true);
            inc = 1;
        }
        if (to < 0) {
            return null;
        }
        return {from: from, length: to + inc - from};
    }
884804
function _makeFindCondition(match) {
        switch (typeof match) {
        case "function":
            return match;
        case "string":
            return function findCondition(name, node) {
                return node.name === name;
            }.bind(undefined, match.toUpperCase());
        case "number":
            return function findCondition(type, node) {
                return node.type === type;
            }.bind(undefined, match);
        default:
            console.error("Invalid find condition: " + match);
        }
    }
798104
function getDOMPath(node, dontGoUpTheDom /* = false */ ) {
		var path = [],
			entry = '';

		if (node === window) {
			return 'window';
		}

		while (node instanceof Node) {
			// div
			entry = node.nodeName.toLowerCase();

			// shorten the path a bit
			if (['body', 'head', 'html'].indexOf(entry) > -1) {
				path.push(entry);
				break;
			}

			if (node instanceof DocumentFragment) {
				entry = 'DocumentFragment';
			}

			// div#foo
			if (node.id && node.id !== '') {
				entry += '#' + node.id;
			}
			// div#foo.bar.test
			else if (typeof node.className === 'string' && node.className !== '') {
				entry += '.' + node.className.trim().replace(/\s+/g, '.');
			}
			// div[0] <- index of child node
			else if (node.parentNode instanceof Node) {
				entry += '[' + Math.max(0, Array.prototype.indexOf.call(node.parentNode.children || node.parentNode.childNodes, node)) + ']';
			}

			path.push(entry);

			if (dontGoUpTheDom === true) {
				break;
			}

			// go up the DOM
			node = node && node.parentNode;
		}

		return (path.length > 0) ? path.reverse().join(' > ') : false;
	}
746596
def scan(s):
    
    line = 1
    linepos = 1
    pos = 0
    toks = []
    while pos < len(s):
        matched = False
        for (tokname, r) in patterns:
            m = r.match(s, pos)
            if m is not None:
                # found a matching token
                v = m.group(0)
                prec = _preceding_token(toks)
                if tokname == 'STAR' and prec is not None and _is_special(prec):
                    # XPath 1.0 spec, 3.7 special rule 1a
                    # interpret '*' as a wildcard
                    tok = XPathTok('wildcard', v, line, linepos)
                elif (tokname == 'name' and
                      prec is not None and not _is_special(prec) and
                      v in operators):
                    # XPath 1.0 spec, 3.7 special rule 1b
                    # interpret the name as an operator
                    tok = XPathTok(operators[v], v, line, linepos)
                elif tokname == 'name':
                    # check if next token is '('
                    if re_open_para.match(s, pos + len(v)):
                        # XPath 1.0 spec, 3.7 special rule 2
                        if v in node_types:
                            # XPath 1.0 spec, 3.7 special rule 2a
                            tok = XPathTok('node_type', v, line, linepos)
                        else:
                            # XPath 1.0 spec, 3.7 special rule 2b
                            tok = XPathTok('function_name', v, line, linepos)
                    # check if next token is '::'
                    elif re_axis.match(s, pos + len(v)):
                        # XPath 1.0 spec, 3.7 special rule 3
                        if v in axes:
                            tok = XPathTok('axis', v, line, linepos)
                        else:
                            e = "unknown axis %s" % v
                            raise XPathError(e, line, linepos)
                    else:
                        tok = XPathTok('name', v, line, linepos)
                else:
                    tok = XPathTok(tokname, v, line, linepos)
                if tokname == '_whitespace':
                    n = v.count('\n')
                    if n > 0:
                        line = line + n
                        linepos = len(v) - v.rfind('\n')
                    else:
                        linepos += len(v)
                else:
                    linepos += len(v)
                pos += len(v)
                toks.append(tok)
                matched = True
                break
        if matched == False:
            # no patterns matched
            raise XPathError('syntax error', line, linepos)
    return toks
414644
private String getMethod(ELNode.Function func) throws JspTranslationException {
        FunctionInfo funcInfo = func.getFunctionInfo();
        String signature = funcInfo.getFunctionSignature();

        int start = signature.indexOf(' ');
        if (start < 0) {
            throw new JspTranslationException("jsp.error.tld.fn.invalid.signature " + func.getPrefix()+" "+ func.getName());					
        }
        int end = signature.indexOf('(');
        if (end < 0) {
            throw new JspTranslationException("jsp.error.tld.fn.invalid.signature.parenexpected " + func.getPrefix()+" "+ func.getName());					
        }
        return signature.substring(start + 1, end).trim();
    }
397757
function getFunctionName(aFunction) {
    var regexpResult = aFunction.toString().match(/function (\w*)/);
    if (regexpResult && regexpResult[1]) {
        return regexpResult[1];
    }
    return 'anonymous';
}
292420
def xpath_evaluator(self, namespaces=None, regexp=False, smart_strings=True):
        
        """
        return etree.XPathEvaluator(
            self._xml,
            namespaces=namespaces,
            regexp=regexp,
            smart_strings=smart_strings
        )
28944
function findByNodeName(el, nodeName) {
  if (!el.prop) { // not a jQuery or jqLite object -> wrap it
    el = angular.element(el)
  }

  if (el.prop('nodeName') === nodeName.toUpperCase()) {
    return el
  }

  const c = el.children()
  for (let i = 0; c && i < c.length; i++) {
    const node = findByNodeName(c[i], nodeName)
    if (node) {
      return node
    }
  }
}
1023733
function XPathOptimizer(newEngine) {
// private
    var engine = newEngine;
    var namespaceResolver;
    var mirror = new MirroredDocument(namespaceResolver);
    var finderBuilder = new FinderBuilder();

    // keys are full document HTML strings, and values are mappings from
    // XPath's to objects which the following fields:
    //
    //   - finder       the equivalent finder function for the XPath, for
    //                  single node selection
    //   - nodeCount    the node count for the XPath with respect to the given
    //                  document content
    //   - node         the actual, potentially invalidated, node
    //   - sourceIndex  the value of the sourceIndex attribute of the node at
    //                  time of addition to the cache; this can be used to
    //                  determine if the node has since changed positions
    //
    var knownOptimizations = new XPathOptimizationCache(100);

    /**
     * Returns whether this optimizer is capable of optimizing XPath's for the
     * given node.
     */
    function isOptimizable(node) {
        return (node.nodeType == 1);
    }

    /**
     * Returns whether the given XPath evaluates to the given node in the
     * test document.
     */
    function isXPathValid(xpath, node) {
        var contextNode = mirror.getReflection();
        return (engine.setDocument(mirror.getReflection())
            .selectSingleNode(xpath, contextNode, namespaceResolver) === node);
    }

// public
    this.setDocument = function(newDocument) {
        mirror.setOriginal(newDocument);
        return this;
    }

    /**
     * Sets the document object that will be used for test XPath evaluation and
     * traversal related to construction of the optimized expression. This
     * document will be modified freely by the optimize() operation.
     */
    this.setTestDocument = function(newTestDocument) {
        mirror.setReflection(newTestDocument);
        return this;
    };

    this.setNamespaceResolver = function(newNamespaceResolver) {
        namespaceResolver = newNamespaceResolver;
        mirror.setNamespaceResolver(newNamespaceResolver);
        return this;
    };

    /**
     * Returns an optimal XPath whose first result is the same as the first
     * result of the given XPath, when evaluated on the currently set document.
     * If optimization fails, returns the original XPath.
     */
    this.getOptimizedFinder = function(xpath, contextNode) {
        var originalHtml = mirror.getOriginal().documentElement.innerHTML;
        var optimization = knownOptimizations.get(originalHtml, xpath);

        if (optimization) {
            var finder =  optimization.finder;

            if (finder) {
                // the optimized finder for this document content was found in
                // the cache!
                safe_log('info', 'Found cached optimized finder for ' + xpath);
                return finder;
            }
        }

        mirror.reflect();

        if (contextNode) {
            contextNode = mirror.getReflectedNode(contextNode);
        }

        var firstResult = engine.setDocument(mirror.getReflection())
            .selectSingleNode(xpath, contextNode, namespaceResolver);

        if (! firstResult) {
            // either the element doesn't exist, or there was a failure to
            // reflect the document accurately
            return null;
        }

        if (isOptimizable(firstResult)) {
            var finder = finderBuilder.setDocument(mirror.getReflection())
                .build(firstResult);

            if (finder) {
                safe_log('info', 'Found optimized finder: ' + finder);

                if (! optimization) {
                    optimization = knownOptimizations
                        .getOrCreate(originalHtml, xpath);
                }

                optimization.finder = finder;

                return finder;
            }
        }

        return null;
    };

    this.countNodes = function(xpath, contextNode) {
        var originalHtml = mirror.getOriginal().documentElement.innerHTML;
        var optimization = knownOptimizations.get(originalHtml, xpath);

        if (optimization) {
            var nodeCount = optimization.nodeCount;

            if (nodeCount != null) {
                // the node count for the XPath for this document content was
                // found in the cache!
                safe_log('info', 'Found cached node count for ' + xpath);
                return nodeCount;
            }
        }

        mirror.reflect();

        if (contextNode) {
            contextNode = mirror.getReflectedNode(contextNode);
        }

        // count the nodes using the test document, and circumvent
        // window RPC altogether
        var nodeCount = engine.setDocument(mirror.getReflection())
            .countNodes(xpath, contextNode, namespaceResolver);

        if (! optimization) {
            optimization = knownOptimizations.getOrCreate(originalHtml, xpath);
        }

        optimization.nodeCount = nodeCount;

        return nodeCount;
    };

    this.getKnownOptimizations = function() {
        return knownOptimizations;
    };
}
195219
function getRegExp(node) {

        if (node.value instanceof RegExp) {
            return node.value;
        } else if (typeof node.value === "string") {

            var parent = context.getAncestors().pop();
            if ((parent.type === "NewExpression" || parent.type === "CallExpression") &&
            parent.callee.type === "Identifier" && parent.callee.name === "RegExp") {

                // there could be an invalid regular expression string
                try {
                    return new RegExp(node.value);
                } catch (ex) {
                    return null;
                }

            }
        } else {
            return null;
        }

    }
706132
def get_function_body(self, func_indent):
        """"""
        cursor = self.code_editor.textCursor()
        line_number = cursor.blockNumber() + 1
        number_of_lines = self.code_editor.blockCount()
        body_list = []

        for idx in range(number_of_lines - line_number + 1):
            text = to_text_string(cursor.block().text())
            text_indent = get_indent(text)

            if text.strip() == '':
                pass
            elif len(text_indent) <= len(func_indent):
                break

            body_list.append(text)

            cursor.movePosition(QTextCursor.NextBlock)

        return '\n'.join(body_list)
243627
def match(self, expression=None, xpath=None, namespaces=None): 
        """"""
        class MatchObject(Dict):
            pass
        def _match(function):
            self.matches.append(
                MatchObject(expression=expression, xpath=xpath, function=function, namespaces=namespaces))
            def wrapper(self, *args, **params):
                return function(self, *args, **params)
            return wrapper
        return _match
798525
function _makeNodeTitleMatcher(s) {
		s = s.toLowerCase();
		return function(node) {
			return node.title.toLowerCase().indexOf(s) >= 0;
		};
	}