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


Python Configuration.from_file方法代码示例

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


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

示例1: test_lookups_in_extends

# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import from_file [as 别名]
def test_lookups_in_extends():
    src = Configuration.from_file(TEST_DIR + '/data/extends/extends.yml')
    print_yaml("Extends using !lookup:", src)
    src.configure()
    from ksgen.yaml_utils import LookupDirective
    LookupDirective.lookup_table = src
    print_yaml("Extends using !lookup:", src)
开发者ID:pcaruana,项目名称:khaleesi,代码行数:9,代码来源:test_configure.py

示例2: test_load_from_file

# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import from_file [as 别名]
    def test_load_from_file(self):
        filename = path.join(path.dirname(__file__), 'examples', 'example.default.conf')
        c = Configuration.from_file(filename)
        c.configure()

        self.assertEqual(c.a, 1)
        self.assertIsInstance(c.b, timedelta)
        self.assertEqual(c.b, timedelta(days=1))
开发者ID:alfred82santa,项目名称:configure,代码行数:10,代码来源:tests.py

示例3: validate_configuration

# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import from_file [as 别名]
def validate_configuration(options):
    # must have 3 sections common



if __name__ == '__main__':
    parser = build_argument_parser()
    options = parser.parse_args()
    config = Configuration.from_file(options.config)
    
开发者ID:PGower,项目名称:DifferenceEngine,代码行数:11,代码来源:DifferenceEngine.py

示例4: configuration_loader

# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import from_file [as 别名]
def configuration_loader(filename):
    from collections import Mapping
    from configure import Configuration
    config = Configuration.from_file(filename)
    config.configure()

    def to_dict(mapping):
        return {k: (to_dict(v) if isinstance(v, Mapping) else v) for k, v in mapping.items()}

    return to_dict(config)
开发者ID:alfred82santa,项目名称:aio-service-client,代码行数:12,代码来源:spec_loaders.py

示例5: load_configuration

# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import from_file [as 别名]
def load_configuration(file_path, rel_dir=None):
    """ Return the Configuration for the file_path. Also logs an error if
        there is an error while parsing the file.
        If the optional rel_dir is passed the error message would print
        the file_path relative to rel_dir instead of current directory
    """

    logger.debug('Loading file: %s', file_path)
    try:
        return Configuration.from_file(file_path).configure()
    except ConfigurationError as e:
        rel_dir = rel_dir or os.curdir
        logger.error("Error loading: %s; reason: %s",
                     os.path.relpath(file_path, rel_dir), e)
        raise
    return None
开发者ID:RandyLevensalor,项目名称:khaleesi,代码行数:18,代码来源:settings.py

示例6: _load_defaults

# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import from_file [as 别名]
    def _load_defaults(self, path, value):
        param = '-'.join(path[len(self.config_dir + os.sep):].split('/')[::2])
        if not self.parsed['--' + param]:
            logging.warning(
                "\'--%s\' hasn't been provided, using \'%s\' as default" % (
                    param, value))
            self.defaults.append(''.join(['--', param, '=', str(value)]))
        else:
            value = self.parsed['--' + param]

        file_path = path + os.sep + str(value) + '.yml'
        loaded_file = Configuration.from_file(file_path)

        if loaded_file.get(DEFAULTS_TAG):
            path += os.sep + str(value)
            for sub_key, sub_value in loaded_file[DEFAULTS_TAG].iteritems():
                self._load_defaults(path + os.sep + sub_key, sub_value)
开发者ID:Haoxing-Wang,项目名称:InfraRed,代码行数:19,代码来源:settings.py

示例7: getVars

# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import from_file [as 别名]
def getVars(self):
    """ Used at setup of test """
    config = Configuration.from_file('./config.yml').configure()

    self.testbrowser  = config['browser']
    self.host = config['sharehost']	
    self.port = config['shareport']		
    self.sharehost = config['sharehost']
    self.shareport = config['shareport']
    self.repohost  = config['repohost']
    self.repoport  = config['repoport']
    self.host	     = config['sharehost']	

    if config['https'] is True:
       uri = 'https'
    else:	
       uri = 'http'

    if self.shareport is None:
       self.url = uri + '://' + self.sharehost 
    else:
       self.url = uri + '://' + self.sharehost + ':' + str(self.shareport)

    if self.repoport is None:
   		 self.repourl = uri + '://' + self.repohost
    else:
       self.repourl = uri + '://' + self.repohost + ':' + str(self.repoport)

    self.username  = config['user']
    self.password  = config['passwd']
    self.loginurl  = self.url + config['loginurl']
    self.photopath = config['photopath']
    self.cmisurl   = config['cmisurl']
    self.cmisatom  = self.repourl + config['cmisatom']
    self.ftpurl    = config['sharehost']
    self.ftpport   = config['ftpport']
    self.imap_host = config['imap_host']
    self.imap_port = config['imap_port']

    return self
开发者ID:marsbard,项目名称:alfresco-tests,代码行数:42,代码来源:testconfig.py

示例8:

# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import from_file [as 别名]
# -*- coding: utf-8 -*-
import os
import warnings
from configure import Configuration


try:
    environment = os.environ['APPLICATION_ENV']
except:
    warnings.warn('catch error when get os environment APPLICATION_EVN, '
                  'use default prod instead')
    environment = 'prod'

path = os.path.dirname(__file__)
config_file = '{0}/config/config_{1}.yml'.format(path, environment)
settings = Configuration.from_file(config_file).configure()
开发者ID:Rick1125,项目名称:smsapi,代码行数:18,代码来源:config.py

示例9: represent_Include

# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import from_file [as 别名]
# from configure import Include
# Function for programatically representing includes to the configure module
# def represent_Include(dumper, include):
#     return dumper.represent_scalar(u'!include:%s' % include.filename, '')
# yaml.add_representer(Include, represent_Include)

# Load the base configuration YAML
# with open(appfile, 'r') as stream:
#     app = yaml.load(stream)

# Auto load realms and sites directories
# for stem in ['realm', 'site']:
#     plural = stem + 's'
#     # basedir = os.path.join(rootdir, plural)
#     app[plural] = app.get(plural, {}) or {}
#     for dir in os.listdir(os.path.join(appdir, plural)):
#         relative = os.path.join(plural, dir, stem + '.yaml')
#         if os.path.isfile(os.path.join(appdir, relative)):
#             app[plural][dir] = Include(relative)

# config = Configuration.from_string(yaml.dump(app), pwd=os.path.abspath(appdir))

config = Configuration.from_file(appfile)

print config



print Just(1) & Nothing
Either
Maybe
开发者ID:forgerocket,项目名称:openam-scratchpad-python,代码行数:33,代码来源:scratchpad.py

示例10:

# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import from_file [as 别名]
import subprocess
from subprocess import Popen, PIPE, STDOUT
import os
import boto.cloudformation
import boto.s3.connection
import gzip
import logging
import datetime
import sys
from configure import Configuration


folderlocation = os.path.dirname(os.path.realpath(__file__))

#Load Connection Configuration File
ConnectionConfig = Configuration.from_file(os.path.join(folderlocation, 'ConnectionConfig.yaml')).configure()

# Load SQL Server Queries File
queries = Configuration.from_file(os.path.join(folderlocation, 'SQLServerQueries.yaml')).configure()

#Load Redshift Configuration File
RedshiftConfig = Configuration.from_file(os.path.join(folderlocation, 'RedShiftTablesConfig.yaml')).configure()

#Set the date for logging
processdate = datetime.datetime.today().strftime('%Y%m%d')


#Set the package variables

#Packagename
packagename = sys.argv[1]
开发者ID:mikebmassey,项目名称:ETL,代码行数:33,代码来源:RedShift_Load.py

示例11: _load_file

# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import from_file [as 别名]
 def _load_file(self, f):
     logging.debug('Loading file: %s', f)
     cfg = Configuration.from_file(f).configure()
     self._all_settings.update(cfg)
开发者ID:rbrady,项目名称:khaleesi,代码行数:6,代码来源:settings.py

示例12: Env

# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import from_file [as 别名]
'''Get configuration from a file config.ini'''
import os
import base64
import json

from configure import Configuration


config_file = os.path.abspath(os.path.join(os.path.dirname( __file__ ), os.pardir, 'config.yml'))
config = Configuration.from_file(config_file).configure()

class Env(object):
  def __init__(self, adict):
    self.__dict__.update(adict)

def get_environment(section):
    return getattr(config, section)

def get_task_config(task_name):
    for task in config.tasks:
        if task['name'] == task_name:
            return Env(task['config'])
    raise Exception('NO CONFIG FOUND')

def get_io_config(io_name):
    for io_device in config.io:
        if io_device['name'] == io_name:
            return Env(io_device['config'])
    raise Exception('NO CONFIG FOUND')

def decode_var(var, jsonize=False):
开发者ID:davinirjr,项目名称:cron-metrics,代码行数:33,代码来源:config.py


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