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)
| 96 | return cfgdict |
| 97 | |
| 98 | def readconfig(cfgdict): |
| 99 | """Read config-files, change configuration-dict accordingly. |
| 100 | |
| 101 | If there is a turtle.cfg file in the current working directory, |
| 102 | read it from there. If this contains an importconfig-value, |
| 103 | say 'myway', construct filename turtle_mayway.cfg else use |
| 104 | turtle.cfg and read it from the import-directory, where |
| 105 | turtle.py is located. |
| 106 | Update configuration dictionary first according to config-file, |
| 107 | in the import directory, then according to config-file in the |
| 108 | current working directory. |
| 109 | If no config-file is found, the default configuration is used. |
| 110 | """ |
| 111 | default_cfg = "turtle.cfg" |
| 112 | cfgdict1 = {} |
| 113 | cfgdict2 = {} |
| 114 | if isfile(default_cfg): |
| 115 | cfgdict1 = config_dict(default_cfg) |
| 116 | if "importconfig" in cfgdict1: |
| 117 | default_cfg = "turtle_%s.cfg" % cfgdict1["importconfig"] |
| 118 | try: |
| 119 | head, tail = split(__file__) |
| 120 | cfg_file2 = join(head, default_cfg) |
| 121 | except Exception: |
| 122 | cfg_file2 = "" |
| 123 | if isfile(cfg_file2): |
| 124 | cfgdict2 = config_dict(cfg_file2) |
| 125 | _CFG.update(cfgdict2) |
| 126 | _CFG.update(cfgdict1) |
| 127 | |
| 128 | try: |
| 129 | readconfig(_CFG) |
no test coverage detected