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

Function copy_children

tables/scripts/ptrepack.py:210–346  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

208
209
210def 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 )

Callers 1

mainFunction · 0.85

Calls 12

newdst_groupFunction · 0.85
recreate_indexesFunction · 0.85
create_groupMethod · 0.80
_f_copy_childrenMethod · 0.80
_f_walknodesMethod · 0.80
del_attrMethod · 0.80
get_attrMethod · 0.80
get_nodeMethod · 0.45
removeMethod · 0.45
_f_copyMethod · 0.45
closeMethod · 0.45
set_attrMethod · 0.45

Tested by

no test coverage detected