diff --git a/conflate.py b/conflate.py index 166b91c..704c9ce 100755 --- a/conflate.py +++ b/conflate.py @@ -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: diff --git a/profiles/moscow_parkomats.py b/profiles/moscow_parkomats.py index 84a84b8..38565d1 100644 --- a/profiles/moscow_parkomats.py +++ b/profiles/moscow_parkomats.py @@ -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: