本文整理汇总了Python中uritemplate.URITemplate类的典型用法代码示例。如果您正苦于以下问题:Python URITemplate类的具体用法?Python URITemplate怎么用?Python URITemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了URITemplate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_default_value
def test_default_value(self):
uri = 'https://api.github.com/user{/user=sigmavirus24}'
t = URITemplate(uri)
self.assertEqual(t.expand(),
'https://api.github.com/user/sigmavirus24')
self.assertEqual(t.expand(user='lukasa'),
'https://api.github.com/user/lukasa')
开发者ID:sigmavirus24,项目名称:uritemplate,代码行数:7,代码来源:test_uritemplate.py
示例2: __init__
def __init__(self, user, session=None):
super(User, self).__init__(user, session)
if not self.type:
self.type = 'User'
#: ID of the user's image on Gravatar
self.gravatar_id = user.get('gravatar_id', '')
#: True -- for hire, False -- not for hire
self.hireable = user.get('hireable', False)
## The number of public_gists
#: Number of public gists
self.public_gists = user.get('public_gists', 0)
# Private information
#: How much disk consumed by the user
self.disk_usage = user.get('disk_usage', 0)
#: Number of private repos owned by this user
self.owned_private_repos = user.get('owned_private_repos', 0)
#: Number of private gists owned by this user
self.total_private_gists = user.get('total_private_gists', 0)
#: Total number of private repos
self.total_private_repos = user.get('total_private_repos', 0)
#: Which plan this user is on
self.plan = Plan(user.get('plan', {}))
events_url = user.get('events_url', '')
#: Events URL Template. Expands with ``privacy``
self.events_urlt = URITemplate(events_url) if events_url else None
#: Followers URL (not a template)
self.followers_url = user.get('followers_url', '')
furl = user.get('following_url', '')
#: Following URL Template. Expands with ``other_user``
self.following_urlt = URITemplate(furl) if furl else None
gists_url = user.get('gists_url', '')
#: Gists URL Template. Expands with ``gist_id``
self.gists_urlt = URITemplate(gists_url) if gists_url else None
#: Organizations URL (not a template)
self.organizations_url = user.get('organizations_url', '')
#: Received Events URL (not a template)
self.received_events_url = user.get('received_events_url', '')
#: Repostories URL (not a template)
self.repos_url = user.get('repos_url', '')
starred_url = user.get('starred_url', '')
#: Starred URL Template. Expands with ``owner`` and ``repo``
self.starred_urlt = URITemplate(starred_url) if starred_url else None
#: Subscriptions URL (not a template)
self.subscriptions_url = user.get('subscriptions_url', '')
self._uniq = user.get('id', None)
开发者ID:B-Rich,项目名称:github3.py,代码行数:60,代码来源:users.py
示例3: test_no_variables_in_uri
def test_no_variables_in_uri(self):
"""
This test ensures that if there are no variables present, the
template evaluates to itself.
"""
uri = 'https://api.github.com/users'
t = URITemplate(uri)
self.assertEqual(t.expand(), uri)
self.assertEqual(t.expand(users='foo'), uri)
开发者ID:sigmavirus24,项目名称:uritemplate,代码行数:9,代码来源:test_uritemplate.py
示例4: test_expand
def test_expand(self):
"""
This test ensures that expansion works as expected.
"""
# Single
t = URITemplate("https://api.github.com/users{/user}")
expanded = "https://api.github.com/users/sigmavirus24"
self.assertEqual(t.expand(user="sigmavirus24"), expanded)
v = t.variables[0]
self.assertEqual(v.expand({"user": None}), {"/user": ""})
# Multiple
t = URITemplate("https://api.github.com/users{/user}{/repo}")
expanded = "https://api.github.com/users/sigmavirus24/github3.py"
self.assertEqual(t.expand({"repo": "github3.py"}, user="sigmavirus24"), expanded)
开发者ID:pyspi-mirror,项目名称:uritemplate,代码行数:15,代码来源:test_uritemplate.py
示例5: __init__
def __init__(self, release, session=None):
super(Release, self).__init__(release, session)
self._api = release.get('url')
#: List of :class:`Asset <Asset>` objects for this release
self.assets = [Asset(i, self) for i in release.get('assets', [])]
#: URL for uploaded assets
self.assets_url = release.get('assets_url')
#: Body of the release (the description)
self.body = release.get('body')
#: Date the release was created
self.created_at = self._strptime(release.get('created_at'))
#: Boolean whether value is True or False
self.draft = release.get('draft')
#: HTML URL of the release
self.html_url = release.get('html_url')
#: GitHub id
self.id = release.get('id')
#: Name given to the release
self.name = release.get('name')
#; Boolean whether release is a prerelease
self.prerelease = release.get('prerelease')
#: Date the release was published
self.published_at = self._strptime(release.get('published_at'))
#: Name of the tag
self.tag_name = release.get('tag_name')
#: "Commit" that this release targets
self.target_commitish = release.get('target_commitish')
upload_url = release.get('upload_url')
#: URITemplate to upload an asset with
self.upload_urlt = URITemplate(upload_url) if upload_url else None
开发者ID:AndreasBackx,项目名称:github3.py,代码行数:30,代码来源:release.py
示例6: test_expand
def test_expand(self):
"""
This test ensures that expansion works as expected.
"""
# Single
t = URITemplate('https://api.github.com/users{/user}')
expanded = 'https://api.github.com/users/sigmavirus24'
self.assertEqual(t.expand(user='sigmavirus24'), expanded)
v = t.variables[0]
self.assertEqual(v.expand({'user': None}), {'/user': ''})
# Multiple
t = URITemplate('https://api.github.com/users{/user}{/repo}')
expanded = 'https://api.github.com/users/sigmavirus24/github3.py'
self.assertEqual(
t.expand({'repo': 'github3.py'}, user='sigmavirus24'),
expanded
)
开发者ID:sigmavirus24,项目名称:uritemplate,代码行数:18,代码来源:test_uritemplate.py
示例7: _update_attributes
def _update_attributes(self, user):
self.avatar_url = user["avatar_url"]
self.events_urlt = URITemplate(user["events_url"])
self.followers_url = user["followers_url"]
self.following_urlt = URITemplate(user["following_url"])
self.gists_urlt = URITemplate(user["gists_url"])
self.gravatar_id = user["gravatar_id"]
self.html_url = user["html_url"]
self.id = user["id"]
self.login = user["login"]
self.organizations_url = user["organizations_url"]
self.received_events_url = user["received_events_url"]
self.repos_url = user["repos_url"]
self.site_admin = user.get("site_admin")
self.starred_urlt = URITemplate(user["starred_url"])
self.subscriptions_url = user["subscriptions_url"]
self.type = user["type"]
self.url = self._api = user["url"]
self._uniq = self.id
开发者ID:sigmavirus24,项目名称:github3.py,代码行数:19,代码来源:users.py
示例8: _update_attributes
def _update_attributes(self, release):
self._api = self.url = release["url"]
self.original_assets = [Asset(i, self) for i in release["assets"]]
self.assets_url = release["assets_url"]
self.author = users.ShortUser(release["author"], self)
self.body = release["body"]
self.created_at = self._strptime(release["created_at"])
self.draft = release["draft"]
self.html_url = release["html_url"]
self.id = release["id"]
self.name = release["name"]
self.prerelease = release["prerelease"]
self.published_at = self._strptime(release["published_at"])
self.tag_name = release["tag_name"]
self.tarball_url = release["tarball_url"]
self.target_commitish = release["target_commitish"]
self.upload_urlt = URITemplate(release["upload_url"])
self.zipball_url = release["zipball_url"]
开发者ID:sigmavirus24,项目名称:github3.py,代码行数:18,代码来源:release.py
示例9: PriceURL
class PriceURL:
""" PriceURl implements an easily readible, funcational, and modifiable URL for retreiving prices
:param item_type:
:param item_number:
:param =color_id:
Usage:
url_template = PriceURL()
uri = url_template.expand(item_type=itemtypeID, item_number=itemID, color_id=itemColorID)
'https://www.bricklink.com/catalogPG.asp?P=3004&colorID=8'
"""
url = ('https://www.bricklink.com/catalogPG.asp?'
'{item_type} = {item_number} &'
'colorID = {color_id}'
)
def __init__(self):
self.raw_url = PriceURL.url.replace(" ", "") # Spaces improved readability
self.url_template = URITemplate(self.raw_url)
def expand(self, itemtypeID, itemID, itemColorID):
self.url = self.url_template.expand(item_type=itemtypeID, item_number=itemID, color_id=itemColorID)
return self.url
开发者ID:Geekly,项目名称:pybcm,代码行数:24,代码来源:elementreader.py
示例10: main
#.........这里部分代码省略.........
if(not "hostname" in destination):
raise Exception("SFTP Publish","No hostname was defined for the SFTP site.")
hostname = destination["hostname"]
if(not "local_path" in destination):
raise Exception("SFTP Publish","No local path was defined for the SFTP upload.")
local_path = destination["local_path"]
if(not "remote_path" in destination):
raise Exception("SFTP Publish","No remote path was defined for the SFTP upload.")
remote_path = destination["remote_path"]
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
sftp = pysftp.Connection(host=hostname, username=sftp_username, password=sftp_password, cnopts=cnopts)
local_path = local_path.format(major=version[0], minor=version[1], patch=version[2], build=version[3])
remote_path = remote_path.format(major=version[0], minor=version[1], patch=version[2], build=version[3])
print("SFTP: Publishing {} to remote {}:{}".format(local_path, hostname, remote_path))
sftp.put(local_path, remotepath=remote_path)
print("SFTP: Upload Complete!")
if(destination["type"] == "github"):
account = destination["account"]
tag_name = destination["tag_name"]
branch = destination["branch"]
name = destination["name"]
body_file = destination["body_file"]
local_path = destination["local_path"]
prerelease = destination["prerelease"]
asset_name = destination["asset_name"]
tag_name = tag_name.format(major=version[0], minor=version[1], patch=version[2], build=version[3])
name = name.format(major=version[0], minor=version[1], patch=version[2], build=version[3])
asset_name = asset_name.format(major=version[0], minor=version[1], patch=version[2], build=version[3])
local_path = local_path.format(major=version[0], minor=version[1], patch=version[2], build=version[3])
release_text_file = open(body_file, mode='r')
release_text = release_text_file.read()
release_text_file.close()
create_request = {
"tag_name": tag_name,
"target_commitish": branch,
"name": name,
"body": release_text,
"draft": False,
"prerelease": prerelease
}
github_token = os.environ["IDI_GITHUB_TOKEN"]
release_string = json.dumps(create_request, separators=(',',':'))
temp_dir = tempfile.mkdtemp()
tmpname = os.path.join(temp_dir,"jsonpost")
temp_file = open(tmpname, 'w')
temp_file.write(release_string)
temp_file.close()
curl_string = ' '.join(["curl", '-s', '-H "Authorization: token {}"'.format(github_token), '-H "Content-Type: application/json"', "--request POST", "--data", '"@{}"'.format(tmpname).replace('\\','\\\\'), "https://api.github.com/repos/{}/releases".format(account)])
print("Creating Github Release...")
response = subprocess.check_output(curl_string)
response_json = json.loads(response.decode("ascii"))
shutil.rmtree(temp_dir)
if("id" in response_json):
print("Github Release Created @ {}".format(response_json["url"]))
release_id = response_json["id"]
upload_url = response_json["upload_url"]
t = URITemplate(upload_url)
upload_url = t.expand(name=asset_name)
curl_string = ' '.join(["curl", '-s', '-H "Authorization: token {}"'.format(github_token),
'-H "Content-Type: application/zip"',
"--data-binary",
'"@{}"'.format(local_path),
upload_url])
print("Attaching Asset...")
response = subprocess.check_output(curl_string)
response_json = json.loads(response.decode("ascii"))
if("browser_download_url" in response_json):
print("Asset Attached @ {}".format(response_json["browser_download_url"]))
else:
print(response_json)
raise Exception("Github Publish","Failed to Attach Asset")
else:
print(response_json)
raise Exception("Github Publish","Failed to Create Release")
except Exception as e:
print(e)
sys.exit(1)
开发者ID:IDI-Systems,项目名称:acre2,代码行数:101,代码来源:publish.py
示例11: test_no_mutate
def test_no_mutate(self):
args = {}
t = URITemplate('')
t.expand(args, key=1)
self.assertEqual(args, {})
开发者ID:sigmavirus24,项目名称:uritemplate,代码行数:5,代码来源:test_uritemplate.py
示例12: _User
class _User(models.GitHubCore):
"""The :class:`User <User>` object.
This handles and structures information in the `User section`_.
Two user instances can be checked like so::
u1 == u2
u1 != u2
And is equivalent to::
u1.id == u2.id
u1.id != u2.id
.. _User section:
http://developer.github.com/v3/users/
"""
class_name = "_User"
def _update_attributes(self, user):
self.avatar_url = user["avatar_url"]
self.events_urlt = URITemplate(user["events_url"])
self.followers_url = user["followers_url"]
self.following_urlt = URITemplate(user["following_url"])
self.gists_urlt = URITemplate(user["gists_url"])
self.gravatar_id = user["gravatar_id"]
self.html_url = user["html_url"]
self.id = user["id"]
self.login = user["login"]
self.organizations_url = user["organizations_url"]
self.received_events_url = user["received_events_url"]
self.repos_url = user["repos_url"]
self.site_admin = user.get("site_admin")
self.starred_urlt = URITemplate(user["starred_url"])
self.subscriptions_url = user["subscriptions_url"]
self.type = user["type"]
self.url = self._api = user["url"]
self._uniq = self.id
def __str__(self):
return self.login
def _repr(self):
full_name = ""
name = getattr(self, "name", None)
if name is not None:
full_name = ":{}".format(name)
return "<{s.class_name} [{s.login}{full_name}]>".format(
s=self, full_name=full_name
)
def is_assignee_on(self, username, repository):
"""Check if this user can be assigned to issues on username/repository.
:param str username: owner's username of the repository
:param str repository: name of the repository
:returns: True if the use can be assigned, False otherwise
:rtype: :class:`bool`
"""
url = self._build_url(
"repos", username, repository, "assignees", self.login
)
return self._boolean(self._get(url), 204, 404)
def is_following(self, username):
"""Check if this user is following ``username``.
:param str username: (required)
:returns: bool
"""
url = self.following_urlt.expand(other_user=username)
return self._boolean(self._get(url), 204, 404)
def events(self, public=False, number=-1, etag=None):
r"""Iterate over events performed by this user.
:param bool public: (optional), only list public events for the
authenticated user
:param int number: (optional), number of events to return. Default: -1
returns all available events.
:param str etag: (optional), ETag from a previous request to the same
endpoint
:returns: generator of :class:`Event <github3.events.Event>`\ s
"""
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)
def followers(self, number=-1, etag=None):
r"""Iterate over the followers of this user.
:param int number: (optional), number of followers to return. Default:
-1 returns all available
:param str etag: (optional), ETag from a previous request to the same
endpoint
#.........这里部分代码省略.........
开发者ID:sigmavirus24,项目名称:github3.py,代码行数:101,代码来源:users.py
示例13: Release
class Release(GitHubCore):
"""The :class:`Release <Release>` object.
It holds the information GitHub returns about a release from a
:class:`Repository <github3.repos.repo.Repository>`.
"""
CUSTOM_HEADERS = {'Accept': 'application/vnd.github.manifold-preview'}
def _update_attributes(self, release):
self._api = release.get('url')
#: List of :class:`Asset <Asset>` objects for this release
self.original_assets = [
Asset(i, self) for i in release.get('assets', [])
]
#: URL for uploaded assets
self.assets_url = release.get('assets_url')
#: Body of the release (the description)
self.body = release.get('body')
#: Date the release was created
self.created_at = self._strptime(release.get('created_at'))
#: Boolean whether value is True or False
self.draft = release.get('draft')
#: HTML URL of the release
self.html_url = release.get('html_url')
#: GitHub id
self.id = release.get('id')
#: Name given to the release
self.name = release.get('name')
#: Boolean whether release is a prerelease
self.prerelease = release.get('prerelease')
#: Date the release was published
self.published_at = self._strptime(release.get('published_at'))
#: Name of the tag
self.tag_name = release.get('tag_name')
#: URL to download a tarball of the release
self.tarball_url = release.get('tarball_url')
#: "Commit" that this release targets
self.target_commitish = release.get('target_commitish')
upload_url = release.get('upload_url')
#: URITemplate to upload an asset with
self.upload_urlt = URITemplate(upload_url) if upload_url else None
#: URL to download a zipball of the release
self.zipball_url = release.get('zipball_url')
def _repr(self):
return '<Release [{0}]>'.format(self.name)
def archive(self, format, path=''):
"""Get the tarball or zipball archive for this release.
:param str format: (required), accepted values: ('tarball',
'zipball')
:param path: (optional), path where the file should be saved
to, default is the filename provided in the headers and will be
written in the current directory.
it can take a file-like object as well
:type path: str, file
:returns: bool -- True if successful, False otherwise
"""
resp = None
if format in ('tarball', 'zipball'):
repo_url = self._api[:self._api.rfind('/releases')]
url = self._build_url(format, self.tag_name, base_url=repo_url)
resp = self._get(url, allow_redirects=True, stream=True)
if resp and self._boolean(resp, 200, 404):
utils.stream_response_to_file(resp, path)
return True
return False
def asset(self, asset_id):
"""Retrieve the asset from this release with ``asset_id``.
:param int asset_id: ID of the Asset to retrieve
:returns: :class:`~github3.repos.release.Asset`
"""
json = None
if int(asset_id) > 0:
i = self._api.rfind('/')
url = self._build_url('assets', str(asset_id),
base_url=self._api[:i])
json = self._json(self._get(url), 200)
return self._instance_or_null(Asset, json)
def assets(self, number=-1, etag=None):
"""Iterate over the assets available for this release.
:param int number: (optional), Number of assets to return
:param str etag: (optional), last ETag header sent
:returns: generator of :class:`Asset <Asset>` objects
"""
url = self._build_url('assets', base_url=self._api)
return self._iter(number, url, Asset, etag=etag)
@requires_auth
def delete(self):
#.........这里部分代码省略.........
开发者ID:ArRolin,项目名称:gitsome,代码行数:101,代码来源:release.py
示例14: __get_url
def __get_url(self, path, id):
rootUrl = self.hal.get_root_url()
template = URITemplate(rootUrl + path);
return template.expand(id= str(id) if id is not None else "")
开发者ID:viagogo,项目名称:gogokit.py,代码行数:5,代码来源:clients.py
示例15: _test_
def _test_(self):
for k, v in d.items():
t = URITemplate(k)
self.assertEqual(t.expand(v['expansion']), v['expected'])
开发者ID:sigmavirus24,项目名称:uritemplate,代码行数:4,代码来源:test_uritemplate.py
示例16: Release
class Release(GitHubCore):
"""The :class:`Release <Release>` object.
It holds the information GitHub returns about a release from a
:class:`Repository <github3.repos.repo.Repository>`.
"""
CUSTOM_HEADERS = {'Accept': 'application/vnd.github.manifold-preview'}
def __init__(self, release, session=None):
super(Release, self).__init__(release, session)
self._api = release.get('url')
#: List of :class:`Asset <Asset>` objects for this release
self.assets = [Asset(i, self) for i in release.get('assets', [])]
#: URL for uploaded assets
self.assets_url = release.get('assets_url')
#: Body of the release (the description)
self.body = release.get('body')
#: Date the release was created
self.created_at = self._strptime(release.get('created_at'))
#: Boolean whether value is True or False
self.draft = release.get('draft')
#: HTML URL of the release
self.html_url = release.get('html_url')
#: GitHub id
self.id = release.get('id')
#: Name given to the release
self.name = release.get('name')
#; Boolean whether release is a prerelease
self.prerelease = release.get('prerelease')
#: Date the release was published
self.published_at = self._strptime(release.get('published_at'))
#: Name of the tag
self.tag_name = release.get('tag_name')
#: "Commit" that this release targets
self.target_commitish = release.get('target_commitish')
upload_url = release.get('upload_url')
#: URITemplate to upload an asset with
self.upload_urlt = URITemplate(upload_url) if upload_url else None
def _repr(self):
return '<Release [{0}]>'.format(self.name)
@requires_auth
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
)
@requires_auth
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 release.
If the edit is successful, this object will update itself.
:param str tag_name: (optional), Name of the tag to use
:param str target_commitish: (optional), The "commitish" value that
determines where the Git tag is created from. Defaults to the
repository's default branch.
:param str name: (optional), Name of the release
:param str body: (optional), Description of the release
:param boolean draft: (optional), True => Release is a draft
:param boolean prerelease: (optional), True => Release is a prerelease
:returns: True if successful; False if not successful
"""
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(
url, data=json.dumps(data), headers=Release.CUSTOM_HEADERS
)
successful = self._boolean(r, 200, 404)
if successful:
# If the edit was successful, let's update the object.
self.__init__(r.json(), self)
return successful
def iter_assets(self, number=-1, etag=None):
"""Iterate over the assets available for this release.
#.........这里部分代码省略.........
开发者ID:AndreasBackx,项目名称:github3.py,代码行数:101,代码来源:release.py
示例17: test_default_value
def test_default_value(self):
uri = "https://api.github.com/user{/user=sigmavirus24}"
t = URITemplate(uri)
self.assertEqual(t.expand(), "https://api.github.com/user/sigmavirus24")
self.assertEqual(t.expand(user="lukasa"), "https://api.github.com/user/lukasa")
开发者ID:pyspi-mirror,项目名称:uritemplate,代码行数:5,代码来源:test_uritemplate.py
示例18: User
class User(BaseAccount):
"""The :class:`User <User>` object. This handles and structures information
in the `User section <http://developer.github.com/v3/users/>`_.
Two user instances can be checked like so::
u1 == u2
u1 != u2
And is equivalent to::
u1.id == u2.id
u1.id != u2.id
"""
def __init__(self, user, session=None):
super(User, self).__init__(user, session)
if not self.type:
self.type = 'User'
#: ID of the user's image on Gravatar
self.gravatar_id = user.get('gravatar_id', '')
#: True -- for hire, False -- not for hire
self.hireable = user.get('hireable', False)
## The number of public_gists
#: Number of public gists
self.public_gists = user.get('public_gists', 0)
# Private information
#: How much disk consumed by the user
self.disk_usage = user.get('disk_usage', 0)
#: Number of private repos owned by this user
self.owned_private_repos = user.get('owned_private_repos', 0)
#: Number of private gists owned by this user
self.total_private_gists = user.get('total_private_gists', 0)
#: Total number of private repos
self.total_private_repos = user.get('total_private_repos', 0)
#: Which plan this user is on
self.plan = Plan(user.get('plan', {}))
events_url = user.get('events_url', '')
#: Events URL Template. Expands with ``privacy``
self.events_urlt = URITemplate(events_url) if events_url else None
#: Followers URL (not a template)
self.followers_url = user.get('followers_url', '')
furl = user.get('following_url', '')
#: Following URL Template. Expands with ``other_user``
self.following_urlt = URITemplate(furl) if furl else None
gists_url = user.get('gists_url', '')
#: Gists URL Template. Expands with ``gist_id``
self.gists_urlt = URITemplate(gists_url) if gists_url else None
#: Organizations URL (not a template)
self.organizations_url = user.get('organizations_url', '')
#: Received Events URL (not a template)
self.received_events_url = user.get('received_events_url', '')
#: Repostories URL (not a template)
self.repos_url = user.get('repos_url', '')
starred_url = user.get('starred_url', '')
#: Starred URL Template. Expands with ``owner`` and ``repo``
self.starred_urlt = URITemplate(starred_url) if starred_url else None
#: Subscriptions URL (not a template)
self.subscriptions_url = user.get('subscriptions_url', '')
def __str__(self):
return self.login
def _update_(self, user):
self.__init__(user, self._session)
@requires_auth
def add_email_address(self, address):
"""Add the single email address to the authenticated user's
account.
:param str address: (required), email address to add
:returns: list of email addresses
"""
return self.add_email_addresses([address])
@requires_auth
def add_email_addresses(self, addresses=[]):
"""Add the email addresses in ``addresses`` to the authenticated
user's account.
:param list addresses: (optional), email addresses to be added
:returns: list of email addresses
"""
#.........这里部分代码省略.........
开发者ID:esacteksab,项目名称:github3.py,代码行数:101,代码来源:users.py
示例19: Release
class Release(models.GitHubCore):
"""Representation of a GitHub release.
It holds the information GitHub returns about a release from a
:class:`Repository <github3.repos.repo.Repository>`.
Please see GitHub's `Releases Documentation`_ for more information.
This object has the following attributes:
.. attribute:: original_assets
A list of :class:`~github3.repos.release.Asset` objects representing
the assets uploaded for this relesae.
.. attribute:: assets_url
The URL to retrieve the assets from the API.
.. attribute:: author
A :class:`~github3.users.ShortUser` representing the creator of this
release.
.. attribute:: body
The description of this release as written by the release creator.
.. attribute:: created_at
A :class:`~datetime.datetime` object representing the date and time
when this release was created.
.. attribute:: draft
A boolean attribute describing whether this release is a draft.
.. attribute:: html_url
The URL to view this release in a browser.
.. attribute:: id
The unique identifier of this release.
.. attribute:: name
The name given to this release by the :attr:`author`.
.. attribute:: prerelease
A boolean attribute indicating whether the release is a pre-release.
.. attribute:: published_at
A :class:`~datetime.datetime` object representing the date and time
when this release was publisehd.
.. attribute:: tag_name
The name of the tag associated with this release.
.. attribute:: tarball_url
The URL to retrieve a GitHub generated tarball for this release from
the API.
.. attribute:: target_commitish
The reference (usually a commit) that is targetted by this release.
.. attribute:: upload_urlt
A :class:`~uritemplate.URITemplate` object that expands to form the
URL to upload assets to.
.. attribute:: zipball_url
The URL to retrieve a GitHub generated zipball for this release from
the API.
.. _Releases Documentation:
https://developer.github.com/v3/repos/releases/
"""
def _update_attributes(self, release):
self._api = self.url = release["url"]
self.original_assets = [Asset(i, self) for i in release["assets"]]
self.assets_url = release["assets_url"]
self.author = users.ShortUser(release["author"], self)
self.body = release["body"]
self.created_at = self._strptime(release["created_at"])
self.draft = release["draft"]
self.html_url = release["html_url"]
self.id = release["id"]
self.name = release["name"]
self.prerelease = release["prerelease"]
self.published_at = self._strptime(release["published_at"])
self.tag_name = release["tag_name"]
self.tarball_url = release["tarball_url"]
#.........这里部分代码省略.........
开发者ID:sigmavirus24,项目名称:github3.py,代码行数:101,代码来源:release.py
示例20: __init__
def __init__(self):
self.raw_url = PriceURL.url.replace(" ", "") # Spaces improved readability
self.url_template = URITemplate(self.raw_url)
开发者ID:Geekly,项目名称:pybcm,代码行数:3,代码来源:elementreader.py
注:本文中的uritemplate.URITemplate类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论