Copy the content of a PyTables file to another. This function allows you to copy an existing PyTables file named srcfilename to another file called dstfilename. The source file must exist and be readable. The destination file can be overwritten in place if existing by asserting the
(
srcfilename: str, dstfilename: str, overwrite: bool = False, **kwargs
)
| 180 | |
| 181 | |
| 182 | def copy_file( |
| 183 | srcfilename: str, dstfilename: str, overwrite: bool = False, **kwargs |
| 184 | ) -> None: |
| 185 | """Copy the content of a PyTables file to another. |
| 186 | |
| 187 | This function allows you to copy an existing PyTables file named |
| 188 | srcfilename to another file called dstfilename. The source file |
| 189 | must exist and be readable. The destination file can be |
| 190 | overwritten in place if existing by asserting the overwrite |
| 191 | argument. |
| 192 | |
| 193 | This function is a shorthand for the :meth:`File.copy_file` method, |
| 194 | which acts on an already opened file. kwargs takes keyword |
| 195 | arguments used to customize the copying process. See the |
| 196 | documentation of :meth:`File.copy_file` for a description of those |
| 197 | arguments. |
| 198 | |
| 199 | """ |
| 200 | # Open the source file. |
| 201 | srcfileh = open_file(srcfilename, mode="r") |
| 202 | |
| 203 | try: |
| 204 | # Copy it to the destination file. |
| 205 | srcfileh.copy_file(dstfilename, overwrite=overwrite, **kwargs) |
| 206 | finally: |
| 207 | # Close the source file. |
| 208 | srcfileh.close() |
| 209 | |
| 210 | |
| 211 | hdf5_version_str = utilsextension.get_hdf5_version() |