python类include()的实例源码

functional.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def gen_elixir_sigil_rules():
        states = {}

        states['strings'] = [
            (r'(%[A-Ba-z])?"""(?:.|\n)*?"""', String.Doc),
            (r"'''(?:.|\n)*?'''", String.Doc),
            (r'"', String.Double, 'dqs'),
            (r"'.*'", String.Single),
            (r'(?<!\w)\?(\\(x\d{1,2}|\h{1,2}(?!\h)\b|0[0-7]{0,2}(?![0-7])\b|'
             r'[^x0MC])|(\\[MC]-)+\w|[^\s\\])', String.Other)
        ]

        for lbrace, rbrace, name, in ('\\{', '\\}', 'cb'), \
                                     ('\\[', '\\]', 'sb'), \
                                     ('\\(', '\\)', 'pa'), \
                                     ('\\<', '\\>', 'lt'):

            states['strings'] += [
                (r'%[a-z]' + lbrace, String.Double, name + 'intp'),
                (r'%[A-Z]' + lbrace, String.Double, name + 'no-intp')
            ]

            states[name +'intp'] = [
                (r'' + rbrace + '[a-z]*', String.Double, "#pop"),
                include('enddoublestr')
            ]

            states[name +'no-intp'] = [
                (r'.*' + rbrace + '[a-z]*', String.Double , "#pop")
            ]

        return states
functional.py 文件源码 项目:webapp 作者: superchilli 项目源码 文件源码 阅读 54 收藏 0 点赞 0 评论 0
def gen_elixir_sigil_rules():
        states = {}

        states['strings'] = [
            (r'(%[A-Ba-z])?"""(?:.|\n)*?"""', String.Doc),
            (r"'''(?:.|\n)*?'''", String.Doc),
            (r'"', String.Double, 'dqs'),
            (r"'.*'", String.Single),
            (r'(?<!\w)\?(\\(x\d{1,2}|\h{1,2}(?!\h)\b|0[0-7]{0,2}(?![0-7])\b|'
             r'[^x0MC])|(\\[MC]-)+\w|[^\s\\])', String.Other)
        ]

        for lbrace, rbrace, name, in ('\\{', '\\}', 'cb'), \
                                     ('\\[', '\\]', 'sb'), \
                                     ('\\(', '\\)', 'pa'), \
                                     ('\\<', '\\>', 'lt'):

            states['strings'] += [
                (r'%[a-z]' + lbrace, String.Double, name + 'intp'),
                (r'%[A-Z]' + lbrace, String.Double, name + 'no-intp')
            ]

            states[name +'intp'] = [
                (r'' + rbrace + '[a-z]*', String.Double, "#pop"),
                include('enddoublestr')
            ]

            states[name +'no-intp'] = [
                (r'.*' + rbrace + '[a-z]*', String.Double , "#pop")
            ]

        return states


问题


面经


文章

微信
公众号

扫码关注公众号