PK!==json_ext_encoder/__init__.pyfrom .encoder import JSONEncoder __all__ = ("JSONEncoder",) PK!6ig  json_ext_encoder/duration.pyfrom datetime import timedelta from typing import Tuple __all__ = ("iso_string",) def iso_string(duration: timedelta) -> str: if duration < timedelta(0): sign = "-" duration *= -1 else: sign = "" days, hours, minutes, seconds, microseconds = _get_components(duration) ms = f".{microseconds:06d}" if microseconds else "" return f"{sign}P{days}DT{hours:02d}H{minutes:02d}M{seconds:02d}{ms}S" def _get_components(duration: timedelta) -> Tuple[int, int, int, int, int]: days = duration.days seconds = duration.seconds microseconds = duration.microseconds minutes = seconds // 60 seconds = seconds % 60 hours = minutes // 60 minutes = minutes % 60 return days, hours, minutes, seconds, microseconds PK!&_##json_ext_encoder/encoder.pyimport datetime import decimal import enum import json import uuid from json_ext_encoder import duration, timezone __all__ = ("JSONEncoder",) class JSONEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, datetime.datetime): r = o.isoformat() if o.microsecond: r = r[:23] + r[26:] if r.endswith("+00:00"): r = r[:-6] + "Z" return r elif isinstance(o, datetime.date): return o.isoformat() elif isinstance(o, datetime.time): if timezone.is_aware(o): raise ValueError("JSON can't represent timezone-aware times.") r = o.isoformat() if o.microsecond: r = r[:12] return r elif isinstance(o, datetime.timedelta): return duration.iso_string(o) elif isinstance(o, (decimal.Decimal, uuid.UUID)): return str(o) elif isinstance(o, enum.Enum): return o.value return super().default(o) PK!kejson_ext_encoder/timezone.pyfrom datetime import datetime, time from typing import Union __all__ = ("is_aware",) def is_aware(value: Union[datetime, time]) -> bool: """ Determine if a given datetime.datetime or datetime.time is aware. The concept is defined in Python's docs: http://docs.python.org/library/datetime.html#datetime.tzinfo Assuming value.tzinfo is either None or a proper datetime.tzinfo, value.utcoffset() implements the appropriate logic. """ return value.utcoffset() is not None PK!=-//(json_ext_encoder-0.2.0.dist-info/LICENSEMIT License Copyright (c) 2018 Nikita Grishko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!H_zTT&json_ext_encoder-0.2.0.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]n0H*J>mlcAPK!H )json_ext_encoder-0.2.0.dist-info/METADATAVr48LahHNm<۔mi; tb+d$9a!xB#izہYHt9HX#?qcV 0:c'jE#\e:&DZJfnW9t0.WhXgՆXKN*@'sMx!\Qhe GOEƕEeoVdJ;s3:ѹIL\ [\npD իh_o@7;t d֊hI8Ӑ{*F/ R21 ^Kv+OƥD7zVp%/u%r~T 3;v&:K,̈'jDp䲩N#AsRQOpZ9Lsu{MgRX i>P\|TVKf7gw?r-PEb:[1*C=Vq#<M9,ޘrAm!x[o&x v?  d(&g8蹧FzyʀÕW&auaxgH3ce.G; a*y[49k*xM #A\p|9ʄ:M`y&$ff訮EN߾=?ǭ6ޮJTŰ!ZXZi!+m\ 2ޡһuV;4Rg\վQt׀i9HBL͘5X1͜FZIRgfȂۘi9Ҫ-Se\ W4jsk86^$'^mrkD!fSc:lYmAfxqn}w&m*Vykپ62U)2PVyBdE@&-'<N@`򛝗$ ]?'Jls璯bu-isQƅsؿPK!Hޤq'json_ext_encoder-0.2.0.dist-info/RECORDr@л,b9 Y$BϠ0춤OKe*9uWcK:ڼ^P21#NxR.$զ7sO%:َr. w[3@=dR'yH&RP :17ԥ> 78 wn;FgO>ɼzݩs#ks 獉X/DWTxzgEa3mÖQUyB|5@Fd's.%8--Wsj}|6lL1>Dwi{|Syi'oQlǩ`YO]NP)B\󧌁+HO_mXEr,{ȸ48d+ /񏫩PK!==json_ext_encoder/__init__.pyPK!6ig  wjson_ext_encoder/duration.pyPK!&_##json_ext_encoder/encoder.pyPK!kejson_ext_encoder/timezone.pyPK!=-//(K json_ext_encoder-0.2.0.dist-info/LICENSEPK!H_zTT&json_ext_encoder-0.2.0.dist-info/WHEELPK!H )Xjson_ext_encoder-0.2.0.dist-info/METADATAPK!Hޤq'[json_ext_encoder-0.2.0.dist-info/RECORDPK}/