Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Apply futurize level 1 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tjstum committed Nov 28, 2015
1 parent 78ec265 commit 4040d90
Show file tree
Hide file tree
Showing 18 changed files with 47 additions and 28 deletions.
1 change: 1 addition & 0 deletions gmusicapi/_version.py
@@ -1 +1,2 @@
from __future__ import unicode_literals
__version__ = "7.0.1-dev"
1 change: 1 addition & 0 deletions gmusicapi/clients/__init__.py
@@ -1,3 +1,4 @@
from __future__ import print_function, division, absolute_import, unicode_literals
from gmusicapi.clients.webclient import Webclient
from gmusicapi.clients.musicmanager import Musicmanager, OAUTH_FILEPATH
from gmusicapi.clients.mobileclient import Mobileclient
Expand Down
1 change: 1 addition & 0 deletions gmusicapi/clients/mobileclient.py
@@ -1,3 +1,4 @@
from __future__ import print_function, division, absolute_import, unicode_literals
from collections import defaultdict
import datetime
from operator import itemgetter
Expand Down
15 changes: 8 additions & 7 deletions gmusicapi/clients/musicmanager.py
@@ -1,3 +1,4 @@
from __future__ import print_function, division, absolute_import, unicode_literals
import os
from socket import gethostname
import time
Expand Down Expand Up @@ -74,16 +75,16 @@ def perform_oauth(storage_filepath=OAUTH_FILEPATH, open_browser=False):
flow = OAuth2WebServerFlow(*musicmanager.oauth)

auth_uri = flow.step1_get_authorize_url()
print
print "Visit the following url:\n %s" % auth_uri
print()
print("Visit the following url:\n %s" % auth_uri)

if open_browser:
print
print 'Opening your browser to it now...',
print()
print('Opening your browser to it now...', end=' ')
webbrowser.open(auth_uri)
print 'done.'
print "If you don't see your browser, you can just copy and paste the url."
print
print('done.')
print("If you don't see your browser, you can just copy and paste the url.")
print()

code = raw_input("Follow the prompts,"
" then paste the auth code here and hit enter: ")
Expand Down
1 change: 1 addition & 0 deletions gmusicapi/clients/shared.py
@@ -1,3 +1,4 @@
from __future__ import print_function, division, absolute_import, unicode_literals
import logging

from gmusicapi.utils import utils
Expand Down
1 change: 1 addition & 0 deletions gmusicapi/clients/webclient.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

from __future__ import print_function, division, absolute_import, unicode_literals
from urlparse import urlparse, parse_qsl

import gmusicapi
Expand Down
3 changes: 2 additions & 1 deletion gmusicapi/compat.py
Expand Up @@ -3,6 +3,7 @@
"""
Single interface for code that varies across Python environments.
"""
from __future__ import print_function, division, absolute_import, unicode_literals

import sys

Expand All @@ -22,7 +23,7 @@
from appdirs import AppDirs
my_appdirs = AppDirs('gmusicapi', 'Simon Weber')
except ImportError:
print 'warning: could not import appdirs; will use current directory'
print('warning: could not import appdirs; will use current directory')

class FakeAppDirs(object):
to_spoof = set([base + '_dir' for base in
Expand Down
1 change: 1 addition & 0 deletions gmusicapi/exceptions.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

"""Custom exceptions used across the project."""
from __future__ import print_function, division, absolute_import, unicode_literals


class CallFailure(Exception):
Expand Down
22 changes: 12 additions & 10 deletions gmusicapi/gmtools/tools.py
@@ -1,12 +1,14 @@
# -*- coding: utf-8 -*-

"""Tools for manipulating client-received Google Music data."""
from __future__ import print_function, division, absolute_import, unicode_literals

import operator
import re
import collections

from gmusicapi.compat import Counter
from functools import reduce


def get_id_pairs(track_list):
Expand Down Expand Up @@ -222,13 +224,13 @@ def manual_tiebreak(query, results):
:param results: list of results.
"""

print
print "Manual tiebreak for query:"
print build_query_rep(query).encode('utf-8')
print
print "Enter the number next to your choice:"
print
print "0: None of these."
print()
print("Manual tiebreak for query:")
print(build_query_rep(query).encode('utf-8'))
print()
print("Enter the number next to your choice:")
print()
print("0: None of these.")

menu_lines = []
key = 1
Expand All @@ -241,7 +243,7 @@ def manual_tiebreak(query, results):

key += 1

print "\n".join(menu_lines)
print("\n".join(menu_lines))

choice = -1

Expand Down Expand Up @@ -299,7 +301,7 @@ def query_library(self, query, tie_breaker=no_tiebreak, modifiers=None, auto=Fal

if not results:
try:
current_mods.append(future_mods.next())
current_mods.append(next(future_mods))
except StopIteration:
return results

Expand All @@ -311,7 +313,7 @@ def query_library(self, query, tie_breaker=no_tiebreak, modifiers=None, auto=Fal
# Branch; try more modifers to try and improve.
# If results, use them; otherwise tiebreak ours.
try:
current_mods.append(future_mods.next())
current_mods.append(next(future_mods))
except StopIteration:
raise self.TieBroken(tie_breaker(query, results))

Expand Down
1 change: 1 addition & 0 deletions gmusicapi/session.py
Expand Up @@ -3,6 +3,7 @@
"""
Sessions handle the details of authentication and transporting requests.
"""
from __future__ import print_function, division, absolute_import, unicode_literals
from contextlib import closing

import gpsoauth
Expand Down
1 change: 1 addition & 0 deletions gmusicapi/test/local_tests.py
Expand Up @@ -3,6 +3,7 @@
"""
Tests that don't hit the Google Music servers.
"""
from __future__ import print_function, division, absolute_import, unicode_literals

from collections import namedtuple
import os
Expand Down
7 changes: 4 additions & 3 deletions gmusicapi/test/rewrite_audiotest_tags.py
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-

"""A script that will rewrite audiotest* metadata to match their filenames."""
from __future__ import print_function, division, absolute_import, unicode_literals

from glob import glob
import os
Expand All @@ -12,7 +13,7 @@
audio = mutagen.File(fname, easy=True)

if audio is None:
print 'could not open', fname
print('could not open', fname)
continue

# clear existing tags
Expand All @@ -27,5 +28,5 @@

# read back to verify
audio = mutagen.File(fname, easy=True) # assume it worked; it worked above
print fname
print ' ', audio.tags
print(fname)
print(' ', audio.tags)
11 changes: 6 additions & 5 deletions gmusicapi/test/run_tests.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function, division, absolute_import, unicode_literals
from collections import namedtuple
from functools import partial, update_wrapper
from getpass import getpass
Expand Down Expand Up @@ -49,7 +50,7 @@ def prompt_for_wc_auth():
valid_wc_auth = False

while not valid_wc_auth:
print
print()
email = raw_input("Email: ")
passwd = getpass()

Expand All @@ -72,7 +73,7 @@ def get_kwargs(envargs):

if not all([wc_kwargs[arg] for arg in ('email', 'password')]):
if os.environ.get('TRAVIS'):
print 'on Travis but could not read auth from environ; quitting.'
print('on Travis but could not read auth from environ; quitting.')
sys.exit(1)

wc_kwargs.update(zip(['email', 'password'], prompt_for_wc_auth()))
Expand All @@ -88,7 +89,7 @@ def get_kwargs(envargs):
credentials_from_refresh_token(mm_kwargs['oauth_credentials'])

if 'GM_AA_D_ID' not in os.environ:
print 'an android id must be provided in the env var GM_AA_D_ID'
print('an android id must be provided in the env var GM_AA_D_ID')
sys.exit(1)

mc_kwargs = wc_kwargs.copy()
Expand Down Expand Up @@ -140,9 +141,9 @@ def main():
try:
TestProgram(module=sys.modules[__name__]).run_and_exit()
except SystemExit as e:
print
print()
if noticer.seen_message:
print '(failing build due to log warnings)'
print('(failing build due to log warnings)')
sys.exit(1)

if e.code is not None:
Expand Down
1 change: 1 addition & 0 deletions gmusicapi/test/server_tests.py
Expand Up @@ -6,6 +6,7 @@
Destructive modifications are not made, but if things go terrible wrong,
an extra test playlist or song may result.
"""
from __future__ import print_function, division, absolute_import, unicode_literals

from collections import namedtuple
from hashlib import md5
Expand Down
1 change: 1 addition & 0 deletions gmusicapi/test/utils.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

"""Utilities used in testing."""
from __future__ import print_function, division, absolute_import, unicode_literals

import logging
import os
Expand Down
3 changes: 2 additions & 1 deletion gmusicapi/utils/counter.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function, division, absolute_import, unicode_literals
from operator import itemgetter
from heapq import nlargest
from itertools import repeat, ifilter
Expand Down Expand Up @@ -190,4 +191,4 @@ def __and__(self, other):

if __name__ == '__main__':
import doctest
print doctest.testmod()
print(doctest.testmod())
1 change: 1 addition & 0 deletions gmusicapi/utils/jsarray.py
Expand Up @@ -3,6 +3,7 @@
"""
Tools to handle Google's ridiculous interchange format.
"""
from __future__ import print_function, division, absolute_import, unicode_literals

from StringIO import StringIO
from tokenize import generate_tokens
Expand Down
3 changes: 2 additions & 1 deletion gmusicapi/utils/utils.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

"""Utility functions used across api code."""
from __future__ import print_function, division, absolute_import, unicode_literals

from bisect import bisect_left
from distutils import spawn
Expand Down Expand Up @@ -584,7 +585,7 @@ def wrapper(function, *args, **kw):
if len(args[position]) == 0:
# avoid polluting our namespace
ns = {}
exec 'retval = ' + return_code in ns
exec('retval = ' + return_code, ns)
return ns['retval']
else:
return function(*args, **kw)
Expand Down

0 comments on commit 4040d90

Please sign in to comment.