Changeset 3241dd2 in sasview for src/sans/dataloader/readers/xml_reader.py
- Timestamp:
- Sep 25, 2014 10:33:41 AM (10 years ago)
- 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:
- a91bc5d
- Parents:
- 72cdbec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sans/dataloader/readers/xml_reader.py
rac5b69d r3241dd2 15 15 ############################################################################# 16 16 17 import logging 17 18 from lxml import etree 18 19 from lxml.builder import E … … 37 38 processing_instructions = None 38 39 39 def __init__(self, xml = None, schema = None , root = None):40 def __init__(self, xml = None, schema = None): 40 41 self.xml = xml 41 42 self.schema = schema 42 43 self.processing_instructions = {} 43 44 if xml is not None: 44 self.set_xml_file(xml , root)45 self.set_xml_file(xml) 45 46 else: 46 47 self.xmldoc = None … … 61 62 return self.xmldoc 62 63 63 def set_xml_file(self, xml , root = None):64 def set_xml_file(self, xml): 64 65 """ 65 66 Set the XML file and parse … … 69 70 self.xmldoc = etree.parse(self.xml, parser = PARSER) 70 71 self.xmlroot = self.xmldoc.getroot() 72 except etree.XMLSyntaxError as xml_error: 73 logging.info(xml_error) 71 74 except Exception: 72 75 self.xml = None … … 81 84 self.schema = schema 82 85 self.schemadoc = etree.parse(self.schema, parser = PARSER) 86 except etree.XMLSyntaxError as xml_error: 87 logging.info(xml_error) 83 88 except Exception: 84 89 self.schema = None … … 105 110 try: 106 111 first_error = schema.assertValid(self.xmldoc) 107 except etree.DocumentInvalid as e :108 first_error = str(e )112 except etree.DocumentInvalid as err: 113 first_error = str(err) 109 114 return first_error 110 115 … … 116 121 self.set_schema(self.schema) 117 122 118 def to_string(self, elem, p p=False, encoding=None):123 def to_string(self, elem, pretty_print=False, encoding=None): 119 124 """ 120 125 Converts an etree element into a string 121 126 """ 122 return etree.tostring(elem, pretty_print = pp, encoding = encoding) 127 return etree.tostring(elem, pretty_print = pretty_print, \ 128 encoding = encoding) 123 129 124 130 def break_processing_instructions(self, string, dic):
Note: See TracChangeset
for help on using the changeset viewer.