MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / _parse_opt

Method _parse_opt

tools/engine/config.py:27–47  ·  view source on GitHub ↗
(self, opts)

Source from the content-addressed store, hash-verified

25 return args
26
27 def _parse_opt(self, opts):
28 config = {}
29 if not opts:
30 return config
31 for s in opts:
32 s = s.strip()
33 k, v = s.split('=', 1)
34 if '.' not in k:
35 config[k] = yaml.load(v, Loader=yaml.Loader)
36 else:
37 keys = k.split('.')
38 if keys[0] not in config:
39 config[keys[0]] = {}
40 cur = config[keys[0]]
41 for idx, key in enumerate(keys[1:]):
42 if idx == len(keys) - 2:
43 cur[key] = yaml.load(v, Loader=yaml.Loader)
44 else:
45 cur[key] = {}
46 cur = cur[key]
47 return config
48
49
50class AttrDict(dict):

Callers 1

parse_argsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected