Skip to main content

Easily save and load any object data to/from a xml file

Project description

EZobject2xml

Save and load easily any python object data into/from a xml file.

This module has only one object xmltool with 2 functions.

For saving an object into a xml file, you just have to code (python):

from EZobject2xml.xmltoolMod import *
myXmltool = xmltool()
myXmltool.saveObject2xml(myObject,myFilename)

where:

myObject is the object to save

myFileName if the xml file

And for loading:

myXmltool.loadObjectFromXml(myObject,myFilename)

Not wanna save a data of your object ?:

Just add "__" at the end of the name of the data and "saveObject2xml" function won't save this data.

Wanna save a single value data such as integer, float, string, set, tuple, list or dict ?:

You just have to use SingleType class object:

from EZobject2xml.xmltoolMod import *
myxmltool = xmltool()
myvalue_object = SingleType(myvalue)
myxmltool.saveObject2xml(myvalue_object,'myvalue.xml')

For loading:

myxmltool.loadObjectFromXml(myvalue_object,'myvalue.xml')
myvalue = myvalue_object.value

where:

myvalue is any basic data type as int, float, str, set, tuple, list or dict

Exception:

If objects have to be dynamically initialized during the data reading process (i.e. if your object has a list of an undefined number of other objects), we have to create them first before reading their saved data. In order to do that, we give a list of object class that we could use to create a new instance of these objects.

This list of class objects is a initDataList object and we pass it as:

myInitDataList = initDataList()
myInitDataList.addInitData(mySubObject1Class,(a tuple containing the parameters to initialize this SubObject))
myInitDataList.addInitData(mySubObject2Class,(a tuple containing the parameters to initialize this SubObject))
...

myXmltool = xmltool()
myXmltool.loadObjectFromXml(myObject,myFilename,myInitDataList)

where:

mySubObject1Class is the class of an object which can be contained in myObject

myObject is the object to save

myFileName if the xml file

As seen, myInitDataList is optional and only needed when your object has a list of an undefined number of other objects.

The test file has a concrete example.

Please see the python help() function to see more technical information about these functions.

To install the package :

-m pip install EZobject2xml

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

EZobject2xml-1.0.2.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

EZobject2xml-1.0.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file EZobject2xml-1.0.2.tar.gz.

File metadata

  • Download URL: EZobject2xml-1.0.2.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1

File hashes

Hashes for EZobject2xml-1.0.2.tar.gz
Algorithm Hash digest
SHA256 01b83a5b5da42a41923c46041ae29d5042e86e64a4632be2e60bac833f517862
MD5 f8aa1cd5846b4c8cbf1829f5ef96a26e
BLAKE2b-256 251f231e4b3618bda477e4e34b6ec3a68bea531e2ae6ac1b9c00b9fb0b2623a7

See more details on using hashes here.

File details

Details for the file EZobject2xml-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: EZobject2xml-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1

File hashes

Hashes for EZobject2xml-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 775bdb582a213f9c5110b8d19ef3d774eec9b33956fcfb517a995e0330d8cf09
MD5 d8c09ac95b429b25c7f918f588a2050f
BLAKE2b-256 9065240eeb4f7ce482b38a587ca8726760e2b7a83860228ccfc825527ed19cb1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page