def test_int_to_alpha(self): self.assertIs(int_to_alpha('a'), None) self.assertIs(int_to_alpha(3.14), None) self.assertIs(int_to_alpha(-1), None) self.assertEqual(int_to_alpha(1), 'a') self.assertEqual(int_to_alpha(26), 'z') self.assertEqual(int_to_alpha(27), 'aa') self.assertEqual(int_to_alpha(30), 'dd') self.assertEqual(int_to_alpha(52), 'zz') self.assertIs(int_to_alpha(53), None)
def parse_appendices(appendices, part): """ Process the list of appendices (minus interps) and send them along. """ if not appendices: return subpart = PAYLOAD.subparts['appendix_subpart'] for i, _appendix in enumerate(appendices): n_value = _appendix['N'] head = _appendix.find('HEAD').text.strip() _appendix.find('HEAD').replaceWith('') default_label = int_to_alpha(i + 1).upper() label = get_appendix_label(n_value, head, default_label) if PAYLOAD.interp_refs and label in PAYLOAD.interp_refs: prefix = PAYLOAD.interp_refs[label]['1'] + '\n' else: prefix = '' appendix = Section( subpart=subpart, label=label, title=head, contents=prefix + parse_appendix_elements(_appendix, default_label) ) appendix.save() PAYLOAD.appendices.append(appendix)
def parse_appendices(appendices, part): """ Process the list of appendices (minus interps) and send them along. """ if not appendices: return subpart = PAYLOAD.subparts['appendix_subpart'] for i, _appendix in enumerate(appendices): n_value = _appendix['N'] head = _appendix.find('HEAD').text.strip() _appendix.find('HEAD').replaceWith('') default_label = int_to_alpha(i + 1).upper() label = get_appendix_label(n_value, head, default_label) if PAYLOAD.interp_refs and label in PAYLOAD.interp_refs: prefix = PAYLOAD.interp_refs[label]['1'] + '\n' else: prefix = '' appendix = Section(subpart=subpart, label=label, title=head, contents=prefix + parse_appendix_elements(_appendix, default_label)) appendix.save() PAYLOAD.appendices.append(appendix)