Skip to main content

Dumpo Python Object Serialiser

Dumpo serialises a Python object recursively to arbitrary levels, optionally in a JSON like format.

Synopsis:

from dumpo import dumpo
print(dumpo(obj))

Keyword arguments:

Argument Description Type Default Value
as_is Data type name or list of them to be shown as is. i.e., f'{obj}' List or string []
as_is_tag String to append to a data item serialised "as is" String "<as_is>"
code_tag String to replace function code String "<code>"
compressed If True compress list to a single line instead of one data item per line Boolean True
debug If True append debug information to each data item, e.g., data type, quotes to use and iterator Boolean False
deep_types Data type names or list of them to be shown even the item is at level maxdepth+1 List or string []
excluded Data item names or list of them to be excluded from serialisation List or string []
excluded_tag String to replace excluded data items. Blank to hide all excluded data items. String "<excluded>"
expand_keys If True serialise structured item keys, else show them as a string. i.e., print(f'{itemKey}') Boolean False
include_all_keys If True include all keys including internal ones (_<name>) and built-in ones (__<name>) excluding __dict__. Boolean False
include_everything Equivalent to include_all_keys=True, include_functions=True, expand_keys=True, with __dict__ included. Boolean False
include_internals If True include internal keys (_<name>) but not built-in ones (__<name>). Boolean False
include_functions If True include object function names (including internal functions if include_all_keys is also True). Boolean False
indent String used for indentation, repeat for the number of levels String "| "
item_quotes Quotation 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 keys String None
json_like If True serialise in JSON format - implying indent=" " and item_quotes = '"', and False for show_types and show_all_types. Boolean False
maxdepth Maximum levels to serialise Integer 5
quotes Quotation 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 items String ""
show_all_types If True prepend the data type to each data item of all types, e.g., <type>{ ... } Boolean True
show_types If True prepend the data type to each data item except for simple types, e.g., <type>{ ... } Boolean True
too_deep_tag String to replace data items or structures below the maxdepthth level String "<too_deep>"

Dumpo at GitHub

Examples

>>> from dumpo import dumpo
>>> import boto3
>>> 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-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': 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"
  }
}

Metadata

Release files for dumpo 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dumpo 0.0.8
File Size Uploaded Provenance
dumpo-0.0.8.tar.gz 11.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dumpo 0.0.8
File Interpreter ABI Platform
dumpo-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 19.8 kB

Release files / dumpo-0.0.8.tar.gz

Download URL dumpo-0.0.8.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e7a49125b64ade9f44f1c3c7bbdfe3a02df8a5cda503761be223f9ff4439a881
BLAKE2b-256 checksum
How to use checksums
520983c38f0b12b979dd21cb166d708684b4c9dce655ab502fd52d53c34b06f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / dumpo-0.0.8-py3-none-any.whl

Download URL dumpo-0.0.8-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dee60d685af05d61402e6bd3295bc9a71edb94b4450d5227aafebdb3ee0e0704
BLAKE2b-256 checksum
How to use checksums
6902a0e3e5a0dcd77338c3a675b50fab8b4e9ddb076170a793f916f242d91c9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Security for dumpo 0.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page