<commit_before>import os,sys
if sys.platform=="win32":
    os.environ['SDL_VIDEODRIVER']='windib'
import zlib
from core import pygame
import threading,time,urllib,urllib2
from zipfile import ZipFile,ZIP_DEFLATED
from pwvlib import *

ERROR_STR= """Error removing %(path)s, %(error)s """

def rmgeneric(path, __func__):
    try:
        __func__(path)
        print 'Removed ', path
    except OSError, (errno, strerror):
        print ERROR_STR % {'path' : path, 'error': strerror }
            
def removeall(path):
    if not os.path.isdir(path):
        return
    files=os.listdir(path)
    for x in files:
        fullpath=os.path.join(path, x)
        if os.path.isfile(fullpath):
            f=os.remove
            rmgeneric(fullpath, f)
        elif os.path.isdir(fullpath):
            removeall(fullpath)
            f=os.rmdir
            rmgeneric(fullpath, f)

import md5

from gui import *

def createfiles(dir="port"):
    for f in os.listdir("art/"+dir):
        if f == ".svn": continue
        if not os.path.isdir(f): continue
        myzip = ZipFile("zip_"+dir+"/"+f+".zip","w",ZIP_DEFLATED)
        for sub in os.listdir("art/"+dir+"/"+f):
            if sub == ".svn": continue
            myzip.write("art/"+dir+"/"+f+"/"+sub,sub)
        myzip.close()
        print "wrote","zips/"+f+".zip"
        
def create_path(dir):
    pathfull = ""
    for pathpart in dir.split("/"):
        pathfull+=pathpart+"/"
        if not os.path.exists(pathfull):
            os.mkdir(pathfull)
for required_path in ["art/3d","art/bg","art/ev","art/fg","art/general","art/port","music","games","fonts","sfx"]:
    create_path(required_path)

def mynames(dir="art/port"):
    files = {}
    for file in [x for x in os.listdir(dir) if x != ".svn"]:
        files[file] = get_data_from_folder(dir+"/"+file)
    return files

import cStringIO
iconcache = {}
def load_image(path):
    if path not in iconcache:
        f = urllib2.urlopen("http://pywright.dawnsoft.org/"+path)
        txt = f.read()
        f.close()
        f = cStringIO.StringIO(txt)
        icon = pygame.image.load(f,path)
        iconcache[path] = icon
    return iconcache[path]
        
def names(url):
    print "accessing","http://pywright.dawnsoft.org/"+url
    if 1:#try:
        f = urllib2.urlopen("http://pywright.dawnsoft.org/"+url)
    else:#except:
        print "fail"
        return {}
    lines = eval(f.read())
    f.close()
    files = {}
    for x in lines:
        if x["zipname"] in files:
            if compare_versions(x["version"],files[x["zipname"]]["version"])<0:
                continue
        files[x["zipname"]]=x
    return files

screen = pygame.display.set_mode([400,50])
root = widget()
root.width,root.height = [640,480]

Label = label
label = editbox(None,"Select content type to download:")
label.draw_back=False
root.add_child(label)
label.draw(screen)

list = scrollpane([0,0])
list.rpos[1]=100
list.width,list.height = [400,300]
list.status_box = editbox(None,"")
list.status_box.draw_back = False
list.status_box.draw(screen)
root.add_child(list)

def build_list(dir="art/port",url="zip_port_info",check_folder=None):
    list.children = [list.status_box,list.scbar]
    fnd = 0
    list.status_box.text="Scanning local files..."
    mn = mynames(dir)
    list.status_box.text="Fetching data from server..."
    an = names(url)
    if check_folder:
        d = get_data_from_folder(check_folder)
        mn = {}
        for n in an:
            mn[n] = d
    cases = {"NEW":[],"UPDATED":[],"INSTALLED":[]}
    for n in sorted(an.keys()):
        if n not in mn:
            status = "NEW"
        elif compare_versions(an[n]["version"],mn[n]["version"])>0:
            status = "UPDATED"
        else:
            status = "INSTALLED"
        fnd = 1
        cb = checkbox(an[n].get("title",an[n]["zipname"]))
        cb.name = n
        cb.file = an[n]["zipfile"]
        cb.filename = an[n]["zipname"]
        p = pane([0,0])
        p.width,p.height = [300,95]
        p.align = "horiz"
        image_b = button(None,"")
        image_b.background = False
        image_b.border = False
        image_b.click_down_over = cb.click_down_over
        def load_icon_this(url=an[n]["iconurl"],but=image_b):
            try:
                image = load_image(url)
            except:
                image = None
            but.graphic = image
        threading.Thread(target=load_icon_this).start()
        p.add_child(image_b)
        stats = pane([0,0])
        stats.width,stats.height = [250,93]
        stats.align = "vert"
        stats.background = False
        stats.border = False
        stats.add_child(cb)
        sline = status 
        if an[n].get("author",""):
            sline += "                    "+"by "+an[n]["author"]
        stats.add_child(Label(sline))
        if an[n].get("version_date",""):
            stats.add_child(Label("ver %s updated on %s"%(cver_s(an[n]["version"]),an[n]["version_date"])))<commit_msg>Bigger libupdate window<commit_after>import os,sys
if sys.platform=="win32":
    os.environ['SDL_VIDEODRIVER']='windib'
import zlib
from core import pygame
import threading,time,urllib,urllib2
from zipfile import ZipFile,ZIP_DEFLATED
from pwvlib import *

ERROR_STR= """Error removing %(path)s, %(error)s """

def rmgeneric(path, __func__):
    try:
        __func__(path)
        print 'Removed ', path
    except OSError, (errno, strerror):
        print ERROR_STR % {'path' : path, 'error': strerror }
            
def removeall(path):
    if not os.path.isdir(path):
        return
    files=os.listdir(path)
    for x in files:
        fullpath=os.path.join(path, x)
        if os.path.isfile(fullpath):
            f=os.remove
            rmgeneric(fullpath, f)
        elif os.path.isdir(fullpath):
            removeall(fullpath)
            f=os.rmdir
            rmgeneric(fullpath, f)

import md5

from gui import *

def createfiles(dir="port"):
    for f in os.listdir("art/"+dir):
        if f == ".svn": continue
        if not os.path.isdir(f): continue
        myzip = ZipFile("zip_"+dir+"/"+f+".zip","w",ZIP_DEFLATED)
        for sub in os.listdir("art/"+dir+"/"+f):
            if sub == ".svn": continue
            myzip.write("art/"+dir+"/"+f+"/"+sub,sub)
        myzip.close()
        print "wrote","zips/"+f+".zip"
        
def create_path(dir):
    pathfull = ""
    for pathpart in dir.split("/"):
        pathfull+=pathpart+"/"
        if not os.path.exists(pathfull):
            os.mkdir(pathfull)
for required_path in ["art/3d","art/bg","art/ev","art/fg","art/general","art/port","music","games","fonts","sfx"]:
    create_path(required_path)

def mynames(dir="art/port"):
    files = {}
    for file in [x for x in os.listdir(dir) if x != ".svn"]:
        files[file] = get_data_from_folder(dir+"/"+file)
    return files

import cStringIO
iconcache = {}
def load_image(path):
    if path not in iconcache:
        f = urllib2.urlopen("http://pywright.dawnsoft.org/"+path)
        txt = f.read()
        f.close()
        f = cStringIO.StringIO(txt)
        icon = pygame.image.load(f,path)
        iconcache[path] = icon
    return iconcache[path]
        
def names(url):
    print "accessing","http://pywright.dawnsoft.org/"+url
    if 1:#try:
        f = urllib2.urlopen("http://pywright.dawnsoft.org/"+url)
    else:#except:
        print "fail"
        return {}
    lines = eval(f.read())
    f.close()
    files = {}
    for x in lines:
        if x["zipname"] in files:
            if compare_versions(x["version"],files[x["zipname"]]["version"])<0:
                continue
        files[x["zipname"]]=x
    return files

screen = pygame.display.set_mode([400,50])
root = widget()
root.width,root.height = [640,480]

Label = label
label = editbox(None,"Select content type to download:")
label.draw_back=False
root.add_child(label)
label.draw(screen)

list = scrollpane([0,0])
list.rpos[1]=100
list.width,list.height = [400,300]
list.status_box = editbox(None,"")
list.status_box.draw_back = False
list.status_box.draw(screen)
root.add_child(list)

def build_list(dir="art/port",url="zip_port_info",check_folder=None):
    list.children = [list.status_box,list.scbar]
    fnd = 0
    list.status_box.text="Scanning local files..."
    mn = mynames(dir)
    list.status_box.text="Fetching data from server..."
    an = names(url)
    if check_folder:
        d = get_data_from_folder(check_folder)
        mn = {}
        for n in an:
            mn[n] = d
    cases = {"NEW":[],"UPDATED":[],"INSTALLED":[]}
    for n in sorted(an.keys()):
        if n not in mn:
            status = "NEW"
        elif compare_versions(an[n]["version"],mn[n]["version"])>0:
            status = "UPDATED"
        else:
            status = "INSTALLED"
        fnd = 1
        cb = checkbox(an[n].get("title",an[n]["zipname"]))
        cb.name = n
        cb.file = an[n]["zipfile"]
        cb.filename = an[n]["zipname"]
        p = pane([0,0])
        p.width,p.height = [380,95]
        p.align = "horiz"
        image_b = button(None,"")
        image_b.background = False
        image_b.border = False
        image_b.click_down_over = cb.click_down_over
        def load_icon_this(url=an[n]["iconurl"],but=image_b):
            try:
                image = load_image(url)
            except:
                image = None
            but.graphic = image
        threading.Thread(target=load_icon_this).start()
        p.add_child(image_b)
        stats = pane([0,0])
        stats.width,stats.height = [340,93]
        stats.align = "vert"
        stats.background = False
        stats.border = False
        stats.add_child(cb)
        sline = status 
        if an[n].get("author",""):
            sline += "                    "+"by "+an[n]["author"]
        stats.add_child(Label(sline))
        if an[n].get("version_date",""):
            stats.add_child(Label("ver %s updated on %s"%(cver_s(an[n]["version"]),an[n]["version_date"])))
{'fraction_non_alphanumeric': 0.15827627869512687, 'fraction_numerical': 0.00986709625453081, 'mean_word_length': 2.4405957741600277, 'pattern_counts': {'":': 12, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1629877', 'n_tokens_mistral': 3499, 'n_tokens_neox': 3418, 'n_words': 653}