1.6. utils

fitdecode.utils.scrub_method_name(method_name, convert_units=False)

Create a valid Python name out of method_name

fitdecode.utils.get_mesg_type(mesg_name_or_num)

Get a fitdecode.MessageType from profile, by its name (str) or its global number (int).

Raise ValueError if type was not found.

fitdecode.utils.get_mesg_num(mesg_name)

Get the global number of a message as defined in profile, by its name

Raise ValueError if type was not found.

fitdecode.utils.get_mesg_field(mesg_name_or_num, field_name_or_num)

Get the fitdecode.types.Field object of a particular field from a particular message.

Raise ValueError if message or field was not found.

fitdecode.utils.get_mesg_field_num(mesg_name_or_num, field_name)

Get the definition number of a particular field from a particular message.

Raise ValueError if message or field was not found.

fitdecode.utils.get_field_type(field_name)

Get fitdecode.FieldType by name from profile.

Raise ValueError if type was not found.

fitdecode.utils.compute_crc(byteslike, *, crc=0, start=0, end=None)

Compute the CRC as per FIT definition, of byteslike object, from offset start (included) to end (excluded)

fitdecode.utils.blocking_read(istream, size=-1, nonblocking_reads_delay=0.06)

Read from istream and do not return until size bytes have been read unless EOF has been reached.

Return all the data read so far. The length of the returned data may still be less than size in case EOF has been reached.

nonblocking_reads_delay specifies the number of seconds (float) to wait before trying to read from istream again in case BlockingIOError has been raised during previous call.