state_reader

sans.guiframe.state_reader

class sans.guiframe.state_reader.Reader1D

read state of a plugin and available data

Dependencies :The CanSas reader requires PyXML 0.8.4 or later.
__init__()
__module__ = 'sans.guiframe.state_reader'
_parse_entry()

Parse a SASentry

Parameters:node – SASentry node
Returns:Data1D object
_store_content()

Get the content of a xpath location and store the result. The value is treated as a string.

The xpath location might or might not exist. If it does not exist, nothing is done

Parameters:
  • location – xpath location to fetch
  • node – node to read the data from
  • variable – name of the data member to store it in [string]
  • storage – data object that has the ‘variable’ data member
Returns:

return a list of errors

_store_float()

Get the content of a xpath location and store the result. Check that the units are compatible with the destination. The value is expected to be a float.

The xpath location might or might not exist. If it does not exist, nothing is done

Parameters:
  • location – xpath location to fetch
  • node – node to read the data from
  • variable – name of the data member to store it in [string]
  • storage – data object that has the ‘variable’ data member
  • optional – if True, no exception will be raised if unit conversion can’t be done
Raises ValueError:
 

raised when the units are not recognized

_to_xml_doc()

Create an XML document to contain the content of a Data1D

Parameters:datainfo – Data1D object
ext = []
read()

Load data file

Parameters:

path – file path

Returns:

Data1D object if a single SASentry was found, or a list of Data1D objects if multiple entries were found, or None of nothing was found

Raises:
  • RuntimeError – when the file can’t be opened
  • ValueError – when the length of the data vectors are inconsistent
type = []
type_name = 'CanSAS 1D'
version = '1.0'
write()

Write the content of a Data1D as a CanSAS XML file

Parameters:
  • filename – name of the file to write
  • datainfo – Data1D object
class sans.guiframe.state_reader.Reader2D

Class to load a basic guiframe state

__init__()
__module__ = 'sans.guiframe.state_reader'
_parse_entry()

Parse a SASentry

Parameters:node – SASentry node
Returns:Data1D/Data2D object
_parse_state()

Read a fit result from an XML node

Parameters:entry – XML node to read from
Returns:PageState object
_read_cansas()

Load data and P(r) information from a CanSAS XML file.

Parameters:

path – file path

Returns:

Data1D object if a single SASentry was found, or a list of Data1D objects if multiple entries were found, or None of nothing was found

Raises:
  • RuntimeError – when the file can’t be opened
  • ValueError – when the length of the data vectors are inconsistent
_to_xml_doc()

Create an XML document to contain the content of a Data2D

Parameters:datainfo – Data2D object
ext = ['.fitv', '.FITV', '.svs', 'SVS']
read()

Load a new P(r) inversion state from file

Parameters:path – file path
type = ['Fitting files (*.fitv)|*.fitvSANSView file (*.svs)|*.svs']
type_name = 'Fitting'
write()

Write the content of a Data1D as a CanSAS XML file only for standalone

Parameters:
  • filename – name of the file to write
  • datainfo – Data1D object
  • fitstate – PageState object
write_toXML()

Write toXML, a helper for write() , could be used by guimanager._on_save()

: return: xml doc

sans.guiframe.state_reader.get_content()

Get the first instance of the content of a xpath location.

Parameters:
  • location – xpath location
  • node – node to start at
Returns:

Element, or None

sans.guiframe.state_reader.get_float()

Get the content of a node as a float

Parameters:
  • location – xpath location
  • node – node to start at
sans.guiframe.state_reader.write_node()
Parameters:
  • doc – document DOM
  • parent – parent node
  • name – tag of the element
  • value – value of the child text node
  • attr – attribute dictionary
Returns:

True if something was appended, otherwise False

Table Of Contents

Previous topic

startup_configuration

Next topic

utils

This Page