def _get_issue_links(self, project_id, after=0, limit=0):
     key = self._import_config.get_key_for_field_name(u'Links')
     delimiter = getattr(csvClient,
                         'VALUE_DELIMITER',
                         csvClient.CSV_DELIMITER)
     links = []
     for issue in self._get_issues(project_id):
         source_id = self._get_yt_issue_id(issue)
         self._link_importer.created_issue_ids.add(source_id)
         if key not in issue:
             continue
         link_groups = issue[key].split(delimiter)
         for group in link_groups:
             ids = group.split(csvClient.CSV_DELIMITER)
             if len(ids) < 2:
                 # Bad format.
                 # There should be at least link type and one issue id.
                 continue
             link_type = ids.pop(0)
             for i in ids:
                 try:
                     i = "%s-%d" % (project_id, int(i))
                 except ValueError:
                     pass
                 self._link_importer.created_issue_ids.add(i)
                 link = Link()
                 link.typeName = link_type
                 link.source = source_id
                 link.target = i
                 links.append(link)
     return links
def process_links(target, issue, yt_links):
    links = issue['fields']['links']['value'] + issue['fields']['sub-tasks']['value']
    for link in links:
        is_directed = 'direction' in link
        target_issue = issue['key']
        source_issue = link['issueKey']

        try:
            if int(target_issue[6:]) > int(source_issue[6:]):
                continue
        except:
            continue

        try:
            link_description = link['type']['description'] if 'description' in link['type'] else link['type']['name']
            if is_directed:
                target.createIssueLinkTypeDetailed(link['type']['name'], link_description, link_description, False)
            else:
                outward = 'is ' + link['type']['name']
                inward = link_description
                if link['type']['direction'] == u'OUTBOUND':
                    c = outward
                    outward = inward
                    inward = outward
                    c = source_issue
                    source_issue = target_issue
                    target_issue = c
                target.createIssueLinkTypeDetailed(link['type']['name'], outward, inward, True)
        except YouTrackException:
            pass
        yt_link = Link()
        yt_link.typeName = link['type']['name']
        yt_link.source = source_issue
        yt_link.target = target_issue
        yt_links.append(yt_link)
Exemplo n.º 3
0
def process_links(target, issue, yt_links):
    for sub_task in issue['fields']['subtasks']:
        parent = issue[u'key']
        child = sub_task[u'key']
        link = Link()
        link.typeName = u'subtask'
        link.source = parent
        link.target = child
        yt_links.append(link)

    links = issue['fields'][u'issuelinks']
    for link in links:
        if u'inwardIssue' in link:
            source_issue = issue[u'key']
            target_issue = link[u'inwardIssue'][u'key']
        elif u'outwardIssue' in link:
            source_issue = issue[u'key']
            target_issue = link[u'outwardIssue'][u'key']
        else:
            continue

        type = link[u'type']
        type_name = type[u'name']
        inward = type[u'inward']
        outward = type[u'outward']
        try:
            if inward == outward:
                target.createIssueLinkTypeDetailed(type_name, outward, inward,
                                                   False)
            else:
                target.createIssueLinkTypeDetailed(type_name, outward, inward,
                                                   True)
        except YouTrackException:
            pass

        yt_link = Link()
        yt_link.typeName = type_name
        yt_link.source = source_issue
        yt_link.target = target_issue
        yt_links.append(yt_link)
def process_links(target, issue, yt_links):
    for sub_task in issue['fields']['subtasks']:
        parent = issue[u'key']
        child = sub_task[u'key']
        link = Link()
        link.typeName = u'subtask'
        link.source = parent
        link.target = child
        yt_links.append(link)

    links = issue['fields'][u'issuelinks']
    for link in links:
        if u'inwardIssue' in link:
            source_issue = issue[u'key']
            target_issue = link[u'inwardIssue'][u'key']
        elif u'outwardIssue' in link:
            source_issue = issue[u'key']
            target_issue = link[u'outwardIssue'][u'key']
        else:
            continue

        type = link[u'type']
        type_name = type[u'name']
        inward = type[u'inward']
        outward = type[u'outward']
        try:
            if inward == outward:
                target.createIssueLinkTypeDetailed(type_name, outward, inward, False)
            else:
                target.createIssueLinkTypeDetailed(type_name, outward, inward, True)
        except YouTrackException:
            pass

        yt_link = Link()
        yt_link.typeName = type_name
        yt_link.source = source_issue
        yt_link.target = target_issue
        yt_links.append(yt_link)
Exemplo n.º 5
0
def fb2youtrack(params):
    # Connection to FogBugz
    source = FBClient(params['fb_url'],
                      params['fb_login'],
                      params['fb_password'])

    # Connecting to YouTrack
    token = params.get('token')
    if not token and 'token_file' in params:
        try:
            with open(params['token_file'], 'r') as f:
                token = f.read().strip()
        except (OSError, IOError) as e:
            print("Cannot load token from file: " + str(e))
            sys.exit(1)
    if token:
        target = Connection(params['yt_url'], token=token)
    elif 'yt_login' in params:
        target = Connection(params['yt_url'],
                            params.get('yt_login'),
                            params.get('yt_password'))
    else:
        print("You have to provide token or login/password to import data")
        sys.exit(1)

    if not params.get('project_lead_login'):
        project_lead = params.get('yt_login')
        if not project_lead:
            for login in ('root', 'admin', 'administrator', 'guest'):
                try:
                    project_lead = target.getUser(login).login
                    break
                except youtrack.YouTrackException:
                    continue
        params['project_lead_login'] = project_lead

    max_issue_id = params['fb_max_issue_id']

    project_names = youtrackutils.fbugz.PROJECTS_TO_IMPORT
    accessible_projects = source.list_project_names()
    for p_name in project_names:
        if not (p_name in accessible_projects.keys()):
            print('Unknown project names. Exiting...')
            sys.exit()

#    for p_name in accessible_projects :
#        if (p_name.encode('utf-8') in project_names_str) :
#            project_names_str.remove(p_name.encode('utf-8'))
#            project_names.append(p_name)
#
#    if (len(project_names_str) != 0) :
#        print 'Unknown project names!'

    print('Creating custom fields')
#
#    for field_name in ['Category', 'Priority', 'Status']:
#        field_name = get_yt_name_from_fb__field_name(field_name)
#        create_custom_field(target, fbugz.CF_TYPES[field_name], field_name, False)

    fb_category_bundle_name = u'FB Categories'
    fb_priorities_bundle_name = u'FB Priorities'
    fb_statuses_bundle_name = u'FB Statuses'

    common_fields = {
        u'category'  :   fb_category_bundle_name,
        u'priority'  :   fb_priorities_bundle_name,
        u'status'    :   fb_statuses_bundle_name
    }

    field_name = u'category'
    create_bundle_with_values(
        target,
        youtrackutils.fbugz.CF_TYPES[get_yt_field_name(field_name)],
        common_fields[field_name],
        source.list_categories(),
        lambda bundle, value:
        bundle.createElement(to_yt_field_value(field_name, value)))
    field_name = u'priority'
    create_bundle_with_values(target, youtrackutils.fbugz.CF_TYPES[get_yt_field_name(field_name)],
                              common_fields[field_name],
                              [elem[0] + '-' + elem[1] for elem in source.list_priorities()],
                              lambda bundle, value : bundle.createElement(to_yt_field_value(field_name, value)))

    field_name = u'status'
    statuses = [(to_yt_field_value(field_name, value), resolved) for (value, resolved) in source.list_statuses()]
    create_bundle_with_values(target, youtrackutils.fbugz.CF_TYPES[get_yt_field_name(field_name)],
                              common_fields[field_name],
                              statuses, lambda bundle, value : to_yt_status(bundle, value))

    simple_fields = [u'original_title', u'version', u'computer', u'due', u'estimate']

    for name in simple_fields:
        name = get_yt_field_name(name)
        create_custom_field(target, youtrackutils.fbugz.CF_TYPES[name], name, False)

    print('Importing users')
    for name in ['Normal', 'Deleted', 'Community', 'Virtual'] :
        group = Group()
        group.name = name
        try :
            target.createGroup(group)
            print('Group with name [ %s ] successfully created' % name)
        except:
            print("Can't create group with name [ %s ] (maybe because it already exists)" % name)

    users_to_import = []
    max = 100
    for user in source.get_users() :
        yt_user = _to_yt_user(user)
        print('Importing user [ %s ]' % yt_user.login)
        users_to_import.append(yt_user)
        if len(users_to_import) >= max:
            _do_import_users(target, users_to_import)
            users_to_import = []
    _do_import_users(target, users_to_import)
    print('Importing users finished')

    # to handle linked issues
    try :
        target.createIssueLinkTypeDetailed('parent-child', 'child of', 'parent of', True)
    except YouTrackException:
        print("Can't create issue link type [ parent-child ] (maybe because it already exists)")
    links_to_import = []

    for project_name in project_names:
        value_sets = dict([])

        project_id = accessible_projects[project_name]
        print('Importing project [ %s ]' % project_name)
        target.createProjectDetailed(project_id,
                                     project_name.encode('utf-8'),
                                     '',
                                     params['project_lead_login'])

        print('Creating custom fields in project [ %s ]' % project_name)

        for cf_name in common_fields:
            bundle_name = common_fields[cf_name]
            cf_name = get_yt_field_name(cf_name)
            target.deleteProjectCustomField(project_id, cf_name)
            target.createProjectCustomFieldDetailed(project_id, cf_name, 'No ' + cf_name.lower(),
                    {'bundle' : bundle_name})

        for cf_name in simple_fields:
            cf_name = get_yt_field_name(cf_name)
            try:
                target.createProjectCustomFieldDetailed(project_id, cf_name, 'No ' + cf_name.lower())
            except YouTrackException:
                print("Can't create custom field with name [%s]" % cf_name)
        cf_name = get_yt_field_name('fix_for')
        milestones = source.get_milestones(project_id)
        value_sets["fix_for"] = []
        for milestone in milestones:
            value_sets["fix_for"].append(milestone.name)
            milestone.name = to_yt_field_value('fix_for', milestone.name)
        add_values_to_field(target, cf_name, project_id, milestones,
                            lambda bundle, value: _to_yt_version(bundle, value))

        cf_name = get_yt_field_name('area')
        areas = source.get_areas(project_id)
        value_sets["area"] = []
        for area in areas:
            value_sets["area"].append(area.name)
            area.name = to_yt_field_value('area', area.name)
        add_values_to_field(target, cf_name, project_id, areas,
                            lambda bundle, value: _to_yt_subsystem(bundle, value))

        print('Importing issues for project [ %s ]' % project_name)
        start = 0
        issues_to_import = []
        # create dictionary with child : parent pairs
        while start <= max_issue_id:
            fb_issues = source.get_issues(project_name, start, 30)
            for issue in fb_issues :
                add_values_to_field(target, get_yt_field_name('area'), project_id,
                                    [issue.field_values['area']], lambda bundle, value: bundle.createElement(value))
                issues_to_import.append(_to_yt_issue(issue, value_sets))
            target.importIssues(project_id, project_name.encode('utf-8') + " assignees", issues_to_import)
            for issue in fb_issues :
                full_issue_id = '%s-%s' % (project_id, issue.ix_bug)
                for attach in issue.attachments :
                    target.createAttachmentFromAttachment(full_issue_id, attach)
                for tag in issue.tags :
                    target.executeCommand(full_issue_id, 'tag ' + tag)
                if issue.bug_parent is not None:
                    parent_issue_id = '%s-%s' % (source.get_issue_project_id(issue.bug_parent), issue.bug_parent)
                    link = Link()
                    link.typeName = 'parent-child'
                    link.source = full_issue_id
                    link.target = parent_issue_id
                    links_to_import.append(link)
            issues_to_import = []
            start += 30
        print('Importing issues for project [ %s ] finished' % project_name)

    print('Importing issue links')
    print(target.importLinks(links_to_import))
    print('Importing issue links finished')
Exemplo n.º 6
0
def fb2youtrack(target_url, target_login, target_password, source_url,
                source_login, source_password, project_names, max_issue_id):
    #encoding = 'utf-8'
    source = FBClient(source_url, source_login, source_password)
    target = Connection(target_url, target_login, target_password)
    accessible_projects = source.list_project_names()
    for p_name in project_names:
        if not (p_name in accessible_projects.keys()):
            print 'Unknown project names. Exiting...'
            sys.exit()


#    for p_name in accessible_projects :
#        if (p_name.encode('utf-8') in project_names_str) :
#            project_names_str.remove(p_name.encode('utf-8'))
#            project_names.append(p_name)
#
#    if (len(project_names_str) != 0) :
#        print 'Unknown project names!'

    print('Creating custom fields')
    #
    #    for field_name in ['Category', 'Priority', 'Status']:
    #        field_name = get_yt_name_from_fb__field_name(field_name)
    #        create_custom_field(target, fbugz.CF_TYPES[field_name], field_name, False)

    fb_category_bundle_name = u'FB Categories'
    fb_priorities_bundle_name = u'FB Priorities'
    fb_statuses_bundle_name = u'FB Statuses'

    common_fields = {
        u'category': fb_category_bundle_name,
        u'priority': fb_priorities_bundle_name,
        u'status': fb_statuses_bundle_name
    }

    field_name = u'category'
    create_bundle_with_values(
        target, fbugz.CF_TYPES[get_yt_name_from_fb_field_name(field_name)],
        common_fields[field_name], source.list_categories(),
        lambda bundle, value: bundle.createElement(
            to_yt_field_value(field_name, value)))
    field_name = u'priority'
    create_bundle_with_values(
        target, fbugz.CF_TYPES[get_yt_name_from_fb_field_name(field_name)],
        common_fields[field_name],
        [elem[0] + '-' + elem[1] for elem in source.list_priorities()],
        lambda bundle, value: bundle.createElement(
            to_yt_field_value(field_name, value)))

    field_name = u'status'
    statuses = [(to_yt_field_value(field_name, value), resolved)
                for (value, resolved) in source.list_statuses()]
    create_bundle_with_values(
        target, fbugz.CF_TYPES[get_yt_name_from_fb_field_name(field_name)],
        common_fields[field_name], statuses,
        lambda bundle, value: to_yt_status(bundle, value))

    simple_fields = [
        u'original_title', u'version', u'computer', u'due', u'estimate'
    ]

    for name in simple_fields:
        name = get_yt_name_from_fb_field_name(name)
        create_custom_field(target, fbugz.CF_TYPES[name], name, False)

    print 'Importing users'
    for name in ['Normal', 'Deleted', 'Community', 'Virtual']:
        group = Group()
        group.name = name
        try:
            target.createGroup(group)
            print 'Group with name [ %s ] successfully created' % name
        except:
            print "Can't create group with name [ %s ] (maybe because it already exists)" % name

    users_to_import = []
    max = 100
    for user in source.get_users():
        yt_user = _to_yt_user(user)
        print 'Importing user [ %s ]' % yt_user.login
        users_to_import.append(yt_user)
        if len(users_to_import) >= max:
            _do_import_users(target, users_to_import)
            users_to_import = []
    _do_import_users(target, users_to_import)
    print 'Importing users finished'

    # to handle linked issues
    try:
        target.createIssueLinkTypeDetailed('parent-child', 'child of',
                                           'parent of', True)
    except YouTrackException:
        print "Can't create issue link type [ parent-child ] (maybe because it already exists)"
    links_to_import = []

    for project_name in project_names:
        value_sets = dict([])

        project_id = accessible_projects[project_name]
        print 'Importing project [ %s ]' % project_name
        target.createProjectDetailed(project_id, project_name.encode('utf-8'),
                                     'no description', 'root')

        print 'Creating custom fields in project [ %s ]' % project_name

        for cf_name in common_fields:
            bundle_name = common_fields[cf_name]
            cf_name = get_yt_name_from_fb_field_name(cf_name)
            target.deleteProjectCustomField(project_id, cf_name)
            target.createProjectCustomFieldDetailed(project_id, cf_name,
                                                    'No ' + cf_name.lower(),
                                                    {'bundle': bundle_name})

        for cf_name in simple_fields:
            cf_name = get_yt_name_from_fb_field_name(cf_name)
            try:
                target.createProjectCustomFieldDetailed(
                    project_id, cf_name, 'No ' + cf_name.lower())
            except YouTrackException:
                print "Can't create custom field with name [%s]" % cf_name
        cf_name = get_yt_name_from_fb_field_name('fix_for')
        milestones = source.get_milestones(project_id)
        value_sets["fix_for"] = []
        for milestone in milestones:
            value_sets["fix_for"].append(milestone.name)
            milestone.name = to_yt_field_value('fix_for', milestone.name)
        add_values_to_field(
            target, cf_name, project_id, milestones,
            lambda bundle, value: _to_yt_version(bundle, value))

        cf_name = get_yt_name_from_fb_field_name('area')
        areas = source.get_areas(project_id)
        value_sets["area"] = []
        for area in areas:
            value_sets["area"].append(area.name)
            area.name = to_yt_field_value('area', area.name)
        add_values_to_field(
            target, cf_name, project_id, areas,
            lambda bundle, value: _to_yt_subsystem(bundle, value))

        print 'Importing issues for project [ %s ]' % project_name
        start = 0
        issues_to_import = []
        # create dictionary with child : parent pairs
        while start <= max_issue_id:
            fb_issues = source.get_issues(project_name, start, 30)
            for issue in fb_issues:
                add_values_to_field(
                    target, get_yt_name_from_fb_field_name('area'), project_id,
                    [issue.field_values['area']],
                    lambda bundle, value: bundle.createElement(value))
                issues_to_import.append(_to_yt_issue(issue, value_sets))
            target.importIssues(project_id,
                                project_name.encode('utf-8') + " assignees",
                                issues_to_import)
            for issue in fb_issues:
                full_issue_id = '%s-%s' % (project_id, issue.ix_bug)
                for attach in issue.attachments:
                    target.createAttachmentFromAttachment(
                        full_issue_id, attach)
                for tag in issue.tags:
                    target.executeCommand(full_issue_id, 'tag ' + tag)
                if issue.bug_parent is not None:
                    parent_issue_id = '%s-%s' % (source.get_issue_project_id(
                        issue.bug_parent), issue.bug_parent)
                    link = Link()
                    link.typeName = 'parent-child'
                    link.source = full_issue_id
                    link.target = parent_issue_id
                    links_to_import.append(link)
            issues_to_import = []
            start += 30
        print 'Importing issues for project [ %s ] finished' % project_name

    print 'Importing issue links'
    print target.importLinks(links_to_import)
    print 'Importing issue links finished'
            last_page = True
        for story in stories[u"items"]:
            tasks = (
                [to_yt_sub_task(target, project_id, story, task) for task in story["tasks"]]
                if u"tasks" in story
                else []
            )
            if len(tasks):
                for task in tasks:
                    max_story_id += 1
                    task.numberInProject = str(max_story_id)
                result = target.importIssues(project_id, project_id + " assignees", tasks)
                items = minidom.parseString(result).getElementsByTagName("item")
                issue_links_to_import = []
                for item in items:
                    link = Link()
                    link.typeName = "Subtask"
                    link.target = "%s-%s" % (project_id, item.attributes["id"].value)
                    link.source = "%s-%d" % (project_id, story[u"id"])
                    issue_links_to_import.append(link)
                target.importLinks(issue_links_to_import)
        current_page += 1


#        for parent_id, tasks in tasks_to_import:
#            import_result = target.importIssues(project_id, project_id + " assignees", tasks)
#


def doImport(project_names_to_import, source, target):
    last_page = False
def fb2youtrack(target_url, target_login, target_password, source_url, source_login, source_password, project_names, max_issue_id) :
    #encoding = 'utf-8'
    source = FBClient(source_url, source_login, source_password)
    target = Connection(target_url, target_login, target_password)
    accessible_projects = source.list_project_names()
    for p_name in project_names :
        if not(p_name in  accessible_projects.keys()) :
            print 'Unknown project names. Exiting...'
            sys.exit()

#    for p_name in accessible_projects :
#        if (p_name.encode('utf-8') in project_names_str) :
#            project_names_str.remove(p_name.encode('utf-8'))
#            project_names.append(p_name)
#
#    if (len(project_names_str) != 0) :
#        print 'Unknown project names!'

    print('Creating custom fields')
#
#    for field_name in ['Category', 'Priority', 'Status']:
#        field_name = get_yt_name_from_fb__field_name(field_name)
#        create_custom_field(target, fbugz.CF_TYPES[field_name], field_name, False)

    fb_category_bundle_name = u'FB Categories'
    fb_priorities_bundle_name = u'FB Priorities'
    fb_statuses_bundle_name = u'FB Statuses'

    common_fields = {
        u'category'  :   fb_category_bundle_name,
        u'priority'  :   fb_priorities_bundle_name,
        u'status'    :   fb_statuses_bundle_name
    }

    field_name = u'category'
    create_bundle_with_values(target,fbugz.CF_TYPES[get_yt_name_from_fb_field_name(field_name)],
                              common_fields[field_name],
                              source.list_categories(),
                              lambda bundle, value : bundle.createElement(to_yt_field_value(field_name, value)))
    field_name = u'priority'
    create_bundle_with_values(target, fbugz.CF_TYPES[get_yt_name_from_fb_field_name(field_name)],
                              common_fields[field_name],
                              [elem[0] + '-' + elem[1] for elem in source.list_priorities()],
                              lambda bundle, value : bundle.createElement(to_yt_field_value(field_name, value)))

    field_name = u'status'
    statuses = [(to_yt_field_value(field_name, value), resolved) for (value, resolved) in source.list_statuses()]
    create_bundle_with_values(target, fbugz.CF_TYPES[get_yt_name_from_fb_field_name(field_name)],
                              common_fields[field_name],
                              statuses, lambda bundle, value : to_yt_status(bundle, value))

    simple_fields = [u'original_title', u'version', u'computer', u'due', u'estimate']

    for name in simple_fields:
        name = get_yt_name_from_fb_field_name(name)
        create_custom_field(target, fbugz.CF_TYPES[name], name, False)

    print 'Importing users'
    for name in ['Normal', 'Deleted', 'Community', 'Virtual'] :
        group = Group()
        group.name = name
        try :
            target.createGroup(group)
            print 'Group with name [ %s ] successfully created' % name
        except:
            print "Can't create group with name [ %s ] (maybe because it already exists)" % name


    users_to_import = []
    max = 100
    for user in source.get_users() :
        yt_user = _to_yt_user(user)
        print 'Importing user [ %s ]' % yt_user.login
        users_to_import.append(yt_user)
        if len(users_to_import) >= max:
            _do_import_users(target, users_to_import)
            users_to_import = []
    _do_import_users(target, users_to_import)
    print 'Importing users finished'

    # to handle linked issues
    try :
        target.createIssueLinkTypeDetailed('parent-child', 'child of', 'parent of', True)
    except YouTrackException:
        print "Can't create issue link type [ parent-child ] (maybe because it already exists)"
    links_to_import = []

    for project_name in project_names :
        value_sets = dict([])

        project_id = accessible_projects[project_name]
        print 'Importing project [ %s ]' % project_name
        target.createProjectDetailed(project_id, project_name.encode('utf-8'), 'no description', 'root')

        print 'Creating custom fields in project [ %s ]' % project_name

        for cf_name in common_fields:
            bundle_name = common_fields[cf_name]
            cf_name = get_yt_name_from_fb_field_name(cf_name)
            target.deleteProjectCustomField(project_id, cf_name)
            target.createProjectCustomFieldDetailed(project_id, cf_name, 'No ' + cf_name.lower(),
                    {'bundle' : bundle_name})

        for cf_name in simple_fields:
            cf_name = get_yt_name_from_fb_field_name(cf_name)
            try:
                target.createProjectCustomFieldDetailed(project_id, cf_name, 'No ' + cf_name.lower())
            except YouTrackException:
                print "Can't create custom field with name [%s]" % cf_name
        cf_name = get_yt_name_from_fb_field_name('fix_for')
        milestones = source.get_milestones(project_id)
        value_sets["fix_for"] = []
        for milestone in milestones:
            value_sets["fix_for"].append(milestone.name)
            milestone.name = to_yt_field_value('fix_for', milestone.name)
        add_values_to_field(target, cf_name, project_id, milestones,
                            lambda bundle, value: _to_yt_version(bundle, value))

        cf_name = get_yt_name_from_fb_field_name('area')
        areas = source.get_areas(project_id)
        value_sets["area"] = []
        for area in areas:
            value_sets["area"].append(area.name)
            area.name = to_yt_field_value('area', area.name)
        add_values_to_field(target, cf_name, project_id, areas,
                            lambda bundle, value: _to_yt_subsystem(bundle, value))

        print 'Importing issues for project [ %s ]' % project_name
        start = 0
        issues_to_import = []
        # create dictionary with child : parent pairs
        while start <= max_issue_id:
            fb_issues = source.get_issues(project_name, start, 30)
            for issue in fb_issues :
                add_values_to_field(target, get_yt_name_from_fb_field_name('area'), project_id,
                    [issue.field_values['area']], lambda bundle, value: bundle.createElement(value))
                issues_to_import.append(_to_yt_issue(issue, value_sets))
            target.importIssues(project_id, project_name.encode('utf-8') + " assignees", issues_to_import)
            for issue in fb_issues :
                full_issue_id = '%s-%s' % (project_id, issue.ix_bug)
                for attach in issue.attachments :
                    target.createAttachmentFromAttachment(full_issue_id, attach)
                for tag in issue.tags :
                    target.executeCommand(full_issue_id, 'tag ' + tag)
                if issue.bug_parent is not None:
                    parent_issue_id = '%s-%s' % (source.get_issue_project_id(issue.bug_parent), issue.bug_parent)
                    link = Link()
                    link.typeName = 'parent-child'
                    link.source = full_issue_id
                    link.target = parent_issue_id
                    links_to_import.append(link)
            issues_to_import = []
            start += 30
        print 'Importing issues for project [ %s ] finished' % project_name

    print 'Importing issue links'
    print target.importLinks(links_to_import)
    print 'Importing issue links finished'
Exemplo n.º 9
0
        for story in stories[u'items']:
            tasks = [
                to_yt_sub_task(target, project_id, story, task)
                for task in story['tasks']
            ] if u'tasks' in story else []
            if len(tasks):
                for task in tasks:
                    max_story_id += 1
                    task.numberInProject = str(max_story_id)
                result = target.importIssues(project_id,
                                             project_id + " assignees", tasks)
                items = minidom.parseString(result).getElementsByTagName(
                    "item")
                issue_links_to_import = []
                for item in items:
                    link = Link()
                    link.typeName = "Subtask"
                    link.target = "%s-%s" % (project_id,
                                             item.attributes['id'].value)
                    link.source = "%s-%d" % (project_id, story[u'id'])
                    issue_links_to_import.append(link)
                target.importLinks(issue_links_to_import)
        current_page += 1


#        for parent_id, tasks in tasks_to_import:
#            import_result = target.importIssues(project_id, project_id + " assignees", tasks)
#


def agilezen2youtrack(source_url, source_token, target_url, target_login,