Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[script.module.googleapi] 2.67.0 #2360

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 9 additions & 5 deletions script.module.googleapi/addon.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.module.googleapi"
name="googleapi"
version="1.6.7+matrix.1"
version="2.67.0+matrix.1"
provider-name="Google">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.httplib2" version="0.17.0+matrix.1" />
<import addon="script.module.oauth2client" version="4.1.3+matrix.1" />
<import addon="script.module.six" version="1.14.0+matrix.1" />
<import addon="script.module.uritemplate" version="3.0.1+matrix.1" />
<import addon="script.module.oauth2client" version="4.1.3"/>
<import addon="script.module.six" version="1.14.0+matrix.1"/>
<import addon="script.module.google-api-core" version="1.3.22"/>
<import addon="script.module.uritemplate" version="3.0.1"/>
<import addon="script.module.google-auth-httplib2" version="0.1.0"/>
</requires>
<extension point="xbmc.python.module"
library="lib" />
Expand All @@ -20,6 +21,9 @@
<disclaimer lang="en_GB">Source code for the Google API from https://developers.google.com/api-client-library/python/start/installation</disclaimer>
<license>Apache 2.0</license>
<website>https://developers.google.com/api-client-library/python/start/installation</website>
<assets>
<icon>icon.png</icon>
</assets>
<source>https://github.com/google/google-api-python-client</source>
</extension>
</addon>
4 changes: 4 additions & 0 deletions script.module.googleapi/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2.67.0

updated to googleapi 2.67.0

1.6.4

updated to googleapi 1.6.4
Expand Down
Binary file added script.module.googleapi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions script.module.googleapi/lib/googleapiclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "1.6.7"

# Set default logging handler to avoid "No handler found" warnings.
import logging

try: # Python 2.7+
from logging import NullHandler
except ImportError:

class NullHandler(logging.Handler):
def emit(self, record):
pass


logging.getLogger(__name__).addHandler(NullHandler())
70 changes: 45 additions & 25 deletions script.module.googleapi/lib/googleapiclient/_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
try:
import google.auth
import google.auth.credentials

HAS_GOOGLE_AUTH = True
except ImportError: # pragma: NO COVER
HAS_GOOGLE_AUTH = False
Expand All @@ -31,22 +32,44 @@
try:
import oauth2client
import oauth2client.client

HAS_OAUTH2CLIENT = True
except ImportError: # pragma: NO COVER
HAS_OAUTH2CLIENT = False


def default_credentials():
def credentials_from_file(filename, scopes=None, quota_project_id=None):
"""Returns credentials loaded from a file."""
if HAS_GOOGLE_AUTH:
credentials, _ = google.auth.load_credentials_from_file(
filename, scopes=scopes, quota_project_id=quota_project_id
)
return credentials
else:
raise EnvironmentError(
"client_options.credentials_file is only supported in google-auth."
)


def default_credentials(scopes=None, quota_project_id=None):
"""Returns Application Default Credentials."""
if HAS_GOOGLE_AUTH:
credentials, _ = google.auth.default()
credentials, _ = google.auth.default(
scopes=scopes, quota_project_id=quota_project_id
)
return credentials
elif HAS_OAUTH2CLIENT:
if scopes is not None or quota_project_id is not None:
raise EnvironmentError(
"client_options.scopes and client_options.quota_project_id are not supported in oauth2client."
"Please install google-auth."
)
return oauth2client.client.GoogleCredentials.get_application_default()
else:
raise EnvironmentError(
'No authentication library is available. Please install either '
'google-auth or oauth2client.')
"No authentication library is available. Please install either "
"google-auth or oauth2client."
)


def with_scopes(credentials, scopes):
Expand All @@ -62,10 +85,8 @@ def with_scopes(credentials, scopes):
Union[google.auth.credentials.Credentials,
oauth2client.client.Credentials]: The scoped credentials.
"""
if HAS_GOOGLE_AUTH and isinstance(
credentials, google.auth.credentials.Credentials):
return google.auth.credentials.with_scopes_if_required(
credentials, scopes)
if HAS_GOOGLE_AUTH and isinstance(credentials, google.auth.credentials.Credentials):
return google.auth.credentials.with_scopes_if_required(credentials, scopes)
else:
try:
if credentials.create_scoped_required():
Expand All @@ -90,16 +111,15 @@ def authorized_http(credentials):
"""
from googleapiclient.http import build_http

if HAS_GOOGLE_AUTH and isinstance(
credentials, google.auth.credentials.Credentials):
if HAS_GOOGLE_AUTH and isinstance(credentials, google.auth.credentials.Credentials):
if google_auth_httplib2 is None:
raise ValueError(
'Credentials from google.auth specified, but '
'google-api-python-client is unable to use these credentials '
'unless google-auth-httplib2 is installed. Please install '
'google-auth-httplib2.')
return google_auth_httplib2.AuthorizedHttp(credentials,
http=build_http())
"Credentials from google.auth specified, but "
"google-api-python-client is unable to use these credentials "
"unless google-auth-httplib2 is installed. Please install "
"google-auth-httplib2."
)
return google_auth_httplib2.AuthorizedHttp(credentials, http=build_http())
else:
return credentials.authorize(build_http())

Expand All @@ -110,8 +130,7 @@ def refresh_credentials(credentials):
# Http instance which would cause a weird recursive loop of refreshing
# and likely tear a hole in spacetime.
refresh_http = httplib2.Http()
if HAS_GOOGLE_AUTH and isinstance(
credentials, google.auth.credentials.Credentials):
if HAS_GOOGLE_AUTH and isinstance(credentials, google.auth.credentials.Credentials):
request = google_auth_httplib2.Request(refresh_http)
return credentials.refresh(request)
else:
Expand All @@ -126,22 +145,23 @@ def apply_credentials(credentials, headers):


def is_valid(credentials):
if HAS_GOOGLE_AUTH and isinstance(
credentials, google.auth.credentials.Credentials):
if HAS_GOOGLE_AUTH and isinstance(credentials, google.auth.credentials.Credentials):
return credentials.valid
else:
return (
credentials.access_token is not None and
not credentials.access_token_expired)
credentials.access_token is not None
and not credentials.access_token_expired
)


def get_credentials_from_http(http):
if http is None:
return None
elif hasattr(http.request, 'credentials'):
elif hasattr(http.request, "credentials"):
return http.request.credentials
elif (hasattr(http, 'credentials')
and not isinstance(http.credentials, httplib2.Credentials)):
elif hasattr(http, "credentials") and not isinstance(
http.credentials, httplib2.Credentials
):
return http.credentials
else:
return None
61 changes: 32 additions & 29 deletions script.module.googleapi/lib/googleapiclient/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,31 @@
import functools
import inspect
import logging
import warnings

import six
from six.moves import urllib

import urllib

logger = logging.getLogger(__name__)

POSITIONAL_WARNING = 'WARNING'
POSITIONAL_EXCEPTION = 'EXCEPTION'
POSITIONAL_IGNORE = 'IGNORE'
POSITIONAL_SET = frozenset([POSITIONAL_WARNING, POSITIONAL_EXCEPTION,
POSITIONAL_IGNORE])
POSITIONAL_WARNING = "WARNING"
POSITIONAL_EXCEPTION = "EXCEPTION"
POSITIONAL_IGNORE = "IGNORE"
POSITIONAL_SET = frozenset(
[POSITIONAL_WARNING, POSITIONAL_EXCEPTION, POSITIONAL_IGNORE]
)

positional_parameters_enforcement = POSITIONAL_WARNING

_SYM_LINK_MESSAGE = 'File: {0}: Is a symbolic link.'
_IS_DIR_MESSAGE = '{0}: Is a directory'
_MISSING_FILE_MESSAGE = 'Cannot access {0}: No such file or directory'
_SYM_LINK_MESSAGE = "File: {0}: Is a symbolic link."
_IS_DIR_MESSAGE = "{0}: Is a directory"
_MISSING_FILE_MESSAGE = "Cannot access {0}: No such file or directory"


def positional(max_positional_args):
"""A decorator to declare that only the first N arguments my be positional.
"""A decorator to declare that only the first N arguments may be positional.

This decorator makes it easy to support Python 3 style keyword-only
parameters. For example, in Python 3 it is possible to write::

def fn(pos1, *, kwonly1=None, kwonly1=None):
def fn(pos1, *, kwonly1=None, kwonly2=None):
...

All named parameters after ``*`` must be a keyword::
Expand Down Expand Up @@ -96,15 +93,15 @@ def my_method(cls, pos1, kwonly1=None):

Args:
max_positional_arguments: Maximum number of positional arguments. All
parameters after the this index must be
parameters after this index must be
keyword only.

Returns:
A decorator that prevents using arguments after max_positional_args
from being used as positional parameters.

Raises:
TypeError: if a key-word only argument is provided as a positional
TypeError: if a keyword-only argument is provided as a positional
parameter, but only if
_helpers.positional_parameters_enforcement is set to
POSITIONAL_EXCEPTION.
Expand All @@ -114,23 +111,27 @@ def positional_decorator(wrapped):
@functools.wraps(wrapped)
def positional_wrapper(*args, **kwargs):
if len(args) > max_positional_args:
plural_s = ''
plural_s = ""
if max_positional_args != 1:
plural_s = 's'
message = ('{function}() takes at most {args_max} positional '
'argument{plural} ({args_given} given)'.format(
function=wrapped.__name__,
args_max=max_positional_args,
args_given=len(args),
plural=plural_s))
plural_s = "s"
message = (
"{function}() takes at most {args_max} positional "
"argument{plural} ({args_given} given)".format(
function=wrapped.__name__,
args_max=max_positional_args,
args_given=len(args),
plural=plural_s,
)
)
if positional_parameters_enforcement == POSITIONAL_EXCEPTION:
raise TypeError(message)
elif positional_parameters_enforcement == POSITIONAL_WARNING:
logger.warning(message)
return wrapped(*args, **kwargs)

return positional_wrapper

if isinstance(max_positional_args, six.integer_types):
if isinstance(max_positional_args, int):
return positional_decorator
else:
args, _, _, defaults = inspect.getargspec(max_positional_args)
Expand All @@ -151,10 +152,12 @@ def parse_unique_urlencoded(content):
"""
urlencoded_params = urllib.parse.parse_qs(content)
params = {}
for key, value in six.iteritems(urlencoded_params):
for key, value in urlencoded_params.items():
if len(value) != 1:
msg = ('URL-encoded content contains a repeated value:'
'%s -> %s' % (key, ', '.join(value)))
msg = "URL-encoded content contains a repeated value:" "%s -> %s" % (
key,
", ".join(value),
)
raise ValueError(msg)
params[key] = value[0]
return params
Expand Down
Loading
Loading