import sys
import os.path
import re

buttonFileName = 'Button/gpio-keys'
print "Checking " + buttonFileName
if os.path.isfile(buttonFileName):
    try:
        print "Setting proper permissions on " + buttonFileName
        os.chmod(buttonFileName, 0744)
    except:
        pass

apikeysFileName = 'Clock/ApiKeys.py'
wuapi_re = re.compile('\\s*wuapi\\s*=')
dsapi_re = re.compile('\\s*dsapi\\s*=')

print "Checking " + apikeysFileName
if (os.path.isfile(apikeysFileName)):
    altered = False
    foundds = False
    newfile = ''
    apikeys = open(apikeysFileName, "r")
    for aline in apikeys:
        if dsapi_re.match(aline):
            foundds = True
        if wuapi_re.match(aline):
            print "Removing wuapi key from " + apikeysFileName
            altered = True
        else:
            newfile += aline
    apikeys.close()

    if not foundds:
        print "This version of PiClock requires a DarkSky api key."
        print "https://darksky.net/dev"
        print "Enter your DarkSky api key."
        print "key:",
        k = sys.stdin.readline()
        k = k.strip()
        if len(k) > 1:
            newfile += "dsapi = '" + k + "'"
            altered = True

    if altered:
        print "Writing Updated " + apikeysFileName
        apikeys = open(apikeysFileName, "w")
        apikeys.write(newfile)
        apikeys.close()
    else:
        print "No changes made to " + apikeysFileName

    try:
        from rpi_ws281x import *    # NOQA
    except:
        print "NeoAmbi.py now uses rpi-ws281x/rpi-ws281x-python"
        print "Please install it as follows:"
        print "sudo pip install rpi_ws281x"

@@ -390,16 +390,98 @@
 i%5C%5Cs*=')
+%0Accapi_re = re.compile('%5C%5Cs*ccapi%5C%5Cs*=')%0Aowmapi_re = re.compile('%5C%5Cs*owmapi%5C%5Cs*=')
 %0A%0Aprint 
@@ -577,18 +577,39 @@
    found
-ds
+cc = False%0A    foundowm
  = False
@@ -704,18 +704,80 @@
      if 
-ds
+ccapi_re.match(aline):%0A            foundcc = True%0A        if owm
 api_re.m
@@ -806,18 +806,19 @@
    found
-ds
+wom
  = True%0A
@@ -933,32 +933,156 @@
  altered = True%0A
+        if dsapi_re.match(aline):%0A            print %22Removing dsapi key from %22 + apikeysFileName%0A            altered = True%0A
         else:%0A  
@@ -1145,18 +1145,35 @@
 ot found
-ds
+cc and not foundowm
 :%0A      
@@ -1216,23 +1216,25 @@
 uires a 
-DarkSky
+ClimaCell
  api key
@@ -1263,23 +1263,37 @@
 s://
-darksky.net/dev
+www.climacell.co/weather-api/
 %22%0A  
@@ -1320,15 +1320,17 @@
 our 
-DarkSky
+Climacell
  api
@@ -1460,18 +1460,18 @@
 ile += %22
-ds
+cc
 api = '%22

Change updater for new api key.