當前位置: 首頁>>代碼示例>>Python>>正文


Python configparser.ExtendedInterpolation方法代碼示例

本文整理匯總了Python中configparser.ExtendedInterpolation方法的典型用法代碼示例。如果您正苦於以下問題:Python configparser.ExtendedInterpolation方法的具體用法?Python configparser.ExtendedInterpolation怎麽用?Python configparser.ExtendedInterpolation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在configparser的用法示例。


在下文中一共展示了configparser.ExtendedInterpolation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: copy_dependencies

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def copy_dependencies(f):
    config_path = '/etc/yangcatalog/yangcatalog.conf'
    config = ConfigParser.ConfigParser()
    config._interpolation = ConfigParser.ExtendedInterpolation()
    config.read(config_path)
    yang_models = config.get('Directory-Section', 'save-file-dir')
    tmp = config.get('Directory-Section', 'temp')
    out = f.getvalue()
    letters = string.ascii_letters
    suffix = ''.join(random.choice(letters) for i in range(8))
    dep_dir = '{}/yangvalidator-dependencies-{}'.format(tmp, suffix)
    os.mkdir(dep_dir)
    dependencies = out.split(':')[1].strip().split(' ')
    for dep in dependencies:
        for file in glob.glob(r'{}/{}*.yang'.format(yang_models, dep)):
            shutil.copy(file, dep_dir)
    return dep_dir 
開發者ID:YangCatalog,項目名稱:bottle-yang-extractor-validator,代碼行數:19,代碼來源:views.py

示例2: configs_from_inifile

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def configs_from_inifile(inifile):
    try:
        from configparser import ConfigParser, ExtendedInterpolation
    except ImportError:
        import errno
        raise IOError(
            errno.ENOENT,
            'Missing ConfigParser and ExtendedInterpolation: '
            'please use python3+')
    else:
        parser = ConfigParser(
            allow_no_value=False,     # don't allow "key" without "="
            delimiters=('=',),        # inifile "=" between key and value
            comment_prefixes=(';',),  # only ';' for comments (fixes #channel)
            inline_comment_prefixes=(';',),     # comments after lines
            interpolation=ExtendedInterpolation(),
            empty_lines_in_values=False)  # empty line means new key
        parser.read_file(inifile)
        return BridgeConfigsFromIni(parser).get() 
開發者ID:ossobv,項目名稱:slackbridge,代碼行數:21,代碼來源:ini.py

示例3: load

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def load(path: str, fallback: ConfigParser = None) -> ConfigParser:
    """
    Retrieve the PyRDP settings from a file

    :param path: The path of the file to load.
    :param fallback: The fallback configuration path.

    :returns: A ConfigParser instance with the loaded settings.
    :throws Exception: When the fallback configuration is missing and no configuration is found.
    """
    config = ConfigParser(interpolation=ExtendedInterpolation())
    config.optionxform = str
    try:
        if len(config.read(path)) > 0:
            return config
    except Exception:
        # Fallback to default settings.
        pass

    if not fallback:
        raise Exception('Invalid configuration with no fallback specified')
    return fallback 
開發者ID:GoSecure,項目名稱:pyrdp,代碼行數:24,代碼來源:settings.py

示例4: get_config

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def get_config(config_filename):
    friar_config = configparser.ConfigParser(
        interpolation=configparser.ExtendedInterpolation(),
        allow_no_value=True,
        delimiters='=',
        inline_comment_prefixes='#'
    )

    local_filename = config_filename.replace('.cfg', '_local.cfg')
    if path.isfile(local_filename):
        config_filename = local_filename

    with open(config_filename, 'r') as file:
        friar_config.read_file(file)

    return friar_config 
開發者ID:codesociety,項目名稱:friartuck,代碼行數:18,代碼來源:friar_tuck_run.py

示例5: read_ini_file

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def read_ini_file(cpFile):
    """Read a .ini file and return it as a ConfigParser class.
    This function does none of the parsing/combining of sections. It simply
    reads the file and returns it unedited

    Parameters
    ----------
    cpFile : The path to a .ini file to be read in

    Returns
    -------
    cp: The ConfigParser class containing the read in .ini file
    """

    # Initialise ConfigParser class
    cp = ConfigParser.ConfigParser(\
        interpolation=ConfigParser.ExtendedInterpolation())
    # Read the file
    fp = open(cpFile,'r')
    cp.read_file(fp)
    fp.close()
    return cp 
開發者ID:gwastro,項目名稱:pycbc,代碼行數:24,代碼來源:configparser_test.py

示例6: __init__

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def __init__(self, extended_interpolation=True):
        if extended_interpolation:
            cp = ConfigParser(interpolation=ExtendedInterpolation())
        else:
            cp = ConfigParser()
        cp.optionxform = _name_xform
        self._cp = cp 
開發者ID:biocommons,項目名稱:hgvs,代碼行數:9,代碼來源:config.py

示例7: __init__

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def __init__(self, paths_config, verbose=False):
        config = configparser.ConfigParser()
        config._interpolation = configparser.ExtendedInterpolation()
        config.read(paths_config)
        print(paths_config)

        c = config['DEFAULT']

        d = {}
        for k in c:
            d[k] = c[k]

        self.resources_dir = d['resources_dir']

        self.vocab_dir = d['vocab_dir']

        # Word2Vec Vocab to Idxs
        self.word_vocab_pkl = d['word_vocab_pkl']
        # Wid2Idx for Known Entities ~ 620K (readers.train.vocab.py)
        self.kwnwid_vocab_pkl = d['kwnwid_vocab_pkl']
        # FIGER Type label 2 idx (readers.train.vocab.py)
        self.label_vocab_pkl = d['label_vocab_pkl']
        # EntityWid: [FIGER Type Labels]
        # CoherenceStr2Idx at various thresholds (readers.train.vocab.py)
        self.cohstringG9_vocab_pkl = d['cohstringg9_vocab_pkl']

        # wid2Wikititle for whole KB ~ 3.18M (readers.train.vocab.py)
        self.widWiktitle_pkl = d['widwiktitle_pkl']

        self.crosswikis_pruned_pkl = d['crosswikis_pruned_pkl']

        self.glove_pkl = d['glove_pkl']
        self.glove_word_vocab_pkl = d['glove_word_vocab_pkl']

        self.test_file = d['test_file']

        if verbose:
            pp.pprint(d)

    #endinit 
開發者ID:nitishgupta,項目名稱:neural-el,代碼行數:42,代碼來源:config.py

示例8: __init__

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def __init__(self, defaults_file=os.path.join('config', 'defaults.cfg'), config_file='', **kwargs):
    """"""
    
    #super(Config, self).__init__(defaults=kwargs.pop('DEFAULT', {}))
    super(Config, self).__init__(interpolation=ExtendedInterpolation())
    self.read([defaults_file, config_file])
    for section, options in six.iteritems(kwargs):
      if section != 'DEFAULT' and not self.has_section(section):
        self.add_section(section)
      for option, value in six.iteritems(options):
        self.set(section, option, str(value))
    return
  
  #============================================================= 
開發者ID:tdozat,項目名稱:Parser-v3,代碼行數:16,代碼來源:config.py

示例9: test_get_extended_interpolation

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def test_get_extended_interpolation(self):
        parser = configparser.ConfigParser(
          interpolation=configparser.ExtendedInterpolation())
        parser.read_string("""
        [Paths]
        home_dir: /Users
        my_dir: ${home_dir1}/lumberjack
        my_pictures: ${my_dir}/Pictures
        """)
        cm = self.assertRaises(configparser.InterpolationMissingOptionError)
        with cm:
            parser.get('Paths', 'my_dir')
        self.assertIs(cm.exception.__suppress_context__, True) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:15,代碼來源:test_configparser.py

示例10: _get_prefs

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def _get_prefs(self):
        """
        """

        prefs = ConfigParser(interpolation=ExtendedInterpolation())
        prefs.read_string("""
        
            [default]
            ads_token = dev_key
            
            [proxy]
            ssh_user = None
            ssh_server = None
            ssh_port = 22
            
            [options]
            download_pdf = True
            alert_sound = True
            debug = False            
                          
            """)
        prefs_dir = os.path.dirname(self.prefs_path)

        if not os.path.exists(prefs_dir):
            os.makedirs(prefs_dir)
        if not os.path.exists(self.prefs_path):
            with open(self.prefs_path, 'w') as prefs_file:
                prefs.write(prefs_file)
        else:
            prefs.read(self.prefs_path)

        return prefs 
開發者ID:r-xue,項目名稱:ads2bibdesk,代碼行數:34,代碼來源:prefs.py

示例11: clean

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def clean(self):
        print('Ahenk cleaning..')
        import configparser
        try:
            config = configparser.ConfigParser()
            config._interpolation = configparser.ExtendedInterpolation()
            config.read(System.Ahenk.config_path())
            db_path = config.get('BASE', 'dbPath')

            if Util.is_exist(System.Ahenk.fifo_file()):
                Util.delete_file(System.Ahenk.fifo_file())

            if Util.is_exist(db_path):
                Util.delete_file(db_path)

            if Util.is_exist(System.Ahenk.pid_path()):
                Util.delete_file(System.Ahenk.pid_path())

            config.set('CONNECTION', 'uid', '')
            config.set('CONNECTION', 'password', '')
            config.set('CONNECTION', 'host', '')
            config.set('MACHINE', 'user_disabled', 'false')

            with open(System.Ahenk.config_path(), 'w') as file:
                config.write(file)
            file.close()
            print('Ahenk cleaned.')
        except Exception as e:
            self.logger.error("Error while running clean command. Error Message  " + str(e))
            print('Error while running clean command. Error Message {0}'.format(str(e))) 
開發者ID:Pardus-LiderAhenk,項目名稱:ahenk,代碼行數:32,代碼來源:registration.py

示例12: clean

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def clean(self):
        print('Ahenk cleaning..')
        try:
            config = configparser.ConfigParser()
            config._interpolation = configparser.ExtendedInterpolation()
            config.read(System.Ahenk.config_path())
            db_path = config.get('BASE', 'dbPath')

            if Util.is_exist(System.Ahenk.fifo_file()):
                Util.delete_file(System.Ahenk.fifo_file())

            if Util.is_exist(db_path):
                Util.delete_file(db_path)

            if Util.is_exist(System.Ahenk.pid_path()):
                Util.delete_file(System.Ahenk.pid_path())

            config.set('CONNECTION', 'uid', '')
            config.set('CONNECTION', 'password', '')

            with open(System.Ahenk.config_path(), 'w') as file:
                config.write(file)
            file.close()
            print('Ahenk cleaned.')
        except Exception as e:
            print('Error while running clean command. Error Message {0}'.format(str(e))) 
開發者ID:Pardus-LiderAhenk,項目名稱:ahenk,代碼行數:28,代碼來源:command_manager.py

示例13: db_path

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def db_path():
            config = configparser.ConfigParser()
            config._interpolation = configparser.ExtendedInterpolation()
            config.read(System.Ahenk.config_path())
            return config.get('BASE', 'dbPath') 
開發者ID:Pardus-LiderAhenk,項目名稱:ahenk,代碼行數:7,代碼來源:system.py

示例14: agreement_timeout

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def agreement_timeout():
            config = configparser.ConfigParser()
            config._interpolation = configparser.ExtendedInterpolation()
            config.read(System.Ahenk.config_path())
            return config.get('SESSION', 'agreement_timeout') 
開發者ID:Pardus-LiderAhenk,項目名稱:ahenk,代碼行數:7,代碼來源:system.py

示例15: registration_timeout

# 需要導入模塊: import configparser [as 別名]
# 或者: from configparser import ExtendedInterpolation [as 別名]
def registration_timeout():
            config = configparser.ConfigParser()
            config._interpolation = configparser.ExtendedInterpolation()
            config.read(System.Ahenk.config_path())
            return config.get('SESSION', 'registration_timeout') 
開發者ID:Pardus-LiderAhenk,項目名稱:ahenk,代碼行數:7,代碼來源:system.py


注:本文中的configparser.ExtendedInterpolation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。