Ejemplo n.º 1
0
    def __init__(self, widget=None, exclusion_rules=None):
        super(PreferencesWidget, self).__init__(widget)
        self.ui = Ui_Preferences()
        self.ui.setupUi(self)

        if exclusion_rules == None:
            exclusion_rules = ExclusionRules()

        self.ui.buttonBox.clicked.connect(self.__onButtonClicked)
        self.ui.buttonBox.button(QDialogButtonBox.Ok).setText("Save")

        self.ui.addFileButton.clicked.connect(self.__onAddFile)
        self.ui.addDirButton.clicked.connect(self.__onAddDir)
        self.ui.addRegButton.clicked.connect(self.__onAddReg)

        self.ui.deleteFileButton.clicked.connect(
            lambda: self.__removeSelectedItems(self.ui.treeViewFiles))
        self.ui.deleteDirButton.clicked.connect(
            lambda: self.__removeSelectedItems(self.ui.treeViewDirs))
        self.ui.deleteRegButton.clicked.connect(
            lambda: self.__removeSelectedItems(self.ui.treeViewReg))
        self.ui.lblExpressionHintLink.linkActivated.connect(
            self.__onHelpLinkActivated)

        if not Platform.isWindows:
            self.ui.tabWidget.removeTab(2)

        self.rules = exclusion_rules
Ejemplo n.º 2
0
class TestExclusionRules(unittest.TestCase):
	def setUp(self):
		self.r = ExclusionRules(settings = QSettings())

	def test_can_store_changes_to_file_exclusions(self):
		new_rule = ".* last rule.*"

		# adds a new rule
		rules = self.r.fileExcludes()
		rules.append(new_rule)
		self.r.setFileExcludes(rules)

		self.assertEqual("FileWave", self.r.settings.organizationName())
		self.assertEqual("UnitTest", self.r.settings.applicationName())

		# fetch and test (the self.r rules are stored/read in default QSettings, unit test main sets this up)
		p = DirectoryScanner()
		self.assertTrue(new_rule in p.file_excludes)
		self.assertTrue(new_rule not in p.dir_excludes)

	def test_can_store_changes_to_dir_exclusions(self):
		new_rule = ".* dir rule.*"

		# adds a new rule
		rules = self.r.dirExcludes()
		rules.append(new_rule)
		self.r.setDirExcludes(rules)

		self.assertEqual("FileWave", self.r.settings.organizationName())
		self.assertEqual("UnitTest", self.r.settings.applicationName())

		# fetch and test (the self.r rules are stored/read in default QSettings, unit test main sets this up)
		p = DirectoryScanner()
		self.assertTrue(new_rule not in p.file_excludes)
		self.assertTrue(new_rule in p.dir_excludes)

	def test_exclusion_defaults(self):
		def_excludes = self.r.defaultFileExclusionRules()
		self.assertTrue(len(def_excludes) > 0)
		def_excludes = self.r.defaultDirExclusionRules()
		self.assertTrue(len(def_excludes) > 0)
		def_excludes = self.r.defaultRegistryExclusionRules()
		if Platform.isWindows:
			self.assertTrue(len(def_excludes) > 0)
		else:
			self.assertEqual(len(def_excludes), 0)
Ejemplo n.º 3
0
    def __init__(self, exclusion_rules = None):
        if exclusion_rules is None:
            exclusion_rules = ExclusionRules()
        self.rules = exclusion_rules

        # this is the public set of posix style exclusion patterns, e.g. *.txt
        self.excludes = []
        self.loadExclusionPreferences()

        # when a scan takes place, the excludes are compiled into regex instances within __excludes
        self.__excludes = []

        # default to scanning all HIVES
        self.__hives = HIVES.keys()
Ejemplo n.º 4
0
    def __init__(self, exclusion_rules=None):
        if exclusion_rules is None:
            exclusion_rules = ExclusionRules()
        self.rules = exclusion_rules

        # this is the public set of posix style file patterns, e.g. *.txt
        self.dir_excludes = []
        self.file_excludes = []
        self.loadExclusionPreferences()

        # when a scan takes place, the dir_excludes are compiled into regex instances within _excludes
        self.__dir_excludes = []
        self.__file_excludes = []
        self.paths_to_scan = []
Ejemplo n.º 5
0
	def setUp(self):
		self.r = ExclusionRules(settings = QSettings())