diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-07-20 19:07:26 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-07-20 19:07:26 +0200 | 
| commit | 96f8d1373860d7df9d35e8c3e95a2963f71bebdc (patch) | |
| tree | cacf5415cf4667c2384d13c312d339312fa4b194 /ishtar_common | |
| parent | 030a7a7791f96649029370ead6bcff2c448db52e (diff) | |
| parent | 8fa0f928e68e10d4ef055bf9afd47e0e91ce7b55 (diff) | |
| download | Ishtar-96f8d1373860d7df9d35e8c3e95a2963f71bebdc.tar.bz2 Ishtar-96f8d1373860d7df9d35e8c3e95a2963f71bebdc.zip  | |
Merge branch 'master' into develop
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/models.py | 16 | 
1 files changed, 8 insertions, 8 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 6082fb4e0..01b46b7ae 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2532,20 +2532,20 @@ class Import(models.Model):              tmpdir = tempfile.mkdtemp(prefix='tmp-ishtar-')              imported_file = z.extract(filename, tmpdir) -        with open(imported_file) as csv_file: -            encodings = [self.encoding] -            encodings += [coding for coding, c in ENCODINGS] -            for encoding in encodings: -                try: +        encodings = [self.encoding] +        encodings += [coding for coding, c in ENCODINGS +                      if coding != self.encoding] +        for encoding in encodings: +            try: +                with open(imported_file) as csv_file:                      vals = [line                              for line in unicodecsv.reader(csv_file,                                                            encoding=encoding)]                      if tmpdir:                          shutil.rmtree(tmpdir)                      return vals -                except UnicodeDecodeError: -                    if encoding != encodings[-1]: -                        csv_file.seek(0) +            except UnicodeDecodeError: +                pass  # try the next encoding          if tmpdir:              shutil.rmtree(tmpdir)          return []  | 
