Ticket #8165: csv2.patch
| File csv2.patch, 3.1 KB (added by Thijs Triemstra <lists@…>, 20 months ago) |
|---|
-
trac/ticket/report.py
39 39 add_stylesheet, add_warning, \ 40 40 INavigationContributor, Chrome 41 41 from trac.wiki import IWikiSyntaxProvider, WikiParser 42 from trac.wiki.formatter import format_to_plaintext 42 43 43 44 44 45 def cell_value(v): … … 726 727 def iso_datetime(dt): 727 728 return format_datetime(from_utimestamp(dt), 'iso8601') 728 729 730 def plaintext(s): 731 return format_to_plaintext(self.env, Context.from_request(req), s) 732 729 733 col_conversions = { 734 'description': plaintext, 730 735 'time': iso_time, 731 736 'datetime': iso_datetime, 732 737 'changetime': iso_datetime, -
trac/ticket/query.py
44 44 45 45 from trac.wiki.api import IWikiSyntaxProvider 46 46 from trac.wiki.macros import WikiMacroBase # TODO: should be moved in .api 47 from trac.wiki.formatter import format_to_plaintext 47 48 49 48 50 class QuerySyntaxError(TracError): 49 51 """Exception raised when a ticket query cannot be parsed from a string.""" 50 52 … … 1099 1101 def export_csv(self, req, query, sep=',', mimetype='text/plain'): 1100 1102 content = StringIO() 1101 1103 cols = query.get_columns() 1104 1105 if 'description' in query.rows: 1106 query.cols.insert(2, 'description') 1107 1102 1108 writer = csv.writer(content, delimiter=sep, quoting=csv.QUOTE_MINIMAL) 1103 1109 writer.writerow([unicode(c).encode('utf-8') for c in cols]) 1104 1110 … … 1115 1121 value) 1116 1122 elif col in query.time_fields: 1117 1123 value = format_datetime(value, tzinfo=req.tz) 1124 elif col == 'description': 1125 value = format_to_plaintext(self.env, context, value) 1118 1126 values.append(unicode(value).encode('utf-8')) 1119 1127 writer.writerow(values) 1120 1128 return (content.getvalue(), '%s;charset=utf-8' % mimetype) -
trac/wiki/formatter.py
42 42 43 43 __all__ = ['wiki_to_html', 'wiki_to_oneliner', 'wiki_to_outline', 44 44 'Formatter', 'format_to', 'format_to_html', 'format_to_oneliner', 45 ' extract_link']45 'format_to_plaintext', 'extract_link'] 46 46 47 47 48 48 def system_message(msg, text=None): … … 1503 1503 shorten = context.get_hint('shorten_lines', False) 1504 1504 return InlineHtmlFormatter(env, context, wikidom).generate(shorten) 1505 1505 1506 def format_to_plaintext(env, context, wikidom): 1507 html = format_to_html(env, context, wikidom) 1508 return plaintext(html)[1:-2] 1509 1506 1510 def extract_link(env, context, wikidom): 1507 1511 if not wikidom: 1508 1512 return Markup()
