def ascii(file_path, address_name, street_and_number, postcode_and_city, country): """ :param file_path: path to the text file you want to parse. :param address_name: see idea_layout.txt :param street_and_number: see idea_layout.txt :param postcode_and_city: see idea_layout.txt :param country: see idea_layout.txt :return: text file containing all the postcards """ message_list = message_listing.build(file_path) # postcard_layout = postcard.empty(address_name, street_and_number, postcode_and_city, country) formatted_message_list = message_listing.format_monospace_font(message_list) count = 0 twelve_lines = list() postcard_stack = list() for number in range(len(formatted_message_list)): if count < 12: twelve_lines.append(formatted_message_list[number]) count += 1 if count == 12: postcard_stack.append(postcard.fill(twelve_lines, postcard.empty(address_name, street_and_number, postcode_and_city, country))) count = 0 twelve_lines = list() postcard_stack.append(postcard.fill(twelve_lines, postcard.empty(address_name, street_and_number, postcode_and_city, country))) return postcard_stack
def test_format_monospace_short_person2(self): test_list = [(False, 'just a few chars')] text_width = random.randint(30,50) result_list = message_listing.format_monospace_font(test_list, text_width) self.assertEqual(len(result_list), 1) self.assertEqual(len(result_list[0]), text_width) short_line = 'just a few chars<-' for _ in range(text_width - 18): short_line = ' ' + short_line self.assertEqual(result_list[0], short_line)
def test_format_monospace_date(self): test_list = [('date', '[29.06.2015]')] text_width = random.randint(30,50) result_list = message_listing.format_monospace_font(test_list, text_width) self.assertEqual(len(result_list), 2) self.assertEqual(len(result_list[0]), text_width) self.assertEqual(len(result_list[1]), text_width) blank_line = '' for _ in range(text_width): blank_line = blank_line + ' ' self.assertEqual(result_list[0], blank_line) date_line = ' [29.06.2015]' for _ in range(text_width - 17): date_line = date_line + ' ' self.assertEqual(result_list[1], date_line)