Return a short string representation of the object tree. Examples -------- :: >>> import tables >>> f = tables.open_file('tables/tests/Tables_lzo2.h5') >>> print(f) tables/tests/Tables_lzo2.h5 (File) 'Table Benchmark'
(self)
| 2948 | return False # do not hide exceptions |
| 2949 | |
| 2950 | def __str__(self) -> str: |
| 2951 | """Return a short string representation of the object tree. |
| 2952 | |
| 2953 | Examples |
| 2954 | -------- |
| 2955 | :: |
| 2956 | |
| 2957 | >>> import tables |
| 2958 | >>> f = tables.open_file('tables/tests/Tables_lzo2.h5') |
| 2959 | >>> print(f) |
| 2960 | tables/tests/Tables_lzo2.h5 (File) 'Table Benchmark' |
| 2961 | Last modif.: '...' |
| 2962 | Object Tree: |
| 2963 | / (RootGroup) 'Table Benchmark' |
| 2964 | /tuple0 (Table(100,)lzo(1)) 'This is the table title' |
| 2965 | /group0 (Group) '' |
| 2966 | /group0/tuple1 (Table(100,)lzo(1)) 'This is the table title' |
| 2967 | /group0/group1 (Group) '' |
| 2968 | /group0/group1/tuple2 (Table(100,)lzo(1)) 'This is the table title' |
| 2969 | /group0/group1/group2 (Group) '' |
| 2970 | >>> f.close() |
| 2971 | |
| 2972 | """ |
| 2973 | if not self.isopen: |
| 2974 | return "<closed File>" |
| 2975 | |
| 2976 | # Print all the nodes (Group and Leaf objects) on object tree |
| 2977 | try: |
| 2978 | date = datetime.datetime.fromtimestamp( |
| 2979 | Path(self.filename).stat().st_mtime, datetime.UTC |
| 2980 | ).isoformat(timespec="seconds") |
| 2981 | except OSError: |
| 2982 | # in-memory file |
| 2983 | date = "<in-memory file>" |
| 2984 | lines = [ |
| 2985 | f"{self.filename} (File) {self.title!r}", |
| 2986 | f"Last modif.: {date!r}", |
| 2987 | "Object Tree: ", |
| 2988 | ] |
| 2989 | |
| 2990 | for group in self.walk_groups("/"): |
| 2991 | lines.append(f"{group}") |
| 2992 | for kind in self._node_kinds[1:]: |
| 2993 | for node in self.list_nodes(group, kind): |
| 2994 | lines.append(f"{node}") |
| 2995 | return "\n".join(lines) + "\n" |
| 2996 | |
| 2997 | def __repr__(self) -> str: |
| 2998 | """Return a detailed string representation of the object tree.""" |
nothing calls this directly
no test coverage detected