def make_record(cls, row, key_lookup, **kwargs): for k, v in row.items(): if isinstance(v, basestring): v = v.strip() row[k] = v[:254] elif isinstance(v, uuid.UUID): continue try: if k: if (k not in cls.__table__.c): del row[k] elif not v or v.strip() == "": row[k] = None elif k.endswith('date'): row[k] = datetime.datetime.strptime(v, '%Y%m%d').date() elif '_id' in k: v_san = str(v) try: key_lookup[k] except KeyError: key_lookup[k] = dict() try: row[k] = key_lookup[k][str(v_san)] except KeyError: key_lookup[k][str(v_san)] = libuuid.uuid4() row[k] = key_lookup[k][str(v_san)] else: log.warning("I've got issues with your GTFS {0} data. I'll continue, but expect more errors...".format(cls.__name__)) except Exception, e: log.error(e)
def assign_uuid(message, timestamp): if isinstance(timestamp, datetime): timestamp = (timestamp - epoch).total_seconds() return { 'id': str(uuid4()), 'message': message, 'timestamp': int(round(timestamp * 1000)), }
def test_is_UUID_instance(self): u = libuuid.uuid4() self.assert_(isinstance(u, uuid.UUID))
def test_uuid4(self): u = libuuid.uuid4() u2 = uuid.UUID(bytes=u.bytes) self.assertEqual(u.bytes, u2.bytes)
def _runsome(): for _ in xrange(200): q.put(libuuid.uuid4().hex) q.put(libuuid.uuid1().hex)
def _runsome(): for _ in range(200): q.put(libuuid.uuid4().hex) q.put(libuuid.uuid1().hex)