""" Gaby HTML print plug-in Copyright (c) 2000 Frederic Peters Released under the terms of the GPL """ # the informations we want are in gaby.PrintDict import sys import string #sys.stderr = open('/dev/null', 'w') d = gaby.PrintDict _ = gaby.gettext if len(d['forms']) != 0 and len(d['fileforms']) == 0: gaby.message_dialog(2, _('You should set a file for the forms')) raise 'Error' if len(d['list']) != 0 and len(d['filelist'] ) == 0: gaby.message_dialog(2, _('You should set a file for the list')) raise 'Error' if len(d['list']) == 0 and len(d['form']) == 0: gaby.message_dialog(2, _('It would be a good idea to print something...')) raise 'Error' st = d['subtable'] rs = [] for id in d['records']: rs.append(st.get_record_no(id)) if d['order'] <> -1: sortfield = d['order'] def cmpfunc(x, y): if len(y[sortfield]) == 0: return 0 if len(x[sortfield]) == 0: return 1 return cmp(x[sortfield], y[sortfield]) rs.sort( lambda x,y: cmpfunc(x, y) ) if len(d['forms']): sf = [] for r, i in map(None, rs, range(len(rs))): sf.append('
| %s' % _('Form')) for f in d['list']: sl.append(' | %s' % st.i18n_fields[f]) sl.append('\n') if d['fileforms'] == d['filelist']: fforforms = '' else: fforforms = d['fileforms'] for r, i in map(None, rs, range(len(rs))): sl.append(' |
|---|---|
| *' % (fforforms,i) )
for f in d['list']:
s = string.replace(r[f], '\n', ' ') sl.append(' | %s' % s) sl.append('\n') sl.append(' |