MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / readconfig

Function readconfig

Python/Turtle.py:98–126  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

96 return cfgdict
97
98def 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
128try:
129 readconfig(_CFG)

Callers 1

Turtle.pyFile · 0.85

Calls 2

config_dictFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected