MCPcopy Create free account
hub / github.com/PyTables/PyTables / mark

Method mark

tables/file.py:2522–2566  ·  view source on GitHub ↗

Mark the state of the database. Creates a mark for the current state of the database. A unique (and immutable) identifier for the mark is returned. An optional name (a string) can be assigned to the mark. Both the identifier of a mark and its name can be used in :met

(self, name: str | None = None)

Source from the content-addressed store, hash-verified

2520 self._undoEnabled = False
2521
2522 def mark(self, name: str | None = None) -> int:
2523 """Mark the state of the database.
2524
2525 Creates a mark for the current state of the database. A unique (and
2526 immutable) identifier for the mark is returned. An optional name (a
2527 string) can be assigned to the mark. Both the identifier of a mark and
2528 its name can be used in :meth:`File.undo` and :meth:`File.redo`
2529 operations. When the name has already been used for another mark,
2530 an UndoRedoError is raised.
2531
2532 This method can only be called when the Undo/Redo mechanism has been
2533 enabled. Otherwise, an UndoRedoError is raised.
2534
2535 """
2536 self._check_open()
2537 self._check_undo_enabled()
2538
2539 if name is None:
2540 name = ""
2541 else:
2542 if not isinstance(name, str):
2543 raise TypeError(
2544 "Only strings are allowed as mark names. "
2545 "You passed object: '%s'" % name
2546 )
2547 if name in self._markers:
2548 raise UndoRedoError(
2549 "Name '%s' is already used as a marker "
2550 "name. Try another one." % name
2551 )
2552
2553 # The file is going to be changed.
2554 self._check_writable()
2555
2556 self._markers[name] = self._curmark + 1
2557
2558 # Create an explicit mark
2559 # Insert the mark in the action log
2560 self._log("MARK", str(self._curmark + 1), name)
2561 self._curmark += 1
2562 self._nmarks = self._curmark + 1
2563 self._seqmarkers.append(self._curaction)
2564 # Create a group for the current mark
2565 self._create_mark(self._trans, self._curmark)
2566 return self._curmark
2567
2568 def _log(self, action: str, *args) -> None:
2569 """Log an action.

Callers 15

test02_twice2Method · 0.80
test03_6times3marksMethod · 0.80
test04_6times3marksroMethod · 0.80
test05_destructiveMethod · 0.80
test05b_destructiveMethod · 0.80
test05c_destructiveMethod · 0.80
test05d_destructiveMethod · 0.80
test05e_destructiveMethod · 0.80
test06_totalunwindMethod · 0.80
test07_totalrewindMethod · 0.80
test08_marknamesMethod · 0.80
test08_initialmarkMethod · 0.80

Calls 7

_check_openMethod · 0.95
_check_undo_enabledMethod · 0.95
_check_writableMethod · 0.95
_logMethod · 0.95
_create_markMethod · 0.95
UndoRedoErrorClass · 0.85
appendMethod · 0.45

Tested by 15

test02_twice2Method · 0.64
test03_6times3marksMethod · 0.64
test04_6times3marksroMethod · 0.64
test05_destructiveMethod · 0.64
test05b_destructiveMethod · 0.64
test05c_destructiveMethod · 0.64
test05d_destructiveMethod · 0.64
test05e_destructiveMethod · 0.64
test06_totalunwindMethod · 0.64
test07_totalrewindMethod · 0.64
test08_marknamesMethod · 0.64
test08_initialmarkMethod · 0.64