Python 3.6 compatibility: Applied 2to3
This commit is contained in:
@@ -15,7 +15,7 @@ import attract.shots_and_assets
|
||||
EXTENSION_NAME = 'attract'
|
||||
|
||||
# Roles required to view task or shot details.
|
||||
ROLES_REQUIRED_TO_VIEW_ITEMS = {u'demo', u'subscriber', u'admin'}
|
||||
ROLES_REQUIRED_TO_VIEW_ITEMS = {'demo', 'subscriber', 'admin'}
|
||||
|
||||
|
||||
class AttractExtension(PillarExtension):
|
||||
|
@@ -46,7 +46,7 @@ def create_svner_account(email, project_url):
|
||||
log.error('Unable to find project url=%s', project_url)
|
||||
return 1
|
||||
|
||||
account, token = create_service_account(email, [u'svner'], {'svner': {'project': proj['_id']}})
|
||||
account, token = create_service_account(email, ['svner'], {'svner': {'project': proj['_id']}})
|
||||
return account, token
|
||||
|
||||
manager.add_command("attract", manager_attract)
|
||||
|
@@ -16,7 +16,7 @@ def find_for_shot(project, node):
|
||||
@register_node_finder(node_type_task['name'])
|
||||
def find_for_task(project, node):
|
||||
|
||||
parent = node.get(u'parent') if isinstance(node, dict) else node.parent
|
||||
parent = node.get('parent') if isinstance(node, dict) else node.parent
|
||||
if parent:
|
||||
endpoint = 'attract.shots.perproject.with_task'
|
||||
else:
|
||||
|
@@ -4,8 +4,6 @@ This is intended to be used by the CLI and unittests only, not tested
|
||||
for live/production situations.
|
||||
"""
|
||||
|
||||
from __future__ import print_function, division
|
||||
|
||||
import copy
|
||||
import logging
|
||||
|
||||
|
@@ -21,25 +21,25 @@ from attract.node_types import node_type_shot, node_type_task, node_type_asset
|
||||
|
||||
# From patch operation name to fields that operation may edit.
|
||||
VALID_SHOT_PATCH_FIELDS = {
|
||||
u'from-blender': {
|
||||
u'name',
|
||||
u'picture',
|
||||
u'properties.trim_start_in_frames',
|
||||
u'properties.trim_end_in_frames',
|
||||
u'properties.duration_in_edit_in_frames',
|
||||
u'properties.cut_in_timeline_in_frames',
|
||||
u'properties.status',
|
||||
u'properties.used_in_edit',
|
||||
'from-blender': {
|
||||
'name',
|
||||
'picture',
|
||||
'properties.trim_start_in_frames',
|
||||
'properties.trim_end_in_frames',
|
||||
'properties.duration_in_edit_in_frames',
|
||||
'properties.cut_in_timeline_in_frames',
|
||||
'properties.status',
|
||||
'properties.used_in_edit',
|
||||
},
|
||||
u'from-web': {
|
||||
u'properties.status',
|
||||
u'properties.notes',
|
||||
u'description',
|
||||
'from-web': {
|
||||
'properties.status',
|
||||
'properties.notes',
|
||||
'description',
|
||||
},
|
||||
}
|
||||
|
||||
VALID_SHOT_PATCH_OPERATIONS = {
|
||||
u'from-blender', u'from-web', u'unlink', u'relink',
|
||||
'from-blender', 'from-web', 'unlink', 'relink',
|
||||
}
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -282,15 +282,15 @@ def patch_shot(node_id, patch):
|
||||
node_setattr(node, key, value)
|
||||
else:
|
||||
# Remaining operations are for marking as 'in use' or 'not in use'.
|
||||
if node.get('_deleted', False) and op == u'unlink':
|
||||
if node.get('_deleted', False) and op == 'unlink':
|
||||
# We won't undelete a node in response to an unlink request.
|
||||
return pillar.api.utils.jsonify({'_deleted': True,
|
||||
'_etag': node['_etag'],
|
||||
'_id': node['_id']})
|
||||
|
||||
used_in_edit = {
|
||||
u'unlink': False,
|
||||
u'relink': True,
|
||||
'unlink': False,
|
||||
'relink': True,
|
||||
}[op]
|
||||
node['properties']['used_in_edit'] = used_in_edit
|
||||
|
||||
@@ -308,8 +308,8 @@ def assert_is_valid_patch(patch):
|
||||
raise wz_exceptions.BadRequest("PATCH should have a key 'op' indicating the operation.")
|
||||
|
||||
if op not in VALID_SHOT_PATCH_OPERATIONS:
|
||||
valid_ops = u', '.join(sorted(VALID_SHOT_PATCH_OPERATIONS))
|
||||
raise wz_exceptions.BadRequest(u'Operation should be one of %s' % valid_ops)
|
||||
valid_ops = ', '.join(sorted(VALID_SHOT_PATCH_OPERATIONS))
|
||||
raise wz_exceptions.BadRequest('Operation should be one of %s' % valid_ops)
|
||||
|
||||
if op not in VALID_SHOT_PATCH_FIELDS:
|
||||
# Valid operation, and we don't have to check the fields.
|
||||
@@ -324,7 +324,7 @@ def assert_is_valid_patch(patch):
|
||||
|
||||
disallowed_fields = fields - allowed_fields
|
||||
if disallowed_fields:
|
||||
raise wz_exceptions.BadRequest(u"Operation '%s' does not allow you to set fields %s" % (
|
||||
raise wz_exceptions.BadRequest("Operation '%s' does not allow you to set fields %s" % (
|
||||
op, disallowed_fields
|
||||
))
|
||||
|
||||
|
@@ -72,8 +72,8 @@ def activity_after_replacing_shot_asset(shot_or_asset, original):
|
||||
descr = 'changed the thumbnail of %s "%s"' % (typename, shot_or_asset['name'])
|
||||
elif key == 'properties.status':
|
||||
val_shot = pillar.web.jinja.format_undertitle(val_shot)
|
||||
elif isinstance(val_shot, basestring) and len(val_shot) > 80:
|
||||
val_shot = val_shot[:80] + u'…'
|
||||
elif isinstance(val_shot, str) and len(val_shot) > 80:
|
||||
val_shot = val_shot[:80] + '…'
|
||||
|
||||
if descr is None:
|
||||
# A name change activity contains both the old and the new name.
|
||||
|
@@ -1,7 +1,5 @@
|
||||
"""Subversion interface."""
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import collections
|
||||
import dateutil.parser
|
||||
import re
|
||||
|
@@ -36,7 +36,7 @@ def subversion_kick(project, attract_props):
|
||||
|
||||
|
||||
@api_blueprint.route('/<project_url>/subversion/log', methods=['POST'])
|
||||
@authorization.require_login(require_roles={u'service', u'svner'}, require_all=True)
|
||||
@authorization.require_login(require_roles={'service', 'svner'}, require_all=True)
|
||||
def subversion_log(project_url):
|
||||
if request.mimetype != 'application/json':
|
||||
log.warning('Received %s instead of application/json', request.mimetype)
|
||||
|
@@ -66,7 +66,7 @@ class TaskManager(object):
|
||||
task.description = fields.pop('description')
|
||||
task.properties.status = fields.pop('status')
|
||||
task.properties.task_type = fields.pop('task_type', None)
|
||||
if isinstance(task.properties.task_type, basestring):
|
||||
if isinstance(task.properties.task_type, str):
|
||||
task.properties.task_type = task.properties.task_type.strip() or None
|
||||
|
||||
due_date = fields.pop('due_date', None)
|
||||
@@ -150,13 +150,13 @@ class TaskManager(object):
|
||||
:type log_entry: attract.subversion.LogEntry
|
||||
"""
|
||||
|
||||
self._log.info(u"Task '%s' logged in SVN by %s: %s...",
|
||||
self._log.info("Task '%s' logged in SVN by %s: %s...",
|
||||
shortcode, log_entry.author, log_entry.msg[:30].replace('\n', ' // '))
|
||||
|
||||
# Find the task
|
||||
task = self.api_task_for_shortcode(shortcode)
|
||||
if not task:
|
||||
self._log.warning(u'Task %s not found, ignoring SVN commit.', shortcode)
|
||||
self._log.warning('Task %s not found, ignoring SVN commit.', shortcode)
|
||||
return
|
||||
|
||||
# Find the author
|
||||
@@ -164,7 +164,7 @@ class TaskManager(object):
|
||||
proj = db['projects'].find_one({'_id': task['project']},
|
||||
projection={'extension_props.attract': 1})
|
||||
if not proj:
|
||||
self._log.warning(u'Project %s for task %s not found, ignoring SVN commit.',
|
||||
self._log.warning('Project %s for task %s not found, ignoring SVN commit.',
|
||||
task['project'], task['_id'])
|
||||
return
|
||||
|
||||
@@ -175,7 +175,7 @@ class TaskManager(object):
|
||||
if user_id:
|
||||
msg = 'committed SVN revision %s: %s' % (log_entry.revision, log_entry.msg)
|
||||
else:
|
||||
self._log.warning(u'No Pillar user mapped for SVN user %s, using SVNer account.',
|
||||
self._log.warning('No Pillar user mapped for SVN user %s, using SVNer account.',
|
||||
log_entry.author)
|
||||
user_id = authentication.current_user_id()
|
||||
msg = 'committed SVN revision %s authored by SVN user %s: %s' % (
|
||||
|
@@ -112,7 +112,7 @@ def register_task_activity(task, descr):
|
||||
|
||||
def get_user_list(user_list):
|
||||
if not user_list:
|
||||
return u'-nobody-'
|
||||
return '-nobody-'
|
||||
|
||||
user_coll = current_app.db()['users']
|
||||
users = user_coll.find(
|
||||
@@ -123,7 +123,7 @@ def get_user_list(user_list):
|
||||
)
|
||||
|
||||
names = [user['full_name'] for user in users]
|
||||
return u', '.join(names)
|
||||
return ', '.join(names)
|
||||
|
||||
|
||||
@only_for_task
|
||||
@@ -150,8 +150,8 @@ def activity_after_replacing_task(task, original):
|
||||
human_key = 'assigned users'
|
||||
val_task = get_user_list(val_task)
|
||||
descr = 'assigned task "%s" to %s' % (task['name'], val_task)
|
||||
elif isinstance(val_task, basestring) and len(val_task) > 80:
|
||||
val_task = val_task[:80] + u'…'
|
||||
elif isinstance(val_task, str) and len(val_task) > 80:
|
||||
val_task = val_task[:80] + '…'
|
||||
|
||||
if descr is None:
|
||||
# A name change activity contains both the old and the new name.
|
||||
@@ -181,13 +181,13 @@ def activity_after_deleting_task(task):
|
||||
def set_defaults(task):
|
||||
from attract import shortcodes
|
||||
|
||||
shortcode = shortcodes.generate_shortcode(task['project'], task['node_type'], u'T')
|
||||
shortcode = shortcodes.generate_shortcode(task['project'], task['node_type'], 'T')
|
||||
task_properties = task.setdefault('properties', {})
|
||||
task_properties['shortcode'] = shortcode
|
||||
|
||||
# When the task is assigned to a user, this prevents a change of 'assigned_to' to a dict.
|
||||
# Instead, the activity will be registered on 'assigned_to.users', which is nicer.
|
||||
task_properties.setdefault('assigned_to', {u'users': []})
|
||||
task_properties.setdefault('assigned_to', {'users': []})
|
||||
|
||||
|
||||
def nodes_set_defaults(nodes):
|
||||
|
Reference in New Issue
Block a user