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

Class File

tables/file.py:604–3032  ·  view source on GitHub ↗

The in-memory representation of a PyTables file. An instance of this class is returned when a PyTables file is opened with the :func:`tables.open_file` function. It offers methods to manipulate (create, rename, delete...) nodes and handle their attributes, as well as methods to trav

Source from the content-addressed store, hash-verified

602
603
604class File(hdf5extension.File):
605 """The in-memory representation of a PyTables file.
606
607 An instance of this class is returned when a PyTables file is
608 opened with the :func:`tables.open_file` function. It offers methods
609 to manipulate (create, rename, delete...) nodes and handle their
610 attributes, as well as methods to traverse the object tree.
611 The *user entry point* to the object tree attached to the HDF5 file
612 is represented in the root_uep attribute.
613 Other attributes are available.
614
615 File objects support an *Undo/Redo mechanism* which can be enabled
616 with the :meth:`File.enable_undo` method. Once the Undo/Redo
617 mechanism is enabled, explicit *marks* (with an optional unique
618 name) can be set on the state of the database using the
619 :meth:`File.mark`
620 method. There are two implicit marks which are always available:
621 the initial mark (0) and the final mark (-1). Both the identifier
622 of a mark and its name can be used in *undo* and *redo* operations.
623
624 Hierarchy manipulation operations (node creation, movement and
625 removal) and attribute handling operations (setting and deleting)
626 made after a mark can be undone by using the :meth:`File.undo`
627 method, which returns the database to the state of a past mark.
628 If undo() is not followed by operations that modify the hierarchy
629 or attributes, the :meth:`File.redo` method can be used to return
630 the database to the state of a future mark. Else, future states of
631 the database are forgotten.
632
633 Note that data handling operations can not be undone nor redone by
634 now. Also, hierarchy manipulation operations on nodes that do not
635 support the Undo/Redo mechanism issue an UndoRedoWarning *before*
636 changing the database.
637
638 The Undo/Redo mechanism is persistent between sessions and can
639 only be disabled by calling the :meth:`File.disable_undo` method.
640
641 File objects can also act as context managers when using the with
642 statement introduced in Python 2.5. When exiting a context, the
643 file is automatically closed.
644
645 Parameters
646 ----------
647 filename : str
648 The name of the file (supports environment variable expansion).
649 It is suggested that file names have any of the .h5, .hdf or
650 .hdf5 extensions, although this is not mandatory.
651
652 mode : str
653 The mode to open the file. It can be one of the
654 following:
655
656 * *'r'*: Read-only; no data can be modified.
657 * *'w'*: Write; a new file is created (an existing file
658 with the same name would be deleted).
659 * *'a'*: Append; an existing file is opened for reading
660 and writing, and if the file does not exist it is created.
661 * *'r+'*: It is similar to 'a', but the file must already

Callers 1

open_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected