RMF
cloning.py

RMF includes functions to help cloning files an extracting parts. They are also exposed through the rmf_slice application.

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 import RMF
6 
7 in_name = RMF.get_example_path("3U7W.rmf")
8 out_name = RMF._get_temporary_file_path("3U7W.out.rmfz")
9 
10 in_file = RMF.open_rmf_file_read_only(in_name)
11 out_file = RMF.create_rmf_file(out_name)
12 
13 print("creating file", out_name)
14 
15 # copy over info like the creator, this isn't essential
16 RMF.clone_file_info(in_file, out_file)
17 # copy over the hierarchy
18 # This is necessary in order to copy the data
19 RMF.clone_hierarchy(in_file, out_file)
20 
21 # copy all the static data
22 RMF.clone_static_frame(in_file, out_file)
23 
24 # go through and copy each frame
25 for f in in_file.get_frames():
26  print("cloning frame", f)
27  in_file.set_current_frame(f)
28  out_file.add_frame(in_file.get_name(f), in_file.get_type(f))
29  RMF.clone_loaded_frame(in_file, out_file)