Replace yapf with black
This commit is contained in:
@@ -11,8 +11,8 @@ class ListParser(object):
|
||||
_parser: pp.ParserElement
|
||||
|
||||
def __init__(self):
|
||||
newline = '\n'
|
||||
space_plus = pp.Regex('[ \t]+')
|
||||
newline = "\n"
|
||||
space_plus = pp.Regex("[ \t]+")
|
||||
space_star = pp.Optional(space_plus)
|
||||
|
||||
quoted_element = pp.Regex(r'[^\\"]|\\[^A-Za-z0-9]|\\[trn]')
|
||||
@@ -22,10 +22,10 @@ class ListParser(object):
|
||||
|
||||
def action_bracket_open(tokens: pp.ParseResults):
|
||||
nonlocal bracket_content
|
||||
marker = ']' + '=' * (len(tokens[0]) - 2) + ']'
|
||||
marker = "]" + "=" * (len(tokens[0]) - 2) + "]"
|
||||
bracket_content <<= pp.SkipTo(marker, include=True)
|
||||
|
||||
bracket_open = pp.Regex(r'\[=*\[').setParseAction(action_bracket_open)
|
||||
bracket_open = pp.Regex(r"\[=*\[").setParseAction(action_bracket_open)
|
||||
bracket_argument = pp.Combine(bracket_open + bracket_content)
|
||||
|
||||
unquoted_element = pp.Regex(r'[^\s()#"\\]|\\[^A-Za-z0-9]|\\[trn]')
|
||||
@@ -33,25 +33,29 @@ class ListParser(object):
|
||||
|
||||
argument = bracket_argument | quoted_argument | unquoted_argument
|
||||
|
||||
line_comment = pp.Combine('#' + ~bracket_open +
|
||||
pp.SkipTo(pp.LineEnd()))
|
||||
bracket_comment = pp.Combine('#' + bracket_argument)
|
||||
line_ending = (space_star +
|
||||
pp.ZeroOrMore(bracket_comment + space_star) +
|
||||
pp.Optional(line_comment) + (newline | pp.lineEnd))
|
||||
line_comment = pp.Combine("#" + ~bracket_open + pp.SkipTo(pp.LineEnd()))
|
||||
bracket_comment = pp.Combine("#" + bracket_argument)
|
||||
line_ending = (
|
||||
space_star
|
||||
+ pp.ZeroOrMore(bracket_comment + space_star)
|
||||
+ pp.Optional(line_comment)
|
||||
+ (newline | pp.lineEnd)
|
||||
)
|
||||
|
||||
identifier = pp.Word(pp.alphas + '_', pp.alphanums + '_')
|
||||
identifier = pp.Word(pp.alphas + "_", pp.alphanums + "_")
|
||||
arguments = pp.Forward()
|
||||
arguments << pp.ZeroOrMore(argument | line_ending | space_plus
|
||||
| '(' + arguments + ')').leaveWhitespace()
|
||||
arguments << pp.ZeroOrMore(
|
||||
argument | line_ending | space_plus | "(" + arguments + ")"
|
||||
).leaveWhitespace()
|
||||
arguments = pp.Group(arguments)
|
||||
PAREN_L, PAREN_R = map(pp.Suppress, '()')
|
||||
PAREN_L, PAREN_R = map(pp.Suppress, "()")
|
||||
command_invocation = (
|
||||
identifier + space_star.suppress() + PAREN_L + arguments +
|
||||
PAREN_R).setParseAction(lambda t: (t[0], t[1].asList()))
|
||||
identifier + space_star.suppress() + PAREN_L + arguments + PAREN_R
|
||||
).setParseAction(lambda t: (t[0], t[1].asList()))
|
||||
|
||||
file_element = (space_star + command_invocation + line_ending
|
||||
| line_ending).leaveWhitespace()
|
||||
file_element = (
|
||||
space_star + command_invocation + line_ending | line_ending
|
||||
).leaveWhitespace()
|
||||
file = pp.ZeroOrMore(file_element)
|
||||
|
||||
self._parser = file
|
||||
|
||||
Reference in New Issue
Block a user