本文整理汇总了Python中spyne.util._bytes_join函数的典型用法代码示例。如果您正苦于以下问题:Python _bytes_join函数的具体用法?Python _bytes_join怎么用?Python _bytes_join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_bytes_join函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_urlsafe_base64
def from_urlsafe_base64(cls, value):
#FIXME: Find out why we need to do this.
if isinstance(value, six.text_type):
value = value.encode('utf8')
try:
return (urlsafe_b64decode(_bytes_join(value)),)
except TypeError as e:
logger.exception(e)
if len(value) > 100:
raise ValidationError(value)
else:
raise ValidationError(value[:100] + "(...)")
示例2: create_in_document
def create_in_document(self, ctx, charset=None):
"""Uses the iterable of string fragments in ``ctx.in_string`` to set
``ctx.in_document``."""
string = _bytes_join(ctx.in_string)
try:
try:
ctx.in_document = etree.fromstring(string,
parser=XMLParser(**self.parser_kwargs))
except ValueError:
logger.debug('ValueError: Deserializing from unicode strings '
'with encoding declaration is not supported by '
'lxml.')
ctx.in_document = etree.fromstring(string.decode(charset),
self.parser)
except XMLSyntaxError, e:
logger_invalid.error(string)
raise Fault('Client.XMLSyntaxError', str(e))
示例3: create_in_document
def create_in_document(self, ctx, charset=None):
"""Uses the iterable of string fragments in ``ctx.in_string`` to set
``ctx.in_document``."""
string = _bytes_join(ctx.in_string)
try:
try:
ctx.in_document = etree.fromstring(string, self.parser)
except XMLSyntaxError, e:
logger.error(string)
raise Fault("Client.XMLSyntaxError", str(e))
except ValueError:
try:
ctx.in_document = etree.fromstring(string.decode(charset), self.parser)
except XMLSyntaxError, e:
logger.error(string)
raise Fault("Client.XMLSyntaxError", str(e))
示例4: from_base64
def from_base64(cls, value):
try:
return [b64decode(_bytes_join(value))]
except TypeError as e:
raise ValidationError(value)
示例5: to_base64
def to_base64(cls, value):
return b64encode(_bytes_join(value))
示例6: from_hex
def from_hex(cls, value):
return [unhexlify(_bytes_join(value))]
示例7: to_hex
def to_hex(cls, value):
return hexlify(_bytes_join(value))
示例8: from_urlsafe_base64
def from_urlsafe_base64(cls, value):
#FIXME: Find out why we need to do this.
if isinstance(value, unicode):
value = value.encode('utf8')
return [urlsafe_b64decode(_bytes_join(value))]
示例9: to_urlsafe_base64
def to_urlsafe_base64(cls, value):
return urlsafe_b64encode(_bytes_join(value))
示例10: from_urlsafe_base64
def from_urlsafe_base64(cls, value):
return [urlsafe_b64decode(_bytes_join(value))]
示例11: from_base64
def from_base64(cls, value):
return [base64.b64decode(_bytes_join(value))]
示例12: set_response
def set_response(self, retval, response):
retval.content = _bytes_join(response, b"")