def convert_bert(self, item): bert_type = item[1] if bert_type == "nil": return None elif bert_type == "string": return item[3].decode(Atom(item[2])) elif bert_type == "dict": return dict((self.convert(k), self.convert(v)) for k, v in item[2]) elif bert_type in ("true", True): return True elif bert_type in ("false", False): return False elif bert_type == "time": return utc_to_datetime(item[2] * 1000000 + item[3], item[4]) elif bert_type == "regex": flags = 0 if 'extended' in item[3]: flags |= re.VERBOSE if 'caseless' in item[3]: flags |= re.IGNORECASE if 'multiline' in item[3]: flags |= re.MULTILINE if 'dotall' in item[3]: flags |= re.DOTALL return re.compile(item[2], flags) raise NotImplementedError("Unknown BERT type %s" % item[1])
def testToDatetime(self): for dt, tstamp in self.test_dates: self.failUnlessEqual(dt, utc_to_datetime(tstamp[0], tstamp[1]))
def testToDatetime(self): for dt, tstamp in self.test_dates: self.assertEqual(dt, utc_to_datetime(tstamp[0], tstamp[1]))