Read config-files, change configuration-dict accordingly. If there is a turtle.cfg file in the current working directory, read it from there. If this contains an importconfig-value, say 'myway', construct filename turtle_mayway.cfg else use turtle.cfg and read it from the import-dir
(cfgdict)
| 195 | return cfgdict |
| 196 | |
| 197 | def readconfig(cfgdict): |
| 198 | """Read config-files, change configuration-dict accordingly. |
| 199 | |
| 200 | If there is a turtle.cfg file in the current working directory, |
| 201 | read it from there. If this contains an importconfig-value, |
| 202 | say 'myway', construct filename turtle_mayway.cfg else use |
| 203 | turtle.cfg and read it from the import-directory, where |
| 204 | turtle.py is located. |
| 205 | Update configuration dictionary first according to config-file, |
| 206 | in the import directory, then according to config-file in the |
| 207 | current working directory. |
| 208 | If no config-file is found, the default configuration is used. |
| 209 | """ |
| 210 | default_cfg = "turtle.cfg" |
| 211 | cfgdict1 = {} |
| 212 | cfgdict2 = {} |
| 213 | if isfile(default_cfg): |
| 214 | cfgdict1 = config_dict(default_cfg) |
| 215 | if "importconfig" in cfgdict1: |
| 216 | default_cfg = "turtle_%s.cfg" % cfgdict1["importconfig"] |
| 217 | try: |
| 218 | head, tail = split(__file__) |
| 219 | cfg_file2 = join(head, default_cfg) |
| 220 | except Exception: |
| 221 | cfg_file2 = "" |
| 222 | if isfile(cfg_file2): |
| 223 | cfgdict2 = config_dict(cfg_file2) |
| 224 | _CFG.update(cfgdict2) |
| 225 | _CFG.update(cfgdict1) |
| 226 | |
| 227 | try: |
| 228 | readconfig(_CFG) |