Package: dumpo
Dumpo Python Object SerialiserDumpo serialises a Python object recursively to arbitrary levels, optionally in a JSON like format.Synopsis:fromdumpoimportdumpoprint(dumpo(obj))Keyword arguments:ArgumentDescriptionTypeDefault Valueas_isData type name or list of them to be shown as is. i.e.,f'{obj}'List or string[]as_is_tagString to append to a data item serialised "as is"String"<as_is>"code_tagString to replace function codeString"<code>"compressedIf True compress list to a single line instead of one data item per lineBooleanTruedebugIf True append debug information to each data item, e.g., data type, quotes to use and iteratorBooleanFalsedeep_typesData type names or list of them to be shown even the item is at levelmaxdepth+1List or string[]excludedData item names or list of them to be excluded from serialisationList or string[]excluded_tagString to replace excluded data items. Blank to hide all excluded data items.String"<excluded>"expand_keysIf True serialise structured item keys, else show them as a string. i.e.,print(f'{itemKey}')BooleanFalseinclude_all_keysIf True include all keys including internal ones (_<name>) and built-in ones (__<name>) excluding__dict__.BooleanFalseinclude_everythingEquivalent toinclude_all_keys=True, include_functions=True, expand_keys=True, with__dict__included.BooleanFalseinclude_internalsIf True include internal keys (_<name>) but not built-in ones (__<name>).BooleanFalseinclude_functionsIf True include object function names (including internal functions ifinclude_all_keysis also True).BooleanFalseindentString used for indentation, repeat for the number of levelsString"| "item_quotesQuotation marks for item keys - a 2-character string for open and close respectively; a 1-character string if open and close are the same; blank means no quotation marks for item keysStringNonejson_likeIf True serialise in JSON format - implyingindent="  "anditem_quotes = '"', andFalseforshow_typesandshow_all_types.BooleanFalsemaxdepthMaximum levels to serialiseInteger5quotesQuotation marks for data items - a 2-character string for open and close respectively; a 1-character string if open and close are the same; blank means no quotation marks for data itemsString""show_all_typesIf True prepend the data type to each data item of all types, e.g.,<type>{ ... }BooleanTrueshow_typesIf True prepend the data type to each data item except for simple types, e.g.,<type>{ ... }BooleanTruetoo_deep_tagString to replace data items or structures below themaxdepthth levelString"<too_deep>"Dumpo at GitHubExamples>>>fromdumpoimportdumpo>>>importboto3>>>ec2=boto3.client('ec2')>>>response=ec2.describe_instances()>>>print(dumpo(response,maxdepth=1)){|Reservations:[<too_deep>,<too_deep>,<too_deep>,<too_deep>,<too_deep>,<too_deep>,<too_deep>,<too_deep>,<too_deep>,<too_deep>],|ResponseMetadata:{||RequestId:<too_deep>,||HTTPStatusCode:<too_deep>,||HTTPHeaders:<too_deep>,||RetryAttempts:<too_deep>|}}>>>print(dumpo(response['Reservations'][0],maxdepth=1)){|Groups:[],|Instances:[<too_deep>],|OwnerId:"999999999999",|ReservationId:"r-xxxxxxxxxxxxxxxxx"}>>>print(dumpo(response['Reservations'][0]['Instances'][0],too_deep_tag='...')){|AmiLaunchIndex:0,|ImageId:"ami-xxxxxxxxxxxxxxxxx",|InstanceId:"i-xxxxxxxxxxxxxxxxx",|InstanceType:"x9.xxxx",|KeyName:"xxx",|LaunchTime:<datetime>yyyy-mm-ddHH:MM:SS+00:00,|Monitoring:{'State':'disabled'},|Placement:{'AvailabilityZone':'xx-xxxxxx-9x','GroupName':'','Tenancy':'default'},|PrivateDnsName:"ip-99-99-99-99.xx-xxxxxx-9.compute.internal",|PrivateIpAddress:"99.99.99.99",|ProductCodes:[],|PublicDnsName:"",|State:{'Code':80,'Name':'stopped'},|StateTransitionReason:"User initiated (yyyy-mm-dd HH:MM:SS GMT)",|SubnetId:"subnet-xxxxxxxx",|VpcId:"vpc-xxxxxxxx",|Architecture:"x86_64",|BlockDeviceMappings:[{|||DeviceName:"/dev/xvda",|||Ebs:{'AttachTime':datetime.datetime(yyyy,mm,dd,HH,MM,SS,tzinfo=tzutc()),'DeleteOnTermination':True,'Status':'attached','VolumeId':'vol-xxxxxxxxxxxxxxxxx'}||}],|ClientToken:"",|EbsOptimized:False,|EnaSupport:True,|Hypervisor:"xen",|NetworkInterfaces:[{|||Attachment:{'AttachTime':datetime.datetime(yyyy,mm,dd,HH,MM,SS,tzinfo=tzutc()),'AttachmentId':'eni-attach-0eb44e06cead04be4','DeleteOnTermination':True,'DeviceIndex':0,'Status':'attached','NetworkCardIndex':0},|||Description:"Primary network interface",|||Groups:[{|||||GroupName:"ssh-xxx",|||||GroupId:"sg-xxxxxxxxxxxxxxxxx"||||}],|||Ipv6Addresses:[],|||MacAddress:"xx:xx:xx:xx:xx:xx",|||NetworkInterfaceId:"eni-xxxxxxxxxxxxxxxxx",|||OwnerId:"999999999999",|||PrivateDnsName:"ip-99-99-99-99.xx-xxxxxx-9.compute.internal",|||PrivateIpAddress:"99.99.99.99",|||PrivateIpAddresses:[{|||||Primary:True,|||||PrivateDnsName:"ip-99-99-99-99.xx-xxxxxx-9.compute.internal",|||||PrivateIpAddress:"99.99.99.99"||||}],|||SourceDestCheck:True,|||Status:"in-use",|||SubnetId:"subnet-xxxxxxxx",|||VpcId:"vpc-xxxxxxxx",|||InterfaceType:"interface"||}],|RootDeviceName:"/dev/xvda",|RootDeviceType:"ebs",|SecurityGroups:[{|||GroupName:"ssh-xxx",|||GroupId:"sg-xxxxxxxxxxxxxxxxx"||}],|SourceDestCheck:True,|StateReason:{'Code':'Client.UserInitiatedShutdown','Message':'Client.UserInitiatedShutdown: User initiated shutdown'},|Tags:[{|||Key:"Name",|||Value:"xxx"||}],|VirtualizationType:"hvm",|CpuOptions:{'CoreCount':1,'ThreadsPerCore':1},|CapacityReservationSpecification:{'CapacityReservationPreference':'open'},|HibernationOptions:{'Configured':False},|MetadataOptions:{'State':'applied','HttpTokens':'optional','HttpPutResponseHopLimit':1,'HttpEndpoint':'enabled'},|EnclaveOptions:{'Enabled':False}}>>>print(dumpo(response['Reservations'][0]['Instances'][0],too_deep_tag='...',json_like=True)){"AmiLaunchIndex":0,"ImageId":"ami-xxxxxxxxxxxxxxxxx","InstanceId":"i-xxxxxxxxxxxxxxxxx","InstanceType":"x9.xxxx","KeyName":"xxx","LaunchTime":"yyyy-mm-dd HH:MM:SS+00:00","Monitoring":{"State":"disabled"},"Placement":{"AvailabilityZone":"xx-xxxxxx-9x","GroupName":"","Tenancy":"default"},"PrivateDnsName":"ip-99-99-99-99.xx-xxxxxx-9.compute.internal","PrivateIpAddress":"99.99.99.99","ProductCodes":"[]","PublicDnsName":"","State":{"Code":80,"Name":"stopped"},"StateTransitionReason":"User initiated (yyyy-mm-dd HH:MM:SS GMT)","SubnetId":"subnet-xxxxxxxx","VpcId":"vpc-xxxxxxxx","Architecture":"x86_64","BlockDeviceMappings":[{"DeviceName":"/dev/xvda","Ebs":{"AttachTime":"yyyy-mm-dd HH:MM:SS+00:00","DeleteOnTermination":"True","Status":"attached","VolumeId":"vol-xxxxxxxxxxxxxxxxx"}}],"ClientToken":"","EbsOptimized":"False","EnaSupport":"True","Hypervisor":"xen","NetworkInterfaces":[{"Attachment":{"AttachTime":"yyyy-mm-dd HH:MM:SS+00:00","AttachmentId":"eni-attach-xxxxxxxxxxxxxxxxx","DeleteOnTermination":"True","DeviceIndex":0,"Status":"attached","NetworkCardIndex":0},"Description":"Primary network interface","Groups":[{"GroupName":"ssh-xxx","GroupId":"sg-xxxxxxxxxxxxxxxxx"}],"Ipv6Addresses":"[]","MacAddress":"xx:xx:xx:xx:xx:xx","NetworkInterfaceId":"eni-xxxxxxxxxxxxxxxxx","OwnerId":"999999999999","PrivateDnsName":"ip-99-99-99-99.xx-xxxxxx-9.compute.internal","PrivateIpAddress":"99.99.99.99","PrivateIpAddresses":[{"Primary":"True","PrivateDnsName":"ip-99-99-99-99.xx-xxxxxx-9.compute.internal","PrivateIpAddress":"99.99.99.99"}],"SourceDestCheck":"True","Status":"in-use","SubnetId":"subnet-xxxxxxxx","VpcId":"vpc-xxxxxxxx","InterfaceType":"interface"}],"RootDeviceName":"/dev/xvda","RootDeviceType":"ebs","SecurityGroups":[{"GroupName":"ssh-xxx","GroupId":"sg-xxxxxxxxxxxxxxxxx"}],"SourceDestCheck":"True","StateReason":{"Code":"Client.UserInitiatedShutdown","Message":"Client.UserInitiatedShutdown: User initiated shutdown"},"Tags":[{"Key":"Name","Value":"xxx"}],"VirtualizationType":"hvm","CpuOptions":{"CoreCount":1,"ThreadsPerCore":1},"CapacityReservationSpecification":{"CapacityReservationPreference":"open"},"HibernationOptions":{"Configured":"False"},"MetadataOptions":{"State":"applied","HttpTokens":"optional","HttpPutResponseHopLimit":1,"HttpEndpoint":"enabled"},"EnclaveOptions":{"Enabled":"False"}}