FileXml Module¶
Handles loading and saving ERACS data to and from XML file formats. Other XML-related formats such as SVG depend on this module. The lxml Python library is a dependency.
-
class
TEracsFileXml
(ADataConverter=None)¶ Class for reading and writing ERACS XML data files.
- Inherits
-
LoadFromStrings
(ANetworkDataString, ALibraryDataString)¶ This method converts the given string argument into an XML element and stores it into the NetTree instance variable (Network data) and LibTree instance variable (Library data).
- Parameters
ANetworkDataString (str) – Network data as a string.
ALibraryDataString (str) – Library data as a string.
-
Load
(AFilePathAndName, ATrySameName)¶ Loads data from the specified file. Clears previous data to make space for the next set of data.
- Parameters
AFilePathAndName (str) – The file to load, must have the appropriate extension.
- Returns
True if successful
- Raises
TEracsArgumentError – If the file doesn’t exist or has the incorrect extension.
-
Save
(AFilePathAndName)¶ - Uses an XML object to write contents to a file (creates a directory if
it doesn’t already exist).
- Required
lxml Python library.
- Parameters
AFilePathAndName – The file directory (and name) to save the XML contents to.
- Returns
True if successfully saved.
- Raises
TEracsArgumentError – If path was incorrect and unable to write the file to it.
TEracsDataError – If the required lxml library is missing.