Exemple #1
0
 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])
Exemple #2
0
 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])
Exemple #3
0
 def testToDatetime(self):
     for dt, tstamp in self.test_dates:
         self.failUnlessEqual(dt, utc_to_datetime(tstamp[0], tstamp[1]))
Exemple #4
0
 def testToDatetime(self):
     for dt, tstamp in self.test_dates:
         self.failUnlessEqual(dt, utc_to_datetime(tstamp[0], tstamp[1]))
Exemple #5
0
 def testToDatetime(self):
     for dt, tstamp in self.test_dates:
         self.assertEqual(dt, utc_to_datetime(tstamp[0], tstamp[1]))
Exemple #6
0
 def testToDatetime(self):
     for dt, tstamp in self.test_dates:
         self.assertEqual(dt, utc_to_datetime(tstamp[0], tstamp[1]))