def display_message(self, message): if message: is_reset_message = message == u' ' self._message_to_send = self._message_header + as_ascii( u' ' if is_reset_message else adjust_string( message, MAX_CENTER_DISPLAY_LENGTH).strip( )) + self._message_tail self._request_send_message()
def adjust_arguments(format_string, original_arguments): adjusted_arguments = list(original_arguments) matches = re.finditer(FORMAT_SPECIFIER_WITH_MARKUP_PATTERN, format_string) for index, match in enumerate(matches): has_markup = match.group(1) original_format_specifier = match.group(3) if has_markup is not None: desired_length = int(match.group(2)) original_argument = original_arguments[index] if original_format_specifier != 's': if original_format_specifier.find('*') != -1: raise ValueError('Format specifiers using * for field width/precision are not supported') original_argument = ('%' + original_format_specifier) % original_argument adjusted_arguments[index] = adjust_string(original_argument, desired_length) return tuple(adjusted_arguments)
def adjust_arguments(format_string, original_arguments): adjusted_arguments = list(original_arguments) matches = re.finditer(FORMAT_SPECIFIER_WITH_MARKUP_PATTERN, format_string) for index, match in enumerate(matches): has_markup = match.group(1) original_format_specifier = match.group(3) if has_markup is not None: desired_length = int(match.group(2)) original_argument = original_arguments[index] if original_format_specifier != u's': if original_format_specifier.find(u'*') != -1: raise ValueError(u'Format specifiers using * for field width/precision are not supported') original_argument = (u'%' + original_format_specifier) % original_argument adjusted_arguments[index] = adjust_string(original_argument, desired_length) return tuple(adjusted_arguments)
def combine_strings(string1, string2, length): part_length = old_div(length - 1, 2) return '{} {}'.format(adjust_string(string1, part_length), adjust_string(string2, part_length))
def _drum_pad_notification_formatter(self): return lambda x: adjust_string(x, 8)