def testCopyableRegexObject(self): obj1 = copyable_regex_object.CopyableRegexObject('fo*') self.assertTrue(obj1.match('foooo')) self.assertFalse(obj1.match('bar')) obj2 = copy.copy(obj1) self.assertTrue(obj2.match('foooo')) self.assertFalse(obj2.match('bar'))
def _ParseIndex(self, preread, precompile): """Reads index file and stores entries in TextTable. For optimisation reasons, a second table is created with compiled entries. Args: preread: func, Pre-processing, applied to each field as it is read. precompile: func, Pre-compilation, applied to each field before compiling. Raises: IndexTableError: If the column headers has illegal column labels. """ self.index = texttable.TextTable() self.index.CsvToTable(self._index_handle) if preread: for row in self.index: for col in row.header: row[col] = preread(col, row[col]) self.compiled = copy.deepcopy(self.index) for row in self.compiled: for col in row.header: if precompile: row[col] = precompile(col, row[col]) if row[col]: row[col] = copyable_regex_object.CopyableRegexObject( row[col])