iterative / iterative/PyDrive2
Support file revisions
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 670
- Forks
- 75
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en pydrive2/files.py, en GetContentFile, y lee la referencia vinculada de la Google Drive revisions API; después, sigue cómo se envuelven los ID de archivo y las solicitudes de descarga. Se considera terminado cuando el paquete puede descargar una revisión de archivo especificada mediante su id, conservando el comportamiento de descarga existente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- api
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100