ait.core.table module¶
-
class
ait.core.table.
FSWColDefn
(*args, **kwargs)¶ Bases:
object
FSWColDefn - Argument Definition
Argument Definitions encapsulate all information required to define a single column.
-
__init__
(*args, **kwargs)¶ Creates a new Column Definition.
-
decode
(in_stream, raw=False)¶ Decode a column’s value according to its data type
Read bytes equal to this column’s data type from the input stream and decode it into a value per that data type’s definition.
- Arguments:
in_stream: A file-like object from which to read data.
- raw: Flag denoting whether raw values or enumerate values
- (if present for this column) should be returned.
- Raises:
- EOFError: If the number of bytes read from the input stream
- is less than the length of the data type.
-
encode
(value)¶ Encode a columns value according to its data type
- Arguments:
- value: The value to encode provided as either a string or
- the appropriate type for the column’s data type.
-
-
class
ait.core.table.
FSWTab
(defn, *args)¶ Bases:
object
Table object that contains column definitions
-
__init__
(defn, *args)¶ Creates a new FSWTab based on the given definition arguments.
-
coldefns
¶ The table column definitions.
-
fswheaderdefns
¶ The table fsw header definitions.
-
-
class
ait.core.table.
FSWTabDefn
(*args, **kwargs)¶ Bases:
object
Table Definition
FSW Table Definitions encapsulate all information required to define a single column. This includes the column name, its opcode, subsystem, description and a list of argument definitions. Name and opcode are required. All others are optional.
-
__init__
(*args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
decode
(**kwargs)¶ Decode table data according to the current table definition
Decode table data (provided via either an input file or binary blob) given the current FSWTabDefn format. The decoded table data will be returned as a list of lists, each containing an individual row’s field data. The first row of the returned data is the header’s values if applicable for this table definition.
- Keyword Arguments:
- file_in (open file stream): A file stream from which to read
- the table data for decoding.
bin_in (bytes-like object): An encoded binary table data.
- raw (boolean): Flag indicating whether columns with enumerations
- should return a raw value (True) or an enumerated value (False) when the option exists. (default: False)
-
encode
(**kwargs)¶ Encode table data according to the current table definition
Encode table data (provided via either an input file or list of table rows) given the current FSWTabDefn format. Header data to be encoded can be included as the first non-comment row in the input stream or as a separate list of column values under the hdr_vals kwarg. Lines starting with a ‘#’ are considered comments and discarded.
Rows of table data (header or otherwise) should use the given table definitions delimiter to separate entries. Extra whitespace around entries is stripped whenever possible.
- Keyword Arguments:
- file_in (open file stream): A file stream from which to read
- the table data for encoding.
- text_in (list): A list of row strings to use when encoding
- the table data.
- hdr_vals (list): An optional list of values to use when encoding
- the header row. If values are passed here then no header values should be present in the input data source. Overlap here will result in unexpected behavior.
-
-
class
ait.core.table.
FSWTabDict
(*args, **kwargs)¶ Bases:
dict
Table dictionary object
Table Dictionaries provide a Python dictionary (i.e. hashtable) interface mapping Tables names to Column Definitions.
-
__init__
(*args, **kwargs)¶ Creates a new Table Dictionary from the given dictionary filename.
-
add
(defn)¶ Adds the given Table Definition to this Table Dictionary.
-
create
(name, *args)¶ Creates a new table with the given arguments.
-
load
(filename)¶ Loads Table Definitions from the given YAML file into this Table Dictionary.
-
-
class
ait.core.table.
FSWTabDictCache
(filename=None)¶ Bases:
object
-
__init__
(filename=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
load
()¶
-
dirty
¶ True if the pickle cache needs to be regenerated, False to use current pickle binary
-
-
ait.core.table.
YAMLCtor_FSWColDefn
(loader, node)¶
-
ait.core.table.
YAMLCtor_FSWTabDefn
(loader, node)¶
-
ait.core.table.
decode_to_file
(tbl_type, in_path, out_path)¶
-
ait.core.table.
encode_to_file
(tbl_type, in_path, out_path)¶
-
ait.core.table.
getDefaultDict
()¶
-
ait.core.table.
getDefaultFSWTabDict
()¶
-
ait.core.table.
hash_file
(filename)¶ Calculate SHA-1 hash of the passed file