do not dump undefined locations, make sure out point is > inpoint
This commit is contained in:
parent
2b8e2e8219
commit
764a22aafb
2 changed files with 30 additions and 23 deletions
|
@ -160,6 +160,8 @@ def import_layers(item, layers):
|
||||||
annotation = Annotation(item=item, layer=layer_name)
|
annotation = Annotation(item=item, layer=layer_name)
|
||||||
annotation.start = float(layer['time_in'])/1000
|
annotation.start = float(layer['time_in'])/1000
|
||||||
annotation.end = float(layer['time_out'])/1000
|
annotation.end = float(layer['time_out'])/1000
|
||||||
|
if annotation.end < annotation.start:
|
||||||
|
annotation.end = annotation.start + 3
|
||||||
username = layer['creator'].strip()
|
username = layer['creator'].strip()
|
||||||
annotation.user = User.objects.get(username=username)
|
annotation.user = User.objects.get(username=username)
|
||||||
annotation.value = html_parser(layer['value'])
|
annotation.value = html_parser(layer['value'])
|
||||||
|
@ -183,6 +185,9 @@ for oldId in sorted(padma, key=lambda x: padma[x]['created']):
|
||||||
item.user = User.objects.get(username=username)
|
item.user = User.objects.get(username=username)
|
||||||
for key in _data:
|
for key in _data:
|
||||||
item.data[key] = _data[key]
|
item.data[key] = _data[key]
|
||||||
|
if 'collection' in data and data['collection']:
|
||||||
|
group, created = Group.objects.get_or_create(name=data['collection'])
|
||||||
|
item.groups.add(group)
|
||||||
if 'poster_frame' in item.data:
|
if 'poster_frame' in item.data:
|
||||||
item.poster_frame = float(item.data.pop('poster_frame')) / 1000
|
item.poster_frame = float(item.data.pop('poster_frame')) / 1000
|
||||||
if 'published' in item.data:
|
if 'published' in item.data:
|
||||||
|
@ -260,6 +265,7 @@ for l in locations:
|
||||||
l['user'] = User.objects.get(username=l['user'].strip())
|
l['user'] = User.objects.get(username=l['user'].strip())
|
||||||
else:
|
else:
|
||||||
l['user'] = User.objects.all().order_by('id')[0]
|
l['user'] = User.objects.all().order_by('id')[0]
|
||||||
|
l['name'] = ox.decodeHtml(l['name'])
|
||||||
l['created'] = datetime.fromtimestamp(int(l['created']))
|
l['created'] = datetime.fromtimestamp(int(l['created']))
|
||||||
l['modified'] = datetime.fromtimestamp(int(l['modified']))
|
l['modified'] = datetime.fromtimestamp(int(l['modified']))
|
||||||
l['alternativeNames'] = tuple(l['alternativeNames'])
|
l['alternativeNames'] = tuple(l['alternativeNames'])
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vi:si:et:sw=2:sts=2:ts=2
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
# GPL written 2008 by j@pad.ma
|
# GPL written 2008 by j@pad.ma
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
@ -93,28 +93,29 @@ with open(os.path.join(prefix, 'lists.json'), 'w') as f:
|
||||||
|
|
||||||
locations = []
|
locations = []
|
||||||
for l in Location.select().orderBy('id'):
|
for l in Location.select().orderBy('id'):
|
||||||
data = {}
|
if l.lat_center != 0 and l.lng_center != 0 and l.area != 0:
|
||||||
data['id'] = l.hid
|
data = {}
|
||||||
data['name'] = l.name
|
data['id'] = l.hid
|
||||||
data['south'] = l.lat_sw
|
data['name'] = l.name
|
||||||
data['west'] = l.lng_sw
|
data['south'] = l.lat_sw
|
||||||
data['north'] = l.lat_ne
|
data['west'] = l.lng_sw
|
||||||
data['east'] = l.lng_ne
|
data['north'] = l.lat_ne
|
||||||
data['lat'] = l.lat_center
|
data['east'] = l.lng_ne
|
||||||
data['lng'] = l.lng_center
|
data['lat'] = l.lat_center
|
||||||
data['area'] = l.area
|
data['lng'] = l.lng_center
|
||||||
data['created'] = int(l.created.strftime('%s'))
|
data['area'] = l.area
|
||||||
data['modified'] = int(l.modified.strftime('%s'))
|
data['created'] = int(l.created.strftime('%s'))
|
||||||
data['alternativeNames'] = [l.name for l in l.alt_names]
|
data['modified'] = int(l.modified.strftime('%s'))
|
||||||
try:
|
data['alternativeNames'] = [l.name for l in l.alt_names]
|
||||||
if l.creator:
|
try:
|
||||||
data['user'] = l.creator.user_name
|
if l.creator:
|
||||||
except SQLObjectNotFound:
|
data['user'] = l.creator.user_name
|
||||||
pass
|
except SQLObjectNotFound:
|
||||||
data['annotations'] = []
|
pass
|
||||||
for a in l.layers:
|
data['annotations'] = []
|
||||||
data['annotations'].append(a.hid)
|
for a in l.layers:
|
||||||
locations.append(data)
|
data['annotations'].append(a.hid)
|
||||||
|
locations.append(data)
|
||||||
|
|
||||||
with open(os.path.join(prefix, 'locations.json'), 'w') as f:
|
with open(os.path.join(prefix, 'locations.json'), 'w') as f:
|
||||||
json.dump(locations, f, indent=2)
|
json.dump(locations, f, indent=2)
|
||||||
|
|
Loading…
Reference in a new issue