Package kenozooid :: Module uddf :: Class NodeCopier

Class NodeCopier

source code

object --+
         |
        NodeCopier


UDDF dcument node copier.

See :py:func:`NodeCopier.copy` for details.

:Attributes:
 doc
    The target document.
 doc_ids
    The cache of target document ids.

Instance Methods
 
__init__(self, doc)
Initialize node copier.
source code
 
__enter__(self)
Create UDDF node copier context manager.
source code
 
__exit__(self, *args)
Close UDDF node copier context manager.
source code
 
copy(self, node, target)
Copy node from UDDF document to target node in destination UDDF document. Target node becomes parent of node to be copied.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, doc)
(Constructor)

source code 
Initialize node copier.
Overrides: object.__init__

copy(self, node, target)

source code 

Copy node from UDDF document to target node in destination UDDF document. Target node becomes parent of node to be copied.

The copying works under following assumptions

  • whole node is being copied including its descendants
  • node is not copied if it has id and id already exists in the target
  • if copied nodes reference non-descendant nodes and they do _not_ exist in destination document, then referencing nodes are _removed_
  • if, due to node removal, its parent node becomes empty, then parent is removed, too

Copy of the node is returned.

Parameters:
  • node - Node to copy.
  • target - The future parent of the copied node.