コード例 #1
0
def setUpModule():
    for cfgfile in (CURRENT_CONFIG_FILE, _OLD_CONFIG_FILE):
        if os.path.exists(cfgfile):
            os.rename(cfgfile, cfgfile + '.bak_test')

            if cfgfile == CURRENT_CONFIG_FILE:
                yt.utilities.configure.CONFIG = YTConfigParser()
                if not yt.utilities.configure.CONFIG.has_section('yt'):
                    yt.utilities.configure.CONFIG.add_section('yt')
コード例 #2
0
# -*- coding: UTF-8 -*-
#-----------------------------------------------------------------------------
# Copyright (c) 2016, yt Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------

import os
import shutil
import sys
import argparse
from yt.config import CURRENT_CONFIG_FILE, _OLD_CONFIG_FILE, YTConfigParser

CONFIG = YTConfigParser()
CONFIG.read([CURRENT_CONFIG_FILE])


def get_config(section, option):
    return CONFIG.get(section, option)


def set_config(section, option, value):
    if not CONFIG.has_section(section):
        CONFIG.add_section(section)
    CONFIG.set(section, option, value)
    write_config()


def write_config(fd=None):