コード例 #1
0
ファイル: parser.py プロジェクト: leftees/papukaani
def create_points(data):
    """
    Creates a new entry for every Gathering not already in the database.
    :param data: The contents of the uploaded file.
    :return: A list containing all of the Gatherings found in the file.
    :return: A list containing all of the Gatherings found in the file.
    """
    collections = {}

    for point in data:
        if point['GpsNumber'] not in collections:
            collections[point['GpsNumber']] = []

        device.get_or_create(deviceId = point['GpsNumber'], parserInfo=parserInfo)

        collections[point['GpsNumber']].append(
            gathering.Gathering(
                time=ecotones_parse_time(point['GPSTime']),
                geometry = [float(point["Latitude"]), float(point["Longtitude"])],
                temperature=float(point['Temperature'])
            ))

    points = []
    for k in collections.keys():
            points += collections[k]
            document.create(str(uuid.uuid4()), collections[k], k)

    return points
コード例 #2
0
ファイル: testDevice.py プロジェクト: leftees/papukaani
    def test_get_or_create(self):
        before = len(device.get_all())
        device.get_or_create("ABCD1234567", {"type":"Type", "manufacturer":"Manu"})
        self.assertEquals(before, len(device.get_all()))

        d = device.get_or_create("TESTTEST", {"type":"Type", "manufacturer":"Manu"})
        self.assertLess(before, len(device.get_all()))

        d.delete()