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

Method _parse_opt

tools/utility.py:25–45  ·  view source on GitHub ↗
(self, opts)

Source from the content-addressed store, hash-verified

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

Callers 1

parse_argsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected