Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def encode_regexp(self, value):
# Semantic tag 35
self.encode_semantic(CBORTag(35, as_unicode(value.pattern)))
def encode_mime(self, value):
# Semantic tag 36
self.encode_semantic(CBORTag(36, as_unicode(value.as_string())))
if self._timezone:
value = value.replace(tzinfo=self._timezone)
else:
raise CBOREncodeValueError(
'naive datetime {!r} encountered and no default timezone '
'has been set'.format(value))
if self.datetime_as_timestamp:
from calendar import timegm
if not value.microsecond:
timestamp = timegm(value.utctimetuple())
else:
timestamp = timegm(value.utctimetuple()) + value.microsecond / 1000000
self.encode_semantic(CBORTag(1, timestamp))
else:
datestring = as_unicode(value.isoformat().replace('+00:00', 'Z'))
self.encode_semantic(CBORTag(0, datestring))