text_prompt
stringlengths
157
13.1k
code_prompt
stringlengths
7
19.8k
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_commit(self, message, tree, parents, author={}, committer={}): """Create a commit on this repository. :param str message: (required), commit message :...
json = None if message and tree and isinstance(parents, list): url = self._build_url('git', 'commits', base_url=self._api) data = {'message': message, 'tree': tree, 'parents': parents, 'author': author, 'committer': committer} json = self._json(se...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_deployment(self, ref, force=False, payload='', auto_merge=False, description='', environment=None): """Create a deployment. :param str ref: (required)...
json = None if ref: url = self._build_url('deployments', base_url=self._api) data = {'ref': ref, 'force': force, 'payload': payload, 'auto_merge': auto_merge, 'description': description, 'environment': environment} self._remove...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_fork(self, organization=None): """Create a fork of this repository. :param str organization: (required), login for organization to create the fork und...
url = self._build_url('forks', base_url=self._api) if organization: resp = self._post(url, data={'organization': organization}) else: resp = self._post(url) json = self._json(resp, 202) return Repository(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_hook(self, name, config, events=['push'], active=True): """Create a hook on this repository. :param str name: (required), name of the hook :param dict...
json = None if name and config and isinstance(config, dict): url = self._build_url('hooks', base_url=self._api) data = {'name': name, 'config': config, 'events': events, 'active': active} json = self._json(self._post(url, data=data), 201) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_issue(self, title, body=None, assignee=None, milestone=None, labels=None): """Creates an issue on this repository. :param str title: (required), title...
issue = {'title': title, 'body': body, 'assignee': assignee, 'milestone': milestone, 'labels': labels} self._remove_none(issue) json = None if issue: url = self._build_url('issues', base_url=self._api) json = self._json(self._post(url, data=issu...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_key(self, title, key): """Create a deploy key. :param str title: (required), title of key :param str key: (required), key text :returns: :class:`Key <...
json = None if title and key: data = {'title': title, 'key': key} url = self._build_url('keys', base_url=self._api) json = self._json(self._post(url, data=data), 201) return Key(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_label(self, name, color): """Create a label for this repository. :param str name: (required), name to give to the label :param str color: (required), ...
json = None if name and color: data = {'name': name, 'color': color.strip('#')} url = self._build_url('labels', base_url=self._api) json = self._json(self._post(url, data=data), 201) return Label(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_milestone(self, title, state=None, description=None, due_on=None): """Create a milestone for this repository. :param str title: (required), title of t...
url = self._build_url('milestones', base_url=self._api) if state not in ('open', 'closed'): state = None data = {'title': title, 'state': state, 'description': description, 'due_on': due_on} self._remove_none(data) json = None if data: ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_pull(self, title, base, head, body=None): """Create a pull request of ``head`` onto ``base`` branch in this repo. :param str title: (required) :param ...
data = {'title': title, 'body': body, 'base': base, 'head': head} return self._create_pull(data)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_ref(self, ref, sha): """Create a reference in this repository. :param str ref: (required), fully qualified name of the reference, e.g. ``refs/heads/ma...
json = None if ref and ref.count('/') >= 2 and sha: data = {'ref': ref, 'sha': sha} url = self._build_url('git', 'refs', base_url=self._api) json = self._json(self._post(url, data=data), 201) return Reference(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_release(self, tag_name, target_commitish=None, name=None, body=None, draft=False, prerelease=False): """Create a release for this repository. :param s...
data = {'tag_name': str(tag_name), 'target_commitish': target_commitish, 'name': name, 'body': body, 'draft': draft, 'prerelease': prerelease } self._remove_none(data) url = self._build_url('release...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_status(self, sha, state, target_url=None, description=None, context='default'): """Create a status object on a commit. :param str sha: (required), SHA...
json = None if sha and state: data = {'state': state, 'target_url': target_url, 'description': description, 'context': context} url = self._build_url('statuses', sha, base_url=self._api) self._remove_none(data) json = self._json(self._...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_tag(self, tag, message, sha, obj_type, tagger, lightweight=False): """Create a tag in this repository. :param str tag: (required), name of the tag :pa...
if lightweight and tag and sha: return self.create_ref('refs/tags/' + tag, sha) json = None if tag and message and sha and obj_type and len(tagger) == 3: data = {'tag': tag, 'message': message, 'object': sha, 'type': obj_type, 'tagger': tagger} ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_tree(self, tree, base_tree=''): """Create a tree on this repository. :param list tree: (required), specifies the tree structure. Format: [{'path': 'pa...
json = None if tree and isinstance(tree, list): data = {'tree': tree, 'base_tree': base_tree} url = self._build_url('git', 'trees', base_url=self._api) json = self._json(self._post(url, data=data), 201) return Tree(json) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def delete_file(self, path, message, sha, branch=None, committer=None, author=None): """Delete the file located at ``path``. This is part of the Contents CrUD (C...
json = None if path and message and sha: url = self._build_url('contents', path, base_url=self._api) data = {'message': message, 'sha': sha, 'branch': branch, 'committer': validate_commmitter(committer), 'author': validate_commmitter(autho...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def delete_key(self, key_id): """Delete the key with the specified id from your deploy keys list. :returns: bool -- True if successful, False otherwise """
if int(key_id) <= 0: return False url = self._build_url('keys', str(key_id), base_url=self._api) return self._boolean(self._delete(url), 204, 404)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def edit(self, name, description=None, homepage=None, private=None, has_issues=None, has_wiki=None, has_downloads=None, default_branch=None): """Edit this reposi...
edit = {'name': name, 'description': description, 'homepage': homepage, 'private': private, 'has_issues': has_issues, 'has_wiki': has_wiki, 'has_downloads': has_downloads, 'default_branch': default_branch} self._remove_none(edit) json = None ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def hook(self, id_num): """Get a single hook. :param int id_num: (required), id of the hook :returns: :class:`Hook <github3.repos.hook.Hook>` if successful, othe...
json = None if int(id_num) > 0: url = self._build_url('hooks', str(id_num), base_url=self._api) json = self._json(self._get(url), 200) return Hook(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def is_assignee(self, login): """Check if the user is a possible assignee for an issue on this repository. :returns: :class:`bool` """
if not login: return False url = self._build_url('assignees', login, base_url=self._api) return self._boolean(self._get(url), 204, 404)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def issue(self, number): """Get the issue specified by ``number``. :param int number: (required), number of the issue on this repository :returns: :class:`Issue ...
json = None if int(number) > 0: url = self._build_url('issues', str(number), base_url=self._api) json = self._json(self._get(url), 200) return Issue(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def key(self, id_num): """Get the specified deploy key. :param int id_num: (required), id of the key :returns: :class:`Key <github3.users.Key>` if successful, el...
json = None if int(id_num) > 0: url = self._build_url('keys', str(id_num), base_url=self._api) json = self._json(self._get(url), 200) return Key(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def label(self, name): """Get the label specified by ``name`` :param str name: (required), name of the label :returns: :class:`Label <github3.issues.label.Label>...
json = None if name: url = self._build_url('labels', name, base_url=self._api) json = self._json(self._get(url), 200) return Label(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_branches(self, number=-1, etag=None): """Iterate over the branches in this repository. :param int number: (optional), number of branches to return. Defa...
url = self._build_url('branches', base_url=self._api) return self._iter(int(number), url, Branch, etag=etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_code_frequency(self, number=-1, etag=None): """Iterate over the code frequency per week. Returns a weekly aggregate of the number of additions and delet...
url = self._build_url('stats', 'code_frequency', base_url=self._api) return self._iter(int(number), url, list, etag=etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_comments_on_commit(self, sha, number=1, etag=None): """Iterate over comments for a single commit. :param sha: (required), sha of the commit to list comm...
url = self._build_url('commits', sha, 'comments', base_url=self._api) return self._iter(int(number), url, RepoComment, etag=etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_commit_activity(self, number=-1, etag=None): """Iterate over last year of commit activity by week. See: http://developer.github.com/v3/repos/statistics/...
url = self._build_url('stats', 'commit_activity', base_url=self._api) return self._iter(int(number), url, dict, etag=etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_commits(self, sha=None, path=None, author=None, number=-1, etag=None, since=None, until=None): """Iterate over commits in this repository. :param str sh...
params = {'sha': sha, 'path': path, 'author': author, 'since': timestamp_parameter(since), 'until': timestamp_parameter(until)} self._remove_none(params) url = self._build_url('commits', base_url=self._api) return self._iter(int(number), url, RepoCom...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_contributors(self, anon=False, number=-1, etag=None): """Iterate over the contributors to this repository. :param bool anon: (optional), True lists anon...
url = self._build_url('contributors', base_url=self._api) params = {} if anon: params = {'anon': True} return self._iter(int(number), url, User, params, etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_contributor_statistics(self, number=-1, etag=None): """Iterate over the contributors list. See also: http://developer.github.com/v3/repos/statistics/ :p...
url = self._build_url('stats', 'contributors', base_url=self._api) return self._iter(int(number), url, ContributorStats, etag=etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_deployments(self, number=-1, etag=None): """Iterate over deployments for this repository. :param int number: (optional), number of deployments to return...
url = self._build_url('deployments', base_url=self._api) i = self._iter(int(number), url, Deployment, etag=etag) i.headers.update(Deployment.CUSTOM_HEADERS) return i
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_forks(self, sort='', number=-1, etag=None): """Iterate over forks of this repository. :param str sort: (optional), accepted values: ('newest', 'oldest',...
url = self._build_url('forks', base_url=self._api) params = {} if sort in ('newest', 'oldest', 'watchers'): params = {'sort': sort} return self._iter(int(number), url, Repository, params, etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_hooks(self, number=-1, etag=None): """Iterate over hooks registered on this repository. :param int number: (optional), number of hoks to return. Default...
url = self._build_url('hooks', base_url=self._api) return self._iter(int(number), url, Hook, etag=etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_issues(self, milestone=None, state=None, assignee=None, mentioned=None, labels=None, sort=None, direction=None, since=None, number=-1, etag=None): """It...
url = self._build_url('issues', base_url=self._api) params = {'assignee': assignee, 'mentioned': mentioned} if milestone in ('*', 'none') or isinstance(milestone, int): params['milestone'] = milestone self._remove_none(params) params.update( issue_params...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_issue_events(self, number=-1, etag=None): """Iterates over issue events on this repository. :param int number: (optional), number of events to return. D...
url = self._build_url('issues', 'events', base_url=self._api) return self._iter(int(number), url, IssueEvent, etag=etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_languages(self, number=-1, etag=None): """Iterate over the programming languages used in the repository. :param int number: (optional), number of langua...
url = self._build_url('languages', base_url=self._api) return self._iter(int(number), url, tuple, etag=etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_milestones(self, state=None, sort=None, direction=None, number=-1, etag=None): """Iterates over the milestones on this repository. :param str state: (op...
url = self._build_url('milestones', base_url=self._api) accepted = {'state': ('open', 'closed'), 'sort': ('due_date', 'completeness'), 'direction': ('asc', 'desc')} params = {'state': state, 'sort': sort, 'direction': direction} for (k, v) in list...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_network_events(self, number=-1, etag=None): """Iterates over events on a network of repositories. :param int number: (optional), number of events to ret...
base = self._api.replace('repos', 'networks', 1) url = self._build_url('events', base_url=base) return self._iter(int(number), url, Event, etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_notifications(self, all=False, participating=False, since=None, number=-1, etag=None): """Iterates over the notifications for this repository. :param bo...
url = self._build_url('notifications', base_url=self._api) params = { 'all': all, 'participating': participating, 'since': timestamp_parameter(since) } for (k, v) in list(params.items()): if not v: del params[k] ret...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_pages_builds(self, number=-1, etag=None): """Iterate over pages builds of this repository. :returns: generator of :class:`PagesBuild <github3.repos.page...
url = self._build_url('pages', 'builds', base_url=self._api) return self._iter(int(number), url, PagesBuild, etag=etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_pulls(self, state=None, head=None, base=None, sort='created', direction='desc', number=-1, etag=None): """List pull requests on repository. .. versionch...
url = self._build_url('pulls', base_url=self._api) params = {} if state and state.lower() in ('all', 'open', 'closed'): params['state'] = state.lower() params.update(head=head, base=base, sort=sort, direction=direction) self._remove_none(params) return self._...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_refs(self, subspace='', number=-1, etag=None): """Iterates over references for this repository. :param str subspace: (optional), e.g. 'tags', 'stashes',...
if subspace: args = ('git', 'refs', subspace) else: args = ('git', 'refs') url = self._build_url(*args, base_url=self._api) return self._iter(int(number), url, Reference, etag=etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_releases(self, number=-1, etag=None): """Iterates over releases for this repository. :param int number: (optional), number of refs to return. Default: -...
url = self._build_url('releases', base_url=self._api) iterator = self._iter(int(number), url, Release, etag=etag) iterator.headers.update(Release.CUSTOM_HEADERS) return iterator
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_statuses(self, sha, number=-1, etag=None): """Iterates over the statuses for a specific SHA. :param str sha: SHA of the commit to list the statuses of :...
url = '' if sha: url = self._build_url('statuses', sha, base_url=self._api) return self._iter(int(number), url, Status, etag=etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_tags(self, number=-1, etag=None): """Iterates over tags on this repository. :param int number: (optional), return up to at most number tags. Default: -1...
url = self._build_url('tags', base_url=self._api) return self._iter(int(number), url, RepoTag, etag=etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def mark_notifications(self, last_read=''): """Mark all notifications in this repository as read. :param str last_read: (optional), Describes the last point that...
url = self._build_url('notifications', base_url=self._api) mark = {'read': True} if last_read: mark['last_read_at'] = last_read return self._boolean(self._put(url, data=dumps(mark)), 205, 404)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def merge(self, base, head, message=''): """Perform a merge from ``head`` into ``base``. :param str base: (required), where you're merging into :param str head: ...
url = self._build_url('merges', base_url=self._api) data = {'base': base, 'head': head} if message: data['commit_message'] = message json = self._json(self._post(url, data=data), 201) return RepoCommit(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def milestone(self, number): """Get the milestone indicated by ``number``. :param int number: (required), unique id number of the milestone :returns: :class:`Mil...
json = None if int(number) > 0: url = self._build_url('milestones', str(number), base_url=self._api) json = self._json(self._get(url), 200) return Milestone(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def pages(self): """Get information about this repository's pages site. :returns: :class:`PagesInfo <github3.repos.pages.PagesInfo>` """
url = self._build_url('pages', base_url=self._api) json = self._json(self._get(url), 200) return PagesInfo(json) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def pull_request(self, number): """Get the pull request indicated by ``number``. :param int number: (required), number of the pull request. :returns: :class:`Pul...
json = None if int(number) > 0: url = self._build_url('pulls', str(number), base_url=self._api) json = self._json(self._get(url), 200) return PullRequest(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def readme(self): """Get the README for this repository. :returns: :class:`Contents <github3.repos.contents.Contents>` """
url = self._build_url('readme', base_url=self._api) json = self._json(self._get(url), 200) return Contents(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def ref(self, ref): """Get a reference pointed to by ``ref``. The most common will be branches and tags. For a branch, you must specify 'heads/branchname' and fo...
json = None if ref: url = self._build_url('git', 'refs', ref, base_url=self._api) json = self._json(self._get(url), 200) return Reference(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def release(self, id): """Get a single release. :param int id: (required), id of release :returns: :class:`Release <github3.repos.release.Release>` """
json = None if int(id) > 0: url = self._build_url('releases', str(id), base_url=self._api) json = self._json(self._get(url), 200) return Release(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def remove_collaborator(self, login): """Remove collaborator ``login`` from the repository. :param str login: (required), login name of the collaborator :returns...
resp = False if login: url = self._build_url('collaborators', login, base_url=self._api) resp = self._boolean(self._delete(url), 204, 404) return resp
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def tag(self, sha): """Get an annotated tag. http://learn.github.com/p/tagging.html :param str sha: (required), sha of the object for this tag :returns: :class:`...
json = None if sha: url = self._build_url('git', 'tags', sha, base_url=self._api) json = self._json(self._get(url), 200) return Tag(json) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def tree(self, sha): """Get a tree. :param str sha: (required), sha of the object for this tree :returns: :class:`Tree <github3.git.Tree>` """
json = None if sha: url = self._build_url('git', 'trees', sha, base_url=self._api) json = self._json(self._get(url), 200) return Tree(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_label(self, name, color, new_name=''): """Update the label ``name``. :param str name: (required), name of the label :param str color: (required), colo...
label = self.label(name) resp = False if label: upd = label.update resp = upd(new_name, color) if new_name else upd(name, color) return resp
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def weekly_commit_count(self): """Returns the total commit counts. The dictionary returned has two entries: ``all`` and ``owner``. Each has a fifty-two element l...
url = self._build_url('stats', 'participation', base_url=self._api) resp = self._get(url) if resp.status_code == 202: return {} json = self._json(resp, 200) if json.get('ETag'): del json['ETag'] if json.get('Last-Modified'): del json['...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_status(self, state, target_url='', description=''): """Create a new deployment status for this deployment. :param str state: (required), The state of ...
json = None if state in ('pending', 'success', 'error', 'failure'): data = {'state': state, 'target_url': target_url, 'description': description} response = self._post(self.statuses_url, data=data, headers=Deployment.CUSTOM_...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_statuses(self, number=-1, etag=None): """Iterate over the deployment statuses for this deployment. :param int number: (optional), the number of statuses...
i = self._iter(int(number), self.statuses_url, DeploymentStatus, etag=etag) i.headers = Deployment.CUSTOM_HEADERS return i
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_gist(self): """Retrieve the gist at this version. :returns: :class:`Gist <github3.gists.gist.Gist>` """
from .gist import Gist json = self._json(self._get(self._api), 200) return Gist(json, self)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update(self, sha, force=False): """Update this reference. :param str sha: (required), sha of the reference :param bool force: (optional), force the update or...
data = {'sha': sha, 'force': force} json = self._json(self._patch(self._api, data=dumps(data)), 200) if json: self._update_(json) return True return False
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def recurse(self): """Recurse into the tree. :returns: :class:`Tree <Tree>` """
json = self._json(self._get(self._api, params={'recursive': '1'}), 200) return Tree(json, self._session) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get(args): """Get an Aegea configuration parameter by name"""
from . import config for key in args.key.split("."): config = getattr(config, key) print(json.dumps(config))
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set(args): """Set an Aegea configuration parameter to a given value"""
from . import config, tweak class ConfigSaver(tweak.Config): @property def config_files(self): return [config.config_files[2]] config_saver = ConfigSaver(use_yaml=True, save_on_exit=False) c = config_saver for key in args.key.split(".")[:-1]: try: c...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def authorize(login, password, scopes, note='', note_url='', client_id='', client_secret='', two_factor_callback=None): """Obtain an authorization token for the ...
gh = GitHub() gh.login(two_factor_callback=two_factor_callback) return gh.authorize(login, password, scopes, note, note_url, client_id, client_secret)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def login(username=None, password=None, token=None, url=None, two_factor_callback=None): """Construct and return an authenticated GitHub session. This will retur...
g = None if (username and password) or token: g = GitHubEnterprise(url) if url is not None else GitHub() g.login(username, password, token, two_factor_callback) return g
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_followers(username, number=-1, etag=None): """List the followers of ``username``. :param str username: (required), login of the person to list the follo...
return gh.iter_followers(username, number, etag) if username else []
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_following(username, number=-1, etag=None): """List the people ``username`` follows. :param str username: (required), login of the user :param int number...
return gh.iter_following(username, number, etag) if username else []
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_orgs(username, number=-1, etag=None): """List the organizations associated with ``username``. :param str username: (required), login of the user :param ...
return gh.iter_orgs(username, number, etag) if username else []
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_user_repos(login, type=None, sort=None, direction=None, number=-1, etag=None): """List public repositories for the specified ``login``. .. versionadded:...
if login: return gh.iter_user_repos(login, type, sort, direction, number, etag) return iter([])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def add_labels(self, *args): """Add labels to this issue. :param str args: (required), names of the labels you wish to add :returns: list of :class:`Label`\ s ""...
url = self._build_url('labels', base_url=self._api) json = self._json(self._post(url, data=args), 200) return [Label(l, self) for l in json] if json else []
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def assign(self, login): """Assigns user ``login`` to this issue. This is a short cut for ``issue.edit``. :param str login: username of the person to assign this...
if not login: return False number = self.milestone.number if self.milestone else None labels = [str(l) for l in self.labels] return self.edit(self.title, self.body, login, self.state, number, labels)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def comment(self, id_num): """Get a single comment by its id. The catch here is that id is NOT a simple number to obtain. If you were to look at the comments on ...
json = None if int(id_num) > 0: # Might as well check that it's positive owner, repo = self.repository url = self._build_url('repos', owner, repo, 'issues', 'comments', str(id_num)) json = self._json(self._get(url), 200) ret...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_comment(self, body): """Create a comment on this issue. :param str body: (required), comment body :returns: :class:`IssueComment <github3.issues.comme...
json = None if body: url = self._build_url('comments', base_url=self._api) json = self._json(self._post(url, data={'body': body}), 201) return IssueComment(json, self) if json else None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def edit(self, title=None, body=None, assignee=None, state=None, milestone=None, labels=None): """Edit this issue. :param str title: Title of the issue :param st...
json = None data = {'title': title, 'body': body, 'assignee': assignee, 'state': state, 'milestone': milestone, 'labels': labels} self._remove_none(data) if data: if 'milestone' in data and data['milestone'] == 0: data['milestone'] = None ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_comments(self, number=-1): """Iterate over the comments on this issue. :param int number: (optional), number of comments to iterate over :returns: itera...
url = self._build_url('comments', base_url=self._api) return self._iter(int(number), url, IssueComment)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_events(self, number=-1): """Iterate over events associated with this issue only. :param int number: (optional), number of events to return. Default: -1 ...
url = self._build_url('events', base_url=self._api) return self._iter(int(number), url, IssueEvent)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def remove_label(self, name): """Removes label ``name`` from this issue. :param str name: (required), name of the label to remove :returns: bool """
url = self._build_url('labels', name, base_url=self._api) # Docs say it should be a list of strings returned, practice says it # is just a 204/404 response. I'm tenatively changing this until I # hear back from Support. return self._boolean(self._delete(url), 204, 404)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def replace_labels(self, labels): """Replace all labels on this issue with ``labels``. :param list labels: label names :returns: bool """
url = self._build_url('labels', base_url=self._api) json = self._json(self._put(url, data=dumps(labels)), 200) return [Label(l, self) for l in json] if json else []
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def reopen(self): """Re-open a closed issue. :returns: bool """
assignee = self.assignee.login if self.assignee else '' number = self.milestone.number if self.milestone else None labels = [str(l) for l in self.labels] return self.edit(self.title, self.body, assignee, 'open', number, labels)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _strptime(self, time_str): """Convert an ISO 8601 formatted string in UTC into a timezone-aware datetime object."""
if time_str: # Parse UTC string into naive datetime, then add timezone dt = datetime.strptime(time_str, __timeformat__) return dt.replace(tzinfo=UTC()) return None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _iter(self, count, url, cls, params=None, etag=None): """Generic iterator for this project. :param int count: How many items to return. :param int url: First...
from .structs import GitHubIterator return GitHubIterator(count, url, cls, self, params, etag)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def ratelimit_remaining(self): """Number of requests before GitHub imposes a ratelimit. :returns: int """
json = self._json(self._get(self._github_url + '/rate_limit'), 200) core = json.get('resources', {}).get('core', {}) self._remaining = core.get('remaining', 0) return self._remaining
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def refresh(self, conditional=False): """Re-retrieve the information for this object and returns the refreshed instance. :param bool conditional: If True, then w...
headers = {} if conditional: if self.last_modified: headers['If-Modified-Since'] = self.last_modified elif self.etag: headers['If-None-Match'] = self.etag headers = headers or None json = self._json(self._get(self._api, headers=he...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def edit(self, body): """Edit this comment. :param str body: (required), new body of the comment, Markdown formatted :returns: bool """
if body: json = self._json(self._patch(self._api, data=dumps({'body': body})), 200) if json: self._update_(json) return True return False
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description:
def toplot(ts, filename=None, grid=True, legend=True, pargs=(), **kwargs): '''To plot formatter''' fig = plt.figure() ax = fig.add_subplot(111) dates = list(ts.dates()) ax.plot(dates, ts.values(), *pargs) ax.grid(grid) # ro...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def check_table(table): """ Ensure the table is valid for converting to grid table. * The table must a list of lists * Each row must contain the same number of c...
if not type(table) is list: return "Table must be a list of lists" if len(table) == 0: return "Table must contain at least one row and one column" for i in range(len(table)): if not type(table[i]) is list: return "Table must be a list of lists" if not len(table...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _translate_nodes(root, *nodes): """ """
#name2node = {[n, None] for n in nodes if type(n) is str} name2node = dict([[n, None] for n in nodes if type(n) is str]) for n in root.traverse(): if n.name in name2node: if name2node[n.name] is not None: raise TreeError("Ambiguous node name: {}".format(str(n.name))) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def add_feature(self, pr_name, pr_value): """ Add or update a node's feature. """
setattr(self, pr_name, pr_value) self.features.add(pr_name)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def add_features(self, **features): """ Add or update several features. """
for fname, fvalue in six.iteritems(features): setattr(self, fname, fvalue) self.features.add(fname)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def del_feature(self, pr_name): """ Permanently deletes a node's feature."""
if hasattr(self, pr_name): delattr(self, pr_name) self.features.remove(pr_name)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def add_sister(self, sister=None, name=None, dist=None): """ Adds a sister to this node. If sister node is not supplied as an argument, a new TreeNode instance w...
if self.up == None: raise TreeError("A parent node is required to add a sister") else: return self.up.add_child(child=sister, name=name, dist=dist)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def delete(self, prevent_nondicotomic=True, preserve_branch_length=False): """ Deletes node from the tree structure. Notice that this method makes 'disappear' th...
parent = self.up if parent: if preserve_branch_length: if len(self.children) == 1: self.children[0].dist += self.dist elif len(self.children) > 1: parent.dist += self.dist for ch in self.children: ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def prune(self, nodes, preserve_branch_length=False): """ Prunes the topology of a node to conserve only a selected list of leaf internal nodes. The minimum numb...
def cmp_nodes(x, y): # if several nodes are in the same path of two kept nodes, # only one should be maintained. This prioritize internal # nodes that are already in the to_keep list and then # deeper nodes (closer to the leaves). if n2depth[x] > n2d...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_sisters(self): """ Returns an indepent list of sister nodes."""
if self.up != None: return [ch for ch in self.up.children if ch != self] else: return []
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_leaves(self, is_leaf_fn=None): """ Returns an iterator over the leaves under this node."""
for n in self.traverse(strategy="preorder", is_leaf_fn=is_leaf_fn): if not is_leaf_fn: if n.is_leaf(): yield n else: if is_leaf_fn(n): yield n
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_leaf_names(self, is_leaf_fn=None): """Returns an iterator over the leaf names under this node."""
for n in self.iter_leaves(is_leaf_fn=is_leaf_fn): yield n.name
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def iter_descendants(self, strategy="levelorder", is_leaf_fn=None): """ Returns an iterator over all descendant nodes."""
for n in self.traverse(strategy=strategy, is_leaf_fn=is_leaf_fn): if n is not self: yield n
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _iter_descendants_levelorder(self, is_leaf_fn=None): """ Iterate over all desdecendant nodes."""
tovisit = deque([self]) while len(tovisit) > 0: node = tovisit.popleft() yield node if not is_leaf_fn or not is_leaf_fn(node): tovisit.extend(node.children)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _iter_descendants_preorder(self, is_leaf_fn=None): """ Iterator over all descendant nodes. """
to_visit = deque() node = self while node is not None: yield node if not is_leaf_fn or not is_leaf_fn(node): to_visit.extendleft(reversed(node.children)) try: node = to_visit.popleft() except: node =...