コード例 #1
0
def haslinkrel(htmlfile):
    p = "<link rel=stylesheet href="
    filedata = list("".join(u.readfile(htmlfile)).partition(p))
    if filedata[1] == "":
        return False
    else:
        return True
コード例 #2
0
def loadtables():
    a = u.readfile("/home/umar/yqltables")
    curls = [eval(x.replace("\n","")).items()
             for x in a if x.startswith("{") == True]
    strings = [x.replace("\n","")
               for x in a if x.startswith("{") != True]
    return [curls,strings]
コード例 #3
0
def quotesfile(qf):
    a = "".join(u.readfile(qf)[:-1]).split("\n\n")
    b = [x.split("\n") for x in a]
    for x in b:
        x.insert(-1,"--")
    c = ["".join(x) for x in b]
    return c
コード例 #4
0
def matchprojections(data,randomprojections,digitizations,
                     directory):
    labels = []
    for x in randomprojectiondigitizehash(data,
                                          randomprojections,
                                          digitizations):
        labels.append(u.readfile(directory+str(hash(x))))
    return labels
コード例 #5
0
def changelinkrel(htmlfile, cssfile):
    p = "<link rel=stylesheet href="
    original = list("".join(u.readfile(htmlfile)).partition(p))
    original.remove(p)
    firstpart = original[0]
    secondpart = list(original[1].partition(' type="text/css">'))[2:]
    final = "".join([firstpart, linkrel(cssfile), secondpart[0]])
    u.writefile("".join(final), htmlfile)
    print htmlfile + " written"
コード例 #6
0
def googlevideosearches():
    f = "".join(u.readfile("/home/umar/googlevideosearch"))
    parts = f.partition("\n\n") 
    sites = [x.split(",") for x in parts[0].split("\n")]
    searches = [x.split(",") for x in parts[2].split("\n")][:-1]
    for x in searches:
        for y in sites:
            if x[1] == y[1]:
                x[1] = y[0]
    a = [[[x[0],x[1]],x[2:]] for x in searches]
    return h.tabularize([
        h.newtabopen("".join(["http://www.google.com/search?q=",
                              "&".join([googlesitesearchvideo(x[0]),
                                        "tbm=vid",
                                        "tbs="+",".join([
        googlevideosearchattribute(y)
        for y in x[1]]),
                                        ])]),x[0][0])
        for x in a],2)
コード例 #7
0
def urlfiles():
    files =  [imagenetdir+x for x in os.listdir(imagenetdir)
            if x.endswith(".urls") == True]
    return [[x,len(u.readfile(x))] for x in files]
コード例 #8
0
def writelinkrel(htmlfile, cssfile):
    original = list("".join(u.readfile(htmlfile)).partition("<head>"))
    original.insert(2, linkrel(cssfile))
    u.writefile("".join(original), htmlfile)
    print htmlfile + " written"
コード例 #9
0
def reddits():
    return [[y[0],"".join(y[1:]).split(",")] for y in
            [x.split("\n") for x in
             "".join(u.readfile("/home/umar/reddits")).split("\n\n")]]