removed unnecessary lines and files

This commit is contained in:
Jakub Trllo 2019-04-19 21:35:27 +02:00
parent 6157dff134
commit b364cc443f
5 changed files with 1 additions and 142 deletions

View file

@ -3,11 +3,9 @@ import sys
import logging
import argparse
import re
# import json
from pype.vendor import ftrack_api
from pype.ftrack import BaseAction
# from pype import api as pype, lib as pypelib
from avalon import lib as avalonlib
from avalon.tools.libraryloader.io_nonsingleton import DbConnector
from pypeapp import config, Anatomy
@ -239,17 +237,6 @@ class CreateFolders(BaseAction):
output.extend(self.get_notask_children(child))
return output
# def get_presets(self):
# fpath_items = [pypelib.get_presets_path(), 'tools', 'sw_folders.json']
# filepath = os.path.normpath(os.path.sep.join(fpath_items))
# presets = dict()
# try:
# with open(filepath) as data_file:
# presets = json.load(data_file)
# except Exception as e:
# self.log.warning('Wasn\'t able to load presets')
# return dict(presets)
def template_format(self, template, data):
partial_data = PartialDict(data)

View file

@ -42,7 +42,7 @@ class CreateProjectFolders(BaseAction):
else:
project = entity['project']
presets = config.load_presets()['tools']['project_folder_structure']
presets = config.get_presets()['tools']['project_folder_structure']
try:
# Get paths based on presets
basic_paths = self.get_path_items(presets)
@ -142,28 +142,6 @@ class CreateProjectFolders(BaseAction):
self.session.commit()
return new_ent
# def load_presets(self):
# preset_items = [
# pypelib.get_presets_path(),
# 'tools',
# 'project_folder_structure.json'
# ]
# filepath = os.path.sep.join(preset_items)
#
# # Load folder structure template from presets
# presets = dict()
# try:
# with open(filepath) as data_file:
# presets = json.load(data_file)
# except Exception as e:
# msg = 'Unable to load Folder structure preset'
# self.log.warning(msg)
# return {
# 'success': False,
# 'message': msg
# }
# return presets
def get_path_items(self, in_dict):
output = []
for key, value in in_dict.items():

View file

@ -23,9 +23,7 @@ class DJVViewAction(BaseAction):
'''Expects a ftrack_api.Session instance'''
super().__init__(session)
self.djv_path = None
self.config_data = None
# self.load_config_data()
self.config_data = config.get_presets()['djv_view']['config']
self.set_djv_path()
@ -54,22 +52,6 @@ class DJVViewAction(BaseAction):
return True
return False
def load_config_data(self):
# path_items = [pypelib.get_presets_path(), 'djv_view', 'config.json']
path_items = config.get_presets()['djv_view']['config']
filepath = os.path.sep.join(path_items)
data = dict()
try:
with open(filepath) as data_file:
data = json.load(data_file)
except Exception as e:
log.warning(
'Failed to load data from DJV presets file ({})'.format(e)
)
self.config_data = data
def set_djv_path(self):
for path in self.config_data.get("djv_paths", []):
if os.path.exists(path):

View file

@ -39,7 +39,6 @@ class RVAction(BaseAction):
)
else:
# if not, fallback to config file location
# self.load_config_data()
self.config_data = config.get_presets()['djv_view']['config']
self.set_rv_path()
@ -61,21 +60,6 @@ class RVAction(BaseAction):
return True
return False
def load_config_data(self):
path_items = config.get_presets['rv']['config.json']
filepath = os.path.sep.join(path_items)
data = dict()
try:
with open(filepath) as data_file:
data = json.load(data_file)
except Exception as e:
log.warning(
'Failed to load data from RV presets file ({})'.format(e)
)
self.config_data = data
def set_rv_path(self):
self.rv_path = self.config_data.get("rv_path")

View file

@ -1,72 +0,0 @@
from pype.vendor import ftrack_api
from pype.ftrack import BaseEvent
class CollectEntities(BaseEvent):
priority = 1
def _launch(self, event):
entities = self.translate_event(event)
event['data']['entities_object'] = entities
return
def translate_event(self, event):
selection = event['data'].get('selection', [])
entities = list()
for entity in selection:
ent = self.session.get(
self.get_entity_type(entity),
entity.get('entityId')
)
entities.append(ent)
return entities
def get_entity_type(self, entity):
'''Return translated entity type tht can be used with API.'''
# Get entity type and make sure it is lower cased. Most places except
# the component tab in the Sidebar will use lower case notation.
entity_type = entity.get('entityType').replace('_', '').lower()
for schema in self.session.schemas:
alias_for = schema.get('alias_for')
if (
alias_for and isinstance(alias_for, str) and
alias_for.lower() == entity_type
):
return schema['id']
for schema in self.session.schemas:
if schema['id'].lower() == entity_type:
return schema['id']
raise ValueError(
'Unable to translate entity type: {0}.'.format(entity_type)
)
def register(self):
self.session.event_hub.subscribe(
'topic=ftrack.action.discover'
' and source.user.username={0}'.format(self.session.api_user),
self._launch,
priority=self.priority
)
self.session.event_hub.subscribe(
'topic=ftrack.action.launch'
' and source.user.username={0}'.format(self.session.api_user),
self._launch,
priority=self.priority
)
def register(session, **kw):
'''Register plugin. Called when used as an plugin.'''
if not isinstance(session, ftrack_api.session.Session):
return
CollectEntities(session).register()