def showmatches(self): """Converts the results to html code and returns that. Is not capable of handling an empty self.matches list of matches.""" if not self.matches: raise ValueError, "self.matches must be non-empty list of re match opbjects" index = -1 # number of current match that's being printed html = [] html.append("""<table cellpadding="0" cellspacing="0"><tr><td bgcolor="#F8F8F8"><font color="#777777">""") # load match layout templates starttemplate = settings.get(STARTTEMPLATE, """<font color="#%%(%s)s"><b>(</b></font>""" % GROUPCOLOR) endtemplate = settings.get(ENDTEMPLATE, """<font color="#%%(%s)s"><b>)<font size="0">%%(%s)s</font></b></font>""" % (GROUPCOLOR, GROUPNUMBER)) matchtemplate = settings.get(MATCHTEMPLATE, """<font color="#000000"><b><u><b><font size="0">%%(%s)s:</font></b></u>%%(%s)s</b></font>""" % (MATCHINDEX, FORMATTEDMATCH)) # loop through matches and create output for match in self.matches: index += 1 # determine what part of the string we're looking at if index>0: prevmatchend = self.matches[index-1].end() else: prevmatchend = 0 if index+1 < len(self.matches): nextmatchstart = self.matches[index+1].start() else: nextmatchstart = -1 # append piece in between matches html.append(self.htmlize(match.string[prevmatchend:match.start()])) # append current match #html.append(self.htmlize(match.string[match.start():match.end()])) html.append(self.formatmatch(match, index, matchtemplate, starttemplate, endtemplate)) # append end piece if necessary if index+1 >= len(self.matches): # if last match, print rest of string html.append(self.htmlize(match.string[match.end():])) html.append("""</font></td></tr></table>""") res = "".join(html) return res
def showmatches(self): """Converts the results to html code and returns that. Is not capable of handling an empty self.matches list of matches.""" if not self.matches: raise ValueError("self.matches must be non-empty list of re match opbjects") index = -1 # number of current match that's being printed html = [] html.append("""<table cellpadding="0" cellspacing="0"><tr><td bgcolor="#F8F8F8"><font color="#777777">""") # load match layout templates starttemplate = settings.get(STARTTEMPLATE, """<font color="#%%(%s)s"><b>(</b></font>""" % GROUPCOLOR) endtemplate = settings.get(ENDTEMPLATE, """<font color="#%%(%s)s"><b>)<font size="0">%%(%s)s</font></b></font>""" % (GROUPCOLOR, GROUPNUMBER)) matchtemplate = settings.get(MATCHTEMPLATE, """<font color="#000000"><b><u><b><font size="0">%%(%s)s:</font></b></u>%%(%s)s</b></font>""" % (MATCHINDEX, FORMATTEDMATCH)) # loop through matches and create output for match in self.matches: index += 1 # determine what part of the string we're looking at if index>0: prevmatchend = self.matches[index-1].end() else: prevmatchend = 0 if index+1 < len(self.matches): nextmatchstart = self.matches[index+1].start() else: nextmatchstart = -1 # append piece in between matches html.append(self.htmlize(match.string[prevmatchend:match.start()])) # append current match #html.append(self.htmlize(match.string[match.start():match.end()])) html.append(self.formatmatch(match, index, matchtemplate, starttemplate, endtemplate)) # append end piece if necessary if index+1 >= len(self.matches): # if last match, print rest of string html.append(self.htmlize(match.string[match.end():])) html.append("""</font></td></tr></table>""") res = "".join(html) return res
def onStart(self, event): if self.choice2.GetSelection() == wx.NOT_FOUND: return if self.choice3.GetSelection() == wx.NOT_FOUND: return p1 = int(self.choice2.GetStringSelection().split(" -")[0]) p2 = int(self.choice3.GetStringSelection().split(" -")[0]) # print p1, p2 #select t1.p, "del" as type from (SELECT path as p FROM files where variant_id = 45) as t1 left join (SELECT path as p FROM files where variant_id = 56) as t2 on t1.p=t2.p where t2.p is null # t = time.time() app.pf.PushStatusText(u"Сравнение данных...") v1 = {} c = self.conn.cursor() for r in c.execute( """select path, size, mtime from files where variant_id = ?""", (p1, )): v1[r[0]] = (r[1], r[2], "del") print len(v1) for r in c.execute( """select path, size, mtime from files where variant_id = ?""", (p2, )): if v1.has_key(r[0]): if v1[r[0]][0] == r[1] and round(v1[r[0]][1]) == round(r[2]): #такой элемент существовал раньше - не изменился, удаляем del v1[r[0]] else: v1[r[0]] = (r[1], r[2], "chg") else: v1[r[0]] = (r[1], r[2], "new") html = ["<HTML><BODY><TABLE>"] skeys = v1.keys() skeys.sort() for r in skeys: # не буюем показывать лишнее if r.find(".tmp") >= 0: continue if r.find(".lnk") >= 0: continue if r.find("Thumbs.db") >= 0: continue if r.find("~$") >= 0: continue if v1[r][2] == "del": html.append("<TR><TD>" + v1[r][2] + "</TD><TD>" + r + "</TD></TR>") elif v1[r][2] == "new": html.append("<TR><TD><b>" + v1[r][2] + "</b></TD><TD><b> <a href=\"" + r + "\"> " + r + "</a></b></TD></TR>") else: html.append("<TR><TD>" + v1[r][2] + "</TD><TD> <a href=\"" + r + "\"> " + r + "</a></TD></TR>") html.append("</BODY></HTML>") self.htmlWin.SetPage("".join(html)) print len(v1) app.pf.PushStatusText( u"Найдено файлов: %i." % (len(v1), ) + "Сравнеие выполнено за " + time.strftime("%M:%S", time.localtime(time.time() - t))) event.Skip()
def create_brief(self, html, index): pyspec_aspect = self.find_aspect("pyspec") if not self.defined_here(): return index else: if index is not None: name = ["method", ["a", {"href":"#%d" % (index+1)}, ["tt", self.name()]]] self.index = index + 1 return self.index else: name = ["method", ["tt", self.name()]] html.append(["tr", ["td"] + name, ["td", pyspec_aspect.short_description()]])
def create_brief(self, html, index): pyspec_aspect = self.find_aspect("pyspec") if not self.defined_here(): return index else: if isinstance(self.target(), object): classtype = "class" else: classtype = "old style class" html.append(["tr", ["td", ["font", {"size":3, "color":"blue"}, classtype], ["a", {"href":"#%d" % (index+1)}, ["tt", self.name()]]], ["td", pyspec_aspect.short_description()]]) self.index = index + 1 return index + 1
def create_brief(self, html, index): pyspec_aspect = self.find_aspect("pyspec") if not self.defined_here(): return index else: if index is not None: name = [ "method", ["a", { "href": "#%d" % (index + 1) }, ["tt", self.name()]] ] self.index = index + 1 return self.index else: name = ["method", ["tt", self.name()]] html.append([ "tr", ["td"] + name, ["td", pyspec_aspect.short_description()] ])
def create_description(self, html): if not self.defined_here(): return pyspec_aspect = self.find_aspect("pyspec") methodtype = "" if type(self.target()) is types.MethodType: methodtype = "method" else: methodtype = "function" args = inspect.getargspec(self.target()) argspec = inspect.formatargspec(*args) html.append(["hr"]) html.append([ "a", { "name": str(self.index) }, ["font", { "size": 3, "color": "blue" }, methodtype], ["font", { "size": 3 }, ["b", "%s%s" % (self.name(), argspec)]] ]) description = pyspec_aspect.description() if description is not None: html.append(["p", pyspec_aspect.description()])
def create_description(self, html, index): if not self.defined_here(): return index html.append(["hr"]) if isinstance(self.target(), object): html.append(["h4", "class %s" % self.name()]) else: html.append(["h4", "old style class %s" % self.name()]) method_table = ["table", {"border":1, "cellpadding":3, "cellspacing":0, "width":"100%"}] for method in self.methods(sort=True): method.create_brief(method_table, None) html.append(method_table) return index
def create_brief(self, html, index): pyspec_aspect = self.find_aspect("pyspec") if not self.defined_here(): return index else: if isinstance(self.target(), object): classtype = "class" else: classtype = "old style class" html.append([ "tr", [ "td", ["font", { "size": 3, "color": "blue" }, classtype], ["a", { "href": "#%d" % (index + 1) }, ["tt", self.name()]] ], ["td", pyspec_aspect.short_description()] ]) self.index = index + 1 return index + 1
def create_description(self, html, index): if not self.defined_here(): return index html.append(["hr"]) if isinstance(self.target(), object): html.append(["h4", "class %s" % self.name()]) else: html.append(["h4", "old style class %s" % self.name()]) method_table = [ "table", { "border": 1, "cellpadding": 3, "cellspacing": 0, "width": "100%" } ] for method in self.methods(sort=True): method.create_brief(method_table, None) html.append(method_table) return index
def create_description(self, html): if not self.defined_here(): return pyspec_aspect = self.find_aspect("pyspec") methodtype = "" if type(self.target()) is types.MethodType: methodtype = "method" else: methodtype = "function" args = inspect.getargspec(self.target()) argspec = inspect.formatargspec(*args) html.append(["hr"]) html.append(["a", {"name": str(self.index)}, ["font", {"size":3, "color":"blue"}, methodtype], ["font", {"size":3}, ["b", "%s%s" % (self.name(), argspec)]]]) description = pyspec_aspect.description() if description is not None: html.append(["p", pyspec_aspect.description()])
def SetCard(self, cdid): """Show a faceup card.""" if self.previewCard == cdid: return self.previewCard = cdid self.oglCanvas.SetCard(cdid) try: card = database.get()[cdid] except KeyError: print cdid return # HTML card text html = ['<html><body bgcolor="#ffffa0"><center>'] html.append('<font size="+1"><b>%s</b></font>' % card.name) # Everything has a name. try: html.append('<br>%s' % typeNames[card.type]) except KeyError: pass if card.type in ('personality', 'follower', 'item'): # Force and chi. html.append('<br>Force: <b>%s</b> Chi: <b>%s</b>' % (card.force, card.chi)) elif card.type == 'holding' and card.gold_production != '': html.append('<br>Gold Production: <b>%s</b>' % card.gold_production) if card.type == 'personality': # Gold cost, honor req, phonor. html.append('<br>HR: <b>%s</b> GC: <b>%s</b> PH: <b>%s</b>' % (card.honor_req, card.cost, card.personal_honor)) elif card.type == 'follower': # Gold cost, honor req. html.append('<br>HR: <b>%s</b> GC: <b>%s</b>' % (card.honor_req, card.cost)) elif card.type == 'stronghold': # Production, honor, etc. html.append('<br>Province Strength: <b>%s</b><br>Gold Production: <b>%s</b><br>Starting Honor: <b>%s</b>' % \ (card.province_strength, card.gold_production, card.starting_honor)) elif card.hasGoldCost(): # Gold cost. html.append('<br>Gold Cost: <b>%s</b>' % card.cost) textArr = [] for text in card.text.split("<br>"): textArr.append('<p>%s</p>' % text) textArr.append('<p><font size="-1"><i>%s</i></font></p>' % card.flavor) cardText = '<hr><font size="-1">%s</font><hr>' % ('\n'.join(textArr)) html.append(cardText) if card.isFate(): html.append('<br>Focus Value: <b>%s</b>' % card.focus) html.append('<br><font size="-1">Legal in <b>%s</b></font>' % ', '.join(card.legal)) if card.id[0] == '_': html.append('<br><font size="-1">Created card</font>') else: html.append('<br><font size="-1">%s</font>' % card.id) if card.rarity != "": html.append('<img src=\'' + locationsettings.data_dir + '/' + 'images/rarity_%s.png\' />' % card.rarity) if card.artist != "": html.append('<br><font size="-1">Artist: %s</font>' % card.artist) #rarity flavor and artist to go in. html.append('</center></body></html>') self.cardText.SetPage('\n'.join(html)) self.cardText.Refresh() # Rulings try: if card.rulings: self.EnableRulings() txt = '\n'.join('* ' + ruling for ruling in card.rulings) self.cardRulings.SetValue(txt) else: self.EnableRulings(False) except AttributeError: self.EnableRulings(False) self.Layout()
def make_html_waiting_page(subtest_name, index, len_subtests): html = ['<html><H2 align=center>Waiting for Subtest to Complete</H2>'] html.append('<H3 align=center>Test Name: %s</H3>' % subtest_name) html.append('<H4 align=center>Test %d of %d</H4></html>' % (index + 1, len_subtests)) return '\n'.join(html)