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

Method test02_Recursive

tables/tests/test_create.py:931–985  ·  view source on GitHub ↗

Checking recursive copy of a Group

(self)

Source from the content-addressed store, hash-verified

929 print("The attrs contents has been copied correctly")
930
931 def test02_Recursive(self):
932 """Checking recursive copy of a Group"""
933
934 if common.verbose:
935 print("\n", "-=" * 30)
936 print("Running %s.test02_Recursive..." % self.__class__.__name__)
937
938 # Create the destination node
939 group = self.h5file2.root
940 for groupname in self.dstnode.split("/"):
941 if groupname:
942 group = self.h5file2.create_group(group, groupname)
943 dstgroup = self.h5file2.get_node(self.dstnode)
944
945 # Copy a group non-recursively
946 srcgroup = self.h5file.get_node(self.srcnode)
947 self.h5file.copy_children(
948 srcgroup, dstgroup, recursive=True, filters=self.filters
949 )
950 lenSrcGroup = len(srcgroup._v_pathname)
951 if lenSrcGroup == 1:
952 lenSrcGroup = 0 # Case where srcgroup == "/"
953 if self.close:
954 # Close the destination file
955 self.h5file2.close()
956 # And open it again
957 self.h5file2 = tb.open_file(self.h5fname2, "r")
958 dstgroup = self.h5file2.get_node(self.dstnode)
959
960 # Check that the copy has been done correctly
961 lenDstGroup = len(dstgroup._v_pathname)
962 if lenDstGroup == 1:
963 lenDstGroup = 0 # Case where dstgroup == "/"
964 first = 1
965 nodelist1 = []
966 for node in srcgroup._f_walknodes():
967 if first:
968 # skip the first group
969 first = 0
970 continue
971 nodelist1.append(node._v_pathname[lenSrcGroup:])
972
973 first = 1
974 nodelist2 = []
975 for node in dstgroup._f_walknodes():
976 if first:
977 # skip the first group
978 first = 0
979 continue
980 nodelist2.append(node._v_pathname[lenDstGroup:])
981
982 if common.verbose:
983 print("The origin node list -->", nodelist1)
984 print("The copied node list -->", nodelist2)
985 self.assertEqual(nodelist1, nodelist2)
986
987 def test03_RecursiveFilters(self):
988 """Checking recursive copy of a Group (cheking Filters)"""

Callers

nothing calls this directly

Calls 6

create_groupMethod · 0.80
_f_walknodesMethod · 0.80
get_nodeMethod · 0.45
copy_childrenMethod · 0.45
closeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected