4. fa.utils

This module contains utility code that is useful in a wide variety of FoneAstra projects.

fa.utils.convert_temp(chars)

Unpacks a single packed integer from two chars. Each value is a 12-bit two’s complement number, with eight integer bits and 4 fraction bits.

Parameters:chars (string) – The data string. Only the first two chars are used.
fa.utils.get_temp_sequence(readings)

Separates the given string into two char segments, then converts each of those segments to an integer and returns the list.

Parameters:readings (string) – The string to get readings out ot.
fa.utils.chunks(iterable, n)

Yield successive n-sized chunks from iterable. If the length of iterable is not evenly divisible by n, the final chunk will be small.

Parameters:
  • iterable (iterable) – The iterable to split up.
  • n (int) – The size of the chunks.
fa.utils.regex_test(regex_list, input_string)

Given a list of (regex, object) tuples and an input string, matches the input string against each regex in turn and returns a tuple containing the object and the regex match object if the string matches. Returns only the first match if there are 1+ matches, or (None, None) if there was no match.

Parameters:
  • regex_list (list) – The list of (regex, object) tuples.
  • input_string (string) – The string to match over the *regex*es.

Previous topic

3. fa.transports

This Page