Exemplo n.º 1
0
    def getToken(self):
        token = Regex(
            r'((?# Начало разбора IP )(?<!\.)(?:25[0-5]|2[0-4]\d|1\d\d|0?[1-9]\d|0{,2}[1-9])(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)){3}(?!\.[0-9])(?!\w)(?# Конец разбора IP )|(((news|telnet|nttp|file|http|ftp|https|page)://)|(www|ftp)\.)[-\w0-9\.]+[-\w0-9]+)(:[0-9]*)?(/([-\w0-9_,\$\.\+\!\*\(\):@|&=\?/~\#\%]*[-\w0-9_\$\+\!\*\(\):@|&=\?/~\#\%])?)?',
            re.IGNORECASE)("url")

        token.setParseAction(self.__convertToUrlLink)
        return token
Exemplo n.º 2
0
    def getToken (self):
        tableCell = Regex (r"(?P<text>(.|(\\\n))*?)(\\\n\s*)*\|\|", re.UNICODE)
        tableCell.setParseAction(self.__convertTableCell)

        tableRow = LineStart() + "||" + OneOrMore (tableCell) + Optional (LineEnd())
        tableRow.setParseAction(self.__convertTableRow)

        table = LineStart() + Regex (r"\|\| *(?P<params>.+)?", re.UNICODE) + LineEnd() + OneOrMore (tableRow)
        table = table.setParseAction(self.__convertTable)("table")

        return table
Exemplo n.º 3
0
    def getToken(self):
        tableCell = Regex(r"(?P<text>(.|(\\\n))*?)\|\|")
        tableCell.setParseAction(self.__convertTableCell)

        tableRow = LineStart() + Literal("||") + OneOrMore(tableCell).leaveWhitespace() + Optional(LineEnd())
        tableRow.setParseAction(self.__convertTableRow)

        table = LineStart() + Regex(r"\|\| *(?P<params>.+)?") + LineEnd() + OneOrMore(tableRow)
        table = table.setParseAction(self.__convertTable)("table")

        return table
Exemplo n.º 4
0
    def getToken (self):
        term = Regex (r"(?P<text>(?:(?:\\\n)|.)*)\s*(?=\n)")
        term = LineStart() + Regex (r"\^\^") + Regex(TagAttrsPattern.value) + term + LineEnd()
        term.setParseAction(self.__convertTerm).leaveWhitespace()

        description = Regex (r"(?P<text>(?:(?!(?<!\\)\n(?:<}}|\$\$.|\^\^.)).)*)", re.DOTALL)
        description = LineStart() + Regex (r"\$\$") + Regex(TagAttrsPattern.value) + description + LineEnd()
        description.setParseAction(self.__convertDescription).leaveWhitespace()

        definitionList = LineStart() + Regex (r"{{> *(?P<params>.+)?\s*") + \
                         OneOrMore (term | description) + Suppress("<}}") + Optional (FollowedBy (LineEnd()))
        definitionList.setParseAction(self.__convertDefinitionList)("definitionlist").leaveWhitespace()

        return definitionList
Exemplo n.º 5
0
    def getToken(self):
        tableCell = Regex(r"(?P<text>(.|(\\\n))*?)(\\\n\s*)*\|\|", re.UNICODE)
        tableCell.setParseAction(self.__convertTableCell)

        tableRow = LineStart() + "||" + OneOrMore(tableCell) + Optional(
            LineEnd())
        tableRow.setParseAction(self.__convertTableRow)

        table = LineStart() + Regex(
            r"\|\| *(?P<params>.+)?",
            re.UNICODE) + LineEnd() + OneOrMore(tableRow)
        table = table.setParseAction(self.__convertTable)("table")

        return table
Exemplo n.º 6
0
 def getToken(self):
     result = Regex(r"""%\s*?
                     (?:
                         (?:thumb\s+)?
                         (?:width\s*?=\s*?(?P<width>\d+)
                         |height\s*?=\s*?(?P<height>\d+)
                         |maxsize\s*?=\s*?(?P<maxsize>\d+))\s*?
                         (?:px)?
                         |thumb\s*?
                     )\s*?
                     %\s*?
                     Attach:(?P<fname>.*?\.(?:jpe?g|bmp|gif|tiff?|png))\s*?%%""",
                    re.IGNORECASE | re.VERBOSE)
     result = result.setParseAction(self.__convertThumb)("thumbnail")
     return result
Exemplo n.º 7
0
 def getToken (self):
     result = Regex (r"""%\s*?
                     (?:
                         (?:thumb\s+)?
                         (?:width\s*?=\s*?(?P<width>\d+)
                         |height\s*?=\s*?(?P<height>\d+)
                         |maxsize\s*?=\s*?(?P<maxsize>\d+))\s*?
                         (?:px)?
                         |thumb\s*?
                     )\s*?
                     %\s*?
                     Attach:(?P<fname>.*?\.(?:jpe?g|bmp|gif|tiff?|png))\s*?%%""",
                     re.IGNORECASE | re.VERBOSE)
     result = result.setParseAction (self.__convertThumb)("thumbnail")
     return result
Exemplo n.º 8
0
    def getToken (self):
        token = Regex (ur'((?# Начало разбора IP )(?<!\.)(?:25[0-5]|2[0-4]\d|1\d\d|0?[1-9]\d|0{,2}[1-9])(?:\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)){3}(?!\.[0-9])(?!\w)(?# Конец разбора IP )|(((news|telnet|nttp|file|http|ftp|https|page)://)|(www|ftp)\.)[-\w0-9\.]+[-\w0-9]+)(:[0-9]*)?(/([-\w0-9_,\$\.\+\!\*\(\):@|&=\?/~\#\%]*[-\w0-9_\$\+\!\*\(\):@|&=\?/~\#\%])?)?', re.IGNORECASE | re.UNICODE)("url")

        token.setParseAction(self.__convertToUrlLink)
        return token
Exemplo n.º 9
0
    def getToken (self):
        token =  Regex ("([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}|(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)\\.)[-\\w0-9\\.]+[-\\w0-9]+)(:[0-9]*)?(/([-\\w0-9_,\\$\\.\\+\\!\\*\\(\\):@|&=\\?/~\\#\\%]*[-\\w0-9_\\$\\+\\!\\*\\(\\):@|&=\\?/~\\#\\%])?)?", re.IGNORECASE | re.UNICODE)("url")

        token.setParseAction(self.__convertToUrlLink)
        return token
Exemplo n.º 10
0
 def getToken(self):
     token = Regex(r"\\\n")
     token = token.setParseAction(lambda s, l, t: u"")("linejoin")
     return token
Exemplo n.º 11
0
 def getToken(self):
     token = Regex(r"\\\n")
     token = token.setParseAction(lambda s, l, t: u"")("linejoin")
     return token
Exemplo n.º 12
0
 def getToken (self):
     result = Regex (r"""% *?(((thumb +)?width *?= *?(?P<width>\d+) *?(px)?)|((thumb +)?height *?= *?(?P<height>\d+) *?(px)?)|((thumb +)?maxsize *?= *?(?P<maxsize>\d+) *?(px)?)|(thumb *?)) *?% *?Attach:(?P<fname>.*?\.(jpe?g|bmp|gif|tiff?|png)) *?%%""", re.IGNORECASE)
     result = result.setParseAction (self.__convertThumb)("thumbnail")
     return result