本文整理汇总了Python中marshmallow.fields.URL属性的典型用法代码示例。如果您正苦于以下问题:Python fields.URL属性的具体用法?Python fields.URL怎么用?Python fields.URL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类marshmallow.fields
的用法示例。
在下文中一共展示了fields.URL属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_url
# 需要导入模块: from marshmallow import fields [as 别名]
# 或者: from marshmallow.fields import URL [as 别名]
def from_url(cls, url: str) -> "ConnectionInvitation":
"""
Parse a URL-encoded invitation into a `ConnectionInvitation` message.
Args:
url: Url to decode
Returns:
A `ConnectionInvitation` object.
"""
parts = urlparse(url)
query = parse_qs(parts.query)
if "c_i" in query:
c_i = b64_to_bytes(query["c_i"][0], urlsafe=True)
return cls.from_json(c_i)
return None
示例2: wrap_payload_content
# 需要导入模块: from marshmallow import fields [as 别名]
# 或者: from marshmallow.fields import URL [as 别名]
def wrap_payload_content(self, data: dict) -> dict:
"""SCEP Payload is silly and double wraps its PayloadContent item."""
inner_content = {
'URL': data.pop('URL', None),
'Name': data.pop('Name'),
'Challenge': data.pop('Challenge'),
'Keysize': data.pop('Keysize'),
'CAFingerprint': data.pop('CAFingerprint'),
'KeyType': data.pop('KeyType'),
'KeyUsage': data.pop('KeyUsage'),
'Retries': data.pop('Retries'),
'RetryDelay': data.pop('RetryDelay'),
}
data['PayloadContent'] = inner_content
return data
示例3: base_paginator
# 需要导入模块: from marshmallow import fields [as 别名]
# 或者: from marshmallow.fields import URL [as 别名]
def base_paginator(seed_url: "URL", session_manager: "SessionManager", schema: Any) -> Iterable[Any]: # type: ignore # noqa: F821, E501
"""Create a paginator using the passed parameters.
Args:
seed_url: The url to get the first batch of results.
session_manager: The session manager that will manage the get.
schema: The Schema subclass used to build individual instances.
Yields:
Instances of the object passed in the schema field.
"""
resource_endpoint = seed_url
while True:
paginator = session_manager.get(resource_endpoint, schema=schema)
for instrument in paginator:
yield instrument
if paginator.next is not None:
resource_endpoint = paginator.next
else:
break
示例4: __init__
# 需要导入模块: from marshmallow import fields [as 别名]
# 或者: from marshmallow.fields import URL [as 别名]
def __init__(
self,
*,
label: str = None,
did: str = None,
recipient_keys: Sequence[str] = None,
endpoint: str = None,
routing_keys: Sequence[str] = None,
image_url: str = None,
**kwargs,
):
"""
Initialize connection invitation object.
Args:
label: Optional label for connection
did: DID for this connection invitation
recipient_keys: List of recipient keys
endpoint: Endpoint which this agent can be reached at
routing_keys: List of routing keys
image_url: Optional image URL for connection invitation
"""
super(ConnectionInvitation, self).__init__(**kwargs)
self.label = label
self.did = did
self.recipient_keys = list(recipient_keys) if recipient_keys else None
self.endpoint = endpoint
self.routing_keys = list(routing_keys) if routing_keys else None
示例5: to_url
# 需要导入模块: from marshmallow import fields [as 别名]
# 或者: from marshmallow.fields import URL [as 别名]
def to_url(self, base_url: str = None) -> str:
"""
Convert an invitation to URL format for sharing.
Returns:
An invite url
"""
c_json = self.to_json()
c_i = bytes_to_b64(c_json.encode("ascii"), urlsafe=True)
result = urljoin(base_url or self.endpoint or "", "?c_i={}".format(c_i))
return result
示例6: url
# 需要导入模块: from marshmallow import fields [as 别名]
# 或者: from marshmallow.fields import URL [as 别名]
def url(cls):
return relationship('URL')