PK Union[Dict, tuple]: """Converts a tuple of type namedtuple to a dict. This isn't registered as injecting this via registration won't work because it will never be falling through to as tuples convert to list. if the tuple isn't a named one, it will return the tuple unchanged """ if hasattr(instance, "_asdict"): return instance._asdict() return instance if numpy_loaded: @register.converter(numpy.ndarray) def numpy_listable(item): return item.tolist() @register.converter(str, numpy.unicode_) def numpy_stringable(item): return str(item) @register.converter(numpy.bytes_) def numpy_byte_decodeable(item): return item.decode() @register.converter(numpy.bool_) def numpy_boolable(item): return bool(item) @register.converter(numpy.integer) def numpy_integerable(item): return int(item) @register.converter(float, numpy.floating) def numpy_floatable(item): return float(item) PK Callable: """A decorator that registers the wrapped function as a pre-converter for the provided types in the provided `store` data structure or a default global one. Returns the decorated function unchanged. """ def register_converter(function): if not override: for kind in kinds: if kind in store[scope]: raise ExistingConverter(kind, store[scope], function) for kind in kinds: # we redo this loop simply to guard against partial application store[scope][kind] = function return function return register_converter json = partial(converter, scope="json") bson = partial(converter, scope="bson") msgpack = partial(converter, scope="msgpack") PKcNPPpreconvert/output/__init__.py"""Exposes all output formatters that have built-in support for preconversion Note: the interesting try: catch: pattern is done as their isn't a guarantee that the user has any of the given output formatters installed, which is required for preconvert to plug-in it's preconversion. """ try: from preconvert.output import json except ImportError: pass try: from preconvert.output import bson except ImportError: pass try: from preconvert.output import msgpack except ImportError: pass try: from preconvert.output import simplejson except ImportError: pass PK4NXbpreconvert/output/bson.pyimport bson from bson import * from preconvert import convert from preconvert.converters import convert_namedtuple def dumps(content, *args, on_unknown=convert.bson, **kwargs): # type: ignore """BSON dumps with preconversion for common unserializable types in place""" if isinstance(content, tuple): content = convert_namedtuple(content) return bson.dumps(content, on_unknown=on_unknown, *args, **kwargs) def dump(content, *args, on_unknown=convert.bson, **kwargs): # type: ignore """BSON dump with preconversion for common unserializable types in place""" if isinstance(content, tuple): content = convert_namedtuple(content) return bson.dump(content, on_unknown=on_unknown, *args, **kwargs) PK\N9preconvert/output/json.pyimport json from json import * from preconvert import convert from preconvert.converters import convert_namedtuple def dumps(content, *args, default=convert.json, **kwargs): # type: ignore """JSON dumps with preconversion for common unserializable types in place""" if isinstance(content, tuple): content = convert_namedtuple(content) return json.dumps(content, default=default, *args, **kwargs) def dump(content, *args, default=convert.json, **kwargs): # type: ignore """JSON dump with preconversion for common unserializable types in place""" if isinstance(content, tuple): content = convert_namedtuple(content) return json.dump(content, default=default, *args, **kwargs) PKNnѲOOpreconvert/output/msgpack.pyimport msgpack from msgpack import * from preconvert import convert from preconvert.converters import convert_namedtuple def pack(content, *args, default=convert.msgpack, **kwargs): # type: ignore """Msgpacks with preconversion for common unserializable types in place""" if isinstance(content, tuple): content = convert_namedtuple(content) return msgpack.pack(content, default=default, *args, **kwargs) def packb(content, *args, default=convert.msgpack, **kwargs): # type: ignore """Msgpacks with preconversion for common unserializable types in place""" if isinstance(content, tuple): content = convert_namedtuple(content) return msgpack.packb(content, default=default, *args, **kwargs) def dump(content, *args, default=convert.msgpack, **kwargs): # type: ignore """Msgpack dump with preconversion for common unserializable types in place""" if isinstance(content, tuple): content = convert_namedtuple(content) return msgpack.dump(content, default=default, *args, **kwargs) def dumps(content, *args, default=convert.msgpack, **kwargs): # type: ignore """Msgpacks dump with preconversion for common unserializable types in place""" if isinstance(content, tuple): content = convert_namedtuple(content) return msgpack.dumps(content, default=default, *args, **kwargs) PKG NL2wpreconvert/output/simplejson.pyimport simplejson from funtools import partial from preconvert import convert from simplejson import * dumps = partial(simplejson.dumps, default=convert.json) # type: ignore dump = partial(simplejson.dump, default=convert.json) # type: ignore PK+LN+vAA"preconvert-0.0.1.dist-info/LICENSEThe MIT License (MIT) Copyright (c) 2019 Timothy Edmund Crosley 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!HPO preconvert-0.0.1.dist-info/WHEEL HM K-*ϳR03rOK-J,/RH,szd&Y)r$[)T&UrPK!HE! #preconvert-0.0.1.dist-info/METADATAVێ6}WL؀M6Y&Ȣ EشDJJREgMz ~ȹ93 d&䩸QTjV 'TE!]=z,)#ګISu6x uH[(ld IIrZ"^BMKFJ?;:Z방Ij 6uU}4NzwKqRmB/26TR3j&k>fNiɌ~>~$ΔO.RZ [$ S>8ͥz"9gLetReZTlFgjr[69tv U_v*ή, mFuY-R||cWa'b) 7%\جʕz?!>Ế>G]52[dU:1ganİ H+S+ {GVTXǧE{O* |pU*!l-% ayZka0h#ENvH7w)hP 7Dѐ2[FMdNZቐynwLV^R4%:~.kU9 J5IV_ TΞ'@?0.nJ=vA<8cIݧ*v]#f0Pq` ePsrav8N |n,]\š%$τˆuE"t`w)BT+Y VѲyr#6f$*YqRT &I2I3J+о`KI\1R: Lny)mm3T 5ˮۘ2KT ӄ0s+3!.V ?&.:QBٜ>=} 7 .݄x |ɩ2j,Sهq`zvq6ƽ"-;c-QB0낀|DkAty,ET0[S)Y;E-H7`gMz,ljFrt˶{ &^`w}^6e'z _P/ .wM9i̽kCMԌuu2N -<7d3R܎~'(RpYy2{IC !oEj'Y xڭ G?g?+K̲xE֫})o)$k8"W)ear G?.mW!PK