Evaluates string_, must evaluate to list of strings. Also converts field names to uppercase
541140
def eval_fieldnames(string_, varname="fieldnames"):
    """"""
    ff = eval(string_)
    if not isinstance(ff, list):
        raise RuntimeError("{0!s} must be a list".format(varname))
    if not all([isinstance(x, str) for x in ff]):
        raise RuntimeError("{0!s} must be a list of strings".format(varname))
    ff = [x.upper() for x in ff]
    return ff
896822
def eval_string_value(self, element, value):
        
        strval = ''
        vals = []

        for term in value:
            if type(term) is ast.WhitespaceToken:
                pass

            elif type(term) is ast.StringToken:
                strval += term.value

            elif type(term) is ast.IdentToken:
                log(DEBUG, u"IdentToken as string: {}".format(
                    term.value).encode('utf-8'))
                strval += term.value

            elif type(term) is ast.LiteralToken:
                log(DEBUG, u"LiteralToken as string: {}".format(
                    term.value).encode('utf-8'))
                strval += term.value

            elif type(term) is ast.FunctionBlock:
                if term.name == 'string':
                    str_args = split(term.arguments, ',')
                    str_name = self.eval_string_value(element,
                                                      str_args[0])[0]
                    val = self.lookup('strings', str_name)
                    if val == '':
                        if len(str_args) > 1:
                            val = self.eval_string_value(element,
                                                         str_args[1])[0]
                        else:
                            log(WARN, u"{} blank string"
                                .format(str_name).encode('utf-8'))
                    strval += val

                elif term.name == u'attr':
                    att_args = split(term.arguments, ',')
                    att_name = self.eval_string_value(element,
                                                      att_args[0])[0]
                    att_def = ''
                    if len(att_args) > 1:
                        att_def = self.eval_string_value(element,
                                                         att_args[1])[0]
                    if '|' in att_name:
                        ns, att = att_name.split('|')
                        try:
                            ns = self.css_namespaces[ns]
                        except KeyError:
                            log(WARN, u"Undefined namespace prefix {}"
                                .format(ns).encode('utf-8'))
                            continue
                        att_name = etree.QName(ns, att)
                    strval += element.etree_element.get(att_name, att_def)

                elif term.name == u'uuid':
                    strval += self.generate_id()

                elif term.name == u'content':
                    strval += etree.tostring(element.etree_element,
                                             encoding='unicode',
                                             method='text',
                                             with_tail=False)

                elif term.name.startswith('target-'):
                    if strval:
                        vals.append(strval)
                        strval = ''
                    target_args = split(term.arguments, ',')
                    vref = self.eval_string_value(element,
                                                  target_args[0])[0]
                    vname = self.eval_string_value(element,
                                                   target_args[1])[0]

                    vtype = term.name[7:]+'s'
                    vals.append(TargetVal(self, vref[1:], vname, vtype))

                elif term.name == u'first-letter':
                    tmpstr = self.eval_string_value(element, term.arguments)
                    if tmpstr:
                        if isinstance(tmpstr[0], basestring):
                            strval += tmpstr[0][0]
                        else:
                            log(WARN, u"Bad string value:"
                                u" nested target-* not allowed. "
                                u"{}".format(
                                    serialize(value)).encode(
                                        'utf-8'))

                    # FIXME can we do delayed first-letter

                elif term.name == 'counter':
                    counterargs = [serialize(t).strip(" \'")
                                   for t in split(term.arguments, ',')]
                    count = self.lookup('counters', counterargs)
                    strval += str(count)

                elif term.name == u'pending':
                    log(WARN, u"Bad string value: pending() not allowed. "
                        u"{}".format(serialize(value)).encode(
                                       'utf-8'))
                else:
                    log(WARN, u"Bad string value: unknown function: {}. "
                        u"{}".format(term.name, serialize(value)).encode(
                            'utf-8'))

        if strval:
            vals.append(strval)
        return vals
954309
def api_eval(expr_str)
      body = ["ver:\"#{@haystack_version}\""]
      body << "expr"
      body << '"'+expr_str+'"'
      res = self.connection.post('eval') do |req|
        req.headers['Content-Type'] = 'text/plain'
        req.body = body.join("\n")
      end
      JSON.parse! res.body
    end
1115348
protected String eval(final Object[] _values)
    {
        final String ret;
        if ((_values == null) || (_values.length == 0) || (_values[0] == null))  {
            ret = null;
        } else if (_values[0] instanceof String) {
            ret = (String) _values[0];
        } else if (_values[0] != null) {
            ret = _values[0].toString();
        } else  {
            ret = null;
        }
        return ret;
    }
649047
def _str_to_list(value, separator):
    """"""
    value_list = [item.strip() for item in value.split(separator)]
    value_list_sanitized = builtins.list(filter(None, value_list))
    if len(value_list_sanitized) > 0:
        return value_list_sanitized
    else:
        raise ValueError('Invalid list variable.')
951910
function nameValMatch(definedNameVals, lookupKey) {
    var keys = _.keys(definedNameVals),
        key,
        index;
    for (index in keys) {
        key = keys[index];
        if (key === lookupKey) {
            return {
                matchedWith: lookupKey,
                match: definedNameVals[key]
            };
        } else if (!definedNameVals[key].matchKeyCase && (key.toUpperCase() === (lookupKey.toUpperCase()))) {
            return {
                matchedWith: key,
                match: definedNameVals[key]
            };
        }
    }
    return null;
}
2634
def evaluate_strings(self, string, temp=False):
        """"""

        value = ''
        if self.strings:
            if self.decode_escapes:
                value = RE_SURROGATES.sub(
                    self.replace_surrogates,
                    (RE_TEMP_ESC if temp else RE_ESC).sub(self.replace_escapes, string)
                )
            else:
                value = string
            if not temp:
                self.quoted_strings.append([value, self.line_num, 'utf-8'])
        return value
1327093
def parse_fields(fields)
      if fields.blank?
        {}
      elsif fields =~ /^#{match_fields}$/
        fields.scan(/(#{match_field})(?:,|$)/).inject({}) do |m, match|
          m.merge(parse_field(match[0]))
        end
      else
        raise ArgumentError, "The fields string is not in the correct format.\n\n'#{fields}' did not match: #{match_fields}"
      end
    end
889876
def eval(lisp):
    '''
    
    '''
    macro_values = []
    if not isinstance(lisp, list):
        raise EvalError('eval root element must be a list')
    for item in lisp:
        if not isinstance(item, list):
            raise EvalError('must evaluate list of list')
        if not all(isinstance(i, str) for i in item):
            raise EvalError(
                'must evaluate list of list of strings. not a list of strings: {}'
                .format(item))
        name = item[0]
        args = item[1:]
        try:
            macro = state['macros'][name]
        except KeyError:
            raise MacroNotFoundError("macro {} not found".format(repr(name)))
        try:
            res = macro(*args)
        except Exception as exc:
            if os.getenv('PLASH_DEBUG', '').lower() in ('1', 'yes', 'true'):
                raise
            if isinstance(exc, MacroError):
                # only raise that one time and don't have multiple wrapped MacroError
                raise
            raise MacroError(macro, name, sys.exc_info())
        if not isinstance(res, str) and res is not None:
            raise EvalError(
                'eval macro must return string or None ({} returned {})'.
                format(name, type(res)))
        if res is not None:
            macro_values.append(res)
    return '\n'.join(macro_values)
634979
def clean(some_string, uppercase=False):
    
    if uppercase:
        return some_string.strip().upper()
    else:
        return some_string.strip().lower()
116512
function validateString(context, name, def, map) {
  var value = context[name]

  if (value == null) {
    value = def
  }

  value = String(value)

  if (!(value in map)) {
    raise(value, 'options.' + name)
  }

  context[name] = value
}
87024
def eval_string_type(self, text, is_string=False):
        """"""

        stype = set()
        wstype = set()

        for m in RE_ITER_STRING_TYPES.finditer(text):
            value = m.group(0)
            if value == '*':
                wstype.add('u')
                wstype.add('f')
                wstype.add('r')
                wstype.add('b')
            elif value.endswith('*'):
                wstype.add(value[0].lower())
            else:
                stype.add(value.lower())

        if is_string and 'b' not in stype and 'f' not in stype:
            stype.add('u')

        return stype, wstype
1230723
def _normalize_coerce_to_field_dict(self, v):
        

        def tokenize(s):
            """ Tokenize a string by splitting it by + and -

            >>> tokenize('this + that')
            ['this', '+', 'that']

            >>> tokenize('this+that')
            ['this', '+', 'that']

            >>> tokenize('this+that-other')
            ['this', '+', 'that', '-', 'other]
            """

            # Crude tokenization
            s = s.replace('+', ' + ').replace('-', ' - ') \
                .replace('/', ' / ').replace('*', ' * ')
            words = [w for w in s.split(' ') if w]
            return words

        if isinstance(v, _str_type):
            field_parts = tokenize(v)
            field = field_parts[0]
            d = {'value': field}
            if len(field_parts) > 1:
                # if we need to add and subtract from the field join the field
                # parts into pairs, for instance if field parts is
                #     [MyTable.first, '-', MyTable.second, '+', MyTable.third]
                # we will get two pairs here
                #     [('-', MyTable.second), ('+', MyTable.third)]
                d['operators'] = []
                for operator, other_field in zip(
                    field_parts[1::2], field_parts[2::2]
                ):
                    d['operators'].append({
                        'operator': operator,
                        'field': {
                            'value': other_field
                        }
                    })
            return d
        else:
            return v
507703
function evalString(text) {
      if (text.lastIndexOf('\\') < 0)
        return text;
      return text.replace(/\\\\/g, '\\')
                 .replace(/\\n/g, '\n')
                 .replace(/\\r/g, '\r')
                 .replace(/\\t/g, '\t')
                 .replace(/\\b/g, '\b')
                 .replace(/\\f/g, '\f')
                 .replace(/\\{/g, '{')
                 .replace(/\\}/g, '}')
                 .replace(/\\"/g, '"')
                 .replace(/\\'/g, "'");
    }
1248897
def expr(str):
    
    sc = SparkContext._active_spark_context
    return Column(sc._jvm.functions.expr(str))
839727
def make_checks(self, string_checks):
        
        checks = {}
        for key, value in string_checks.items():
            is_pyname = not key.endswith('.object') and \
                not key.endswith('.type')
            evaluated = self._evaluate(value, is_pyname=is_pyname)
            if evaluated is not None:
                checks[key] = evaluated
        return checks
1033152
Object evaluateIndex(Object pContext,
                         VariableResolver pResolver,
                         Map functions,
                         String defaultPrefix,
                         Logger pLogger)
            throws ELException {
        return mName;
    }