'Finish creating a link'

def finishLink(self, event):

    if (self.link is None):
        return
    source = self.linkWidget
    c = self.canvas
    (x, y) = (self.canvasx(event.x_root), self.canvasy(event.y_root))
    target = self.findItem(x, y)
    dest = self.itemToWidget.get(target, None)
    if ((source is None) or (dest is None) or (source == dest) or (dest in source.links) or (source in dest.links)):
        self.releaseNetLink(event)
        return
    stags = self.canvas.gettags(self.widgetToItem[source])
    dtags = self.canvas.gettags(target)
    if ((('Host' in stags) and ('Host' in dtags)) or (('Controller' in dtags) and ('LegacyRouter' in stags)) or (('Controller' in stags) and ('LegacyRouter' in dtags)) or (('Controller' in dtags) and ('LegacySwitch' in stags)) or (('Controller' in stags) and ('LegacySwitch' in dtags)) or (('Controller' in dtags) and ('Host' in stags)) or (('Controller' in stags) and ('Host' in dtags)) or (('Controller' in stags) and ('Controller' in dtags))):
        self.releaseNetLink(event)
        return
    linkType = 'data'
    if (('Controller' in stags) or ('Controller' in dtags)):
        linkType = 'control'
        c.itemconfig(self.link, dash=(6, 4, 2, 4), fill='red')
        self.createControlLinkBindings()
    else:
        linkType = 'data'
        self.createDataLinkBindings()
    c.itemconfig(self.link, tags=(c.gettags(self.link) + (linkType,)))
    (x, y) = c.coords(target)
    c.coords(self.link, self.linkx, self.linky, x, y)
    self.addLink(source, dest, linktype=linkType)
    if (linkType == 'control'):
        controllerName = ''
        switchName = ''
        if ('Controller' in stags):
            controllerName = source['text']
            switchName = dest['text']
        else:
            controllerName = dest['text']
            switchName = source['text']
        self.switchOpts[switchName]['controllers'].append(controllerName)
    self.link = self.linkWidget = None
