Ran 2to3 on pillar + some manual fixups
The 'manual fixups' are: - incorrect use of dict.items() where dict.iteritems() was meant; this results in list(dict.items()), which I changed to dict.items(). - removal of 'from __future__ import' lines, which 2to3 changes into empty lines; I removed the empty lines.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import copy
|
||||
import hashlib
|
||||
import json
|
||||
import urllib
|
||||
import urllib.request, urllib.parse, urllib.error
|
||||
|
||||
import datetime
|
||||
import functools
|
||||
@@ -103,7 +103,7 @@ def skip_when_testing(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
if current_app.config['TESTING']:
|
||||
log.debug('Skipping call to %s(...) due to TESTING', func.func_name)
|
||||
log.debug('Skipping call to %s(...) due to TESTING', func.__name__)
|
||||
return None
|
||||
|
||||
return func(*args, **kwargs)
|
||||
@@ -145,19 +145,18 @@ def gravatar(email, size=64):
|
||||
parameters = {'s': str(size), 'd': 'mm'}
|
||||
return "https://www.gravatar.com/avatar/" + \
|
||||
hashlib.md5(str(email)).hexdigest() + \
|
||||
"?" + urllib.urlencode(parameters)
|
||||
"?" + urllib.parse.urlencode(parameters)
|
||||
|
||||
|
||||
|
||||
class MetaFalsey(type):
|
||||
def __nonzero__(cls):
|
||||
def __bool__(cls):
|
||||
return False
|
||||
__bool__ = __nonzero__ # for Python 3
|
||||
|
||||
|
||||
class DoesNotExist(object):
|
||||
class DoesNotExist(object, metaclass=MetaFalsey):
|
||||
"""Returned as value by doc_diff if a value does not exist."""
|
||||
__metaclass__ = MetaFalsey
|
||||
|
||||
|
||||
def doc_diff(doc1, doc2, falsey_is_equal=True):
|
||||
@@ -175,7 +174,7 @@ def doc_diff(doc1, doc2, falsey_is_equal=True):
|
||||
"""
|
||||
|
||||
for key in set(doc1.keys()).union(set(doc2.keys())):
|
||||
if isinstance(key, basestring) and key[0] == u'_':
|
||||
if isinstance(key, str) and key[0] == '_':
|
||||
continue
|
||||
|
||||
val1 = doc1.get(key, DoesNotExist)
|
||||
|
@@ -124,7 +124,7 @@ def store_token(user_id, token, token_expiry, oauth_subclient_id=False):
|
||||
:returns: the token document from MongoDB
|
||||
"""
|
||||
|
||||
assert isinstance(token, (str, unicode)), 'token must be string type, not %r' % type(token)
|
||||
assert isinstance(token, str), 'token must be string type, not %r' % type(token)
|
||||
|
||||
token_data = {
|
||||
'user': user_id,
|
||||
|
@@ -238,22 +238,22 @@ def merge_permissions(*args):
|
||||
asdict0 = {permission[field_name]: permission['methods'] for permission in from0}
|
||||
asdict1 = {permission[field_name]: permission['methods'] for permission in from1}
|
||||
|
||||
keys = set(asdict0.keys() + asdict1.keys())
|
||||
keys = set(asdict0.keys()).union(set(asdict1.keys()))
|
||||
for key in maybe_sorted(keys):
|
||||
methods0 = asdict0.get(key, [])
|
||||
methods1 = asdict1.get(key, [])
|
||||
methods = maybe_sorted(set(methods0).union(set(methods1)))
|
||||
effective.setdefault(plural_name, []).append({field_name: key, u'methods': methods})
|
||||
effective.setdefault(plural_name, []).append({field_name: key, 'methods': methods})
|
||||
|
||||
merge(u'user')
|
||||
merge(u'group')
|
||||
merge('user')
|
||||
merge('group')
|
||||
|
||||
# Gather permissions for world
|
||||
world0 = args[0].get('world', [])
|
||||
world1 = args[1].get('world', [])
|
||||
world_methods = set(world0).union(set(world1))
|
||||
if world_methods:
|
||||
effective[u'world'] = maybe_sorted(world_methods)
|
||||
effective['world'] = maybe_sorted(world_methods)
|
||||
|
||||
# Recurse for longer merges
|
||||
if len(args) > 2:
|
||||
@@ -380,4 +380,4 @@ def user_matches_roles(require_roles=set(),
|
||||
def is_admin(user):
|
||||
"""Returns True iff the given user has the admin role."""
|
||||
|
||||
return user_has_role(u'admin', user)
|
||||
return user_has_role('admin', user)
|
||||
|
@@ -173,7 +173,7 @@ class GoogleCloudStorageBucket(Bucket):
|
||||
"""Set the ContentDisposition metadata so that when a file is downloaded
|
||||
it has a human-readable name.
|
||||
"""
|
||||
blob.content_disposition = u'attachment; filename="{0}"'.format(name)
|
||||
blob.content_disposition = 'attachment; filename="{0}"'.format(name)
|
||||
blob.patch()
|
||||
|
||||
def copy_blob(self, blob, to_bucket):
|
||||
@@ -215,11 +215,11 @@ def update_file_name(node):
|
||||
if node['properties'].get('status', '') == 'processing':
|
||||
return
|
||||
|
||||
def _format_name(name, override_ext, size=None, map_type=u''):
|
||||
def _format_name(name, override_ext, size=None, map_type=''):
|
||||
root, _ = os.path.splitext(name)
|
||||
size = u'-{}'.format(size) if size else u''
|
||||
map_type = u'-{}'.format(map_type) if map_type else u''
|
||||
return u'{}{}{}{}'.format(root, size, map_type, override_ext)
|
||||
size = '-{}'.format(size) if size else ''
|
||||
map_type = '-{}'.format(map_type) if map_type else ''
|
||||
return '{}{}{}{}'.format(root, size, map_type, override_ext)
|
||||
|
||||
def _update_name(file_id, file_props):
|
||||
files_collection = current_app.data.driver.db['files']
|
||||
@@ -229,7 +229,7 @@ def update_file_name(node):
|
||||
return
|
||||
|
||||
# For textures -- the map type should be part of the name.
|
||||
map_type = file_props.get('map_type', u'')
|
||||
map_type = file_props.get('map_type', '')
|
||||
|
||||
storage = GoogleCloudStorageBucket(str(node['project']))
|
||||
blob = storage.Get(file_doc['file_path'], to_dict=False)
|
||||
|
@@ -21,7 +21,7 @@ def generate_local_thumbnails(name_base, src):
|
||||
save_to_base, _ = os.path.splitext(src)
|
||||
name_base, _ = os.path.splitext(name_base)
|
||||
|
||||
for size, settings in thumbnail_settings.iteritems():
|
||||
for size, settings in thumbnail_settings.items():
|
||||
dst = '{0}-{1}{2}'.format(save_to_base, size, '.jpg')
|
||||
name = '{0}-{1}{2}'.format(name_base, size, '.jpg')
|
||||
|
||||
@@ -143,7 +143,7 @@ def get_video_data(filepath):
|
||||
res_y=video_stream['height'],
|
||||
)
|
||||
if video_stream['sample_aspect_ratio'] != '1:1':
|
||||
print '[warning] Pixel aspect ratio is not square!'
|
||||
print('[warning] Pixel aspect ratio is not square!')
|
||||
|
||||
return outdata
|
||||
|
||||
@@ -190,14 +190,14 @@ def ffmpeg_encode(src, format, res_y=720):
|
||||
dst = os.path.splitext(src)
|
||||
dst = "{0}-{1}p.{2}".format(dst[0], res_y, format)
|
||||
args.append(dst)
|
||||
print "Encoding {0} to {1}".format(src, format)
|
||||
print("Encoding {0} to {1}".format(src, format))
|
||||
returncode = subprocess.call([current_app.config['BIN_FFMPEG']] + args)
|
||||
if returncode == 0:
|
||||
print "Successfully encoded {0}".format(dst)
|
||||
print("Successfully encoded {0}".format(dst))
|
||||
else:
|
||||
print "Error during encode"
|
||||
print "Code: {0}".format(returncode)
|
||||
print "Command: {0}".format(current_app.config['BIN_FFMPEG'] + " " + " ".join(args))
|
||||
print("Error during encode")
|
||||
print("Code: {0}".format(returncode))
|
||||
print("Command: {0}".format(current_app.config['BIN_FFMPEG'] + " " + " ".join(args)))
|
||||
dst = None
|
||||
# return path of the encoded video
|
||||
return dst
|
||||
|
Reference in New Issue
Block a user