mirror of https://github.com/yandex/gixy
Reworked Nginx comments parsing
parent
8de6f0a698
commit
521d4e39f5
|
@ -87,9 +87,8 @@ class RawParser(object):
|
||||||
)("file_delimiter")
|
)("file_delimiter")
|
||||||
|
|
||||||
comment = (
|
comment = (
|
||||||
Suppress('#') +
|
Regex(r"#.*")
|
||||||
Regex(r".*")
|
)("comment").setParseAction(_fix_comment)
|
||||||
)("comment")
|
|
||||||
|
|
||||||
hash_value = Group(
|
hash_value = Group(
|
||||||
value +
|
value +
|
||||||
|
@ -160,3 +159,17 @@ class RawParser(object):
|
||||||
)("unparsed_block")
|
)("unparsed_block")
|
||||||
|
|
||||||
return sub_block
|
return sub_block
|
||||||
|
|
||||||
|
|
||||||
|
def _fix_comment(string, location, tokens):
|
||||||
|
"""
|
||||||
|
Returns "cleared" comment text
|
||||||
|
|
||||||
|
:param string: original parse string
|
||||||
|
:param location: location in the string where matching started
|
||||||
|
:param tokens: list of the matched tokens, packaged as a ParseResults_ object
|
||||||
|
:return: list of the cleared comment tokens
|
||||||
|
"""
|
||||||
|
|
||||||
|
comment = tokens[0][1:].strip()
|
||||||
|
return [comment]
|
||||||
|
|
Loading…
Reference in New Issue