MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / _check_protected_path

Method _check_protected_path

bleachbit/GuiPreferences.py:771–814  ·  view source on GitHub ↗

Check if path is protected and warn user if so. Returns True if it's safe to proceed, False if user cancelled.

(self, pathname)

Source from the content-addressed store, hash-verified

769 return False
770
771 def _check_protected_path(self, pathname):
772 """Check if path is protected and warn user if so.
773
774 Returns True if it's safe to proceed, False if user cancelled.
775 """
776 logger.debug("Checking protected path: %s", pathname)
777 match_info = ProtectedPath.check_protected_path(pathname)
778 if match_info is None:
779 return True
780
781 if not options.get('expert_mode'):
782 self.show_infobar(
783 # TRANSLATORS: Error message shown in the infobar.
784 _("This path is protected. To bypass protection, enable expert mode."),
785 Gtk.MessageType.WARNING)
786 return False
787
788 # Check if user already confirmed this path
789 normalized = ProtectedPath._normalize_for_comparison(
790 pathname, match_info['case_sensitive'])
791 warning_key = 'protected_path:' + normalized
792 if options.get_warning_preference(warning_key):
793 return True
794
795 # Calculate impact
796 # FIXME later: this can be very slow with many objects
797 logger.debug("Checking protected path impact: %s", pathname)
798 impact = ProtectedPath.calculate_impact(pathname)
799
800 # Generate warning message
801 warning_msg = ProtectedPath.get_warning_message(pathname, impact)
802
803 # Show warning dialog
804 confirmed, remember = GuiBasic.warning_confirm_dialog(
805 self.dialog,
806 # TRANSLATORS: Title of warning dialog shown when adding a protected path.
807 _("Protected Path"),
808 warning_msg
809 )
810
811 if confirmed and remember:
812 options.remember_warning_preference(warning_key)
813
814 return confirmed
815
816 def _add_path(self, pathname, path_type, page_type, liststore, pathnames):
817 """Common function to add a path to either whitelist or custom list"""

Callers 1

_add_pathMethod · 0.95

Calls 4

show_infobarMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected