当前位置: 首页>>代码示例>>Python>>正文


Python conf.load_opts_from_mrjob_conf函数代码示例

本文整理汇总了Python中mrjob.conf.load_opts_from_mrjob_conf函数的典型用法代码示例。如果您正苦于以下问题:Python load_opts_from_mrjob_conf函数的具体用法?Python load_opts_from_mrjob_conf怎么用?Python load_opts_from_mrjob_conf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了load_opts_from_mrjob_conf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_include_relative_to_real_path

    def test_include_relative_to_real_path(self):
        os.mkdir(os.path.join(self.tmp_dir, 'conf'))

        base_conf_path = os.path.join(self.tmp_dir, 'conf', 'mrjob.base.conf')
        real_base_conf_path = os.path.realpath(base_conf_path)

        conf_path = os.path.join(self.tmp_dir, 'conf', 'mrjob.conf')
        conf_symlink_path = os.path.join(self.tmp_dir, 'mrjob.conf')

        with open(base_conf_path, 'w') as f:
            dump_mrjob_conf({}, f)

        with open(conf_path, 'w') as f:
            dump_mrjob_conf({'include': 'mrjob.base.conf'}, f)

        os.symlink(os.path.join('conf', 'mrjob.conf'), conf_symlink_path)

        self.assertEqual(
            load_opts_from_mrjob_conf('foo', conf_path),
            [(real_base_conf_path, {}), (conf_path, {})])

        # relative include should work from the symlink even though
        # it's not in the same directory as mrjob.base.conf
        self.assertEqual(
            load_opts_from_mrjob_conf('foo', conf_symlink_path),
            [(real_base_conf_path, {}), (conf_symlink_path, {})])
开发者ID:Affirm,项目名称:mrjob,代码行数:26,代码来源:test_conf.py

示例2: test_load_mrjob_conf_and_load_opts

    def test_load_mrjob_conf_and_load_opts(self):
        conf_path = os.path.join(self.tmp_dir, "mrjob.conf.2")
        with open(conf_path, "w") as f:
            f.write('{"runners": {"foo": {"qux": "quux"}}}')

        self.assertEqual(load_mrjob_conf(conf_path=conf_path), {"runners": {"foo": {"qux": "quux"}}})
        self.assertEqual(load_opts_from_mrjob_conf("foo", conf_path=conf_path)[0][1], {"qux": "quux"})
        # test missing options
        with logger_disabled("mrjob.conf"):
            self.assertEqual(load_opts_from_mrjob_conf("bar", conf_path=conf_path)[0][1], {})
开发者ID:JeffersonK,项目名称:mrjob,代码行数:10,代码来源:test_conf.py

示例3: test_load_mrjob_conf_and_load_opts

    def test_load_mrjob_conf_and_load_opts(self):
        conf_path = os.path.join(self.tmp_dir, 'mrjob.conf.2')
        with open(conf_path, 'w') as f:
            f.write('{"runners": {"foo": {"qux": "quux"}}}')

        assert_equal(load_mrjob_conf(conf_path=conf_path),
                     {'runners': {'foo': {'qux': 'quux'}}})
        assert_equal(load_opts_from_mrjob_conf('foo', conf_path=conf_path),
                     {'qux': 'quux'})
        # test missing options
        with logger_disabled('mrjob.conf'):
            assert_equal(
                load_opts_from_mrjob_conf('bar', conf_path=conf_path), {})
开发者ID:gimlids,项目名称:LTPM,代码行数:13,代码来源:conf_test.py

示例4: test_nested_include

    def test_nested_include(self):
        conf_path = os.path.join(self.tmp_dir, 'mrjob.conf')
        conf_path_1 = os.path.join(self.tmp_dir, 'mrjob.1.conf')
        conf_path_2 = os.path.join(self.tmp_dir, 'mrjob.2.conf')
        conf_path_3 = os.path.join(self.tmp_dir, 'mrjob.3.conf')

        # accidentally reversed the order of nested includes when
        # trying to make precedence work; this test would catch that

        with open(conf_path, 'w') as f:
            dump_mrjob_conf({'include': conf_path_1}, f)

        with open(conf_path_1, 'w') as f:
            dump_mrjob_conf({'include': [conf_path_2, conf_path_3]}, f)

        with open(conf_path_2, 'w') as f:
            dump_mrjob_conf({}, f)

        with open(conf_path_3, 'w') as f:
            dump_mrjob_conf({}, f)

        self.assertEqual(
            load_opts_from_mrjob_conf('foo', conf_path),
            [(conf_path_2, {}),
             (conf_path_3, {}),
             (conf_path_1, {}),
             (conf_path, {})])
开发者ID:Affirm,项目名称:mrjob,代码行数:27,代码来源:test_conf.py

示例5: test_recursive_include

    def test_recursive_include(self):
        conf_path = os.path.join(self.tmp_dir, 'mrjob.conf')
        with open(conf_path, 'w') as f:
            dump_mrjob_conf({'include': conf_path}, f)

        self.assertEqual(
            load_opts_from_mrjob_conf('foo', conf_path),
            [(conf_path, {})])
开发者ID:Affirm,项目名称:mrjob,代码行数:8,代码来源:test_conf.py

示例6: test_load_and_load_opts_use_find_mrjob_conf

    def test_load_and_load_opts_use_find_mrjob_conf(self):
        os.environ["HOME"] = self.tmp_dir

        dot_mrjob_path = os.path.join(self.tmp_dir, ".mrjob.conf")
        with open(dot_mrjob_path, "w") as f:
            f.write('{"runners": {"foo": {"bar": "baz"}}}')

        self.assertEqual(load_mrjob_conf(), {"runners": {"foo": {"bar": "baz"}}})
        self.assertEqual(load_opts_from_mrjob_conf("foo")[0][1], {"bar": "baz"})
开发者ID:JeffersonK,项目名称:mrjob,代码行数:9,代码来源:test_conf.py

示例7: test_load_and_load_opts_use_find_mrjob_conf

    def test_load_and_load_opts_use_find_mrjob_conf(self):
        os.environ['HOME'] = self.tmp_dir

        dot_mrjob_path = os.path.join(self.tmp_dir, '.mrjob.conf')
        with open(dot_mrjob_path, 'w') as f:
            f.write('{"runners": {"foo": {"bar": "baz"}}}')

        assert_equal(load_mrjob_conf(),
                     {'runners': {'foo': {'bar': 'baz'}}})
        assert_equal(load_opts_from_mrjob_conf('foo'), {'bar': 'baz'})
开发者ID:gimlids,项目名称:LTPM,代码行数:10,代码来源:conf_test.py

示例8: test_doubly_recursive_include

    def test_doubly_recursive_include(self):
        conf_path_1 = os.path.join(self.tmp_dir, "mrjob.1.conf")
        conf_path_2 = os.path.join(self.tmp_dir, "mrjob.2.conf")

        with open(conf_path_1, "w") as f:
            dump_mrjob_conf({"include": conf_path_2}, f)

        with open(conf_path_2, "w") as f:
            dump_mrjob_conf({"include": conf_path_1}, f)

        self.assertEqual(load_opts_from_mrjob_conf("foo", conf_path_1), [(conf_path_2, {}), (conf_path_1, {})])
开发者ID:kartheek6,项目名称:mrjob,代码行数:11,代码来源:test_conf.py

示例9: test_doubly_recursive_include

    def test_doubly_recursive_include(self):
        conf_path_1 = os.path.join(self.tmp_dir, 'mrjob.1.conf')
        conf_path_2 = os.path.join(self.tmp_dir, 'mrjob.2.conf')

        with open(conf_path_1, 'w') as f:
            dump_mrjob_conf({'include': conf_path_2}, f)

        with open(conf_path_2, 'w') as f:
            dump_mrjob_conf({'include': conf_path_1}, f)

        self.assertEqual(
            load_opts_from_mrjob_conf('foo', conf_path_1),
            [(conf_path_2, {}), (conf_path_1, {})])
开发者ID:Affirm,项目名称:mrjob,代码行数:13,代码来源:test_conf.py

示例10: test_relative_include

    def test_relative_include(self):
        base_conf_path = os.path.join(self.tmp_dir, "mrjob.base.conf")
        real_base_conf_path = os.path.realpath(base_conf_path)

        conf_path = os.path.join(self.tmp_dir, "mrjob.conf")

        with open(base_conf_path, "w") as f:
            dump_mrjob_conf({}, f)

        with open(conf_path, "w") as f:
            dump_mrjob_conf({"include": "mrjob.base.conf"}, f)

        self.assertEqual(load_opts_from_mrjob_conf("foo", conf_path), [(real_base_conf_path, {}), (conf_path, {})])
开发者ID:kartheek6,项目名称:mrjob,代码行数:13,代码来源:test_conf.py

示例11: test_relative_include

    def test_relative_include(self):
        base_conf_path = os.path.join(self.tmp_dir, 'mrjob.base.conf')
        real_base_conf_path = os.path.realpath(base_conf_path)

        conf_path = os.path.join(self.tmp_dir, 'mrjob.conf')

        with open(base_conf_path, 'w') as f:
            dump_mrjob_conf({}, f)

        with open(conf_path, 'w') as f:
            dump_mrjob_conf({'include': 'mrjob.base.conf'}, f)

        self.assertEqual(
            load_opts_from_mrjob_conf('foo', conf_path),
            [(real_base_conf_path, {}), (conf_path, {})])
开发者ID:Affirm,项目名称:mrjob,代码行数:15,代码来源:test_conf.py

示例12: test_include_relative_to_real_path

    def test_include_relative_to_real_path(self):
        os.mkdir(os.path.join(self.tmp_dir, "conf"))

        base_conf_path = os.path.join(self.tmp_dir, "conf", "mrjob.base.conf")
        real_base_conf_path = os.path.realpath(base_conf_path)

        conf_path = os.path.join(self.tmp_dir, "conf", "mrjob.conf")
        conf_symlink_path = os.path.join(self.tmp_dir, "mrjob.conf")

        with open(base_conf_path, "w") as f:
            dump_mrjob_conf({}, f)

        with open(conf_path, "w") as f:
            dump_mrjob_conf({"include": "mrjob.base.conf"}, f)

        os.symlink(os.path.join("conf", "mrjob.conf"), conf_symlink_path)

        self.assertEqual(load_opts_from_mrjob_conf("foo", conf_path), [(real_base_conf_path, {}), (conf_path, {})])

        # relative include should work from the symlink even though
        # it's not in the same directory as mrjob.base.conf
        self.assertEqual(
            load_opts_from_mrjob_conf("foo", conf_symlink_path), [(real_base_conf_path, {}), (conf_symlink_path, {})]
        )
开发者ID:kartheek6,项目名称:mrjob,代码行数:24,代码来源:test_conf.py

示例13: test_tilde_in_include

    def test_tilde_in_include(self):
        # regression test for #1308

        os.environ['HOME'] = self.tmp_dir
        base_conf_path = os.path.join(self.tmp_dir, 'mrjob.base.conf')
        conf_path = os.path.join(self.tmp_dir, 'mrjob.conf')

        with open(base_conf_path, 'w') as f:
            dump_mrjob_conf({}, f)

        with open(conf_path, 'w') as f:
            dump_mrjob_conf({'include': '~/mrjob.base.conf'}, f)

        self.assertEqual(
            load_opts_from_mrjob_conf('foo', conf_path),
            [(base_conf_path, {}), (conf_path, {})])
开发者ID:Affirm,项目名称:mrjob,代码行数:16,代码来源:test_conf.py

示例14: test_include_order_beats_include

    def test_include_order_beats_include(self):
        conf_path = os.path.join(self.tmp_dir, "mrjob.conf")
        conf_path_1 = os.path.join(self.tmp_dir, "mrjob.1.conf")
        conf_path_2 = os.path.join(self.tmp_dir, "mrjob.2.conf")

        with open(conf_path, "w") as f:
            dump_mrjob_conf({"include": [conf_path_1, conf_path_2]}, f)

        with open(conf_path_1, "w") as f:
            dump_mrjob_conf({"include": [conf_path_2]}, f)

        with open(conf_path_2, "w") as f:
            dump_mrjob_conf({}, f)

        # shouldn't matter that conf_path_1 includes conf_path_2
        self.assertEqual(
            load_opts_from_mrjob_conf("foo", conf_path), [(conf_path_1, {}), (conf_path_2, {}), (conf_path, {})]
        )
开发者ID:kartheek6,项目名称:mrjob,代码行数:18,代码来源:test_conf.py

示例15: test_include_order_beats_include

    def test_include_order_beats_include(self):
        conf_path = os.path.join(self.tmp_dir, 'mrjob.conf')
        conf_path_1 = os.path.join(self.tmp_dir, 'mrjob.1.conf')
        conf_path_2 = os.path.join(self.tmp_dir, 'mrjob.2.conf')

        with open(conf_path, 'w') as f:
            dump_mrjob_conf({'include': [conf_path_1, conf_path_2]}, f)

        with open(conf_path_1, 'w') as f:
            dump_mrjob_conf({'include': [conf_path_2]}, f)

        with open(conf_path_2, 'w') as f:
            dump_mrjob_conf({}, f)

        # shouldn't matter that conf_path_1 includes conf_path_2
        self.assertEqual(
            load_opts_from_mrjob_conf('foo', conf_path),
            [(conf_path_1, {}), (conf_path_2, {}), (conf_path, {})])
开发者ID:Affirm,项目名称:mrjob,代码行数:18,代码来源:test_conf.py


注:本文中的mrjob.conf.load_opts_from_mrjob_conf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。