diff --git a/papers/configs.py b/papers/configs.py index 4f133c1..d1b02c7 100644 --- a/papers/configs.py +++ b/papers/configs.py @@ -19,6 +19,7 @@ DFT_COLOR = 'yes' DFT_PLUGINS = 'texnote' DFT_CONFIG = {'papers_dir' : DFT_PAPERS_DIR, + 'doc_dir' : os.path.join(DFT_PAPERS_DIR, 'doc'), 'open_cmd' : DFT_OPEN_CMD, 'edit_cmd' : DFT_EDIT_CMD, 'import_copy' : DFT_IMPORT_COPY, @@ -41,10 +42,12 @@ def config(section = MAIN_SECTION): class Config(object): - def __init__(self): + def __init__(self, **kwargs): object.__setattr__(self, '_cfg', configparser.SafeConfigParser(DFT_CONFIG)) object.__setattr__(self, '_section', MAIN_SECTION) # active section self._cfg.add_section(self._section) + for name, value in kwargs.items(): + self.__setattr__(name, value) def as_global(self): global _config diff --git a/tests/test_config.py b/tests/test_config.py index bda8c7c..8d2d4d0 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -58,3 +58,7 @@ class TestConfig(unittest.TestCase): config(section = 'bla3').color self.assertEqual(config(section = 'bla3').get('color', default = 'green'), 'green') self.assertEqual(config(section = 'bla3').get('color', default = config().color), True) + + def test_keywords(self): + a = configs.Config(papers_dir = '/blabla') + self.assertEqual(a.papers_dir, '/blabla')