Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(7)  |  Call(7)  |  Derive(0)  |  Import(0)
Set a dpm configuration value. If section or option are not already in the config, creates them.

:param section:
    the name of the section in the ini file, e.g. "index:ckan".
:type section: str

:param option:
    the name of the option to be retrieved from the section of the ini file, e.g. 'ckan.api_key'
:type option: str
(more...)

        def set_config(section, option, value=None):
    """Set a dpm configuration value. If section or option are not already in the config, creates them.

    :param section:
        the name of the section in the ini file, e.g. "index:ckan".
    :type section: str

    :param option:
        the name of the option to be retrieved from the section of the ini file, e.g. 'ckan.api_key'
    :type option: str

    :param value:
        the new value for the option. If None, it sets the value as an empty string ''
    :type option: str


    :return:
        str -- The new option value
    """
    if section not in get_config():
        dpm.CONFIG.add_section(section)
    if not value:
        value = ""
    dpm.CONFIG.set(section, option, value)
    dpm.CONFIG.write(open(dpm.config.default_config_path, 'w'))
    dpm.CONFIG = dpm.config.load_config()
    return get_config(section, option)
        


src/d/a/datadeck-0.4.0/datadeck/settings.py   datadeck(Download)
    def ckan_url(ckan_url=None):
        if not ckan_url:
            return dpm.lib.get_config(Settings._ckan_section, Settings._ckan_url_option)
        else:
            return dpm.lib.set_config(Settings._ckan_section, Settings._ckan_url_option, ckan_url)
    def ckan_api(ckan_api=None):
        if not ckan_api:
            return dpm.lib.get_config(Settings._ckan_section, Settings._ckan_api_key_option)
        else:
            return dpm.lib.set_config(Settings._ckan_section, Settings._ckan_api_key_option, ckan_api)
    def library_path(default_path=None):
        if not default_path:
            return dpm.lib.get_config(Settings._datadeck_section, Settings._datadeck_library_path_option)
        else:
            return dpm.lib.set_config(Settings._datadeck_section, Settings._datadeck_library_path_option,

src/d/p/dpm-0.10/dpm/tests/test_lib.py   dpm(Download)
    def test_set_config(self):
        value = lib.set_config("test:section", "test.option", "testvalue")
        assert value == "testvalue"
        assert lib.get_config("test:section") == ["test.option"]
        #clean up
        dpm.CONFIG.remove_section("test:section")
        dpm.CONFIG.write(open(dpm.config.default_config_path,'w'))
 
    def test_delete_config(self):
        value = lib.set_config("test:section", "test.option", "testvalue")

src/d/p/dpm-old-HEAD/dpm/tests/test_lib.py   dpm-old(Download)
    def test_set_config(self):
        value = lib.set_config("test:section", "test.option", "testvalue")
        assert value == "testvalue"
        assert lib.get_config("test:section") == ["test.option"]
        #clean up
        dpm.CONFIG.remove_section("test:section")
        dpm.CONFIG.write(open(dpm.config.default_config_path,'w'))
 
    def test_delete_config(self):
        value = lib.set_config("test:section", "test.option", "testvalue")