RMF
cloning.py
1 ## \example cloning.py
2 # RMF includes functions to help cloning files an extracting parts. They are
3 # also exposed through the [rmf_slice](\ref rmf_slice) application.
4 
5 from __future__ import print_function
6 import RMF
7 
8 in_name = RMF.get_example_path("3U7W.rmf")
9 out_name = RMF._get_temporary_file_path("3U7W.out.rmfz")
10 
11 in_file = RMF.open_rmf_file_read_only(in_name)
12 out_file = RMF.create_rmf_file(out_name)
13 
14 print("creating file", out_name)
15 
16 # copy over info like the creator, this isn't essential
17 RMF.clone_file_info(in_file, out_file)
18 # copy over the hierarchy
19 # This is necessary in order to copy the data
20 RMF.clone_hierarchy(in_file, out_file)
21 
22 # copy all the static data
23 RMF.clone_static_frame(in_file, out_file)
24 
25 # go through and copy each frame
26 for f in in_file.get_frames():
27  print("cloning frame", f)
28  in_file.set_current_frame(f)
29  out_file.add_frame(in_file.get_name(f), in_file.get_type(f))
30  RMF.clone_loaded_frame(in_file, out_file)
void clone_static_frame(FileConstHandle input, FileHandle output)
void clone_hierarchy(FileConstHandle input, FileHandle output)
FileConstHandle open_rmf_file_read_only(std::string path)
void clone_file_info(FileConstHandle input, FileHandle output)
void clone_loaded_frame(FileConstHandle input, FileHandle output)
FileHandle create_rmf_file(std::string path)
Create an RMF from a file system path.