def composePrint(apibase, password, **msg): """ Create an atlas. """ kwargs = dict(print_id=msg['print_id'], paper_size=msg['paper_size'], orientation=msg['orientation'], layout=msg.get('layout', 'full-page'), pages=msg['pages']) if 'form_id' in msg and 'form_url' in msg: def on_fields(fields): for page in msg['pages']: page['text'] = (page.get('text', '').strip() + '\n\n' + forms.fields_as_text(fields['fields'])).strip() print 'Composing print', msg['print_id'], 'and form', msg['form_id'] try: compose.main(apibase, password, **kwargs) forms.main(apibase, password, msg['form_id'], msg['form_url'], on_fields) except: client.captureException() raise else: if 'form_fields' in msg: for page in msg['pages']: page['text'] = (page.get('text', '').strip() + '\n\n' + forms.fields_as_text(msg['form_fields'])).strip() print 'Composing print', msg['print_id'] try: compose.main(apibase, password, **kwargs) except: client.captureException() raise
def on_fields(fields): for page in msg['pages']: page['text'] = (page.get('text', '').strip() + '\n\n' + forms.fields_as_text(fields['fields'])).strip()