All pastes #214602 Raw Edit

don

public python v1 · immutable
#214602 ·published 2006-10-22 03:03 UTC
rendered paste body
# ColorMe - Changes the colors of fonts in MC360# Made by Donno for MC360import xbmcgui, re, xbmcfrom os import path, listdirfilepath = "Q:\\Skin\\Blackbolt Classic\\PAL\\includes.xml"filepathCT = "Q:\\Skin\\Blackbolt Classic\\ColorThemes\\"rs = '<include name="%s"><%s>%s</%s></include> <!--'def fileopen(f):    fs = open(f,"r")    data = fs.read()    fs.close()    return datadef WriteFile(f,data):    fs = open(f,"w")    fs.write(data)    fs.close()def ReadColorSettings(fp,data):    configdata = fileopen(fp)    configdata = configdata.split("\n")    for i in configdata:        cfd = i.split("=")        if len(cfd) == 3:            data = changeItem(data,cfd[0],cfd[1],cfd[2])    return datadef Default(data):    data = changeItem(data,"shadow-black","FF000000","shadowcolor")    data = changeItem(data,"textcolor-white","DDFFFFFF","textcolor")    data = changeItem(data,"textcolor-white2","D0FFFFFF","textcolor2")    data = changeItem(data,"textcolor-black","FF000000","textcolor")    data = changeItem(data,"textcolor-yellow","FFE7FF00","textcolor")    data = changeItem(data,"textcolor-green","FF9FCA4F","textcolor")    data = changeItem(data,"textcolor-green2","FF80C234","textcolor")    data = changeItem(data,"textcolor-selected","FF9FCA4F","selectedcolor")    data = changeItem(data,"textcolor-selected2","FF9FCA4F","selectedcolor2")    data = changeItem(data,"textcolor-spincontrol","FFE7FF00","spincolor")    data = changeItem(data,"textcolor-rsstitle","FF9FCA4F","titlecolor")    data = changeItem(data,"textcolor-rssheadline","FF80C234","headlinecolor")    return datadef Moonlight(data):    data = changeItem(data,"textcolor-yellow","FF00eaff","textcolor")    data = changeItem(data,"textcolor-green","FF4fbaca","textcolor")    data = changeItem(data,"textcolor-green2","FF34a9c2","textcolor")    data = changeItem(data,"textcolor-selected","FF34a9c2","selectedcolor")    data = changeItem(data,"textcolor-selected2","FF34a9c2","selectedcolor2")    data = changeItem(data,"textcolor-spincontrol","FF00eaff","spincolor")    data = changeItem(data,"textcolor-rsstitle","FF4fbaca","titlecolor")    data = changeItem(data,"textcolor-rssheadline","FF34a9c2","headlinecolor")    return datadef Inferno(data):    data = changeItem(data,"textcolor-yellow","FF00eaff","textcolor")    data = changeItem(data,"textcolor-green","FF4fbaca","textcolor")    data = changeItem(data,"textcolor-green2","FF34a9c2","textcolor")    data = changeItem(data,"textcolor-selected","FF34a9c2","selectedcolor")    data = changeItem(data,"textcolor-selected2","FF34a9c2","selectedcolor2")    data = changeItem(data,"textcolor-spincontrol","FF00eaff","spincolor")    data = changeItem(data,"textcolor-rsstitle","FF4fbaca","titlecolor")    data = changeItem(data,"textcolor-rssheadline","FF34a9c2","headlinecolor")    return datadef changeItem(data,item,newcolor,type):    rsm = rs % (item,type,"(.*)",type)    newstr = rs % (item,type,newcolor,type)    data = re.compile(rsm, re.IGNORECASE).sub( newstr, data)    #t = re.compile(rsm, re.IGNORECASE).findall(data) # For reading    return datadef CTList(optionlist):    if path.exists(filepathCT):        ctlist = listdir(filepathCT)        for x in ctlist:            if x[-4:] == ".cof":                optionlist.append(x[:-4])        return optionlist    return optionlistdef DoStuff(dat):    optionlist = ["*Read From File*","Default","Moonlight","Inferno"]    optionlist = CTList(optionlist)    test = xbmcgui.Dialog().select("Select Font Color",optionlist)    if test == 0:        fn = xbmcgui.Dialog().browse(1,"Browse for color config","files")        if fn[-4:] == ".cof" and path.exists(fn):            dat = ReadColorSettings(fn,dat)        else:            xbmcgui.Dialog().ok("MC360","Color remains unchanged")            return None    elif test == 1:        dat = Default(dat)     # << will set back to defaults    elif test == 2:        dat = Moonlight(dat)    elif test == 3:        dat = Inferno(dat)    elif test > 3:        dat = ReadColorSettings(filepathCT+optionlist[test]+".cof",dat)    return datdef main():    if path.exists(filepath):        dat = fileopen(filepath)    # loads in the file        dat = DoStuff(dat)          # Do your thing (show window etc)        if dat == None:            return        WriteFile(filepath,dat)        xbmcgui.Dialog().ok("Blackbolt Classic","Text Colors Changed","Skin will be reloaded after OK")        xbmc.executebuiltin('XBMC.ReloadSkin()')main()