From 895af6035514f70f528a84607d0c8ee2232dc6af Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Mon, 21 Jan 2019 18:47:30 +0100 Subject: [PATCH] djvwie action inheritate from base handler, formatted to flake8 --- .../actions/{djvview.py => action_djvview.py} | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) rename pype/ftrack/actions/{djvview.py => action_djvview.py} (95%) diff --git a/pype/ftrack/actions/djvview.py b/pype/ftrack/actions/action_djvview.py similarity index 95% rename from pype/ftrack/actions/djvview.py rename to pype/ftrack/actions/action_djvview.py index 662b26cfd4..0be3624f2d 100644 --- a/pype/ftrack/actions/djvview.py +++ b/pype/ftrack/actions/action_djvview.py @@ -5,27 +5,25 @@ import os import re from operator import itemgetter import ftrack_api -from app.api import Logger +from pype.ftrack import BaseHandler -class DJVViewAction(object): +class DJVViewAction(BaseHandler): """Launch DJVView action.""" identifier = "djvview-launch-action" # label = "DJV View" # icon = "http://a.fsdn.com/allura/p/djv/icon" + type = 'Application' def __init__(self, session): '''Expects a ftrack_api.Session instance''' - - self.log = Logger.getLogger(self.__class__.__name__) + super().__init__(session) if self.identifier is None: raise ValueError( 'Action missing identifier.' ) - self.session = session - def is_valid_selection(self, event): selection = event["data"].get("selection", []) @@ -87,11 +85,6 @@ class DJVViewAction(object): ), self.launch ) - self.log.info( - "Action '{}' - Registered successfully".format( - self.__class__.__name__ - ) - ) def get_applications(self): applications = [] @@ -346,15 +339,21 @@ class DJVViewAction(object): try: # TODO This is proper way to get filepath!!! # THIS WON'T WORK RIGHT NOW - location = component['component_locations'][0]['location'] + location = component[ + 'component_locations' + ][0]['location'] file_path = location.get_filesystem_path(component) # if component.isSequence(): # if component.getMembers(): - # frame = int(component.getMembers()[0].getName()) + # frame = int( + # component.getMembers()[0].getName() + # ) # file_path = file_path % frame except Exception: # This works but is NOT proper way - file_path = component['component_locations'][0]['resource_identifier'] + file_path = component[ + 'component_locations' + ][0]['resource_identifier'] event["data"]["items"].append( {"label": label, "value": file_path} @@ -382,7 +381,7 @@ class DJVViewAction(object): } -def register(session, **kw): +def register(session): """Register hooks.""" if not isinstance(session, ftrack_api.session.Session): return