-
Notifications
You must be signed in to change notification settings - Fork 0
/
exporters.py
34 lines (30 loc) · 1.46 KB
/
exporters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from google.appengine.ext import db
from google.appengine.tools import bulkloader
import datetime
# model
class Earthquake(db.Model):
location = db.StringProperty()
position = db.GeoPtProperty()
time = db.DateTimeProperty()
magnitude = db.FloatProperty()
magnitude_type = db.CategoryProperty() # Short form, eg. Richter => ML; UKN when there is a lack of data
depth = db.FloatProperty()
object_type = db.CategoryProperty() # Normal or Special
extra = db.TextProperty() # Usually used when "kind" is "Special"
details = db.LinkProperty()
created_at = db.DateTimeProperty(auto_now_add=True)
class EarthquakeExporter(bulkloader.Exporter):
def __init__(self):
bulkloader.Exporter.__init__(self, 'Earthquake',
[('location', lambda x: x.encode('utf-8'), None),
('position', lambda x: str(x.lat) + " " + str(x.lon), None),
('time', str, None),
('magnitude', float, None),
('magnitude_type', str, None),
('depth', float, None),
('details', str, None),
('created_at', str, None),
('object_type', str, None),
('extra', lambda x: x.encode('utf-8'), None),
])
exporters = [EarthquakeExporter]