Ejemplo n.º 1
0
 def test_object(self):
     data = {
         "help": 5,
         "xxx": datetime.utcnow(),
         "bla": None,
         "foo": set(["a"]),
         "yum": b"xxx",
     }
     json = dump_json(data)
     out = load_json(json)
     assert "bla" not in out, out
     assert "xxx" in out, out
     assert "a" in out["foo"], out
     assert load_json("") is None
     assert load_json(None) is None
     assert dump_json(None) == ""
Ejemplo n.º 2
0
 def test_object(self):
     data = {
         'help': 5,
         'xxx': datetime.utcnow(),
         'bla': None,
         'foo': set(['a']),
         'yum': b'xxx'
     }
     json = dump_json(data)
     out = load_json(json)
     assert 'bla' not in out, out
     assert 'xxx' in out, out
     assert 'a' in out['foo'], out
     assert load_json('') is None
     assert load_json(None) is None
     assert dump_json(None) == ''
Ejemplo n.º 3
0
 def unpack(cls, conn, data):
     if data is None:
         return None
     data = load_json(data)
     job = Job(conn, data.get('dataset'), data.get('job'))
     stage = job.get_stage(data.get('stage'))
     return Task(stage, data.get('payload'), data.get('context'))
Ejemplo n.º 4
0
 def unpack(cls, conn, data):
     if data is None:
         return None
     data = load_json(data)
     job = Job(conn, data.get("dataset"), data.get("job"))
     stage = job.get_stage(data.get("stage"))
     return Task(stage, data.get("payload"), data.get("context"))
Ejemplo n.º 5
0
 def event_list(cls, key, start, end):
     results = []
     events = conn.lrange(key, start, end)
     if events is None:
         return results
     for event in events:
         result = load_json(event)
         result["timestamp"] = unpack_datetime(result['timestamp'])
         results.append(result)
     return results
Ejemplo n.º 6
0
 def get_tag(self, key):
     value = tags.get(make_key(self.crawler, "tag", key))
     if value is not None:
         return load_json(value)