Changeset b35d3d1 in sasview for invariantview/perspectives/invariant
- Timestamp:
- Aug 6, 2010 7:36:07 PM (14 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:
- 028a0e8
- Parents:
- a93f525
- Location:
- invariantview/perspectives/invariant
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/perspectives/invariant/invariant.py
r210ff4f rb35d3d1 105 105 loader = Loader() 106 106 loader.associate_file_reader(".inv", self.state_reader) 107 loader.associate_file_reader(".svs", self.state_reader) 107 108 # Return the list of panels 108 109 return [self.invariant_panel] -
invariantview/perspectives/invariant/invariant_panel.py
r210ff4f rb35d3d1 131 131 self.reset_panel() 132 132 self.compute_invariant(event=None) 133 self.state.file = self._data.name 133 134 return True 134 135 def set_message(self): … … 166 167 if not self.set_data(data): 167 168 return 168 self.state = state 169 169 self.state = state 170 self.state.file = data.name 170 171 num = self.state.saved_state['state_num'] 171 172 -
invariantview/perspectives/invariant/invariant_state.py
r5b03122 rb35d3d1 266 266 # File name 267 267 element = newdoc.createElement("filename") 268 if self.file is not None:268 if self.file != None and self.file !='': 269 269 element.appendChild(newdoc.createTextNode(str(self.file))) 270 270 else: … … 353 353 entry = get_content('ns:filename', node) 354 354 if entry is not None: 355 self.file = entry.text.strip()356 355 file_name = entry.text.strip() 356 357 357 # Get time stamp 358 358 entry = get_content('ns:timestamp', node) … … 432 432 if input_field is not None: 433 433 self.set_saved_state(name=item, value=val) 434 434 435 self.file = file_name 436 435 437 def set_report_string(self): 436 438 """ … … 606 608 607 609 ## Wildcards 608 type = ["Invariant file (*.inv)|*.inv"] 610 type = ["Invariant file (*.inv)|*.inv", 611 "SANSView file (*.svs)|*.svs"] 609 612 ## List of allowed extensions 610 ext=['.inv', '.INV' ]613 ext=['.inv', '.INV', '.svs', 'SVS'] 611 614 612 615 def __init__(self, call_back, cansas=True): … … 660 663 : return: InvariantState object 661 664 """ 662 # Create an empty state 663 state = InvariantState() 664 665 state = None 665 666 # Locate the invariant node 666 667 try: 667 668 nodes = entry.xpath('ns:%s' % INVNODE_NAME, namespaces={'ns': CANSAS_NS}) 668 state.fromXML(node=nodes[0]) 669 # Create an empty state 670 if nodes !=[]: 671 state = InvariantState() 672 state.fromXML(node=nodes[0]) 669 673 except: 670 674 logging.info("XML document does not contain invariant information.\n %s" % sys.exc_value) … … 683 687 """ 684 688 output = [] 685 686 689 if os.path.isfile(path): 687 690 basename = os.path.basename(path) … … 702 705 sas_entry = self._parse_entry(entry) 703 706 invstate = self._parse_state(entry) 704 sas_entry.meta_data['invstate'] = invstate 705 706 sas_entry.filename = invstate.file 707 output.append(sas_entry) 708 707 708 #invstate could be None when .svs file is loaded 709 #in this case, skip appending to output 710 if invstate != None: 711 sas_entry.meta_data['invstate'] = invstate 712 sas_entry.filename = invstate.file 713 output.append(sas_entry) 709 714 else: 710 715 raise RuntimeError, "%s is not a file" % path … … 730 735 : param invstate: InvariantState object 731 736 """ 732 733 737 # Sanity check 734 738 if self.cansas == True: 735 if datainfo is None: 736 datainfo = DataLoader.data_info.Data1D(x=[], y=[]) 737 elif not issubclass(datainfo.__class__, DataLoader.data_info.Data1D): 738 raise RuntimeError, "The cansas writer expects a Data1D instance: %s" % str(datainfo.__class__.__name__) 739 740 # Create basic XML document 741 doc, sasentry = self._to_xml_doc(datainfo) 742 743 # Add the invariant information to the XML document 744 if invstate is not None: 745 invstate.toXML(doc=doc, entry_node=sasentry) 746 739 doc = self.write_toXML(datainfo,invstate) 747 740 # Write the XML document 748 741 fd = open(filename, 'w') … … 752 745 invstate.toXML(file=filename) 753 746 754 755 747 def write_toXML(self, datainfo=None, state=None): 748 """ 749 Write toXML, a helper for write() 750 751 : return: xml doc 752 """ 753 if datainfo is None: 754 datainfo = DataLoader.data_info.Data1D(x=[], y=[]) 755 elif not issubclass(datainfo.__class__, DataLoader.data_info.Data1D): 756 raise RuntimeError, "The cansas writer expects a Data1D instance: %s" % str(datainfo.__class__.__name__) 757 #make sure title and data run is filled up. 758 if datainfo.title == None or datainfo.title=='': datainfo.title = datainfo.name 759 if datainfo.run_name == None or datainfo.run_name=={}: 760 datainfo.run = [str(datainfo.name)] 761 datainfo.run_name[0] = datainfo.name 762 763 # Create basic XML document 764 doc, sasentry = self._to_xml_doc(datainfo) 765 766 # Add the invariant information to the XML document 767 if state is not None: 768 state.toXML(doc=doc, entry_node=sasentry) 769 770 return doc
Note: See TracChangeset
for help on using the changeset viewer.