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


Python munch.munchify函数代码示例

本文整理汇总了Python中munch.munchify函数的典型用法代码示例。如果您正苦于以下问题:Python munchify函数的具体用法?Python munchify怎么用?Python munchify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: prepare_test_tender_data

def prepare_test_tender_data(procedure_intervals, mode):
    # Get actual intervals by mode name
    if mode in procedure_intervals:
        intervals = procedure_intervals[mode]
    else:
        intervals = procedure_intervals['default']
    LOGGER.log_message(Message(intervals))

    # Set acceleration value for certain modes
    if mode in ['openua', 'openeu']:
        assert isinstance(intervals['accelerator'], int), \
            "Accelerator should be an 'int', " \
            "not '{}'".format(type(intervals['accelerator']).__name__)
        assert intervals['accelerator'] >= 0, \
            "Accelerator should not be less than 0"
    else:
        assert 'accelerator' not in intervals.keys(), \
               "Accelerator is not available for mode '{0}'".format(mode)

    if mode == 'single':
        return munchify({'data': test_tender_data(intervals)})
    elif mode == 'multi':
        return munchify({'data': test_tender_data_multiple_items(intervals)})
    elif mode == 'limited':
        return munchify({'data': test_tender_data_limited(intervals)})
    elif mode == 'openua':
        return munchify({'data': test_tender_data_openua(intervals)})
    raise ValueError("Invalid mode for prepare_test_tender_data")
开发者ID:andriykucherenko,项目名称:robot_tests,代码行数:28,代码来源:service_keywords.py

示例2: test_munchify

def test_munchify():
    b = munchify({"urmom": {"sez": {"what": "what"}}})
    assert b.urmom.sez.what == "what"

    b = munchify({"lol": ("cats", {"hah": "i win again"}), "hello": [{"french": "salut", "german": "hallo"}]})
    assert b.hello[0].french == "salut"
    assert b.lol[1].hah == "i win again"
开发者ID:mbarrien,项目名称:munch,代码行数:7,代码来源:test_munch.py

示例3: test_bid_competitive_data

def test_bid_competitive_data():
    bid = munchify({
        "data": {
            "tenderers": [
                fake.procuringEntity()
            ]
        }
    })
    if len(used_identifier_id) == 3:
        del used_identifier_id[0]
    id = bid.data.tenderers[0].identifier.id
    while (id in used_identifier_id):
        bid = munchify({
            "data": {
                "tenderers": [
                    fake.procuringEntity()
                ]
            }
        })
        id = bid.data.tenderers[0].identifier.id
    used_identifier_id.append(id)
    bid.data.tenderers[0].address.countryName_en = translate_country_en(bid.data.tenderers[0].address.countryName)
    bid.data.tenderers[0].address.countryName_ru = translate_country_ru(bid.data.tenderers[0].address.countryName)
    bid.data['status'] = 'draft'
    return bid
开发者ID:Valdisk92,项目名称:robot_tests,代码行数:25,代码来源:initial_data.py

示例4: prepare_test_tender_data

def prepare_test_tender_data(period_interval=2, mode="single"):
    if mode == "single":
        return munchify({"data": test_tender_data(period_interval=period_interval)})
    elif mode == "multi":
        return munchify({"data": test_tender_data_multiple_lots(period_interval=period_interval)})
    elif mode == "meat":
        return munchify({"data": test_meat_tender_data(period_interval=period_interval)})
    raise ValueError("A very specific bad thing happened")
开发者ID:Leits,项目名称:rt,代码行数:8,代码来源:service_keywords.py

示例5: prepare_test_tender_data

def prepare_test_tender_data(period_intervals, mode):
    if mode == 'single':
        return munchify({'data': test_tender_data(period_intervals)})
    elif mode == 'multi':
        return munchify({'data': test_tender_data_multiple_items(period_intervals)})
    elif mode == 'limited':
        return munchify({'data': test_tender_data_limited(period_intervals)})
    raise ValueError('Invalid mode for test_tender_data')
开发者ID:kamilo92,项目名称:robot_tests,代码行数:8,代码来源:service_keywords.py

示例6: test_get_location_error

 def test_get_location_error(self):
     setup_routing(self.app, routs=["tender_subpage_item"])
     self.assertEqual(self.client.get_question(self.empty_tender, question_id=TEST_KEYS.question_id),
                      munchify(loads(location_error('questions'))))
     self.assertEqual(self.client.get_lot(self.empty_tender, lot_id=TEST_KEYS.lot_id),
                      munchify(loads(location_error('lots'))))
     self.assertEqual(self.client.get_bid(self.empty_tender, bid_id=TEST_KEYS.bid_id, access_token=API_KEY),
                      munchify(loads(location_error('bids'))))
开发者ID:gorserg,项目名称:openprocurement.client.python,代码行数:8,代码来源:tests.py

示例7: test_delete_location_error

 def test_delete_location_error(self):
     setup_routing(self.app, routs=["tender_subpage_item_delete"])
     self.assertEqual(
         self.client.delete_bid(self.empty_tender, TEST_KEYS.error_id, API_KEY),
         munchify(loads(location_error("bids"))),
     )
     self.assertEqual(
         self.client.delete_lot(self.empty_tender, TEST_KEYS.error_id), munchify(loads(location_error("lots")))
     )
开发者ID:mykhaly,项目名称:openprocurement.client.python,代码行数:9,代码来源:tests.py

示例8: test_munchify_cycle

def test_munchify_cycle():
    # dict1 -> dict2 -> dict1
    x = dict(id="x")
    y = dict(x=x, id="y")
    x['y'] = y
    
    m = munchify(x)
    assert m.id == "x"
    assert m.y.id == "y"
    assert m.y.x is m
    
    # dict -> list -> dict
    x = dict(id="x")
    y = ["y", x]
    x["y"] = y
    
    m = munchify(x)
    assert m.id == "x"
    assert m.y[0] == "y"
    assert m.y[1] is m

    # dict -> tuple -> dict
    x = dict(id="x")
    y = ("y", x)
    x["y"] = y

    m = munchify(x)
    assert m.id == "x"
    assert m.y[0] == "y"
    assert m.y[1] is m
    
    # dict1 -> list -> dict2 -> list
    z = dict(id="z")
    y = ["y", z]
    z["y"] = y
    x = dict(id="x", y=y)
    
    m = munchify(x)
    assert m.id == "x"
    assert m.y[0] == "y"
    assert m.y[1].id == "z"
    assert m.y[1].y is m.y

    # dict1 -> tuple -> dict2 -> tuple
    z = dict(id="z")
    y = ("y", z)
    z["y"] = y
    x = dict(id="x", y=y)
    
    m = munchify(x)
    assert m.id == "x"
    assert m.y[0] == "y"
    assert m.y[1].id == "z"
    assert m.y[1].y is m.y
开发者ID:Infinidat,项目名称:munch,代码行数:54,代码来源:test_munch.py

示例9: setUp

    def setUp(self):
        self.app = Bottle()
        setup_routing(self.app)
        self.server = WSGIServer(('localhost', 20602), self.app, log=None)
        self.server.start()

        self.client = plan_client.PlansClient('', host_url=HOST_URL, api_version=API_VERSION)

        with open(ROOT + 'plans.json') as plans:
            self.plans = munchify(load(plans))
        with open(ROOT + 'plan_' + TEST_PLAN_KEYS.plan_id + '.json') as plan:
            self.plan = munchify(load(plan))
开发者ID:gorserg,项目名称:openprocurement.client.python,代码行数:12,代码来源:tests.py

示例10: init

def init(config, codeRegistry, verbose=False, tags=None):
    '''cwd is where segment file was loaded.'''
    mdb = codeRegistry.getService('fashion.prime.modelAccess')
    args = munchify(mdb.getSingleton("fashion.prime.args"))
    if "force" in args:
        f = args.force
    else:
        f = False
    pf = munchify(mdb.getSingleton("fashion.prime.portfolio"))
    codeRegistry.addService(MirrorService(Path(pf.projectPath), Path(pf.mirrorPath), force=f))
    codeRegistry.addService(TemplateService())
    codeRegistry.addService(GenerateService(codeRegistry))
开发者ID:braddillman,项目名称:fashion,代码行数:12,代码来源:services.py

示例11: prepare_test_tender_data

def prepare_test_tender_data(procedure_intervals,
                             tender_parameters,
                             submissionMethodDetails,
                             accelerator,
                             funders):
    # Get actual intervals by mode name
    mode = tender_parameters['mode']
    if mode in procedure_intervals:
        intervals = procedure_intervals[mode]
    else:
        intervals = procedure_intervals['default']
    LOGGER.log_message(Message(intervals))
    tender_parameters['intervals'] = intervals

    # Set acceleration value for certain modes
    assert isinstance(intervals['accelerator'], int), \
        "Accelerator should be an 'int', " \
        "not '{}'".format(type(intervals['accelerator']).__name__)
    assert intervals['accelerator'] >= 0, \
        "Accelerator should not be less than 0"
    if mode == 'negotiation':
        return munchify({'data': test_tender_data_limited(tender_parameters)})
    elif mode == 'negotiation.quick':
        return munchify({'data': test_tender_data_limited(tender_parameters)})
    elif mode == 'openeu':
        return munchify({'data': test_tender_data_openeu(
            tender_parameters, submissionMethodDetails)})
    elif mode == 'openua':
        return munchify({'data': test_tender_data_openua(
            tender_parameters, submissionMethodDetails)})
    elif mode == 'openua_defense':
        return munchify({'data': test_tender_data_openua_defense(
            tender_parameters, submissionMethodDetails)})
    elif mode == 'open_competitive_dialogue':
        return munchify({'data': test_tender_data_competitive_dialogue(
            tender_parameters, submissionMethodDetails)})
    elif mode == 'reporting':
        return munchify({'data': test_tender_data_limited(tender_parameters)})
    elif mode == 'open_framework':
        return munchify({'data': test_tender_data_framework_agreement(
            tender_parameters, submissionMethodDetails)})
    elif mode == 'belowThreshold':
        return munchify({'data': test_tender_data(
            tender_parameters,
            submissionMethodDetails=submissionMethodDetails,
            funders=funders,
            accelerator=accelerator)})
    elif mode == 'open_esco':
         return munchify({'data': test_tender_data_esco(
            tender_parameters, submissionMethodDetails)})
        # The previous line needs an explicit keyword argument because,
        # unlike previous functions, this one has three arguments.
    raise ValueError("Invalid mode for prepare_test_tender_data")
开发者ID:portunatos,项目名称:robot_tests,代码行数:53,代码来源:service_keywords.py

示例12: setUp

    def setUp(self):
        #self._testMethodName
        self.app = Bottle()

        setup_routing(self.app)
        self.server = WSGIServer(('localhost', 20602), self.app, log=None)
        self.server.start()
        self.client = client.Client(API_KEY,  host_url=HOST_URL, api_version=API_VERSION)

        with open(ROOT + TEST_KEYS.tender_id + '.json') as tender:
            self.tender = munchify(load(tender))
            self.tender.update({'access':{"token": API_KEY}})
        with open(ROOT + TEST_KEYS.empty_tender + '.json') as tender:
            self.empty_tender = munchify(load(tender))
            self.empty_tender.update({'access':{"token": API_KEY}})
开发者ID:Leits,项目名称:openprocurement.client.python,代码行数:15,代码来源:tests.py

示例13: test_invalid_checkpoint

    def test_invalid_checkpoint(self):
        """Invalid checkpoint names return helpful error message."""

        node = tut.sphinx.checkpoint.TutCheckpoint(
            'checkpoint',
            ('blarf',),
            {'path': os.getcwd()},
            content='',
            lineno=0,
            content_offset=0,
            block_text=None,
            state=munchify({
                'document': {
                    'settings': {
                        'env': {
                            'relfn2path': lambda p: (p, p)
                        },
                    },
                },
            }),
            state_machine=None,
        )

        with self.assertRaises(ValueError) as git_error:
            node.run()

        self.assertEqual(
            str(git_error.exception),
            "git checkpoint 'blarf' does not exist.",
        )
开发者ID:nyergler,项目名称:tut,代码行数:30,代码来源:test_sphinx.py

示例14: test_bid_data

def test_bid_data():
    return munchify({
        "data": {
            "tenderers": [
                {
                    "address": {
                        "countryName": "Україна",
                        "locality": "м. Вінниця",
                        "postalCode": "21100",
                        "region": "м. Вінниця",
                        "streetAddress": fake.street_address()
                    },
                    "contactPoint": {
                        "name": fake.name(),
                        "telephone": fake.phone_number()
                    },
                    "identifier": {
                        "scheme": u"UA-EDR",
                        "id": u"0000{}".format(fake.pyint()),
                    },
                    "name": fake.company()
                }
            ],
            "value": {
                "amount": 500
            }
        }
    })
开发者ID:SavchukRoman,项目名称:robot_tests,代码行数:28,代码来源:initial_data.py

示例15: test_complaint_data

def test_complaint_data():
    return munchify({
        "data": {
            "author": {
                "address": {
                    "countryName": "Україна",
                    "locality": "м. Вінниця",
                    "postalCode": "21100",
                    "region": "м. Вінниця",
                    "streetAddress": fake.street_address()
                },
                "contactPoint": {
                    "name": fake.name(),
                    "telephone": fake.phone_number()
                },
                "identifier": {
                    "scheme": u"UA-EDR",
                    "id": u"0000{}".format(fake.pyint()),
                    "uri": fake.image_url(width=None, height=None)
                },
                "name": fake.company()
            },
            "description": fake.sentence(nb_words=10, variable_nb_words=True),
            "title": fake.sentence(nb_words=6, variable_nb_words=True)
        }
    })
开发者ID:SavchukRoman,项目名称:robot_tests,代码行数:26,代码来源:initial_data.py


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