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 delete(self):
"""Users with push access to the repository can delete a release. :returns: True if successful; False if not successful """ |
url = self._api
return self._boolean(
self._delete(url, headers=Release.CUSTOM_HEADERS),
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, tag_name=None, target_commitish=None, name=None, body=None, draft=None, prerelease=None):
"""Users with push access to the repository can edit a r... |
url = self._api
data = {
'tag_name': tag_name,
'target_commitish': target_commitish,
'name': name,
'body': body,
'draft': draft,
'prerelease': prerelease,
}
self._remove_none(data)
r = self._session.patch(
... |
<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_assets(self, number=-1, etag=None):
"""Iterate over the assets available for this release. :param int number: (optional), Number of assets to return :pa... |
url = self._build_url('assets', base_url=self._api)
return self._iter(number, url, Asset, 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 upload_asset(self, content_type, name, asset):
"""Upload an asset to this release. All parameters are required. :param str content_type: The content type of ... |
headers = Release.CUSTOM_HEADERS.copy()
headers.update({'Content-Type': content_type})
url = self.upload_urlt.expand({'name': name})
r = self._post(url, data=asset, json=False, headers=headers,
verify=False)
if r.status_code in (201, 202):
retu... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def download(self, path=''):
"""Download the data for this asset. :param path: (optional), path where the file should be saved to, default is the filename provid... |
headers = {
'Accept': 'application/octet-stream'
}
resp = self._get(self._api, allow_redirects=False, stream=True,
headers=headers)
if resp.status_code == 302:
# Amazon S3 will reject the redirected request unless we omit
... |
<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, label=None):
"""Edit this asset. :param str name: (required), The file name of the asset :param str label: (optional), An alternate descript... |
if not name:
return False
edit_data = {'name': name, 'label': label}
self._remove_none(edit_data)
r = self._patch(
self._api,
data=json.dumps(edit_data),
headers=Release.CUSTOM_HEADERS
)
successful = self._boolean(r, 200, 4... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def ls(args):
""" List status of all configured SNS-SQS message buses and instances subscribed to them. """ |
table = []
queues = list(resources.sqs.queues.filter(QueueNamePrefix="github"))
max_age = datetime.now(tzutc()) - timedelta(days=15)
for topic in resources.sns.topics.all():
account_id = ARN(topic.arn).account_id
try:
bucket = resources.s3.Bucket("deploy-status-{}".format(ac... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def grant(args):
""" Given an IAM role or instance name, attach an IAM policy granting appropriate permissions to subscribe to deployments. Given a GitHub repo U... |
try:
role = resources.iam.Role(args.iam_role_or_instance)
role.load()
except ClientError:
role = get_iam_role_for_instance(args.iam_role_or_instance)
role.attach_policy(PolicyArn=ensure_deploy_iam_policy().arn)
for private_repo in [args.repo] + list(private_submodules(args.repo)... |
<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, message, branch=None, committer=None, author=None):
"""Delete this file. :param str message: (required), commit message to describe the removal ... |
json = None
if message:
data = {'message': message, 'sha': self.sha, 'branch': branch,
'committer': validate_commmitter(committer),
'author': validate_commmitter(author)}
self._remove_none(data)
json = self._json(self._delete(s... |
<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, message, content, branch=None, committer=None, author=None):
"""Update this file. :param str message: (required), commit message to describe the... |
if content and not isinstance(content, bytes):
raise ValueError( # (No coverage)
'content must be a bytes object') # (No coverage)
json = None
if message and content:
content = b64encode(content).decode('utf-8')
data = {'message': message, ... |
<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, description='', files={}):
"""Edit this gist. :param str description: (optional), description of the gist :param dict files: (optional), files tha... |
data = {}
json = None
if description:
data['description'] = description
if files:
data['files'] = files
if data:
json = self._json(self._patch(self._api, data=dumps(data)), 200)
if json:
self._update_(json)
retu... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def fork(self):
"""Fork this gist. :returns: :class:`Gist <Gist>` if successful, ``None`` otherwise """ |
url = self._build_url('forks', base_url=self._api)
json = self._json(self._post(url), 201)
return Gist(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_starred(self):
"""Check to see if this gist is starred by the authenticated user. :returns: bool -- True if it is starred, False otherwise """ |
url = self._build_url('star', 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 iter_commits(self, number=-1, etag=None):
"""Iter over the commits on this gist. These commits will be requested from the API and should be the same as what ... |
url = self._build_url('commits', base_url=self._api)
return self._iter(int(number), url, GistHistory) |
<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, number=-1, etag=None):
"""Iterator of forks of this gist. .. versionchanged:: 0.9 Added params ``number`` and ``etag``. :param int number: (... |
url = self._build_url('forks', base_url=self._api)
return self._iter(int(number), url, Gist, 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 star(self):
"""Star this gist. :returns: bool -- True if successful, False otherwise """ |
url = self._build_url('star', base_url=self._api)
return self._boolean(self._put(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 unstar(self):
"""Un-star this gist. :returns: bool -- True if successful, False otherwise """ |
url = self._build_url('star', 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 update(self, body):
"""Update this comment. :param str body: (required) :returns: bool """ |
json = None
if body:
json = self._json(self._post(self._api, data={'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 scp(args):
""" Transfer files to or from EC2 instance. Use "--" to separate scp args from aegea args: aegea scp -- -r local_dir instance_name:~/remote_dir ""... |
if args.scp_args[0] == "--":
del args.scp_args[0]
user_or_hostname_chars = string.ascii_letters + string.digits
for i, arg in enumerate(args.scp_args):
if arg[0] in user_or_hostname_chars and ":" in arg:
hostname, colon, path = arg.partition(":")
username, at, hostna... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def ls(args):
""" List S3 buckets. See also "aws s3 ls". Use "aws s3 ls NAME" to list bucket contents. """ |
table = []
for bucket in filter_collection(resources.s3.buckets, args):
bucket.LocationConstraint = clients.s3.get_bucket_location(Bucket=bucket.name)["LocationConstraint"]
cloudwatch = resources.cloudwatch
bucket_region = bucket.LocationConstraint or "us-east-1"
if bucket_regio... |
<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, name, color):
"""Update this label. :param str name: (required), new name of the label :param str color: (required), color code, e.g., 626262, n... |
json = None
if name and color:
if color[0] == '#':
color = color[1:]
json = self._json(self._patch(self._api, data=dumps({
'name': name, 'color': color})), 200)
if json:
self._update_(json)
return True
re... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def basic_auth(self, username, password):
"""Set the Basic Auth credentials on this Session. :param str username: Your GitHub username :param str password: Your ... |
if not (username and password):
return
self.auth = (username, password)
# Disable token authentication
self.headers.pop('Authorization', 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 build_url(self, *args, **kwargs):
"""Builds a new API url from scratch.""" |
parts = [kwargs.get('base_url') or self.base_url]
parts.extend(args)
parts = [str(p) for p in parts]
key = tuple(parts)
__logs__.info('Building a url from %s', key)
if not key in __url_cache__:
__logs__.info('Missed the cache building the url')
__... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def retrieve_client_credentials(self):
"""Return the client credentials. :returns: tuple(client_id, client_secret) """ |
client_id = self.params.get('client_id')
client_secret = self.params.get('client_secret')
return (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 token_auth(self, token):
"""Use an application token for authentication. :param str token: Application token retrieved from GitHub's /authorizations endpoint... |
if not token:
return
self.headers.update({
'Authorization': 'token {0}'.format(token)
})
# Unset username/password so we stop sending them
self.auth = 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 no_auth(self):
"""Unset authentication temporarily as a context manager.""" |
old_basic_auth, self.auth = self.auth, None
old_token_auth = self.headers.pop('Authorization', None)
yield
self.auth = old_basic_auth
if old_token_auth:
self.headers['Authorization'] = old_token_auth |
<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, config={}, events=[], add_events=[], rm_events=[], active=True):
"""Edit this hook. :param dict config: (optional), key-value pairs of settings fo... |
data = {'config': config, 'active': active}
if events:
data['events'] = events
if add_events:
data['add_events'] = add_events
if rm_events:
data['remove_events'] = rm_events
json = self._json(self._patch(self._api, data=dumps(data)), 200)
... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def ping(self):
"""Ping this hook. :returns: bool """ |
url = self._build_url('pings', base_url=self._api)
return self._boolean(self._post(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 requires_auth(func):
"""Decorator to note which object methods require authorization.""" |
@wraps(func)
def auth_wrapper(self, *args, **kwargs):
auth = False
if hasattr(self, '_session'):
auth = (self._session.auth or
self._session.headers.get('Authorization'))
if auth:
return func(self, *args, **kwargs)
else:
f... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def requires_app_credentials(func):
"""Require client_id and client_secret to be associated. This is used to note and enforce which methods require a client_id a... |
@wraps(func)
def auth_wrapper(self, *args, **kwargs):
client_id, client_secret = self._session.retrieve_client_credentials()
if client_id and client_secret:
return func(self, *args, **kwargs)
else:
from .models import GitHubError
# Mock a 401 response... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def authorization(self, id_num):
"""Get information about authorization ``id``. :param int id_num: (required), unique id of the authorization :returns: :class:`A... |
json = None
if int(id_num) > 0:
url = self._build_url('authorizations', str(id_num))
json = self._json(self._get(url), 200)
return Authorization(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 authorize(self, login, password, scopes=None, note='', note_url='', client_id='', client_secret=''):
"""Obtain an authorization token from the GitHub API for... |
json = None
# TODO: Break this behaviour in 1.0 (Don't rely on self._session.auth)
auth = None
if self._session.auth:
auth = self._session.auth
elif login and password:
auth = (login, password)
if auth:
url = self._build_url('authoriz... |
<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_authorization(self, access_token):
"""OAuth applications can use this method to check token validity without hitting normal rate limits because of fail... |
p = self._session.params
auth = (p.get('client_id'), p.get('client_secret'))
if access_token and auth:
url = self._build_url('applications', str(auth[0]), 'tokens',
str(access_token))
resp = self._get(url, auth=auth, 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 create_gist(self, description, files, public=True):
"""Create a new gist. If no login was provided, it will be anonymous. :param str description: (required),... |
new_gist = {'description': description, 'public': public,
'files': files}
url = self._build_url('gists')
json = self._json(self._post(url, data=new_gist), 201)
return Gist(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_issue(self, owner, repository, title, body=None, assignee=None, milestone=None, labels=[]):
"""Create an issue on the project 'repository' owned by 'o... |
repo = None
if owner and repository and title:
repo = self.repository(owner, repository)
if repo:
return repo.create_issue(title, body, assignee, milestone, labels)
# Regardless, something went wrong. We were unable to create the
# issue
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 create_key(self, title, key):
"""Create a new key for the authenticated user. :param str title: (required), key title :param key: (required), actual key cont... |
created = None
if title and key:
url = self._build_url('user', 'keys')
req = self._post(url, data={'title': title, 'key': key})
json = self._json(req, 201)
if json:
created = Key(json, self)
return created |
<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 user key pointed to by ``key_id``. :param int key_id: (required), unique id used by Github :returns: bool """ |
key = self.key(key_id)
if key:
return key.delete()
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 emojis(self):
"""Retrieves a dictionary of all of the emojis that GitHub supports. :returns: dictionary where the key is what would be in between the colons ... |
url = self._build_url('emojis')
return self._json(self._get(url), 200) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def feeds(self):
"""List GitHub's timeline resources in Atom format. :returns: dictionary parsed to include URITemplates """ |
url = self._build_url('feeds')
json = self._json(self._get(url), 200)
del json['ETag']
del json['Last-Modified']
urls = [
'timeline_url', 'user_url', 'current_user_public_url',
'current_user_url', 'current_user_actor_url',
'current_user_organ... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def follow(self, login):
"""Make the authenticated user follow login. :param str login: (required), user to follow :returns: bool """ |
resp = False
if login:
url = self._build_url('user', 'following', login)
resp = self._boolean(self._put(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 gist(self, id_num):
"""Gets the gist using the specified id number. :param int id_num: (required), unique id of the gist :returns: :class:`Gist <github3.gist... |
url = self._build_url('gists', str(id_num))
json = self._json(self._get(url), 200)
return Gist(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 gitignore_template(self, language):
"""Returns the template for language. :returns: str """ |
url = self._build_url('gitignore', 'templates', language)
json = self._json(self._get(url), 200)
if not json:
return ''
return json.get('source', '') |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def gitignore_templates(self):
"""Returns the list of available templates. :returns: list of template names """ |
url = self._build_url('gitignore', 'templates')
return self._json(self._get(url), 200) or [] |
<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_following(self, login):
"""Check if the authenticated user is following login. :param str login: (required), login of the user to check if the authenticat... |
json = False
if login:
url = self._build_url('user', 'following', login)
json = self._boolean(self._get(url), 204, 404)
return 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 iter_all_repos(self, number=-1, since=None, etag=None, per_page=None):
"""Iterate over every repository in the order they were created. :param int number: (o... |
url = self._build_url('repositories')
return self._iter(int(number), url, Repository,
params={'since': since, 'per_page': per_page},
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_all_users(self, number=-1, etag=None, per_page=None):
"""Iterate over every user in the order they signed up for GitHub. :param int number: (optional), ... |
url = self._build_url('users')
return self._iter(int(number), url, User,
params={'per_page': per_page}, 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_authorizations(self, number=-1, etag=None):
"""Iterate over authorizations for the authenticated user. This will return a 404 if you are using a token f... |
url = self._build_url('authorizations')
return self._iter(int(number), url, Authorization, 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_emails(self, number=-1, etag=None):
"""Iterate over email addresses for the authenticated user. :param int number: (optional), number of email addresses... |
url = self._build_url('user', 'emails')
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_events(self, number=-1, etag=None):
"""Iterate over public events. :param int number: (optional), number of events to return. Default: -1 returns all av... |
url = self._build_url('events')
return self._iter(int(number), url, Event, 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_followers(self, login=None, number=-1, etag=None):
"""If login is provided, iterate over a generator of followers of that login name; otherwise return a... |
if login:
return self.user(login).iter_followers()
return self._iter_follow('followers', int(number), 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_following(self, login=None, number=-1, etag=None):
"""If login is provided, iterate over a generator of users being followed by login; otherwise return ... |
if login:
return self.user(login).iter_following()
return self._iter_follow('following', int(number), 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_notifications(self, all=False, participating=False, number=-1, etag=None):
"""Iterate over the user's notification. :param bool all: (optional), iterate... |
params = None
if all:
params = {'all': all}
elif participating:
params = {'participating': participating}
url = self._build_url('notifications')
return self._iter(int(number), url, Thread, params, 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_org_issues(self, name, filter='', state='', labels='', sort='', direction='', since=None, number=-1, etag=None):
"""Iterate over the organnization's iss... |
url = self._build_url('orgs', name, 'issues')
# issue_params will handle the since parameter
params = issue_params(filter, state, labels, sort, direction, since)
return self._iter(int(number), url, Issue, 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_orgs(self, login=None, number=-1, etag=None):
"""Iterate over public organizations for login if provided; otherwise iterate over public and private orga... |
if login:
url = self._build_url('users', login, 'orgs')
else:
url = self._build_url('user', 'orgs')
return self._iter(int(number), url, Organization, 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_repos(self, type=None, sort=None, direction=None, number=-1, etag=None):
"""List public repositories for the authenticated user. .. versionchanged:: 0.6... |
url = self._build_url('user', 'repos')
params = {}
if type in ('all', 'owner', 'public', 'private', 'member'):
params.update(type=type)
if sort in ('created', 'updated', 'pushed', 'full_name'):
params.update(sort=sort)
if direction in ('asc', 'desc'):
... |
<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_starred(self, login=None, sort=None, direction=None, number=-1, etag=None):
"""Iterate over repositories starred by ``login`` or the authenticated user.... |
if login:
return self.user(login).iter_starred(sort, direction)
params = {'sort': sort, 'direction': direction}
self._remove_none(params)
url = self._build_url('user', 'starred')
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_subscriptions(self, login=None, number=-1, etag=None):
"""Iterate over repositories subscribed to by ``login`` or the authenticated user. :param str log... |
if login:
return self.user(login).iter_subscriptions()
url = self._build_url('user', 'subscriptions')
return self._iter(int(number), url, Repository, 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_user_teams(self, number=-1, etag=None):
"""Gets the authenticated user's teams across all of organizations. List all of the teams across all of the orga... |
url = self._build_url('user', 'teams')
return self._iter(int(number), url, Team, 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 login(self, username=None, password=None, token=None, two_factor_callback=None):
"""Logs the user into GitHub for protected API calls. :param str username: l... |
if username and password:
self._session.basic_auth(username, password)
elif token:
self._session.token_auth(token)
# The Session method handles None for free.
self._session.two_factor_auth_callback(two_factor_callback) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def membership_in(self, organization):
"""Retrieve the user's membership in the specified organization.""" |
url = self._build_url('user', 'memberships', 'orgs',
str(organization))
json = self._json(self._get(url), 200)
return Membership(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 meta(self):
"""Returns a dictionary with arrays of addresses in CIDR format specifying theaddresses that the incoming service hooks will originate from. .. v... |
url = self._build_url('meta')
return self._json(self._get(url), 200) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def octocat(self, say=None):
"""Returns an easter egg of the API. :params str say: (optional), pass in what you'd like Octocat to say :returns: ascii art of Octo... |
url = self._build_url('octocat')
req = self._get(url, params={'s': say})
return req.content if req.ok 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 organization(self, login):
"""Returns a Organization object for the login name :param str login: (required), login name of the org :returns: :class:`Organiza... |
url = self._build_url('orgs', login)
json = self._json(self._get(url), 200)
return Organization(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 organization_memberships(self, state=None, number=-1, etag=None):
"""List organizations of which the user is a current or pending member. :param str state: (... |
params = None
url = self._build_url('user', 'memberships', 'orgs')
if state is not None and state.lower() in ('active', 'pending'):
params = {'state': state.lower()}
return self._iter(int(number), url, Membership,
params=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 repository(self, owner, repository):
"""Returns a Repository object for the specified combination of owner and repository :param str owner: (required) :param... |
json = None
if owner and repository:
url = self._build_url('repos', owner, repository)
json = self._json(self._get(url), 200)
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 revoke_authorization(self, access_token):
"""Revoke specified authorization for an OAuth application. Revoke all authorization tokens created by your applica... |
client_id, client_secret = self._session.retrieve_client_credentials()
url = self._build_url('applications', str(client_id), 'tokens',
access_token)
with self._session.temporary_basic_auth(client_id, client_secret):
response = self._delete(url, 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 search_code(self, query, sort=None, order=None, per_page=None, text_match=False, number=-1, etag=None):
"""Find code via the code search API. The query can c... |
params = {'q': query}
headers = {}
if sort == 'indexed':
params['sort'] = sort
if sort and order in ('asc', 'desc'):
params['order'] = order
if text_match:
headers = {
'Accept': 'application/vnd.github.v3.full.text-match+jso... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def search_issues(self, query, sort=None, order=None, per_page=None, text_match=False, number=-1, etag=None):
"""Find issues by state and keyword The query can c... |
params = {'q': query}
headers = {}
if sort in ('comments', 'created', 'updated'):
params['sort'] = sort
if order in ('asc', 'desc'):
params['order'] = order
if text_match:
headers = {
'Accept': 'application/vnd.github.v3.ful... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def search_users(self, query, sort=None, order=None, per_page=None, text_match=False, number=-1, etag=None):
"""Find users via the Search API. The query can cont... |
params = {'q': query}
headers = {}
if sort in ('followers', 'repositories', 'joined'):
params['sort'] = sort
if order in ('asc', 'desc'):
params['order'] = order
if text_match:
headers = {
'Accept': 'application/vnd.github.v... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def unfollow(self, login):
"""Make the authenticated user stop following login :param str login: (required) :returns: bool """ |
resp = False
if login:
url = self._build_url('user', 'following', login)
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 update_user(self, name=None, email=None, blog=None, company=None, location=None, hireable=False, bio=None):
"""If authenticated as this user, update the info... |
user = self.user()
return user.update(name, email, blog, company, location, hireable,
bio) |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def user(self, login=None):
"""Returns a User object for the specified login name if provided. If no login name is provided, this will return a User object for t... |
if login:
url = self._build_url('users', login)
else:
url = self._build_url('user')
json = self._json(self._get(url), 200)
return User(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 zen(self):
"""Returns a quote from the Zen of GitHub. Yet another API Easter Egg :returns: str """ |
url = self._build_url('zen')
resp = self._get(url)
return resp.content if resp.status_code == 200 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 admin_stats(self, option):
"""This is a simple way to get statistics about your system. :param str option: (required), accepted values: ('all', 'repos', 'hoo... |
stats = {}
if option.lower() in ('all', 'repos', 'hooks', 'pages', 'orgs',
'users', 'pulls', 'issues', 'milestones',
'gists', 'comments'):
url = self._build_url('enterprise', 'stats', option.lower())
stats = self._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 update(self, title, key):
"""Update this key. :param str title: (required), title of the key :param str key: (required), text of the key file :returns: bool ... |
json = None
if title and key:
data = {'title': title, 'key': key}
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 add_email_addresses(self, addresses=[]):
"""Add the email addresses in ``addresses`` to the authenticated user's account. :param list addresses: (optional), ... |
json = []
if addresses:
url = self._build_url('user', 'emails')
json = self._json(self._post(url, data=addresses), 201)
return 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 delete_email_addresses(self, addresses=[]):
"""Delete the email addresses in ``addresses`` from the authenticated user's account. :param list addresses: (opt... |
url = self._build_url('user', 'emails')
return self._boolean(self._delete(url, data=dumps(addresses)),
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 is_following(self, login):
"""Checks if this user is following ``login``. :param str login: (required) :returns: bool """ |
url = self.following_urlt.expand(other_user=login)
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 iter_events(self, public=False, number=-1, etag=None):
"""Iterate over events performed by this user. :param bool public: (optional), only list public events... |
path = ['events']
if public:
path.append('public')
url = self._build_url(*path, base_url=self._api)
return self._iter(int(number), url, Event, 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_followers(self, number=-1, etag=None):
"""Iterate over the followers of this user. :param int number: (optional), number of followers to return. Default... |
url = self._build_url('followers', base_url=self._api)
return self._iter(int(number), url, User, 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_keys(self, number=-1, etag=None):
"""Iterate over the public keys of this user. .. versionadded:: 0.5 :param int number: (optional), number of keys to r... |
url = self._build_url('keys', base_url=self._api)
return self._iter(int(number), url, Key, 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_org_events(self, org, number=-1, etag=None):
"""Iterate over events as they appear on the user's organization dashboard. You must be authenticated to vi... |
url = ''
if org:
url = self._build_url('events', 'orgs', org, base_url=self._api)
return self._iter(int(number), url, Event, 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_orgs(self, number=-1, etag=None):
"""Iterate over organizations the user is member of :param int number: (optional), number of organizations to return. ... |
# Import here, because a toplevel import causes an import loop
from .orgs import Organization
url = self._build_url('orgs', base_url=self._api)
return self._iter(int(number), url, Organization, 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_starred(self, sort=None, direction=None, number=-1, etag=None):
"""Iterate over repositories starred by this user. .. versionchanged:: 0.5 Added sort an... |
from .repos import Repository
params = {'sort': sort, 'direction': direction}
self._remove_none(params)
url = self.starred_urlt.expand(owner=None, repo=None)
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_subscriptions(self, number=-1, etag=None):
"""Iterate over repositories subscribed to by this user. :param int number: (optional), number of subscriptio... |
from .repos import Repository
url = self._build_url('subscriptions', base_url=self._api)
return self._iter(int(number), url, Repository, 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 update(self, name=None, email=None, blog=None, company=None, location=None, hireable=False, bio=None):
"""If authenticated as this user, update the informati... |
user = {'name': name, 'email': email, 'blog': blog,
'company': company, 'location': location,
'hireable': hireable, 'bio': bio}
self._remove_none(user)
url = self._build_url('user')
json = self._json(self._patch(url, data=dumps(user)), 200)
if jso... |
<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_subscription(self):
"""Delete subscription for this thread. :returns: bool """ |
url = self._build_url('subscription', 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 set_subscription(self, subscribed, ignored):
"""Set the user's subscription for this thread :param bool subscribed: (required), determines if notifications s... |
url = self._build_url('subscription', base_url=self._api)
sub = {'subscribed': subscribed, 'ignored': ignored}
json = self._json(self._put(url, data=dumps(sub)), 200)
return Subscription(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 subscription(self):
"""Checks the status of the user's subscription to this thread. :returns: :class:`Subscription <Subscription>` """ |
url = self._build_url('subscription', base_url=self._api)
json = self._json(self._get(url), 200)
return Subscription(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 set(self, subscribed, ignored):
"""Set the user's subscription for this subscription :param bool subscribed: (required), determines if notifications should b... |
sub = {'subscribed': subscribed, 'ignored': ignored}
json = self._json(self._put(self._api, data=dumps(sub)), 200)
self.__init__(json, self._session) |
<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_collaborator(self, login):
"""Add ``login`` as a collaborator to a repository. :param str login: (required), login of the user :returns: bool -- True if ... |
resp = False
if login:
url = self._build_url('collaborators', login, base_url=self._api)
resp = self._boolean(self._put(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 archive(self, format, path='', ref='master'):
"""Get the tarball or zipball archive for this repo at ref. See: http://developer.github.com/v3/repos/contents/... |
resp = None
if format in ('tarball', 'zipball'):
url = self._build_url(format, ref, base_url=self._api)
resp = self._get(url, allow_redirects=True, stream=True)
if resp and self._boolean(resp, 200, 404):
stream_response_to_file(resp, path)
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 asset(self, id):
"""Returns a single Asset. :param int id: (required), id of the asset :returns: :class:`Asset <github3.repos.release.Asset>` """ |
data = None
if int(id) > 0:
url = self._build_url('releases', 'assets', str(id),
base_url=self._api)
data = self._json(self._get(url, headers=Release.CUSTOM_HEADERS),
200)
return Asset(data, self) if data el... |
<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
def blob(self, sha):
"""Get the blob indicated by ``sha``. :param str sha: (required), sha of the blob :returns: :class:`Blob <github3.git.Blob>` if successful, ... |
url = self._build_url('git', 'blobs', sha, base_url=self._api)
json = self._json(self._get(url), 200)
return Blob(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 branch(self, name):
"""Get the branch ``name`` of this repository. :param str name: (required), branch name :type name: str :returns: :class:`Branch <github3... |
json = None
if name:
url = self._build_url('branches', name, base_url=self._api)
json = self._json(self._get(url), 200)
return Branch(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 commit_comment(self, comment_id):
"""Get a single commit comment. :param int comment_id: (required), id of the comment used by GitHub :returns: :class:`RepoC... |
url = self._build_url('comments', str(comment_id), base_url=self._api)
json = self._json(self._get(url), 200)
return RepoComment(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 compare_commits(self, base, head):
"""Compare two commits. :param str base: (required), base for the comparison :param str head: (required), compare this aga... |
url = self._build_url('compare', base + '...' + head,
base_url=self._api)
json = self._json(self._get(url), 200)
return Comparison(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 contents(self, path, ref=None):
"""Get the contents of the file pointed to by ``path``. If the path provided is actually a directory, you will receive a dict... |
url = self._build_url('contents', path, base_url=self._api)
json = self._json(self._get(url, params={'ref': ref}), 200)
if isinstance(json, dict):
return Contents(json, self)
elif isinstance(json, list):
return dict((j.get('name'), Contents(j, self)) for j in jso... |
<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_blob(self, content, encoding):
"""Create a blob with ``content``. :param str content: (required), content of the blob :param str encoding: (required),... |
sha = ''
if encoding in ('base64', 'utf-8'):
url = self._build_url('git', 'blobs', base_url=self._api)
data = {'content': content, 'encoding': encoding}
json = self._json(self._post(url, data=data), 201)
if json:
sha = json.get('sha')
... |
<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, sha, path=None, position=None, line=1):
"""Create a comment on a commit. :param str body: (required), body of the message :param s... |
json = None
if body and sha and (line and int(line) > 0):
data = {'body': body, 'line': line, 'path': path,
'position': position}
self._remove_none(data)
url = self._build_url('commits', sha, 'comments',
base_url=... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.