partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | InspectView.get_image_field_display | Render an image | wagtailmodeladmin/views.py | def get_image_field_display(self, field_name, field):
""" Render an image """
image = getattr(self.instance, field_name)
if image:
fltr, _ = Filter.objects.get_or_create(spec='max-400x400')
rendition = image.get_rendition(fltr)
return rendition.img_tag
... | def get_image_field_display(self, field_name, field):
""" Render an image """
image = getattr(self.instance, field_name)
if image:
fltr, _ = Filter.objects.get_or_create(spec='max-400x400')
rendition = image.get_rendition(fltr)
return rendition.img_tag
... | [
"Render",
"an",
"image"
] | rkhleics/wagtailmodeladmin | python | https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L786-L793 | [
"def",
"get_image_field_display",
"(",
"self",
",",
"field_name",
",",
"field",
")",
":",
"image",
"=",
"getattr",
"(",
"self",
".",
"instance",
",",
"field_name",
")",
"if",
"image",
":",
"fltr",
",",
"_",
"=",
"Filter",
".",
"objects",
".",
"get_or_cre... | 7fddc853bab2ff3868b8c7a03329308c55f16358 |
train | InspectView.get_document_field_display | Render a link to a document | wagtailmodeladmin/views.py | def get_document_field_display(self, field_name, field):
""" Render a link to a document """
document = getattr(self.instance, field_name)
if document:
return mark_safe(
'<a href="%s">%s <span class="meta">(%s, %s)</span></a>' % (
document.url,
... | def get_document_field_display(self, field_name, field):
""" Render a link to a document """
document = getattr(self.instance, field_name)
if document:
return mark_safe(
'<a href="%s">%s <span class="meta">(%s, %s)</span></a>' % (
document.url,
... | [
"Render",
"a",
"link",
"to",
"a",
"document"
] | rkhleics/wagtailmodeladmin | python | https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L795-L807 | [
"def",
"get_document_field_display",
"(",
"self",
",",
"field_name",
",",
"field",
")",
":",
"document",
"=",
"getattr",
"(",
"self",
".",
"instance",
",",
"field_name",
")",
"if",
"document",
":",
"return",
"mark_safe",
"(",
"'<a href=\"%s\">%s <span class=\"meta... | 7fddc853bab2ff3868b8c7a03329308c55f16358 |
train | InspectView.get_dict_for_field | Return a dictionary containing `label` and `value` values to display
for a field. | wagtailmodeladmin/views.py | def get_dict_for_field(self, field_name):
"""
Return a dictionary containing `label` and `value` values to display
for a field.
"""
try:
field = self.model._meta.get_field(field_name)
except FieldDoesNotExist:
field = None
return {
... | def get_dict_for_field(self, field_name):
"""
Return a dictionary containing `label` and `value` values to display
for a field.
"""
try:
field = self.model._meta.get_field(field_name)
except FieldDoesNotExist:
field = None
return {
... | [
"Return",
"a",
"dictionary",
"containing",
"label",
"and",
"value",
"values",
"to",
"display",
"for",
"a",
"field",
"."
] | rkhleics/wagtailmodeladmin | python | https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L809-L821 | [
"def",
"get_dict_for_field",
"(",
"self",
",",
"field_name",
")",
":",
"try",
":",
"field",
"=",
"self",
".",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"except",
"FieldDoesNotExist",
":",
"field",
"=",
"None",
"return",
"{",
"'label'... | 7fddc853bab2ff3868b8c7a03329308c55f16358 |
train | InspectView.get_fields_dict | Return a list of `label`/`value` dictionaries to represent the
fiels named by the model_admin class's `get_inspect_view_fields` method | wagtailmodeladmin/views.py | def get_fields_dict(self):
"""
Return a list of `label`/`value` dictionaries to represent the
fiels named by the model_admin class's `get_inspect_view_fields` method
"""
fields = []
for field_name in self.model_admin.get_inspect_view_fields():
fields.append(se... | def get_fields_dict(self):
"""
Return a list of `label`/`value` dictionaries to represent the
fiels named by the model_admin class's `get_inspect_view_fields` method
"""
fields = []
for field_name in self.model_admin.get_inspect_view_fields():
fields.append(se... | [
"Return",
"a",
"list",
"of",
"label",
"/",
"value",
"dictionaries",
"to",
"represent",
"the",
"fiels",
"named",
"by",
"the",
"model_admin",
"class",
"s",
"get_inspect_view_fields",
"method"
] | rkhleics/wagtailmodeladmin | python | https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/views.py#L823-L831 | [
"def",
"get_fields_dict",
"(",
"self",
")",
":",
"fields",
"=",
"[",
"]",
"for",
"field_name",
"in",
"self",
".",
"model_admin",
".",
"get_inspect_view_fields",
"(",
")",
":",
"fields",
".",
"append",
"(",
"self",
".",
"get_dict_for_field",
"(",
"field_name"... | 7fddc853bab2ff3868b8c7a03329308c55f16358 |
train | items_for_result | Generates the actual list of data. | wagtailmodeladmin/templatetags/wagtailmodeladmin_tags.py | def items_for_result(view, result):
"""
Generates the actual list of data.
"""
model_admin = view.model_admin
for field_name in view.list_display:
empty_value_display = model_admin.get_empty_value_display()
row_classes = ['field-%s' % field_name]
try:
f, attr, val... | def items_for_result(view, result):
"""
Generates the actual list of data.
"""
model_admin = view.model_admin
for field_name in view.list_display:
empty_value_display = model_admin.get_empty_value_display()
row_classes = ['field-%s' % field_name]
try:
f, attr, val... | [
"Generates",
"the",
"actual",
"list",
"of",
"data",
"."
] | rkhleics/wagtailmodeladmin | python | https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/templatetags/wagtailmodeladmin_tags.py#L26-L78 | [
"def",
"items_for_result",
"(",
"view",
",",
"result",
")",
":",
"model_admin",
"=",
"view",
".",
"model_admin",
"for",
"field_name",
"in",
"view",
".",
"list_display",
":",
"empty_value_display",
"=",
"model_admin",
".",
"get_empty_value_display",
"(",
")",
"ro... | 7fddc853bab2ff3868b8c7a03329308c55f16358 |
train | result_list | Displays the headers and data list together | wagtailmodeladmin/templatetags/wagtailmodeladmin_tags.py | def result_list(context):
"""
Displays the headers and data list together
"""
view = context['view']
object_list = context['object_list']
headers = list(result_headers(view))
num_sorted_fields = 0
for h in headers:
if h['sortable'] and h['sorted']:
num_sorted_fields +... | def result_list(context):
"""
Displays the headers and data list together
"""
view = context['view']
object_list = context['object_list']
headers = list(result_headers(view))
num_sorted_fields = 0
for h in headers:
if h['sortable'] and h['sorted']:
num_sorted_fields +... | [
"Displays",
"the",
"headers",
"and",
"data",
"list",
"together"
] | rkhleics/wagtailmodeladmin | python | https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/templatetags/wagtailmodeladmin_tags.py#L88-L103 | [
"def",
"result_list",
"(",
"context",
")",
":",
"view",
"=",
"context",
"[",
"'view'",
"]",
"object_list",
"=",
"context",
"[",
"'object_list'",
"]",
"headers",
"=",
"list",
"(",
"result_headers",
"(",
"view",
")",
")",
"num_sorted_fields",
"=",
"0",
"for"... | 7fddc853bab2ff3868b8c7a03329308c55f16358 |
train | run | TEAL interface for the `acssum` function. | acstools/acssum.py | def run(configobj=None):
"""
TEAL interface for the `acssum` function.
"""
acssum(configobj['input'],
configobj['output'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
verbose=configobj['verbose'],
quiet=configobj['quiet'... | def run(configobj=None):
"""
TEAL interface for the `acssum` function.
"""
acssum(configobj['input'],
configobj['output'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
verbose=configobj['verbose'],
quiet=configobj['quiet'... | [
"TEAL",
"interface",
"for",
"the",
"acssum",
"function",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acssum.py#L111-L122 | [
"def",
"run",
"(",
"configobj",
"=",
"None",
")",
":",
"acssum",
"(",
"configobj",
"[",
"'input'",
"]",
",",
"configobj",
"[",
"'output'",
"]",
",",
"exec_path",
"=",
"configobj",
"[",
"'exec_path'",
"]",
",",
"time_stamps",
"=",
"configobj",
"[",
"'time... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | _detsat_one | Called by :func:`detsat`. | acstools/satdet.py | def _detsat_one(filename, ext, sigma=2.0, low_thresh=0.1, h_thresh=0.5,
small_edge=60, line_len=200, line_gap=75,
percentile=(4.5, 93.0), buf=200, plot=False, verbose=False):
"""Called by :func:`detsat`."""
if verbose:
t_beg = time.time()
fname = '{0}[{1}]'.format(fi... | def _detsat_one(filename, ext, sigma=2.0, low_thresh=0.1, h_thresh=0.5,
small_edge=60, line_len=200, line_gap=75,
percentile=(4.5, 93.0), buf=200, plot=False, verbose=False):
"""Called by :func:`detsat`."""
if verbose:
t_beg = time.time()
fname = '{0}[{1}]'.format(fi... | [
"Called",
"by",
":",
"func",
":",
"detsat",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L180-L444 | [
"def",
"_detsat_one",
"(",
"filename",
",",
"ext",
",",
"sigma",
"=",
"2.0",
",",
"low_thresh",
"=",
"0.1",
",",
"h_thresh",
"=",
"0.5",
",",
"small_edge",
"=",
"60",
",",
"line_len",
"=",
"200",
",",
"line_gap",
"=",
"75",
",",
"percentile",
"=",
"(... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | _get_valid_indices | Give array shape and desired indices, return indices that are
correctly bounded by the shape. | acstools/satdet.py | def _get_valid_indices(shape, ix0, ix1, iy0, iy1):
"""Give array shape and desired indices, return indices that are
correctly bounded by the shape."""
ymax, xmax = shape
if ix0 < 0:
ix0 = 0
if ix1 > xmax:
ix1 = xmax
if iy0 < 0:
iy0 = 0
if iy1 > ymax:
iy1 = ym... | def _get_valid_indices(shape, ix0, ix1, iy0, iy1):
"""Give array shape and desired indices, return indices that are
correctly bounded by the shape."""
ymax, xmax = shape
if ix0 < 0:
ix0 = 0
if ix1 > xmax:
ix1 = xmax
if iy0 < 0:
iy0 = 0
if iy1 > ymax:
iy1 = ym... | [
"Give",
"array",
"shape",
"and",
"desired",
"indices",
"return",
"indices",
"that",
"are",
"correctly",
"bounded",
"by",
"the",
"shape",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L447-L465 | [
"def",
"_get_valid_indices",
"(",
"shape",
",",
"ix0",
",",
"ix1",
",",
"iy0",
",",
"iy1",
")",
":",
"ymax",
",",
"xmax",
"=",
"shape",
"if",
"ix0",
"<",
"0",
":",
"ix0",
"=",
"0",
"if",
"ix1",
">",
"xmax",
":",
"ix1",
"=",
"xmax",
"if",
"iy0",... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | _rotate_point | Transform a point from original image coordinates to rotated image
coordinates and back. It assumes the rotation point is the center of an
image.
This works on a simple rotation transformation::
newx = (startx) * np.cos(angle) - (starty) * np.sin(angle)
newy = (startx) * np.sin(angle) + (s... | acstools/satdet.py | def _rotate_point(point, angle, ishape, rshape, reverse=False):
"""Transform a point from original image coordinates to rotated image
coordinates and back. It assumes the rotation point is the center of an
image.
This works on a simple rotation transformation::
newx = (startx) * np.cos(angle) ... | def _rotate_point(point, angle, ishape, rshape, reverse=False):
"""Transform a point from original image coordinates to rotated image
coordinates and back. It assumes the rotation point is the center of an
image.
This works on a simple rotation transformation::
newx = (startx) * np.cos(angle) ... | [
"Transform",
"a",
"point",
"from",
"original",
"image",
"coordinates",
"to",
"rotated",
"image",
"coordinates",
"and",
"back",
".",
"It",
"assumes",
"the",
"rotation",
"point",
"is",
"the",
"center",
"of",
"an",
"image",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L468-L532 | [
"def",
"_rotate_point",
"(",
"point",
",",
"angle",
",",
"ishape",
",",
"rshape",
",",
"reverse",
"=",
"False",
")",
":",
"# unpack the image and rotated images shapes",
"if",
"reverse",
":",
"angle",
"=",
"(",
"angle",
"*",
"-",
"1",
")",
"temp",
"=",
"i... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | make_mask | Create DQ mask for an image for a given satellite trail.
This mask can be added to existing DQ data using :func:`update_dq`.
.. note::
Unlike :func:`detsat`, multiprocessing is not available for
this function.
Parameters
----------
filename : str
FITS image filename.
... | acstools/satdet.py | def make_mask(filename, ext, trail_coords, sublen=75, subwidth=200, order=3,
sigma=4, pad=10, plot=False, verbose=False):
"""Create DQ mask for an image for a given satellite trail.
This mask can be added to existing DQ data using :func:`update_dq`.
.. note::
Unlike :func:`detsat`, m... | def make_mask(filename, ext, trail_coords, sublen=75, subwidth=200, order=3,
sigma=4, pad=10, plot=False, verbose=False):
"""Create DQ mask for an image for a given satellite trail.
This mask can be added to existing DQ data using :func:`update_dq`.
.. note::
Unlike :func:`detsat`, m... | [
"Create",
"DQ",
"mask",
"for",
"an",
"image",
"for",
"a",
"given",
"satellite",
"trail",
".",
"This",
"mask",
"can",
"be",
"added",
"to",
"existing",
"DQ",
"data",
"using",
":",
"func",
":",
"update_dq",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L535-L874 | [
"def",
"make_mask",
"(",
"filename",
",",
"ext",
",",
"trail_coords",
",",
"sublen",
"=",
"75",
",",
"subwidth",
"=",
"200",
",",
"order",
"=",
"3",
",",
"sigma",
"=",
"4",
",",
"pad",
"=",
"10",
",",
"plot",
"=",
"False",
",",
"verbose",
"=",
"F... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | update_dq | Update the given image and DQ extension with the given
satellite trails mask and flag.
Parameters
----------
filename : str
FITS image filename to update.
ext : int, str, or tuple
DQ extension, as accepted by ``astropy.io.fits``, to update.
mask : ndarray
Boolean mask,... | acstools/satdet.py | def update_dq(filename, ext, mask, dqval=16384, verbose=True):
"""Update the given image and DQ extension with the given
satellite trails mask and flag.
Parameters
----------
filename : str
FITS image filename to update.
ext : int, str, or tuple
DQ extension, as accepted by ``a... | def update_dq(filename, ext, mask, dqval=16384, verbose=True):
"""Update the given image and DQ extension with the given
satellite trails mask and flag.
Parameters
----------
filename : str
FITS image filename to update.
ext : int, str, or tuple
DQ extension, as accepted by ``a... | [
"Update",
"the",
"given",
"image",
"and",
"DQ",
"extension",
"with",
"the",
"given",
"satellite",
"trails",
"mask",
"and",
"flag",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L877-L927 | [
"def",
"update_dq",
"(",
"filename",
",",
"ext",
",",
"mask",
",",
"dqval",
"=",
"16384",
",",
"verbose",
"=",
"True",
")",
":",
"with",
"fits",
".",
"open",
"(",
"filename",
",",
"mode",
"=",
"'update'",
")",
"as",
"pf",
":",
"dqarr",
"=",
"pf",
... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | _satdet_worker | Multiprocessing worker. | acstools/satdet.py | def _satdet_worker(work_queue, done_queue, sigma=2.0, low_thresh=0.1,
h_thresh=0.5, small_edge=60, line_len=200, line_gap=75,
percentile=(4.5, 93.0), buf=200):
"""Multiprocessing worker."""
for fil, chip in iter(work_queue.get, 'STOP'):
try:
result = _de... | def _satdet_worker(work_queue, done_queue, sigma=2.0, low_thresh=0.1,
h_thresh=0.5, small_edge=60, line_len=200, line_gap=75,
percentile=(4.5, 93.0), buf=200):
"""Multiprocessing worker."""
for fil, chip in iter(work_queue.get, 'STOP'):
try:
result = _de... | [
"Multiprocessing",
"worker",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L934-L952 | [
"def",
"_satdet_worker",
"(",
"work_queue",
",",
"done_queue",
",",
"sigma",
"=",
"2.0",
",",
"low_thresh",
"=",
"0.1",
",",
"h_thresh",
"=",
"0.5",
",",
"small_edge",
"=",
"60",
",",
"line_len",
"=",
"200",
",",
"line_gap",
"=",
"75",
",",
"percentile",... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | detsat | Find satellite trails in the given images and extensions.
The trails are calculated using Probabilistic Hough Transform.
.. note::
The trail endpoints found here are crude approximations.
Use :func:`make_mask` to create the actual DQ mask for the trail(s)
of interest.
Parameters
... | acstools/satdet.py | def detsat(searchpattern, chips=[1, 4], n_processes=4, sigma=2.0,
low_thresh=0.1, h_thresh=0.5, small_edge=60, line_len=200,
line_gap=75, percentile=(4.5, 93.0), buf=200, plot=False,
verbose=True):
"""Find satellite trails in the given images and extensions.
The trails are calcu... | def detsat(searchpattern, chips=[1, 4], n_processes=4, sigma=2.0,
low_thresh=0.1, h_thresh=0.5, small_edge=60, line_len=200,
line_gap=75, percentile=(4.5, 93.0), buf=200, plot=False,
verbose=True):
"""Find satellite trails in the given images and extensions.
The trails are calcu... | [
"Find",
"satellite",
"trails",
"in",
"the",
"given",
"images",
"and",
"extensions",
".",
"The",
"trails",
"are",
"calculated",
"using",
"Probabilistic",
"Hough",
"Transform",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/satdet.py#L955-L1149 | [
"def",
"detsat",
"(",
"searchpattern",
",",
"chips",
"=",
"[",
"1",
",",
"4",
"]",
",",
"n_processes",
"=",
"4",
",",
"sigma",
"=",
"2.0",
",",
"low_thresh",
"=",
"0.1",
",",
"h_thresh",
"=",
"0.5",
",",
"small_edge",
"=",
"60",
",",
"line_len",
"=... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | EventBus.on | Decorator for subscribing a function to a specific event.
:param event: Name of the event to subscribe to.
:type event: str
:return: The outer function.
:rtype: Callable | event_bus/bus.py | def on(self, event: str) -> Callable:
""" Decorator for subscribing a function to a specific event.
:param event: Name of the event to subscribe to.
:type event: str
:return: The outer function.
:rtype: Callable
"""
def outer(func):
self.add_event(f... | def on(self, event: str) -> Callable:
""" Decorator for subscribing a function to a specific event.
:param event: Name of the event to subscribe to.
:type event: str
:return: The outer function.
:rtype: Callable
"""
def outer(func):
self.add_event(f... | [
"Decorator",
"for",
"subscribing",
"a",
"function",
"to",
"a",
"specific",
"event",
"."
] | seanpar203/event-bus | python | https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L73-L92 | [
"def",
"on",
"(",
"self",
",",
"event",
":",
"str",
")",
"->",
"Callable",
":",
"def",
"outer",
"(",
"func",
")",
":",
"self",
".",
"add_event",
"(",
"func",
",",
"event",
")",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
... | 60319b9eb4e38c348e80f3ec625312eda75da765 |
train | EventBus.add_event | Adds a function to a event.
:param func: The function to call when event is emitted
:type func: Callable
:param event: Name of the event.
:type event: str | event_bus/bus.py | def add_event(self, func: Callable, event: str) -> None:
""" Adds a function to a event.
:param func: The function to call when event is emitted
:type func: Callable
:param event: Name of the event.
:type event: str
"""
self._events[event].add(func) | def add_event(self, func: Callable, event: str) -> None:
""" Adds a function to a event.
:param func: The function to call when event is emitted
:type func: Callable
:param event: Name of the event.
:type event: str
"""
self._events[event].add(func) | [
"Adds",
"a",
"function",
"to",
"a",
"event",
"."
] | seanpar203/event-bus | python | https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L94-L103 | [
"def",
"add_event",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"event",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_events",
"[",
"event",
"]",
".",
"add",
"(",
"func",
")"
] | 60319b9eb4e38c348e80f3ec625312eda75da765 |
train | EventBus.emit | Emit an event and run the subscribed functions.
:param event: Name of the event.
:type event: str
.. notes:
Passing in threads=True as a kwarg allows to run emitted events
as separate threads. This can significantly speed up code execution
depending on the c... | event_bus/bus.py | def emit(self, event: str, *args, **kwargs) -> None:
""" Emit an event and run the subscribed functions.
:param event: Name of the event.
:type event: str
.. notes:
Passing in threads=True as a kwarg allows to run emitted events
as separate threads. This can sig... | def emit(self, event: str, *args, **kwargs) -> None:
""" Emit an event and run the subscribed functions.
:param event: Name of the event.
:type event: str
.. notes:
Passing in threads=True as a kwarg allows to run emitted events
as separate threads. This can sig... | [
"Emit",
"an",
"event",
"and",
"run",
"the",
"subscribed",
"functions",
"."
] | seanpar203/event-bus | python | https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L105-L130 | [
"def",
"emit",
"(",
"self",
",",
"event",
":",
"str",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"threads",
"=",
"kwargs",
".",
"pop",
"(",
"'threads'",
",",
"None",
")",
"if",
"threads",
":",
"events",
"=",
"[",
"Thread",... | 60319b9eb4e38c348e80f3ec625312eda75da765 |
train | EventBus.emit_only | Specifically only emits certain subscribed events.
:param event: Name of the event.
:type event: str
:param func_names: Function(s) to emit.
:type func_names: Union[ str | List[str] ] | event_bus/bus.py | def emit_only(self, event: str, func_names: Union[str, List[str]], *args,
**kwargs) -> None:
""" Specifically only emits certain subscribed events.
:param event: Name of the event.
:type event: str
:param func_names: Function(s) to emit.
:type func_names: Unio... | def emit_only(self, event: str, func_names: Union[str, List[str]], *args,
**kwargs) -> None:
""" Specifically only emits certain subscribed events.
:param event: Name of the event.
:type event: str
:param func_names: Function(s) to emit.
:type func_names: Unio... | [
"Specifically",
"only",
"emits",
"certain",
"subscribed",
"events",
"."
] | seanpar203/event-bus | python | https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L132-L147 | [
"def",
"emit_only",
"(",
"self",
",",
"event",
":",
"str",
",",
"func_names",
":",
"Union",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"func_names",
"... | 60319b9eb4e38c348e80f3ec625312eda75da765 |
train | EventBus.emit_after | Decorator that emits events after the function is completed.
:param event: Name of the event.
:type event: str
:return: Callable
.. note:
This plainly just calls functions without passing params into the
subscribed callables. This is great if you want to do som... | event_bus/bus.py | def emit_after(self, event: str) -> Callable:
""" Decorator that emits events after the function is completed.
:param event: Name of the event.
:type event: str
:return: Callable
.. note:
This plainly just calls functions without passing params into the
... | def emit_after(self, event: str) -> Callable:
""" Decorator that emits events after the function is completed.
:param event: Name of the event.
:type event: str
:return: Callable
.. note:
This plainly just calls functions without passing params into the
... | [
"Decorator",
"that",
"emits",
"events",
"after",
"the",
"function",
"is",
"completed",
"."
] | seanpar203/event-bus | python | https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L149-L173 | [
"def",
"emit_after",
"(",
"self",
",",
"event",
":",
"str",
")",
"->",
"Callable",
":",
"def",
"outer",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"returned",
"=",... | 60319b9eb4e38c348e80f3ec625312eda75da765 |
train | EventBus.remove_event | Removes a subscribed function from a specific event.
:param func_name: The name of the function to be removed.
:type func_name: str
:param event: The name of the event.
:type event: str
:raise EventDoesntExist if there func_name doesn't exist in event. | event_bus/bus.py | def remove_event(self, func_name: str, event: str) -> None:
""" Removes a subscribed function from a specific event.
:param func_name: The name of the function to be removed.
:type func_name: str
:param event: The name of the event.
:type event: str
:raise EventDoesntE... | def remove_event(self, func_name: str, event: str) -> None:
""" Removes a subscribed function from a specific event.
:param func_name: The name of the function to be removed.
:type func_name: str
:param event: The name of the event.
:type event: str
:raise EventDoesntE... | [
"Removes",
"a",
"subscribed",
"function",
"from",
"a",
"specific",
"event",
"."
] | seanpar203/event-bus | python | https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L175-L196 | [
"def",
"remove_event",
"(",
"self",
",",
"func_name",
":",
"str",
",",
"event",
":",
"str",
")",
"->",
"None",
":",
"event_funcs_copy",
"=",
"self",
".",
"_events",
"[",
"event",
"]",
".",
"copy",
"(",
")",
"for",
"func",
"in",
"self",
".",
"_event_f... | 60319b9eb4e38c348e80f3ec625312eda75da765 |
train | EventBus._event_funcs | Returns an Iterable of the functions subscribed to a event.
:param event: Name of the event.
:type event: str
:return: A iterable to do things with.
:rtype: Iterable | event_bus/bus.py | def _event_funcs(self, event: str) -> Iterable[Callable]:
""" Returns an Iterable of the functions subscribed to a event.
:param event: Name of the event.
:type event: str
:return: A iterable to do things with.
:rtype: Iterable
"""
for func in self._events[event... | def _event_funcs(self, event: str) -> Iterable[Callable]:
""" Returns an Iterable of the functions subscribed to a event.
:param event: Name of the event.
:type event: str
:return: A iterable to do things with.
:rtype: Iterable
"""
for func in self._events[event... | [
"Returns",
"an",
"Iterable",
"of",
"the",
"functions",
"subscribed",
"to",
"a",
"event",
"."
] | seanpar203/event-bus | python | https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L202-L212 | [
"def",
"_event_funcs",
"(",
"self",
",",
"event",
":",
"str",
")",
"->",
"Iterable",
"[",
"Callable",
"]",
":",
"for",
"func",
"in",
"self",
".",
"_events",
"[",
"event",
"]",
":",
"yield",
"func"
] | 60319b9eb4e38c348e80f3ec625312eda75da765 |
train | EventBus._event_func_names | Returns string name of each function subscribed to an event.
:param event: Name of the event.
:type event: str
:return: Names of functions subscribed to a specific event.
:rtype: list | event_bus/bus.py | def _event_func_names(self, event: str) -> List[str]:
""" Returns string name of each function subscribed to an event.
:param event: Name of the event.
:type event: str
:return: Names of functions subscribed to a specific event.
:rtype: list
"""
return [func.__n... | def _event_func_names(self, event: str) -> List[str]:
""" Returns string name of each function subscribed to an event.
:param event: Name of the event.
:type event: str
:return: Names of functions subscribed to a specific event.
:rtype: list
"""
return [func.__n... | [
"Returns",
"string",
"name",
"of",
"each",
"function",
"subscribed",
"to",
"an",
"event",
"."
] | seanpar203/event-bus | python | https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L214-L223 | [
"def",
"_event_func_names",
"(",
"self",
",",
"event",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"func",
".",
"__name__",
"for",
"func",
"in",
"self",
".",
"_events",
"[",
"event",
"]",
"]"
] | 60319b9eb4e38c348e80f3ec625312eda75da765 |
train | EventBus._subscribed_event_count | Returns the total amount of subscribed events.
:return: Integer amount events.
:rtype: int | event_bus/bus.py | def _subscribed_event_count(self) -> int:
""" Returns the total amount of subscribed events.
:return: Integer amount events.
:rtype: int
"""
event_counter = Counter() # type: Dict[Any, int]
for key, values in self._events.items():
event_counter[key] = len(v... | def _subscribed_event_count(self) -> int:
""" Returns the total amount of subscribed events.
:return: Integer amount events.
:rtype: int
"""
event_counter = Counter() # type: Dict[Any, int]
for key, values in self._events.items():
event_counter[key] = len(v... | [
"Returns",
"the",
"total",
"amount",
"of",
"subscribed",
"events",
"."
] | seanpar203/event-bus | python | https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L225-L236 | [
"def",
"_subscribed_event_count",
"(",
"self",
")",
"->",
"int",
":",
"event_counter",
"=",
"Counter",
"(",
")",
"# type: Dict[Any, int]",
"for",
"key",
",",
"values",
"in",
"self",
".",
"_events",
".",
"items",
"(",
")",
":",
"event_counter",
"[",
"key",
... | 60319b9eb4e38c348e80f3ec625312eda75da765 |
train | clean | r"""Remove horizontal stripes from ACS WFC post-SM4 data.
Parameters
----------
input : str or list of str
Input filenames in one of these formats:
* a Python list of filenames
* a partial filename with wildcards ('\*flt.fits')
* filename of an ASN table ('j1234... | acstools/acs_destripe.py | def clean(input, suffix, stat="pmode1", maxiter=15, sigrej=2.0,
lower=None, upper=None, binwidth=0.3,
mask1=None, mask2=None, dqbits=None,
rpt_clean=0, atol=0.01, clobber=False, verbose=True):
r"""Remove horizontal stripes from ACS WFC post-SM4 data.
Parameters
----------
... | def clean(input, suffix, stat="pmode1", maxiter=15, sigrej=2.0,
lower=None, upper=None, binwidth=0.3,
mask1=None, mask2=None, dqbits=None,
rpt_clean=0, atol=0.01, clobber=False, verbose=True):
r"""Remove horizontal stripes from ACS WFC post-SM4 data.
Parameters
----------
... | [
"r",
"Remove",
"horizontal",
"stripes",
"from",
"ACS",
"WFC",
"post",
"-",
"SM4",
"data",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L222-L463 | [
"def",
"clean",
"(",
"input",
",",
"suffix",
",",
"stat",
"=",
"\"pmode1\"",
",",
"maxiter",
"=",
"15",
",",
"sigrej",
"=",
"2.0",
",",
"lower",
"=",
"None",
",",
"upper",
"=",
"None",
",",
"binwidth",
"=",
"0.3",
",",
"mask1",
"=",
"None",
",",
... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | perform_correction | Clean each input image.
Parameters
----------
image : str
Input image name.
output : str
Output image name.
mask : `numpy.ndarray`
Mask array.
maxiter, sigrej, clobber
See :func:`clean`.
dqbits : int, str, or None
Data quality bits to be considere... | acstools/acs_destripe.py | def perform_correction(image, output, stat="pmode1", maxiter=15, sigrej=2.0,
lower=None, upper=None, binwidth=0.3,
mask=None, dqbits=None,
rpt_clean=0, atol=0.01, clobber=False, verbose=True):
"""
Clean each input image.
Parameters
--... | def perform_correction(image, output, stat="pmode1", maxiter=15, sigrej=2.0,
lower=None, upper=None, binwidth=0.3,
mask=None, dqbits=None,
rpt_clean=0, atol=0.01, clobber=False, verbose=True):
"""
Clean each input image.
Parameters
--... | [
"Clean",
"each",
"input",
"image",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L466-L547 | [
"def",
"perform_correction",
"(",
"image",
",",
"output",
",",
"stat",
"=",
"\"pmode1\"",
",",
"maxiter",
"=",
"15",
",",
"sigrej",
"=",
"2.0",
",",
"lower",
"=",
"None",
",",
"upper",
"=",
"None",
",",
"binwidth",
"=",
"0.3",
",",
"mask",
"=",
"None... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | clean_streak | Apply destriping algorithm to input array.
Parameters
----------
image : `StripeArray` object
Arrays are modifed in-place.
stat : str
Statistics for background computations
(see :py:func:`clean` for more details)
mask : `numpy.ndarray`
Mask array. Pixels with zero ... | acstools/acs_destripe.py | def clean_streak(image, stat="pmode1", maxiter=15, sigrej=2.0,
lower=None, upper=None, binwidth=0.3, mask=None,
rpt_clean=0, atol=0.01, verbose=True):
"""
Apply destriping algorithm to input array.
Parameters
----------
image : `StripeArray` object
Arrays a... | def clean_streak(image, stat="pmode1", maxiter=15, sigrej=2.0,
lower=None, upper=None, binwidth=0.3, mask=None,
rpt_clean=0, atol=0.01, verbose=True):
"""
Apply destriping algorithm to input array.
Parameters
----------
image : `StripeArray` object
Arrays a... | [
"Apply",
"destriping",
"algorithm",
"to",
"input",
"array",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L583-L890 | [
"def",
"clean_streak",
"(",
"image",
",",
"stat",
"=",
"\"pmode1\"",
",",
"maxiter",
"=",
"15",
",",
"sigrej",
"=",
"2.0",
",",
"lower",
"=",
"None",
",",
"upper",
"=",
"None",
",",
"binwidth",
"=",
"0.3",
",",
"mask",
"=",
"None",
",",
"rpt_clean",
... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | djs_iterstat | Iterative sigma-clipping.
Parameters
----------
InputArr : `numpy.ndarray`
Input image array.
MaxIter, SigRej : see `clean`
Max, Min : float
Max and min values for clipping.
Mask : `numpy.ndarray`
Mask array to indicate pixels to reject, in addition to clipping.
... | acstools/acs_destripe.py | def djs_iterstat(InputArr, MaxIter=10, SigRej=3.0,
Max=None, Min=None, Mask=None, lineno=None):
"""
Iterative sigma-clipping.
Parameters
----------
InputArr : `numpy.ndarray`
Input image array.
MaxIter, SigRej : see `clean`
Max, Min : float
Max and min val... | def djs_iterstat(InputArr, MaxIter=10, SigRej=3.0,
Max=None, Min=None, Mask=None, lineno=None):
"""
Iterative sigma-clipping.
Parameters
----------
InputArr : `numpy.ndarray`
Input image array.
MaxIter, SigRej : see `clean`
Max, Min : float
Max and min val... | [
"Iterative",
"sigma",
"-",
"clipping",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L899-L1010 | [
"def",
"djs_iterstat",
"(",
"InputArr",
",",
"MaxIter",
"=",
"10",
",",
"SigRej",
"=",
"3.0",
",",
"Max",
"=",
"None",
",",
"Min",
"=",
"None",
",",
"Mask",
"=",
"None",
",",
"lineno",
"=",
"None",
")",
":",
"NGood",
"=",
"InputArr",
".",
"size",
... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | run | TEAL interface for the `clean` function. | acstools/acs_destripe.py | def run(configobj=None):
"""TEAL interface for the `clean` function."""
clean(configobj['input'],
suffix=configobj['suffix'],
stat=configobj['stat'],
maxiter=configobj['maxiter'],
sigrej=configobj['sigrej'],
lower=configobj['lower'],
upper=configobj['u... | def run(configobj=None):
"""TEAL interface for the `clean` function."""
clean(configobj['input'],
suffix=configobj['suffix'],
stat=configobj['stat'],
maxiter=configobj['maxiter'],
sigrej=configobj['sigrej'],
lower=configobj['lower'],
upper=configobj['u... | [
"TEAL",
"interface",
"for",
"the",
"clean",
"function",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L1022-L1039 | [
"def",
"run",
"(",
"configobj",
"=",
"None",
")",
":",
"clean",
"(",
"configobj",
"[",
"'input'",
"]",
",",
"suffix",
"=",
"configobj",
"[",
"'suffix'",
"]",
",",
"stat",
"=",
"configobj",
"[",
"'stat'",
"]",
",",
"maxiter",
"=",
"configobj",
"[",
"'... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | main | Command line driver. | acstools/acs_destripe.py | def main():
"""Command line driver."""
import argparse
parser = argparse.ArgumentParser(
prog=__taskname__,
description='Remove horizontal stripes from ACS WFC post-SM4 data.')
parser.add_argument(
'arg0', metavar='input', type=str, help='Input file')
parser.add_argument(
... | def main():
"""Command line driver."""
import argparse
parser = argparse.ArgumentParser(
prog=__taskname__,
description='Remove horizontal stripes from ACS WFC post-SM4 data.')
parser.add_argument(
'arg0', metavar='input', type=str, help='Input file')
parser.add_argument(
... | [
"Command",
"line",
"driver",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L1046-L1111 | [
"def",
"main",
"(",
")",
":",
"import",
"argparse",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"__taskname__",
",",
"description",
"=",
"'Remove horizontal stripes from ACS WFC post-SM4 data.'",
")",
"parser",
".",
"add_argument",
"(",
"'arg... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | StripeArray.configure_arrays | Get the SCI and ERR data. | acstools/acs_destripe.py | def configure_arrays(self):
"""Get the SCI and ERR data."""
self.science = self.hdulist['sci', 1].data
self.err = self.hdulist['err', 1].data
self.dq = self.hdulist['dq', 1].data
if (self.ampstring == 'ABCD'):
self.science = np.concatenate(
(self.scien... | def configure_arrays(self):
"""Get the SCI and ERR data."""
self.science = self.hdulist['sci', 1].data
self.err = self.hdulist['err', 1].data
self.dq = self.hdulist['dq', 1].data
if (self.ampstring == 'ABCD'):
self.science = np.concatenate(
(self.scien... | [
"Get",
"the",
"SCI",
"and",
"ERR",
"data",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L99-L113 | [
"def",
"configure_arrays",
"(",
"self",
")",
":",
"self",
".",
"science",
"=",
"self",
".",
"hdulist",
"[",
"'sci'",
",",
"1",
"]",
".",
"data",
"self",
".",
"err",
"=",
"self",
".",
"hdulist",
"[",
"'err'",
",",
"1",
"]",
".",
"data",
"self",
".... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | StripeArray.ingest_flatfield | Process flatfield. | acstools/acs_destripe.py | def ingest_flatfield(self):
"""Process flatfield."""
self.invflat = extract_flatfield(
self.hdulist[0].header, self.hdulist[1])
# If BIAS or DARK, set flatfield to unity
if self.invflat is None:
self.invflat = np.ones_like(self.science)
return
... | def ingest_flatfield(self):
"""Process flatfield."""
self.invflat = extract_flatfield(
self.hdulist[0].header, self.hdulist[1])
# If BIAS or DARK, set flatfield to unity
if self.invflat is None:
self.invflat = np.ones_like(self.science)
return
... | [
"Process",
"flatfield",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L115-L129 | [
"def",
"ingest_flatfield",
"(",
"self",
")",
":",
"self",
".",
"invflat",
"=",
"extract_flatfield",
"(",
"self",
".",
"hdulist",
"[",
"0",
"]",
".",
"header",
",",
"self",
".",
"hdulist",
"[",
"1",
"]",
")",
"# If BIAS or DARK, set flatfield to unity",
"if",... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | StripeArray.ingest_flash | Process post-flash. | acstools/acs_destripe.py | def ingest_flash(self):
"""Process post-flash."""
self.flash = extract_flash(self.hdulist[0].header, self.hdulist[1])
# Set post-flash to zeros
if self.flash is None:
self.flash = np.zeros_like(self.science)
return
# Apply the flash subtraction if neces... | def ingest_flash(self):
"""Process post-flash."""
self.flash = extract_flash(self.hdulist[0].header, self.hdulist[1])
# Set post-flash to zeros
if self.flash is None:
self.flash = np.zeros_like(self.science)
return
# Apply the flash subtraction if neces... | [
"Process",
"post",
"-",
"flash",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L131-L144 | [
"def",
"ingest_flash",
"(",
"self",
")",
":",
"self",
".",
"flash",
"=",
"extract_flash",
"(",
"self",
".",
"hdulist",
"[",
"0",
"]",
".",
"header",
",",
"self",
".",
"hdulist",
"[",
"1",
"]",
")",
"# Set post-flash to zeros",
"if",
"self",
".",
"flash... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | StripeArray.ingest_dark | Process dark. | acstools/acs_destripe.py | def ingest_dark(self):
"""Process dark."""
self.dark = extract_dark(self.hdulist[0].header, self.hdulist[1])
# If BIAS or DARK, set dark to zeros
if self.dark is None:
self.dark = np.zeros_like(self.science)
return
# Apply the dark subtraction if necess... | def ingest_dark(self):
"""Process dark."""
self.dark = extract_dark(self.hdulist[0].header, self.hdulist[1])
# If BIAS or DARK, set dark to zeros
if self.dark is None:
self.dark = np.zeros_like(self.science)
return
# Apply the dark subtraction if necess... | [
"Process",
"dark",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L146-L159 | [
"def",
"ingest_dark",
"(",
"self",
")",
":",
"self",
".",
"dark",
"=",
"extract_dark",
"(",
"self",
".",
"hdulist",
"[",
"0",
"]",
".",
"header",
",",
"self",
".",
"hdulist",
"[",
"1",
"]",
")",
"# If BIAS or DARK, set dark to zeros",
"if",
"self",
".",
... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | StripeArray.write_corrected | Write out the destriped data. | acstools/acs_destripe.py | def write_corrected(self, output, clobber=False):
"""Write out the destriped data."""
# un-apply the flatfield if necessary
if self.flatcorr != 'COMPLETE':
self.science = self.science / self.invflat
self.err = self.err / self.invflat
# un-apply the post-flash if... | def write_corrected(self, output, clobber=False):
"""Write out the destriped data."""
# un-apply the flatfield if necessary
if self.flatcorr != 'COMPLETE':
self.science = self.science / self.invflat
self.err = self.err / self.invflat
# un-apply the post-flash if... | [
"Write",
"out",
"the",
"destriped",
"data",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acs_destripe.py#L161-L191 | [
"def",
"write_corrected",
"(",
"self",
",",
"output",
",",
"clobber",
"=",
"False",
")",
":",
"# un-apply the flatfield if necessary",
"if",
"self",
".",
"flatcorr",
"!=",
"'COMPLETE'",
":",
"self",
".",
"science",
"=",
"self",
".",
"science",
"/",
"self",
"... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | calacs | Run the calacs.e executable as from the shell.
By default this will run the calacs given by 'calacs.e'.
Parameters
----------
input_file : str
Name of input file.
exec_path : str, optional
The complete path to a calacs executable.
time_stamps : bool, optional
Set to T... | acstools/calacs.py | def calacs(input_file, exec_path=None, time_stamps=False, temp_files=False,
verbose=False, debug=False, quiet=False, single_core=False,
exe_args=None):
"""
Run the calacs.e executable as from the shell.
By default this will run the calacs given by 'calacs.e'.
Parameters
-----... | def calacs(input_file, exec_path=None, time_stamps=False, temp_files=False,
verbose=False, debug=False, quiet=False, single_core=False,
exe_args=None):
"""
Run the calacs.e executable as from the shell.
By default this will run the calacs given by 'calacs.e'.
Parameters
-----... | [
"Run",
"the",
"calacs",
".",
"e",
"executable",
"as",
"from",
"the",
"shell",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/calacs.py#L28-L104 | [
"def",
"calacs",
"(",
"input_file",
",",
"exec_path",
"=",
"None",
",",
"time_stamps",
"=",
"False",
",",
"temp_files",
"=",
"False",
",",
"verbose",
"=",
"False",
",",
"debug",
"=",
"False",
",",
"quiet",
"=",
"False",
",",
"single_core",
"=",
"False",
... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | run | TEAL interface for the `calacs` function. | acstools/calacs.py | def run(configobj=None):
"""
TEAL interface for the `calacs` function.
"""
calacs(configobj['input_file'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
temp_files=configobj['temp_files'],
verbose=configobj['verbose'],
deb... | def run(configobj=None):
"""
TEAL interface for the `calacs` function.
"""
calacs(configobj['input_file'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
temp_files=configobj['temp_files'],
verbose=configobj['verbose'],
deb... | [
"TEAL",
"interface",
"for",
"the",
"calacs",
"function",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/calacs.py#L115-L128 | [
"def",
"run",
"(",
"configobj",
"=",
"None",
")",
":",
"calacs",
"(",
"configobj",
"[",
"'input_file'",
"]",
",",
"exec_path",
"=",
"configobj",
"[",
"'exec_path'",
"]",
",",
"time_stamps",
"=",
"configobj",
"[",
"'time_stamps'",
"]",
",",
"temp_files",
"=... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | PermissionHelper.has_any_permissions | Return a boolean to indicate whether the supplied user has any
permissions at all on the associated model | wagtailmodeladmin/helpers.py | def has_any_permissions(self, user):
"""
Return a boolean to indicate whether the supplied user has any
permissions at all on the associated model
"""
for perm in self.get_all_model_permissions():
if self.has_specific_permission(user, perm.codename):
r... | def has_any_permissions(self, user):
"""
Return a boolean to indicate whether the supplied user has any
permissions at all on the associated model
"""
for perm in self.get_all_model_permissions():
if self.has_specific_permission(user, perm.codename):
r... | [
"Return",
"a",
"boolean",
"to",
"indicate",
"whether",
"the",
"supplied",
"user",
"has",
"any",
"permissions",
"at",
"all",
"on",
"the",
"associated",
"model"
] | rkhleics/wagtailmodeladmin | python | https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/helpers.py#L31-L39 | [
"def",
"has_any_permissions",
"(",
"self",
",",
"user",
")",
":",
"for",
"perm",
"in",
"self",
".",
"get_all_model_permissions",
"(",
")",
":",
"if",
"self",
".",
"has_specific_permission",
"(",
"user",
",",
"perm",
".",
"codename",
")",
":",
"return",
"Tr... | 7fddc853bab2ff3868b8c7a03329308c55f16358 |
train | PagePermissionHelper.get_valid_parent_pages | Identifies possible parent pages for the current user by first looking
at allowed_parent_page_models() on self.model to limit options to the
correct type of page, then checking permissions on those individual
pages to make sure we have permission to add a subpage to it. | wagtailmodeladmin/helpers.py | def get_valid_parent_pages(self, user):
"""
Identifies possible parent pages for the current user by first looking
at allowed_parent_page_models() on self.model to limit options to the
correct type of page, then checking permissions on those individual
pages to make sure we have ... | def get_valid_parent_pages(self, user):
"""
Identifies possible parent pages for the current user by first looking
at allowed_parent_page_models() on self.model to limit options to the
correct type of page, then checking permissions on those individual
pages to make sure we have ... | [
"Identifies",
"possible",
"parent",
"pages",
"for",
"the",
"current",
"user",
"by",
"first",
"looking",
"at",
"allowed_parent_page_models",
"()",
"on",
"self",
".",
"model",
"to",
"limit",
"options",
"to",
"the",
"correct",
"type",
"of",
"page",
"then",
"check... | rkhleics/wagtailmodeladmin | python | https://github.com/rkhleics/wagtailmodeladmin/blob/7fddc853bab2ff3868b8c7a03329308c55f16358/wagtailmodeladmin/helpers.py#L108-L128 | [
"def",
"get_valid_parent_pages",
"(",
"self",
",",
"user",
")",
":",
"# Start with empty qs",
"parents_qs",
"=",
"Page",
".",
"objects",
".",
"none",
"(",
")",
"# Add pages of the correct type",
"for",
"pt",
"in",
"self",
".",
"model",
".",
"allowed_parent_page_mo... | 7fddc853bab2ff3868b8c7a03329308c55f16358 |
train | acsrej | r"""
Run the acsrej.e executable as from the shell.
Parameters
----------
input : str or list of str
Input filenames in one of these formats:
* a Python list of filenames
* a partial filename with wildcards ('\*flt.fits')
* filename of an ASN table ('j123456... | acstools/acsrej.py | def acsrej(input, output, exec_path='', time_stamps=False, verbose=False,
shadcorr=False, crrejtab='', crmask=False, scalense=None,
initgues='', skysub='', crsigmas='', crradius=None, crthresh=None,
badinpdq=None, newbias=False, readnoise_only=False, exe_args=None):
r"""
Run the... | def acsrej(input, output, exec_path='', time_stamps=False, verbose=False,
shadcorr=False, crrejtab='', crmask=False, scalense=None,
initgues='', skysub='', crsigmas='', crradius=None, crthresh=None,
badinpdq=None, newbias=False, readnoise_only=False, exe_args=None):
r"""
Run the... | [
"r",
"Run",
"the",
"acsrej",
".",
"e",
"executable",
"as",
"from",
"the",
"shell",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acsrej.py#L38-L198 | [
"def",
"acsrej",
"(",
"input",
",",
"output",
",",
"exec_path",
"=",
"''",
",",
"time_stamps",
"=",
"False",
",",
"verbose",
"=",
"False",
",",
"shadcorr",
"=",
"False",
",",
"crrejtab",
"=",
"''",
",",
"crmask",
"=",
"False",
",",
"scalense",
"=",
"... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | run | TEAL interface for the `acsrej` function. | acstools/acsrej.py | def run(configobj=None):
"""
TEAL interface for the `acsrej` function.
"""
acsrej(configobj['input'],
configobj['output'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
verbose=configobj['verbose'],
shadcorr=configobj['sha... | def run(configobj=None):
"""
TEAL interface for the `acsrej` function.
"""
acsrej(configobj['input'],
configobj['output'],
exec_path=configobj['exec_path'],
time_stamps=configobj['time_stamps'],
verbose=configobj['verbose'],
shadcorr=configobj['sha... | [
"TEAL",
"interface",
"for",
"the",
"acsrej",
"function",
"."
] | spacetelescope/acstools | python | https://github.com/spacetelescope/acstools/blob/bbf8dd080cefcbf88529ec87c420f9e1b8002554/acstools/acsrej.py#L209-L229 | [
"def",
"run",
"(",
"configobj",
"=",
"None",
")",
":",
"acsrej",
"(",
"configobj",
"[",
"'input'",
"]",
",",
"configobj",
"[",
"'output'",
"]",
",",
"exec_path",
"=",
"configobj",
"[",
"'exec_path'",
"]",
",",
"time_stamps",
"=",
"configobj",
"[",
"'time... | bbf8dd080cefcbf88529ec87c420f9e1b8002554 |
train | monkeypatch_os_fork_functions | Replace os.fork* with wrappers that use ForkSafeLock to acquire
all locks before forking and release them afterwards. | atfork/__init__.py | def monkeypatch_os_fork_functions():
"""
Replace os.fork* with wrappers that use ForkSafeLock to acquire
all locks before forking and release them afterwards.
"""
builtin_function = type(''.join)
if hasattr(os, 'fork') and isinstance(os.fork, builtin_function):
global _orig_os_fork
... | def monkeypatch_os_fork_functions():
"""
Replace os.fork* with wrappers that use ForkSafeLock to acquire
all locks before forking and release them afterwards.
"""
builtin_function = type(''.join)
if hasattr(os, 'fork') and isinstance(os.fork, builtin_function):
global _orig_os_fork
... | [
"Replace",
"os",
".",
"fork",
"*",
"with",
"wrappers",
"that",
"use",
"ForkSafeLock",
"to",
"acquire",
"all",
"locks",
"before",
"forking",
"and",
"release",
"them",
"afterwards",
"."
] | google/python-atfork | python | https://github.com/google/python-atfork/blob/0ba186bd3a75f823c720e711b39d73441da67ea4/atfork/__init__.py#L58-L71 | [
"def",
"monkeypatch_os_fork_functions",
"(",
")",
":",
"builtin_function",
"=",
"type",
"(",
"''",
".",
"join",
")",
"if",
"hasattr",
"(",
"os",
",",
"'fork'",
")",
"and",
"isinstance",
"(",
"os",
".",
"fork",
",",
"builtin_function",
")",
":",
"global",
... | 0ba186bd3a75f823c720e711b39d73441da67ea4 |
train | atfork | A Python work-a-like of pthread_atfork.
Any time a fork() is called from Python, all 'prepare' callables will
be called in the order they were registered using this function.
After the fork (successful or not), all 'parent' callables will be called in
the parent process. If the fork succeeded, al... | atfork/__init__.py | def atfork(prepare=None, parent=None, child=None):
"""A Python work-a-like of pthread_atfork.
Any time a fork() is called from Python, all 'prepare' callables will
be called in the order they were registered using this function.
After the fork (successful or not), all 'parent' callables will be ca... | def atfork(prepare=None, parent=None, child=None):
"""A Python work-a-like of pthread_atfork.
Any time a fork() is called from Python, all 'prepare' callables will
be called in the order they were registered using this function.
After the fork (successful or not), all 'parent' callables will be ca... | [
"A",
"Python",
"work",
"-",
"a",
"-",
"like",
"of",
"pthread_atfork",
".",
"Any",
"time",
"a",
"fork",
"()",
"is",
"called",
"from",
"Python",
"all",
"prepare",
"callables",
"will",
"be",
"called",
"in",
"the",
"order",
"they",
"were",
"registered",
"usi... | google/python-atfork | python | https://github.com/google/python-atfork/blob/0ba186bd3a75f823c720e711b39d73441da67ea4/atfork/__init__.py#L82-L108 | [
"def",
"atfork",
"(",
"prepare",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"child",
"=",
"None",
")",
":",
"assert",
"not",
"prepare",
"or",
"callable",
"(",
"prepare",
")",
"assert",
"not",
"parent",
"or",
"callable",
"(",
"parent",
")",
"assert",... | 0ba186bd3a75f823c720e711b39d73441da67ea4 |
train | _call_atfork_list | Given a list of callables in call_list, call them all in order and save
and return a list of sys.exc_info() tuples for each exception raised. | atfork/__init__.py | def _call_atfork_list(call_list):
"""
Given a list of callables in call_list, call them all in order and save
and return a list of sys.exc_info() tuples for each exception raised.
"""
exception_list = []
for func in call_list:
try:
func()
except:
exception... | def _call_atfork_list(call_list):
"""
Given a list of callables in call_list, call them all in order and save
and return a list of sys.exc_info() tuples for each exception raised.
"""
exception_list = []
for func in call_list:
try:
func()
except:
exception... | [
"Given",
"a",
"list",
"of",
"callables",
"in",
"call_list",
"call",
"them",
"all",
"in",
"order",
"and",
"save",
"and",
"return",
"a",
"list",
"of",
"sys",
".",
"exc_info",
"()",
"tuples",
"for",
"each",
"exception",
"raised",
"."
] | google/python-atfork | python | https://github.com/google/python-atfork/blob/0ba186bd3a75f823c720e711b39d73441da67ea4/atfork/__init__.py#L111-L122 | [
"def",
"_call_atfork_list",
"(",
"call_list",
")",
":",
"exception_list",
"=",
"[",
"]",
"for",
"func",
"in",
"call_list",
":",
"try",
":",
"func",
"(",
")",
"except",
":",
"exception_list",
".",
"append",
"(",
"sys",
".",
"exc_info",
"(",
")",
")",
"r... | 0ba186bd3a75f823c720e711b39d73441da67ea4 |
train | parent_after_fork_release | Call all parent after fork callables, release the lock and print
all prepare and parent callback exceptions. | atfork/__init__.py | def parent_after_fork_release():
"""
Call all parent after fork callables, release the lock and print
all prepare and parent callback exceptions.
"""
prepare_exceptions = list(_prepare_call_exceptions)
del _prepare_call_exceptions[:]
exceptions = _call_atfork_list(_parent_call_list)
_for... | def parent_after_fork_release():
"""
Call all parent after fork callables, release the lock and print
all prepare and parent callback exceptions.
"""
prepare_exceptions = list(_prepare_call_exceptions)
del _prepare_call_exceptions[:]
exceptions = _call_atfork_list(_parent_call_list)
_for... | [
"Call",
"all",
"parent",
"after",
"fork",
"callables",
"release",
"the",
"lock",
"and",
"print",
"all",
"prepare",
"and",
"parent",
"callback",
"exceptions",
"."
] | google/python-atfork | python | https://github.com/google/python-atfork/blob/0ba186bd3a75f823c720e711b39d73441da67ea4/atfork/__init__.py#L131-L141 | [
"def",
"parent_after_fork_release",
"(",
")",
":",
"prepare_exceptions",
"=",
"list",
"(",
"_prepare_call_exceptions",
")",
"del",
"_prepare_call_exceptions",
"[",
":",
"]",
"exceptions",
"=",
"_call_atfork_list",
"(",
"_parent_call_list",
")",
"_fork_lock",
".",
"rel... | 0ba186bd3a75f823c720e711b39d73441da67ea4 |
train | _print_exception_list | Given a list of sys.exc_info tuples, print them all using the traceback
module preceeded by a message and separated by a blank line. | atfork/__init__.py | def _print_exception_list(exceptions, message, output_file=None):
"""
Given a list of sys.exc_info tuples, print them all using the traceback
module preceeded by a message and separated by a blank line.
"""
output_file = output_file or sys.stderr
message = 'Exception %s:\n' % message
for exc... | def _print_exception_list(exceptions, message, output_file=None):
"""
Given a list of sys.exc_info tuples, print them all using the traceback
module preceeded by a message and separated by a blank line.
"""
output_file = output_file or sys.stderr
message = 'Exception %s:\n' % message
for exc... | [
"Given",
"a",
"list",
"of",
"sys",
".",
"exc_info",
"tuples",
"print",
"them",
"all",
"using",
"the",
"traceback",
"module",
"preceeded",
"by",
"a",
"message",
"and",
"separated",
"by",
"a",
"blank",
"line",
"."
] | google/python-atfork | python | https://github.com/google/python-atfork/blob/0ba186bd3a75f823c720e711b39d73441da67ea4/atfork/__init__.py#L155-L166 | [
"def",
"_print_exception_list",
"(",
"exceptions",
",",
"message",
",",
"output_file",
"=",
"None",
")",
":",
"output_file",
"=",
"output_file",
"or",
"sys",
".",
"stderr",
"message",
"=",
"'Exception %s:\\n'",
"%",
"message",
"for",
"exc_type",
",",
"exc_value"... | 0ba186bd3a75f823c720e711b39d73441da67ea4 |
train | os_forkpty_wrapper | Wraps os.forkpty() to run atfork handlers. | atfork/__init__.py | def os_forkpty_wrapper():
"""Wraps os.forkpty() to run atfork handlers."""
pid = None
prepare_to_fork_acquire()
try:
pid, fd = _orig_os_forkpty()
finally:
if pid == 0:
child_after_fork_release()
else:
parent_after_fork_release()
return pid, fd | def os_forkpty_wrapper():
"""Wraps os.forkpty() to run atfork handlers."""
pid = None
prepare_to_fork_acquire()
try:
pid, fd = _orig_os_forkpty()
finally:
if pid == 0:
child_after_fork_release()
else:
parent_after_fork_release()
return pid, fd | [
"Wraps",
"os",
".",
"forkpty",
"()",
"to",
"run",
"atfork",
"handlers",
"."
] | google/python-atfork | python | https://github.com/google/python-atfork/blob/0ba186bd3a75f823c720e711b39d73441da67ea4/atfork/__init__.py#L185-L196 | [
"def",
"os_forkpty_wrapper",
"(",
")",
":",
"pid",
"=",
"None",
"prepare_to_fork_acquire",
"(",
")",
"try",
":",
"pid",
",",
"fd",
"=",
"_orig_os_forkpty",
"(",
")",
"finally",
":",
"if",
"pid",
"==",
"0",
":",
"child_after_fork_release",
"(",
")",
"else",... | 0ba186bd3a75f823c720e711b39d73441da67ea4 |
train | maybe | Wraps an object with a Maybe instance.
>>> maybe("I'm a value")
Something("I'm a value")
>>> maybe(None);
Nothing
Testing for value:
>>> maybe("I'm a value").is_some()
True
>>> maybe("I'm a value").is_none()
False
>>> maybe(None).is_some()
... | pymaybe/__init__.py | def maybe(value):
"""Wraps an object with a Maybe instance.
>>> maybe("I'm a value")
Something("I'm a value")
>>> maybe(None);
Nothing
Testing for value:
>>> maybe("I'm a value").is_some()
True
>>> maybe("I'm a value").is_none()
False
>>> may... | def maybe(value):
"""Wraps an object with a Maybe instance.
>>> maybe("I'm a value")
Something("I'm a value")
>>> maybe(None);
Nothing
Testing for value:
>>> maybe("I'm a value").is_some()
True
>>> maybe("I'm a value").is_none()
False
>>> may... | [
"Wraps",
"an",
"object",
"with",
"a",
"Maybe",
"instance",
"."
] | ekampf/pymaybe | python | https://github.com/ekampf/pymaybe/blob/f755600f5478b6b595e2100417b39a7bc3de2c6f/pymaybe/__init__.py#L472-L575 | [
"def",
"maybe",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Maybe",
")",
":",
"return",
"value",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"Something",
"(",
"value",
")",
"return",
"Nothing",
"(",
")"
] | f755600f5478b6b595e2100417b39a7bc3de2c6f |
train | TelnetHandler.setup | Called after instantiation | telnetsrv/evtlet.py | def setup(self):
'''Called after instantiation'''
TelnetHandlerBase.setup(self)
# Spawn a greenlet to handle socket input
self.greenlet_ic = eventlet.spawn(self.inputcooker)
# Note that inputcooker exits on EOF
# Sleep for 0.5 second to allow options negotiation
... | def setup(self):
'''Called after instantiation'''
TelnetHandlerBase.setup(self)
# Spawn a greenlet to handle socket input
self.greenlet_ic = eventlet.spawn(self.inputcooker)
# Note that inputcooker exits on EOF
# Sleep for 0.5 second to allow options negotiation
... | [
"Called",
"after",
"instantiation"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/evtlet.py#L16-L24 | [
"def",
"setup",
"(",
"self",
")",
":",
"TelnetHandlerBase",
".",
"setup",
"(",
"self",
")",
"# Spawn a greenlet to handle socket input",
"self",
".",
"greenlet_ic",
"=",
"eventlet",
".",
"spawn",
"(",
"self",
".",
"inputcooker",
")",
"# Note that inputcooker exits o... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandler.inputcooker_store_queue | Put the cooked data in the input queue (no locking needed) | telnetsrv/evtlet.py | def inputcooker_store_queue(self, char):
"""Put the cooked data in the input queue (no locking needed)"""
if type(char) in [type(()), type([]), type("")]:
for v in char:
self.cookedq.put(v)
else:
self.cookedq.put(char) | def inputcooker_store_queue(self, char):
"""Put the cooked data in the input queue (no locking needed)"""
if type(char) in [type(()), type([]), type("")]:
for v in char:
self.cookedq.put(v)
else:
self.cookedq.put(char) | [
"Put",
"the",
"cooked",
"data",
"in",
"the",
"input",
"queue",
"(",
"no",
"locking",
"needed",
")"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/evtlet.py#L51-L57 | [
"def",
"inputcooker_store_queue",
"(",
"self",
",",
"char",
")",
":",
"if",
"type",
"(",
"char",
")",
"in",
"[",
"type",
"(",
"(",
")",
")",
",",
"type",
"(",
"[",
"]",
")",
",",
"type",
"(",
"\"\"",
")",
"]",
":",
"for",
"v",
"in",
"char",
"... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | SSHHandler.setup | Setup the connection. | telnetsrv/paramiko_ssh.py | def setup(self):
'''Setup the connection.'''
log.debug( 'New request from address %s, port %d', self.client_address )
try:
self.transport.load_server_moduli()
except:
log.exception( '(Failed to load moduli -- gex will be unsupported.)' )
rais... | def setup(self):
'''Setup the connection.'''
log.debug( 'New request from address %s, port %d', self.client_address )
try:
self.transport.load_server_moduli()
except:
log.exception( '(Failed to load moduli -- gex will be unsupported.)' )
rais... | [
"Setup",
"the",
"connection",
"."
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/paramiko_ssh.py#L71-L108 | [
"def",
"setup",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'New request from address %s, port %d'",
",",
"self",
".",
"client_address",
")",
"try",
":",
"self",
".",
"transport",
".",
"load_server_moduli",
"(",
")",
"except",
":",
"log",
".",
"excepti... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | SSHHandler.streamserver_handle | Translate this class for use in a StreamServer | telnetsrv/paramiko_ssh.py | def streamserver_handle(cls, socket, address):
'''Translate this class for use in a StreamServer'''
request = cls.dummy_request()
request._sock = socket
server = None
cls(request, address, server) | def streamserver_handle(cls, socket, address):
'''Translate this class for use in a StreamServer'''
request = cls.dummy_request()
request._sock = socket
server = None
cls(request, address, server) | [
"Translate",
"this",
"class",
"for",
"use",
"in",
"a",
"StreamServer"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/paramiko_ssh.py#L118-L123 | [
"def",
"streamserver_handle",
"(",
"cls",
",",
"socket",
",",
"address",
")",
":",
"request",
"=",
"cls",
".",
"dummy_request",
"(",
")",
"request",
".",
"_sock",
"=",
"socket",
"server",
"=",
"None",
"cls",
"(",
"request",
",",
"address",
",",
"server",... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | SSHHandler.check_channel_shell_request | Request to start a shell on the given channel | telnetsrv/paramiko_ssh.py | def check_channel_shell_request(self, channel):
'''Request to start a shell on the given channel'''
try:
self.channels[channel].start()
except KeyError:
log.error('Requested to start a channel (%r) that was not previously set up.', channel)
return False
... | def check_channel_shell_request(self, channel):
'''Request to start a shell on the given channel'''
try:
self.channels[channel].start()
except KeyError:
log.error('Requested to start a channel (%r) that was not previously set up.', channel)
return False
... | [
"Request",
"to",
"start",
"a",
"shell",
"on",
"the",
"given",
"channel"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/paramiko_ssh.py#L200-L208 | [
"def",
"check_channel_shell_request",
"(",
"self",
",",
"channel",
")",
":",
"try",
":",
"self",
".",
"channels",
"[",
"channel",
"]",
".",
"start",
"(",
")",
"except",
"KeyError",
":",
"log",
".",
"error",
"(",
"'Requested to start a channel (%r) that was not p... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | SSHHandler.check_channel_pty_request | Request to allocate a PTY terminal. | telnetsrv/paramiko_ssh.py | def check_channel_pty_request(self, channel, term, width, height, pixelwidth,
pixelheight, modes):
'''Request to allocate a PTY terminal.'''
#self.sshterm = term
#print "term: %r, modes: %r" % (term, modes)
log.debug('PTY requested. Setting up %r.', sel... | def check_channel_pty_request(self, channel, term, width, height, pixelwidth,
pixelheight, modes):
'''Request to allocate a PTY terminal.'''
#self.sshterm = term
#print "term: %r, modes: %r" % (term, modes)
log.debug('PTY requested. Setting up %r.', sel... | [
"Request",
"to",
"allocate",
"a",
"PTY",
"terminal",
"."
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/paramiko_ssh.py#L210-L219 | [
"def",
"check_channel_pty_request",
"(",
"self",
",",
"channel",
",",
"term",
",",
"width",
",",
"height",
",",
"pixelwidth",
",",
"pixelheight",
",",
"modes",
")",
":",
"#self.sshterm = term",
"#print \"term: %r, modes: %r\" % (term, modes)",
"log",
".",
"debug",
"... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | download | if py3:
file_size = int(u.getheader("Content-Length")[0])
else:
file_size = int(u.info().getheaders("Content-Length")[0]) | pydl4j/downloader.py | def download(url, file_name):
r = requests.get(url, stream=True)
file_size = int(r.headers['Content-length'])
'''
if py3:
file_size = int(u.getheader("Content-Length")[0])
else:
file_size = int(u.info().getheaders("Content-Length")[0])
'''
file_exists = False
if... | def download(url, file_name):
r = requests.get(url, stream=True)
file_size = int(r.headers['Content-length'])
'''
if py3:
file_size = int(u.getheader("Content-Length")[0])
else:
file_size = int(u.info().getheaders("Content-Length")[0])
'''
file_exists = False
if... | [
"if",
"py3",
":",
"file_size",
"=",
"int",
"(",
"u",
".",
"getheader",
"(",
"Content",
"-",
"Length",
")",
"[",
"0",
"]",
")",
"else",
":",
"file_size",
"=",
"int",
"(",
"u",
".",
"info",
"()",
".",
"getheaders",
"(",
"Content",
"-",
"Length",
")... | deeplearning4j/pydl4j | python | https://github.com/deeplearning4j/pydl4j/blob/63f8a1cae2afb4b08dbfe28ef8e08de741f0d3cd/pydl4j/downloader.py#L23-L82 | [
"def",
"download",
"(",
"url",
",",
"file_name",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"stream",
"=",
"True",
")",
"file_size",
"=",
"int",
"(",
"r",
".",
"headers",
"[",
"'Content-length'",
"]",
")",
"file_exists",
"=",
"False... | 63f8a1cae2afb4b08dbfe28ef8e08de741f0d3cd |
train | BankIDJSONClient.authenticate | Request an authentication order. The :py:meth:`collect` method
is used to query the status of the order.
Note that personal number is not needed when authentication is to
be done on the same device, provided that the returned
``autoStartToken`` is used to open the BankID Client.
... | bankid/jsonclient.py | def authenticate(
self, end_user_ip, personal_number=None, requirement=None, **kwargs
):
"""Request an authentication order. The :py:meth:`collect` method
is used to query the status of the order.
Note that personal number is not needed when authentication is to
be done on t... | def authenticate(
self, end_user_ip, personal_number=None, requirement=None, **kwargs
):
"""Request an authentication order. The :py:meth:`collect` method
is used to query the status of the order.
Note that personal number is not needed when authentication is to
be done on t... | [
"Request",
"an",
"authentication",
"order",
".",
"The",
":",
"py",
":",
"meth",
":",
"collect",
"method",
"is",
"used",
"to",
"query",
"the",
"status",
"of",
"the",
"order",
"."
] | hbldh/pybankid | python | https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/jsonclient.py#L79-L126 | [
"def",
"authenticate",
"(",
"self",
",",
"end_user_ip",
",",
"personal_number",
"=",
"None",
",",
"requirement",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"endUserIp\"",
":",
"end_user_ip",
"}",
"if",
"personal_number",
":",
"data... | 1405f66e41f912cdda15e20aea08cdfa6b60480a |
train | BankIDJSONClient.sign | Request an signing order. The :py:meth:`collect` method
is used to query the status of the order.
Note that personal number is not needed when signing is to be done
on the same device, provided that the returned ``autoStartToken``
is used to open the BankID Client.
Example data... | bankid/jsonclient.py | def sign(
self,
end_user_ip,
user_visible_data,
personal_number=None,
requirement=None,
user_non_visible_data=None,
**kwargs
):
"""Request an signing order. The :py:meth:`collect` method
is used to query the status of the order.
Note t... | def sign(
self,
end_user_ip,
user_visible_data,
personal_number=None,
requirement=None,
user_non_visible_data=None,
**kwargs
):
"""Request an signing order. The :py:meth:`collect` method
is used to query the status of the order.
Note t... | [
"Request",
"an",
"signing",
"order",
".",
"The",
":",
"py",
":",
"meth",
":",
"collect",
"method",
"is",
"used",
"to",
"query",
"the",
"status",
"of",
"the",
"order",
"."
] | hbldh/pybankid | python | https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/jsonclient.py#L128-L190 | [
"def",
"sign",
"(",
"self",
",",
"end_user_ip",
",",
"user_visible_data",
",",
"personal_number",
"=",
"None",
",",
"requirement",
"=",
"None",
",",
"user_non_visible_data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"endUserIp\"",
... | 1405f66e41f912cdda15e20aea08cdfa6b60480a |
train | BankIDJSONClient.collect | Collects the result of a sign or auth order using the
``orderRef`` as reference.
RP should keep on calling collect every two seconds as long as status
indicates pending. RP must abort if status indicates failed. The user
identity is returned when complete.
Example collect resul... | bankid/jsonclient.py | def collect(self, order_ref):
"""Collects the result of a sign or auth order using the
``orderRef`` as reference.
RP should keep on calling collect every two seconds as long as status
indicates pending. RP must abort if status indicates failed. The user
identity is returned when... | def collect(self, order_ref):
"""Collects the result of a sign or auth order using the
``orderRef`` as reference.
RP should keep on calling collect every two seconds as long as status
indicates pending. RP must abort if status indicates failed. The user
identity is returned when... | [
"Collects",
"the",
"result",
"of",
"a",
"sign",
"or",
"auth",
"order",
"using",
"the",
"orderRef",
"as",
"reference",
"."
] | hbldh/pybankid | python | https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/jsonclient.py#L192-L267 | [
"def",
"collect",
"(",
"self",
",",
"order_ref",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"self",
".",
"_collect_endpoint",
",",
"json",
"=",
"{",
"\"orderRef\"",
":",
"order_ref",
"}",
")",
"if",
"response",
".",
"status_code"... | 1405f66e41f912cdda15e20aea08cdfa6b60480a |
train | BankIDJSONClient.cancel | Cancels an ongoing sign or auth order.
This is typically used if the user cancels the order
in your service or app.
:param order_ref: The UUID string specifying which order to cancel.
:type order_ref: str
:return: Boolean regarding success of cancellation.
:rtype: bool
... | bankid/jsonclient.py | def cancel(self, order_ref):
"""Cancels an ongoing sign or auth order.
This is typically used if the user cancels the order
in your service or app.
:param order_ref: The UUID string specifying which order to cancel.
:type order_ref: str
:return: Boolean regarding succes... | def cancel(self, order_ref):
"""Cancels an ongoing sign or auth order.
This is typically used if the user cancels the order
in your service or app.
:param order_ref: The UUID string specifying which order to cancel.
:type order_ref: str
:return: Boolean regarding succes... | [
"Cancels",
"an",
"ongoing",
"sign",
"or",
"auth",
"order",
"."
] | hbldh/pybankid | python | https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/jsonclient.py#L269-L288 | [
"def",
"cancel",
"(",
"self",
",",
"order_ref",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"self",
".",
"_cancel_endpoint",
",",
"json",
"=",
"{",
"\"orderRef\"",
":",
"order_ref",
"}",
")",
"if",
"response",
".",
"status_code",
... | 1405f66e41f912cdda15e20aea08cdfa6b60480a |
train | TelnetHandler.setup | Called after instantiation | telnetsrv/threaded.py | def setup(self):
'''Called after instantiation'''
TelnetHandlerBase.setup(self)
# Spawn a thread to handle socket input
self.thread_ic = threading.Thread(target=self.inputcooker)
self.thread_ic.setDaemon(True)
self.thread_ic.start()
# Note that inputcooker exits o... | def setup(self):
'''Called after instantiation'''
TelnetHandlerBase.setup(self)
# Spawn a thread to handle socket input
self.thread_ic = threading.Thread(target=self.inputcooker)
self.thread_ic.setDaemon(True)
self.thread_ic.start()
# Note that inputcooker exits o... | [
"Called",
"after",
"instantiation"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/threaded.py#L23-L33 | [
"def",
"setup",
"(",
"self",
")",
":",
"TelnetHandlerBase",
".",
"setup",
"(",
"self",
")",
"# Spawn a thread to handle socket input",
"self",
".",
"thread_ic",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"inputcooker",
")",
"self",
".",
... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandler.getc | Return one character from the input queue | telnetsrv/threaded.py | def getc(self, block=True):
"""Return one character from the input queue"""
if not block:
if not len(self.cookedq):
return ''
while not len(self.cookedq):
time.sleep(0.05)
self.IQUEUELOCK.acquire()
ret = self.cookedq[0]
self.cookedq... | def getc(self, block=True):
"""Return one character from the input queue"""
if not block:
if not len(self.cookedq):
return ''
while not len(self.cookedq):
time.sleep(0.05)
self.IQUEUELOCK.acquire()
ret = self.cookedq[0]
self.cookedq... | [
"Return",
"one",
"character",
"from",
"the",
"input",
"queue"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/threaded.py#L44-L55 | [
"def",
"getc",
"(",
"self",
",",
"block",
"=",
"True",
")",
":",
"if",
"not",
"block",
":",
"if",
"not",
"len",
"(",
"self",
".",
"cookedq",
")",
":",
"return",
"''",
"while",
"not",
"len",
"(",
"self",
".",
"cookedq",
")",
":",
"time",
".",
"s... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandler.inputcooker_store_queue | Put the cooked data in the input queue (with locking) | telnetsrv/threaded.py | def inputcooker_store_queue(self, char):
"""Put the cooked data in the input queue (with locking)"""
self.IQUEUELOCK.acquire()
if type(char) in [type(()), type([]), type("")]:
for v in char:
self.cookedq.append(v)
else:
self.cookedq.append(char)
... | def inputcooker_store_queue(self, char):
"""Put the cooked data in the input queue (with locking)"""
self.IQUEUELOCK.acquire()
if type(char) in [type(()), type([]), type("")]:
for v in char:
self.cookedq.append(v)
else:
self.cookedq.append(char)
... | [
"Put",
"the",
"cooked",
"data",
"in",
"the",
"input",
"queue",
"(",
"with",
"locking",
")"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/threaded.py#L61-L69 | [
"def",
"inputcooker_store_queue",
"(",
"self",
",",
"char",
")",
":",
"self",
".",
"IQUEUELOCK",
".",
"acquire",
"(",
")",
"if",
"type",
"(",
"char",
")",
"in",
"[",
"type",
"(",
"(",
")",
")",
",",
"type",
"(",
"[",
"]",
")",
",",
"type",
"(",
... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandler.writemessage | Put data in output queue, rebuild the prompt and entered data | telnetsrv/threaded.py | def writemessage(self, text):
"""Put data in output queue, rebuild the prompt and entered data"""
# Need to grab the input queue lock to ensure the entered data doesn't change
# before we're done rebuilding it.
# Note that writemessage will eventually call writecooked
self.IQUEUE... | def writemessage(self, text):
"""Put data in output queue, rebuild the prompt and entered data"""
# Need to grab the input queue lock to ensure the entered data doesn't change
# before we're done rebuilding it.
# Note that writemessage will eventually call writecooked
self.IQUEUE... | [
"Put",
"data",
"in",
"output",
"queue",
"rebuild",
"the",
"prompt",
"and",
"entered",
"data"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/threaded.py#L74-L81 | [
"def",
"writemessage",
"(",
"self",
",",
"text",
")",
":",
"# Need to grab the input queue lock to ensure the entered data doesn't change",
"# before we're done rebuilding it.",
"# Note that writemessage will eventually call writecooked",
"self",
".",
"IQUEUELOCK",
".",
"acquire",
"(... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandler.writecooked | Put data directly into the output queue | telnetsrv/threaded.py | def writecooked(self, text):
"""Put data directly into the output queue"""
# Ensure this is the only thread writing
self.OQUEUELOCK.acquire()
TelnetHandlerBase.writecooked(self, text)
self.OQUEUELOCK.release() | def writecooked(self, text):
"""Put data directly into the output queue"""
# Ensure this is the only thread writing
self.OQUEUELOCK.acquire()
TelnetHandlerBase.writecooked(self, text)
self.OQUEUELOCK.release() | [
"Put",
"data",
"directly",
"into",
"the",
"output",
"queue"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/threaded.py#L83-L88 | [
"def",
"writecooked",
"(",
"self",
",",
"text",
")",
":",
"# Ensure this is the only thread writing",
"self",
".",
"OQUEUELOCK",
".",
"acquire",
"(",
")",
"TelnetHandlerBase",
".",
"writecooked",
"(",
"self",
",",
"text",
")",
"self",
".",
"OQUEUELOCK",
".",
"... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | split_certificate | Splits a PKCS12 certificate into Base64-encoded DER certificate and key.
This method splits a potentially password-protected
`PKCS12 <https://en.wikipedia.org/wiki/PKCS_12>`_ certificate
(format ``.p12`` or ``.pfx``) into one certificate and one key part, both in
`pem <https://en.wikipedia.org/wiki/X.5... | bankid/certutils.py | def split_certificate(certificate_path, destination_folder, password=None):
"""Splits a PKCS12 certificate into Base64-encoded DER certificate and key.
This method splits a potentially password-protected
`PKCS12 <https://en.wikipedia.org/wiki/PKCS_12>`_ certificate
(format ``.p12`` or ``.pfx``) into on... | def split_certificate(certificate_path, destination_folder, password=None):
"""Splits a PKCS12 certificate into Base64-encoded DER certificate and key.
This method splits a potentially password-protected
`PKCS12 <https://en.wikipedia.org/wiki/PKCS_12>`_ certificate
(format ``.p12`` or ``.pfx``) into on... | [
"Splits",
"a",
"PKCS12",
"certificate",
"into",
"Base64",
"-",
"encoded",
"DER",
"certificate",
"and",
"key",
"."
] | hbldh/pybankid | python | https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/certutils.py#L62-L152 | [
"def",
"split_certificate",
"(",
"certificate_path",
",",
"destination_folder",
",",
"password",
"=",
"None",
")",
":",
"try",
":",
"# Attempt Linux and Darwin call first.",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"\"openssl\"",
",",
"\"version\"",
"]",
",... | 1405f66e41f912cdda15e20aea08cdfa6b60480a |
train | InputBashLike.process_delimiter | Process chars while not in a part | telnetsrv/telnetsrvlib.py | def process_delimiter(self, char):
'''Process chars while not in a part'''
if char in self.whitespace:
return
if char in self.quote_chars:
# Store the quote type (' or ") and switch to quote processing.
self.inquote = char
self.process_char = self.... | def process_delimiter(self, char):
'''Process chars while not in a part'''
if char in self.whitespace:
return
if char in self.quote_chars:
# Store the quote type (' or ") and switch to quote processing.
self.inquote = char
self.process_char = self.... | [
"Process",
"chars",
"while",
"not",
"in",
"a",
"part"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L287-L301 | [
"def",
"process_delimiter",
"(",
"self",
",",
"char",
")",
":",
"if",
"char",
"in",
"self",
".",
"whitespace",
":",
"return",
"if",
"char",
"in",
"self",
".",
"quote_chars",
":",
"# Store the quote type (' or \") and switch to quote processing.",
"self",
".",
"inq... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | InputBashLike.process_part | Process chars while in a part | telnetsrv/telnetsrvlib.py | def process_part(self, char):
'''Process chars while in a part'''
if char in self.whitespace or char == self.eol_char:
# End of the part.
self.parts.append( ''.join(self.part) )
self.part = []
# Switch back to processing a delimiter.
self.proce... | def process_part(self, char):
'''Process chars while in a part'''
if char in self.whitespace or char == self.eol_char:
# End of the part.
self.parts.append( ''.join(self.part) )
self.part = []
# Switch back to processing a delimiter.
self.proce... | [
"Process",
"chars",
"while",
"in",
"a",
"part"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L303-L319 | [
"def",
"process_part",
"(",
"self",
",",
"char",
")",
":",
"if",
"char",
"in",
"self",
".",
"whitespace",
"or",
"char",
"==",
"self",
".",
"eol_char",
":",
"# End of the part.",
"self",
".",
"parts",
".",
"append",
"(",
"''",
".",
"join",
"(",
"self",
... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | InputBashLike.process_quote | Process character while in a quote | telnetsrv/telnetsrvlib.py | def process_quote(self, char):
'''Process character while in a quote'''
if char == self.inquote:
# Quote is finished, switch to part processing.
self.process_char = self.process_part
return
try:
self.part.append(char)
except:
se... | def process_quote(self, char):
'''Process character while in a quote'''
if char == self.inquote:
# Quote is finished, switch to part processing.
self.process_char = self.process_part
return
try:
self.part.append(char)
except:
se... | [
"Process",
"character",
"while",
"in",
"a",
"quote"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L321-L330 | [
"def",
"process_quote",
"(",
"self",
",",
"char",
")",
":",
"if",
"char",
"==",
"self",
".",
"inquote",
":",
"# Quote is finished, switch to part processing.",
"self",
".",
"process_char",
"=",
"self",
".",
"process_part",
"return",
"try",
":",
"self",
".",
"p... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | InputBashLike.process_escape | Handle the char after the escape char | telnetsrv/telnetsrvlib.py | def process_escape(self, char):
'''Handle the char after the escape char'''
# Always only run once, switch back to the last processor.
self.process_char = self.last_process_char
if self.part == [] and char in self.whitespace:
# Special case where \ is by itself and not at the... | def process_escape(self, char):
'''Handle the char after the escape char'''
# Always only run once, switch back to the last processor.
self.process_char = self.last_process_char
if self.part == [] and char in self.whitespace:
# Special case where \ is by itself and not at the... | [
"Handle",
"the",
"char",
"after",
"the",
"escape",
"char"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L332-L344 | [
"def",
"process_escape",
"(",
"self",
",",
"char",
")",
":",
"# Always only run once, switch back to the last processor.",
"self",
".",
"process_char",
"=",
"self",
".",
"last_process_char",
"if",
"self",
".",
"part",
"==",
"[",
"]",
"and",
"char",
"in",
"self",
... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | InputBashLike.process | Step through the line and process each character | telnetsrv/telnetsrvlib.py | def process(self, line):
'''Step through the line and process each character'''
self.raw = self.raw + line
try:
if not line[-1] == self.eol_char:
# Should always be here, but add it just in case.
line = line + self.eol_char
except IndexError:
... | def process(self, line):
'''Step through the line and process each character'''
self.raw = self.raw + line
try:
if not line[-1] == self.eol_char:
# Should always be here, but add it just in case.
line = line + self.eol_char
except IndexError:
... | [
"Step",
"through",
"the",
"line",
"and",
"process",
"each",
"character"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L347-L367 | [
"def",
"process",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"raw",
"=",
"self",
".",
"raw",
"+",
"line",
"try",
":",
"if",
"not",
"line",
"[",
"-",
"1",
"]",
"==",
"self",
".",
"eol_char",
":",
"# Should always be here, but add it just in case.",
... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.streamserver_handle | Translate this class for use in a StreamServer | telnetsrv/telnetsrvlib.py | def streamserver_handle(cls, sock, address):
'''Translate this class for use in a StreamServer'''
request = cls.false_request()
request._sock = sock
server = None
log.debug("Accepted connection, starting telnet session.")
try:
cls(request, address, server)
... | def streamserver_handle(cls, sock, address):
'''Translate this class for use in a StreamServer'''
request = cls.false_request()
request._sock = sock
server = None
log.debug("Accepted connection, starting telnet session.")
try:
cls(request, address, server)
... | [
"Translate",
"this",
"class",
"for",
"use",
"in",
"a",
"StreamServer"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L491-L500 | [
"def",
"streamserver_handle",
"(",
"cls",
",",
"sock",
",",
"address",
")",
":",
"request",
"=",
"cls",
".",
"false_request",
"(",
")",
"request",
".",
"_sock",
"=",
"sock",
"server",
"=",
"None",
"log",
".",
"debug",
"(",
"\"Accepted connection, starting te... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.setterm | Set the curses structures for this terminal | telnetsrv/telnetsrvlib.py | def setterm(self, term):
"Set the curses structures for this terminal"
log.debug("Setting termtype to %s" % (term, ))
curses.setupterm(term) # This will raise if the termtype is not supported
self.TERM = term
self.ESCSEQ = {}
for k in self.KEYS.keys():
str = c... | def setterm(self, term):
"Set the curses structures for this terminal"
log.debug("Setting termtype to %s" % (term, ))
curses.setupterm(term) # This will raise if the termtype is not supported
self.TERM = term
self.ESCSEQ = {}
for k in self.KEYS.keys():
str = c... | [
"Set",
"the",
"curses",
"structures",
"for",
"this",
"terminal"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L502-L518 | [
"def",
"setterm",
"(",
"self",
",",
"term",
")",
":",
"log",
".",
"debug",
"(",
"\"Setting termtype to %s\"",
"%",
"(",
"term",
",",
")",
")",
"curses",
".",
"setupterm",
"(",
"term",
")",
"# This will raise if the termtype is not supported",
"self",
".",
"TER... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.setup | Connect incoming connection to a telnet session | telnetsrv/telnetsrvlib.py | def setup(self):
"Connect incoming connection to a telnet session"
try:
self.TERM = self.request.term
except:
pass
self.setterm(self.TERM)
self.sock = self.request._sock
for k in self.DOACK.keys():
self.sendcommand(self.DOACK[k], k)
... | def setup(self):
"Connect incoming connection to a telnet session"
try:
self.TERM = self.request.term
except:
pass
self.setterm(self.TERM)
self.sock = self.request._sock
for k in self.DOACK.keys():
self.sendcommand(self.DOACK[k], k)
... | [
"Connect",
"incoming",
"connection",
"to",
"a",
"telnet",
"session"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L520-L531 | [
"def",
"setup",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"TERM",
"=",
"self",
".",
"request",
".",
"term",
"except",
":",
"pass",
"self",
".",
"setterm",
"(",
"self",
".",
"TERM",
")",
"self",
".",
"sock",
"=",
"self",
".",
"request",
".",... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.finish | End this session | telnetsrv/telnetsrvlib.py | def finish(self):
"End this session"
log.debug("Session disconnected.")
try:
self.sock.shutdown(socket.SHUT_RDWR)
except: pass
self.session_end() | def finish(self):
"End this session"
log.debug("Session disconnected.")
try:
self.sock.shutdown(socket.SHUT_RDWR)
except: pass
self.session_end() | [
"End",
"this",
"session"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L534-L540 | [
"def",
"finish",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"\"Session disconnected.\"",
")",
"try",
":",
"self",
".",
"sock",
".",
"shutdown",
"(",
"socket",
".",
"SHUT_RDWR",
")",
"except",
":",
"pass",
"self",
".",
"session_end",
"(",
")"
] | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.options_handler | Negotiate options | telnetsrv/telnetsrvlib.py | def options_handler(self, sock, cmd, opt):
"Negotiate options"
if cmd == NOP:
self.sendcommand(NOP)
elif cmd == WILL or cmd == WONT:
if self.WILLACK.has_key(opt):
self.sendcommand(self.WILLACK[opt], opt)
else:
self.sendcommand(D... | def options_handler(self, sock, cmd, opt):
"Negotiate options"
if cmd == NOP:
self.sendcommand(NOP)
elif cmd == WILL or cmd == WONT:
if self.WILLACK.has_key(opt):
self.sendcommand(self.WILLACK[opt], opt)
else:
self.sendcommand(D... | [
"Negotiate",
"options"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L550-L580 | [
"def",
"options_handler",
"(",
"self",
",",
"sock",
",",
"cmd",
",",
"opt",
")",
":",
"if",
"cmd",
"==",
"NOP",
":",
"self",
".",
"sendcommand",
"(",
"NOP",
")",
"elif",
"cmd",
"==",
"WILL",
"or",
"cmd",
"==",
"WONT",
":",
"if",
"self",
".",
"WIL... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.sendcommand | Send a telnet command (IAC) | telnetsrv/telnetsrvlib.py | def sendcommand(self, cmd, opt=None):
"Send a telnet command (IAC)"
if cmd in [DO, DONT]:
if not self.DOOPTS.has_key(opt):
self.DOOPTS[opt] = None
if (((cmd == DO) and (self.DOOPTS[opt] != True))
or ((cmd == DONT) and (self.DOOPTS[opt] != False))):
... | def sendcommand(self, cmd, opt=None):
"Send a telnet command (IAC)"
if cmd in [DO, DONT]:
if not self.DOOPTS.has_key(opt):
self.DOOPTS[opt] = None
if (((cmd == DO) and (self.DOOPTS[opt] != True))
or ((cmd == DONT) and (self.DOOPTS[opt] != False))):
... | [
"Send",
"a",
"telnet",
"command",
"(",
"IAC",
")"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L582-L599 | [
"def",
"sendcommand",
"(",
"self",
",",
"cmd",
",",
"opt",
"=",
"None",
")",
":",
"if",
"cmd",
"in",
"[",
"DO",
",",
"DONT",
"]",
":",
"if",
"not",
"self",
".",
"DOOPTS",
".",
"has_key",
"(",
"opt",
")",
":",
"self",
".",
"DOOPTS",
"[",
"opt",
... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase._readline_echo | Echo a recieved character, move cursor etc... | telnetsrv/telnetsrvlib.py | def _readline_echo(self, char, echo):
"""Echo a recieved character, move cursor etc..."""
if self._readline_do_echo(echo):
self.write(char) | def _readline_echo(self, char, echo):
"""Echo a recieved character, move cursor etc..."""
if self._readline_do_echo(echo):
self.write(char) | [
"Echo",
"a",
"recieved",
"character",
"move",
"cursor",
"etc",
"..."
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L619-L622 | [
"def",
"_readline_echo",
"(",
"self",
",",
"char",
",",
"echo",
")",
":",
"if",
"self",
".",
"_readline_do_echo",
"(",
"echo",
")",
":",
"self",
".",
"write",
"(",
"char",
")"
] | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase._readline_insert | Deal properly with inserted chars in a line. | telnetsrv/telnetsrvlib.py | def _readline_insert(self, char, echo, insptr, line):
"""Deal properly with inserted chars in a line."""
if not self._readline_do_echo(echo):
return
# Write out the remainder of the line
self.write(char + ''.join(line[insptr:]))
# Cursor Left to the current insert poi... | def _readline_insert(self, char, echo, insptr, line):
"""Deal properly with inserted chars in a line."""
if not self._readline_do_echo(echo):
return
# Write out the remainder of the line
self.write(char + ''.join(line[insptr:]))
# Cursor Left to the current insert poi... | [
"Deal",
"properly",
"with",
"inserted",
"chars",
"in",
"a",
"line",
"."
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L624-L632 | [
"def",
"_readline_insert",
"(",
"self",
",",
"char",
",",
"echo",
",",
"insptr",
",",
"line",
")",
":",
"if",
"not",
"self",
".",
"_readline_do_echo",
"(",
"echo",
")",
":",
"return",
"# Write out the remainder of the line",
"self",
".",
"write",
"(",
"char"... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.ansi_to_curses | Handles reading ANSI escape sequences | telnetsrv/telnetsrvlib.py | def ansi_to_curses(self, char):
'''Handles reading ANSI escape sequences'''
# ANSI sequences are:
# ESC [ <key>
# If we see ESC, read a char
if char != ESC:
return char
# If we see [, read another char
if self.getc(block=True) != ANSI_START_SEQ:
... | def ansi_to_curses(self, char):
'''Handles reading ANSI escape sequences'''
# ANSI sequences are:
# ESC [ <key>
# If we see ESC, read a char
if char != ESC:
return char
# If we see [, read another char
if self.getc(block=True) != ANSI_START_SEQ:
... | [
"Handles",
"reading",
"ANSI",
"escape",
"sequences"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L637-L654 | [
"def",
"ansi_to_curses",
"(",
"self",
",",
"char",
")",
":",
"# ANSI sequences are:",
"# ESC [ <key>",
"# If we see ESC, read a char",
"if",
"char",
"!=",
"ESC",
":",
"return",
"char",
"# If we see [, read another char",
"if",
"self",
".",
"getc",
"(",
"block",
"=",... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.readline | Return a line of text, including the terminating LF
If echo is true always echo, if echo is false never echo
If echo is None follow the negotiated setting.
prompt is the current prompt to write (and rewrite if needed)
use_history controls if this current line uses (and adds t... | telnetsrv/telnetsrvlib.py | def readline(self, echo=None, prompt='', use_history=True):
"""Return a line of text, including the terminating LF
If echo is true always echo, if echo is false never echo
If echo is None follow the negotiated setting.
prompt is the current prompt to write (and rewrite if needed... | def readline(self, echo=None, prompt='', use_history=True):
"""Return a line of text, including the terminating LF
If echo is true always echo, if echo is false never echo
If echo is None follow the negotiated setting.
prompt is the current prompt to write (and rewrite if needed... | [
"Return",
"a",
"line",
"of",
"text",
"including",
"the",
"terminating",
"LF",
"If",
"echo",
"is",
"true",
"always",
"echo",
"if",
"echo",
"is",
"false",
"never",
"echo",
"If",
"echo",
"is",
"None",
"follow",
"the",
"negotiated",
"setting",
".",
"prompt",
... | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L656-L768 | [
"def",
"readline",
"(",
"self",
",",
"echo",
"=",
"None",
",",
"prompt",
"=",
"''",
",",
"use_history",
"=",
"True",
")",
":",
"line",
"=",
"[",
"]",
"insptr",
"=",
"0",
"ansi",
"=",
"0",
"histptr",
"=",
"len",
"(",
"self",
".",
"history",
")",
... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.writeline | Send a packet with line ending. | telnetsrv/telnetsrvlib.py | def writeline(self, text):
"""Send a packet with line ending."""
log.debug('writing line %r' % text)
self.write(text+chr(10)) | def writeline(self, text):
"""Send a packet with line ending."""
log.debug('writing line %r' % text)
self.write(text+chr(10)) | [
"Send",
"a",
"packet",
"with",
"line",
"ending",
"."
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L786-L789 | [
"def",
"writeline",
"(",
"self",
",",
"text",
")",
":",
"log",
".",
"debug",
"(",
"'writing line %r'",
"%",
"text",
")",
"self",
".",
"write",
"(",
"text",
"+",
"chr",
"(",
"10",
")",
")"
] | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.writemessage | Write out an asynchronous message, then reconstruct the prompt and entered text. | telnetsrv/telnetsrvlib.py | def writemessage(self, text):
"""Write out an asynchronous message, then reconstruct the prompt and entered text."""
log.debug('writing message %r', text)
self.write(chr(10)+text+chr(10))
self.write(self._current_prompt+''.join(self._current_line)) | def writemessage(self, text):
"""Write out an asynchronous message, then reconstruct the prompt and entered text."""
log.debug('writing message %r', text)
self.write(chr(10)+text+chr(10))
self.write(self._current_prompt+''.join(self._current_line)) | [
"Write",
"out",
"an",
"asynchronous",
"message",
"then",
"reconstruct",
"the",
"prompt",
"and",
"entered",
"text",
"."
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L791-L795 | [
"def",
"writemessage",
"(",
"self",
",",
"text",
")",
":",
"log",
".",
"debug",
"(",
"'writing message %r'",
",",
"text",
")",
"self",
".",
"write",
"(",
"chr",
"(",
"10",
")",
"+",
"text",
"+",
"chr",
"(",
"10",
")",
")",
"self",
".",
"write",
"... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.write | Send a packet to the socket. This function cooks output. | telnetsrv/telnetsrvlib.py | def write(self, text):
"""Send a packet to the socket. This function cooks output."""
text = str(text) # eliminate any unicode or other snigglets
text = text.replace(IAC, IAC+IAC)
text = text.replace(chr(10), chr(13)+chr(10))
self.writecooked(text) | def write(self, text):
"""Send a packet to the socket. This function cooks output."""
text = str(text) # eliminate any unicode or other snigglets
text = text.replace(IAC, IAC+IAC)
text = text.replace(chr(10), chr(13)+chr(10))
self.writecooked(text) | [
"Send",
"a",
"packet",
"to",
"the",
"socket",
".",
"This",
"function",
"cooks",
"output",
"."
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L797-L802 | [
"def",
"write",
"(",
"self",
",",
"text",
")",
":",
"text",
"=",
"str",
"(",
"text",
")",
"# eliminate any unicode or other snigglets",
"text",
"=",
"text",
".",
"replace",
"(",
"IAC",
",",
"IAC",
"+",
"IAC",
")",
"text",
"=",
"text",
".",
"replace",
"... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase._inputcooker_getc | Get one character from the raw queue. Optionally blocking.
Raise EOFError on end of stream. SHOULD ONLY BE CALLED FROM THE
INPUT COOKER. | telnetsrv/telnetsrvlib.py | def _inputcooker_getc(self, block=True):
"""Get one character from the raw queue. Optionally blocking.
Raise EOFError on end of stream. SHOULD ONLY BE CALLED FROM THE
INPUT COOKER."""
if self.rawq:
ret = self.rawq[0]
self.rawq = self.rawq[1:]
return re... | def _inputcooker_getc(self, block=True):
"""Get one character from the raw queue. Optionally blocking.
Raise EOFError on end of stream. SHOULD ONLY BE CALLED FROM THE
INPUT COOKER."""
if self.rawq:
ret = self.rawq[0]
self.rawq = self.rawq[1:]
return re... | [
"Get",
"one",
"character",
"from",
"the",
"raw",
"queue",
".",
"Optionally",
"blocking",
".",
"Raise",
"EOFError",
"on",
"end",
"of",
"stream",
".",
"SHOULD",
"ONLY",
"BE",
"CALLED",
"FROM",
"THE",
"INPUT",
"COOKER",
"."
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L809-L825 | [
"def",
"_inputcooker_getc",
"(",
"self",
",",
"block",
"=",
"True",
")",
":",
"if",
"self",
".",
"rawq",
":",
"ret",
"=",
"self",
".",
"rawq",
"[",
"0",
"]",
"self",
".",
"rawq",
"=",
"self",
".",
"rawq",
"[",
"1",
":",
"]",
"return",
"ret",
"i... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase._inputcooker_store | Put the cooked data in the correct queue | telnetsrv/telnetsrvlib.py | def _inputcooker_store(self, char):
"""Put the cooked data in the correct queue"""
if self.sb:
self.sbdataq = self.sbdataq + char
else:
self.inputcooker_store_queue(char) | def _inputcooker_store(self, char):
"""Put the cooked data in the correct queue"""
if self.sb:
self.sbdataq = self.sbdataq + char
else:
self.inputcooker_store_queue(char) | [
"Put",
"the",
"cooked",
"data",
"in",
"the",
"correct",
"queue"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L839-L844 | [
"def",
"_inputcooker_store",
"(",
"self",
",",
"char",
")",
":",
"if",
"self",
".",
"sb",
":",
"self",
".",
"sbdataq",
"=",
"self",
".",
"sbdataq",
"+",
"char",
"else",
":",
"self",
".",
"inputcooker_store_queue",
"(",
"char",
")"
] | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.inputcooker | Input Cooker - Transfer from raw queue to cooked queue.
Set self.eof when connection is closed. Don't block unless in
the midst of an IAC sequence. | telnetsrv/telnetsrvlib.py | def inputcooker(self):
"""Input Cooker - Transfer from raw queue to cooked queue.
Set self.eof when connection is closed. Don't block unless in
the midst of an IAC sequence.
"""
try:
while True:
c = self._inputcooker_getc()
if not sel... | def inputcooker(self):
"""Input Cooker - Transfer from raw queue to cooked queue.
Set self.eof when connection is closed. Don't block unless in
the midst of an IAC sequence.
"""
try:
while True:
c = self._inputcooker_getc()
if not sel... | [
"Input",
"Cooker",
"-",
"Transfer",
"from",
"raw",
"queue",
"to",
"cooked",
"queue",
"."
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L851-L912 | [
"def",
"inputcooker",
"(",
"self",
")",
":",
"try",
":",
"while",
"True",
":",
"c",
"=",
"self",
".",
"_inputcooker_getc",
"(",
")",
"if",
"not",
"self",
".",
"iacseq",
":",
"if",
"c",
"==",
"IAC",
":",
"self",
".",
"iacseq",
"+=",
"c",
"continue",... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.cmdHELP | [<command>]
Display help
Display either brief help on all commands, or detailed
help on a single command passed as a parameter. | telnetsrv/telnetsrvlib.py | def cmdHELP(self, params):
"""[<command>]
Display help
Display either brief help on all commands, or detailed
help on a single command passed as a parameter.
"""
if params:
cmd = params[0].upper()
if self.COMMANDS.has_key(cmd):
meth... | def cmdHELP(self, params):
"""[<command>]
Display help
Display either brief help on all commands, or detailed
help on a single command passed as a parameter.
"""
if params:
cmd = params[0].upper()
if self.COMMANDS.has_key(cmd):
meth... | [
"[",
"<command",
">",
"]",
"Display",
"help",
"Display",
"either",
"brief",
"help",
"on",
"all",
"commands",
"or",
"detailed",
"help",
"on",
"a",
"single",
"command",
"passed",
"as",
"a",
"parameter",
"."
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L921-L969 | [
"def",
"cmdHELP",
"(",
"self",
",",
"params",
")",
":",
"if",
"params",
":",
"cmd",
"=",
"params",
"[",
"0",
"]",
".",
"upper",
"(",
")",
"if",
"self",
".",
"COMMANDS",
".",
"has_key",
"(",
"cmd",
")",
":",
"method",
"=",
"self",
".",
"COMMANDS",... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.cmdHISTORY | Display the command history | telnetsrv/telnetsrvlib.py | def cmdHISTORY(self, params):
"""
Display the command history
"""
cnt = 0
self.writeline('Command history\n')
for line in self.history:
cnt = cnt + 1
self.writeline("%-5d : %s" % (cnt, ''.join(line))) | def cmdHISTORY(self, params):
"""
Display the command history
"""
cnt = 0
self.writeline('Command history\n')
for line in self.history:
cnt = cnt + 1
self.writeline("%-5d : %s" % (cnt, ''.join(line))) | [
"Display",
"the",
"command",
"history"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L980-L988 | [
"def",
"cmdHISTORY",
"(",
"self",
",",
"params",
")",
":",
"cnt",
"=",
"0",
"self",
".",
"writeline",
"(",
"'Command history\\n'",
")",
"for",
"line",
"in",
"self",
".",
"history",
":",
"cnt",
"=",
"cnt",
"+",
"1",
"self",
".",
"writeline",
"(",
"\"%... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.handleException | Exception handler (False to abort) | telnetsrv/telnetsrvlib.py | def handleException(self, exc_type, exc_param, exc_tb):
"Exception handler (False to abort)"
self.writeline(''.join( traceback.format_exception(exc_type, exc_param, exc_tb) ))
return True | def handleException(self, exc_type, exc_param, exc_tb):
"Exception handler (False to abort)"
self.writeline(''.join( traceback.format_exception(exc_type, exc_param, exc_tb) ))
return True | [
"Exception",
"handler",
"(",
"False",
"to",
"abort",
")"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L992-L995 | [
"def",
"handleException",
"(",
"self",
",",
"exc_type",
",",
"exc_param",
",",
"exc_tb",
")",
":",
"self",
".",
"writeline",
"(",
"''",
".",
"join",
"(",
"traceback",
".",
"format_exception",
"(",
"exc_type",
",",
"exc_param",
",",
"exc_tb",
")",
")",
")... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.authentication_ok | Checks the authentication and sets the username of the currently connected terminal. Returns True or False | telnetsrv/telnetsrvlib.py | def authentication_ok(self):
'''Checks the authentication and sets the username of the currently connected terminal. Returns True or False'''
username = None
password = None
if self.authCallback:
if self.authNeedUser:
username = self.readline(prompt=self.PROM... | def authentication_ok(self):
'''Checks the authentication and sets the username of the currently connected terminal. Returns True or False'''
username = None
password = None
if self.authCallback:
if self.authNeedUser:
username = self.readline(prompt=self.PROM... | [
"Checks",
"the",
"authentication",
"and",
"sets",
"the",
"username",
"of",
"the",
"currently",
"connected",
"terminal",
".",
"Returns",
"True",
"or",
"False"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L997-L1020 | [
"def",
"authentication_ok",
"(",
"self",
")",
":",
"username",
"=",
"None",
"password",
"=",
"None",
"if",
"self",
".",
"authCallback",
":",
"if",
"self",
".",
"authNeedUser",
":",
"username",
"=",
"self",
".",
"readline",
"(",
"prompt",
"=",
"self",
"."... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandlerBase.handle | The actual service to which the user has connected. | telnetsrv/telnetsrvlib.py | def handle(self):
"The actual service to which the user has connected."
if self.TELNET_ISSUE:
self.writeline(self.TELNET_ISSUE)
if not self.authentication_ok():
return
if self.DOECHO:
self.writeline(self.WELCOME)
self.session_start()
w... | def handle(self):
"The actual service to which the user has connected."
if self.TELNET_ISSUE:
self.writeline(self.TELNET_ISSUE)
if not self.authentication_ok():
return
if self.DOECHO:
self.writeline(self.WELCOME)
self.session_start()
w... | [
"The",
"actual",
"service",
"to",
"which",
"the",
"user",
"has",
"connected",
"."
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/telnetsrvlib.py#L1023-L1050 | [
"def",
"handle",
"(",
"self",
")",
":",
"if",
"self",
".",
"TELNET_ISSUE",
":",
"self",
".",
"writeline",
"(",
"self",
".",
"TELNET_ISSUE",
")",
"if",
"not",
"self",
".",
"authentication_ok",
"(",
")",
":",
"return",
"if",
"self",
".",
"DOECHO",
":",
... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandler.setup | Called after instantiation | telnetsrv/green.py | def setup(self):
'''Called after instantiation'''
TelnetHandlerBase.setup(self)
# Spawn a greenlet to handle socket input
self.greenlet_ic = gevent.spawn(self.inputcooker)
# Note that inputcooker exits on EOF
# Sleep for 0.5 second to allow options negotiation
... | def setup(self):
'''Called after instantiation'''
TelnetHandlerBase.setup(self)
# Spawn a greenlet to handle socket input
self.greenlet_ic = gevent.spawn(self.inputcooker)
# Note that inputcooker exits on EOF
# Sleep for 0.5 second to allow options negotiation
... | [
"Called",
"after",
"instantiation"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/green.py#L16-L24 | [
"def",
"setup",
"(",
"self",
")",
":",
"TelnetHandlerBase",
".",
"setup",
"(",
"self",
")",
"# Spawn a greenlet to handle socket input",
"self",
".",
"greenlet_ic",
"=",
"gevent",
".",
"spawn",
"(",
"self",
".",
"inputcooker",
")",
"# Note that inputcooker exits on ... | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | TelnetHandler.getc | Return one character from the input queue | telnetsrv/green.py | def getc(self, block=True):
"""Return one character from the input queue"""
try:
return self.cookedq.get(block)
except gevent.queue.Empty:
return '' | def getc(self, block=True):
"""Return one character from the input queue"""
try:
return self.cookedq.get(block)
except gevent.queue.Empty:
return '' | [
"Return",
"one",
"character",
"from",
"the",
"input",
"queue"
] | ianepperson/telnetsrvlib | python | https://github.com/ianepperson/telnetsrvlib/blob/fac52a4a333c2d373d53d295a76a0bbd71e5d682/telnetsrv/green.py#L35-L40 | [
"def",
"getc",
"(",
"self",
",",
"block",
"=",
"True",
")",
":",
"try",
":",
"return",
"self",
".",
"cookedq",
".",
"get",
"(",
"block",
")",
"except",
"gevent",
".",
"queue",
".",
"Empty",
":",
"return",
"''"
] | fac52a4a333c2d373d53d295a76a0bbd71e5d682 |
train | BankIDClient.authenticate | Request an authentication order. The :py:meth:`collect` method
is used to query the status of the order.
:param personal_number: The Swedish personal number
in format YYYYMMDDXXXX.
:type personal_number: str
:return: The OrderResponse parsed to a dictionary.
:rtype: ... | bankid/client.py | def authenticate(self, personal_number, **kwargs):
"""Request an authentication order. The :py:meth:`collect` method
is used to query the status of the order.
:param personal_number: The Swedish personal number
in format YYYYMMDDXXXX.
:type personal_number: str
:retu... | def authenticate(self, personal_number, **kwargs):
"""Request an authentication order. The :py:meth:`collect` method
is used to query the status of the order.
:param personal_number: The Swedish personal number
in format YYYYMMDDXXXX.
:type personal_number: str
:retu... | [
"Request",
"an",
"authentication",
"order",
".",
"The",
":",
"py",
":",
"meth",
":",
"collect",
"method",
"is",
"used",
"to",
"query",
"the",
"status",
"of",
"the",
"order",
"."
] | hbldh/pybankid | python | https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/client.py#L84-L109 | [
"def",
"authenticate",
"(",
"self",
",",
"personal_number",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"\"requirementAlternatives\"",
"in",
"kwargs",
":",
"warnings",
".",
"warn",
"(",
"\"Requirement Alternatives \"",
"\"option is not tested.\"",
",",
"BankIDWarning",
... | 1405f66e41f912cdda15e20aea08cdfa6b60480a |
train | BankIDClient.sign | Request an signing order. The :py:meth:`collect` method
is used to query the status of the order.
:param user_visible_data: The information that the end user is
requested to sign.
:type user_visible_data: str
:param personal_number: The Swedish personal number in
... | bankid/client.py | def sign(self, user_visible_data, personal_number=None, **kwargs):
"""Request an signing order. The :py:meth:`collect` method
is used to query the status of the order.
:param user_visible_data: The information that the end user is
requested to sign.
:type user_visible_data: ... | def sign(self, user_visible_data, personal_number=None, **kwargs):
"""Request an signing order. The :py:meth:`collect` method
is used to query the status of the order.
:param user_visible_data: The information that the end user is
requested to sign.
:type user_visible_data: ... | [
"Request",
"an",
"signing",
"order",
".",
"The",
":",
"py",
":",
"meth",
":",
"collect",
"method",
"is",
"used",
"to",
"query",
"the",
"status",
"of",
"the",
"order",
"."
] | hbldh/pybankid | python | https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/client.py#L111-L144 | [
"def",
"sign",
"(",
"self",
",",
"user_visible_data",
",",
"personal_number",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"\"requirementAlternatives\"",
"in",
"kwargs",
":",
"warnings",
".",
"warn",
"(",
"\"Requirement Alternatives option is not tested.\""... | 1405f66e41f912cdda15e20aea08cdfa6b60480a |
train | BankIDClient.collect | Collect the progress status of the order with the specified
order reference.
:param order_ref: The UUID string specifying which order to
collect status from.
:type order_ref: str
:return: The CollectResponse parsed to a dictionary.
:rtype: dict
:raises BankID... | bankid/client.py | def collect(self, order_ref):
"""Collect the progress status of the order with the specified
order reference.
:param order_ref: The UUID string specifying which order to
collect status from.
:type order_ref: str
:return: The CollectResponse parsed to a dictionary.
... | def collect(self, order_ref):
"""Collect the progress status of the order with the specified
order reference.
:param order_ref: The UUID string specifying which order to
collect status from.
:type order_ref: str
:return: The CollectResponse parsed to a dictionary.
... | [
"Collect",
"the",
"progress",
"status",
"of",
"the",
"order",
"with",
"the",
"specified",
"order",
"reference",
"."
] | hbldh/pybankid | python | https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/client.py#L146-L164 | [
"def",
"collect",
"(",
"self",
",",
"order_ref",
")",
":",
"try",
":",
"out",
"=",
"self",
".",
"client",
".",
"service",
".",
"Collect",
"(",
"order_ref",
")",
"except",
"Error",
"as",
"e",
":",
"raise",
"get_error_class",
"(",
"e",
",",
"\"Could not ... | 1405f66e41f912cdda15e20aea08cdfa6b60480a |
train | BankIDClient._dictify | Transforms the replies to a regular Python dict with
strings and datetimes.
Tested with BankID version 2.5 return data.
:param doc: The response as interpreted by :py:mod:`zeep`.
:returns: The response parsed to a dict.
:rtype: dict | bankid/client.py | def _dictify(self, doc):
"""Transforms the replies to a regular Python dict with
strings and datetimes.
Tested with BankID version 2.5 return data.
:param doc: The response as interpreted by :py:mod:`zeep`.
:returns: The response parsed to a dict.
:rtype: dict
... | def _dictify(self, doc):
"""Transforms the replies to a regular Python dict with
strings and datetimes.
Tested with BankID version 2.5 return data.
:param doc: The response as interpreted by :py:mod:`zeep`.
:returns: The response parsed to a dict.
:rtype: dict
... | [
"Transforms",
"the",
"replies",
"to",
"a",
"regular",
"Python",
"dict",
"with",
"strings",
"and",
"datetimes",
"."
] | hbldh/pybankid | python | https://github.com/hbldh/pybankid/blob/1405f66e41f912cdda15e20aea08cdfa6b60480a/bankid/client.py#L181-L195 | [
"def",
"_dictify",
"(",
"self",
",",
"doc",
")",
":",
"return",
"{",
"k",
":",
"(",
"self",
".",
"_dictify",
"(",
"doc",
"[",
"k",
"]",
")",
"if",
"hasattr",
"(",
"doc",
"[",
"k",
"]",
",",
"\"_xsd_type\"",
")",
"else",
"doc",
"[",
"k",
"]",
... | 1405f66e41f912cdda15e20aea08cdfa6b60480a |
train | DraftailTextArea.intercept_image_formats | Load all image formats if needed. | wagtaildraftail/widgets.py | def intercept_image_formats(self, options):
"""
Load all image formats if needed.
"""
if 'entityTypes' in options:
for entity in options['entityTypes']:
if entity['type'] == ENTITY_TYPES.IMAGE and 'imageFormats' in entity:
if entity['imageF... | def intercept_image_formats(self, options):
"""
Load all image formats if needed.
"""
if 'entityTypes' in options:
for entity in options['entityTypes']:
if entity['type'] == ENTITY_TYPES.IMAGE and 'imageFormats' in entity:
if entity['imageF... | [
"Load",
"all",
"image",
"formats",
"if",
"needed",
"."
] | springload/wagtaildraftail | python | https://github.com/springload/wagtaildraftail/blob/87f1ae3ade493c00daff021394051aa656136c10/wagtaildraftail/widgets.py#L75-L85 | [
"def",
"intercept_image_formats",
"(",
"self",
",",
"options",
")",
":",
"if",
"'entityTypes'",
"in",
"options",
":",
"for",
"entity",
"in",
"options",
"[",
"'entityTypes'",
"]",
":",
"if",
"entity",
"[",
"'type'",
"]",
"==",
"ENTITY_TYPES",
".",
"IMAGE",
... | 87f1ae3ade493c00daff021394051aa656136c10 |
train | PosixTime._GetNormalizedTimestamp | Retrieves the normalized timestamp.
Returns:
decimal.Decimal: normalized timestamp, which contains the number of
seconds since January 1, 1970 00:00:00 and a fraction of second used
for increased precision, or None if the normalized timestamp cannot be
determined. | dfdatetime/posix_time.py | def _GetNormalizedTimestamp(self):
"""Retrieves the normalized timestamp.
Returns:
decimal.Decimal: normalized timestamp, which contains the number of
seconds since January 1, 1970 00:00:00 and a fraction of second used
for increased precision, or None if the normalized timestamp cann... | def _GetNormalizedTimestamp(self):
"""Retrieves the normalized timestamp.
Returns:
decimal.Decimal: normalized timestamp, which contains the number of
seconds since January 1, 1970 00:00:00 and a fraction of second used
for increased precision, or None if the normalized timestamp cann... | [
"Retrieves",
"the",
"normalized",
"timestamp",
"."
] | log2timeline/dfdatetime | python | https://github.com/log2timeline/dfdatetime/blob/141ca4ef1eff3d354b5deaac3d81cb08506f98d6/dfdatetime/posix_time.py#L51-L64 | [
"def",
"_GetNormalizedTimestamp",
"(",
"self",
")",
":",
"if",
"self",
".",
"_normalized_timestamp",
"is",
"None",
":",
"if",
"self",
".",
"_timestamp",
"is",
"not",
"None",
":",
"self",
".",
"_normalized_timestamp",
"=",
"decimal",
".",
"Decimal",
"(",
"sel... | 141ca4ef1eff3d354b5deaac3d81cb08506f98d6 |
train | PosixTime.CopyFromDateTimeString | Copies a POSIX timestamp from a date and time string.
Args:
time_string (str): date and time value formatted as:
YYYY-MM-DD hh:mm:ss.######[+-]##:##
Where # are numeric digits ranging from 0 to 9 and the seconds
fraction can be either 3 or 6 digits. The time of day, seconds
... | dfdatetime/posix_time.py | def CopyFromDateTimeString(self, time_string):
"""Copies a POSIX timestamp from a date and time string.
Args:
time_string (str): date and time value formatted as:
YYYY-MM-DD hh:mm:ss.######[+-]##:##
Where # are numeric digits ranging from 0 to 9 and the seconds
fraction can... | def CopyFromDateTimeString(self, time_string):
"""Copies a POSIX timestamp from a date and time string.
Args:
time_string (str): date and time value formatted as:
YYYY-MM-DD hh:mm:ss.######[+-]##:##
Where # are numeric digits ranging from 0 to 9 and the seconds
fraction can... | [
"Copies",
"a",
"POSIX",
"timestamp",
"from",
"a",
"date",
"and",
"time",
"string",
"."
] | log2timeline/dfdatetime | python | https://github.com/log2timeline/dfdatetime/blob/141ca4ef1eff3d354b5deaac3d81cb08506f98d6/dfdatetime/posix_time.py#L66-L90 | [
"def",
"CopyFromDateTimeString",
"(",
"self",
",",
"time_string",
")",
":",
"date_time_values",
"=",
"self",
".",
"_CopyDateTimeFromString",
"(",
"time_string",
")",
"year",
"=",
"date_time_values",
".",
"get",
"(",
"'year'",
",",
"0",
")",
"month",
"=",
"date... | 141ca4ef1eff3d354b5deaac3d81cb08506f98d6 |
train | PosixTime.CopyToDateTimeString | Copies the POSIX timestamp to a date and time string.
Returns:
str: date and time value formatted as: "YYYY-MM-DD hh:mm:ss" or None
if the timestamp is missing. | dfdatetime/posix_time.py | def CopyToDateTimeString(self):
"""Copies the POSIX timestamp to a date and time string.
Returns:
str: date and time value formatted as: "YYYY-MM-DD hh:mm:ss" or None
if the timestamp is missing.
"""
if self._timestamp is None:
return None
number_of_days, hours, minutes, seco... | def CopyToDateTimeString(self):
"""Copies the POSIX timestamp to a date and time string.
Returns:
str: date and time value formatted as: "YYYY-MM-DD hh:mm:ss" or None
if the timestamp is missing.
"""
if self._timestamp is None:
return None
number_of_days, hours, minutes, seco... | [
"Copies",
"the",
"POSIX",
"timestamp",
"to",
"a",
"date",
"and",
"time",
"string",
"."
] | log2timeline/dfdatetime | python | https://github.com/log2timeline/dfdatetime/blob/141ca4ef1eff3d354b5deaac3d81cb08506f98d6/dfdatetime/posix_time.py#L92-L109 | [
"def",
"CopyToDateTimeString",
"(",
"self",
")",
":",
"if",
"self",
".",
"_timestamp",
"is",
"None",
":",
"return",
"None",
"number_of_days",
",",
"hours",
",",
"minutes",
",",
"seconds",
"=",
"self",
".",
"_GetTimeValues",
"(",
"self",
".",
"_timestamp",
... | 141ca4ef1eff3d354b5deaac3d81cb08506f98d6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.