split a list of closed issues into non-PR Issues and Pull Requests
960663
def split_pulls(all_issues, project="arokem/python-matlab-bridge"):
    """"""
    pulls = []
    issues = []
    for i in all_issues:
        if is_pull_request(i):
            pull = get_pull_request(project, i['number'], auth=True)
            pulls.append(pull)
        else:
            issues.append(i)
    return issues, pulls
508561
def list_issues(context, id, sort, limit):
    

    result = component.list_issues(context, id=id, sort=sort, limit=limit)
    headers = ['id', 'status', 'product', 'component', 'title', 'url']
    utils.format_output(result, context.format, headers)
1088642
def get_filtered_pull_requests(pull_requests)
      pull_requests = filter_array_by_labels(pull_requests)
      pull_requests = filter_merged_pull_requests(pull_requests)
      puts "Filtered pull requests: #{pull_requests.count}" if options[:verbose]
      pull_requests
    end
586744
def with_statuses(issue_statuses)
      if name == 'status_id'
        format 'Status: %s => %s',
               find_issue_status(issue_statuses, old_value),
               find_issue_status(issue_statuses, new_value)
      else
        to_s
      end
    end
1315112
def _process_items(items, user_conf, error_protocol):
    
    def process_meta(item, error_protocol):
        try:
            return item._parse()
        except Exception, e:
            error_protocol.append(
                "Can't parse %s: %s" % (item._get_filenames()[0], e.message)
            )

            if isinstance(item, DataPair):
                return item.ebook_file

    # process all items and put them to output queue
    out = []
    for item in items:
        if isinstance(item, EbookFile):
            out.append(item)
        else:
            out.append(process_meta(item, error_protocol))
    out = filter(lambda x: x, out)  # remove None items (process_meta() fails)

    # remove processed files
    fn_pool = []
    soon_removed = out if conf_merger(user_conf, "LEAVE_BAD_FILES") else items
    for item in soon_removed:
        fn_pool.extend(item._get_filenames())

    _remove_files(fn_pool)

    return out
1182688
def cli(obj, ids, query, filters, tags):
    """"""
    client = obj['client']
    if ids:
        total = len(ids)
    else:
        if query:
            query = [('q', query)]
        else:
            query = build_query(filters)
        total, _, _ = client.get_count(query)
        ids = [a.id for a in client.get_alerts(query)]

    with click.progressbar(ids, label='Untagging {} alerts'.format(total)) as bar:
        for id in bar:
            client.untag_alert(id, tags)
378263
def pull_requests(self):
        '''
        
        '''
        pr_numbers = re.findall(r"[pP][rR]\s?[0-9]+", self.description)
        pr_numbers += re.findall(re.compile("pull\s?request\s?[0-9]+", re.IGNORECASE), self.description)

        # Remove Duplicates
        pr_numbers = [re.sub('[^0-9]','', p) for p in pr_numbers]
        return pr_numbers
157241
def splits(self):
        "  "
        result = []

        def collect(split):
            result.append(split)

            for item in split:
                if isinstance(item, (HSplit, VSplit)):
                    collect(item)

        collect(self.root)
        return result
579900
def unattach_issue(resource_id, issue_id, table):
    """"""

    v1_utils.verify_existence_and_get(issue_id, _TABLE)
    if table.name == 'jobs':
        join_table = models.JOIN_JOBS_ISSUES
        where_clause = sql.and_(join_table.c.job_id == resource_id,
                                join_table.c.issue_id == issue_id)
    else:
        join_table = models.JOIN_COMPONENTS_ISSUES
        where_clause = sql.and_(join_table.c.component_id == resource_id,
                                join_table.c.issue_id == issue_id)

    query = join_table.delete().where(where_clause)
    result = flask.g.db_conn.execute(query)

    if not result.rowcount:
        raise dci_exc.DCIConflict('%s_issues' % table.name, issue_id)

    return flask.Response(None, 204, content_type='application/json')
148877
def sort_labeled_issues(issues)
      sorted_issues = []
      issues.each do |issue|
        label_names = issue["labels"].collect { |l| l["name"] }

        # Add PRs in the order of the @sections array. This will either be the
        # default sections followed by any --add-sections sections in
        # user-defined order, or --configure-sections in user-defined order.
        # Ignore the order of the issue labels from github which cannot be
        # controled by the user.
        @sections.each do |section|
          unless (section.labels & label_names).empty?
            section.issues << issue
            sorted_issues << issue
            break
          end
        end
      end
      issues - sorted_issues
    end
483485
def prune_urls(url_set, start_url, allowed_list, ignored_list):
    """"""
    result = set()

    for url in url_set:
        allowed = False
        for allow_url in allowed_list:
            if url.startswith(allow_url):
                allowed = True
                break

        if not allowed:
            continue

        ignored = False
        for ignore_url in ignored_list:
            if url.startswith(ignore_url):
                ignored = True
                break

        if ignored:
            continue

        prefix, suffix = (url.rsplit('.', 1) + [''])[:2]
        if suffix.lower() in IGNORE_SUFFIXES:
            continue

        result.add(url)

    return result
824562
def merge_conflicts(self):
        """"""
        filenames = set()
        listing = self.context.capture('git', 'ls-files', '--unmerged', '-z')
        for entry in split(listing, '\0'):
            # The output of `git ls-files --unmerged -z' consists of two
            # tab-delimited fields per zero-byte terminated record, where the
            # first field contains metadata and the second field contains the
            # filename. A single filename can be output more than once.
            metadata, _, name = entry.partition('\t')
            if metadata and name:
                filenames.add(name)
        return sorted(filenames)
987826
def _do_cancel_problems(self):
        
        try:
            while True:
                # Pull as many problems as we can, block when none are available.

                # `None` task is used to signal thread termination
                item = self._cancel_queue.get()
                if item is None:
                    break

                item_list = [item]
                while True:
                    try:
                        item_list.append(self._cancel_queue.get_nowait())
                    except queue.Empty:
                        break

                # Submit the problems, attach the ids as a json list in the
                # body of the delete query.
                try:
                    body = [item[0] for item in item_list]

                    try:
                        self.session.delete(posixpath.join(self.endpoint, 'problems/'), json=body)
                    except requests.exceptions.Timeout:
                        raise RequestTimeout

                except Exception as err:
                    for _, future in item_list:
                        if future is not None:
                            future._set_error(err, sys.exc_info())

                # Mark all the ids as processed regardless of success or failure.
                [self._cancel_queue.task_done() for _ in item_list]

                # this is equivalent to a yield to scheduler in other threading libraries
                time.sleep(0)

        except Exception as err:
            _LOGGER.exception(err)
1049738
def as_issue(self):
        
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.issue_url
        )
        return github.Issue.Issue(self._requester, headers, data, completed=True)
703817
def list_repos(owner=None, **kwargs):
    """"""
    client = get_repos_api()

    api_kwargs = {}
    api_kwargs.update(utils.get_page_kwargs(**kwargs))

    # pylint: disable=fixme
    # FIXME: Compatibility code until we work out how to conflate
    # the overlapping repos_list methods into one.
    repos_list = client.repos_list_with_http_info

    if owner is not None:
        api_kwargs["owner"] = owner
        if hasattr(client, "repos_list0_with_http_info"):
            # pylint: disable=no-member
            repos_list = client.repos_list0_with_http_info
    else:
        if hasattr(client, "repos_all_list_with_http_info"):
            # pylint: disable=no-member
            repos_list = client.repos_all_list_with_http_info

    with catch_raise_api_exception():
        res, _, headers = repos_list(**api_kwargs)

    ratelimits.maybe_rate_limit(client, headers)
    page_info = PageInfo.from_headers(headers)
    return [x.to_dict() for x in res], page_info
870522
def _process_open(self):
        """"""
        click.launch(self._format_issue_url())
        if not click.confirm('Did it work?', default=True):
            click.echo()
            self._process_print()
            click.secho(
                '\nOpen the line manually and copy the text above\n',
                fg='yellow'
            )
            click.secho(
                '  ' + self.REPO_URL + self.ISSUE_SUFFIX + '\n', bold=True
            )
313083
def _format_issue(issue):
    '''
    
    '''
    ret = {'id': issue.get('id'),
           'issue_number': issue.get('number'),
           'state': issue.get('state'),
           'title': issue.get('title'),
           'user': issue.get('user').get('login'),
           'html_url': issue.get('html_url')}

    assignee = issue.get('assignee')
    if assignee:
        assignee = assignee.get('login')

    labels = issue.get('labels')
    label_names = []
    for label in labels:
        label_names.append(label.get('name'))

    milestone = issue.get('milestone')
    if milestone:
        milestone = milestone.get('title')

    ret['assignee'] = assignee
    ret['labels'] = label_names
    ret['milestone'] = milestone

    return ret