From 6c14d47650daf3a44cec2f6a392184dec14fe9cc Mon Sep 17 00:00:00 2001 From: MasterofJOKers Date: Wed, 30 Jul 2014 21:39:39 +0200 Subject: [PATCH] genPOI: unite for-loops with itertools Since all the POIs are created from different lists, multiple for loops were used. With itertools.chain these lists can be looped over with only one for loop thus removing doubled code. --- overviewer_core/aux_files/genPOI.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/overviewer_core/aux_files/genPOI.py b/overviewer_core/aux_files/genPOI.py index 98ad1ee..cb54fe9 100755 --- a/overviewer_core/aux_files/genPOI.py +++ b/overviewer_core/aux_files/genPOI.py @@ -22,6 +22,7 @@ import re import urllib2 import Queue import multiprocessing +import itertools from multiprocessing import Process from multiprocessing import Pool @@ -350,22 +351,8 @@ def main(): name = replaceBads(filter_name) + hex(hash(filter_function))[-4:] + "_" + hex(hash(rset))[-4:] markerSetDict[name] = dict(created=False, raw=[], name=filter_name) - for poi in rset._pois['Entities']: - result = filter_function(poi) - if result: - d = create_marker_from_filter_result(poi, result) - markerSetDict[name]['raw'].append(d) - for poi in rset._pois['TileEntities']: - result = filter_function(poi) - if result: - d = create_marker_from_filter_result(poi, result) - markerSetDict[name]['raw'].append(d) - for poi in rset._pois['Players']: - result = filter_function(poi) - if result: - d = create_marker_from_filter_result(poi, result) - markerSetDict[name]['raw'].append(d) - for poi in rset._pois['Manual']: + poi_sets = ['Entities', 'TileEntities', 'Players', 'Manual'] + for poi in itertools.chain(rset._pois[n] for n in poi_sets): result = filter_function(poi) if result: d = create_marker_from_filter_result(poi, result)