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


Python Munch.fromDict方法代码示例

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


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

示例1: load_data_from

# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import fromDict [as 别名]
def load_data_from(file_name, mode=None, external_params_name=None):
    """We assume that 'external_params' is a a valid json if passed
    """

    external_params = BuiltIn().\
        get_variable_value('${{{name}}}'.format(name=external_params_name))

    if not os.path.exists(file_name):
        file_name = os.path.join(os.path.dirname(__file__), 'data', file_name)
    with open(file_name) as file_obj:
        if file_name.endswith('.json'):
            file_data = Munch.fromDict(load(file_obj))
        elif file_name.endswith('.yaml'):
            file_data = Munch.fromYAML(file_obj)
    if mode == 'brokers':
        default = file_data.pop('Default')
        brokers = {}
        for k, v in file_data.iteritems():
            brokers[k] = merge_dicts(default, v)
        file_data = brokers

    try:
        ext_params_munch \
            = Munch.fromDict(loads(external_params)) \
            if external_params else Munch()
    except ValueError:
        raise ValueError(
            'Value {param} of command line parameter {name} is invalid'.
            format(name=external_params_name, param=str(external_params))
        )

    return merge_dicts(file_data, ext_params_munch)
开发者ID:OSerhii,项目名称:robot_tests,代码行数:34,代码来源:service_keywords.py

示例2: _check_session

# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import fromDict [as 别名]
 def _check_session(self):
     if not 'FLASK_FAS_OPENID_USER' in flask.session \
             or flask.session['FLASK_FAS_OPENID_USER'] is None:
         flask.g.fas_user = None
     else:
         user = flask.session['FLASK_FAS_OPENID_USER']
         # Add approved_memberships to provide backwards compatibility
         # New applications should only use g.fas_user.groups
         user['approved_memberships'] = []
         for group in user['groups']:
             membership = dict()
             membership['name'] = group
             user['approved_memberships'].append(Munch.fromDict(membership))
         flask.g.fas_user = Munch.fromDict(user)
         flask.g.fas_user.groups = frozenset(flask.g.fas_user.groups)
     flask.g.fas_session_id = 0
开发者ID:rodrigc,项目名称:python-fedora,代码行数:18,代码来源:flask_fas_openid.py

示例3: load_initial_data_from

# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import fromDict [as 别名]
def load_initial_data_from(file_name):
    if not os.path.exists(file_name):
        file_name = os.path.join(os.path.dirname(__file__), 'data/{}'.format(file_name))
    with open(file_name) as file_obj:
        if file_name.endswith(".json"):
            return Munch.fromDict(load(file_obj))
        elif file_name.endswith(".yaml"):
            return fromYAML(file_obj)
开发者ID:yboi,项目名称:robot_tests,代码行数:10,代码来源:service_keywords.py

示例4: load_data_from_file

# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import fromDict [as 别名]
def load_data_from_file(file_name):
    if not os.path.exists(file_name):
        file_name = os.path.join(os.path.dirname(__file__), file_name)
    with open(file_name) as file_obj:
        if file_name.endswith(".json"):
            return Munch.fromDict(load(file_obj))
        elif file_name.endswith(".yaml"):
            return Munch.fromYAML(file_obj)
开发者ID:Valdisk92,项目名称:robot_tests,代码行数:10,代码来源:op_faker.py

示例5: load_data_from

# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import fromDict [as 别名]
def load_data_from(file_name, mode=None):
    if not os.path.exists(file_name):
        file_name = os.path.join(os.path.dirname(__file__), 'data', file_name)
    with open(file_name) as file_obj:
        if file_name.endswith(".json"):
            file_data = Munch.fromDict(load(file_obj))
        elif file_name.endswith(".yaml"):
            file_data = fromYAML(file_obj)
    if mode == "brokers":
        default = file_data.pop('Default')
        brokers = {}
        for k, v in file_data.iteritems():
            brokers[k] = merge_dicts(default, v)
        return brokers
    else:
        return file_data
开发者ID:OlehGordiichuk,项目名称:robot_tests,代码行数:18,代码来源:service_keywords.py

示例6: test_fromDict

# 需要导入模块: from munch import Munch [as 别名]
# 或者: from munch.Munch import fromDict [as 别名]
def test_fromDict():
    b = Munch.fromDict({'urmom': {'sez': {'what': 'what'}}})
    assert b.urmom.sez.what == 'what'
开发者ID:Infinidat,项目名称:munch,代码行数:5,代码来源:test_munch.py


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