Process the None-coalescing operator.
179539
def none_coalesce_handle(tokens):
    """"""
    if len(tokens) == 1:
        return tokens[0]
    elif tokens[0].isalnum():
        return "({b} if {a} is None else {a})".format(
            a=tokens[0],
            b=none_coalesce_handle(tokens[1:]),
        )
    else:
        return "(lambda {x}: {b} if {x} is None else {x})({a})".format(
            x=none_coalesce_var,
            a=tokens[0],
            b=none_coalesce_handle(tokens[1:]),
        )
95316
def _prohibited(from_op, to_op):
    ""
    # 'not' can only be removed but not replaced with
    # '+', '-' or '~' b/c that may lead to strange results
    if from_op is UnaryOperators.Not:
        if to_op is not UnaryOperators.Nothing:
            return True

    # '+1' => '1' yields equivalent mutations
    if from_op is UnaryOperators.UAdd:
        if to_op is UnaryOperators.Nothing:
            return True

    return False
155903
function processOperators (ops) {
    if (!ops) return {};
    var operators = {};
    for (var i=0,k,prec;prec=ops[i]; i++) {
        for (k=1;k < prec.length;k++) {
            operators[prec[k]] = {precedence: i+1, assoc: prec[0]};
        }
    }
    return operators;
}
810429
def _none():
    """"""

    Mock = type("Mock", (), {"__getattr__": lambda Qt, attr: None})

    Qt.__binding__ = "None"
    Qt.__qt_version__ = "0.0.0"
    Qt.__binding_version__ = "0.0.0"
    Qt.QtCompat.loadUi = lambda uifile, baseinstance=None: None
    Qt.QtCompat.setSectionResizeMode = lambda *args, **kwargs: None

    for submodule in _common_members.keys():
        setattr(Qt, submodule, Mock())
        setattr(Qt, "_" + submodule, Mock())
325067
public function process()
    {
        $operands = $this->getOperands();

        if (($c = count($operands)) < 2) {
            $msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator takes 2 sub-expressions as parameters, ${c} given.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::NOT_ENOUGH_OPERANDS);
        } elseif ($operands->containsNull() === true) {
            return null;
        } elseif ($operands->exclusivelyString() === false) {
            $msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts operands with a string baseType.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        } elseif ($operands[0]->getCardinality() !== Cardinality::SINGLE) {
            $msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts a first operand with single cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        } elseif ($operands[1]->getCardinality() !== Cardinality::MULTIPLE && $operands[1]->getCardinality() !== Cardinality::ORDERED) {
            $msg = "The 'qtism.runtime.expressions.operators.custom.Implode' custom operator only accepts a second operand with multiple or ordered cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        $glue = $operands[0]->getValue();
        $pieces = $operands[1];

        // Note: implode() is binary-safe \0/!
        $string = implode($glue, $pieces->getArrayCopy());

        return new QtiString($string);
    }
950891
public function process()
    {
        $operands = $this->getOperands();

        if ($operands->containsNull() === true) {
            return null;
        }

        if ($operands->exclusivelySingle() === false) {
            $msg = "The Equal operator only accepts operands with a single cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        if ($operands->exclusivelyNumeric() === false) {
            $msg = "The Equal operator only accepts operands with an integer or float baseType";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        }

        $operand1 = $operands[0];
        $operand2 = $operands[1];
        $expression = $this->getExpression();

        if ($expression->getToleranceMode() === ToleranceMode::EXACT) {
            return new QtiBoolean($operand1->getValue() == $operand2->getValue());
        } else {
            $tolerance = $expression->getTolerance();

            if (gettype($tolerance[0]) === 'string') {
                $strTolerance = $tolerance;
                $tolerance = array();

                // variableRef to handle.
                $state = $this->getState();
                $tolerance0Name = Utils::sanitizeVariableRef($strTolerance[0]);
                $varValue = $state[$tolerance0Name];

                if (is_null($varValue)) {
                    $msg = "The variable with name '${tolerance0Name}' could not be resolved.";
                    throw new OperatorProcessingException($msg, $this, OperatorProcessingException::NONEXISTENT_VARIABLE);
                } elseif (!$varValue instanceof QtiFloat) {
                    $msg = "The variable with name '${tolerance0Name}' is not a float.";
                    throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_VARIABLE_BASETYPE);
                }

                $tolerance[] = $varValue->getValue();

                if (isset($strTolerance[1]) && gettype($strTolerance[1]) === 'string') {
                    // A second variableRef to handle.
                    $tolerance1Name = Utils::sanitizeVariableRef($strTolerance[1]);

                    if (($varValue = $state[$tolerance1Name]) !== null && $varValue instanceof QtiFloat) {
                        $tolerance[] = $varValue->getValue();
                    }
                }
            }

            if ($expression->getToleranceMode() === ToleranceMode::ABSOLUTE) {

                $t0 = $operand1->getValue() - $tolerance[0];
                $t1 = $operand1->getValue() + ((isset($tolerance[1])) ? $tolerance[1] : $tolerance[0]);

                $moreThanLower = ($expression->doesIncludeLowerBound()) ? $operand2->getValue() >= $t0 : $operand2->getValue() > $t0;
                $lessThanUpper = ($expression->doesIncludeUpperBound()) ? $operand2->getValue() <= $t1 : $operand2->getValue() < $t1;

                return new QtiBoolean($moreThanLower && $lessThanUpper);
            } else {
                // Tolerance mode RELATIVE
                $tolerance = $expression->getTolerance();
                $t0 = $operand1->getValue() * (1 - $tolerance[0] / 100);
                $t1 = $operand1->getValue() * (1 + ((isset($tolerance[1])) ? $tolerance[1] : $tolerance[0]) / 100);

                $moreThanLower = ($expression->doesIncludeLowerBound()) ? $operand2->getValue() >= $t0 : $operand2->getValue() > $t0;
                $lessThanUpper = ($expression->doesIncludeUpperBound()) ? $operand2->getValue() <= $t1 : $operand2->getValue() < $t1;

                return new QtiBoolean($moreThanLower && $lessThanUpper);
            }
        }
    }
1351760
function process( $tpl, &$value, $nspace, $current_nspace )
    {
        $named_params = array();
        $param_list = $tpl->operatorParameterList( $this->Name );
        $i = 0;
        foreach ( $param_list as $param_name => $param_type )
        {
            if ( !isset( $this->Params[$i] ) or
                 $this->Params[$i]["type"] == "null" )
            {
                if ( $param_type["required"] )
                {
                    $tpl->warning( "eZTemplateOperatorElement", "Parameter '$param_name' ($i) missing" );
                    $named_params[$param_name] = $param_type["default"];
                }
                else
                {
                    $named_params[$param_name] = $param_type["default"];
                }
            }
            else
            {
                $param_data = $this->Params[$i];
                $named_params[$param_name] = $tpl->elementValue( $param_data, $nspace );
            }
            ++$i;
        }
        if ( $param_list !== null )
            $tpl->doOperator( $this, $nspace, $current_nspace, $value, $this->Name, $this->Params, $named_params );
        else
            $tpl->doOperator( $this, $nspace, $current_nspace, $value, $this->Name, $this->Params );
    }
195210
private void processNonOptionToken(String value, boolean stopAtNonOption)
    {
        if (stopAtNonOption && (currentOption == null || !currentOption.hasArg()))
        {
            eatTheRest = true;
            tokens.add("--");
        }

        tokens.add(value);
        currentOption = null;
    }
1183185
public function process()
    {
        $operands = $this->getOperands();

        if ($operands->containsNull() === true) {
            return null;
        }

        if ($operands->exclusivelyMultipleOrOrdered() === false) {
            $msg = "The StatsOperator operator only accepts operands with a multiple or ordered cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        if ($operands->exclusivelyNumeric() === false) {
            $msg = "The StatsOperator operator only accepts operands with a multiple or ordered cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        }

        $qtiFuncName = Statistics::getNameByConstant($this->getExpression()->getName());
        $methodName = 'process' . ucfirst($qtiFuncName);

        return call_user_func_array(array($this, $methodName), array());
    }
889554
public function process()
    {
        $operands = $this->getOperands();

        if ($operands->containsNull() === true) {
            return null;
        }

        if ($operands->exclusivelySingle() === false) {
            $msg = "The Inside operator only accepts operands with a single cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        if ($operands->exclusivelyPoint() === false) {
            $msg = "The Inside operator only accepts operands with a baseType of point.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        }

        $operand = $operands[0];
        $coords = $this->getExpression()->getCoords();

        return new QtiBoolean($coords->inside($operand));
    }
1028408
def eval_nonagg_call(self, exp):
    ""
    # todo: get more concrete about argument counts
    args=self.eval(exp.args)
    if exp.f=='coalesce':
      a,b=args # todo: does coalesce take more than 2 args?
      return b if a is None else a
    elif exp.f=='unnest': return self.eval(exp.args)[0] # note: run_select does some work in this case too
    elif exp.f in ('to_tsquery','to_tsvector'): return set(self.eval(exp.args.children[0]).split())
    else: raise NotImplementedError('unk_function',exp.f)
1358471
def skipNullPadding(self, buff):
        '''
        
        '''
        def readNext(buff, first_run=True):
            datas = unpack('<i', buff.read(4))
            header = datas[0]

            if header == CHUNK_NULL_TYPE and first_run:
                print("Skipping null padding in StringPoolChunk header")
                header = readNext(buff, first_run=False)
            elif header != CHUNK_STRINGPOOL_TYPE:
                print("Invalid StringPoolChunk header")

            return header

        header = readNext(buff)
        return header >> 8, header & 0xFF
101953
def noop(*layers):
    """"""

    def begin_update(X, drop=0.0):
        return X, lambda D, *a, **k: D

    return begin_update
914160
def nexec(statement, globals=None, locals=None, **kwargs):
    """"""

    try:
        import __builtin__ as builtins
    except ImportError:
        import builtins

    from ast import parse
    from napi.transformers import NapiTransformer
    from ast import fix_missing_locations as fml
    try:
        node = parse(statement, '<string>', 'exec')
    except ImportError:#KeyError:
        exec(statement)
    else:
        if globals is None:
            globals = builtins.globals()
        if locals is None:
            locals = {}
        trans = NapiTransformer(globals=globals, locals=locals, **kwargs)
        trans.visit(node)
        code = compile(fml(node), '<string>', 'exec')
        return builtins.eval(code, globals, locals)
1215277
def _filter_none(items):
    """"""
    type_ = list if isinstance(items, list) else tuple
    return type_(filter(_not_none, items))
200919
def _lt_from_gt(self, other):
    """"""
    op_result = self.__gt__(other)
    if op_result is NotImplemented:
        return NotImplemented
    return not op_result and self != other
688400
def selectisnot(table, field, value, complement=False):
    """"""

    return selectop(table, field, value, operator.is_not, complement=complement)