def __init__(self, parent=None, **kwargs): super(Window, self).__init__(parent) self.current_show = None if 'show' in kwargs: self.current_show = kwargs['show'] self.type = kwargs['type'] self.value = kwargs['value'] self.title = kwargs['title'] self.label = kwargs['label'] self.width = kwargs['width'] self.height = kwargs['height'] self.brows_directory = resources.getWorkspacePath() self.brows_directory = '/mnt/bkp/Icons gallery/icons_04' self.q_image, self.q_image_path = None, None # current input file self.file_path = os.path.join(resources.getInputPath(), '%s.json' % self.type) print 'db path', self.file_path self.connect = studioConnect.Connect(self.file_path, value=self.value) self.data, self.sort_data, self.all_input_data = self.connect.getInputData( ) self.module, self.lable, self.version = platforms.get_tool_kit() self.setup_ui() self.load_widgets()
def create(self, input_data): ''' Description - Creates and edit the exists show this function set to operate :param input_data <{}> exmple input_data = { 'pipe_maya_directory': '/usr/autodesk/maya2016', 'pipe_nuke_version': '2.7', 'pipe_site_packages_directory': '/usr/lib64/python2.7/site-packages', 'pipe_nuke_directory': '/mnt/bkp/Icons gallery/icons_04', 'pipe_python_directory': '/usr/bin/python', 'pipe_maya_version': '2016', 'pipe_studio_pipe_directory': '/venture/subins_tutorials/studioPipe', 'pipe_name': 'studio_pipe', 'pipe_shows_directory': '/home/shreya/Documents/studio_pipe/showsdfsfdsfdf' } :example from studioPipe.api import studioPreferences studio_preferences = studioPreferences.Connect() studio_preferences.create(input_data) ''' input_data['enable'] = True studio_input = studioConnect.Connect() dirname = os.path.join(resources.getWorkspacePath()) studio_input.createDb(dirname=self.dirname, localhost=self.localhost, name=self.name, type=self.type, tag=self.tag, data={input_data['pipe_name']: input_data})
def create(self, current_show, input_data): input_data['enabled'] = True studio_image = studioImage.ImageCalibration( imgae_file=input_data['discipline_icon']) q_image, q_image_path = studio_image.set_studio_size(width=256, height=256) icon_path = os.path.join( self.dirname, 'icons', '%s_%s%s' % (current_show, input_data['name'], self.icon_format)) input_data['discipline_icon'] = icon_path current_input_data = {input_data['name']: input_data} discipline_data = self.disciplineData(current_show, current_input_data) current_discipline_data = {current_show: discipline_data} studio_input = studioConnect.Connect() studio_input.createDb(dirname=self.dirname, localhost=self.localhost, name=self.name, type=self.type, tag=self.tag, data=current_discipline_data) if not os.path.isdir(os.path.dirname(icon_path)): os.makedirs(os.path.dirname(icon_path)) q_image.save(icon_path)
def getDisciplines(self, show): show_discipline_content = self.getDisciplineData(show) if show not in show_discipline_content: return None, None stdio_input = studioConnect.Connect(file_path=self.full_path) disciplines = stdio_input.sortData(data=show_discipline_content[show]) discipline_content = {} for k, v in show_discipline_content[show].items(): discipline_content.update(v) return disciplines, discipline_content
def getDescriptions(self, show): show_description_content = self.getDescriptionData(show) if show not in show_description_content: return None, None stdio_input = studioConnect.Connect(file_path=self.full_path) descriptions = stdio_input.sortData( data=show_description_content[show]) description_content = {} for k, v in show_description_content[show].items(): description_content.update(v) return descriptions, description_content
def create(self, input_data): ''' Description - Creates and edit the exists show this function set to operate :param na <str> exmple 'my_super_hero' :param dn <str> exmple 'My Super Hero' :param sn <str> exmple 'MSH' :param tp <str> exmple 'My Super Hero' :param ic <str> exmple '/tmp/hero.png' :example from studioPipe.api import studioShows ss = studioShows.Shows() ss.create(na='my_super_hero', dn = 'My Super Hero', sn = 'MSH', tp = 'My Super Hero', ic = '/tmp/hero.png' ) ''' if not self.studio_config.has_valid(): warnings.warn( 'not found studio preferences data, update the preferences and try', Warning) return if not os.path.isdir(self.dirname): warnings.warn('not found studio pipe directory', Warning) return if not os.path.isfile(input_data['show_icon']): warnings.warn('not found file %s' % input_data['show_icon'], Warning) return studio_image = studioImage.ImageCalibration( imgae_file=input_data['show_icon']) q_image, q_image_path = studio_image.set_studio_size( width=self.width, height=self.height) icon_path = os.path.join( self.dirname, 'icons', '%s%s' % (input_data['show_name'], self.icon_format)) input_data['show_icon'] = icon_path studio_input = studioConnect.Connect() studio_input.createDb( dirname=self.dirname, localhost=self.localhost, name=self.name, type=self.type, tag=self.tag, data={input_data['show_name']: input_data} ) if not os.path.isdir(os.path.dirname(icon_path)): os.makedirs(os.path.dirname(icon_path)) q_image.save(icon_path)
def create(self, show, description, discipline, input_data): ''' Description - Creates and edit the exists show this function set to operate :param na <str> exmple 'my_super_hero' :param dn <str> exmple 'My Super Hero' :param sn <str> exmple 'MSH' :param tp <str> exmple 'My Super Hero' :param ic <str> exmple '/tmp/hero.png' :example from studioPipe.api import studioShows ss = studioShows.Shows() ss.create(na='my_super_hero', dn = 'My Super Hero', sn = 'MSH', tp = 'My Super Hero', ic = '/tmp/hero.png' ) ''' if not self.studio_config.has_valid(): warnings.warn( 'not found studio preferences data, update the preferences and try', Warning) return if not os.path.isdir(self.dirname): warnings.warn('not found studio pipe directory', Warning) return studio_discipline = studioDiscipline.Connect() discipline_data = studio_discipline.getSpecificTypes(show) disciplines = discipline_data[description] exists_data = self.headerData(show, discipline, disciplines, input_data) #======================================================================= # all_data = {} # for k, v in input_data.items(): # each_data = {} # for each in disciplines[description]: # each_data.setdefault(each, v) # all_data.setdefault(k, each_data) #======================================================================= current_data = {show: exists_data} studio_input = studioConnect.Connect() studio_input.createDb(dirname=self.dirname, localhost=self.localhost, name=self.name, type=self.type, tag=self.tag, data=current_data)
def getOutputData(self): ''' Description -function set for get exists show or shows data. :paran show_name <str> exmple 'my_super_hero' :return <dict> :example from studioPipe.api import studioShows ss = studioShows.Shows() ss.get('my_super_hero') ''' stdio_input = studioConnect.Connect(file_path=self.full_path) output_data = stdio_input.getOutputData() return output_data
def getShows(self): ''' Description -function set for get show list. :paran <None> :return <list> :example from studioPipe.api import studioShows ss = studioShows.Shows() ss.getShows() ''' stdio_input = studioConnect.Connect(file_path=self.full_path) data = stdio_input.sortData() return data
def getShowData(self, show, data=None): if not data: studio_connect = studioConnect.Connect(file_path=self.full_path) data, rollback_data, sort_data = studio_connect.getAllData() show_index = 0 show_data = {} for index, content in data.items(): if show not in content: continue show_data = content[show] show_index = index break return show_data, show_index
def getOutputData(self): ''' Description -function set for get exists item or items data. :paran item_name <str> exmple 'my_super_hero' :return <dict> :example from studioPipe.api import studioPreferences studio_preferences = studioPreferences.Connect() studio_preferences.getOutputData() ''' studio_output = studioConnect.Connect(file_path=self.full_path) data = studio_output.getOutputData() return data['0']['studio_pipe']
def getInputData(self): ''' Description -function set for get the show input data. :paran <None> :return (<dict>, <list>) :example from studioPipe.api import studioShows ss = studioShows.Shows() ss.getInputData('my_super_hero') ''' input_file = os.path.join(resources.getInputPath(), 'discipline.json') studio_input = studioConnect.Connect(file_path=input_file) data, sort_data, key_data = studio_input.getInputData() return data, sort_data, key_data
def create(self, current_show, description, input_data): input_data['enabled'] = True input_data['name'] = self.description_type[description] current_input_data = {input_data['name']: input_data} description_data = self.tierData(current_show, current_input_data) current_description_data = {current_show: description_data} studio_input = studioConnect.Connect() studio_input.createDb(dirname=self.dirname, localhost=self.localhost, name=self.name, type=self.type, tag=self.tag, data=current_description_data)
def getInputData(self): ''' Description -function set for get the show input data. :paran <None> :return (<dict>, <list>, <dict>) :example from studioPipe.api import studioPreferences studio_preferences = studioPreferences.Connect() studio_preferences.getInputData() ''' input_file = os.path.join(resources.getInputPath(), 'preferences.json') studio_input = studioConnect.Connect(file_path=input_file) data, sort_input_data, key_data = studio_input.getInputData() return data, sort_input_data, key_data
def has(self, discipline_name): ''' Description -function set for validate the show. :paran show_name <str> example 'my_super_hero' :return <bool> :example from studioPipe.api import studioShows ss = studioShows.Shows() ss.hasShow('my_super_hero') ''' stdio_input = studioConnect.Connect(file_path=self.full_path) disciplines = stdio_input.sortData() if discipline_name in disciplines: return True return False
def tierData(self, show, current_data): studio_connect = studioConnect.Connect(file_path=self.full_path) data, rollback_data, sort_data = studio_connect.getAllData() exists_data = {} if data: for index, content in data.items(): for k, v in content.items(): if show != k: continue exists_data = v break rollback_data = self.rollback(exists_data) pprint(rollback_data) length = len(exists_data) for k, v in current_data.items(): if k in rollback_data: length = rollback_data[k] exists_data[length] = {k: v} return exists_data
def getDisciplineData(self, show): ''' Description -function set for get show list. :paran <None> :return <list> :example from studioPipe.api import studioShows ss = studioShows.Shows() ss.getShows() ''' stdio_input = studioConnect.Connect(file_path=self.full_path) data = stdio_input.getAllData() show_discipline_content = {} for k, v in data[0].items(): if show not in v: continue show_discipline_content = v break return show_discipline_content
def getOutputData(self, show_name=None): ''' Description -function set for get exists show or shows data. :paran show_name <str> exmple 'my_super_hero' :return <dict> :example from studioPipe.api import studioShows ss = studioShows.Shows() ss.get('my_super_hero') ''' stdio_input = studioConnect.Connect(file_path=self.full_path) output_data = stdio_input.getOutputData(tag_name=show_name) if not output_data: warnings.warn('not fount data') return if show_name not in output_data: warnings.warn('not fount %s data' % show_name) return return output_data[show_name]
def headerData(self, show, discipline, disciplines, current_data): # show, discipline, input_data studio_connect = studioConnect.Connect(file_path=self.full_path) data, rollback_data, sort_data = studio_connect.getAllData() show_data, show_index = self.getShowData(show, data=data) new_header = list(set(current_data.keys()) - set(show_data.keys())) for index, discipline_content in show_data.items(): if index in new_header: continue for each_discipline, content in discipline_content.items(): # update all discipline header name content['name']['value'] = current_data[index]['name'] if discipline not in each_discipline: continue # update specific discipline header values for k, v in current_data[index].items(): content[k]['value'] = current_data[index][k] # create new header disciplines new_data = {} for index in new_header: new_discipline_data = {} for each_discipline in disciplines: new_header_data = {} for each_header, values in current_data[index].items(): values = {'value': values} new_header_data.setdefault(each_header, values) new_discipline_data.setdefault(each_discipline, new_header_data) new_data.setdefault(index, new_discipline_data) show_data.update(new_data) # replace the specific show data #======================================================================= # data[show_index].pop(show) # data[show_index] = {show: show_data} #======================================================================= return show_data
def getSpecificValue(self, key, value): stdio_input = studioConnect.Connect(file_path=self.full_path) data = stdio_input.getSpecificValue(key, value) return data
def getDisciplineAllData(self): stdio_input = studioConnect.Connect(file_path=self.full_path) data = stdio_input.getAllData() return data
def getShows(self): stdio_input = studioConnect.Connect(file_path=self.full_path) data = stdio_input.sortData() return data