def _add_to_package_contents(self, pkgroot, node_path, hashes, target,
                                 source_path, transform, user_meta_hash):
        """
        Adds an object (name-hash mapping) or group to package contents.
        """
        assert isinstance(node_path, list)
        assert user_meta_hash is None or isinstance(user_meta_hash, str)

        contents = pkgroot

        if not node_path:
            # Allow setting metadata on the root node, but that's it.
            assert target is TargetType.GROUP
            contents.metadata_hash = user_meta_hash
            return

        ptr = contents
        for node in node_path[:-1]:
            ptr = ptr.children[node]

        if target is TargetType.GROUP:
            node = GroupNode(
                children=dict(),
                metadata_hash=user_meta_hash
            )
        else:
            node = FileNode( # pylint:disable=R0204
                hashes=hashes,
                metadata=dict(
                    q_ext=transform,
                    q_path=source_path,
                    q_target=target.value
                ),
                metadata_hash=user_meta_hash
            )

        ptr.children[node_path[-1]] = node
def _add_to_package_contents ( self , pkgroot , node_path , hashes , target , source_path , transform , user_meta_hash ) : assert isinstance ( node_path , list ) assert user_meta_hash is None or isinstance ( user_meta_hash , str ) contents = pkgroot if not node_path : assert target is TargetType . GROUP contents . metadata_hash = user_meta_hash return ptr = contents for node in node_path [ : - 1 ] : ptr = ptr . children [ node ] if target is TargetType . GROUP : node = GroupNode ( children = dict ( ) , metadata_hash = user_meta_hash ) else : node = FileNode ( hashes = hashes , metadata = dict ( q_ext = transform , q_path = source_path , q_target = target . value ) , metadata_hash = user_meta_hash ) ptr . children [ node_path [ - 1 ] ] = node
Adds an object (name-hash mapping) or group to package contents.