diff options
| author | Timo Furrer <tuxtimo@gmail.com> | 2016-02-15 19:26:23 -0800 |
|---|---|---|
| committer | Timo Furrer <tuxtimo@gmail.com> | 2016-02-15 19:29:46 -0800 |
| commit | d99db57d75bc6a694e4eb2376d80aabbdcfbfca6 (patch) | |
| tree | 93cb9fdf3e7dfaf4e3164723a8340b29fd90e317 /tablib | |
| parent | 2299c00883a8f6feacc38aef2975d52f4aa477d7 (diff) | |
| download | tablib-d99db57d75bc6a694e4eb2376d80aabbdcfbfca6.tar.gz | |
Fix export only formats
Formats like LaTeX could have never been exported because
`setattr(cls, set_%s % fmt.title, fmt.import_set)` always failed
for export-only formats and with that the exception was caught in the
outer try/except and the format tuple was set to (None, None) with
`cls._formats[fmt.title] = (None, None)`
Diffstat (limited to 'tablib')
| -rw-r--r-- | tablib/core.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tablib/core.py b/tablib/core.py index 5b23cb5..f94dda2 100644 --- a/tablib/core.py +++ b/tablib/core.py @@ -252,12 +252,13 @@ class Dataset(object): try: try: setattr(cls, fmt.title, property(fmt.export_set, fmt.import_set)) + setattr(cls, 'get_%s' % fmt.title, fmt.export_set) + setattr(cls, 'set_%s' % fmt.title, fmt.import_set) cls._formats[fmt.title] = (fmt.export_set, fmt.import_set) except AttributeError: setattr(cls, fmt.title, property(fmt.export_set)) + setattr(cls, 'get_%s' % fmt.title, fmt.export_set) cls._formats[fmt.title] = (fmt.export_set, None) - setattr(cls, 'get_%s' % fmt.title, fmt.export_set) - setattr(cls, 'set_%s' % fmt.title, fmt.import_set) except AttributeError: cls._formats[fmt.title] = (None, None) |
