Copy the children from source group to destination group.
(
srcfile,
dstfile,
srcgroup,
dstgroup,
title,
recursive,
filters,
copyuserattrs,
overwritefile,
overwrtnodes,
stats,
start,
stop,
step,
chunkshape,
sortby,
check_CSI, # noqa: N803
propindexes,
upgradeflavors,
allow_padding,
use_hardlinks=True,
)
| 208 | |
| 209 | |
| 210 | def copy_children( |
| 211 | srcfile, |
| 212 | dstfile, |
| 213 | srcgroup, |
| 214 | dstgroup, |
| 215 | title, |
| 216 | recursive, |
| 217 | filters, |
| 218 | copyuserattrs, |
| 219 | overwritefile, |
| 220 | overwrtnodes, |
| 221 | stats, |
| 222 | start, |
| 223 | stop, |
| 224 | step, |
| 225 | chunkshape, |
| 226 | sortby, |
| 227 | check_CSI, # noqa: N803 |
| 228 | propindexes, |
| 229 | upgradeflavors, |
| 230 | allow_padding, |
| 231 | use_hardlinks=True, |
| 232 | ): |
| 233 | """Copy the children from source group to destination group.""" |
| 234 | # Open the source file with srcgroup as root_uep |
| 235 | srcfileh = tb.open_file( |
| 236 | srcfile, "r", root_uep=srcgroup, allow_padding=allow_padding |
| 237 | ) |
| 238 | # Assign the root to srcgroup |
| 239 | srcgroup = srcfileh.root |
| 240 | |
| 241 | created_dstgroup = False |
| 242 | # Check whether the destination group exists or not |
| 243 | if Path(dstfile).is_file() and not overwritefile: |
| 244 | dstfileh = tb.open_file( |
| 245 | dstfile, |
| 246 | "a", |
| 247 | pytables_sys_attrs=createsysattrs, |
| 248 | allow_padding=allow_padding, |
| 249 | ) |
| 250 | try: |
| 251 | dstgroup = dstfileh.get_node(dstgroup) |
| 252 | except tb.exceptions.NoSuchNodeError: |
| 253 | # The dstgroup does not seem to exist. Try creating it. |
| 254 | dstgroup = newdst_group(dstfileh, dstgroup, title, filters) |
| 255 | created_dstgroup = True |
| 256 | else: |
| 257 | # The node exists, but it is really a group? |
| 258 | if not isinstance(dstgroup, tb.group.Group): |
| 259 | # No. Should we overwrite it? |
| 260 | if overwrtnodes: |
| 261 | parent = dstgroup._v_parent |
| 262 | last_slash = dstgroup._v_pathname.rindex("/") |
| 263 | dstgroupname = dstgroup._v_pathname[last_slash + 1 :] |
| 264 | dstgroup.remove() |
| 265 | dstgroup = dstfileh.create_group( |
| 266 | parent, dstgroupname, title=title, filters=filters |
| 267 | ) |
no test coverage detected