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


Python ConfigParser.options方法代码示例

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


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

示例1: readROIFile

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
def readROIFile(hfile):
    cp =  ConfigParser()
    cp.read(hfile)
    output = []
    for a in cp.options('rois'):
        if a.lower().startswith('roi'):
            iroi = int(a[3:])
            name, dat = cp.get('rois',a).split('|')
            xdat = [int(i) for i in dat.split()]
            dat = [(xdat[0], xdat[1]), (xdat[2], xdat[3]),
                   (xdat[4], xdat[5]), (xdat[6], xdat[7])]
            output.append((iroi, name.strip(), dat))
    roidata = sorted(output)
    calib = {}

    caldat = cp.options('calibration')
    for attr in ('offset', 'slope', 'quad'):
        calib[attr] = [float(x) for x in cp.get('calibration', attr).split()]
    dxp = {}
    ndet = len(calib['offset'])
    for attr in cp.options('dxp'):
        tmpdat = [x for x in cp.get('dxp', attr).split()]
        if len(tmpdat) == 2*ndet:
            tmpdat = ['%s %s' % (i, j) for i, j in zip(tmpdat[::2], tmpdat[1::2])]
        try:
            dxp[attr] = [int(x) for x in tmpdat]
        except ValueError:
            try:
                dxp[attr] = [float(x) for x in tmpdat]
            except ValueError:
                dxp[attr] = tmpdat
    return roidata, calib, dxp
开发者ID:newville,项目名称:xrmcollect,代码行数:34,代码来源:mapfolder.py

示例2: from_file

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
    def from_file(cls, file_name):
        """ Make a Config from a file. """
        file_name = os.path.expanduser(file_name)

        parser = ConfigParser()
        # IMPORTANT: Turn off downcasing of option names.
        parser.optionxform = str

        parser.read(file_name)
        cfg = Config()
        if parser.has_section('index_values'):
            for repo_id in parser.options('index_values'):
                cfg.version_table[repo_id] = (
                    parser.getint('index_values', repo_id))
        if parser.has_section('request_usks'):
            for repo_dir in parser.options('request_usks'):
                cfg.request_usks[repo_dir] = parser.get('request_usks',
                                                        repo_dir)
        if parser.has_section('insert_usks'):
            for repo_id in parser.options('insert_usks'):
                cfg.insert_usks[repo_id] = parser.get('insert_usks', repo_id)

        # ignored = fms_id|usk_hash|usk_hash|...
        if parser.has_section('fmsread_trust_map'):
            cfg.fmsread_trust_map.clear() # Wipe defaults.
            for ordinal in parser.options('fmsread_trust_map'):
                fields = parser.get('fmsread_trust_map',
                                    ordinal).strip().split('|')
                Config.validate_trust_map_entry(cfg, fields)
                cfg.fmsread_trust_map[fields[0]] = tuple(fields[1:])

        Config.update_defaults(parser, cfg)

        cfg.file_name = file_name
        return cfg
开发者ID:SeekingFor,项目名称:infocalypse,代码行数:37,代码来源:config.py

示例3: read_properties

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
 def read_properties(self, property_file="Coordinator.properties"):
         """ process properties file """
         ## Reads the configuration properties
         cfg = ConfigParser()
         cfg.read(property_file)
         self.install_dir = cfg.get("config", "install_dir")
         self.euca_rc_dir = cfg.get("config", "euca_rc_dir")
         self.initial_cluster_size = cfg.get("config", "initial_cluster_size")
         self.max_cluster_size = cfg.get("config", "max_cluster_size")
         self.bucket_name = cfg.get("config", "bucket_name")
         self.instance_type = cfg.get("config", "instance_type")
         self.cluster_name = cfg.get("config", "cluster_name")
         self.hostname_template = cfg.get("config", "hostname_template")
         self.reconfigure = cfg.get("config", "reconfigure")
         self.cluster_type = cfg.get("config", "cluster_type")
         self.db_file = cfg.get("config", "db_file")
         self.add_nodes = cfg.get("config", "add_nodes")
         self.rem_nodes = cfg.get("config", "rem_nodes")
         self.cloud_api_type = cfg.get("config", "cloud_api_type")
         self.trans_cost = cfg.get("config", "trans_cost")
         self.gain = cfg.get("config", "gain")
         self.serv_throughput = cfg.get("config", "serv_throughput")
         try:
             self.gamma = cfg.get("config", "gamma")
         except:
             self.gamma = 0
         
         ## Reads the monitoring thresholds
         self.thresholds_add = {}
         self.thresholds_remove = {}
         for option in cfg.options("thresholds_add"):
             self.thresholds_add[option] = cfg.get("thresholds_add", option)
         for option in cfg.options("thresholds_remove"):
             self.thresholds_remove[option] = cfg.get("thresholds_remove", option)
开发者ID:molddu,项目名称:tiramola,代码行数:36,代码来源:Utils.py

示例4: getViewsForModule

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
    def getViewsForModule(self, module, model):
        """
        @param module: the name of the model to get the views for
        @param model: the L{commitmessage.model.Model} to initialize views with
        @return: the configured views for a module
        """
        viewLine = ConfigParser.get(self, module, 'views')
        p = re.compile(',\s?')
        viewNames = [name.strip() for name in p.split(viewLine) if len(name.strip()) > 0]

        userMap = self.userMap

        views = []
        for viewName in viewNames:
            fullClassName = ConfigParser.get(self, 'views', viewName)
            view = getNewInstance(fullClassName)
            view.__init__(viewName, model)

            # Setup default values
            if ConfigParser.has_section(self, viewName):
                for name in ConfigParser.options(self, viewName):
                    value = ConfigParser.get(self, viewName, name, 1)
                    view.__dict__[name] = str(Itpl(value))

            # Setup module-specific values
            forViewPrefix = re.compile('^%s.' % viewName)
            for option in ConfigParser.options(self, module):
                if forViewPrefix.search(option):
                    # Take off the 'viewName.'
                    name = option[len(viewName)+1:]
                    value = ConfigParser.get(self, module, option, 1)
                    view.__dict__[name] = str(Itpl(value))

            views.append(view)
        return views
开发者ID:dagvl,项目名称:commitmessage,代码行数:37,代码来源:util.py

示例5: __init__

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
class PrintersConfig:
    def __init__(self):
        self.Config = ConfigParser()
        self.Config2 = ConfigParser()
        self.Config.read(os.path.join("/etc/printerstats/config", "printers.ini"))
        self.Config2.read(os.path.join("/etc/printerstats/config", "config.ini"))

    def ConfigMap(self, section):
        dict1 = {}
        options = self.Config2.options(section)
        for option in options:
            dict1[option] = self.Config2.get(section, option)
        return dict1


    def CampusMap(self, section):
        dict1 = {}
        options = self.Config.options(section)
        for option in options:
            dict1[section] = self.Config.get(section, option)
        return dict1


    def ConfigMapPrinters(self, section):
        dict1 = {section: {}}
        options = self.Config.options(section)
        for option in options:
            dict1[section][option] = self.Config.get(section, option)
        return dict1
开发者ID:RIEI,项目名称:printerStats,代码行数:31,代码来源:PrintersConfig.py

示例6: main

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
def main():
    cp = ConfigParser()
    cp.read(sys.argv[1])
    certfile = cp.get('sslexport', 'pemfile')
    external = cp.get('sslexport', 'external')
    internal = '127.0.0.1'
  
    # External (SSL) listeners
    for ext_port in cp.options('sslexport.server'):
        ipport = cp.get('sslexport.server', ext_port)
        ip,port = ipport.split(':')
        server = gevent.server.StreamServer(
            (external, int(ext_port)),
            Forwarder(ip, port, gevent.socket.socket),
            certfile=certfile)
        server.start()
        print 'ssl(%s:%s) => clear(%s:%s)' % (
            external, ext_port, ip, port)
  
    # Internal (non-SSL) listeners
    for int_port in cp.options('sslexport.client'):
        ipport = cp.get('sslexport.client', int_port)
        ip,port = ipport.split(':')
        server = gevent.server.StreamServer(
            (internal, int(int_port)),
            Forwarder(ip, port, lambda:gevent.ssl.SSLSocket(gevent.socket.socket())),
            certfile=certfile)
        server.start()
        print 'clear(%s:%s) => ssl(%s:%s)' % (
            internal, int_port, ip, port)
  
    while True:
        gevent.sleep(10)
        print '--- mark ---'
开发者ID:PurpleHua,项目名称:ChatRoom,代码行数:36,代码来源:text.py

示例7: createDictFromConfig

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
def createDictFromConfig():
    """ Read the configuration from scipion/config/scipionbox.conf.
     A dictionary will be created where each key will be a section starting
     by MICROSCOPE:, all variables that are in the GLOBAL section will be
     inherited by default.
    """
    # Read from users' config file.
    confGlobalDict = OrderedDict()
    confDict = OrderedDict()

    cp = ConfigParser()
    cp.optionxform = str  # keep case (stackoverflow.com/questions/1611799)

    confFile = pw.getConfigPath("scipionbox.conf")

    print "Reading conf file: ", confFile
    cp.read(confFile)

    GLOBAL = "GLOBAL"
    MICROSCOPE = "MICROSCOPE:"

    if not GLOBAL in cp.sections():
        raise Exception("Missing section %s in %s" % (GLOBAL, confFile))
    else:
        for opt in cp.options(GLOBAL):
            confGlobalDict[opt] = cp.get(GLOBAL, opt)

    for section in cp.sections():
        if section != GLOBAL and section.startswith(MICROSCOPE):
            sectionDict = OrderedDict(confGlobalDict)
            for opt in cp.options(section):
                sectionDict[opt] = cp.get(section, opt)
            confDict[section.replace(MICROSCOPE, '')] = sectionDict

    return confDict
开发者ID:I2PC,项目名称:scipion,代码行数:37,代码来源:scipionbox_wizard_scilifelab.py

示例8: readROIFile

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
def readROIFile(hfile):
    cp =  ConfigParser()
    cp.read(hfile)
    roiout = []
    try:
        rois = cp.options('rois')
    except:
        print 'rois not found'
        return []

    for a in cp.options('rois'):
        if a.lower().startswith('roi'):
            iroi = int(a[3:])
            name, dat = cp.get('rois',a).split('|')
            xdat = [int(i) for i in dat.split()]
            dat = [(xdat[0], xdat[1]), (xdat[2], xdat[3]),
                   (xdat[4], xdat[5]), (xdat[6], xdat[7])]
            roiout.append((iroi, name.strip(), dat))
    roiout = sorted(roiout)
    calib = {}
    calib['CAL_OFFSET'] = cp.get('calibration', 'OFFSET')
    calib['CAL_SLOPE']  = cp.get('calibration', 'SLOPE')
    calib['CAL_QUAD']   = cp.get('calibration', 'QUAD')
    calib['CAL_TWOTHETA']   = ' 0 0 0 0'
    return roiout, calib
开发者ID:newville,项目名称:xrmcollect,代码行数:27,代码来源:xrf_writer.py

示例9: readScanConfig

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
def readScanConfig(sfile):
    cp =  ConfigParser()
    cp.read(sfile)
    scan = {}
    for a in cp.options('scan'):
        scan[a]  = cp.get('scan',a)
    general = {}
    for a in cp.options('general'):
        general[a]  = cp.get('general',a)
    return scan, general
开发者ID:newville,项目名称:xrmcollect,代码行数:12,代码来源:SaveEscans.py

示例10: readROIFile

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
def readROIFile(hfile,xrd=False):

    cp =  ConfigParser()
    cp.read(hfile)
    output = []

    if xrd:
        for a in cp.options('xrd1d'):
            if a.lower().startswith('roi'):
                iroi = int(a[3:])
                name,unit,dat = cp.get('xrd1d',a).split('|')
                lims = [float(i) for i in dat.split()]
                dat = [lims[0], lims[1]]
                output.append((iroi, name.strip(), unit.strip(), dat))
        return sorted(output)

    else:
        for a in cp.options('rois'):
            if a.lower().startswith('roi'):
                iroi = int(a[3:])
                name, dat = cp.get('rois',a).split('|')
                lims = [int(i) for i in dat.split()]
                ndet = int(len(lims)/2)
                dat = []
                for i in range(ndet):
                    dat.append((lims[i*2], lims[i*2+1]))
                output.append((iroi, name.strip(), dat))
        roidata = sorted(output)

        calib = {}

        caldat = cp.options('calibration')
        for attr in ('offset', 'slope', 'quad'):
            calib[attr] = [float(x) for x in cp.get('calibration', attr).split()]
        extra = {}
        ndet = len(calib['offset'])
        file_sections = cp.sections()
        for section in ('dxp', 'extra'):
            if section not in file_sections:
                continue
            for attr in cp.options(section):
                tmpdat = [x for x in cp.get(section, attr).split()]
                if len(tmpdat) == 2*ndet:
                    tmpdat = ['%s %s' % (i, j) for i, j in zip(tmpdat[::2], tmpdat[1::2])]
                try:
                    extra[attr] = [int(x) for x in tmpdat]
                except ValueError:
                    try:
                        extra[attr] = [float(x) for x in tmpdat]
                    except ValueError:
                        extra[attr] = tmpdat


        return roidata, calib, extra
开发者ID:maurov,项目名称:xraylarch,代码行数:56,代码来源:asciifiles.py

示例11: __init__

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
    def __init__(self, cfg_file):
        PARSER = ConfigParser()
        PARSER.read(cfg_file)

        for cfg_section in PARSER.sections():
            # First round, create objects
            for cfg_option in PARSER.options(cfg_section):
                setattr(self, cfg_section, self.StandInObject())
            # Second round, add attributes
            for cfg_option in PARSER.options(cfg_section):
                # Set the values for the section options
                setattr(getattr(self, cfg_section), cfg_option, PARSER.get(cfg_section, cfg_option))
开发者ID:typophil,项目名称:ConfigParserObjectified,代码行数:14,代码来源:ConfigParserObjectified.py

示例12: read_stageconfig

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
def read_stageconfig(filename=None, _larch=None):
    """read Sample Stage configurattion file, saving results

    Parameters
    ----------
    filename:   None or string, name of file holding sample positions (see Note)

    Examples
    --------
      read_stageconfig()

    Notes
    ------
      1. If filename is None (the default) 'SampleStage_autosave.ini'
         from the current working folder is used.
      2. the file timestamp is always tested to find new position names
      3. Generally, you don't need to do this explicitly, as
         move_samplestage will run this when necessary.

    """
    if filename is None: filename = DEF_SampleStageFile
    if not os.path.exists(filename): 
       print 'No stageconfig found!'
       return None
    #endif

    stages = []
    positions = OrderedDict()
    ini = ConfigParser()
    ini.read(filename)

    for item in ini.options('stages'):
        line = ini.get('stages', item)
        words = [i.strip() for i in line.split('||')]
        stages.append(words[0])
    #endfor

    for item in ini.options('positions'):
        line = ini.get('positions', item)
        words = [i.strip() for i in line.split('||')]
        name = words[0].lower()
        vals = [float(i) for i in words[2].split(',')]
        positions[name] = vals
    #endfor
    this = Group(pos=positions, stages=stages,
                 _modtime_=os.stat(filename).st_mtime)
    if _larch is not None:
        if not _larch.symtable.has_group('macros'):
            _larch.symtable.new_group('macros')
        _larch.symtable.macros.stage_conf = this
    print(" Read %d positions from stage configuration." % len(positions) )
        
    return this
开发者ID:pyepics,项目名称:stepscan,代码行数:55,代码来源:basic_macros.py

示例13: TesseraConfig

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
class TesseraConfig(object):
    def __init__(self, path):
        self._path = path
        self._config = ConfigParser()
        if os.path.exists(path):
            self._parse()

    def get_path(self):
        return self._path

    def _parse(self):
        self._config.read(self._path)

    def has_option(self, section, option):
        try:
            self._config.get(section, option)
            return True
        except:
            return False

    def get_option_index(self, section, option):
        try:
            options = self._config.options(section)
        except:
            return -1
        try:
            return options.index(option)
        except:
            return -1

    def get_option_name(self, section, idx):
        try:
            options = self._config.options(section)
        except:
            return "?"
        if idx == None:
            return "no " + section
        return options[idx]

    def get(self, section, option):
        try:
            return self._config.get(section, option)
        except NoSectionError:
            raise ConfigSectionNotFoundError(section, self._path)
        except NoOptionError:
            raise ConfigOptionNotFoundError(option, section, self._path)

    def set(self, section, option, value):
        self._config.set(section, option, value)

    def store(self):
        with open(self._path, "w") as f:
            self._config.write(f)
开发者ID:neolynx,项目名称:git-tessera,代码行数:55,代码来源:tesseraconfig.py

示例14: generate_config

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
def generate_config():
    config_parser = ConfigParser()
    current_directory = os.path.dirname(os.path.abspath(__file__))
    config_parser.read(os.path.normpath(os.path.join(current_directory, '..', 'secrets', 'secrets.ini')))

    config = dict(zip([option.upper() for option in config_parser.options('core')],
                [config_parser.get('core', y) for y in config_parser.options('core')]))

    for section in [s for s in config_parser.sections() if s != 'core']:
        config[section] = ConfigStruct(dict(zip(config_parser.options(section),
                [config_parser.get(section, y) for y in config_parser.options(section)])))

    return config
开发者ID:carbonblack,项目名称:cb-2fa-login,代码行数:15,代码来源:__init__.py

示例15: init_from_options

# 需要导入模块: from ConfigParser import ConfigParser [as 别名]
# 或者: from ConfigParser.ConfigParser import options [as 别名]
    def init_from_options(self):

        # If a config file is provided, read it into the ABACManager
        if self._options.config:
            cp = ConfigParser()
            cp.optionxform=str
            cp.read(self._options.config)

            for name in cp.options('Principals'):
                cert_file = cp.get('Principals', name)
                self.register_id(name, cert_file)

            for name in cp.options('Keys'):
                key_file = cp.get('Keys', name)
                self.register_key(name, key_file)

            if 'Assertions' in cp.sections():
                for assertion in cp.options('Assertions'):
                    self.register_assertion(assertion)

            if 'AssertionFiles' in cp.sections():
                for assertion_file in cp.options("AssertionFiles"):
                    self.register_assertion_file(assertion_file)

        # Use all the other command-line options to override/augment 
        # the values in the ABCManager

        # Add new principal ID's / keys
        if self._options.id:
            for id_filename in options.id:
                parts = id_filename.split(':')
                id_name = parts[0].strip()
                id_cert_file = None
                if len(parts) > 1:
                    id_cert_file = parts[1].strip()
                    self.register_id(id_name, id_cert_file)
                    
                id_key_file = None
                if len(parts) > 2:
                    id_key_file = parts[2].strip()
                    self.register_key(name, id_key_file)

        # Register assertion files provided by command line
        if self._options.assertion_file:
            for assertion_file in self._options.assertion_file:
                self.register_assertion_file(assertion_file)

        # Grab pure ABAC assertions from commandline
        if self._options.assertion:
            for assertion in self._options.assertion:
                self.register_assertion(assertion)
开发者ID:ahelsing,项目名称:geni-ch,代码行数:53,代码来源:ABACManager.py


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