Added zipfile
This commit is contained in:
parent
0e025b7b46
commit
8363d07311
2 changed files with 9 additions and 6 deletions
|
@ -8,8 +8,9 @@ import requests
|
|||
import os
|
||||
import sys
|
||||
from io import BytesIO
|
||||
import json # for profiles
|
||||
import re # for profiles
|
||||
import json # for profiles
|
||||
import re # for profiles
|
||||
import zipfile # for profiles
|
||||
try:
|
||||
from lxml import etree
|
||||
except ImportError:
|
||||
|
@ -414,7 +415,8 @@ class OsmConflator:
|
|||
p.lon = sp.lon
|
||||
p.action = 'modify'
|
||||
if 'source' in p.tags:
|
||||
p.tags['source'] = ';'.join([p.tags['source'], self.source])
|
||||
if self.source not in p.tags['source']:
|
||||
p.tags['source'] = ';'.join([p.tags['source'], self.source])
|
||||
else:
|
||||
p.tags['source'] = self.source
|
||||
if self.ref is not None:
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
import json
|
||||
import re
|
||||
import logging
|
||||
import zipfile
|
||||
|
||||
# Verify this at http://data.mos.ru/opendata/1421/passport ("Download .json")
|
||||
# Disabled since the link returns a zip file and not a plain json
|
||||
# download_url = 'http://op.mos.ru/EHDWSREST/catalog/export/get?id=89786'
|
||||
download_url = 'https://op.mos.ru/EHDWSREST/catalog/export/get?id=216775'
|
||||
|
||||
# What will be put into "source" tags. Lower case please
|
||||
source = 'dit.mos.ru'
|
||||
|
@ -35,7 +35,8 @@ master_tags = ('zone:parking', 'ref', 'contact:phone', 'contact:website', 'opera
|
|||
|
||||
# A list of SourcePoint objects. Initialize with (id, lat, lon, {tags}).
|
||||
def dataset(fileobj):
|
||||
source = json.loads(fileobj.read().decode('cp1251'))
|
||||
zf = zipfile.ZipFile(fileobj)
|
||||
source = json.loads(zf.read(zf.namelist()[0]).decode('cp1251'))
|
||||
RE_NUM4 = re.compile(r'\d{4,6}')
|
||||
data = []
|
||||
for el in source:
|
||||
|
|
Loading…
Add table
Reference in a new issue