project.py 文件源码

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

项目:sublime_libsass 作者: blitzrk 项目源码 文件源码
def guess_root(file):
    '''
    For projects without .libsass.json configs, search for the most distant
    parent directory that still has a .sass or .scss file
    '''

    def is_sass(file):
        ext = os.path.splitext(file)[1]
        return ext in ['.sass', '.scss']

    for i, path in enumerate(subpaths(file)):
        (_, _, files) = next(os.walk(path))
        if not any([is_sass(f) for f in files]):
            break

    if not is_sass(file):
        sublime.error_message("Please save the file")

    assert is_sass(file)
    assert i > 0

    return subpaths(file)[i-1]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号