def exportIssueLinks(self):
     response, content = self._req('GET', '/export/links')
     xml = minidom.parseString(content)
     return [
         youtrack.Link(e, self) for e in xml.documentElement.childNodes
         if e.nodeType == Node.ELEMENT_NODE
     ]
 def _apply_relations(self, limit=CHUNK_SIZE):
     links = []
     for link_type, ids in self._relations.items():
         for from_id, to_ids in ids.items():
             for to_id in to_ids:
                 link = youtrack.Link()
                 link.typeName = link_type
                 try:
                     link.source = self._to_yt_issue_id(from_id)
                     link.target = self._to_yt_issue_id(to_id)
                 except KeyError:
                     print("Cannot apply link (%s) to issues: %d and %d" %
                           (link_type, from_id, to_id))
                     if hasattr(link, 'source') and link.source:
                         print("The second issue was not imported")
                         continue
                     else:
                         print("The first issues was not imported")
                         break
                 links.append(link)
                 if len(links) >= limit:
                     self._target.importLinks(links)
                     del links[0:]
     if links:
         self._target.importLinks(links)
示例#3
0
 def getLinks(self, id, outwardOnly=False):
     response, content = self._req('GET', '/issue/' + urlquote(id) + '/link')
     xml = minidom.parseString(content)
     res = []
     for c in [e for e in xml.documentElement.childNodes if e.nodeType == Node.ELEMENT_NODE]:
         link = youtrack.Link(c, self)
         if link.source == id or not outwardOnly:
             res.append(link)
     return res
示例#4
0
 def _apply_relations(self, limit=CHUNK_SIZE):
     links = []
     for link_type, ids in self._relations.items():
         for from_id, to_ids in ids.items():
             for to_id in to_ids:
                 link = youtrack.Link()
                 link.typeName = link_type
                 try:
                     link.source = self._to_yt_issue_id(from_id)
                     link.target = self._to_yt_issue_id(to_id)
                 except KeyError, e:
                     print "Cannot apply link (%s) to issues: %d and %d" % \
                           (link_type, from_id, to_id)
                     print "Some issues were not imported to YouTrack"
                     raise e
                 links.append(link)
                 if len(links) >= limit:
                     self._target.importLinks(links)
                     del links[0:]