googledrive.py 文件源码

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

项目:cazador 作者: andrewsmhay 项目源码 文件源码
def find_file(self, name=None, md5=None, sha1=None):
        """Find one or more files using the name and/or hash in Google Drive."""
        matches = []

        if not name and not md5 and sha1:
            logger.error("Google Drive does not support SHA1 hash searching.")
            return matches

        if md5:
            logger.warn("Google Drive does not officially support MD5 searching."
                        " This operation will walk your entire heirarchy comparing"
                        " file metadata.")

        def std_item_check(item):
            matches.append(self.convert_file(item))

        try:
            if name:
                self._run_file_search_query("name contains '{}'".format(name),
                                            std_item_check)
        except AccessTokenRefreshError:
            # The AccessTokenRefreshError exception is raised if the credentials
            # have been revoked by the user or they have expired.
            logger.error('Unable to execute command. The access tokens have been'
                         ' revoked by the user or have expired.')

        if md5:
            matches.extend(self._find_by_md5(md5))

        return matches
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号