本文整理匯總了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')