2011-11-22 18:49:36 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
openslides.utils.csv_ext
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Additional dialect definitions for pythons CSV module.
|
|
|
|
|
|
|
|
:copyright: 2011 by the OpenSlides team, see AUTHORS.
|
|
|
|
:license: GNU GPL, see LICENSE for more details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from csv import Dialect, excel, register_dialect
|
|
|
|
|
2011-11-24 19:38:25 +01:00
|
|
|
class excel_semikolon(Dialect):
|
|
|
|
delimiter = ';'
|
|
|
|
doublequote = True
|
|
|
|
lineterminator = '\r\n'
|
|
|
|
quotechar = '"'
|
|
|
|
quoting = 0
|
|
|
|
skipinitialspace = False
|
2011-11-22 18:49:36 +01:00
|
|
|
|
2011-11-24 19:38:25 +01:00
|
|
|
def patchup(dialect):
|
|
|
|
if dialect:
|
2011-11-24 20:24:13 +01:00
|
|
|
if dialect.delimiter in [excel_semikolon.delimiter, excel.delimiter] and \
|
2011-11-24 19:38:25 +01:00
|
|
|
dialect.quotechar == excel_semikolon.quotechar:
|
|
|
|
# walks like a duck and talks like a duck.. must be one
|
|
|
|
dialect.doublequote = True
|
|
|
|
return dialect
|
2011-11-22 18:49:36 +01:00
|
|
|
|
|
|
|
register_dialect("excel_semikolon", excel_semikolon)
|
|
|
|
|