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)
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for EZobject2xml-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 333d38aa802533c41f80d51aa904e8e3b3cc68ccbd35c7c186e00975d8869138 |
|
MD5 | 3ccad83850300f61167e7f2f5bee8980 |
|
BLAKE2b-256 | 5fa444d8275903716ababe13ebef82819d5aeae8972c794eac33de3b3d4da529 |