From: Fredrik Tolf Date: Sat, 28 Dec 2013 05:37:03 +0000 (+0100) Subject: Merge branch 'master' into python3 X-Git-Url: http://dolda2000.com/gitweb/?p=wrw.git;a=commitdiff_plain;h=cb66c33fdb75345266af29fc4063bf833100cca5 Merge branch 'master' into python3 Conflicts: wrw/sp/util.py --- cb66c33fdb75345266af29fc4063bf833100cca5 diff --cc wrw/sp/util.py index e7d9c29,02f61f0..5138f17 --- a/wrw/sp/util.py +++ b/wrw/sp/util.py @@@ -156,8 -149,18 +149,18 @@@ class formatter(object) self.start(el) elif ev == "$": self.end(el) + - def next(self): ++ def __next__(self): + if self.src is None: + raise StopIteration() + try: + ev, el = next(self.src) + except StopIteration: + self.src = None + ev, el = "$", None + self.handle(ev, el) - ret = str(self.buf) - self.buf[:] = "" + ret = bytes(self.buf) + self.buf[:] = b"" return ret def nsname(self, el): @@@ -225,9 -228,10 +228,10 @@@ class indenter(formatter) self.atbreak = True self.inline = False self.stack = [] + self.last = None, None def write(self, text): - lines = text.split(u"\n") + lines = text.split("\n") if len(lines) > 1: for ln in lines[:-1]: self.buf.extend(ln.encode(self.charset)) @@@ -283,6 -290,10 +290,10 @@@ def end(self, el): self.br() + def handle(self, ev, el): - super(indenter, self).handle(ev, el) ++ super().handle(ev, el) + self.last = ev, el + class textindenter(indenter): maxcol = 70 diff --cc wrw/sp/xhtml.py index 73872b4,a2c1eb1..eb82f57 --- a/wrw/sp/xhtml.py +++ b/wrw/sp/xhtml.py @@@ -38,13 -38,13 +38,13 @@@ def head(title=None, css=None) return head class htmlformatter(util.formatter): - allowshort = set([u"br", u"hr", u"img", u"input", u"meta", u"link"]) + allowshort = {"br", "hr", "img", "input", "meta", "link"} def shorttag(self, el): if el.name in self.allowshort: - super(htmlformatter, self).shorttag(el) + super().shorttag(el) else: - self.starttag(el) - self.endtag(el) + self.handle(">", el) + self.handle("<", el) class htmlindenter(util.textindenter, htmlformatter): pass