workflow.py 文件源码

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

项目:Gank-Alfred-Workflow 作者: hujiaweibujidao 项目源码 文件源码
def _delete_directory_contents(self, dirpath, filter_func):
        """Delete all files in a directory

        :param dirpath: path to directory to clear
        :type dirpath: ``unicode`` or ``str``
        :param filter_func function to determine whether a file shall be
            deleted or not.
        :type filter_func ``callable``
        """

        if os.path.exists(dirpath):
            for filename in os.listdir(dirpath):
                if not filter_func(filename):
                    continue
                path = os.path.join(dirpath, filename)
                if os.path.isdir(path):
                    shutil.rmtree(path)
                else:
                    os.unlink(path)
                self.logger.debug('Deleted : %r', path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号