Wrap keyvalue embedded variable in double quotes.

        Args:
            data (string): The data with embedded variables.

        Returns:
            (string): Results retrieved from DB
551499
def wrap_embedded_keyvalue(self, data):
        
        if data is not None:
            try:
                data = u'{}'.format(data)
                # variables = re.findall(self._vars_keyvalue_embedded, u'{}'.format(data))
            except UnicodeEncodeError:
                # variables = re.findall(self._vars_keyvalue_embedded, data)
                pass

            variables = []
            for v in re.finditer(self._vars_keyvalue_embedded, data):
                variables.append(v.group(0))

            for var in set(variables):  # recursion over set to handle duplicates
                # pull (#App:1441:embedded_string!String) from (": #App:1441:embedded_string!String)
                variable_string = re.search(self._variable_parse, var).group(0)
                # reformat to replace the correct instance only, handling the case where a variable
                # is embedded multiple times in the same key value array.
                data = data.replace(var, '": "{}"'.format(variable_string))
        return data
1058516
def create_key_for_data(prefix, data, key_params):
    
    d = data.get_data()
    values = []
    for k in key_params:
        if k in d and type(d[k]) is list:
            values.append("{0}:{1}".format(k, " -".join(d[k])))
        else:
            value = d[k] if k in d else ''
            values.append("{0}:{1}".format(k, value))

    return "{0}-{1}".format(prefix, "-".join(values))
28543
def paste_as(self, key, data):
        

        def error_msg(err):
            msg = _("Error evaluating data: ") + str(err)
            post_command_event(self.main_window, self.StatusBarMsg, text=msg)

        interfaces = self.main_window.interfaces
        key = self.main_window.grid.actions.cursor

        try:
            obj = ast.literal_eval(data)

        except (SyntaxError, AttributeError):
            # This is no Python code so te try to interpret it as paste data
            try:
                obj = [map(ast.literal_eval, line.split("\t"))
                       for line in data.split("\n")]

            except Exception, err:
                # This must just be text.
                try:
                    obj = [line.split('\t') for line in data.split('\n')]
                except Exception, err:
                    # Now I really have no idea
                    error_msg(err)
                    return

        except ValueError, err:
            error_msg(err)
            return

        parameters = interfaces.get_pasteas_parameters_from_user(obj)

        if parameters is None:
            # Dialog aborted
            return

        paste_data = self._get_pasteas_data(parameters["dim"], obj)

        if parameters["transpose"]:
            paste_data = zip(*paste_data)

        self.main_window.grid.actions.paste(key, paste_data, freq=1000)
390714
def _compile_value(self, data, indent_level):
        """"""
        if isinstance(data, dict):
            return self._compile_key_val(data, indent_level)
        elif isinstance(data, list):
            return self._compile_list(data, indent_level)
        else:
            return self._compile_literal(data)
144481
def url_param2value(param):
    
    if param == None:
        return Null
    if param == None:
        return Null

    def _decode(v):
        output = []
        i = 0
        while i < len(v):
            c = v[i]
            if c == "%":
                d = hex2chr(v[i + 1:i + 3])
                output.append(d)
                i += 3
            else:
                output.append(c)
                i += 1

        output = text_type("".join(output))
        try:
            return json2value(output)
        except Exception:
            pass
        return output

    query = Data()
    for p in param.split('&'):
        if not p:
            continue
        if p.find("=") == -1:
            k = p
            v = True
        else:
            k, v = p.split("=")
            v = _decode(v)

        u = query.get(k)
        if u is None:
            query[k] = v
        elif is_list(u):
            u += [v]
        else:
            query[k] = [u, v]

    return query
929492
function getQueryString(data) {
    if (!data || typeof data !== 'object' || !Object.keys(data).length)
        return '';
    return '?' + Object.keys(data).map((k) => {
        const value = (typeof data[k] === 'object')
            ? JSON.stringify(data[k])
            : encodeURIComponent(data[k]);
        return `${encodeURIComponent(k)}=${value}`;
    }).join('&');
}
251052
def _format_param_value(key, value):
    
    if isinstance(value, str):
        value = "'{}'".format(value)
    return "{}={}".format(key, value)
921286
def quote_attrval (s):
    
    res = []
    for c in s:
        if ord(c) <= 127:
            # ASCII
            if c == u'&':
                res.append(u"&amp;")
            elif c == u'"':
                res.append(u"&quot;")
            else:
                res.append(c)
        else:
            res.append(u"&#%d;" % ord(c))
    return u"".join(res)
876299
def _parse_quoted_key(self):  # type: () -> Key
        
        quote_style = self._current
        key_type = None
        dotted = False
        for t in KeyType:
            if t.value == quote_style:
                key_type = t
                break

        if key_type is None:
            raise RuntimeError("Should not have entered _parse_quoted_key()")

        self.inc()
        self.mark()

        while self._current != quote_style and self.inc():
            pass

        key = self.extract()

        if self._current == ".":
            self.inc()
            dotted = True
            key += "." + self._parse_key().as_string()
            key_type = KeyType.Bare
        else:
            self.inc()

        return Key(key, key_type, "", dotted)
1120681
def _maybe_quote(val):
    ''''''
    assert isinstance(val, str), 'We should never set non-string values.'
    needs_quoting = False
    try:
        int(val)
        needs_quoting = True
    except Exception:
        pass
    try:
        float(val)
        needs_quoting = True
    except Exception:
        pass
    if needs_quoting:
        return '"{}"'.format(val)
    else:
        return val
865914
def escape(value):
    

    if isinstance(value, (tuple, list)):
        return "(" + ", ".join([escape(arg) for arg in value]) + ")"
    else:
        typ = by_python_type.get(value.__class__)
        if typ is None:
            raise InterfaceError(
                "Unsupported python input: %s (%s)" % (value, value.__class__)
            )

        return typ.to_sql(value)
16988
def extract_value(self, data):
        
        if self.name not in data and not self.allow_missing:
            raise exceptions.FieldNotFound('Field {} is missing from request'.format(self.name))
        
        if self.multiple_inputs:
            self.value = []
            for value in data.getlist(self.name):
                if self.strip_value:
                    value = value.strip()
                if value == '' and self.convert_empty_to_none:
                    value = None

                self.value.append(value)
        else:
            self.value = data.get(self.name)
            if self.value is not None:
                if self.strip_value:
                    self.value = self.value.strip()
                if self.value == '' and self.convert_empty_to_none:
                    self.value = None

        # Convert the value to the correct data type
        self.convert_value()
958658
public static String escapeString(String data) {
    return StringUtils.escapeString(data, StringUtils.ESCAPE_CHAR, 
                                    charsToEscape);
  }
1371328
def quote(value, column = nil)
      return value.quoted_id if value.respond_to?(:quoted_id)

      if column && column.type == :primary_key
        value.to_s
      elsif column && String === value && column.type == :binary && column.class.respond_to?(:string_to_binary)
        s = column.class.string_to_binary(value).unpack("H*")[0]
        "x'#{s}'"
      elsif BigDecimal === value
        "'#{value.to_s("F")}'"
      else
        super
      end
    end
609100
def create_string_array(self, key, value):
        
        data = None
        if key is not None and value is not None:
            if isinstance(value, (list)):
                data = self.db.create(key.strip(), json.dumps(value))
            else:
                # used to save raw value with embedded variables
                data = self.db.create(key.strip(), value)
        else:
            self.tcex.log.warning(u'The key or value field was None.')
        return data
711931
def build_query_string(self, data):
        
        query_params = []
        keys_to_be_removed = []
        for key, value in data.items():
            if key not in ['version', 'restApi', 'resourcePath']:
                if key == 'addressLine':
                    query_params.append('{0}={1}'.format(key,
                                                         quote(value)))
                    keys_to_be_removed.append(key)
                else:
                    query_params.append('{0}={1}'.format(key,
                                                         value))
                    keys_to_be_removed.append(key)
        data['query'] = "&".join(query_params)
        for k in keys_to_be_removed:
            del data[k]
        return data
212031
def urlquote(val):
    
    if val is None: return ''
    if not isinstance(val, unicode): val = str(val)
    else: val = val.encode('utf-8')
    return urllib.quote(val)