Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Support file revisions

オープン
#161 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
api

調査の方向性

pydrive2/files.py の GetContentFile から始め、リンクされている Google Drive revisions API のリファレンスを読み、続いてファイル ID とダウンロードリクエストがどのようにラップされているかを追跡します。パッケージが id で指定されたファイルリビジョンを、既存のダウンロード動作を維持したままダウンロードできれば完了です。

索引モデルが issue の本文から書いたものです。

説明

feature request

Hello PyDrive2 team,

First, thank you for developing and maintaining this package, I find it very helpful.

Second, I wanted to propose a new feature, which I personally find very useful (e.g. I am planning to use it for creating a simplified configuration management tool):

possibility to download a particular file revision by its id.

I have a code snipped that worked for me (based on GetContentFile function), but It has many shortcuts and potential flaws, therefore, I don't think it is good idea to create a PR with this code. Unfortunately, I don't have much experience working with the GDrive API to fix it myself.

@LoadAuth
def _GetContentRevision(
    file,
    rev_id,
    filename,
    chunksize=DEFAULT_CHUNK_SIZE,
):
    revisions = file.auth.service.revisions()
    file_id = file.metadata.get("id") or file.get("id")
    if not file_id:
        raise ValueError('No ID')

    def _download(fd, request):
        downloader = MediaIoBaseDownload(
            fd, file._WrapRequest(request), chunksize=chunksize
        )
        done = False
        while done is False:
            status, done = downloader.next_chunk()

    with open(filename, mode="w+b") as fd:
        rev = revisions.get(fileId=file_id, revisionId=rev_id)
        revision_metadata = rev.execute()
        rev.uri = revision_metadata["downloadUrl"]
        _download(fd, rev)

Hope you will find this feature useful as well.

-- Nikita

主要言語
Python
スター
670
フォーク
75
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

iterative/PyDrive2 のほかの issue

iterative/PyDrive2 の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。