segpy.header module¶
-
class
segpy.header.
BaseHeader
(*args, **kwargs)¶ Bases:
object
An abstract base class for header format definitions.
Prefer to inherit from Header rather than BaseHeader.
-
copy
(**updates)¶
-
classmethod
ordered_field_names
()¶ The ordered list of field names.
This is a metamethod which should be called on cls.
Returns: An tuple containing the field names in order.
-
-
class
segpy.header.
FormatMeta
¶ Bases:
type
A metaclass for header format classes.
-
class
segpy.header.
Header
(*args, **kwargs)¶ Bases:
segpy.header.BaseHeader
A base class for header definition classes.
-
class
segpy.header.
HeaderFieldDescriptor
(value_type, offset, default, documentation)¶ Bases:
object
-
class
segpy.header.
NamedField
(value_type, offset, default, documentation)¶ Bases:
object
Instances of NamedField can be detected by the NamedDescriptorResolver metaclass.
-
default
¶ The default value of the field. Must be convertible to value_type.
-
documentation
¶ A descriptive text string.
-
name
¶ The field name.
-
offset
¶ The offset in bytes from the beginning of the header.
-
value_type
¶ The field value type (e.g. Int32)
-
-
class
segpy.header.
SubFormatMeta
(mcs, name, bases, namespace, parent_format, parent_field_names)¶ Bases:
segpy.header.FormatMeta
A metaclass for a format class which has a subset of the fields in an existing format class.
SubFormat classes can be used to reduce storage requirements and increase performance, since they can be used to generate simpler HeaderPackers.
Usage:
class MySubFormat(metaclass=SubFormatMeta, parent_format=MyFormatClass, parent_field_names=[ 'first_field_name', 'second_field_name']): pass
-
segpy.header.
are_equal
(header_a, header_b)¶ Compare two headers for equality.
Note
This is not implemented as __eq__() to prevent recursive behaviour in the header descriptor.
-
segpy.header.
field
(value_type, offset, default, documentation)¶ offset: The offset in bytes for this field from the start of the header.
default: The default value for this field.
- documentation: A docstring for the field. The first sentence should be usable
- as a brief description.
Returns: An instance of a subclass of HeaderFieldDescriptor class.
-
segpy.header.
is_public_non_field_attr
(name, attr)¶