fa.utils ======== .. module:: fa.utils This module contains utility code that is useful in a wide variety of FoneAstra projects. .. function:: 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. :param string chars: The data string. Only the first two chars are used. .. function:: 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. :param string readings: The string to get readings out ot. .. function:: 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. :param iterable iterable: The iterable to split up. :param int n: The size of the chunks. .. function:: 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. :param list regex_list: The list of (*regex*, *object*) tuples. :param string input_string: The string to match over the *regex*es.