當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。