source: subversion/applications/utils/import/bulkupload/conflict-view.py @ 34714

Last change on this file since 34714 was 19989, checked in by balrog-kun, 10 years ago

Set the executable bits on the executables. (this directory still needs a clean-up)

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#! /usr/bin/python
2# vim: fileencoding=utf-8 encoding=utf-8 et sw=4
3
4# Copyright (C) 2009 Andrzej Zaborowski <balrogg@gmail.com>
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19
20import os
21import sys
22import math
23import codecs
24import locale
25
26import httplib
27
28import xml.etree.cElementTree as ElementTree
29
30import locale, codecs
31locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
32encoding = locale.getlocale()[1]
33sys.stdout = codecs.getwriter(encoding)(sys.stdout, errors = "replace")
34sys.stderr = codecs.getwriter(encoding)(sys.stderr, errors = "replace")
35
36def osmparse(filename):
37    tree = ElementTree.parse(filename).getroot()
38    elems = {}
39    if tree.tag == "osm" and tree.attrib.get("version") == "0.6":
40        for element in tree:
41            if not "id" in element.attrib:
42                continue
43            id = element.attrib["id"]
44            if "version" in element.attrib:
45                v = element.attrib["version"]
46            else:
47                v = "0"
48            if "action" in element.attrib:
49                elems[id] = (element.attrib["action"], v, element)
50    elif tree.tag == "osmChange" and \
51            tree.attrib.get("version") in [ "0.3", "0.6" ]:
52        for op in tree:
53            for element in op:
54                id = element.attrib["id"]
55                if "version" in element.attrib:
56                    v = element.attrib["version"]
57                else:
58                    v = "0"
59                elems[id] = (op.tag, v, element)
60    else:
61        print >>sys.stderr, u"File %s is in unknown format %s v%s!" % \
62                (filename, tree.tag, tree.attrib["version"])
63        sys.exit(1)
64    return elems
65
66if len(sys.argv) != 3:
67    print >>sys.stderr, u"Synopsis:"
68    print >>sys.stderr, u"    %s <osm-or-osc-file> <osm-or-osc-file>"
69    sys.exit(1)
70
71a = osmparse(sys.argv[1])
72b = osmparse(sys.argv[2])
73
74for id in a:
75    if id in b:
76        print a[id][2].tag + " " + id + ":", \
77                "A:", a[id][0], "(v" + a[id][1] + ")", \
78                "B:", b[id][0], "(v" + b[id][1] + ")"
Note: See TracBrowser for help on using the repository browser.