How to use the anyconfig.api.multi_load function in anyconfig

To help you get started, we’ve selected a few anyconfig examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ssato / python-anyconfig / tests / api.py View on Github external
def test_60_wrong_merge_strategy(self):
        cpath = os.path.join(self.workdir, "a.json")
        TT.dump(dict(a=1, b=2), cpath)
        try:
            TT.multi_load([cpath, cpath], ac_merge="merge_st_not_exist")
            raise RuntimeError("Wrong merge strategy was not handled!")
        except ValueError:
            self.assertTrue(bool(1))  # To suppress warn of pylint.
github ssato / python-anyconfig / tests / api.py View on Github external
def _check_multi_load_with_strategy(self, exp, merge=TT.MS_DICTS):
        TT.dump(self.dic, self.a_path)
        TT.dump(self.upd, self.b_path)

        self.assertTrue(os.path.exists(self.a_path))
        self.assertTrue(os.path.exists(self.b_path))

        res0 = TT.multi_load(self.g_path, ac_merge=merge)
        res1 = TT.multi_load([self.g_path, self.b_path], ac_merge=merge)

        self.assertTrue(res0)
        self.assertTrue(res1)

        self.assert_dicts_equal(res0, exp)
        self.assert_dicts_equal(res1, exp)
github ssato / python-anyconfig / tests / api.py View on Github external
def _check_multi_load_with_strategy(self, exp, merge=TT.MS_DICTS):
        TT.dump(self.dic, self.a_path)
        TT.dump(self.upd, self.b_path)

        self.assertTrue(os.path.exists(self.a_path))
        self.assertTrue(os.path.exists(self.b_path))

        res0 = TT.multi_load(self.g_path, ac_merge=merge)
        res1 = TT.multi_load([self.g_path, self.b_path], ac_merge=merge)

        self.assertTrue(res0)
        self.assertTrue(res1)

        self.assert_dicts_equal(res0, exp)
        self.assert_dicts_equal(res1, exp)
github ssato / python-anyconfig / tests / api.py View on Github external
def test_40_multi_load__ignore_missing(self):
        cpath = os.path.join(os.curdir, "conf_file_should_not_exist")
        assert not os.path.exists(cpath)

        self.assertEqual(TT.multi_load([cpath], ac_parser="ini",
                                       ac_ignore_missing=True),
                         NULL_CNTNR)
        # It will be remove after 'ignore_missing' was deprecated and removed.
        self.assertEqual(TT.multi_load([cpath], ac_parser="ini",
                                       ignore_missing=True),
                         NULL_CNTNR)
github ssato / python-anyconfig / tests / api.py View on Github external
def test_10_multi_load_w_validation_for_partial_single_config_files(self):
        cpaths = [os.path.join(resdir(), "00-00-cnf.json"),
                  os.path.join(resdir(), "00-01-cnf.json"),
                  os.path.join(resdir(), "00-02-cnf.json")]
        spath = os.path.join(resdir(), "00-scm.json")

        cnf = TT.multi_load(cpaths, ac_schema=spath)
        ref = TT.multi_load(cpaths)
        self.assert_dicts_equal(cnf, ref, ordered=False)
github ssato / python-anyconfig / tests / api.py View on Github external
def test_40_multi_load__ignore_missing(self):
        cpath = os.path.join(os.curdir, "conf_file_should_not_exist")
        assert not os.path.exists(cpath)

        self.assertEqual(TT.multi_load([cpath], ac_parser="ini",
                                       ac_ignore_missing=True),
                         NULL_CNTNR)
        # It will be remove after 'ignore_missing' was deprecated and removed.
        self.assertEqual(TT.multi_load([cpath], ac_parser="ini",
                                       ignore_missing=True),
                         NULL_CNTNR)