@classmethod<EOL><INDENT>def from_conf(cls, path=None, **overrides):<DEDENT>
from onedrive import portalocker<EOL>import yaml<EOL>if path is None:<EOL><INDENT>path = cls.conf_path_default<EOL>log.debug('<STR_LIT>', path)<EOL><DEDENT>path = os.path.expanduser(path)<EOL>with open(path, '<STR_LIT:rb>') as src:<EOL><INDENT>portalocker.lock(src, portalocker.LOCK_SH)<EOL>yaml_str = src.read()<EOL>portalocker.unlock(src)<EOL><DEDENT>conf = yaml.safe_load(yaml_str)<EOL>conf.setdefault('<STR_LIT>', path)<EOL>conf_cls = dict()<EOL>for ns, keys in cls.conf_update_keys.viewitems():<EOL><INDENT>for k in keys:<EOL><INDENT>try:<EOL><INDENT>v = conf.get(ns, dict()).get(k)<EOL><DEDENT>except AttributeError:<EOL><INDENT>if not cls.conf_raise_structure_errors: raise<EOL>raise KeyError((<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' ).format(ns=ns, k=k, path=path))<EOL><DEDENT>if v is not None: conf_cls['<STR_LIT>'.format(ns, k)] = conf[ns][k]<EOL><DEDENT><DEDENT>conf_cls.update(overrides)<EOL>if isinstance(conf.get('<STR_LIT>', dict()).get('<STR_LIT:id>'), (int, long)):<EOL><INDENT>log.warn( '<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>', path )<EOL>cid = conf['<STR_LIT>']['<STR_LIT:id>']<EOL>if not re.search(r'<STR_LIT>'.format(cid), yaml_str)and re.search(r'<STR_LIT>'.format(cid), yaml_str):<EOL><INDENT>cid = int('<STR_LIT>'.format(cid))<EOL><DEDENT>conf['<STR_LIT>']['<STR_LIT:id>'] = '<STR_LIT>'.format(cid)<EOL><DEDENT>self = cls(**conf_cls)<EOL>self.conf_save = conf['<STR_LIT>']<EOL>return self<EOL>
Initialize instance from YAML configuration file,
                writing updates (only to keys, specified by "conf_update_keys") back to it.