• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.utf8函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stripe.util.utf8函数的典型用法代码示例。如果您正苦于以下问题:Python utf8函数的具体用法?Python utf8怎么用?Python utf8使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了utf8函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: instance_url

    def instance_url(self):
        self.id = util.utf8(self.id)
        extn = urllib.quote_plus(self.id)
        if hasattr(self, "customer"):
            customer = util.utf8(self.customer)

            base = Customer.class_url()
            owner_extn = urllib.quote_plus(customer)
            class_base = "sources"

        elif hasattr(self, "recipient"):
            recipient = util.utf8(self.recipient)

            base = Recipient.class_url()
            owner_extn = urllib.quote_plus(recipient)
            class_base = "cards"

        elif hasattr(self, "account"):
            account = util.utf8(self.account)

            base = Account.class_url()
            owner_extn = urllib.quote_plus(account)
            class_base = "external_accounts"

        else:
            raise error.InvalidRequestError(
                "Could not determine whether card_id %s is "
                "attached to a customer, recipient, or "
                "account." % self.id,
                "id",
            )

        return "%s/%s/%s/%s" % (base, owner_extn, class_base, extn)
开发者ID:brianmc,项目名称:stripe-python,代码行数:33,代码来源:resource.py


示例2: instance_url

 def instance_url(self):
     token = util.utf8(self.id)
     transfer = util.utf8(self.transfer)
     base = Transfer.class_url()
     cust_extn = urllib.quote_plus(transfer)
     extn = urllib.quote_plus(token)
     return "%s/%s/reversals/%s" % (base, cust_extn, extn)
开发者ID:VladStm,项目名称:try,代码行数:7,代码来源:resource.py


示例3: instance_url

 def instance_url(self):
     token = util.utf8(self.id)
     schedule = util.utf8(self.schedule)
     base = SubscriptionSchedule.class_url()
     schedule_extn = quote_plus(schedule)
     extn = quote_plus(token)
     return "%s/%s/revisions/%s" % (base, schedule_extn, extn)
开发者ID:stripe,项目名称:stripe-python,代码行数:7,代码来源:subscription_schedule_revision.py


示例4: instance_url

 def instance_url(self):
     token = util.utf8(self.id)
     account = util.utf8(self.account)
     base = Account.class_url()
     acct_extn = quote_plus(account)
     extn = quote_plus(token)
     return "%s/%s/persons/%s" % (base, acct_extn, extn)
开发者ID:stripe,项目名称:stripe-python,代码行数:7,代码来源:person.py


示例5: instance_url

    def instance_url(self):
        token = util.utf8(self.id)
        extn = quote_plus(token)
        if hasattr(self, "customer"):
            customer = util.utf8(self.customer)

            base = Customer.class_url()
            owner_extn = quote_plus(customer)
            class_base = "sources"

        elif hasattr(self, "account"):
            account = util.utf8(self.account)

            base = Account.class_url()
            owner_extn = quote_plus(account)
            class_base = "external_accounts"

        else:
            raise error.InvalidRequestError(
                "Could not determine whether bank_account_id %s is "
                "attached to a customer or an account." % token,
                "id",
            )

        return "%s/%s/%s/%s" % (base, owner_extn, class_base, extn)
开发者ID:stripe,项目名称:stripe-python,代码行数:25,代码来源:bank_account.py


示例6: instance_url

    def instance_url(self):
        self.id = util.utf8(self.id)
        self.customer = util.utf8(self.customer)

        base = Customer.class_url()
        cust_extn = urllib.quote_plus(self.customer)
        extn = urllib.quote_plus(self.id)

        return "%s/%s/subscriptions/%s" % (base, cust_extn, extn)
开发者ID:bluehack,项目名称:stripe-python,代码行数:9,代码来源:resource.py


示例7: instance_url

    def instance_url(self):
        token = util.utf8(self.id)
        extn = urllib.quote_plus(token)
        customer = util.utf8(self.customer)

        base = Customer.class_url()
        owner_extn = urllib.quote_plus(customer)

        return "%s/%s/sources/%s" % (base, owner_extn, extn)
开发者ID:Dipenjethva19,项目名称:MVPskillshare,代码行数:9,代码来源:resource.py


示例8: instance_url

    def instance_url(self):
        token = util.utf8(self.id)
        extn = urllib.parse.quote_plus(token)

        if (hasattr(self, 'customer')):
            customer = util.utf8(self.customer)
            base = Customer.class_url()
            cust_extn = urllib.parse.quote_plus(customer)
            return "%s/%s/sources/%s" % (base, cust_extn, extn)
        else:
            base = BitcoinReceiver.class_url()
            return "%s/%s" % (base, extn)
开发者ID:colehertz,项目名称:Stripe-Tester,代码行数:12,代码来源:resource.py


示例9: verify

    def verify(self, idempotency_key=None, **params):
        headers = populate_headers(idempotency_key)
        extn = urllib.quote_plus(util.utf8(self.id))
        if (hasattr(self, 'customer')):
            customer = util.utf8(self.customer)
            base = Customer.class_url()
            owner_extn = urllib.quote_plus(customer)
            class_base = "bank_accounts"
            url = "%s/%s/%s/%s/verify" % (base, owner_extn, class_base, extn)
            self.refresh_from(self.request('post', url, params, headers))
        else:
            raise NotImplementedError(
                "Can't verify bank account not attached to customer")

        return self
开发者ID:HireAnEsquire,项目名称:stripe-python,代码行数:15,代码来源:resource.py


示例10: request

    def request(self, method, url, headers, post_data=None):
        s = util.StringIO.StringIO()
        rheaders = util.StringIO.StringIO()
        curl = pycurl.Curl()

        if method == 'get':
            curl.setopt(pycurl.HTTPGET, 1)
        elif method == 'post':
            curl.setopt(pycurl.POST, 1)
            curl.setopt(pycurl.POSTFIELDS, post_data)
        else:
            curl.setopt(pycurl.CUSTOMREQUEST, method.upper())

        # pycurl doesn't like unicode URLs
        curl.setopt(pycurl.URL, util.utf8(url))

        curl.setopt(pycurl.WRITEFUNCTION, s.write)
        curl.setopt(pycurl.HEADERFUNCTION, rheaders.write)
        curl.setopt(pycurl.NOSIGNAL, 1)
        curl.setopt(pycurl.CONNECTTIMEOUT, 30)
        curl.setopt(pycurl.TIMEOUT, 80)
        curl.setopt(pycurl.HTTPHEADER, ['%s: %s' % (k, v)
                    for k, v in headers.iteritems()])
        if self._verify_ssl_certs:
            curl.setopt(pycurl.CAINFO, os.path.join(
                os.path.dirname(__file__), 'data/ca-certificates.crt'))
        else:
            curl.setopt(pycurl.SSL_VERIFYHOST, False)

        try:
            curl.perform()
        except pycurl.error, e:
            self._handle_request_error(e)
开发者ID:agentcoops,项目名称:stripe-python,代码行数:33,代码来源:http_client.py


示例11: instance_url

    def instance_url(self):
        self.id = util.utf8(self.id)
        extn = urllib.quote_plus(self.id)
        if (hasattr(self, 'customer')):
            self.customer = util.utf8(self.customer)

            base = Customer.class_url()
            owner_extn = urllib.quote_plus(self.customer)

        else:
            raise error.InvalidRequestError(
                "Could not determine whether bank_id %s is "
                "attached to a customer "
                "or a recipient." % self.id, 'id')

        return "%s/%s/bank_accounts/%s" % (base, owner_extn, extn)
开发者ID:catskul,项目名称:stripe-python,代码行数:16,代码来源:resource.py


示例12: detach

    def detach(self, idempotency_key=None, **params):
        if hasattr(self, 'customer') and self.customer:
            extn = quote_plus(util.utf8(self.id))
            customer = util.utf8(self.customer)
            base = Customer.class_url()
            owner_extn = quote_plus(customer)
            url = "%s/%s/sources/%s" % (base, owner_extn, extn)
            headers = util.populate_headers(idempotency_key)

            self.refresh_from(self.request('delete', url, params, headers))
            return self

        else:
            raise NotImplementedError(
                "This source object does not appear to be currently attached "
                "to a customer object.")
开发者ID:cnicodeme,项目名称:stripe-python,代码行数:16,代码来源:source.py


示例13: retrieve

    def retrieve(self, id, **params):
        base = self.get('url')
        id = util.utf8(id)
        extn = urllib.quote_plus(id)
        url = "%s/%s" % (base, extn)

        return self.request('get', url, params)
开发者ID:bluehack,项目名称:stripe-python,代码行数:7,代码来源:resource.py


示例14: retrieve

    def retrieve(self, id, **params):
        base = self.get("url")
        id = util.utf8(id)
        extn = quote_plus(id)
        url = "%s/%s" % (base, extn)

        return self.request("get", url, params)
开发者ID:stripe,项目名称:stripe-python,代码行数:7,代码来源:list_object.py


示例15: request

    def request(self, method, url, headers, post_data=None):
        b = util.io.BytesIO()
        rheaders = util.io.BytesIO()

        # Pycurl's design is a little weird: although we set per-request
        # options on this object, it's also capable of maintaining established
        # connections. Here we call reset() between uses to make sure it's in a
        # pristine state, but notably reset() doesn't reset connections, so we
        # still get to take advantage of those by virtue of re-using the same
        # object.
        self._curl.reset()

        proxy = self._get_proxy(url)
        if proxy:
            if proxy.hostname:
                self._curl.setopt(pycurl.PROXY, proxy.hostname)
            if proxy.port:
                self._curl.setopt(pycurl.PROXYPORT, proxy.port)
            if proxy.username or proxy.password:
                self._curl.setopt(
                    pycurl.PROXYUSERPWD,
                    "%s:%s" % (proxy.username, proxy.password),
                )

        if method == "get":
            self._curl.setopt(pycurl.HTTPGET, 1)
        elif method == "post":
            self._curl.setopt(pycurl.POST, 1)
            self._curl.setopt(pycurl.POSTFIELDS, post_data)
        else:
            self._curl.setopt(pycurl.CUSTOMREQUEST, method.upper())

        # pycurl doesn't like unicode URLs
        self._curl.setopt(pycurl.URL, util.utf8(url))

        self._curl.setopt(pycurl.WRITEFUNCTION, b.write)
        self._curl.setopt(pycurl.HEADERFUNCTION, rheaders.write)
        self._curl.setopt(pycurl.NOSIGNAL, 1)
        self._curl.setopt(pycurl.CONNECTTIMEOUT, 30)
        self._curl.setopt(pycurl.TIMEOUT, 80)
        self._curl.setopt(
            pycurl.HTTPHEADER,
            ["%s: %s" % (k, v) for k, v in six.iteritems(dict(headers))],
        )
        if self._verify_ssl_certs:
            self._curl.setopt(pycurl.CAINFO, stripe.ca_bundle_path)
        else:
            self._curl.setopt(pycurl.SSL_VERIFYHOST, False)

        try:
            self._curl.perform()
        except pycurl.error as e:
            self._handle_request_error(e)
        rbody = b.getvalue().decode("utf-8")
        rcode = self._curl.getinfo(pycurl.RESPONSE_CODE)
        headers = self.parse_headers(rheaders.getvalue().decode("utf-8"))

        return rbody, rcode, headers
开发者ID:stripe,项目名称:stripe-python,代码行数:58,代码来源:http_client.py


示例16: _api_encode

def _api_encode(data):
    for key, value in data.iteritems():
        key = util.utf8(key)
        if value is None:
            continue
        elif hasattr(value, 'stripe_id'):
            yield (key, value.stripe_id)
        elif isinstance(value, list) or isinstance(value, tuple):
            for subvalue in value:
                yield ("%s[]" % (key,), util.utf8(subvalue))
        elif isinstance(value, dict):
            subdict = dict(('%s[%s]' % (key, subkey), subvalue) for
                           subkey, subvalue in value.iteritems())
            for subkey, subvalue in _api_encode(subdict):
                yield (subkey, subvalue)
        elif isinstance(value, datetime.datetime):
            yield (key, _encode_datetime(value))
        else:
            yield (key, util.utf8(value))
开发者ID:JamesX88,项目名称:tes,代码行数:19,代码来源:api_requestor.py


示例17: detach

    def detach(self, idempotency_key=None, **params):
        token = util.utf8(self.id)

        if hasattr(self, "customer") and self.customer:
            extn = quote_plus(token)
            customer = util.utf8(self.customer)
            base = Customer.class_url()
            owner_extn = quote_plus(customer)
            url = "%s/%s/sources/%s" % (base, owner_extn, extn)
            headers = util.populate_headers(idempotency_key)

            self.refresh_from(self.request("delete", url, params, headers))
            return self

        else:
            raise error.InvalidRequestError(
                "Source %s does not appear to be currently attached "
                "to a customer object." % token,
                "id",
            )
开发者ID:stripe,项目名称:stripe-python,代码行数:20,代码来源:source.py


示例18: instance_url

    def instance_url(self):
        self.id = util.utf8(self.id)
        extn = urllib.quote_plus(self.id)
        if hasattr(self, "customer"):
            self.customer = util.utf8(self.customer)

            base = Customer.class_url()
            owner_extn = urllib.quote_plus(self.customer)

        elif hasattr(self, "recipient"):
            self.recipient = util.utf8(self.recipient)

            base = Recipient.class_url()
            owner_extn = urllib.quote_plus(self.recipient)

        else:
            raise error.InvalidRequestError(
                "Could not determine whether card_id %s is " "attached to a customer " "or a recipient." % self.id, "id"
            )

        return "%s/%s/cards/%s" % (base, owner_extn, extn)
开发者ID:ashishpai1,项目名称:Learn-Django-Payment-Processing,代码行数:21,代码来源:resource.py


示例19: instance_url

    def instance_url(self):
        id = self.get('id')

        if not isinstance(id, six.string_types):
            raise error.InvalidRequestError(
                'Could not determine which URL to request: %s instance '
                'has invalid ID: %r, %s. ID should be of type `str` (or'
                ' `unicode`)' % (type(self).__name__, id, type(id)), 'id')

        id = util.utf8(id)
        base = self.class_url()
        extn = quote_plus(id)
        return "%s/%s" % (base, extn)
开发者ID:cnicodeme,项目名称:stripe-python,代码行数:13,代码来源:api_resource.py


示例20: _api_encode

def _api_encode(data):
    for key, value in six.iteritems(data):
        key = util.utf8(key)
        if value is None:
            continue
        elif hasattr(value, "stripe_id"):
            yield (key, value.stripe_id)
        elif isinstance(value, list) or isinstance(value, tuple):
            for i, sv in enumerate(value):
                if isinstance(sv, dict):
                    subdict = _encode_nested_dict("%s[%d]" % (key, i), sv)
                    for k, v in _api_encode(subdict):
                        yield (k, v)
                else:
                    yield ("%s[%d]" % (key, i), util.utf8(sv))
        elif isinstance(value, dict):
            subdict = _encode_nested_dict(key, value)
            for subkey, subvalue in _api_encode(subdict):
                yield (subkey, subvalue)
        elif isinstance(value, datetime.datetime):
            yield (key, _encode_datetime(value))
        else:
            yield (key, util.utf8(value))
开发者ID:stripe,项目名称:stripe-python,代码行数:23,代码来源:api_requestor.py



注:本文中的stripe.util.utf8函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python struct._calcsize函数代码示例发布时间:2022-05-27
下一篇:
Python helper.MyUpdateable类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap