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


Python ConfigParser.RawConfigParser方法代码示例

本文整理汇总了Python中ConfigParser.RawConfigParser方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.RawConfigParser方法的具体用法?Python ConfigParser.RawConfigParser怎么用?Python ConfigParser.RawConfigParser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigParser的用法示例。


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

示例1: read_config

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def read_config(self):
    """Read the user's configuration file."""

    logging.debug('[VT Plugin] Reading user config file: %s', self.vt_cfgfile)
    config_file = configparser.RawConfigParser()
    config_file.read(self.vt_cfgfile)

    try:
      if config_file.get('General', 'auto_upload') == 'True':
        self.auto_upload = True
      else:
        self.auto_upload = False
      return True
    except:
      logging.error('[VT Plugin] Error reading the user config file.')
      return False 
开发者ID:VirusTotal,项目名称:vt-ida-plugin,代码行数:18,代码来源:plugin_loader.py

示例2: __init__

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def __init__(self,
                  default_lib_dirs=default_lib_dirs,
                  default_include_dirs=default_include_dirs,
                  verbosity=1,
                  ):
        self.__class__.info = {}
        self.local_prefixes = []
        defaults = {'library_dirs': os.pathsep.join(default_lib_dirs),
                    'include_dirs': os.pathsep.join(default_include_dirs),
                    'runtime_library_dirs': os.pathsep.join(default_runtime_dirs),
                    'rpath': '',
                    'src_dirs': os.pathsep.join(default_src_dirs),
                    'search_static_first': str(self.search_static_first),
                    'extra_compile_args': '', 'extra_link_args': ''}
        self.cp = ConfigParser(defaults)
        self.files = []
        self.files.extend(get_standard_file('.numpy-site.cfg'))
        self.files.extend(get_standard_file('site.cfg'))
        self.parse_config_files()

        if self.section is not None:
            self.search_static_first = self.cp.getboolean(
                self.section, 'search_static_first')
        assert isinstance(self.search_static_first, int) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:system_info.py

示例3: __init__

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def __init__(self, filename = None, section = None, simulation = False, log = None):

        super(MyConfig, self).__init__()
        self.log = log
        self.FileName = filename
        self.Section = section
        self.Simulation = simulation
        self.CriticalLock = threading.Lock()        # Critical Lock (writing conf file)
        self.InitComplete = False
        try:
            self.config = RawConfigParser()
            self.config.read(self.FileName)

            if self.Section == None:
                SectionList = self.GetSections()
                if len(SectionList):
                    self.Section = SectionList[0]

        except Exception as e1:
            self.LogErrorLine("Error in MyConfig:init: " + str(e1))
            return
        self.InitComplete = True
    #---------------------MyConfig::HasOption----------------------------------- 
开发者ID:jgyates,项目名称:genmon,代码行数:25,代码来源:myconfig.py

示例4: generate_url

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def generate_url(rse, config):
    '''
    :param rse: Name of the endpoint.
    :param config: RawConfigParser instance which may have configuration
    related to the endpoint.
    :returns: Tuple with the URL where the links can be queried to find new
    dumps and the pattern used to parse the date of the dump of the files/directories
    listed..
    '''
    site = rse.split('_')[0]
    if site not in config.sections():
        base_url = ddmendpoint_url(rse) + 'dumps'
        url_pattern = 'dump_%Y%m%d'
    else:
        url_components = config.get(site, rse).split('/')
        # The pattern may not be the last component
        pattern_index = next(idx for idx, comp in enumerate(url_components) if '%m' in comp)
        base_url = '/'.join(url_components[:pattern_index])
        url_pattern = '/'.join(url_components[pattern_index:])

    return base_url, url_pattern 
开发者ID:rucio,项目名称:rucio,代码行数:23,代码来源:srmdumps.py

示例5: create_skip_replication_cnf

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def create_skip_replication_cnf(override_dir=None):
    """ Create a secondary cnf file that will allow for mysql to skip
        replication start. Useful for running mysql upgrade, etc...

    Args:
    override_dir - Write to this directory rather than CNF_DIR
    """
    skip_replication_parser = ConfigParser.RawConfigParser(allow_no_value=True)
    skip_replication_parser.add_section(MYSQLD_SECTION)
    skip_replication_parser.set(MYSQLD_SECTION, 'skip_slave_start', None)
    if override_dir:
        skip_slave_path = os.path.join(override_dir,
                                       os.path.basename(host_utils.MYSQL_NOREPL_CNF_FILE))
    else:
        skip_slave_path = host_utils.MYSQL_NOREPL_CNF_FILE
    log.info('Writing file {skip_slave_path}'
             ''.format(skip_slave_path=skip_slave_path))
    with open(skip_slave_path, "w") as skip_slave_handle:
            skip_replication_parser.write(skip_slave_handle) 
开发者ID:pinterest,项目名称:mysql_utils,代码行数:21,代码来源:mysql_cnf_builder.py

示例6: __init__

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def __init__(self,
                  default_lib_dirs=default_lib_dirs,
                  default_include_dirs=default_include_dirs,
                  verbosity=1,
                  ):
        self.__class__.info = {}
        self.local_prefixes = []
        defaults = {'library_dirs': os.pathsep.join(default_lib_dirs),
                    'include_dirs': os.pathsep.join(default_include_dirs),
                    'runtime_library_dirs': os.pathsep.join(default_runtime_dirs),
                    'rpath': '',
                    'src_dirs': os.pathsep.join(default_src_dirs),
                    'search_static_first': str(self.search_static_first),
                    'extra_compile_args': '', 'extra_link_args': ''}
        self.cp = ConfigParser(defaults)
        self.files = []
        self.files.extend(get_standard_file('.numpy-site.cfg'))
        self.files.extend(get_standard_file('site.cfg'))
        self.parse_config_files()
        if self.section is not None:
            self.search_static_first = self.cp.getboolean(
                self.section, 'search_static_first')
        assert isinstance(self.search_static_first, int) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:25,代码来源:system_info.py

示例7: read

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def read(self, filenames, option_parser):
        if type(filenames) in (str, unicode):
            filenames = [filenames]
        for filename in filenames:
            try:
                # Config files must be UTF-8-encoded:
                fp = codecs.open(filename, 'r', 'utf-8')
            except IOError:
                continue
            try:
                if sys.version_info < (3,2):
                    CP.RawConfigParser.readfp(self, fp, filename)
                else:
                    CP.RawConfigParser.read_file(self, fp, filename)
            except UnicodeDecodeError:
                self._stderr.write(self.not_utf8_error % (filename, filename))
                fp.close()
                continue
            fp.close()
            self._files.append(filename)
            if self.has_section('options'):
                self.handle_old_config(filename)
            self.validate_settings(filename, option_parser) 
开发者ID:skarlekar,项目名称:faces,代码行数:25,代码来源:frontend.py

示例8: parse_info_file

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def parse_info_file(infofile_path):
    logger = logging.getLogger(__name__)
    cp = configparser.RawConfigParser()
    cp.read(infofile_path)

    options_missing = False
    for option in MANDATORY_OPTIONS:
        if not cp.has_option(*option):
            options_missing = True
            logger.debug("Plugin info file '%s' missing value '%s'", infofile_path, option)
    
    if options_missing:
        raise PluginError("Info file is missing values!")
    
    logger.debug("Plugin info file '%s' parsed successfully!", infofile_path)
    return cp 
开发者ID:niutool,项目名称:xuebao,代码行数:18,代码来源:pluginstore.py

示例9: get_hosted_registry_insecure

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def get_hosted_registry_insecure():
    """ Parses OPTIONS from /etc/sysconfig/docker to determine if the
        registry is currently insecure.
    """
    hosted_registry_insecure = None
    if os.path.exists('/etc/sysconfig/docker'):
        try:
            ini_str = unicode('[root]\n' + open('/etc/sysconfig/docker', 'r').read(), 'utf-8')
            ini_fp = io.StringIO(ini_str)
            config = ConfigParser.RawConfigParser()
            config.readfp(ini_fp)
            options = config.get('root', 'OPTIONS')
            if 'insecure-registry' in options:
                hosted_registry_insecure = True
        except:
            pass
    return hosted_registry_insecure 
开发者ID:openshift,项目名称:origin-ci-tool,代码行数:19,代码来源:openshift_facts.py

示例10: __init__

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def __init__(self, config_file, default_config=None):
        '''
        Init config module.

        @param config_file: Config filepath.
        @param default_config: Default config value use when config file is empty.
        '''
        gobject.GObject.__init__(self)
        self.config_parser = ConfigParser()
        self.remove_option = self.config_parser.remove_option
        self.has_option = self.config_parser.has_option
        self.add_section = self.config_parser.add_section
        self.getboolean = self.config_parser.getboolean
        self.getint = self.config_parser.getint
        self.getfloat = self.config_parser.getfloat
        self.options = self.config_parser.options
        self.items = self.config_parser.items
        self.config_file = config_file
        self.default_config = default_config

        # Load default configure.
        self.load_default() 
开发者ID:dragondjf,项目名称:QMusic,代码行数:24,代码来源:config.py

示例11: __del__

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def __del__(self):
        if self.config_file:
            if options.verbose:
                print "-- Write config file back : %s " % self.config_file
            self.hubic_config = ConfigParser.RawConfigParser()

            self.hubic_config.add_section('hubic')
            if self.client_id:
                self.hubic_config.set('hubic', 'client_id', self.client_id)
            if self.client_secret:
                self.hubic_config.set('hubic', 'client_secret', self.client_secret)
            if self.redirect_uri:
                self.hubic_config.set('hubic', 'redirect_uri', self.redirect_uri)
            if self.username:
                self.hubic_config.set('hubic', 'username', self.username)
            if self.password:
                self.hubic_config.set('hubic', 'password', self.password)
            if self.refresh_token:
                self.hubic_config.set('hubic', 'refresh_token', self.refresh_token)
            if self.access_token:
                self.hubic_config.set('hubic', 'access_token', self.access_token)
            if self.token_expire:
                self.hubic_config.set('hubic', 'token_expire', self.token_expire)

            self.hubic_config.add_section('openstack')
            if self.os_auth_token:
                self.hubic_config.set('openstack', 'os_auth_token', self.os_auth_token)
            if self.os_storage_url:
                self.hubic_config.set('openstack', 'os_storage_url', self.os_storage_url)
            if self.os_token_expire:
                self.hubic_config.set('openstack', 'os_token_expire', self.os_token_expire)

            with open(self.config_file, 'wb') as configfile:
                self.hubic_config.write(configfile)
            os.chmod(self.config_file, 0600) 
开发者ID:puzzle1536,项目名称:hubic-wrapper-to-swift,代码行数:37,代码来源:hubic.py

示例12: create_temp_ini

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def create_temp_ini(self, options={}):
        ini = ConfigParser.RawConfigParser()
        # iterate over sections
        for section, tokens in options.iteritems():
            ini.add_section(section)
            for key, value in tokens.iteritems():
                ini.set(section, key, value)

        fd, path = tempfile.mkstemp(suffix=".ini")
        with os.fdopen(fd, 'w') as f:
            ini.write(f)
        return path 
开发者ID:ni,项目名称:python_labview_automation,代码行数:14,代码来源:labview.py

示例13: get_firefox_profiles

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def get_firefox_profiles(self, directory):
        cp = RawConfigParser()
        cp.read(os.path.join(directory, 'profiles.ini'))
        profile_list = []
        for section in cp.sections():
            if section.startswith('Profile'):
                if cp.has_option(section, 'Path'):
                    profile_list.append(os.path.join(directory, cp.get(section, 'Path').strip()))
        return profile_list 
开发者ID:mehulj94,项目名称:Radium,代码行数:11,代码来源:Mozilla.py

示例14: save_config

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def save_config(self):
        config = configparser.RawConfigParser()
        config.add_section('Configuration')
        config.set('Configuration', 'locale', self.config['locale'])
        config.set('Configuration', 'font-size', self.config['font-size'])
        with open(self.config_path, 'w') as configfile:
            config.write(configfile) 
开发者ID:aroberge,项目名称:easygui_qt,代码行数:9,代码来源:easygui_qt.py

示例15: load_config

# 需要导入模块: import ConfigParser [as 别名]
# 或者: from ConfigParser import RawConfigParser [as 别名]
def load_config(self):
        # Todo: make more robust
        config = configparser.RawConfigParser()
        self.config = {}
        try:
            config.read(self.config_path)
            self.config['locale'] = config.get('Configuration', 'locale')
            self.set_locale(self.config['locale'], save=False)
            self.config['font-size'] = config.getint('Configuration', 'font-size')
            self.set_font_size(self.config['font-size'], save=False)
        except:
            print("Problem encountered in load_config.")
            self.config = {'locale': 'default', 'font-size': 12}
            return 
开发者ID:aroberge,项目名称:easygui_qt,代码行数:16,代码来源:easygui_qt.py


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