Project

Profile

Help

Revision ebe2010d

IDebe2010d87daa3aa00a5076fe20a2680e9296cf8
Parent 96664dff
Child 12e1b5aa

Added by Vincent Le Goff almost 3 years ago

Add automatic convertion from utf-8 with signature to latin-1 in the configuration if needed

View differences:

src/world.py
36 36
from textwrap import dedent
37 37
from threading import RLock
38 38

  
39
from configobj import ConfigObj
39
from configobj import ConfigObj, ParseError
40 40
from ytranslate import t
41 41

  
42 42
from character import Character
......
152 152
        """).strip("\n")
153 153

  
154 154
        if self.settings is None:
155
            self.settings = ConfigObj(spec.split("\n"), encoding="latin-1")
155
            try:
156
                self.settings = ConfigObj(spec.split("\n"), encoding="latin-1")
157
            except ParseError:
158
                logger.warning("Error while parsing the config file, " \
159
                        "trying without encoding")
160
                self.settings = ConfigObj(spec.split("\n"))
161
                self.settings.encoding = "latin-1"
162
                self.settings.write()
156 163

  
157 164
        connection = self.settings["connection"]
158 165
        connection["name"] = self.name

Also available in: Unified diff