forked from pool/python-pydrive2
Accepting request 1131578 from home:mcalabkova:branches:devel:languages:python
- Update to 1.16.2 (bsc#1217858, CVE-2023-49297) * auth: add dictionary storage * auth: rename client_creds_dict -> client_json_dict * fs: simplify auth * fs: hide gdrive_* methods * fs: add acknowledge_abuse parameter * remove six * Implement mv method in GDriveFileSystem * fs: use itertools.chain.from_iterable instead of funcy.py3.cat * add bind_addr parameter to LocalWebserverAuth * drop Python 3.7 support * Merge pull request from GHSA-v5f6-hjmf-9mc5 - Drop merged modernize.patch - Rebase migrate-to-google-auth.patch * pr#180 was closed in favor of pr#221, which was closed as stale OBS-URL: https://build.opensuse.org/request/show/1131578 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pydrive2?expand=0&rev=6
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ac29d6da1eff3e5f14d3da0af10ff0bf3d12448427ee4e99d2f8336663455483
|
||||
size 48501
|
3
PyDrive2-1.16.2.tar.gz
Normal file
3
PyDrive2-1.16.2.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d205233d650dea4b9f6d5c4ab50ff7de0c856e6243235690f6732a2f65fa6a79
|
||||
size 60931
|
File diff suppressed because it is too large
Load Diff
353
modernize.patch
353
modernize.patch
@@ -1,353 +0,0 @@
|
||||
From 2e43e4561d965ce78dc158a02fbdb75ba6c38105 Mon Sep 17 00:00:00 2001
|
||||
From: Ruslan Kuprieiev <kupruser@gmail.com>
|
||||
Date: Wed, 27 Apr 2022 15:31:53 +0300
|
||||
Subject: [PATCH] pydrive2: pyupgrade --py37-plus
|
||||
|
||||
---
|
||||
pydrive2/apiattr.py | 15 ++++++---------
|
||||
pydrive2/auth.py | 14 ++++++--------
|
||||
pydrive2/drive.py | 2 +-
|
||||
pydrive2/files.py | 10 ++++------
|
||||
pydrive2/settings.py | 8 +++-----
|
||||
pydrive2/test/test_drive.py | 1 -
|
||||
pydrive2/test/test_file.py | 18 ++++++++----------
|
||||
pydrive2/test/test_filelist.py | 7 +++----
|
||||
setup.py | 4 +---
|
||||
9 files changed, 32 insertions(+), 47 deletions(-)
|
||||
|
||||
diff --git a/pydrive2/apiattr.py b/pydrive2/apiattr.py
|
||||
index 46845b1..6b66b42 100644
|
||||
--- a/pydrive2/apiattr.py
|
||||
+++ b/pydrive2/apiattr.py
|
||||
@@ -1,7 +1,4 @@
|
||||
-from six import Iterator, iteritems
|
||||
-
|
||||
-
|
||||
-class ApiAttribute(object):
|
||||
+class ApiAttribute:
|
||||
"""A data descriptor that sets and returns values."""
|
||||
|
||||
def __init__(self, name):
|
||||
@@ -32,7 +29,7 @@ def __del__(self, obj=None):
|
||||
del obj.dirty[self.name]
|
||||
|
||||
|
||||
-class ApiAttributeMixin(object):
|
||||
+class ApiAttributeMixin:
|
||||
"""Mixin to initialize required global variables to use ApiAttribute."""
|
||||
|
||||
def __init__(self):
|
||||
@@ -54,7 +51,7 @@ class ApiResource(dict):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Create an instance of ApiResource."""
|
||||
- super(ApiResource, self).__init__()
|
||||
+ super().__init__()
|
||||
self.update(*args, **kwargs)
|
||||
self.metadata = dict(self)
|
||||
|
||||
@@ -79,11 +76,11 @@ def __setitem__(self, key, val):
|
||||
def __repr__(self):
|
||||
"""Overwritten method of dictionary."""
|
||||
dict_representation = dict.__repr__(self)
|
||||
- return "%s(%s)" % (type(self).__name__, dict_representation)
|
||||
+ return f"{type(self).__name__}({dict_representation})"
|
||||
|
||||
def update(self, *args, **kwargs):
|
||||
"""Overwritten method of dictionary."""
|
||||
- for k, v in iteritems(dict(*args, **kwargs)):
|
||||
+ for k, v in dict(*args, **kwargs).items():
|
||||
self[k] = v
|
||||
|
||||
def UpdateMetadata(self, metadata=None):
|
||||
@@ -106,7 +103,7 @@ def GetChanges(self):
|
||||
return dirty
|
||||
|
||||
|
||||
-class ApiResourceList(ApiAttributeMixin, ApiResource, Iterator):
|
||||
+class ApiResourceList(ApiAttributeMixin, ApiResource):
|
||||
"""Abstract class of all api list resources.
|
||||
|
||||
Inherits ApiResource and builds iterator to list any API resource.
|
||||
diff --git a/pydrive2/auth.py b/pydrive2/auth.py
|
||||
index 644befb..a1b8b2f 100644
|
||||
--- a/pydrive2/auth.py
|
||||
+++ b/pydrive2/auth.py
|
||||
@@ -1,8 +1,6 @@
|
||||
-import socket
|
||||
import webbrowser
|
||||
import httplib2
|
||||
import oauth2client.clientsecrets as clientsecrets
|
||||
-from six.moves import input
|
||||
import threading
|
||||
|
||||
from googleapiclient.discovery import build
|
||||
@@ -141,7 +139,7 @@ def _decorated(self, *args, **kwargs):
|
||||
return _decorated
|
||||
|
||||
|
||||
-class GoogleAuth(ApiAttributeMixin, object):
|
||||
+class GoogleAuth(ApiAttributeMixin):
|
||||
"""Wrapper class for oauth2client library in google-api-python-client.
|
||||
|
||||
Loads all settings and credentials from one 'settings.yaml' file
|
||||
@@ -241,13 +239,13 @@ def LocalWebserverAuth(
|
||||
httpd = ClientRedirectServer(
|
||||
(host_name, port), ClientRedirectHandler
|
||||
)
|
||||
- except socket.error:
|
||||
+ except OSError:
|
||||
pass
|
||||
else:
|
||||
success = True
|
||||
break
|
||||
if success:
|
||||
- oauth_callback = "http://%s:%s/" % (host_name, port_number)
|
||||
+ oauth_callback = f"http://{host_name}:{port_number}/"
|
||||
else:
|
||||
print(
|
||||
"Failed to start a local web server. Please check your firewall"
|
||||
@@ -381,7 +379,7 @@ def LoadCredentialsFile(self, credentials_file=None):
|
||||
|
||||
try:
|
||||
self.credentials = self._default_storage.get()
|
||||
- except IOError:
|
||||
+ except OSError:
|
||||
raise InvalidCredentialsError(
|
||||
"Credentials file cannot be symbolic link"
|
||||
)
|
||||
@@ -431,7 +429,7 @@ def SaveCredentialsFile(self, credentials_file=None):
|
||||
|
||||
try:
|
||||
storage.put(self.credentials)
|
||||
- except IOError:
|
||||
+ except OSError:
|
||||
raise InvalidCredentialsError(
|
||||
"Credentials file cannot be symbolic link"
|
||||
)
|
||||
@@ -538,7 +536,7 @@ def LoadServiceConfigSettings(self):
|
||||
]
|
||||
except KeyError:
|
||||
err = "Insufficient service config in settings"
|
||||
- err += "\n\nMissing: {} key.".format(config)
|
||||
+ err += f"\n\nMissing: {config} key."
|
||||
raise InvalidConfigError(err)
|
||||
|
||||
def LoadClientConfigSettings(self):
|
||||
diff --git a/pydrive2/drive.py b/pydrive2/drive.py
|
||||
index d8b26aa..8189ab1 100644
|
||||
--- a/pydrive2/drive.py
|
||||
+++ b/pydrive2/drive.py
|
||||
@@ -4,7 +4,7 @@
|
||||
from .auth import LoadAuth
|
||||
|
||||
|
||||
-class GoogleDrive(ApiAttributeMixin, object):
|
||||
+class GoogleDrive(ApiAttributeMixin):
|
||||
"""Main Google Drive class."""
|
||||
|
||||
def __init__(self, auth=None):
|
||||
diff --git a/pydrive2/files.py b/pydrive2/files.py
|
||||
index 096f9bb..4716c7d 100644
|
||||
--- a/pydrive2/files.py
|
||||
+++ b/pydrive2/files.py
|
||||
@@ -17,9 +17,7 @@
|
||||
BLOCK_SIZE = 1024
|
||||
# Usage: MIME_TYPE_TO_BOM['<Google Drive mime type>']['<download mimetype>'].
|
||||
MIME_TYPE_TO_BOM = {
|
||||
- "application/vnd.google-apps.document": {
|
||||
- "text/plain": "\ufeff".encode("utf8")
|
||||
- }
|
||||
+ "application/vnd.google-apps.document": {"text/plain": "\ufeff".encode()}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +66,7 @@ class GoogleDriveFileList(ApiResourceList):
|
||||
|
||||
def __init__(self, auth=None, param=None):
|
||||
"""Create an instance of GoogleDriveFileList."""
|
||||
- super(GoogleDriveFileList, self).__init__(auth=auth, metadata=param)
|
||||
+ super().__init__(auth=auth, metadata=param)
|
||||
|
||||
@LoadAuth
|
||||
def _GetList(self):
|
||||
@@ -98,7 +96,7 @@ def _GetList(self):
|
||||
return result
|
||||
|
||||
|
||||
-class IoBuffer(object):
|
||||
+class IoBuffer:
|
||||
"""Lightweight retention of one chunk."""
|
||||
|
||||
def __init__(self, encoding):
|
||||
@@ -116,7 +114,7 @@ def read(self):
|
||||
)
|
||||
|
||||
|
||||
-class MediaIoReadable(object):
|
||||
+class MediaIoReadable:
|
||||
def __init__(
|
||||
self,
|
||||
request,
|
||||
diff --git a/pydrive2/settings.py b/pydrive2/settings.py
|
||||
index 8e79881..f5e84ab 100644
|
||||
--- a/pydrive2/settings.py
|
||||
+++ b/pydrive2/settings.py
|
||||
@@ -103,9 +103,9 @@ def LoadSettingsFile(filename=SETTINGS_FILE):
|
||||
:raises: SettingsError
|
||||
"""
|
||||
try:
|
||||
- with open(filename, "r") as stream:
|
||||
+ with open(filename) as stream:
|
||||
data = load(stream, Loader=Loader)
|
||||
- except (YAMLError, IOError) as e:
|
||||
+ except (YAMLError, OSError) as e:
|
||||
raise SettingsError(e)
|
||||
return data
|
||||
|
||||
@@ -158,9 +158,7 @@ def _ValidateSettingsElement(data, struct, key):
|
||||
data[key] = default
|
||||
# If data exists, Check type of the data
|
||||
elif type(value) is not data_type:
|
||||
- raise InvalidConfigError(
|
||||
- "Setting %s should be type %s" % (key, data_type)
|
||||
- )
|
||||
+ raise InvalidConfigError(f"Setting {key} should be type {data_type}")
|
||||
# If type of this data is dict, check if structure of the data is valid.
|
||||
if data_type is dict:
|
||||
_ValidateSettingsStruct(data[key], struct[key]["struct"])
|
||||
diff --git a/pydrive2/test/test_drive.py b/pydrive2/test/test_drive.py
|
||||
index 23b58a6..81498a8 100644
|
||||
--- a/pydrive2/test/test_drive.py
|
||||
+++ b/pydrive2/test/test_drive.py
|
||||
@@ -1,4 +1,3 @@
|
||||
-# -*- coding: utf-8 -*-
|
||||
import unittest
|
||||
|
||||
from pydrive2.auth import GoogleAuth
|
||||
diff --git a/pydrive2/test/test_file.py b/pydrive2/test/test_file.py
|
||||
index e83898c..bf3021a 100644
|
||||
--- a/pydrive2/test/test_file.py
|
||||
+++ b/pydrive2/test/test_file.py
|
||||
@@ -1,4 +1,3 @@
|
||||
-# -*- coding: utf-8 -*-
|
||||
import filecmp
|
||||
import os
|
||||
import unittest
|
||||
@@ -8,7 +7,6 @@
|
||||
from tempfile import mkdtemp
|
||||
from time import time
|
||||
|
||||
-from six.moves import range
|
||||
import timeout_decorator
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from googleapiclient import errors
|
||||
@@ -699,22 +697,22 @@ def test_Gfile_Conversion_Add_Remove_BOM(self):
|
||||
|
||||
def test_InsertPrefix(self):
|
||||
# Create BytesIO.
|
||||
- file_obj = BytesIO("abc".encode("utf8"))
|
||||
+ file_obj = BytesIO(b"abc")
|
||||
original_length = len(file_obj.getvalue())
|
||||
- char_to_insert = "\ufeff".encode("utf8")
|
||||
+ char_to_insert = "\ufeff".encode()
|
||||
|
||||
# Insert the prefix.
|
||||
GoogleDriveFile._InsertPrefix(file_obj, char_to_insert)
|
||||
modified_length = len(file_obj.getvalue())
|
||||
self.assertGreater(modified_length, original_length)
|
||||
- self.assertEqual(file_obj.getvalue(), "\ufeffabc".encode("utf8"))
|
||||
+ self.assertEqual(file_obj.getvalue(), "\ufeffabc".encode())
|
||||
|
||||
def test_InsertPrefixLarge(self):
|
||||
# Create BytesIO.
|
||||
test_content = "abc" * 800
|
||||
file_obj = BytesIO(test_content.encode("utf-8"))
|
||||
original_length = len(file_obj.getvalue())
|
||||
- char_to_insert = "\ufeff".encode("utf8")
|
||||
+ char_to_insert = "\ufeff".encode()
|
||||
|
||||
# Insert the prefix.
|
||||
GoogleDriveFile._InsertPrefix(file_obj, char_to_insert)
|
||||
@@ -725,22 +723,22 @@ def test_InsertPrefixLarge(self):
|
||||
|
||||
def test_RemovePrefix(self):
|
||||
# Create BytesIO.
|
||||
- file_obj = BytesIO("\ufeffabc".encode("utf8"))
|
||||
+ file_obj = BytesIO("\ufeffabc".encode())
|
||||
original_length = len(file_obj.getvalue())
|
||||
- char_to_remove = "\ufeff".encode("utf8")
|
||||
+ char_to_remove = "\ufeff".encode()
|
||||
|
||||
# Insert the prefix.
|
||||
GoogleDriveFile._RemovePrefix(file_obj, char_to_remove)
|
||||
modified_length = len(file_obj.getvalue())
|
||||
self.assertLess(modified_length, original_length)
|
||||
- self.assertEqual(file_obj.getvalue(), "abc".encode("utf8"))
|
||||
+ self.assertEqual(file_obj.getvalue(), b"abc")
|
||||
|
||||
def test_RemovePrefixLarge(self):
|
||||
# Create BytesIO.
|
||||
test_content = "\ufeff" + "abc" * 800
|
||||
file_obj = BytesIO(test_content.encode("utf8"))
|
||||
original_length = len(file_obj.getvalue())
|
||||
- char_to_remove = "\ufeff".encode("utf8")
|
||||
+ char_to_remove = "\ufeff".encode()
|
||||
|
||||
# Insert the prefix.
|
||||
GoogleDriveFile._RemovePrefix(file_obj, char_to_remove)
|
||||
diff --git a/pydrive2/test/test_filelist.py b/pydrive2/test/test_filelist.py
|
||||
index 644c13f..15918cd 100644
|
||||
--- a/pydrive2/test/test_filelist.py
|
||||
+++ b/pydrive2/test/test_filelist.py
|
||||
@@ -1,4 +1,3 @@
|
||||
-# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import unittest
|
||||
|
||||
@@ -28,7 +27,7 @@ def setup_class(cls):
|
||||
|
||||
def test_01_Files_List_GetList(self):
|
||||
drive = GoogleDrive(self.ga)
|
||||
- query = "title = '{}' and trashed = false".format(self.title)
|
||||
+ query = f"title = '{self.title}' and trashed = false"
|
||||
for file1 in pydrive_list_item(drive, query):
|
||||
found = False
|
||||
for file2 in pydrive_list_item(drive, query):
|
||||
@@ -38,7 +37,7 @@ def test_01_Files_List_GetList(self):
|
||||
|
||||
def test_02_Files_List_ForLoop(self):
|
||||
drive = GoogleDrive(self.ga)
|
||||
- query = "title = '{}' and trashed = false".format(self.title)
|
||||
+ query = f"title = '{self.title}' and trashed = false"
|
||||
files = []
|
||||
for x in pydrive_list_item(
|
||||
drive, query, 2
|
||||
@@ -84,7 +83,7 @@ def test_File_List_Folders(self):
|
||||
)
|
||||
pydrive_retry(folder1.Upload)
|
||||
self.file_list.append(folder1)
|
||||
- query = "title = '{}' and trashed = false".format(self.title)
|
||||
+ query = f"title = '{self.title}' and trashed = false"
|
||||
count = 0
|
||||
for file1 in pydrive_list_item(drive, query):
|
||||
self.assertFileInFileList(file1)
|
||||
diff --git a/setup.py b/setup.py
|
||||
index 32c9364..06982d0 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -1,4 +1,3 @@
|
||||
-import sys
|
||||
from setuptools import setup
|
||||
|
||||
# Extra dependecies to run tests
|
||||
@@ -11,8 +10,7 @@
|
||||
"pytest-mock",
|
||||
]
|
||||
|
||||
-if sys.version_info >= (3, 6):
|
||||
- tests_requirements.append("black==22.3.0")
|
||||
+tests_requirements.append("black==22.3.0")
|
||||
|
||||
setup(
|
||||
name="PyDrive2",
|
@@ -1,3 +1,22 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Dec 7 09:17:01 UTC 2023 - Markéta Machová <mmachova@suse.com>
|
||||
|
||||
- Update to 1.16.2 (bsc#1217858, CVE-2023-49297)
|
||||
* auth: add dictionary storage
|
||||
* auth: rename client_creds_dict -> client_json_dict
|
||||
* fs: simplify auth
|
||||
* fs: hide gdrive_* methods
|
||||
* fs: add acknowledge_abuse parameter
|
||||
* remove six
|
||||
* Implement mv method in GDriveFileSystem
|
||||
* fs: use itertools.chain.from_iterable instead of funcy.py3.cat
|
||||
* add bind_addr parameter to LocalWebserverAuth
|
||||
* drop Python 3.7 support
|
||||
* Merge pull request from GHSA-v5f6-hjmf-9mc5
|
||||
- Drop merged modernize.patch
|
||||
- Rebase migrate-to-google-auth.patch
|
||||
* pr#180 was closed in favor of pr#221, which was closed as stale
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jun 3 11:11:45 UTC 2022 - Markéta Machová <mmachova@suse.com>
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-pydrive2
|
||||
#
|
||||
# Copyright (c) 2022 SUSE LLC
|
||||
# Copyright (c) 2023 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@@ -16,17 +16,14 @@
|
||||
#
|
||||
|
||||
|
||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||
Name: python-pydrive2
|
||||
Version: 1.10.1
|
||||
Version: 1.16.2
|
||||
Release: 0
|
||||
Summary: A wrapper library for google-api-python-client
|
||||
License: Apache-2.0
|
||||
URL: https://github.com/iterative/PyDrive2
|
||||
Source: https://files.pythonhosted.org/packages/source/P/PyDrive2/PyDrive2-%{version}.tar.gz
|
||||
# PATCH-FIX-UPSTREAM https://github.com/iterative/PyDrive2/commit/2e43e4561d965ce78dc158a02fbdb75ba6c38105 pydrive2: modernise to python 3.7+
|
||||
Patch0: modernize.patch
|
||||
# PATCH-FIX-UPSTREAM https://github.com/iterative/PyDrive2/pull/180 Migrating to Google Auth Library
|
||||
# PATCH-FIX-UPSTREAM https://github.com/iterative/PyDrive2/pull/221 Migrating to Google Auth Library
|
||||
Patch1: migrate-to-google-auth.patch
|
||||
BuildRequires: %{python_module setuptools}
|
||||
BuildRequires: python-rpm-macros
|
||||
@@ -35,30 +32,25 @@ BuildRequires: python-rpm-macros
|
||||
#BuildRequires: %{python_module google-api-python-client >= 1.12.5}
|
||||
#BuildRequires: %{python_module PyYAML >= 3.0}
|
||||
#BuildRequires: %{python_module black}
|
||||
BuildRequires: %{python_module filelock >= 3.7.0}
|
||||
#BuildRequires: %{python_module flake8-docstrings}
|
||||
#BuildRequires: %{python_module flake8}
|
||||
#BuildRequires: %{python_module fsspec}
|
||||
#BuildRequires: %{python_module funcy >= 1.14}
|
||||
BuildRequires: %{python_module google-auth-oauthlib >= 0.5.1}
|
||||
BuildRequires: %{python_module google-auth >= 2.6.6}
|
||||
BuildRequires: %{python_module google-auth-httplib2 >= 0.1.0}
|
||||
#BuildRequires: %{python_module pyOpenSSL >= 19.1.0}
|
||||
#BuildRequires: %{python_module pytest-mock}
|
||||
#BuildRequires: %{python_module pytest}
|
||||
#BuildRequires: %{python_module six >= 1.13.0}
|
||||
#BuildRequires: %{python_module timeout-decorator}
|
||||
#BuildRequires: %{python_module tqdm}
|
||||
# /SECTION
|
||||
BuildRequires: fdupes
|
||||
Requires: python-PyYAML >= 3.0
|
||||
Requires: python-filelock >= 3.7.0
|
||||
Requires: python-google-api-python-client >= 1.12.5
|
||||
Requires: python-google-auth >= 2.6.6
|
||||
Requires: python-google-auth-httplib2 >= 0.1.0
|
||||
Requires: python-google-auth-oauthlib >= 0.5.1
|
||||
Requires: python-pyOpenSSL >= 19.1.0
|
||||
Requires: python-six >= 1.13.0
|
||||
BuildArch: noarch
|
||||
%python_subpackages
|
||||
|
||||
@@ -84,6 +76,7 @@ By the authors and maintainers of the Git for Data - DVC project.
|
||||
%files %{python_files}
|
||||
%doc CHANGES README.rst
|
||||
%license LICENSE
|
||||
%{python_sitelib}/*
|
||||
%{python_sitelib}/PyDrive2*-info
|
||||
%{python_sitelib}/pydrive2
|
||||
|
||||
%changelog
|
||||
|
Reference in New Issue
Block a user