

def add_link(self, rel, target, wrap=False, **kwargs):
    "Adds a link to the document.\n\n        This method adds a link to the given ``target`` to the document with\n        the given ``rel``. If one or more links are already present for that\n        link relationship type, the new link will be added to the existing\n        links for that link relationship type.\n\n        Unlike ``dougrain.Document.add_link``, this method does not detect\n        equivalence between relationship types with different representations.\n\n        If ``target`` is a string, a link is added with ``target`` as its\n        ``href`` property and other properties from the keyword arguments.\n\n        If ``target`` is a ``dougrain.Document`` object, a link is added with\n        ``target``'s URL as its ``href`` property and other property from the\n        keyword arguments.\n\n        If ``target`` is a ``Builder`` object, a link is added with\n        ``target``'s URL as its ``href`` property and other property from the\n        keyword arguments.\n\n        This method returns self, allowing it to be chained with additional\n        method calls.\n\n        Arguments:\n\n        - ``rel``: a string specifying the link relationship type of the link.\n          It should be a well-known link relation name from the IANA registry\n          (http://www.iana.org/assignments/link-relations/link-relations.xml),\n          a full URI, or a CURIE.\n        - ``target``: the destination of the link.\n        - ``wrap``: Defaults to False, but if True, specifies that the link\n          object should be initally wrapped in a JSON array even if it is the\n          first link for the given ``rel``.\n\n        "
    if isinstance(target, bytes):
        target = target.decode('utf-8')
    if (isinstance(target, str) or isinstance(target, unicode)):
        new_link = dict(href=target, **kwargs)
    else:
        new_link = dict(href=target.url(), **kwargs)
    self._add_rel('_links', rel, new_link, wrap)
    return self

dataset/ETHPy150Open wharris/dougrain/dougrain/builder.py Builder.add_link/original