def remove_project( self ): project_name = str( self.project_combo.currentText() ) if project_name != "": dialog_value = utilities.yes_no_dialog( self, 'Delete Project', 'Are you sure you want to remove {0} project?'.format( project_name ) ) if dialog_value: project_file = '{0}{1}.project'.format( DATA_PATH, project_name ) if os.path.isfile( project_file ): try: os.remove( project_file ) except: pass utilities.add_remove_combo( self.project_combo, remove = True )
def remove_project(self): project_name = str(self.project_combo.currentText()) if project_name != "": dialog_value = utilities.yes_no_dialog( self, 'Delete Project', 'Are you sure you want to remove {0} project?'.format( project_name)) if dialog_value: project_file = '{0}{1}.project'.format(DATA_PATH, project_name) if os.path.isfile(project_file): try: os.remove(project_file) except: pass utilities.add_remove_combo(self.project_combo, remove=True)
def save_export_data(self, group_data, ps_path, ps_name): project_name = str(self.project_combo.currentText()) ps_location = '{0}{1}'.format(ps_path, ps_name) group_data['photoshop_file'] = ps_location load_projects = utilities.load_json_file('{0}{1}.project'.format( DATA_PATH, project_name)) null_file = False if load_projects['saved_files'] == []: load_projects['saved_files'] = [group_data] null_file = True for project in load_projects['saved_files']: if project == None: load_projects['saved_files'] = [group_data] null_file = True else: try: if project['photoshop_file'] == ps_location: update_low_groups = set(project['low']).intersection( group_data['low']) update_high_groups = set(project['high']).intersection( group_data['high']) new_low_grps = list( set(group_data['low']) - set(project['low'])) new_high_grps = list( set(group_data['high']) - set(project['high'])) for low_goup in update_low_groups: project['low'][low_goup] = group_data['low'][ low_goup] for high_goup in update_high_groups: project['high'][high_goup] = group_data['high'][ high_goup] for grp in new_low_grps: project['low'].update( {grp: group_data['low'][grp]}) for grp in new_high_grps: project['high'].update( {grp: group_data['high'][grp]}) except: pass new_project = False for project in load_projects['saved_files']: if not null_file: new_project = list( set([group_data['photoshop_file']]) - set([project['photoshop_file']])) if new_project == []: new_project = False break if new_project != False: load_projects['saved_files'].append(group_data) utilities.write_json_file( '{0}{1}.project'.format(DATA_PATH, project_name), load_projects) save_current_ps = utilities.yes_no_dialog( self, 'Save Photoshop Files', 'Would you like to save your current Photoshop file {0}{1}?'. format(ps_path, ps_name)) if save_current_ps: self.save_photoshop_file(ps_path, ps_name) self.message_report(error_level=0, message="Export completed!")
def save_export_data( self, group_data, ps_path, ps_name ): project_name = str( self.project_combo.currentText() ) ps_location = '{0}{1}'.format( ps_path, ps_name ) group_data['photoshop_file'] = ps_location load_projects = utilities.load_json_file( '{0}{1}.project'.format( DATA_PATH, project_name ) ) null_file = False if load_projects['saved_files'] == []: load_projects['saved_files'] = [group_data] null_file = True for project in load_projects['saved_files']: if project == None: load_projects['saved_files'] = [group_data] null_file = True else: try: if project['photoshop_file'] == ps_location: update_low_groups = set( project['low'] ).intersection( group_data['low'] ) update_high_groups = set( project['high'] ).intersection( group_data['high'] ) new_low_grps = list( set( group_data['low'] ) - set( project['low'] ) ) new_high_grps = list( set( group_data['high'] ) - set( project['high'] ) ) for low_goup in update_low_groups: project['low'][low_goup] = group_data['low'][low_goup] for high_goup in update_high_groups: project['high'][high_goup] = group_data['high'][high_goup] for grp in new_low_grps: project['low'].update( {grp: group_data['low'][grp]} ) for grp in new_high_grps: project['high'].update( {grp: group_data['high'][grp]} ) except: pass new_project = False for project in load_projects['saved_files']: if not null_file: new_project = list( set( [group_data['photoshop_file']] ) - set( [project['photoshop_file']] ) ) if new_project == []: new_project = False break if new_project != False: load_projects['saved_files'].append( group_data ) utilities.write_json_file( '{0}{1}.project'.format( DATA_PATH, project_name ), load_projects ) save_current_ps = utilities.yes_no_dialog( self, 'Save Photoshop Files', 'Would you like to save your current Photoshop file {0}{1}?'.format( ps_path, ps_name ) ) if save_current_ps: self.save_photoshop_file( ps_path, ps_name ) self.message_report( error_level = 0, message = "Export completed!" )