def commit(self): path = str(self.opt_auto_add_path.text()).strip() if path != gprefs['auto_add_path']: if path: path = os.path.abspath(path) self.opt_auto_add_path.setText(path) if not os.path.isdir(path): error_dialog( self, _('Invalid folder'), _('You must specify an existing folder as your ' 'auto-add folder. %s does not exist.') % path, show=True) raise AbortCommit('invalid auto-add folder') if not os.access(path, os.R_OK | os.W_OK): error_dialog( self, _('Invalid folder'), _('You do not have read/write permissions for ' 'the folder: %s') % path, show=True) raise AbortCommit('invalid auto-add folder') if os.path.basename(path)[0] in '._': error_dialog( self, _('Invalid folder'), _('Cannot use folders whose names start with a ' 'period or underscore: %s') % os.path.basename(path), show=True) raise AbortCommit('invalid auto-add folder') if not question_dialog( self, _('Are you sure?'), _('<b>WARNING:</b> Any files you place in %s will be ' 'automatically deleted after being added to ' 'calibre. Are you sure?') % path): return pattern = self.filename_pattern.commit() prefs['filename_pattern'] = pattern fmts = self.current_blocked_auto_formats old = gprefs['blocked_auto_formats'] changed = set(fmts) != set(old) if changed: gprefs['blocked_auto_formats'] = self.current_blocked_auto_formats if self.tag_map_rules is not None: if self.tag_map_rules: gprefs['tag_map_on_add_rules'] = self.tag_map_rules else: gprefs.pop('tag_map_on_add_rules', None) if self.add_filter_rules is not None: if self.add_filter_rules: gprefs['add_filter_rules'] = self.add_filter_rules else: gprefs.pop('add_filter_rules', None) ret = ConfigWidgetBase.commit(self) return changed or ret
def commit(self): path = unicode(self.opt_auto_add_path.text()).strip() if path != gprefs["auto_add_path"]: if path: path = os.path.abspath(path) self.opt_auto_add_path.setText(path) if not os.path.isdir(path): error_dialog( self, _("Invalid folder"), _("You must specify an existing folder as your " "auto-add folder. %s does not exist.") % path, show=True, ) raise AbortCommit("invalid auto-add folder") if not os.access(path, os.R_OK | os.W_OK): error_dialog( self, _("Invalid folder"), _("You do not have read/write permissions for " "the folder: %s") % path, show=True, ) raise AbortCommit("invalid auto-add folder") if not question_dialog( self, _("Are you sure?"), _( "<b>WARNING:</b> Any files you place in %s will be " "automatically deleted after being added to " "calibre. Are you sure?" ) % path, ): return pattern = self.filename_pattern.commit() prefs["filename_pattern"] = pattern fmts = self.current_blocked_auto_formats old = gprefs["blocked_auto_formats"] changed = set(fmts) != set(old) if changed: gprefs["blocked_auto_formats"] = self.current_blocked_auto_formats if self.tag_map_rules is not None: if self.tag_map_rules: gprefs["tag_map_on_add_rules"] = self.tag_map_rules else: gprefs.pop("tag_map_on_add_rules", None) if self.add_filter_rules is not None: if self.add_filter_rules: gprefs["add_filter_rules"] = self.add_filter_rules else: gprefs.pop("add_filter_rules", None) ret = ConfigWidgetBase.commit(self) return changed or ret
def commit(self): path = unicode(self.opt_auto_add_path.text()).strip() if path != gprefs['auto_add_path']: if path: path = os.path.abspath(path) self.opt_auto_add_path.setText(path) if not os.path.isdir(path): error_dialog(self, _('Invalid folder'), _('You must specify an existing folder as your ' 'auto-add folder. %s does not exist.')%path, show=True) raise AbortCommit('invalid auto-add folder') if not os.access(path, os.R_OK|os.W_OK): error_dialog(self, _('Invalid folder'), _('You do not have read/write permissions for ' 'the folder: %s')%path, show=True) raise AbortCommit('invalid auto-add folder') if os.path.basename(path)[0] in '._': error_dialog(self, _('Invalid folder'), _('Cannot use folders whose names start with a ' 'period or underscore: %s')%os.path.basename(path), show=True) raise AbortCommit('invalid auto-add folder') if not question_dialog(self, _('Are you sure?'), _('<b>WARNING:</b> Any files you place in %s will be ' 'automatically deleted after being added to ' 'calibre. Are you sure?')%path): return pattern = self.filename_pattern.commit() prefs['filename_pattern'] = pattern fmts = self.current_blocked_auto_formats old = gprefs['blocked_auto_formats'] changed = set(fmts) != set(old) if changed: gprefs['blocked_auto_formats'] = self.current_blocked_auto_formats if self.tag_map_rules is not None: if self.tag_map_rules: gprefs['tag_map_on_add_rules'] = self.tag_map_rules else: gprefs.pop('tag_map_on_add_rules', None) if self.add_filter_rules is not None: if self.add_filter_rules: gprefs['add_filter_rules'] = self.add_filter_rules else: gprefs.pop('add_filter_rules', None) ret = ConfigWidgetBase.commit(self) return changed or ret