_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q241600 | TVMask.hl_canvas2table_box | train | def hl_canvas2table_box(self, canvas, tag):
"""Highlight all masks inside user drawn box on table."""
self.treeview.clear_selection()
# Remove existing box
cobj = canvas.get_object_by_tag(tag)
if cobj.kind != 'rectangle':
return
canvas.delete_object_by_tag(ta... | python | {
"resource": ""
} |
q241601 | TVMask.hl_canvas2table | train | def hl_canvas2table(self, canvas, button, data_x, data_y):
"""Highlight mask on table when user click on canvas."""
self.treeview.clear_selection()
# Remove existing highlight
if self.maskhltag:
try:
canvas.delete_object_by_tag(self.maskhltag, redraw=True)
... | python | {
"resource": ""
} |
q241602 | AnnulusMixin.contains_pt | train | def contains_pt(self, pt):
"""Containment test."""
obj1, obj2 = self.objects
return obj2.contains_pt(pt) and np.logical_not(obj1.contains_pt(pt)) | python | {
"resource": ""
} |
q241603 | AnnulusMixin.contains_pts | train | def contains_pts(self, pts):
"""Containment test on arrays."""
obj1, obj2 = self.objects
arg1 = obj2.contains_pts(pts)
arg2 = np.logical_not(obj1.contains_pts(pts))
return np.logical_and(arg1, arg2) | python | {
"resource": ""
} |
q241604 | register_wcs | train | def register_wcs(name, wrapper_class, coord_types):
"""
Register a custom WCS wrapper.
Parameters
----------
name : str
The name of the custom WCS wrapper
wrapper_class : subclass of `~ginga.util.wcsmod.BaseWCS`
The class implementing the WCS wrapper
coord_types : list of ... | python | {
"resource": ""
} |
q241605 | choose_coord_units | train | def choose_coord_units(header):
"""Return the appropriate key code for the units value for the axes by
examining the FITS header.
"""
cunit = header['CUNIT1']
match = re.match(r'^deg\s*$', cunit)
if match:
return 'degree'
# raise WCSError("Don't understand units '%s'" % (cunit))
... | python | {
"resource": ""
} |
q241606 | get_coord_system_name | train | def get_coord_system_name(header):
"""Return an appropriate key code for the axes coordinate system by
examining the FITS header.
"""
try:
ctype = header['CTYPE1'].strip().upper()
except KeyError:
try:
# see if we have an "RA" header
ra = header['RA'] # noqa
... | python | {
"resource": ""
} |
q241607 | BaseWCS.datapt_to_wcspt | train | def datapt_to_wcspt(self, datapt, coords='data', naxispath=None):
"""
Convert multiple data points to WCS.
Parameters
----------
datapt : array-like
Pixel coordinates in the format of
``[[x0, y0, ...], [x1, y1, ...], ..., [xn, yn, ...]]``.
coords... | python | {
"resource": ""
} |
q241608 | BaseWCS.wcspt_to_datapt | train | def wcspt_to_datapt(self, wcspt, coords='data', naxispath=None):
"""
Convert multiple WCS to data points.
Parameters
----------
wcspt : array-like
WCS coordinates in the format of
``[[ra0, dec0, ...], [ra1, dec1, ...], ..., [ran, decn, ...]]``.
c... | python | {
"resource": ""
} |
q241609 | BaseWCS.fix_bad_headers | train | def fix_bad_headers(self):
"""
Fix up bad headers that cause problems for the wrapped WCS
module.
Subclass can override this method to fix up issues with the
header for problem FITS files.
"""
# WCSLIB doesn't like "nonstandard" units
unit = self.header.g... | python | {
"resource": ""
} |
q241610 | fov_for_height_and_distance | train | def fov_for_height_and_distance(height, distance):
"""Calculate the FOV needed to get a given frustum height at a
given distance.
"""
vfov_deg = np.degrees(2.0 * np.arctan(height * 0.5 / distance))
return vfov_deg | python | {
"resource": ""
} |
q241611 | Camera.set_gl_transform | train | def set_gl_transform(self):
"""This side effects the OpenGL context to set the view to match
the camera.
"""
tangent = np.tan(self.fov_deg / 2.0 / 180.0 * np.pi)
vport_radius = self.near_plane * tangent
# calculate aspect of the viewport
if self.vport_wd_px < self... | python | {
"resource": ""
} |
q241612 | Camera.get_translation_speed | train | def get_translation_speed(self, distance_from_target):
"""Returns the translation speed for ``distance_from_target``
in units per radius.
"""
return (distance_from_target *
np.tan(self.fov_deg / 2.0 / 180.0 * np.pi)) | python | {
"resource": ""
} |
q241613 | Camera.orbit | train | def orbit(self, x1_px, y1_px, x2_px, y2_px):
"""
Causes the camera to "orbit" around the target point.
This is also called "tumbling" in some software packages.
"""
px_per_deg = self.vport_radius_px / float(self.orbit_speed)
radians_per_px = 1.0 / px_per_deg * np.pi / 180... | python | {
"resource": ""
} |
q241614 | Camera.track | train | def track(self, delta_pixels, push_target=False, adj_fov=False):
"""
This causes the camera to translate forward into the scene.
This is also called "dollying" or "tracking" in some software packages.
Passing in a negative delta causes the opposite motion.
If ``push_target'' is ... | python | {
"resource": ""
} |
q241615 | get_wireframe | train | def get_wireframe(viewer, x, y, z, **kwargs):
"""Produce a compound object of paths implementing a wireframe.
x, y, z are expected to be 2D arrays of points making up the mesh.
"""
# TODO: something like this would make a great utility function
# for ginga
n, m = x.shape
objs = []
for i ... | python | {
"resource": ""
} |
q241616 | get_fileinfo | train | def get_fileinfo(filespec, cache_dir=None):
"""
Parse a file specification and return information about it.
"""
if cache_dir is None:
cache_dir = tempfile.gettempdir()
# Loads first science extension by default.
# This prevents [None] to be loaded instead.
idx = None
name_ext = ... | python | {
"resource": ""
} |
q241617 | shorten_name | train | def shorten_name(name, char_limit, side='right'):
"""Shorten `name` if it is longer than `char_limit`.
If `side` == "right" then the right side of the name is shortened;
if "left" then the left side is shortened.
In either case, the suffix of the name is preserved.
"""
# TODO: A more elegant way... | python | {
"resource": ""
} |
q241618 | ParamSet.update_params | train | def update_params(self, param_d):
"""Update the attributes in self.obj that match the keys in
`param_d`.
"""
for param in self.paramlst:
if param.name in param_d:
value = param_d[param.name]
setattr(self.obj, param.name, value) | python | {
"resource": ""
} |
q241619 | hue_sat_to_cmap | train | def hue_sat_to_cmap(hue, sat):
"""Mkae a color map from a hue and saturation value.
"""
import colorsys
# normalize to floats
hue = float(hue) / 360.0
sat = float(sat) / 100.0
res = []
for val in range(256):
hsv_val = float(val) / 255.0
r, g, b = colorsys.hsv_to_rgb(hue... | python | {
"resource": ""
} |
q241620 | threadSafeBunch.setitem | train | def setitem(self, key, value):
"""Maps dictionary keys to values for assignment. Called for
dictionary style access with assignment.
"""
with self.lock:
self.tbl[key] = value | python | {
"resource": ""
} |
q241621 | threadSafeBunch.get | train | def get(self, key, alt=None):
"""If dictionary contains _key_ return the associated value,
otherwise return _alt_.
"""
with self.lock:
if key in self:
return self.getitem(key)
else:
return alt | python | {
"resource": ""
} |
q241622 | threadSafeBunch.setdefault | train | def setdefault(self, key, value):
"""Atomic store conditional. Stores _value_ into dictionary
at _key_, but only if _key_ does not already exist in the dictionary.
Returns the old value found or the new value.
"""
with self.lock:
if key in self:
retur... | python | {
"resource": ""
} |
q241623 | BasePlugin.help | train | def help(self):
"""Display help for the plugin."""
if not self.fv.gpmon.has_plugin('WBrowser'):
self._help_docstring()
return
self.fv.start_global_plugin('WBrowser')
# need to let GUI finish processing, it seems
self.fv.update_pending()
obj = se... | python | {
"resource": ""
} |
q241624 | LocalPlugin.modes_off | train | def modes_off(self):
"""Turn off any mode user may be in."""
bm = self.fitsimage.get_bindmap()
bm.reset_mode(self.fitsimage) | python | {
"resource": ""
} |
q241625 | _channel_proxy.load_np | train | def load_np(self, imname, data_np, imtype, header):
"""Display a numpy image buffer in a remote Ginga reference viewer.
Parameters
----------
imname : str
A name to use for the image in the reference viewer.
data_np : ndarray
This should be at least a 2D... | python | {
"resource": ""
} |
q241626 | _channel_proxy.load_hdu | train | def load_hdu(self, imname, hdulist, num_hdu):
"""Display an astropy.io.fits HDU in a remote Ginga reference viewer.
Parameters
----------
imname : str
A name to use for the image in the reference viewer.
hdulist : `~astropy.io.fits.HDUList`
This should b... | python | {
"resource": ""
} |
q241627 | _channel_proxy.load_fitsbuf | train | def load_fitsbuf(self, imname, fitsbuf, num_hdu):
"""Display a FITS file buffer in a remote Ginga reference viewer.
Parameters
----------
imname : str
A name to use for the image in the reference viewer.
chname : str
Name of a channel in which to load th... | python | {
"resource": ""
} |
q241628 | ImageViewTk.set_widget | train | def set_widget(self, canvas):
"""Call this method with the Tkinter canvas that will be used
for the display.
"""
self.tkcanvas = canvas
canvas.bind("<Configure>", self._resize_cb)
width = canvas.winfo_width()
height = canvas.winfo_height()
# see reschedu... | python | {
"resource": ""
} |
q241629 | GingaAxes._set_lim_and_transforms | train | def _set_lim_and_transforms(self):
"""
This is called once when the plot is created to set up all the
transforms for the data, text and grids.
"""
# There are three important coordinate spaces going on here:
#
# 1. Data space: The space of the data itself
... | python | {
"resource": ""
} |
q241630 | GingaAxes.start_pan | train | def start_pan(self, x, y, button):
"""
Called when a pan operation has started.
*x*, *y* are the mouse coordinates in display coords.
button is the mouse button number:
* 1: LEFT
* 2: MIDDLE
* 3: RIGHT
.. note::
Intended to be overridden by... | python | {
"resource": ""
} |
q241631 | RendererBase.get_surface_as_bytes | train | def get_surface_as_bytes(self, order=None):
"""Returns the surface area as a bytes encoded RGB image buffer.
Subclass should override if there is a more efficient conversion
than from generating a numpy array first.
"""
arr8 = self.get_surface_as_array(order=order)
return... | python | {
"resource": ""
} |
q241632 | RendererBase.reorder | train | def reorder(self, dst_order, arr, src_order=None):
"""Reorder the output array to match that needed by the viewer."""
if dst_order is None:
dst_order = self.viewer.rgb_order
if src_order is None:
src_order = self.rgb_order
if src_order != dst_order:
ar... | python | {
"resource": ""
} |
q241633 | add_cmap | train | def add_cmap(name, clst):
"""Add a color map."""
global cmaps
assert len(clst) == min_cmap_len, \
ValueError("color map '%s' length mismatch %d != %d (needed)" % (
name, len(clst), min_cmap_len))
cmaps[name] = ColorMap(name, clst) | python | {
"resource": ""
} |
q241634 | get_names | train | def get_names():
"""Get colormap names."""
res = list(cmaps.keys())
res = sorted(res, key=lambda s: s.lower())
return res | python | {
"resource": ""
} |
q241635 | matplotlib_to_ginga_cmap | train | def matplotlib_to_ginga_cmap(cm, name=None):
"""Convert matplotlib colormap to Ginga's."""
if name is None:
name = cm.name
arr = cm(np.arange(0, min_cmap_len) / np.float(min_cmap_len - 1))
clst = arr[:, 0:3]
return ColorMap(name, clst) | python | {
"resource": ""
} |
q241636 | ginga_to_matplotlib_cmap | train | def ginga_to_matplotlib_cmap(cm, name=None):
"""Convert Ginga colormap to matplotlib's."""
if name is None:
name = cm.name
from matplotlib.colors import ListedColormap
carr = np.asarray(cm.clst)
mpl_cm = ListedColormap(carr, name=name, N=len(carr))
return mpl_cm | python | {
"resource": ""
} |
q241637 | add_matplotlib_cmap | train | def add_matplotlib_cmap(cm, name=None):
"""Add a matplotlib colormap."""
global cmaps
cmap = matplotlib_to_ginga_cmap(cm, name=name)
cmaps[cmap.name] = cmap | python | {
"resource": ""
} |
q241638 | add_matplotlib_cmaps | train | def add_matplotlib_cmaps(fail_on_import_error=True):
"""Add all matplotlib colormaps."""
try:
from matplotlib import cm as _cm
from matplotlib.cbook import mplDeprecation
except ImportError:
if fail_on_import_error:
raise
# silently fail
return
for na... | python | {
"resource": ""
} |
q241639 | Cuts.add_legend | train | def add_legend(self):
"""Add or update Cuts plot legend."""
cuts = [tag for tag in self.tags if tag is not self._new_cut]
self.cuts_plot.ax.legend(cuts, loc='best',
shadow=True, fancybox=True,
prop={'size': 8}, labelspacing=0.2) | python | {
"resource": ""
} |
q241640 | Cuts.cut_at | train | def cut_at(self, cuttype):
"""Perform a cut at the last mouse position in the image.
`cuttype` determines the type of cut made.
"""
data_x, data_y = self.fitsimage.get_last_data_xy()
image = self.fitsimage.get_image()
wd, ht = image.get_size()
coords = []
... | python | {
"resource": ""
} |
q241641 | Cuts.width_radius_changed_cb | train | def width_radius_changed_cb(self, widget, val):
"""Callback executed when the Width radius is changed."""
self.width_radius = val
self.redraw_cuts()
self.replot_all()
return True | python | {
"resource": ""
} |
q241642 | Cuts.save_cb | train | def save_cb(self, mode):
"""Save image, figure, and plot data arrays."""
# This just defines the basename.
# Extension has to be explicitly defined or things can get messy.
w = Widgets.SaveDialog(title='Save {0} data'.format(mode))
filename = w.get_path()
if filename is... | python | {
"resource": ""
} |
q241643 | Pan.zoom_cb | train | def zoom_cb(self, fitsimage, event):
"""Zoom event in the pan window. Just zoom the channel viewer.
"""
chviewer = self.fv.getfocus_viewer()
bd = chviewer.get_bindings()
if hasattr(bd, 'sc_zoom'):
return bd.sc_zoom(chviewer, event)
return False | python | {
"resource": ""
} |
q241644 | Pan.zoom_pinch_cb | train | def zoom_pinch_cb(self, fitsimage, event):
"""Pinch event in the pan window. Just zoom the channel viewer.
"""
chviewer = self.fv.getfocus_viewer()
bd = chviewer.get_bindings()
if hasattr(bd, 'pi_zoom'):
return bd.pi_zoom(chviewer, event)
return False | python | {
"resource": ""
} |
q241645 | Pan.pan_pan_cb | train | def pan_pan_cb(self, fitsimage, event):
"""Pan event in the pan window. Just pan the channel viewer.
"""
chviewer = self.fv.getfocus_viewer()
bd = chviewer.get_bindings()
if hasattr(bd, 'pa_pan'):
return bd.pa_pan(chviewer, event)
return False | python | {
"resource": ""
} |
q241646 | ImageViewPg.set_widget | train | def set_widget(self, canvas_w):
"""Call this method with the widget that will be used
for the display.
"""
self.logger.debug("set widget canvas_w=%s" % canvas_w)
self.pgcanvas = canvas_w | python | {
"resource": ""
} |
q241647 | RPMCommand.run | train | def run(self):
"""
Run sdist, then 'rpmbuild' the tar.gz
"""
os.system("cp python-bugzilla.spec /tmp")
try:
os.system("rm -rf python-bugzilla-%s" % get_version())
self.run_command('sdist')
os.system('rpmbuild -ta --clean dist/python-bugzilla-%s... | python | {
"resource": ""
} |
q241648 | _RequestsTransport.parse_response | train | def parse_response(self, response):
"""
Parse XMLRPC response
"""
parser, unmarshaller = self.getparser()
parser.feed(response.text.encode('utf-8'))
parser.close()
return unmarshaller.close() | python | {
"resource": ""
} |
q241649 | _RequestsTransport._request_helper | train | def _request_helper(self, url, request_body):
"""
A helper method to assist in making a request and provide a parsed
response.
"""
response = None
# pylint: disable=try-except-raise
try:
response = self.session.post(
url, data=request_b... | python | {
"resource": ""
} |
q241650 | open_without_clobber | train | def open_without_clobber(name, *args):
"""
Try to open the given file with the given mode; if that filename exists,
try "name.1", "name.2", etc. until we find an unused filename.
"""
fd = None
count = 1
orig_name = name
while fd is None:
try:
fd = os.open(name, os.O_C... | python | {
"resource": ""
} |
q241651 | _do_info | train | def _do_info(bz, opt):
"""
Handle the 'info' subcommand
"""
# All these commands call getproducts internally, so do it up front
# with minimal include_fields for speed
def _filter_components(compdetails):
ret = {}
for k, v in compdetails.items():
if v.get("is_active",... | python | {
"resource": ""
} |
q241652 | _make_bz_instance | train | def _make_bz_instance(opt):
"""
Build the Bugzilla instance we will use
"""
if opt.bztype != 'auto':
log.info("Explicit --bztype is no longer supported, ignoring")
cookiefile = None
tokenfile = None
use_creds = False
if opt.cache_credentials:
cookiefile = opt.cookiefile ... | python | {
"resource": ""
} |
q241653 | _handle_login | train | def _handle_login(opt, action, bz):
"""
Handle all login related bits
"""
is_login_command = (action == 'login')
do_interactive_login = (is_login_command or
opt.login or opt.username or opt.password)
username = getattr(opt, "pos_username", None) or opt.username
password = getattr(op... | python | {
"resource": ""
} |
q241654 | Bugzilla.fix_url | train | def fix_url(url):
"""
Turn passed url into a bugzilla XMLRPC web url
"""
if '://' not in url:
log.debug('No scheme given for url, assuming https')
url = 'https://' + url
if url.count('/') < 3:
log.debug('No path given for url, assuming /xmlrpc.... | python | {
"resource": ""
} |
q241655 | Bugzilla._init_class_from_url | train | def _init_class_from_url(self):
"""
Detect if we should use RHBugzilla class, and if so, set it
"""
from bugzilla import RHBugzilla
if isinstance(self, RHBugzilla):
return
c = None
if "bugzilla.redhat.com" in self.url:
log.info("Using RHBu... | python | {
"resource": ""
} |
q241656 | Bugzilla._login | train | def _login(self, user, password, restrict_login=None):
"""
Backend login method for Bugzilla3
"""
payload = {'login': user, 'password': password}
if restrict_login:
payload['restrict_login'] = True
return self._proxy.User.login(payload) | python | {
"resource": ""
} |
q241657 | Bugzilla.login | train | def login(self, user=None, password=None, restrict_login=None):
"""
Attempt to log in using the given username and password. Subsequent
method calls will use this username and password. Returns False if
login fails, otherwise returns some kind of login info - typically
either a n... | python | {
"resource": ""
} |
q241658 | Bugzilla.interactive_login | train | def interactive_login(self, user=None, password=None, force=False,
restrict_login=None):
"""
Helper method to handle login for this bugzilla instance.
:param user: bugzilla username. If not specified, prompt for it.
:param password: bugzilla password. If not sp... | python | {
"resource": ""
} |
q241659 | Bugzilla.logout | train | def logout(self):
"""
Log out of bugzilla. Drops server connection and user info, and
destroys authentication cookies.
"""
self._logout()
self.disconnect()
self.user = ''
self.password = '' | python | {
"resource": ""
} |
q241660 | Bugzilla.logged_in | train | def logged_in(self):
"""
This is True if this instance is logged in else False.
We test if this session is authenticated by calling the User.get()
XMLRPC method with ids set. Logged-out users cannot pass the 'ids'
parameter and will result in a 505 error. If we tried to login wi... | python | {
"resource": ""
} |
q241661 | Bugzilla._getbugfields | train | def _getbugfields(self):
"""
Get the list of valid fields for Bug objects
"""
r = self._proxy.Bug.fields({'include_fields': ['name']})
return [f['name'] for f in r['fields']] | python | {
"resource": ""
} |
q241662 | Bugzilla.getbugfields | train | def getbugfields(self, force_refresh=False):
"""
Calls getBugFields, which returns a list of fields in each bug
for this bugzilla instance. This can be used to set the list of attrs
on the Bug object.
"""
if force_refresh or not self._cache.bugfields:
log.debu... | python | {
"resource": ""
} |
q241663 | Bugzilla.refresh_products | train | def refresh_products(self, **kwargs):
"""
Refresh a product's cached info. Basically calls product_get
with the passed arguments, and tries to intelligently update
our product cache.
For example, if we already have cached info for product=foo,
and you pass in names=["bar... | python | {
"resource": ""
} |
q241664 | Bugzilla.getproducts | train | def getproducts(self, force_refresh=False, **kwargs):
"""
Query all products and return the raw dict info. Takes all the
same arguments as product_get.
On first invocation this will contact bugzilla and internally
cache the results. Subsequent getproducts calls or accesses to
... | python | {
"resource": ""
} |
q241665 | Bugzilla.getcomponentdetails | train | def getcomponentdetails(self, product, component, force_refresh=False):
"""
Helper for accessing a single component's info. This is a wrapper
around getcomponentsdetails, see that for explanation
"""
d = self.getcomponentsdetails(product, force_refresh)
return d[component... | python | {
"resource": ""
} |
q241666 | Bugzilla.getcomponents | train | def getcomponents(self, product, force_refresh=False):
"""
Return a list of component names for the passed product.
This can be implemented with Product.get, but behind the
scenes it uses Bug.legal_values. Reason being that on bugzilla
instances with tons of components, like bug... | python | {
"resource": ""
} |
q241667 | Bugzilla._process_include_fields | train | def _process_include_fields(self, include_fields, exclude_fields,
extra_fields):
"""
Internal helper to process include_fields lists
"""
def _convert_fields(_in):
if not _in:
return _in
for newname, oldname in self.... | python | {
"resource": ""
} |
q241668 | Bugzilla._getbugs | train | def _getbugs(self, idlist, permissive,
include_fields=None, exclude_fields=None, extra_fields=None):
"""
Return a list of dicts of full bug info for each given bug id.
bug ids that couldn't be found will return None instead of a dict.
"""
oldidlist = idlist
id... | python | {
"resource": ""
} |
q241669 | Bugzilla._getbug | train | def _getbug(self, objid, **kwargs):
"""
Thin wrapper around _getbugs to handle the slight argument tweaks
for fetching a single bug. The main bit is permissive=False, which
will tell bugzilla to raise an explicit error if we can't fetch
that bug.
This logic is called fro... | python | {
"resource": ""
} |
q241670 | Bugzilla.getbug | train | def getbug(self, objid,
include_fields=None, exclude_fields=None, extra_fields=None):
"""
Return a Bug object with the full complement of bug data
already loaded.
"""
data = self._getbug(objid,
include_fields=include_fields, exclude_fields=exclude_field... | python | {
"resource": ""
} |
q241671 | Bugzilla.getbugs | train | def getbugs(self, idlist,
include_fields=None, exclude_fields=None, extra_fields=None,
permissive=True):
"""
Return a list of Bug objects with the full complement of bug data
already loaded. If there's a problem getting the data for a given id,
the corresp... | python | {
"resource": ""
} |
q241672 | Bugzilla.update_tags | train | def update_tags(self, idlist, tags_add=None, tags_remove=None):
"""
Updates the 'tags' field for a bug.
"""
tags = {}
if tags_add:
tags["add"] = self._listify(tags_add)
if tags_remove:
tags["remove"] = self._listify(tags_remove)
d = {
... | python | {
"resource": ""
} |
q241673 | Bugzilla._attachment_uri | train | def _attachment_uri(self, attachid):
"""
Returns the URI for the given attachment ID.
"""
att_uri = self.url.replace('xmlrpc.cgi', 'attachment.cgi')
att_uri = att_uri + '?id=%s' % attachid
return att_uri | python | {
"resource": ""
} |
q241674 | Bugzilla.attachfile | train | def attachfile(self, idlist, attachfile, description, **kwargs):
"""
Attach a file to the given bug IDs. Returns the ID of the attachment
or raises XMLRPC Fault if something goes wrong.
attachfile may be a filename (which will be opened) or a file-like
object, which must provide... | python | {
"resource": ""
} |
q241675 | Bugzilla.openattachment | train | def openattachment(self, attachid):
"""
Get the contents of the attachment with the given attachment ID.
Returns a file-like object.
"""
attachments = self.get_attachments(None, attachid)
data = attachments["attachments"][str(attachid)]
xmlrpcbinary = data["data"]... | python | {
"resource": ""
} |
q241676 | Bugzilla.get_attachments | train | def get_attachments(self, ids, attachment_ids,
include_fields=None, exclude_fields=None):
"""
Wrapper for Bug.attachments. One of ids or attachment_ids is required
:param ids: Get attachments for this bug ID
:param attachment_ids: Specific attachment ID to get
... | python | {
"resource": ""
} |
q241677 | Bugzilla.createbug | train | def createbug(self, *args, **kwargs):
"""
Create a bug with the given info. Returns a new Bug object.
Check bugzilla API documentation for valid values, at least
product, component, summary, version, and description need to
be passed.
"""
data = self._validate_cre... | python | {
"resource": ""
} |
q241678 | Bugzilla._getusers | train | def _getusers(self, ids=None, names=None, match=None):
"""
Return a list of users that match criteria.
:kwarg ids: list of user ids to return data on
:kwarg names: list of user names to return data on
:kwarg match: list of patterns. Returns users whose real name or
... | python | {
"resource": ""
} |
q241679 | Bugzilla.getusers | train | def getusers(self, userlist):
"""
Return a list of Users from .
:userlist: List of usernames to lookup
:returns: List of User records
"""
userobjs = [User(self, **rawuser) for rawuser in
self._getusers(names=userlist).get('users', [])]
# Retu... | python | {
"resource": ""
} |
q241680 | Bugzilla.searchusers | train | def searchusers(self, pattern):
"""
Return a bugzilla User for the given list of patterns
:arg pattern: List of patterns to match against.
:returns: List of User records
"""
return [User(self, **rawuser) for rawuser in
self._getusers(match=pattern).get('u... | python | {
"resource": ""
} |
q241681 | Bugzilla.createuser | train | def createuser(self, email, name='', password=''):
"""
Return a bugzilla User for the given username
:arg email: The email address to use in bugzilla
:kwarg name: Real name to associate with the account
:kwarg password: Password to set for the bugzilla account
:raises XM... | python | {
"resource": ""
} |
q241682 | Bug.refresh | train | def refresh(self, include_fields=None, exclude_fields=None,
extra_fields=None):
"""
Refresh the bug with the latest data from bugzilla
"""
# pylint: disable=protected-access
r = self.bugzilla._getbug(self.bug_id,
include_fields=include_fields, exclude_fields=e... | python | {
"resource": ""
} |
q241683 | Bug._update_dict | train | def _update_dict(self, newdict):
"""
Update internal dictionary, in a way that ensures no duplicate
entries are stored WRT field aliases
"""
if self.bugzilla:
self.bugzilla.post_translation({}, newdict)
# pylint: disable=protected-access
alias... | python | {
"resource": ""
} |
q241684 | Bug.deletecc | train | def deletecc(self, cclist, comment=None):
"""
Removes the given email addresses from the CC list for this bug.
"""
vals = self.bugzilla.build_update(comment=comment,
cc_remove=cclist)
log.debug("deletecc: update=%s", vals)
return... | python | {
"resource": ""
} |
q241685 | Bug.addcomment | train | def addcomment(self, comment, private=False):
"""
Add the given comment to this bug. Set private to True to mark this
comment as private.
"""
# Note: fedora bodhi uses this function
vals = self.bugzilla.build_update(comment=comment,
... | python | {
"resource": ""
} |
q241686 | Bug.getcomments | train | def getcomments(self):
"""
Returns an array of comment dictionaries for this bug
"""
comment_list = self.bugzilla.get_comments([self.bug_id])
return comment_list['bugs'][str(self.bug_id)]['comments'] | python | {
"resource": ""
} |
q241687 | Bug.get_flag_status | train | def get_flag_status(self, name):
"""
Return a flag 'status' field
This method works only for simple flags that have only a 'status' field
with no "requestee" info, and no multiple values. For more complex
flags, use get_flags() to get extended flag value information.
"""... | python | {
"resource": ""
} |
q241688 | Bug.get_attachments | train | def get_attachments(self, include_fields=None, exclude_fields=None):
"""
Helper call to Bugzilla.get_attachments. If you want to fetch
specific attachment IDs, use that function instead
"""
if "attachments" in self.__dict__:
return self.attachments
data = sel... | python | {
"resource": ""
} |
q241689 | User.refresh | train | def refresh(self):
"""
Update User object with latest info from bugzilla
"""
newuser = self.bugzilla.getuser(self.email)
self.__dict__.update(newuser.__dict__) | python | {
"resource": ""
} |
q241690 | RHBugzilla.pre_translation | train | def pre_translation(self, query):
"""
Translates the query for possible aliases
"""
old = query.copy()
if 'bug_id' in query:
if not isinstance(query['bug_id'], list):
query['id'] = query['bug_id'].split(',')
else:
query['id... | python | {
"resource": ""
} |
q241691 | RHBugzilla.post_translation | train | def post_translation(self, query, bug):
"""
Convert the results of getbug back to the ancient RHBZ value
formats
"""
ignore = query
# RHBZ _still_ returns component and version as lists, which
# deviates from upstream. Copy the list values to components
#... | python | {
"resource": ""
} |
q241692 | DuplicateSet.delete | train | def delete(self, mail):
""" Delete a mail from the filesystem. """
self.stats['mail_deleted'] += 1
if self.conf.dry_run:
logger.info("Skip deletion of {!r}.".format(mail))
return
logger.debug("Deleting {!r}...".format(mail))
# XXX Investigate the use of m... | python | {
"resource": ""
} |
q241693 | DuplicateSet.check_differences | train | def check_differences(self):
""" In-depth check of mail differences.
Compare all mails of the duplicate set with each other, both in size
and content. Raise an error if we're not within the limits imposed by
the threshold setting.
"""
logger.info("Check that mail differe... | python | {
"resource": ""
} |
q241694 | DuplicateSet.diff | train | def diff(self, mail_a, mail_b):
""" Return difference in bytes between two mails' normalized body.
TODO: rewrite the diff algorithm to not rely on naive unified diff
result parsing.
"""
return len(''.join(unified_diff(
mail_a.body_lines, mail_b.body_lines,
... | python | {
"resource": ""
} |
q241695 | DuplicateSet.pretty_diff | train | def pretty_diff(self, mail_a, mail_b):
""" Returns a verbose unified diff between two mails' normalized body.
"""
return ''.join(unified_diff(
mail_a.body_lines, mail_b.body_lines,
fromfile='Normalized body of {}'.format(mail_a.path),
tofile='Normalized body o... | python | {
"resource": ""
} |
q241696 | DuplicateSet.apply_strategy | train | def apply_strategy(self):
""" Apply deduplication with the configured strategy.
Transform strategy keyword into its method ID, and call it.
"""
method_id = self.conf.strategy.replace('-', '_')
if not hasattr(DuplicateSet, method_id):
raise NotImplementedError(
... | python | {
"resource": ""
} |
q241697 | DuplicateSet.dedupe | train | def dedupe(self):
""" Performs the deduplication and its preliminary checks. """
if len(self.pool) == 1:
logger.debug("Ignore set: only one message found.")
self.stats['mail_unique'] += 1
self.stats['set_ignored'] += 1
return
try:
# Fi... | python | {
"resource": ""
} |
q241698 | DuplicateSet.delete_older | train | def delete_older(self):
""" Delete all older duplicates.
Only keeps the subset sharing the most recent timestamp.
"""
logger.info(
"Deleting all mails strictly older than the {} timestamp..."
"".format(self.newest_timestamp))
# Select candidates for delet... | python | {
"resource": ""
} |
q241699 | DuplicateSet.delete_oldest | train | def delete_oldest(self):
""" Delete all the oldest duplicates.
Keeps all mail of the duplicate set but those sharing the oldest
timestamp.
"""
logger.info(
"Deleting all mails sharing the oldest {} timestamp...".format(
self.oldest_timestamp))
... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.