How to use the spidermon.data.Data function in spidermon

To help you get started, we’ve selected a few spidermon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scrapinghub / spidermon / tests / test_expressions.py View on Github external
def test_evaluated_expressions(interpreter):
    data = Data({"stats": Data(STATS_TO_EVALUATE)})
    for expression, result in EXPRESSIONS_TO_EVALUATE:
        assert result == interpreter.eval(
            expression, data
        ), 'Expression fails: "%s" != %s' % (expression, result)
github scrapinghub / spidermon / tests / contrib / monitors / mixins / test_validation.py View on Github external
def monitor():
    monitor = DummyValidationMonitor()
    monitor.correct_field_list_handling = True
    monitor.data = Data({"stats": stats})
    return monitor
github scrapinghub / spidermon / tests / contrib / monitors / mixins / test_validation.py View on Github external
def old_monitor():
    monitor = DummyValidationMonitor()
    monitor.correct_field_list_handling = False
    monitor.data = Data({"stats": stats})
    return monitor
github scrapinghub / spidermon / tests / test_data.py View on Github external
def data():
    return Data(item_scraped_count=150)
github scrapinghub / spidermon / tests / contrib / monitors / mixins / test_validation.py View on Github external
def old_monitor_without_attr():
    monitor = DummyValidationMonitor()
    monitor.data = Data({"stats": stats})
    return monitor
github scrapinghub / spidermon / spidermon / runners.py View on Github external
def transform_data(self, **data):
        data = data or {}
        new_data_dict = {}
        for attr_name, attr in data.items():
            if attr_name in self.data_immutable_dicts:
                new_data = Data(attr)
            else:
                new_data = attr
            new_data_dict[attr_name] = new_data
        return Data(new_data_dict)
github scrapinghub / spidermon / spidermon / runners.py View on Github external
def transform_data(self, **data):
        data = data or {}
        new_data_dict = {}
        for attr_name, attr in data.items():
            if attr_name in self.data_immutable_dicts:
                new_data = Data(attr)
            else:
                new_data = attr
            new_data_dict[attr_name] = new_data
        return Data(new_data_dict)