コード例 #1
0
ファイル: pages.py プロジェクト: pombredanne/anacrolix
def recent_deaths(outfile, context):
    doc = outfile
    limits = (0, 200)
    world = context.get_selected_world()
    try:
        minlevel = int(context.get_query("minlevel"))
    except (ValueError, TypeError):
        minlevel = 45
    with doc.open_tag("form", attrs={"method": "get"}):
        doc.write("World:")
        world_select(doc, world, onchange=False)
        doc.write("Min Level:")
        doc.add_tag("input", attrs={"type": "text", "name": "minlevel", "value": minlevel, "maxlength": "3", "size": "3"})
        doc.add_tag("input", attrs={"type": "submit", "value": "Apply Filter"})
    with stattab_table_tag(doc.open_tag):
        with doc.open_tag("tr"):
            for a in ("Time", "Deceased", "Level", "Guild", "Killer", "Accomplices"):
                doc.add_tag("th", a)
            if not world:
                doc.add_tag("th", "World")
        killsIter = dbiface.get_last_deaths(limits, world=world, minlevel=minlevel)
        currentDeath = killsIter.next()
        killsEnded = False
        rowsMade = 0
        rowClass = stattab_row_class()
        while not killsEnded and rowsMade < 30:
            with doc.open_tag("tr", attrs={"class": rowClass.next()}):
                doc.add_tag("td", human_time_diff(currentDeath["stamp"]))
                doc.add_tag("td", char_link(currentDeath["victim"]))
                doc.add_tag("td", currentDeath["level"])
                doc.add_tag("td", context.guild_link(currentDeath["guild"]))
                def make_killer(kill):
                    if kill["isplayer"]:
                        s = char_link(kill["killer"])
                    else:
                        s = kill["killer"]
                    return s
                data = [make_killer(currentDeath)]
                while True:
                    try:
                        nextKill = killsIter.next()
                    except StopIteration:
                        killsEnded = True
                        break
                    if (nextKill["stamp"], nextKill["victim"]) == (currentDeath["stamp"], currentDeath["victim"]):
                        a = make_killer(nextKill)
                        if nextKill["lasthit"]:
                            data.insert(0, a)
                        else:
                            data.append(a)
                    else:
                        #currentDeath = nextKill
                        nextDeath = nextKill
                        break
                doc.add_tag("td", data[0])
                doc.add_tag("td", ", ".join(data[1:]))
                if not world:
                    doc.add_tag("td", currentDeath["world"])
            rowsMade += 1
            currentDeath = nextDeath
コード例 #2
0
ファイル: __pages.py プロジェクト: herasrobert/archive
def recent_deaths(context):
    doc = context.htmldoc
    limits = (0, 100)
    with doc.open_tag("table"):
        with doc.open_tag("tr"):
            for a in ("Time", "Deceased", "Level", "Killer", "Accomplices"):
                doc.add_tag("th", a)
        killsIter = dbiface.get_last_deaths(limits)
        currentDeath = killsIter.next()
        killsEnded = False
        while not killsEnded:
            with doc.open_tag("tr"):
                doc.add_tag("td", currentDeath["stamp"])
                doc.add_tag("td", char_link(currentDeath["victim"]))
                doc.add_tag("td", currentDeath["level"])

                def make_killer(kill):
                    if kill["isplayer"]:
                        s = char_link(kill["killer"])
                    else:
                        s = kill["killer"]
                    return s

                data = [make_killer(currentDeath)]
                while True:
                    try:
                        nextKill = killsIter.next()
                    except StopIteration:
                        killsEnded = True
                        break
                    if (nextKill["stamp"],
                            nextKill["victim"]) == (currentDeath["stamp"],
                                                    currentDeath["victim"]):
                        a = make_killer(nextKill)
                        if nextKill["lasthit"]:
                            data.insert(0, a)
                        else:
                            data.append(a)
                    else:
                        currentDeath = nextKill
                        break
                doc.add_tag("td", data[0])
                doc.add_tag("td", ", ".join(data[1:]))
コード例 #3
0
ファイル: __pages.py プロジェクト: pombredanne/anacrolix
def recent_deaths(context):
    doc = context.htmldoc
    limits = (0, 100)
    with doc.open_tag("table"):
        with doc.open_tag("tr"):
            for a in ("Time", "Deceased", "Level", "Killer", "Accomplices"):
                doc.add_tag("th", a)
        killsIter = dbiface.get_last_deaths(limits)
        currentDeath = killsIter.next()
        killsEnded = False
        while not killsEnded:
            with doc.open_tag("tr"):
                doc.add_tag("td", currentDeath["stamp"])
                doc.add_tag("td", char_link(currentDeath["victim"]))
                doc.add_tag("td", currentDeath["level"])
                def make_killer(kill):
                    if kill["isplayer"]:
                        s = char_link(kill["killer"])
                    else:
                        s = kill["killer"]
                    return s
                data = [make_killer(currentDeath)]
                while True:
                    try:
                        nextKill = killsIter.next()
                    except StopIteration:
                        killsEnded = True
                        break
                    if (nextKill["stamp"], nextKill["victim"]) == (currentDeath["stamp"], currentDeath["victim"]):
                        a = make_killer(nextKill)
                        if nextKill["lasthit"]:
                            data.insert(0, a)
                        else:
                            data.append(a)
                    else:
                        currentDeath = nextKill
                        break
                doc.add_tag("td", data[0])
                doc.add_tag("td", ", ".join(data[1:]))
コード例 #4
0
ファイル: pages.py プロジェクト: herasrobert/archive
def recent_deaths(outfile, context):
    doc = outfile
    limits = (0, 200)
    world = context.get_selected_world()
    try:
        minlevel = int(context.get_query("minlevel"))
    except (ValueError, TypeError):
        minlevel = 45
    with doc.open_tag("form", attrs={"method": "get"}):
        doc.write("World:")
        world_select(doc, world, onchange=False)
        doc.write("Min Level:")
        doc.add_tag("input",
                    attrs={
                        "type": "text",
                        "name": "minlevel",
                        "value": minlevel,
                        "maxlength": "3",
                        "size": "3"
                    })
        doc.add_tag("input", attrs={"type": "submit", "value": "Apply Filter"})
    with stattab_table_tag(doc.open_tag):
        with doc.open_tag("tr"):
            for a in ("Time", "Deceased", "Level", "Guild", "Killer",
                      "Accomplices"):
                doc.add_tag("th", a)
            if not world:
                doc.add_tag("th", "World")
        killsIter = dbiface.get_last_deaths(limits,
                                            world=world,
                                            minlevel=minlevel)
        currentDeath = killsIter.next()
        killsEnded = False
        rowsMade = 0
        rowClass = stattab_row_class()
        while not killsEnded and rowsMade < 30:
            with doc.open_tag("tr", attrs={"class": rowClass.next()}):
                doc.add_tag("td", human_time_diff(currentDeath["stamp"]))
                doc.add_tag("td", char_link(currentDeath["victim"]))
                doc.add_tag("td", currentDeath["level"])
                doc.add_tag("td", context.guild_link(currentDeath["guild"]))

                def make_killer(kill):
                    if kill["isplayer"]:
                        s = char_link(kill["killer"])
                    else:
                        s = kill["killer"]
                    return s

                data = [make_killer(currentDeath)]
                while True:
                    try:
                        nextKill = killsIter.next()
                    except StopIteration:
                        killsEnded = True
                        break
                    if (nextKill["stamp"],
                            nextKill["victim"]) == (currentDeath["stamp"],
                                                    currentDeath["victim"]):
                        a = make_killer(nextKill)
                        if nextKill["lasthit"]:
                            data.insert(0, a)
                        else:
                            data.append(a)
                    else:
                        #currentDeath = nextKill
                        nextDeath = nextKill
                        break
                doc.add_tag("td", data[0])
                doc.add_tag("td", ", ".join(data[1:]))
                if not world:
                    doc.add_tag("td", currentDeath["world"])
            rowsMade += 1
            currentDeath = nextDeath