1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

flake8 for htmllib2

This commit is contained in:
Shlomi Fish 2018-02-19 18:58:43 +02:00
parent 2c1228fc95
commit 472c0f935a
2 changed files with 36 additions and 15 deletions

View file

@ -150,12 +150,15 @@ class HTMLParser(html_parser.HTMLParser):
# --------- Top level elememts
def start_html(self, attrs): pass
def end_html(self): pass
def start_head(self, attrs): pass
def end_head(self): pass
def start_body(self, attrs): pass
def end_body(self): pass
# ------ Head elements
@ -288,7 +291,8 @@ class HTMLParser(html_parser.HTMLParser):
self.list_stack.append(['ul', '*', 0])
def end_ul(self):
if self.list_stack: del self.list_stack[-1]
if self.list_stack:
del self.list_stack[-1]
self.formatter.end_paragraph(not self.list_stack)
self.formatter.pop_margin()
@ -307,12 +311,14 @@ class HTMLParser(html_parser.HTMLParser):
label = '1.'
for a, v in attrs:
if a == 'type':
if len(v) == 1: v = v + '.'
if len(v) == 1:
v += '.'
label = v
self.list_stack.append(['ol', label, 0])
def end_ol(self):
if self.list_stack: del self.list_stack[-1]
if self.list_stack:
del self.list_stack[-1]
self.formatter.end_paragraph(not self.list_stack)
self.formatter.pop_margin()
@ -334,7 +340,8 @@ class HTMLParser(html_parser.HTMLParser):
def end_dl(self):
self.ddpop(1)
if self.list_stack: del self.list_stack[-1]
if self.list_stack:
del self.list_stack[-1]
def do_dt(self, attrs):
self.ddpop()
@ -356,40 +363,50 @@ class HTMLParser(html_parser.HTMLParser):
# Idiomatic Elements
def start_cite(self, attrs): self.start_i(attrs)
def end_cite(self): self.end_i()
def start_code(self, attrs): self.start_tt(attrs)
def end_code(self): self.end_tt()
def start_em(self, attrs): self.start_i(attrs)
def end_em(self): self.end_i()
def start_kbd(self, attrs): self.start_tt(attrs)
def end_kbd(self): self.end_tt()
def start_samp(self, attrs): self.start_tt(attrs)
def end_samp(self): self.end_tt()
def start_strong(self, attrs): self.start_b(attrs)
def end_strong(self): self.end_b()
def start_var(self, attrs): self.start_i(attrs)
def end_var(self): self.end_i()
# Typographic Elements
def start_i(self, attrs):
self.formatter.push_font((AS_IS, 1, AS_IS, AS_IS))
def end_i(self):
self.formatter.pop_font()
def start_b(self, attrs):
self.formatter.push_font((AS_IS, AS_IS, 1, AS_IS))
def end_b(self):
self.formatter.pop_font()
def start_tt(self, attrs):
self.formatter.push_font((AS_IS, AS_IS, AS_IS, 1))
def end_tt(self):
self.formatter.pop_font()
@ -439,11 +456,15 @@ class HTMLParser(html_parser.HTMLParser):
if attrname == 'src':
src = value
if attrname == 'width':
try: width = int(value)
except ValueError: pass
try:
width = int(value)
except ValueError:
pass
if attrname == 'height':
try: height = int(value)
except ValueError: pass
try:
height = int(value)
except ValueError:
pass
self.handle_image(src, alt, ismap, align, width, height)
# --- Really Old Unofficial Deprecated Stuff
@ -462,7 +483,8 @@ class HTMLParser(html_parser.HTMLParser):
def test(args=None):
import sys, formatter
import sys
import formatter
if not args:
args = sys.argv[1:]

View file

@ -17,7 +17,6 @@ my %skip = (
pysollib/games/mahjongg/__init__.py
pysollib/games/special/__init__.py
pysollib/games/ultra/__init__.py
pysollib/htmllib2.py
pysollib/mfxutil.py
pysollib/pysoltk.py
pysollib/tile/ttk.py