Changeset f44b076 in sasview


Ignore:
Timestamp:
Apr 5, 2014 6:28:46 AM (11 years ago)
Author:
Jeff Krzywon <jeffery.krzywon@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
201af9f
Parents:
968aa6e
Message:

Added helper functions to the XMLReader for writing to XML

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sans/dataloader/readers/xml_reader.py

    rea67541 rf44b076  
    146146        return name 
    147147     
     148    def create_tree(self, root): 
     149        """ 
     150        Create an element tree for processing from an XML string 
    148151         
     152        :param root: XML string  
     153        """ 
     154        return etree.ElementTree(root) 
     155     
     156    def create_element(self, name): 
     157        """ 
     158        Create an XML element for writing to file 
     159         
     160        :param name: The name of the element to be created 
     161        """ 
     162        return etree.Element(name) 
     163     
     164    def write_text(self, elem, text): 
     165        """ 
     166        Write text to an etree Element 
     167         
     168        :param elem: etree.Element object 
     169        :param text: text to write to the element 
     170        """ 
     171        elem.text = text 
     172        return elem 
     173     
     174    def write_attribute(self, elem, attr_name, attr_value): 
     175        """ 
     176        Write attributes to an Element 
     177         
     178        :param elem: etree.Element object 
     179        :param attr_name: attribute name to write 
     180        :param attr_value: attribute value to set 
     181        """ 
     182        attr = elem.attrib 
     183        attr[attr_name] = attr_value 
     184         
Note: See TracChangeset for help on using the changeset viewer.