User:HappyBot/MapsKML.py

mydir = "./" pwbdir = mydir + "pywikipedia/"
 * 1) !/usr/bin/python
 * 2) -*- coding: utf-8 -*-

import sys sys.path.append(pwbdir) from wikipedia import *

import urllib import json

paths = (("IHmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AInterstate+Highway+System+articles")),        ("IHkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AInterstate+Highway+System+articles")),         ("USHmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AU.S.+Highway+system+articles")),         ("USHkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AU.S.+Highway+system+articles")),         ("AUTOmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AU.S.+auto+trail+articles")),         ("AUTOkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AU.S.+auto+trail+articles")),         ("US66map", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AU.S.+Route+66+articles")),         ("US66kml", ("kml", "U.S.+road+articles+needing+KML%0D%0AU.S.+Route+66+articles")),         ("ALmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AAlabama+road+transport+articles")), ("ALkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AAlabama+road+transport+articles")), ("AKmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AAlaska+road+transport+articles")), ("AKkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AAlaska+road+transport+articles")), ("AZmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AArizona+road+transport+articles")), ("AZkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AArizona+road+transport+articles")), ("ARmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AArkansas+road+transport+articles")), ("ARkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AArkansas+road+transport+articles")), ("CAmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ACalifornia+road+transport+articles")), ("CAkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ACalifornia+road+transport+articles")), ("COmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AColorado+road+transport+articles")), ("COkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AColorado+road+transport+articles")), ("CTmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AConnecticut+road+transport+articles")), ("CTkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AConnecticut+road+transport+articles")), ("DEmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ADelaware+road+transport+articles")), ("DEkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ADelaware+road+transport+articles")), ("FLmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AFlorida+road+transport+articles")), ("FLkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AFlorida+road+transport+articles")), ("GAmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AGeorgia+(U.S.+state)+road+transport+articles")), ("GAkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AGeorgia+(U.S.+state)+road+transport+articles")), ("HImap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AHawaii+road+transport+articles")), ("HIkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AHawaii+road+transport+articles")), ("IDmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AIdaho+road+transport+articles")), ("IDkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AIdaho+road+transport+articles")), ("ILmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AIllinois+road+transport+articles")), ("ILkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AIllinois+road+transport+articles")), ("INmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AIndiana+road+transport+articles")), ("INkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AIndiana+road+transport+articles")), ("IAmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AIowa+road+transport+articles")), ("IAkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AIowa+road+transport+articles")), ("KSmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AKansas+road+transport+articles")), ("KSkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AKansas+road+transport+articles")), ("KYmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AKentucky+road+transport+articles")), ("KYkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AKentucky+road+transport+articles")), ("LAmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ALouisiana+road+transport+articles")), ("LAkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ALouisiana+road+transport+articles")), ("MEmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AMaine+road+transport+articles")), ("MEkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AMaine+road+transport+articles")), ("MDmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AMaryland+road+transport+articles")), ("MDkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AMaryland+road+transport+articles")), ("MAmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AMassachusetts+road+transport+articles")), ("MAkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AMassachusetts+road+transport+articles")), ("MImap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AMichigan+road+transport+articles")), ("MIkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AMichigan+road+transport+articles")), ("MNmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AMinnesota+road+transport+articles")), ("MNkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AMinnesota+road+transport+articles")), ("MSmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AMississippi+road+transport+articles")), ("MSkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AMississippi+road+transport+articles")), ("MOmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AMissouri+road+transport+articles")), ("MOkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AMissouri+road+transport+articles")), ("MTmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AMontana+road+transport+articles")), ("MTkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AMontana+road+transport+articles")), ("NEmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ANebraska+road+transport+articles")), ("NEkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ANebraska+road+transport+articles")), ("NVmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ANevada+road+transport+articles")), ("NVkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ANevada+road+transport+articles")), ("NHmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ANew+Hampshire+road+transport+articles")), ("NHkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ANew+Hampshire+road+transport+articles")), ("NJmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ANew+Jersey+road+transport+articles")), ("NJkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ANew+Jersey+road+transport+articles")), ("NMmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ANew+Mexico+road+transport+articles")), ("NMkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ANew+Mexico+road+transport+articles")), ("NYmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ANew+York+road+transport+articles")), ("NYkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ANew+York+road+transport+articles")), ("NCmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ANorth+Carolina+road+transport+articles")), ("NCkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ANorth+Carolina+road+transport+articles")), ("NDmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ANorth+Dakota+road+transport+articles")), ("NDkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ANorth+Dakota+road+transport+articles")), ("OHmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AOhio+road+transport+articles")), ("OHkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AOhio+road+transport+articles")), ("OKmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AOklahoma+road+transport+articles")), ("OKkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AOklahoma+road+transport+articles")), ("ORmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AOregon+road+transport+articles")), ("ORkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AOregon+road+transport+articles")), ("PAmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0APennsylvania+road+transport+articles")), ("PAkml", ("kml", "U.S.+road+articles+needing+KML%0D%0APennsylvania+road+transport+articles")), ("RImap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ARhode+Island+road+transport+articles")), ("RIkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ARhode+Island+road+transport+articles")), ("SCmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ASouth+Carolina+road+transport+articles")), ("SCkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ASouth+Carolina+road+transport+articles")), ("SDmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ASouth+Dakota+road+transport+articles")), ("SDkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ASouth+Dakota+road+transport+articles")), ("TNmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ATennessee+road+transport+articles")), ("TNkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ATennessee+road+transport+articles")), ("TXmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0ATexas+road+transport+articles")), ("TXkml", ("kml", "U.S.+road+articles+needing+KML%0D%0ATexas+road+transport+articles")), ("UTmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AUtah+road+transport+articles")), ("UTkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AUtah+road+transport+articles")), ("VTmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AVermont+road+transport+articles")), ("VTkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AVermont+road+transport+articles")), ("VAmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AVirginia+road+transport+articles")), ("VAkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AVirginia+road+transport+articles")), ("WAmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AWashington+road+transport+articles")), ("WAkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AWashington+road+transport+articles")), ("WVmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AWest+Virginia+road+transport+articles")), ("WVkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AWest+Virginia+road+transport+articles")), ("WImap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AWisconsin+road+transport+articles")), ("WIkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AWisconsin+road+transport+articles")), ("WYmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AWyoming+road+transport+articles")), ("WYkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AWyoming+road+transport+articles")), ("GUmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AGuam+road+transport+articles")), ("GUkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AGuam+road+transport+articles")), ("PRmap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0APuerto+Rico+road+transport+articles")), ("PRkml", ("kml", "U.S.+road+articles+needing+KML%0D%0APuerto+Rico+road+transport+articles")), ("VImap", ("map", "U.S.+Roads+project+articles+needing+maps%0D%0AU.S.+Virgin+Islands+road+transport+articles")), ("VIkml", ("kml", "U.S.+road+articles+needing+KML%0D%0AU.S.+Virgin+Islands+road+transport+articles")), ("topGAMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ATop-importance+U.S.+road+transport+articles%0D%0AGA-Class+U.S.+road+transport+articles")), ("highGAMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AGA-Class+U.S.+road+transport+articles")), ("midGAMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AGA-Class+U.S.+road+transport+articles")), ("lowGAMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AGA-Class+U.S.+road+transport+articles")), ("GAMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AGA-Class+U.S.+road+transport+articles")), ("topBMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ATop-importance+U.S.+road+transport+articles%0D%0AB-Class+U.S.+road+transport+articles")), ("highBMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AB-Class+U.S.+road+transport+articles")), ("midBMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AB-Class+U.S.+road+transport+articles")), ("lowBMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AB-Class+U.S.+road+transport+articles")), ("BMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AB-Class+U.S.+road+transport+articles")), ("topCMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ATop-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")), ("highCMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")), ("midCMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")), ("lowCMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")), ("CMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AC-Class+U.S.+road+transport+articles")), ("topStartMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ATop-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")), ("highStartMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")), ("midStartMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")), ("lowStartMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")), ("StartMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AStart-Class+U.S.+road+transport+articles")), ("topStubMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ATop-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")), ("highStubMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")), ("midStubMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")), ("lowStubMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")), ("StubMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AStub-Class+U.S.+road+transport+articles")), ("topFutureMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ATop-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")), ("highFutureMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")), ("midFutureMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")), ("lowFutureMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")), ("FutureMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AFuture-Class+U.S.+road+transport+articles")), ("topMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ATop-importance+U.S.+road+transport+articles")), ("highMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AHigh-importance+U.S.+road+transport+articles")), ("midMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0AMid-importance+U.S.+road+transport+articles")), ("lowMap", ("overall", "U.S.+Roads+project+articles+needing+maps%0D%0ALow-importance+U.S.+road+transport+articles")), ("Map", ("overall", "U.S.+Roads+project+articles+needing+maps")), ("topBKML", ("overall", "U.S.+road+articles+needing+KML%0D%0ATop-importance+U.S.+road+transport+articles%0D%0AB-Class+U.S.+road+transport+articles")), ("highBKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AB-Class+U.S.+road+transport+articles")), ("midBKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AB-Class+U.S.+road+transport+articles")), ("lowBKML", ("overall", "U.S.+road+articles+needing+KML%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AB-Class+U.S.+road+transport+articles")), ("BKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AB-Class+U.S.+road+transport+articles")), ("topCKML", ("overall", "U.S.+road+articles+needing+KML%0D%0ATop-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")), ("highCKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")), ("midCKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")), ("lowCKML", ("overall", "U.S.+road+articles+needing+KML%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AC-Class+U.S.+road+transport+articles")), ("CKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AC-Class+U.S.+road+transport+articles")), ("topStartKML", ("overall", "U.S.+road+articles+needing+KML%0D%0ATop-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")), ("highStartKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")), ("midStartKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")), ("lowStartKML", ("overall", "U.S.+road+articles+needing+KML%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AStart-Class+U.S.+road+transport+articles")), ("StartKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AStart-Class+U.S.+road+transport+articles")), ("topStubKML", ("overall", "U.S.+road+articles+needing+KML%0D%0ATop-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")), ("highStubKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")), ("midStubKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")), ("lowStubKML", ("overall", "U.S.+road+articles+needing+KML%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AStub-Class+U.S.+road+transport+articles")), ("StubKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AStub-Class+U.S.+road+transport+articles")), ("topFutureKML", ("overall", "U.S.+road+articles+needing+KML%0D%0ATop-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")), ("highFutureKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AHigh-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")), ("midFutureKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AMid-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")), ("lowFutureKML", ("overall", "U.S.+road+articles+needing+KML%0D%0ALow-importance+U.S.+road+transport+articles%0D%0AFuture-Class+U.S.+road+transport+articles")), ("FutureKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AFuture-Class+U.S.+road+transport+articles")), ("topKML", ("overall", "U.S.+road+articles+needing+KML%0D%0ATop-importance+U.S.+road+transport+articles")), ("highKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AHigh-importance+U.S.+road+transport+articles")), ("midKML", ("overall", "U.S.+road+articles+needing+KML%0D%0AMid-importance+U.S.+road+transport+articles")), ("lowKML", ("overall", "U.S.+road+articles+needing+KML%0D%0ALow-importance+U.S.+road+transport+articles")), ("KML", ("overall", "U.S.+road+articles+needing+KML")) )

cells = {} status = {"map": [], "kml": [], "overall": []} maps = 0 kml = 0 both = 0 done = 0

for k,v in paths: print "Retrieving stat {0}.".format(k) response = urllib.urlopen("https://tools.wmflabs.org/quick-intersection/index.php?lang=en&project=wikipedia&ns=1&depth=12&max=30000&start=0&format=json&callback=&cats=" + v[1]) if response.getcode == 200: content = response.readline data = json.loads(content) count = data["pagecount"] cells[k] = count status[v[0]].append(count) else: raise IOError

for i in range(len(status["map"])): m = status["map"][i] k = status["kml"][i] if m > 0: maps += 1 if k > 0: both += 1 kml += 1 elif k > 0: kml += 1 else: done += 1

cells["done"] = done cells["map"] = maps cells["kml"] = kml cells["both"] = both

from datetime import date cells["date"] = date.today.isoformat

site = wikipedia.getSite("en","wikipedia") page = wikipedia.Page(site,"User:Happy5214/Map and KML Tables") content = page.get

import re def countrepl(matchobj): return u"|" + matchobj.group(1) + u"=" + unicode(cells[matchobj.group(1)])

newcontent = re.sub(r'\|(\w+)\=(\d{4}-\d{2}-\d{2}|\d+)', countrepl, content) page.put(newcontent, u"Update")