24 Base factory class for line by line reads
26 LineFactoryBase defines the interface for line-by-line IO of a text file to
27 make hits. LineFactoryBase is a factory class i.e. it is used for generating
32 Initialise the base class
34 super(LineFactoryBase, self).
__init__()
40 raise NotImplementedError(
"read_hit not implemented")
43 def _read_formatted(cls, format_list, format_units_dict, file_handle, mass_shell_condition):
45 Read a line and parse according to some pre-defined format
48 line = file_handle.next()
50 raise EOFError(
"End of file reached")
53 if not(len(words) == len(format_list)):
54 raise xboa.hit.BadEventError(
"Read operation failed with line "+str(line))
55 a_hit = xboa.hit.Hit()
56 for key
in format_list:
60 value = xboa.hit.Hit._default_var_types[key](value)
65 value = xboa.hit.Hit._default_var_types[key](value)
66 if xboa.hit.Hit._default_var_types[key] == float:
67 value *= common.units[format_units_dict[key]]
The hit factory module defines a number of factory classes used for generating hit objects...
Base factory class for line by line reads.
def __init__
Initialise the base class.
common module defines common utility data and functions that are used elsewhere
def make_hit
Read a new hit.
Implemented within this module:
def _read_formatted
Read a line and parse according to some pre-defined format.