|
|
|
@ -6,8 +6,8 @@
|
|
|
|
|
from .base_format import Format
|
|
|
|
|
from ..template_engine import ParametersContainer
|
|
|
|
|
from collections import OrderedDict
|
|
|
|
|
from pyparsing import originalTextFor, Literal, ZeroOrMore, Word, printables,\
|
|
|
|
|
OneOrMore, alphanums, ParseException, pyparsing_unicode,\
|
|
|
|
|
from pyparsing import originalTextFor, Literal, Word, printables,\
|
|
|
|
|
OneOrMore, alphanums, ParseException, Regex,\
|
|
|
|
|
Group, Optional, alphas, lineEnd, lineStart, Keyword
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -73,11 +73,7 @@ class DovecotFormat(Format):
|
|
|
|
|
|
|
|
|
|
cls._comment_line_parser = originalTextFor(
|
|
|
|
|
Literal(cls.comment_symbol)
|
|
|
|
|
+ ZeroOrMore(Word(
|
|
|
|
|
printables
|
|
|
|
|
+ pyparsing_unicode.alphanums)
|
|
|
|
|
)
|
|
|
|
|
)('comment')
|
|
|
|
|
+ Regex(r'.*'))('comment')
|
|
|
|
|
|
|
|
|
|
# Для парсинга строк с началом секций.
|
|
|
|
|
section = Word(alphas, alphanums+'-_', excludeChars='{}')
|
|
|
|
@ -96,7 +92,7 @@ class DovecotFormat(Format):
|
|
|
|
|
# Для парсинга строк, содержащих параметры.
|
|
|
|
|
parameter_name = Word(alphas, alphanums+'_-', excludeChars='{}=')
|
|
|
|
|
|
|
|
|
|
parameter_value = OneOrMore(Word(printables))
|
|
|
|
|
parameter_value = Regex(r'\S+(\s+\S+)*')
|
|
|
|
|
|
|
|
|
|
cls._parameter_line_parser = (Group(Optional(action_symbols,
|
|
|
|
|
default='')('action')
|
|
|
|
@ -117,11 +113,11 @@ class DovecotFormat(Format):
|
|
|
|
|
include = Keyword('!include') | Keyword('!include_try')
|
|
|
|
|
|
|
|
|
|
include_line_plain = (Optional(~action_symbols, default='')('action')
|
|
|
|
|
+ include('keyword') + Word(printables)('value'))
|
|
|
|
|
+ include('keyword') + Regex(r'\S+')('value'))
|
|
|
|
|
|
|
|
|
|
include_line_to_delete = (action_symbols('action')
|
|
|
|
|
+ include('keyword')
|
|
|
|
|
+ Word(printables)('value'))
|
|
|
|
|
+ Regex(r'\S+')('value'))
|
|
|
|
|
|
|
|
|
|
cls._include_line_parser = (include_line_plain |
|
|
|
|
|
include_line_to_delete)
|
|
|
|
|