def import_profile(self): src = dialogs.get_open_file_name(self, config.profile_import_dir, _('Select profile to import'), file_types=[ICC, ICM]) if not src: return name = get_profile_name(src) title = self.app.appdata.app_name if name is None: msg = _('Cannot open profile') msg = "%s '%s'" % (msg, src) sec = _('The profile may be corrupted or in an unsupported format') wal.error_dialog(self, title, msg + '\n' + sec) return if name in self.pf_list: msg = _('Selected profile cannot be added to profile list:') msg = "%s '%s'" % (msg, name) sec = _('It seems like you have already imported this profile') wal.error_dialog(self, title, msg + '\n' + sec) return filename = os.path.basename(src) dst_dir = self.app.appdata.app_color_profile_dir dst = os.path.join(dst_dir, filename) if fsutils.exists(dst): msg = _('Selected file has been added to profile pool') msg = "%s '%s'" % (msg, src) sec = _('If you still wish to import the file, try renaming it') wal.error_dialog(self, title, msg + '\n' + sec) return try: shutil.copy(fsutils.get_sys_path(src), fsutils.get_sys_path(dst)) except Exception: msg = _('Cannot copy file') msg = "%s '%s'" % (msg, src) sec = _('Please check write permissions for config directory:') sec += '\n%s' % dst_dir wal.error_dialog(self, title, msg + '\n' + sec) return config.profile_import_dir = os.path.dirname(src) self.profiles[name] = filename self.apply_changes() self.viewer.set_active(self.pf_list.index(name))
def import_profile(self): src = dialogs.get_open_file_name(self, self, config.profile_import_dir, _('Select profile to import'), file_types=[ICC, ICM]) if not src: return name = get_profile_name(src) title = self.app.appdata.app_name if name is None: msg = _('Cannot open profile') msg = "%s '%s'" % (msg, src) sec = _('The profile may be corrupted or not supported format') wal.error_dialog(self, title, msg + '\n' + sec) return if name in self.pf_list: msg = _('Selected profile cannot be added to profile list:') msg = "%s '%s'" % (msg, name) sec = _('It seems you have imported this profile') wal.error_dialog(self, title, msg + '\n' + sec) return filename = os.path.basename(src) dst_dir = self.app.appdata.app_color_profile_dir dst = os.path.join(dst_dir, filename) if os.path.lexists(dst): msg = _('Selected file has been added to profile pool') msg = "%s '%s'" % (msg, src) sec = _('If you sure to import the file try renaming it') wal.error_dialog(self, title, msg + '\n' + sec) return try: shutil.copy(src, dst) except: msg = _('Cannot copy file') msg = "%s '%s'" % (msg, src) sec = _('Please check writing permissions for config directory:') sec += '\n%s' % dst_dir wal.error_dialog(self, title, msg + '\n' + sec) return config.profile_import_dir = os.path.dirname(src) self.profiles[name] = filename self.apply_changes() self.viewer.set_active(self.pf_list.index(name))
def import_profile(self, *args): src = get_profile_import_dialog(self.dlg, self.app, config.profile_import_dir) if not src: return name = get_profile_name(src) if name is None: msg = _('Cannot open profile') msg = "%s '%s'" % (msg, src) sec = _('The profile may be corrupted or not supported format') wal.error_dialog(self.dlg, self.app.appdata.app_name, msg, sec) return if name in self.pf_list: msg = _('Selected profile cannot be added to profile list:') msg = "%s '%s'" % (msg, name) sec = _('It seems you have imported this profile') wal.error_dialog(self.dlg, self.app.appdata.app_name, msg, sec) return filename = os.path.basename(src) dst_dir = self.app.appdata.app_color_profile_dir dst = os.path.join(dst_dir, filename) if os.path.lexists(dst): msg = _('Selected file has been added to profile pool') msg = "%s '%s'" % (msg, src) sec = _('If you sure to import the file try renaming it') wal.error_dialog(self.dlg, self.app.appdata.app_name, msg, sec) return try: shutil.copy(src, dst) except: msg = _('Cannot copy file') msg = "%s '%s'" % (msg, src) sec = _( 'Please check writing permissions for config directory:\n%s' % dst_dir) wal.error_dialog(self.dlg, self.app.appdata.app_name, msg, sec) return config.profile_import_dir = os.path.dirname(src) self.profiles[name] = filename self.apply_changes()
def change_config(options): config = uc2.config if len(options) < 2: echo('Please provide configuration values to change.') return for key, value in options.items(): if key in BOOL_ATTRS: config.__dict__[key] = bool(value) elif key == 'log_level': if value in LEVELS: config.log_level = value elif key in INTENT_ATTRS: if isinstance(value, int) and value in INTENTS: config.__dict__[key] = value elif value in INTENTS: config.__dict__[key] = INTENTS[value] elif key in PROFILES and isinstance(value, str): if not value: config.__dict__[key] = '' continue cs = uc2const.COLORSPACES[PROFILES.index(key)] path = fsutils.normalize_path(value) if not fsutils.exists(path): echo('ERROR: file "%s" is not found!' % path) continue profile_name = cms.get_profile_name(path) if not profile_name: echo('ERROR: file "%s" is not valid color profile!' % path) continue profile_dir = config.app.appdata.app_color_profile_dir dest_path = os.path.join(profile_dir, '%s.icc' % cs) if fsutils.exists(dest_path): fsutils.remove(dest_path) fsutils.copy(path, dest_path) profile_dict = PROFILE_DICTS[PROFILES.index(key)] config.__dict__[profile_dict] = {profile_name: dest_path} config.__dict__[key] = profile_name
def import_profile(self, *args): src = get_profile_import_dialog(self.dlg, self.app, config.profile_import_dir) if not src: return name = get_profile_name(src) if name is None: msg = _('Cannot open profile') msg = "%s '%s'" % (msg, src) sec = _('The profile may be corrupted or not supported format') wal.error_dialog(self.dlg, self.app.appdata.app_name, msg, sec) return if name in self.pf_list: msg = _('Selected profile cannot be added to profile list:') msg = "%s '%s'" % (msg, name) sec = _('It seems you have imported this profile') wal.error_dialog(self.dlg, self.app.appdata.app_name, msg, sec) return filename = os.path.basename(src) dst_dir = self.app.appdata.app_color_profile_dir dst = os.path.join(dst_dir, filename) if os.path.lexists(dst): msg = _('Selected file has been added to profile pool') msg = "%s '%s'" % (msg, src) sec = _('If you sure to import the file try renaming it') wal.error_dialog(self.dlg, self.app.appdata.app_name, msg, sec) return try: shutil.copy(src, dst) except: msg = _('Cannot copy file') msg = "%s '%s'" % (msg, src) sec = _('Please check writing permissions for config directory:\n%s' % dst_dir) wal.error_dialog(self.dlg, self.app.appdata.app_name, msg, sec) return config.profile_import_dir = os.path.dirname(src) self.profiles[name] = filename self.apply_changes()