Make PEP8 cleanup of line spaces and character distances as well as indents
This commit is contained in:
parent
7ff783fea1
commit
b278337172
189 changed files with 2039 additions and 1583 deletions
|
|
@ -30,48 +30,48 @@ class TextToHTMLparser(object):
|
|||
tabstop = 4
|
||||
# mapping html color name <-> ansi code.
|
||||
hilite = ANSI_HILITE
|
||||
unhilite = ANSI_UNHILITE # this will be stripped - there is no css equivalent.
|
||||
normal = ANSI_NORMAL # "
|
||||
unhilite = ANSI_UNHILITE # this will be stripped - there is no css equivalent.
|
||||
normal = ANSI_NORMAL # "
|
||||
underline = ANSI_UNDERLINE
|
||||
blink = ANSI_BLINK
|
||||
inverse = ANSI_INVERSE # this will produce an outline; no obvious css equivalent?
|
||||
colorcodes = [
|
||||
('color-000', unhilite + ANSI_BLACK), # pure black
|
||||
('color-001', unhilite + ANSI_RED),
|
||||
('color-002', unhilite + ANSI_GREEN),
|
||||
('color-003', unhilite + ANSI_YELLOW),
|
||||
('color-004', unhilite + ANSI_BLUE),
|
||||
('color-005', unhilite + ANSI_MAGENTA),
|
||||
('color-006', unhilite + ANSI_CYAN),
|
||||
('color-007', unhilite + ANSI_WHITE), # light grey
|
||||
('color-008', hilite + ANSI_BLACK), # dark grey
|
||||
('color-009', hilite + ANSI_RED),
|
||||
('color-010', hilite + ANSI_GREEN),
|
||||
('color-011', hilite + ANSI_YELLOW),
|
||||
('color-012', hilite + ANSI_BLUE),
|
||||
('color-013', hilite + ANSI_MAGENTA),
|
||||
('color-014', hilite + ANSI_CYAN),
|
||||
('color-015', hilite + ANSI_WHITE) # pure white
|
||||
] + [("color-%03i" % (i+16), XTERM256_FG % ("%i" % (i+16))) for i in xrange(240)]
|
||||
('color-000', unhilite + ANSI_BLACK), # pure black
|
||||
('color-001', unhilite + ANSI_RED),
|
||||
('color-002', unhilite + ANSI_GREEN),
|
||||
('color-003', unhilite + ANSI_YELLOW),
|
||||
('color-004', unhilite + ANSI_BLUE),
|
||||
('color-005', unhilite + ANSI_MAGENTA),
|
||||
('color-006', unhilite + ANSI_CYAN),
|
||||
('color-007', unhilite + ANSI_WHITE), # light grey
|
||||
('color-008', hilite + ANSI_BLACK), # dark grey
|
||||
('color-009', hilite + ANSI_RED),
|
||||
('color-010', hilite + ANSI_GREEN),
|
||||
('color-011', hilite + ANSI_YELLOW),
|
||||
('color-012', hilite + ANSI_BLUE),
|
||||
('color-013', hilite + ANSI_MAGENTA),
|
||||
('color-014', hilite + ANSI_CYAN),
|
||||
('color-015', hilite + ANSI_WHITE) # pure white
|
||||
] + [("color-%03i" % (i + 16), XTERM256_FG % ("%i" % (i + 16))) for i in xrange(240)]
|
||||
|
||||
colorback = [
|
||||
('bgcolor-000', ANSI_BACK_BLACK), # pure black
|
||||
('bgcolor-001', ANSI_BACK_RED),
|
||||
('bgcolor-002', ANSI_BACK_GREEN),
|
||||
('bgcolor-003', ANSI_BACK_YELLOW),
|
||||
('bgcolor-004', ANSI_BACK_BLUE),
|
||||
('bgcolor-005', ANSI_BACK_MAGENTA),
|
||||
('bgcolor-006', ANSI_BACK_CYAN),
|
||||
('bgcolor-007', ANSI_BACK_WHITE), # light grey
|
||||
('bgcolor-008', hilite + ANSI_BACK_BLACK), # dark grey
|
||||
('bgcolor-009', hilite + ANSI_BACK_RED),
|
||||
('bgcolor-010', hilite + ANSI_BACK_GREEN),
|
||||
('bgcolor-011', hilite + ANSI_BACK_YELLOW),
|
||||
('bgcolor-012', hilite + ANSI_BACK_BLUE),
|
||||
('bgcolor-013', hilite + ANSI_BACK_MAGENTA),
|
||||
('bgcolor-014', hilite + ANSI_BACK_CYAN),
|
||||
('bgcolor-015', hilite + ANSI_BACK_WHITE), # pure white
|
||||
] + [("bgcolor-%03i" % (i+16), XTERM256_BG % ("%i" % (i+16))) for i in range(240)]
|
||||
('bgcolor-000', ANSI_BACK_BLACK), # pure black
|
||||
('bgcolor-001', ANSI_BACK_RED),
|
||||
('bgcolor-002', ANSI_BACK_GREEN),
|
||||
('bgcolor-003', ANSI_BACK_YELLOW),
|
||||
('bgcolor-004', ANSI_BACK_BLUE),
|
||||
('bgcolor-005', ANSI_BACK_MAGENTA),
|
||||
('bgcolor-006', ANSI_BACK_CYAN),
|
||||
('bgcolor-007', ANSI_BACK_WHITE), # light grey
|
||||
('bgcolor-008', hilite + ANSI_BACK_BLACK), # dark grey
|
||||
('bgcolor-009', hilite + ANSI_BACK_RED),
|
||||
('bgcolor-010', hilite + ANSI_BACK_GREEN),
|
||||
('bgcolor-011', hilite + ANSI_BACK_YELLOW),
|
||||
('bgcolor-012', hilite + ANSI_BACK_BLUE),
|
||||
('bgcolor-013', hilite + ANSI_BACK_MAGENTA),
|
||||
('bgcolor-014', hilite + ANSI_BACK_CYAN),
|
||||
('bgcolor-015', hilite + ANSI_BACK_WHITE), # pure white
|
||||
] + [("bgcolor-%03i" % (i + 16), XTERM256_BG % ("%i" % (i + 16))) for i in range(240)]
|
||||
|
||||
# make sure to escape [
|
||||
#colorcodes = [(c, code.replace("[", r"\[")) for c, code in colorcodes]
|
||||
|
|
@ -80,8 +80,8 @@ class TextToHTMLparser(object):
|
|||
bg_colormap = dict((code, clr) for clr, code in colorback)
|
||||
|
||||
# create stop markers
|
||||
fgstop = "(?:\033\[1m|\033\[22m)*\033\[3[0-8].*?m|\033\[0m|$"
|
||||
bgstop = "(?:\033\[1m|\033\[22m)*\033\[4[0-8].*?m|\033\[0m|$"
|
||||
fgstop = "(?:\033\[1m|\033\[22m)*\033\[3[0-8].*?m|\033\[0m|$"
|
||||
bgstop = "(?:\033\[1m|\033\[22m)*\033\[4[0-8].*?m|\033\[0m|$"
|
||||
|
||||
# extract color markers, tagging the start marker and the text marked
|
||||
re_fgs = re.compile("((?:\033\[1m|\033\[22m)*\033\[3[0-8].*?m)(.*?)(?=" + fgstop + ")")
|
||||
|
|
@ -93,9 +93,9 @@ class TextToHTMLparser(object):
|
|||
re_uline = re.compile("(?:%s)(.*?)(?=%s|%s)" % (underline.replace("[", r"\["), fgstop, bgstop))
|
||||
re_blink = re.compile("(?:%s)(.*?)(?=%s|%s)" % (blink.replace("[", r"\["), fgstop, bgstop))
|
||||
re_inverse = re.compile("(?:%s)(.*?)(?=%s|%s)" % (inverse.replace("[", r"\["), fgstop, bgstop))
|
||||
re_string = re.compile(r'(?P<htmlchars>[<&>])|(?P<space> [ \t]+)|(?P<spacestart>^ )|(?P<lineend>\r\n|\r|\n)', re.S|re.M|re.I)
|
||||
re_string = re.compile(r'(?P<htmlchars>[<&>])|(?P<space> [ \t]+)|(?P<spacestart>^ )|(?P<lineend>\r\n|\r|\n)', re.S | re.M | re.I)
|
||||
re_url = re.compile(r'((?:ftp|www|https?)\W+(?:(?!\.(?:\s|$)|&\w+;)[^"\',;$*^\\(){}<>\[\]\s])+)(\.(?:\s|$)|&\w+;|)')
|
||||
re_mxplink = re.compile(r'\|lc(.*?)\|lt(.*?)\|le', re.DOTALL)
|
||||
re_mxplink = re.compile(r'\|lc(.*?)\|lt(.*?)\|le', re.DOTALL)
|
||||
|
||||
def _sub_fg(self, colormatch):
|
||||
code, text = colormatch.groups()
|
||||
|
|
@ -135,7 +135,7 @@ class TextToHTMLparser(object):
|
|||
|
||||
"""
|
||||
text = self.re_hilite.sub(r'<strong>\1</strong>', text)
|
||||
return self.re_unhilite.sub(r'\1', text) # strip unhilite - there is no equivalent in css.
|
||||
return self.re_unhilite.sub(r'\1', text) # strip unhilite - there is no equivalent in css.
|
||||
|
||||
def re_underline(self, text):
|
||||
"""
|
||||
|
|
@ -245,9 +245,9 @@ class TextToHTMLparser(object):
|
|||
|
||||
"""
|
||||
cmd, text = [grp.replace('\"', "\\"") for grp in match.groups()]
|
||||
val = r'''<a id="mxplink" href="#" ''' \
|
||||
'''onclick="Evennia.msg("text",["{cmd}"],{{}});''' \
|
||||
'''return false;">{text}</a>'''.format(cmd=cmd, text=text)
|
||||
val = r'''<a id="mxplink" href="#" ''' \
|
||||
'''onclick="Evennia.msg("text",["{cmd}"],{{}});''' \
|
||||
'''return false;">{text}</a>'''.format(cmd=cmd, text=text)
|
||||
return val
|
||||
|
||||
def sub_text(self, match):
|
||||
|
|
@ -306,6 +306,7 @@ class TextToHTMLparser(object):
|
|||
|
||||
return result
|
||||
|
||||
|
||||
HTML_PARSER = TextToHTMLparser()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue