From deffe3e80b786f5782c6915e3adabf855bd54ac4 Mon Sep 17 00:00:00 2001 From: Andrew Harvey Date: Sun, 4 Jul 2021 20:48:39 +1000 Subject: directly commit upload.py as some local changes were made --- upload/conflict-view.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100755 upload/conflict-view.py (limited to 'upload/conflict-view.py') diff --git a/upload/conflict-view.py b/upload/conflict-view.py new file mode 100755 index 0000000..cda91ad --- /dev/null +++ b/upload/conflict-view.py @@ -0,0 +1,78 @@ +#! /usr/bin/python +# vim: fileencoding=utf-8 encoding=utf-8 et sw=4 + +# Copyright (C) 2009 Andrzej Zaborowski +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +import os +import sys +import math +import codecs +import locale + +import httplib + +import xml.etree.cElementTree as ElementTree + +import locale, codecs +locale.setlocale(locale.LC_ALL, "en_US.UTF-8") +encoding = locale.getlocale()[1] +sys.stdout = codecs.getwriter(encoding)(sys.stdout, errors = "replace") +sys.stderr = codecs.getwriter(encoding)(sys.stderr, errors = "replace") + +def osmparse(filename): + tree = ElementTree.parse(filename).getroot() + elems = {} + if tree.tag == "osm" and tree.attrib.get("version") == "0.6": + for element in tree: + if not "id" in element.attrib: + continue + id = element.attrib["id"] + if "version" in element.attrib: + v = element.attrib["version"] + else: + v = "0" + if "action" in element.attrib: + elems[id] = (element.attrib["action"], v, element) + elif tree.tag == "osmChange" and \ + tree.attrib.get("version") in [ "0.3", "0.6" ]: + for op in tree: + for element in op: + id = element.attrib["id"] + if "version" in element.attrib: + v = element.attrib["version"] + else: + v = "0" + elems[id] = (op.tag, v, element) + else: + print >>sys.stderr, u"File %s is in unknown format %s v%s!" % \ + (filename, tree.tag, tree.attrib["version"]) + sys.exit(1) + return elems + +if len(sys.argv) != 3: + print >>sys.stderr, u"Synopsis:" + print >>sys.stderr, u" %s " + sys.exit(1) + +a = osmparse(sys.argv[1]) +b = osmparse(sys.argv[2]) + +for id in a: + if id in b: + print a[id][2].tag + " " + id + ":", \ + "A:", a[id][0], "(v" + a[id][1] + ")", \ + "B:", b[id][0], "(v" + b[id][1] + ")" -- cgit v1.2.3