Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdk/deviceregistry/azure-mgmt-deviceregistry/_meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"commit": "6132d27fe22b7876e0064827a5ac70f7a6166ab9",
"commit": "60c791f3c818acc8ba2b522b956e9ed3b0794937",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"typespec_src": "specification/deviceregistry/DeviceRegistry.Management",
"@azure-tools/typespec-python": "0.36.5"
"@azure-tools/typespec-python": "0.38.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,22 @@ def _deserialize(
return _deserialize_with_callable(deserializer, value)


def _failsafe_deserialize(
deserializer: typing.Any,
value: typing.Any,
module: typing.Optional[str] = None,
rf: typing.Optional["_RestField"] = None,
format: typing.Optional[str] = None,
) -> typing.Any:
try:
return _deserialize(deserializer, value, module, rf, format)
except DeserializationError:
_LOGGER.warning(
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
)
return None


class _RestField:
def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,73 +185,7 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]],
except NameError:
_long_type = int


class UTC(datetime.tzinfo):
"""Time Zone info for handling UTC"""

def utcoffset(self, dt):
"""UTF offset for UTC is 0.

:param datetime.datetime dt: The datetime
:returns: The offset
:rtype: datetime.timedelta
"""
return datetime.timedelta(0)

def tzname(self, dt):
"""Timestamp representation.

:param datetime.datetime dt: The datetime
:returns: The timestamp representation
:rtype: str
"""
return "Z"

def dst(self, dt):
"""No daylight saving for UTC.

:param datetime.datetime dt: The datetime
:returns: The daylight saving time
:rtype: datetime.timedelta
"""
return datetime.timedelta(hours=1)


try:
from datetime import timezone as _FixedOffset # type: ignore
except ImportError: # Python 2.7

class _FixedOffset(datetime.tzinfo): # type: ignore
"""Fixed offset in minutes east from UTC.
Copy/pasted from Python doc
:param datetime.timedelta offset: offset in timedelta format
"""

def __init__(self, offset) -> None:
self.__offset = offset

def utcoffset(self, dt):
return self.__offset

def tzname(self, dt):
return str(self.__offset.total_seconds() / 3600)

def __repr__(self):
return "<FixedOffset {}>".format(self.tzname(None))

def dst(self, dt):
return datetime.timedelta(0)

def __getinitargs__(self):
return (self.__offset,)


try:
from datetime import timezone

TZ_UTC = timezone.utc
except ImportError:
TZ_UTC = UTC() # type: ignore
TZ_UTC = datetime.timezone.utc

_FLATTEN = re.compile(r"(?<!\\)\.")

Expand Down Expand Up @@ -310,7 +244,7 @@ def _create_xml_node(tag, prefix=None, ns=None):
return ET.Element(tag)


class Model(object):
class Model:
"""Mixin for all client request body/response body models to support
serialization and deserialization.
"""
Expand Down Expand Up @@ -563,7 +497,7 @@ def _decode_attribute_map_key(key):
return key.replace("\\.", ".")


class Serializer(object): # pylint: disable=too-many-public-methods
class Serializer: # pylint: disable=too-many-public-methods
"""Request object model serializer."""

basic_types = {str: "str", int: "int", bool: "bool", float: "float"}
Expand Down Expand Up @@ -1441,7 +1375,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument
return children[0]


class Deserializer(object):
class Deserializer:
"""Response object model deserializer.

:param dict classes: Class type dictionary for deserializing complex types.
Expand Down Expand Up @@ -2051,7 +1985,7 @@ def deserialize_rfc(attr):
try:
parsed_date = email.utils.parsedate_tz(attr) # type: ignore
date_obj = datetime.datetime(
*parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60))
*parsed_date[:6], tzinfo=datetime.timezone(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60))
)
if not date_obj.tzinfo:
date_obj = date_obj.astimezone(tz=TZ_UTC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "1.0.0b2"
VERSION = "1.0.0b1"
Loading
Loading