def read_data(path): label, name, version = resources.getToolKit() data = {} element = ElementTree.parse(path) root = element.getroot() if root.tag != 'studio_maya': return data for each in ['version', 'type', 'label']: if each not in root.keys(): return if root.get('version') != version: return if root.get('type') != 'studio_maya_data': return if root.get('label') != 'Studio Maya Interpreter': return for child in root.getchildren(): type = child.tag content_data = {} for sub_element in child.getchildren(): if sub_element.tag != 'content': continue current_index = sub_element.get('index') label = sub_element.get('label') path = sub_element.get('path') contents = {'label': label.encode(), 'path': path.encode()} content_data.setdefault(int(current_index), contents) data.setdefault(type, content_data) return data
def collect_data(self): current_maya = self.combobox_maya.currentText() maya_path = self.lineedit_directory.text() edit = True save = True if self.checkbox_query.isChecked(): edit = False if self.checkbox_overwrite.isChecked(): save = False label, name, version = resources.getToolKit() maya_versions = self.get_maya_versions() data = { 'parent': { 'studio_maya': { 'label': label, 'version': version, 'type': 'preset', } }, 'child': { 'maya': { 'current_version': current_maya.encode(), 'path': maya_path.encode(), 'maya_versions': maya_versions }, 'settings': { 'edit': edit, 'save': save } } } return data
def __init__(self, parent=None, **kwargs): super(Window, self).__init__(parent=None) self.main_window = parent self.label, self.name, self.version = resources.getToolKit() self.preference_path = resources.getPreferenceFile() self.roo_path, self.tag, self.mayapy_type = resources.getRootPath() self.brows_directory = self.roo_path self.labels = [] if 'lables' in kwargs: self.labels = kwargs['lables'] self.width, self.height = 750, 383 self.setup_ui() self.set_parameters()
def read_preset(path): if not os.path.isfile(path): return label, name, version = resources.getToolKit() data = {} element = ElementTree.parse(path) root = element.getroot() if root.tag != 'studio_maya': return data for each in ['version', 'type', 'label']: if each not in root.keys(): return if root.get('version') != version: return if root.get('type') != 'preset': return if root.get('label') != 'Studio Maya Interpreter': return maya_versions = [] current_version = None current_path = None query = True edit = False overwrite = True version = False for child in root.getchildren(): if child.tag == 'maya': maya_versions = ast.literal_eval(child.get('maya_versions')) current_version = child.get('current_version') current_path = child.get('path') if child.tag == 'settings': edit = ast.literal_eval(child.get('edit')) version = ast.literal_eval(child.get('save')) if edit: query = False if version: overwrite = False data['maya_versions'] = maya_versions data['current_version'] = { 'index': maya_versions.index(current_version), 'name': current_version, 'path': current_path } data['mode'] = { "query_only": query, "edit_quey": edit, "overwrite": overwrite, "next_version": version } return data
def get_preference_data(self, input='json'): label, name, version = resources.getToolKit() if input == 'xml': input_data = generic.read_preset(self.preference_path) elif input == 'interface': maya_versions = self.get_maya_versions() settings_data = self.get_settings_data() index, name = self.get_current_version() input_data = { 'maya_versions': maya_versions, 'mode': settings_data, 'current_version': { 'index': index, 'name': name } } else: maya_input = inputs.Connect() input_data = maya_input.get_data() return input_data
def save_to(self): label, name, version = resources.getToolKit() maya_data = widgets.get_item_contents(self.treewidget_maya, 1) code_data = widgets.get_item_contents(self.treewidget_code, 1) data = { 'parent': { 'studio_maya': { 'label': label, 'version': version, 'type': 'studio_maya_data', } }, 'child': { 'maya': maya_data, 'code': code_data } } generic.write_data(data, self.current_file) self.setWindowTitle(self.current_file) print 'Successfully saved to %s' % self.current_file
def __init__(self, parent=None): super(MayaWindow, self).__init__(parent) self.label, self.name, self.version = resources.getToolKit() self.width, self.height = 1000, 900 self.browse_path = resources.getWorkspacePath() self.preference_path = resources.getPreferenceFile() self.current_file = None self.current_treewidget = None self.pause = False self.stop = False self.operating_system = resources.getOperatingSystem() self.thread_status = [] self.style = stylesheet.connect() self.setup_ui() self.modify_widgets() self.preference = preference.Window( parent=self, lables=[self.label_mayalogo, self.label_maya]) self.preference.setStyleSheet(self.style) self.set_toolbar(self.horizontallayout_bar) self.set_maya_version() self.custom_console = console.Connect() self.custom_console.stdout().message_written.connect( self.textedit_output.insertPlainText)