INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
antenna1 data source | def antenna1(self, context):
""" antenna1 data source """
lrow, urow = MS.uvw_row_extents(context)
antenna1 = self._manager.ordered_uvw_table.getcol(
MS.ANTENNA1, startrow=lrow, nrow=urow-lrow)
return antenna1.reshape(context.shape).astype(context.dtype) |
antenna2 data source | def antenna2(self, context):
""" antenna2 data source """
lrow, urow = MS.uvw_row_extents(context)
antenna2 = self._manager.ordered_uvw_table.getcol(
MS.ANTENNA2, startrow=lrow, nrow=urow-lrow)
return antenna2.reshape(context.shape).astype(context.dtype) |
parallactic angle data source | def parallactic_angles(self, context):
""" parallactic angle data source """
# Time and antenna extents
(lt, ut), (la, ua) = context.dim_extents('ntime', 'na')
return (mbu.parallactic_angles(self._times[lt:ut],
self._antenna_positions[la:ua], self._phase_dir)
... |
Observed visibility data source | def observed_vis(self, context):
""" Observed visibility data source """
lrow, urow = MS.row_extents(context)
data = self._manager.ordered_main_table.getcol(
self._vis_column, startrow=lrow, nrow=urow-lrow)
return data.reshape(context.shape).astype(context.dtype) |
Flag data source | def flag(self, context):
""" Flag data source """
lrow, urow = MS.row_extents(context)
flag = self._manager.ordered_main_table.getcol(
MS.FLAG, startrow=lrow, nrow=urow-lrow)
return flag.reshape(context.shape).astype(context.dtype) |
Weight data source | def weight(self, context):
""" Weight data source """
lrow, urow = MS.row_extents(context)
weight = self._manager.ordered_main_table.getcol(
MS.WEIGHT, startrow=lrow, nrow=urow-lrow)
# WEIGHT is applied across all channels
weight = np.repeat(weight, self._manager.ch... |
Load the tensorflow library | def load_tf_lib():
""" Load the tensorflow library """
from os.path import join as pjoin
import pkg_resources
import tensorflow as tf
path = pjoin('ext', 'rime.so')
rime_lib_path = pkg_resources.resource_filename("montblanc", path)
return tf.load_op_library(rime_lib_path) |
Raise any errors associated with the validator. | def raise_validator_errors(validator):
"""
Raise any errors associated with the validator.
Parameters
----------
validator : :class:`cerberus.Validator`
Validator
Raises
------
ValueError
Raised if errors existed on `validator`.
Message describing each error and... |
Take a multiline text and indent it as a block | def indented(text, level, indent=2):
"""Take a multiline text and indent it as a block"""
return "\n".join("%s%s" % (level * indent * " ", s) for s in text.splitlines()) |
Put curly brackets round an indented text | def dumped(text, level, indent=2):
"""Put curly brackets round an indented text"""
return indented("{\n%s\n}" % indented(text, level + 1, indent) or "None", level, indent) + "\n" |
Perform a shell - based file copy. Copying in this way allows the possibility of undo auto - renaming and showing the flying file animation during the copy. | def copy_file(
source_path,
target_path,
allow_undo=True,
no_confirm=False,
rename_on_collision=True,
silent=False,
extra_flags=0,
hWnd=None
):
"""Perform a shell-based file copy. Copying in
this way allows the possibility of undo, auto-renaming,
and showing the "flying file"... |
Perform a shell - based file move. Moving in this way allows the possibility of undo auto - renaming and showing the flying file animation during the copy. | def move_file(
source_path,
target_path,
allow_undo=True,
no_confirm=False,
rename_on_collision=True,
silent=False,
extra_flags=0,
hWnd=None
):
"""Perform a shell-based file move. Moving in
this way allows the possibility of undo, auto-renaming,
and showing the "flying file" ... |
Perform a shell - based file rename. Renaming in this way allows the possibility of undo auto - renaming and showing the flying file animation during the copy. | def rename_file(
source_path,
target_path,
allow_undo=True,
no_confirm=False,
rename_on_collision=True,
silent=False,
extra_flags=0,
hWnd=None
):
"""Perform a shell-based file rename. Renaming in
this way allows the possibility of undo, auto-renaming,
and showing the "flying ... |
Perform a shell - based file delete. Deleting in this way uses the system recycle bin allows the possibility of undo and showing the flying file animation during the delete. | def delete_file(
source_path,
allow_undo=True,
no_confirm=False,
silent=False,
extra_flags=0,
hWnd=None
):
"""Perform a shell-based file delete. Deleting in
this way uses the system recycle bin, allows the
possibility of undo, and showing the "flying file"
animation during the de... |
Pick out info from MS documents with embedded structured storage ( typically MS Word docs etc. ) | def structured_storage(filename):
"""Pick out info from MS documents with embedded
structured storage(typically MS Word docs etc.)
Returns a dictionary of information found
"""
if not pythoncom.StgIsStorageFile(filename):
return {}
flags = storagecon.STGM_READ | storagecon.STGM_SHARE... |
Create a Windows shortcut: | def CreateShortcut(Path, Target, Arguments="", StartIn="", Icon=("", 0), Description=""):
"""Create a Windows shortcut:
Path - As what file should the shortcut be created?
Target - What command should the desktop use?
Arguments - What arguments should be supplied to the command?
StartIn - What fold... |
Restore the most recent version of a filepath returning the filepath it was restored to ( as rename - on - collision will apply if a file already exists at that path ). | def undelete(self, original_filepath):
"""Restore the most recent version of a filepath, returning
the filepath it was restored to(as rename-on-collision will
apply if a file already exists at that path).
"""
candidates = self.versions(original_filepath)
if not candidates... |
Given a list of arrays to feed in fed_arrays return a list of associated queue types obtained from tuples in the data_sources dictionary | def _get_queue_types(fed_arrays, data_sources):
"""
Given a list of arrays to feed in fed_arrays, return
a list of associated queue types, obtained from tuples
in the data_sources dictionary
"""
try:
return [data_sources[n].dtype for n in fed_arrays]
except KeyError as e:
rai... |
Arguments name: string Name of the queue queue_size: integer Size of the queue fed_arrays: list array names that will be fed by this queue data_sources: dict ( lambda/ method dtype ) tuples keyed on array names | def create_queue_wrapper(name, queue_size, fed_arrays, data_sources, *args, **kwargs):
"""
Arguments
name: string
Name of the queue
queue_size: integer
Size of the queue
fed_arrays: list
array names that will be fed by this queue
data_sources: ... |
Parses a string containing assign statements into a dictionary. | def parse_python_assigns(assign_str):
"""
Parses a string, containing assign statements
into a dictionary.
.. code-block:: python
h5 = katdal.open('123456789.h5')
kwargs = parse_python_assigns("spw=3; scans=[1,2];"
"targets='bpcal,radec';"
... |
Returns a dictionary of sink methods found on this object keyed on method name. Sink methods are identified by ( self context ) arguments on this object. For example: | def find_sinks(obj):
"""
Returns a dictionary of sink methods found on this object,
keyed on method name. Sink methods are identified by
(self, context) arguments on this object. For example:
def f(self, context):
...
is a sink method, but
def f(self, ctx):
...
is not... |
Returns a dictionary of sink methods found on this object keyed on method name. Sink methods are identified by ( self context ) arguments on this object. For example: | def sinks(self):
"""
Returns a dictionary of sink methods found on this object,
keyed on method name. Sink methods are identified by
(self, context) arguments on this object. For example:
def f(self, context):
...
is a sink method, but
def f(self, c... |
numba implementation of antenna_uvw | def _antenna_uvw(uvw, antenna1, antenna2, chunks, nr_of_antenna):
""" numba implementation of antenna_uvw """
if antenna1.ndim != 1:
raise ValueError("antenna1 shape should be (row,)")
if antenna2.ndim != 1:
raise ValueError("antenna2 shape should be (row,)")
if uvw.ndim != 2 or uvw.s... |
Raises informative exception for an invalid decomposition | def _raise_decomposition_errors(uvw, antenna1, antenna2,
chunks, ant_uvw, max_err):
""" Raises informative exception for an invalid decomposition """
start = 0
problem_str = []
for ci, chunk in enumerate(chunks):
end = start + chunk
ant1 = antenna1[sta... |
Raises an informative error for missing antenna | def _raise_missing_antenna_errors(ant_uvw, max_err):
""" Raises an informative error for missing antenna """
# Find antenna uvw coordinates where any UVW component was nan
# nan + real == nan
problems = np.nonzero(np.add.reduce(np.isnan(ant_uvw), axis=2))
problem_str = []
for c, a in zip(*prob... |
Computes per - antenna UVW coordinates from baseline uvw antenna1 and antenna2 coordinates logically grouped into baseline chunks. | def antenna_uvw(uvw, antenna1, antenna2, chunks,
nr_of_antenna, check_missing=False,
check_decomposition=False, max_err=100):
"""
Computes per-antenna UVW coordinates from baseline ``uvw``,
``antenna1`` and ``antenna2`` coordinates logically grouped
into baseline chunks.
... |
Returns a dictionary mapping source types to number of sources. If the number of sources for the source type is supplied in the kwargs these will be placed in the dictionary. | def default_sources(**kwargs):
"""
Returns a dictionary mapping source types
to number of sources. If the number of sources
for the source type is supplied in the kwargs
these will be placed in the dictionary.
e.g. if we have 'point', 'gaussian' and 'sersic'
source types, then
default_... |
Converts a source type to number of sources mapping into a source numbering variable to number of sources mapping. | def sources_to_nr_vars(sources):
"""
Converts a source type to number of sources mapping into
a source numbering variable to number of sources mapping.
If, for example, we have 'point', 'gaussian' and 'sersic'
source types, then passing the following dict as an argument
sources_to_nr_vars({'po... |
Given a range of source numbers as well as a dictionary containing the numbers of each source returns a dictionary containing tuples of the start and end index for each source variable type. | def source_range_tuple(start, end, nr_var_dict):
"""
Given a range of source numbers, as well as a dictionary
containing the numbers of each source, returns a dictionary
containing tuples of the start and end index
for each source variable type.
"""
starts = np.array([0 for nr_var in SOURCE... |
Given a range of source numbers as well as a dictionary containing the numbers of each source returns a dictionary containing tuples of the start and end index for each source variable type. | def source_range(start, end, nr_var_dict):
"""
Given a range of source numbers, as well as a dictionary
containing the numbers of each source, returns a dictionary
containing tuples of the start and end index
for each source variable type.
"""
return OrderedDict((k, e-s)
for k, (s, ... |
Given a range of source numbers as well as a dictionary containing the numbers of each source returns a dictionary containing slices for each source variable type. | def source_range_slices(start, end, nr_var_dict):
"""
Given a range of source numbers, as well as a dictionary
containing the numbers of each source, returns a dictionary
containing slices for each source variable type.
"""
return OrderedDict((k, slice(s,e,1))
for k, (s, e)
in s... |
Return a lm coordinate array to montblanc | def point_lm(self, context):
""" Return a lm coordinate array to montblanc """
lm = np.empty(context.shape, context.dtype)
# Print the array schema
montblanc.log.info(context.array_schema.shape)
# Print the space of iteration
montblanc.log.info(context.iter_args)
... |
Return a stokes parameter array to montblanc | def point_stokes(self, context):
""" Return a stokes parameter array to montblanc """
stokes = np.empty(context.shape, context.dtype)
stokes[:,:,0] = 1
stokes[:,:,1:4] = 0
return stokes |
Return a reference frequency array to montblanc | def ref_frequency(self, context):
""" Return a reference frequency array to montblanc """
ref_freq = np.empty(context.shape, context.dtype)
ref_freq[:] = 1.415e9
return ref_freq |
Update this authorization. | def update(self, scopes=[], add_scopes=[], rm_scopes=[], note='',
note_url=''):
"""Update this authorization.
:param list scopes: (optional), replaces the authorization scopes with
these
:param list add_scopes: (optional), scopes to be added
:param list rm_sco... |
Iterate over the labels for every issue associated with this milestone. | def iter_labels(self, number=-1, etag=None):
"""Iterate over the labels for every issue associated with this
milestone.
.. versionchanged:: 0.9
Add etag parameter.
:param int number: (optional), number of labels to return. Default: -1
returns all available labe... |
Get reference to currently running function from inspect/ trace stack frame. | def current_function(frame):
"""
Get reference to currently running function from inspect/trace stack frame.
Parameters
----------
frame : stack frame
Stack frame obtained via trace or inspect
Returns
-------
fnc : function reference
Currently running function
"""
... |
Get name of module of currently running function from inspect/ trace stack frame. | def current_module_name(frame):
"""
Get name of module of currently running function from inspect/trace
stack frame.
Parameters
----------
frame : stack frame
Stack frame obtained via trace or inspect
Returns
-------
modname : string
Currently running function module na... |
Build a record of called functions using the trace mechanism | def _trace(self, frame, event, arg):
"""
Build a record of called functions using the trace mechanism
"""
# Return if this is not a function call
if event != 'call':
return
# Filter calling and called functions by module names
src_mod = current_modul... |
Stop tracing | def stop(self):
"""Stop tracing"""
# Stop tracing
sys.settrace(None)
# Build group structure if group filter is defined
if self.grpflt is not None:
# Iterate over graph nodes (functions)
for k in self.fncts:
# Construct group identity str... |
Default colour generating function | def _clrgen(n, h0, hr):
"""Default colour generating function
Parameters
----------
n : int
Number of colours to generate
h0 : float
Initial H value in HSV colour specification
hr : float
Size of H value range to use for colour generation
... |
Construct call graph | def graph(self, fnm=None, size=None, fntsz=None, fntfm=None, clrgen=None,
rmsz=False, prog='dot'):
"""
Construct call graph
Parameters
----------
fnm : None or string, optional (default None)
Filename of graph file to be written. File type is determined b... |
Create a review comment on this pull request. | def create_review_comment(self, body, commit_id, path, position):
"""Create a review comment on this pull request.
All parameters are required by the GitHub API.
:param str body: The comment text itself
:param str commit_id: The SHA of the commit to comment on
:param str path: ... |
Return the diff | def diff(self):
"""Return the diff"""
resp = self._get(self._api,
headers={'Accept': 'application/vnd.github.diff'})
return resp.content if self._boolean(resp, 200, 404) else None |
Checks to see if the pull request was merged. | def is_merged(self):
"""Checks to see if the pull request was merged.
:returns: bool
"""
url = self._build_url('merge', base_url=self._api)
return self._boolean(self._get(url), 204, 404) |
Iterate over the comments on this pull request. | def iter_comments(self, number=-1, etag=None):
"""Iterate over the comments on this pull request.
:param int number: (optional), number of comments to return. Default:
-1 returns all available comments.
:param str etag: (optional), ETag from a previous request to the same
... |
Iterate over the files associated with this pull request. | def iter_files(self, number=-1, etag=None):
"""Iterate over the files associated with this pull request.
:param int number: (optional), number of files to return. Default:
-1 returns all available files.
:param str etag: (optional), ETag from a previous request to the same
... |
Iterate over the issue comments on this pull request. | def iter_issue_comments(self, number=-1, etag=None):
"""Iterate over the issue comments on this pull request.
:param int number: (optional), number of comments to return. Default:
-1 returns all available comments.
:param str etag: (optional), ETag from a previous request to the sam... |
Merge this pull request. | def merge(self, commit_message='', sha=None):
"""Merge this pull request.
:param str commit_message: (optional), message to be used for the
merge commit
:returns: bool
"""
parameters = {'commit_message': commit_message}
if sha:
parameters['sha'] =... |
Return the patch | def patch(self):
"""Return the patch"""
resp = self._get(self._api,
headers={'Accept': 'application/vnd.github.patch'})
return resp.content if self._boolean(resp, 200, 404) else None |
Update this pull request. | def update(self, title=None, body=None, state=None):
"""Update this pull request.
:param str title: (optional), title of the pull
:param str body: (optional), body of the pull request
:param str state: (optional), ('open', 'closed')
:returns: bool
"""
data = {'ti... |
Reply to this review comment with a new review comment. | def reply(self, body):
"""Reply to this review comment with a new review comment.
:param str body: The text of the comment.
:returns: The created review comment.
:rtype: :class:`~github3.pulls.ReviewComment`
"""
url = self._build_url('comments', base_url=self.pull_reques... |
Add login to this team. | def add_member(self, login):
"""Add ``login`` to this team.
:returns: bool
"""
warnings.warn(
'This is no longer supported by the GitHub API, see '
'https://developer.github.com/changes/2014-09-23-one-more-week'
'-before-the-add-team-member-api-breaki... |
Add repo to this team. | def add_repo(self, repo):
"""Add ``repo`` to this team.
:param str repo: (required), form: 'user/repo'
:returns: bool
"""
url = self._build_url('repos', repo, base_url=self._api)
return self._boolean(self._put(url), 204, 404) |
Edit this team. | def edit(self, name, permission=''):
"""Edit this team.
:param str name: (required)
:param str permission: (optional), ('pull', 'push', 'admin')
:returns: bool
"""
if name:
data = {'name': name, 'permission': permission}
json = self._json(self._pa... |
Checks if this team has access to repo | def has_repo(self, repo):
"""Checks if this team has access to ``repo``
:param str repo: (required), form: 'user/repo'
:returns: bool
"""
url = self._build_url('repos', repo, base_url=self._api)
return self._boolean(self._get(url), 204, 404) |
Invite the user to join this team. | def invite(self, username):
"""Invite the user to join this team.
This returns a dictionary like so::
{'state': 'pending', 'url': 'https://api.github.com/teams/...'}
:param str username: (required), user to invite to join this team.
:returns: dictionary
"""
... |
Retrieve the membership information for the user. | def membership_for(self, username):
"""Retrieve the membership information for the user.
:param str username: (required), name of the user
:returns: dictionary
"""
url = self._build_url('memberships', username, base_url=self._api)
json = self._json(self._get(url), 200)
... |
Remove login from this team. | def remove_member(self, login):
"""Remove ``login`` from this team.
:param str login: (required), login of the member to remove
:returns: bool
"""
warnings.warn(
'This is no longer supported by the GitHub API, see '
'https://developer.github.com/changes/2... |
Revoke this user s team membership. | def revoke_membership(self, username):
"""Revoke this user's team membership.
:param str username: (required), name of the team member
:returns: bool
"""
url = self._build_url('memberships', username, base_url=self._api)
return self._boolean(self._delete(url), 204, 404) |
Remove repo from this team. | def remove_repo(self, repo):
"""Remove ``repo`` from this team.
:param str repo: (required), form: 'user/repo'
:returns: bool
"""
url = self._build_url('repos', repo, base_url=self._api)
return self._boolean(self._delete(url), 204, 404) |
Add login to team and thereby to this organization. | def add_member(self, login, team):
"""Add ``login`` to ``team`` and thereby to this organization.
.. warning::
This method is no longer valid. To add a member to a team, you
must now retrieve the team directly, and use the ``invite``
method.
Any user that is... |
Add repo to team. | def add_repo(self, repo, team):
"""Add ``repo`` to ``team``.
.. note::
This method is of complexity O(n). This iterates over all teams in
your organization and only adds the repo when the team name
matches the team parameter above. If you want constant time, you
... |
Create a repository for this organization if the authenticated user is a member. | def create_repo(self,
name,
description='',
homepage='',
private=False,
has_issues=True,
has_wiki=True,
has_downloads=True,
team_id=0,
auto_... |
Conceal login s membership in this organization. | def conceal_member(self, login):
"""Conceal ``login``'s membership in this organization.
:returns: bool
"""
url = self._build_url('public_members', login, base_url=self._api)
return self._boolean(self._delete(url), 204, 404) |
Assuming the authenticated user owns this organization create and return a new team. | def create_team(self, name, repo_names=[], permission=''):
"""Assuming the authenticated user owns this organization,
create and return a new team.
:param str name: (required), name to be given to the team
:param list repo_names: (optional) repositories, e.g.
['github/dotfil... |
Edit this organization. | def edit(self,
billing_email=None,
company=None,
email=None,
location=None,
name=None):
"""Edit this organization.
:param str billing_email: (optional) Billing email address (private)
:param str company: (optional)
:param ... |
Check if the user with login login is a public member. | def is_public_member(self, login):
"""Check if the user with login ``login`` is a public member.
:returns: bool
"""
url = self._build_url('public_members', login, base_url=self._api)
return self._boolean(self._get(url), 204, 404) |
Iterate over repos for this organization. | def iter_repos(self, type='', number=-1, etag=None):
"""Iterate over repos for this organization.
:param str type: (optional), accepted values:
('all', 'public', 'member', 'private', 'forks', 'sources'), API
default: 'all'
:param int number: (optional), number of members... |
Iterate over teams that are part of this organization. | def iter_teams(self, number=-1, etag=None):
"""Iterate over teams that are part of this organization.
:param int number: (optional), number of teams to return. Default: -1
returns all available teams.
:param str etag: (optional), ETag from a previous request to the same
... |
Make login s membership in this organization public. | def publicize_member(self, login):
"""Make ``login``'s membership in this organization public.
:returns: bool
"""
url = self._build_url('public_members', login, base_url=self._api)
return self._boolean(self._put(url), 204, 404) |
Remove repo from team. | def remove_repo(self, repo, team):
"""Remove ``repo`` from ``team``.
:param str repo: (required), form: 'user/repo'
:param str team: (required)
:returns: bool
"""
for t in self.iter_teams():
if team == t.name:
return t.remove_repo(repo)
... |
Returns Team object with information about team specified by team_id. | def team(self, team_id):
"""Returns Team object with information about team specified by
``team_id``.
:param int team_id: (required), unique id for the team
:returns: :class:`Team <Team>`
"""
json = None
if int(team_id) > 0:
url = self._build_url('tea... |
Edit the user s membership. | def edit(self, state):
"""Edit the user's membership.
:param str state: (required), the state the membership should be in.
Only accepts ``"active"``.
:returns: itself
"""
if state and state.lower() == 'active':
data = dumps({'state': state.lower()})
... |
Users with push access to the repository can delete a release. | 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
... |
Users with push access to the repository can edit a release. | 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 u... |
Iterate over the assets available for this release. | 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
:param str etag: (optional), last ETag header sent
:returns: generator of :class:`Asset <Asset>` objects
"""
url ... |
Upload an asset to this release. | 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 the asset. Wikipedia has
a list of common media types
:param str name: The name of the file
:param asset:... |
Download the data for this asset. | 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 provided in the headers and will be
written in the current directory.
it can take a file-like object as well
... |
Edit this asset. | 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 description of the asset
:returns: boolean
"""
if not name:
return False
edit_data = {'name': name... |
List status of all configured SNS - SQS message buses and instances subscribed to them. | 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():
ac... |
Given an IAM role or instance name attach an IAM policy granting appropriate permissions to subscribe to deployments. Given a GitHub repo URL create and record deployment keys for the repo and any of its private submodules making the keys accessible to the IAM role. | 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 URL, create and record deployment keys for the repo
and any of its private submodules, making the keys accessible to
the IAM role.
"... |
Delete this file. | def delete(self, message, branch=None, committer=None, author=None):
"""Delete this file.
:param str message: (required), commit message to describe the removal
:param str branch: (optional), branch where the file exists.
Defaults to the default branch of the repository.
:pa... |
Update this file. | def update(self, message, content, branch=None, committer=None,
author=None):
"""Update this file.
:param str message: (required), commit message to describe the update
:param str content: (required), content to update the file with
:param str branch: (optional), branch w... |
Edit this gist. | def edit(self, description='', files={}):
"""Edit this gist.
:param str description: (optional), description of the gist
:param dict files: (optional), files that make up this gist; the
key(s) should be the file name(s) and the values should be another
(optional) diction... |
Fork this gist. | 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 |
Check to see if this gist is starred by the authenticated user. | 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) |
Iter over the commits on this gist. | 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 is in ``Gist.history``.
.. versionadded:: 0.6
.. versionchanged:: 0.9
Added param ``etag``.
:p... |
Iterator of forks of this gist. | 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: (optional), number of forks to iterate over.
Default: -1 will iterate over all forks of this gist.
:p... |
Star this gist. | 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) |
Un - star this gist. | 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) |
Update this comment. | 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
... |
Transfer files to or from EC2 instance. | 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
... |
List S3 buckets. See also aws s3 ls. Use aws s3 ls NAME to list bucket contents. | 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"]
clou... |
Update this label. | 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, no leading '#'
:returns: bool
"""
json = None
if name and color:
if color[0] == '#':
... |
Set the Basic Auth credentials on this Session. | def basic_auth(self, username, password):
"""Set the Basic Auth credentials on this Session.
:param str username: Your GitHub username
:param str password: Your GitHub password
"""
if not (username and password):
return
self.auth = (username, password)
... |
Builds a new API url from scratch. | 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_... |
Return the client credentials. | 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) |
Use an application token for authentication. | 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}'.form... |
Unset authentication temporarily as a context manager. | 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['Authorizati... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.