|
2004 | 2004 | "#|export\n", |
2005 | 2005 | "class Config:\n", |
2006 | 2006 | " \"Reading and writing `ConfigParser` ini files\"\n", |
2007 | | - " def __init__(self, cfg_path, cfg_name, create=None, save=True, extra_files=[]):\n", |
| 2007 | + " def __init__(self, cfg_path, cfg_name, create=None, save=True, extra_files=None):\n", |
2008 | 2008 | " cfg_path = Path(cfg_path).expanduser().absolute()\n", |
2009 | 2009 | " self.config_path,self.config_file = cfg_path,cfg_path/cfg_name\n", |
2010 | 2010 | " self._cfg = ConfigParser()\n", |
2011 | 2011 | " self.d = self._cfg['DEFAULT']\n", |
2012 | | - " found = [Path(o) for o in self._cfg.read(extra_files+[self.config_file])]\n", |
| 2012 | + " found = [Path(o) for o in self._cfg.read(L(extra_files)+[self.config_file])]\n", |
2013 | 2013 | " if self.config_file not in found and create is not None:\n", |
2014 | 2014 | " self._cfg.read_dict({'DEFAULT':create})\n", |
2015 | 2015 | " if save:\n", |
2016 | 2016 | " cfg_path.mkdir(exist_ok=True, parents=True)\n", |
2017 | | - " self.save()\n", |
| 2017 | + " save_config_file(self.config_file, create)\n", |
2018 | 2018 | "\n", |
2019 | 2019 | " def __repr__(self): return repr(dict(self._cfg.items('DEFAULT', raw=True)))\n", |
2020 | 2020 | " def __setitem__(self,k,v): self.d[k] = str(v)\n", |
|
2040 | 2040 | "cell_type": "markdown", |
2041 | 2041 | "metadata": {}, |
2042 | 2042 | "source": [ |
2043 | | - "Instantiate a `Config` from a ini file at `cfg_path/cfg_name`:" |
| 2043 | + "Instantiate a `Config` from an ini file at `cfg_path/cfg_name`:" |
2044 | 2044 | ] |
2045 | 2045 | }, |
2046 | 2046 | { |
|
0 commit comments