def test_removing_pipes(): assert strip_pipes('|a|b|c') == 'abc'
def __str__(self): OTT = '140' ORG_ID = self.org_id ORG_NOTIFICATION_TYPE = '001' ORG_NAME = '' NOTIFICATION_ID = self.notification_reference NOTIFICATION_DATE = '' CUSTOMER_REFERENCE = '' ADDITIONAL_LINE_1, \ ADDITIONAL_LINE_2, \ ADDITIONAL_LINE_3, \ ADDITIONAL_LINE_4, \ ADDITIONAL_LINE_5, \ ADDITIONAL_LINE_6, \ ADDITIONAL_LINE_7, \ ADDITIONAL_LINE_8, \ ADDITIONAL_LINE_9, \ ADDITIONAL_LINE_10 = [ line.strip() for line in (( Take.as_field(self.contact_block, self.values, html='strip_dvla_markup') ).as_string.split('\n') + ([''] * 10)) ][:10] TO_NAME_1,\ _,\ TO_ADDRESS_LINE_1,\ TO_ADDRESS_LINE_2,\ TO_ADDRESS_LINE_3,\ TO_ADDRESS_LINE_4,\ TO_ADDRESS_LINE_5,\ TO_POST_CODE, = str(Field( self.address_block, self.values_with_default_optional_address_lines, )).split('\n') TO_NAME_2 = '' RETURN_NAME = '' RETURN_ADDRESS_LINE_1 = '' RETURN_ADDRESS_LINE_2 = '' RETURN_ADDRESS_LINE_3 = '' RETURN_ADDRESS_LINE_4 = '' RETURN_ADDRESS_LINE_5 = '' RETURN_POST_CODE = '' SUBJECT_LINE = '' NOTIFICATION_BODY = ( '{}<cr><cr>' '<h1>{}<normal><cr><cr>' '{}' ).format( datetime.utcnow().strftime('%-d %B %Y'), self.subject, Take.as_field( self.content, self.values, markdown_lists=True, html='strip_dvla_markup').then(prepare_newlines_for_markdown). then(notify_letter_dvla_markdown).then( fix_extra_newlines_in_dvla_lists).as_string) return '|'.join( strip_pipes(line) for line in [ OTT, ORG_ID, ORG_NOTIFICATION_TYPE, ORG_NAME, NOTIFICATION_ID, NOTIFICATION_DATE, CUSTOMER_REFERENCE, ADDITIONAL_LINE_1, ADDITIONAL_LINE_2, ADDITIONAL_LINE_3, ADDITIONAL_LINE_4, ADDITIONAL_LINE_5, ADDITIONAL_LINE_6, ADDITIONAL_LINE_7, ADDITIONAL_LINE_8, ADDITIONAL_LINE_9, ADDITIONAL_LINE_10, TO_NAME_1, TO_NAME_2, TO_ADDRESS_LINE_1, TO_ADDRESS_LINE_2, TO_ADDRESS_LINE_3, TO_ADDRESS_LINE_4, TO_ADDRESS_LINE_5, TO_POST_CODE, RETURN_NAME, RETURN_ADDRESS_LINE_1, RETURN_ADDRESS_LINE_2, RETURN_ADDRESS_LINE_3, RETURN_ADDRESS_LINE_4, RETURN_ADDRESS_LINE_5, RETURN_POST_CODE, SUBJECT_LINE, NOTIFICATION_BODY, ])