_postgres_builtins.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:sublime-text-3-packages 作者: nickjj 项目源码 文件源码
def update_consts(filename, constname, content):
        with open(filename) as f:
            data = f.read()

        # Line to start/end inserting
        re_match = re.compile(r'^%s\s*=\s*\($.*?^\s*\)$' % constname, re.M | re.S)
        m = re_match.search(data)
        if not m:
            raise ValueError('Could not find existing definition for %s' %
                             (constname,))

        new_block = format_lines(constname, content)
        data = data[:m.start()] + new_block + data[m.end():]

        with open(filename, 'w') as f:
            f.write(data)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号