示例#1
0
    def _encode(self):
        res_d = []

        for k, v in self._real_options.items():
            if v is UNSPEC:
                continue

            if not self.passthrough:
                k = ulp.quote(k)
                v = ulp.quote(v)

            res_d.append("{0}={1}".format(k, v))

        for k, v in self._extra_options.items():
            res_d.append("{0}={1}".format(k, v))

        return '&'.join(res_d)
示例#2
0
    def _encode(self):
        res_d = []

        for k, v in self._real_options.items():
            if v is UNSPEC:
                continue

            if not self.passthrough:
                k = ulp.quote(k)
                v = ulp.quote(v)

            res_d.append("{0}={1}".format(k, v))

        for k, v in self._extra_options.items():
            res_d.append("{0}={1}".format(k, v))

        return "&".join(res_d)
    def _encode(self, omit_keys=False):
        res_d = []

        for k, v in self._real_options.items():
            if v is UNSPEC:
                continue

            if omit_keys and k == "keys":
                continue

            if not self.passthrough:
                k = ulp.quote(k)
                v = ulp.quote(v)

            res_d.append("{0}={1}".format(k, v))

        for k, v in self._extra_options.items():
            res_d.append("{0}={1}".format(k, v))

        return '&'.join(res_d)
示例#4
0
def _string_param_common(input, do_quote=False):
    # TODO, if we pass this to urlencode, do we ever need to quote?
    # For the moment, i'm always forcing non-quote behavior
    do_quote = False

    s = None
    if isinstance(input, basestring):
        s = input

    elif isinstance(input, bool):
        raise ArgumentError.pyexc("Can't use boolean as string", input)

    elif isinstance(input, (int, long, float)):
        # Basic numeric types:
        s = str(input)

    else:
        raise ArgumentError.pyexc("Expected simple numeric type or string ", input)
    if do_quote:
        s = ulp.quote(s)

    return s
示例#5
0
def _string_param_common(input, do_quote=False):
    # TODO, if we pass this to urlencode, do we ever need to quote?
    # For the moment, i'm always forcing non-quote behavior
    do_quote = False

    s = None
    if isinstance(input, basestring):
        s = input

    elif isinstance(input, bool):
        raise ArgumentError.pyexc("Can't use boolean as string", input)

    elif isinstance(input, (int, long, float)):
        # Basic numeric types:
        s = str(input)

    else:
        raise ArgumentError.pyexc("Expected simple numeric type or string ",
                                  input)
    if do_quote:
        s = ulp.quote(s)

    return s
示例#6
0
    def _mk_formstr(self, d):
        l = []
        for k, v in d.items():
            l.append('{0}={1}'.format(ulp.quote(k), ulp.quote(str(v))))

        return '&'.join(l)
    def _mk_formstr(self, d):
        l = []
        for k, v in d.items():
            l.append('{0}={1}'.format(ulp.quote(k), ulp.quote(str(v))))

        return '&'.join(l)