From 7b66762f1ab37fa0c78f82e37da4ac49019b4165 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Eddy=20Petri=C8=99or?= Date: Fri, 24 Jul 2009 13:03:14 +0200 Subject: [PATCH] isolate the code to identify same siruta code list in a function --- OsmLocImport.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/OsmLocImport.py b/OsmLocImport.py index 436b5cd..c8935e4 100755 --- a/OsmLocImport.py +++ b/OsmLocImport.py @@ -263,6 +263,18 @@ the existing data which is present in 'oldnode'""" return node +def getSameSiruta(elementlist, sirutacode): + """returns a list with all the elements in list which have the siruta:code == sirutacode""" + + newlist = [] + for x in elementlist: + try: + if x[u"tag"][u"siruta:code"] == sirutacode: + newlist.append(x.copy()) + except KeyError: + pass + + return newlist def readAndProcessSirutaCsv(file, comment = None, source = None): """reads the input CSV file and processes each entry""" @@ -304,14 +316,7 @@ def readAndProcessSirutaCsv(file, comment = None, source = None): # I am confused, more than one node with the same simplified name # try to see if there's already a siruta code attached - newlist = [] - for x in existing_nodes: - try: - if x[u"tag"][u"siruta:code"] == csvplace[u"siruta:code"]: - newlist.append(x.copy()) - except KeyError: - pass - + newlist = getSameSiruta( existing_nodes, csvplace[u"siruta:code"] ) if len(newlist) == 1: existing_nodes = newlist else: -- 2.11.4.GIT