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 | Renderer.draw_path | Draw a path.
In matplotlib, paths are created by filled regions, histograms,
contour plots, patches, etc.
Parameters
----------
data : array_like
A shape (N, 2) array of datapoints.
coordinates : string
A string code, which should be either 'data... | glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py | def draw_path(self, data, coordinates, pathcodes, style,
offset=None, offset_coordinates="data", mplobj=None):
"""
Draw a path.
In matplotlib, paths are created by filled regions, histograms,
contour plots, patches, etc.
Parameters
----------
d... | def draw_path(self, data, coordinates, pathcodes, style,
offset=None, offset_coordinates="data", mplobj=None):
"""
Draw a path.
In matplotlib, paths are created by filled regions, histograms,
contour plots, patches, etc.
Parameters
----------
d... | [
"Draw",
"a",
"path",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/ext/_bundled/mplexporter.py#L638-L673 | [
"def",
"draw_path",
"(",
"self",
",",
"data",
",",
"coordinates",
",",
"pathcodes",
",",
"style",
",",
"offset",
"=",
"None",
",",
"offset_coordinates",
"=",
"\"data\"",
",",
"mplobj",
"=",
"None",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | TimeMOC.from_times | Create a TimeMOC from a `astropy.time.Time`
Parameters
----------
times : `astropy.time.Time`
astropy observation times
delta_t : `astropy.time.TimeDelta`, optional
the duration of one observation. It is set to 30 min by default. This data is used to compute the
... | mocpy/tmoc/tmoc.py | def from_times(cls, times, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Create a TimeMOC from a `astropy.time.Time`
Parameters
----------
times : `astropy.time.Time`
astropy observation times
delta_t : `astropy.time.TimeDelta`, optional
the duration of ... | def from_times(cls, times, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Create a TimeMOC from a `astropy.time.Time`
Parameters
----------
times : `astropy.time.Time`
astropy observation times
delta_t : `astropy.time.TimeDelta`, optional
the duration of ... | [
"Create",
"a",
"TimeMOC",
"from",
"a",
"astropy",
".",
"time",
".",
"Time"
] | cds-astro/mocpy | python | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L31-L53 | [
"def",
"from_times",
"(",
"cls",
",",
"times",
",",
"delta_t",
"=",
"DEFAULT_OBSERVATION_TIME",
")",
":",
"times_arr",
"=",
"np",
".",
"asarray",
"(",
"times",
".",
"jd",
"*",
"TimeMOC",
".",
"DAY_MICRO_SEC",
",",
"dtype",
"=",
"int",
")",
"intervals_arr",... | 09472cabe537f6bfdb049eeea64d3ea57b391c21 |
train | TimeMOC.from_time_ranges | Create a TimeMOC from a range defined by two `astropy.time.Time`
Parameters
----------
min_times : `astropy.time.Time`
astropy times defining the left part of the intervals
max_times : `astropy.time.Time`
astropy times defining the right part of the intervals
... | mocpy/tmoc/tmoc.py | def from_time_ranges(cls, min_times, max_times, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Create a TimeMOC from a range defined by two `astropy.time.Time`
Parameters
----------
min_times : `astropy.time.Time`
astropy times defining the left part of the intervals
... | def from_time_ranges(cls, min_times, max_times, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Create a TimeMOC from a range defined by two `astropy.time.Time`
Parameters
----------
min_times : `astropy.time.Time`
astropy times defining the left part of the intervals
... | [
"Create",
"a",
"TimeMOC",
"from",
"a",
"range",
"defined",
"by",
"two",
"astropy",
".",
"time",
".",
"Time"
] | cds-astro/mocpy | python | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L56-L82 | [
"def",
"from_time_ranges",
"(",
"cls",
",",
"min_times",
",",
"max_times",
",",
"delta_t",
"=",
"DEFAULT_OBSERVATION_TIME",
")",
":",
"min_times_arr",
"=",
"np",
".",
"asarray",
"(",
"min_times",
".",
"jd",
"*",
"TimeMOC",
".",
"DAY_MICRO_SEC",
",",
"dtype",
... | 09472cabe537f6bfdb049eeea64d3ea57b391c21 |
train | TimeMOC.add_neighbours | Add all the pixels at max order in the neighbourhood of the moc | mocpy/tmoc/tmoc.py | def add_neighbours(self):
"""
Add all the pixels at max order in the neighbourhood of the moc
"""
time_delta = 1 << (2*(IntervalSet.HPY_MAX_ORDER - self.max_order))
intervals_arr = self._interval_set._intervals
intervals_arr[:, 0] = np.maximum(intervals_arr[:, 0] - time... | def add_neighbours(self):
"""
Add all the pixels at max order in the neighbourhood of the moc
"""
time_delta = 1 << (2*(IntervalSet.HPY_MAX_ORDER - self.max_order))
intervals_arr = self._interval_set._intervals
intervals_arr[:, 0] = np.maximum(intervals_arr[:, 0] - time... | [
"Add",
"all",
"the",
"pixels",
"at",
"max",
"order",
"in",
"the",
"neighbourhood",
"of",
"the",
"moc"
] | cds-astro/mocpy | python | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L84-L95 | [
"def",
"add_neighbours",
"(",
"self",
")",
":",
"time_delta",
"=",
"1",
"<<",
"(",
"2",
"*",
"(",
"IntervalSet",
".",
"HPY_MAX_ORDER",
"-",
"self",
".",
"max_order",
")",
")",
"intervals_arr",
"=",
"self",
".",
"_interval_set",
".",
"_intervals",
"interval... | 09472cabe537f6bfdb049eeea64d3ea57b391c21 |
train | TimeMOC.remove_neighbours | Remove all the pixels at max order located at the bound of the moc | mocpy/tmoc/tmoc.py | def remove_neighbours(self):
"""
Remove all the pixels at max order located at the bound of the moc
"""
time_delta = 1 << (2*(IntervalSet.HPY_MAX_ORDER - self.max_order))
intervals_arr = self._interval_set._intervals
intervals_arr[:, 0] = np.minimum(intervals_arr[:, 0] ... | def remove_neighbours(self):
"""
Remove all the pixels at max order located at the bound of the moc
"""
time_delta = 1 << (2*(IntervalSet.HPY_MAX_ORDER - self.max_order))
intervals_arr = self._interval_set._intervals
intervals_arr[:, 0] = np.minimum(intervals_arr[:, 0] ... | [
"Remove",
"all",
"the",
"pixels",
"at",
"max",
"order",
"located",
"at",
"the",
"bound",
"of",
"the",
"moc"
] | cds-astro/mocpy | python | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L97-L110 | [
"def",
"remove_neighbours",
"(",
"self",
")",
":",
"time_delta",
"=",
"1",
"<<",
"(",
"2",
"*",
"(",
"IntervalSet",
".",
"HPY_MAX_ORDER",
"-",
"self",
".",
"max_order",
")",
")",
"intervals_arr",
"=",
"self",
".",
"_interval_set",
".",
"_intervals",
"inter... | 09472cabe537f6bfdb049eeea64d3ea57b391c21 |
train | TimeMOC._process_degradation | Degrade (down-sampling) self and ``another_moc`` to ``order_op`` order
Parameters
----------
another_moc : `~mocpy.tmoc.TimeMoc`
order_op : int
the order in which self and ``another_moc`` will be down-sampled to.
Returns
-------
result : (`~mocpy.tmo... | mocpy/tmoc/tmoc.py | def _process_degradation(self, another_moc, order_op):
"""
Degrade (down-sampling) self and ``another_moc`` to ``order_op`` order
Parameters
----------
another_moc : `~mocpy.tmoc.TimeMoc`
order_op : int
the order in which self and ``another_moc`` will be down... | def _process_degradation(self, another_moc, order_op):
"""
Degrade (down-sampling) self and ``another_moc`` to ``order_op`` order
Parameters
----------
another_moc : `~mocpy.tmoc.TimeMoc`
order_op : int
the order in which self and ``another_moc`` will be down... | [
"Degrade",
"(",
"down",
"-",
"sampling",
")",
"self",
"and",
"another_moc",
"to",
"order_op",
"order"
] | cds-astro/mocpy | python | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L123-L150 | [
"def",
"_process_degradation",
"(",
"self",
",",
"another_moc",
",",
"order_op",
")",
":",
"max_order",
"=",
"max",
"(",
"self",
".",
"max_order",
",",
"another_moc",
".",
"max_order",
")",
"if",
"order_op",
">",
"max_order",
":",
"message",
"=",
"'Requested... | 09472cabe537f6bfdb049eeea64d3ea57b391c21 |
train | TimeMOC.intersection | Intersection between self and moc. ``delta_t`` gives the possibility to the user
to set a time resolution for performing the tmoc intersection
Parameters
----------
another_moc : `~mocpy.abstract_moc.AbstractMOC`
the MOC/TimeMOC used for performing the intersection with self... | mocpy/tmoc/tmoc.py | def intersection(self, another_moc, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Intersection between self and moc. ``delta_t`` gives the possibility to the user
to set a time resolution for performing the tmoc intersection
Parameters
----------
another_moc : `~mocpy.abstract_... | def intersection(self, another_moc, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Intersection between self and moc. ``delta_t`` gives the possibility to the user
to set a time resolution for performing the tmoc intersection
Parameters
----------
another_moc : `~mocpy.abstract_... | [
"Intersection",
"between",
"self",
"and",
"moc",
".",
"delta_t",
"gives",
"the",
"possibility",
"to",
"the",
"user",
"to",
"set",
"a",
"time",
"resolution",
"for",
"performing",
"the",
"tmoc",
"intersection"
] | cds-astro/mocpy | python | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L152-L176 | [
"def",
"intersection",
"(",
"self",
",",
"another_moc",
",",
"delta_t",
"=",
"DEFAULT_OBSERVATION_TIME",
")",
":",
"order_op",
"=",
"TimeMOC",
".",
"time_resolution_to_order",
"(",
"delta_t",
")",
"self_degraded",
",",
"moc_degraded",
"=",
"self",
".",
"_process_d... | 09472cabe537f6bfdb049eeea64d3ea57b391c21 |
train | TimeMOC.total_duration | Get the total duration covered by the temporal moc
Returns
-------
duration : `~astropy.time.TimeDelta`
total duration of all the observation times of the tmoc
total duration of all the observation times of the tmoc | mocpy/tmoc/tmoc.py | def total_duration(self):
"""
Get the total duration covered by the temporal moc
Returns
-------
duration : `~astropy.time.TimeDelta`
total duration of all the observation times of the tmoc
total duration of all the observation times of the tmoc
... | def total_duration(self):
"""
Get the total duration covered by the temporal moc
Returns
-------
duration : `~astropy.time.TimeDelta`
total duration of all the observation times of the tmoc
total duration of all the observation times of the tmoc
... | [
"Get",
"the",
"total",
"duration",
"covered",
"by",
"the",
"temporal",
"moc"
] | cds-astro/mocpy | python | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L230-L251 | [
"def",
"total_duration",
"(",
"self",
")",
":",
"if",
"self",
".",
"_interval_set",
".",
"empty",
"(",
")",
":",
"return",
"0",
"total_time_us",
"=",
"0",
"# The interval set is checked for consistency before looping over all the intervals",
"for",
"(",
"start_time",
... | 09472cabe537f6bfdb049eeea64d3ea57b391c21 |
train | TimeMOC.consistency | Get a percentage of fill between the min and max time the moc is defined.
A value near 0 shows a sparse temporal moc (i.e. the moc does not cover a lot
of time and covers very distant times. A value near 1 means that the moc covers
a lot of time without big pauses.
Returns
----... | mocpy/tmoc/tmoc.py | def consistency(self):
"""
Get a percentage of fill between the min and max time the moc is defined.
A value near 0 shows a sparse temporal moc (i.e. the moc does not cover a lot
of time and covers very distant times. A value near 1 means that the moc covers
a lot of time withou... | def consistency(self):
"""
Get a percentage of fill between the min and max time the moc is defined.
A value near 0 shows a sparse temporal moc (i.e. the moc does not cover a lot
of time and covers very distant times. A value near 1 means that the moc covers
a lot of time withou... | [
"Get",
"a",
"percentage",
"of",
"fill",
"between",
"the",
"min",
"and",
"max",
"time",
"the",
"moc",
"is",
"defined",
"."
] | cds-astro/mocpy | python | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L254-L270 | [
"def",
"consistency",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"total_duration",
".",
"jd",
"/",
"(",
"self",
".",
"max_time",
"-",
"self",
".",
"min_time",
")",
".",
"jd",
"return",
"result"
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 |
train | TimeMOC.min_time | Get the `~astropy.time.Time` time of the tmoc first observation
Returns
-------
min_time : `astropy.time.Time`
time of the first observation | mocpy/tmoc/tmoc.py | def min_time(self):
"""
Get the `~astropy.time.Time` time of the tmoc first observation
Returns
-------
min_time : `astropy.time.Time`
time of the first observation
"""
min_time = Time(self._interval_set.min / TimeMOC.DAY_MICRO_SEC, format='jd', sca... | def min_time(self):
"""
Get the `~astropy.time.Time` time of the tmoc first observation
Returns
-------
min_time : `astropy.time.Time`
time of the first observation
"""
min_time = Time(self._interval_set.min / TimeMOC.DAY_MICRO_SEC, format='jd', sca... | [
"Get",
"the",
"~astropy",
".",
"time",
".",
"Time",
"time",
"of",
"the",
"tmoc",
"first",
"observation"
] | cds-astro/mocpy | python | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L273-L285 | [
"def",
"min_time",
"(",
"self",
")",
":",
"min_time",
"=",
"Time",
"(",
"self",
".",
"_interval_set",
".",
"min",
"/",
"TimeMOC",
".",
"DAY_MICRO_SEC",
",",
"format",
"=",
"'jd'",
",",
"scale",
"=",
"'tdb'",
")",
"return",
"min_time"
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 |
train | TimeMOC.max_time | Get the `~astropy.time.Time` time of the tmoc last observation
Returns
-------
max_time : `~astropy.time.Time`
time of the last observation | mocpy/tmoc/tmoc.py | def max_time(self):
"""
Get the `~astropy.time.Time` time of the tmoc last observation
Returns
-------
max_time : `~astropy.time.Time`
time of the last observation
"""
max_time = Time(self._interval_set.max / TimeMOC.DAY_MICRO_SEC, format='jd', scal... | def max_time(self):
"""
Get the `~astropy.time.Time` time of the tmoc last observation
Returns
-------
max_time : `~astropy.time.Time`
time of the last observation
"""
max_time = Time(self._interval_set.max / TimeMOC.DAY_MICRO_SEC, format='jd', scal... | [
"Get",
"the",
"~astropy",
".",
"time",
".",
"Time",
"time",
"of",
"the",
"tmoc",
"last",
"observation"
] | cds-astro/mocpy | python | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L288-L300 | [
"def",
"max_time",
"(",
"self",
")",
":",
"max_time",
"=",
"Time",
"(",
"self",
".",
"_interval_set",
".",
"max",
"/",
"TimeMOC",
".",
"DAY_MICRO_SEC",
",",
"format",
"=",
"'jd'",
",",
"scale",
"=",
"'tdb'",
")",
"return",
"max_time"
] | 09472cabe537f6bfdb049eeea64d3ea57b391c21 |
train | TimeMOC.contains | Get a mask array (e.g. a numpy boolean array) of times being inside (or outside) the
TMOC instance.
Parameters
----------
times : `astropy.time.Time`
astropy times to check whether they are contained in the TMOC or not.
keep_inside : bool, optional
True b... | mocpy/tmoc/tmoc.py | def contains(self, times, keep_inside=True, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Get a mask array (e.g. a numpy boolean array) of times being inside (or outside) the
TMOC instance.
Parameters
----------
times : `astropy.time.Time`
astropy times to check whe... | def contains(self, times, keep_inside=True, delta_t=DEFAULT_OBSERVATION_TIME):
"""
Get a mask array (e.g. a numpy boolean array) of times being inside (or outside) the
TMOC instance.
Parameters
----------
times : `astropy.time.Time`
astropy times to check whe... | [
"Get",
"a",
"mask",
"array",
"(",
"e",
".",
"g",
".",
"a",
"numpy",
"boolean",
"array",
")",
"of",
"times",
"being",
"inside",
"(",
"or",
"outside",
")",
"the",
"TMOC",
"instance",
"."
] | cds-astro/mocpy | python | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L302-L350 | [
"def",
"contains",
"(",
"self",
",",
"times",
",",
"keep_inside",
"=",
"True",
",",
"delta_t",
"=",
"DEFAULT_OBSERVATION_TIME",
")",
":",
"# the requested order for filtering the astropy observations table is more precise than the order",
"# of the TimeMoc object",
"current_max_o... | 09472cabe537f6bfdb049eeea64d3ea57b391c21 |
train | TimeMOC.plot | Plot the TimeMoc in a time window.
This method uses interactive matplotlib. The user can move its mouse through the plot to see the
time (at the mouse position).
Parameters
----------
title : str, optional
The title of the plot. Set to 'TimeMoc' by default.
... | mocpy/tmoc/tmoc.py | def plot(self, title='TimeMoc', view=(None, None)):
"""
Plot the TimeMoc in a time window.
This method uses interactive matplotlib. The user can move its mouse through the plot to see the
time (at the mouse position).
Parameters
----------
title : str, optional
... | def plot(self, title='TimeMoc', view=(None, None)):
"""
Plot the TimeMoc in a time window.
This method uses interactive matplotlib. The user can move its mouse through the plot to see the
time (at the mouse position).
Parameters
----------
title : str, optional
... | [
"Plot",
"the",
"TimeMoc",
"in",
"a",
"time",
"window",
"."
] | cds-astro/mocpy | python | https://github.com/cds-astro/mocpy/blob/09472cabe537f6bfdb049eeea64d3ea57b391c21/mocpy/tmoc/tmoc.py#L391-L474 | [
"def",
"plot",
"(",
"self",
",",
"title",
"=",
"'TimeMoc'",
",",
"view",
"=",
"(",
"None",
",",
"None",
")",
")",
":",
"from",
"matplotlib",
".",
"colors",
"import",
"LinearSegmentedColormap",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"if",
"se... | 09472cabe537f6bfdb049eeea64d3ea57b391c21 |
train | MPDHook.handle | Handle a new update.
Fetches new data from the client, then compares it to the previous
lookup.
Returns:
(bool, new_data): whether changes occurred, and the new value. | mpdlcd/mpdhooks.py | def handle(self, client, subhooks=()):
"""Handle a new update.
Fetches new data from the client, then compares it to the previous
lookup.
Returns:
(bool, new_data): whether changes occurred, and the new value.
"""
new_data = self.fetch(client)
# Hol... | def handle(self, client, subhooks=()):
"""Handle a new update.
Fetches new data from the client, then compares it to the previous
lookup.
Returns:
(bool, new_data): whether changes occurred, and the new value.
"""
new_data = self.fetch(client)
# Hol... | [
"Handle",
"a",
"new",
"update",
"."
] | rbarrois/mpdlcd | python | https://github.com/rbarrois/mpdlcd/blob/85f16c8cc0883f8abb4c2cc7f69729c3e2f857da/mpdlcd/mpdhooks.py#L68-L96 | [
"def",
"handle",
"(",
"self",
",",
"client",
",",
"subhooks",
"=",
"(",
")",
")",
":",
"new_data",
"=",
"self",
".",
"fetch",
"(",
"client",
")",
"# Holds the list of updated fields.",
"updated",
"=",
"{",
"}",
"if",
"not",
"subhooks",
":",
"# We always wa... | 85f16c8cc0883f8abb4c2cc7f69729c3e2f857da |
train | _text_to_vbo | Convert text characters to VBO | glue_vispy_viewers/extern/vispy/visuals/text/text.py | def _text_to_vbo(text, font, anchor_x, anchor_y, lowres_size):
"""Convert text characters to VBO"""
# Necessary to flush commands before requesting current viewport because
# There may be a set_viewport command waiting in the queue.
# TODO: would be nicer if each canvas just remembers and manages its ow... | def _text_to_vbo(text, font, anchor_x, anchor_y, lowres_size):
"""Convert text characters to VBO"""
# Necessary to flush commands before requesting current viewport because
# There may be a set_viewport command waiting in the queue.
# TODO: would be nicer if each canvas just remembers and manages its ow... | [
"Convert",
"text",
"characters",
"to",
"VBO"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/text/text.py#L132-L207 | [
"def",
"_text_to_vbo",
"(",
"text",
",",
"font",
",",
"anchor_x",
",",
"anchor_y",
",",
"lowres_size",
")",
":",
"# Necessary to flush commands before requesting current viewport because",
"# There may be a set_viewport command waiting in the queue.",
"# TODO: would be nicer if each ... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | TextureFont._load_char | Build and store a glyph corresponding to an individual character
Parameters
----------
char : str
A single character to be represented. | glue_vispy_viewers/extern/vispy/visuals/text/text.py | def _load_char(self, char):
"""Build and store a glyph corresponding to an individual character
Parameters
----------
char : str
A single character to be represented.
"""
assert isinstance(char, string_types) and len(char) == 1
assert char not in self... | def _load_char(self, char):
"""Build and store a glyph corresponding to an individual character
Parameters
----------
char : str
A single character to be represented.
"""
assert isinstance(char, string_types) and len(char) == 1
assert char not in self... | [
"Build",
"and",
"store",
"a",
"glyph",
"corresponding",
"to",
"an",
"individual",
"character"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/text/text.py#L72-L108 | [
"def",
"_load_char",
"(",
"self",
",",
"char",
")",
":",
"assert",
"isinstance",
"(",
"char",
",",
"string_types",
")",
"and",
"len",
"(",
"char",
")",
"==",
"1",
"assert",
"char",
"not",
"in",
"self",
".",
"_glyphs",
"# load new glyph data from font",
"_l... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | FontManager.get_font | Get a font described by face and size | glue_vispy_viewers/extern/vispy/visuals/text/text.py | def get_font(self, face, bold=False, italic=False):
"""Get a font described by face and size"""
key = '%s-%s-%s' % (face, bold, italic)
if key not in self._fonts:
font = dict(face=face, bold=bold, italic=italic)
self._fonts[key] = TextureFont(font, self._renderer)
... | def get_font(self, face, bold=False, italic=False):
"""Get a font described by face and size"""
key = '%s-%s-%s' % (face, bold, italic)
if key not in self._fonts:
font = dict(face=face, bold=bold, italic=italic)
self._fonts[key] = TextureFont(font, self._renderer)
... | [
"Get",
"a",
"font",
"described",
"by",
"face",
"and",
"size"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/text/text.py#L119-L125 | [
"def",
"get_font",
"(",
"self",
",",
"face",
",",
"bold",
"=",
"False",
",",
"italic",
"=",
"False",
")",
":",
"key",
"=",
"'%s-%s-%s'",
"%",
"(",
"face",
",",
"bold",
",",
"italic",
")",
"if",
"key",
"not",
"in",
"self",
".",
"_fonts",
":",
"fon... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | stft | Compute the STFT
Parameters
----------
x : array-like
1D signal to operate on. ``If len(x) < n_fft``, x will be zero-padded
to length ``n_fft``.
n_fft : int
Number of FFT points. Much faster for powers of two.
step : int | None
Step size between calculations. If None... | glue_vispy_viewers/extern/vispy/util/fourier.py | def stft(x, n_fft=1024, step=512, fs=2*np.pi, window='hann'):
"""Compute the STFT
Parameters
----------
x : array-like
1D signal to operate on. ``If len(x) < n_fft``, x will be zero-padded
to length ``n_fft``.
n_fft : int
Number of FFT points. Much faster for powers of two.
... | def stft(x, n_fft=1024, step=512, fs=2*np.pi, window='hann'):
"""Compute the STFT
Parameters
----------
x : array-like
1D signal to operate on. ``If len(x) < n_fft``, x will be zero-padded
to length ``n_fft``.
n_fft : int
Number of FFT points. Much faster for powers of two.
... | [
"Compute",
"the",
"STFT"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fourier.py#L8-L56 | [
"def",
"stft",
"(",
"x",
",",
"n_fft",
"=",
"1024",
",",
"step",
"=",
"512",
",",
"fs",
"=",
"2",
"*",
"np",
".",
"pi",
",",
"window",
"=",
"'hann'",
")",
":",
"x",
"=",
"np",
".",
"asarray",
"(",
"x",
",",
"float",
")",
"if",
"x",
".",
"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | fft_freqs | Return frequencies for DFT
Parameters
----------
n_fft : int
Number of points in the FFT.
fs : float
The sampling rate. | glue_vispy_viewers/extern/vispy/util/fourier.py | def fft_freqs(n_fft, fs):
"""Return frequencies for DFT
Parameters
----------
n_fft : int
Number of points in the FFT.
fs : float
The sampling rate.
"""
return np.arange(0, (n_fft // 2 + 1)) / float(n_fft) * float(fs) | def fft_freqs(n_fft, fs):
"""Return frequencies for DFT
Parameters
----------
n_fft : int
Number of points in the FFT.
fs : float
The sampling rate.
"""
return np.arange(0, (n_fft // 2 + 1)) / float(n_fft) * float(fs) | [
"Return",
"frequencies",
"for",
"DFT"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/fourier.py#L59-L69 | [
"def",
"fft_freqs",
"(",
"n_fft",
",",
"fs",
")",
":",
"return",
"np",
".",
"arange",
"(",
"0",
",",
"(",
"n_fft",
"//",
"2",
"+",
"1",
")",
")",
"/",
"float",
"(",
"n_fft",
")",
"*",
"float",
"(",
"fs",
")"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | ArrowVisual.set_data | Set the data used for this visual
Parameters
----------
pos : array
Array of shape (..., 2) or (..., 3) specifying vertex coordinates.
color : Color, tuple, or array
The color to use when drawing the line. If an array is given, it
must be of shape (..... | glue_vispy_viewers/extern/vispy/visuals/line/arrow.py | def set_data(self, pos=None, color=None, width=None, connect=None,
arrows=None):
"""Set the data used for this visual
Parameters
----------
pos : array
Array of shape (..., 2) or (..., 3) specifying vertex coordinates.
color : Color, tuple, or array
... | def set_data(self, pos=None, color=None, width=None, connect=None,
arrows=None):
"""Set the data used for this visual
Parameters
----------
pos : array
Array of shape (..., 2) or (..., 3) specifying vertex coordinates.
color : Color, tuple, or array
... | [
"Set",
"the",
"data",
"used",
"for",
"this",
"visual"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/line/arrow.py#L191-L227 | [
"def",
"set_data",
"(",
"self",
",",
"pos",
"=",
"None",
",",
"color",
"=",
"None",
",",
"width",
"=",
"None",
",",
"connect",
"=",
"None",
",",
"arrows",
"=",
"None",
")",
":",
"if",
"arrows",
"is",
"not",
"None",
":",
"self",
".",
"_arrows",
"=... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | strip_html | Get rid of ugly twitter html | examples/twitter/twitter.py | def strip_html(text):
""" Get rid of ugly twitter html """
def reply_to(text):
replying_to = []
split_text = text.split()
for index, token in enumerate(split_text):
if token.startswith('@'): replying_to.append(token[1:])
else:
message = split_text[... | def strip_html(text):
""" Get rid of ugly twitter html """
def reply_to(text):
replying_to = []
split_text = text.split()
for index, token in enumerate(split_text):
if token.startswith('@'): replying_to.append(token[1:])
else:
message = split_text[... | [
"Get",
"rid",
"of",
"ugly",
"twitter",
"html"
] | anjishnu/ask-alexa-pykit | python | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/twitter.py#L169-L190 | [
"def",
"strip_html",
"(",
"text",
")",
":",
"def",
"reply_to",
"(",
"text",
")",
":",
"replying_to",
"=",
"[",
"]",
"split_text",
"=",
"text",
".",
"split",
"(",
")",
"for",
"index",
",",
"token",
"in",
"enumerate",
"(",
"split_text",
")",
":",
"if",... | a47c278ca7a60532bbe1a9b789f6c37e609fea8b |
train | post_tweet | Helper function to post a tweet | examples/twitter/twitter.py | def post_tweet(user_id, message, additional_params={}):
"""
Helper function to post a tweet
"""
url = "https://api.twitter.com/1.1/statuses/update.json"
params = { "status" : message }
params.update(additional_params)
r = make_twitter_request(url, user_id, params, request_type='POST')
... | def post_tweet(user_id, message, additional_params={}):
"""
Helper function to post a tweet
"""
url = "https://api.twitter.com/1.1/statuses/update.json"
params = { "status" : message }
params.update(additional_params)
r = make_twitter_request(url, user_id, params, request_type='POST')
... | [
"Helper",
"function",
"to",
"post",
"a",
"tweet"
] | anjishnu/ask-alexa-pykit | python | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/twitter.py#L274-L283 | [
"def",
"post_tweet",
"(",
"user_id",
",",
"message",
",",
"additional_params",
"=",
"{",
"}",
")",
":",
"url",
"=",
"\"https://api.twitter.com/1.1/statuses/update.json\"",
"params",
"=",
"{",
"\"status\"",
":",
"message",
"}",
"params",
".",
"update",
"(",
"addi... | a47c278ca7a60532bbe1a9b789f6c37e609fea8b |
train | make_twitter_request | Generically make a request to twitter API using a particular user's authorization | examples/twitter/twitter.py | def make_twitter_request(url, user_id, params={}, request_type='GET'):
""" Generically make a request to twitter API using a particular user's authorization """
if request_type == "GET":
return requests.get(url, auth=get_twitter_auth(user_id), params=params)
elif request_type == "POST":
retu... | def make_twitter_request(url, user_id, params={}, request_type='GET'):
""" Generically make a request to twitter API using a particular user's authorization """
if request_type == "GET":
return requests.get(url, auth=get_twitter_auth(user_id), params=params)
elif request_type == "POST":
retu... | [
"Generically",
"make",
"a",
"request",
"to",
"twitter",
"API",
"using",
"a",
"particular",
"user",
"s",
"authorization"
] | anjishnu/ask-alexa-pykit | python | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/twitter.py#L333-L338 | [
"def",
"make_twitter_request",
"(",
"url",
",",
"user_id",
",",
"params",
"=",
"{",
"}",
",",
"request_type",
"=",
"'GET'",
")",
":",
"if",
"request_type",
"==",
"\"GET\"",
":",
"return",
"requests",
".",
"get",
"(",
"url",
",",
"auth",
"=",
"get_twitter... | a47c278ca7a60532bbe1a9b789f6c37e609fea8b |
train | geo_search | Search for a location - free form | examples/twitter/twitter.py | def geo_search(user_id, search_location):
"""
Search for a location - free form
"""
url = "https://api.twitter.com/1.1/geo/search.json"
params = {"query" : search_location }
response = make_twitter_request(url, user_id, params).json()
return response | def geo_search(user_id, search_location):
"""
Search for a location - free form
"""
url = "https://api.twitter.com/1.1/geo/search.json"
params = {"query" : search_location }
response = make_twitter_request(url, user_id, params).json()
return response | [
"Search",
"for",
"a",
"location",
"-",
"free",
"form"
] | anjishnu/ask-alexa-pykit | python | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/twitter.py#L350-L357 | [
"def",
"geo_search",
"(",
"user_id",
",",
"search_location",
")",
":",
"url",
"=",
"\"https://api.twitter.com/1.1/geo/search.json\"",
"params",
"=",
"{",
"\"query\"",
":",
"search_location",
"}",
"response",
"=",
"make_twitter_request",
"(",
"url",
",",
"user_id",
"... | a47c278ca7a60532bbe1a9b789f6c37e609fea8b |
train | read_out_tweets | Input - list of processed 'Tweets'
output - list of spoken responses | examples/twitter/twitter.py | def read_out_tweets(processed_tweets, speech_convertor=None):
"""
Input - list of processed 'Tweets'
output - list of spoken responses
"""
return ["tweet number {num} by {user}. {text}.".format(num=index+1, user=user, text=text)
for index, (user, text) in enumerate(processed_tweets)] | def read_out_tweets(processed_tweets, speech_convertor=None):
"""
Input - list of processed 'Tweets'
output - list of spoken responses
"""
return ["tweet number {num} by {user}. {text}.".format(num=index+1, user=user, text=text)
for index, (user, text) in enumerate(processed_tweets)] | [
"Input",
"-",
"list",
"of",
"processed",
"Tweets",
"output",
"-",
"list",
"of",
"spoken",
"responses"
] | anjishnu/ask-alexa-pykit | python | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/twitter.py#L374-L380 | [
"def",
"read_out_tweets",
"(",
"processed_tweets",
",",
"speech_convertor",
"=",
"None",
")",
":",
"return",
"[",
"\"tweet number {num} by {user}. {text}.\"",
".",
"format",
"(",
"num",
"=",
"index",
"+",
"1",
",",
"user",
"=",
"user",
",",
"text",
"=",
"text"... | a47c278ca7a60532bbe1a9b789f6c37e609fea8b |
train | search_for_tweets_about | Search twitter API | examples/twitter/twitter.py | def search_for_tweets_about(user_id, params):
""" Search twitter API """
url = "https://api.twitter.com/1.1/search/tweets.json"
response = make_twitter_request(url, user_id, params)
return process_tweets(response.json()["statuses"]) | def search_for_tweets_about(user_id, params):
""" Search twitter API """
url = "https://api.twitter.com/1.1/search/tweets.json"
response = make_twitter_request(url, user_id, params)
return process_tweets(response.json()["statuses"]) | [
"Search",
"twitter",
"API"
] | anjishnu/ask-alexa-pykit | python | https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/twitter.py#L417-L421 | [
"def",
"search_for_tweets_about",
"(",
"user_id",
",",
"params",
")",
":",
"url",
"=",
"\"https://api.twitter.com/1.1/search/tweets.json\"",
"response",
"=",
"make_twitter_request",
"(",
"url",
",",
"user_id",
",",
"params",
")",
"return",
"process_tweets",
"(",
"resp... | a47c278ca7a60532bbe1a9b789f6c37e609fea8b |
train | Saver.add_val | add value in form of dict | tradingAPI/saver.py | def add_val(self, val):
"""add value in form of dict"""
if not isinstance(val, type({})):
raise ValueError(type({}))
self.read()
self.config.update(val)
self.save() | def add_val(self, val):
"""add value in form of dict"""
if not isinstance(val, type({})):
raise ValueError(type({}))
self.read()
self.config.update(val)
self.save() | [
"add",
"value",
"in",
"form",
"of",
"dict"
] | federico123579/Trading212-API | python | https://github.com/federico123579/Trading212-API/blob/0fab20b71a2348e72bbe76071b81f3692128851f/tradingAPI/saver.py#L55-L61 | [
"def",
"add_val",
"(",
"self",
",",
"val",
")",
":",
"if",
"not",
"isinstance",
"(",
"val",
",",
"type",
"(",
"{",
"}",
")",
")",
":",
"raise",
"ValueError",
"(",
"type",
"(",
"{",
"}",
")",
")",
"self",
".",
"read",
"(",
")",
"self",
".",
"c... | 0fab20b71a2348e72bbe76071b81f3692128851f |
train | read_mesh | Read mesh data from file.
Parameters
----------
fname : str
File name to read. Format will be inferred from the filename.
Currently only '.obj' and '.obj.gz' are supported.
Returns
-------
vertices : array
Vertices.
faces : array | None
Triangle face definit... | glue_vispy_viewers/extern/vispy/io/mesh.py | def read_mesh(fname):
"""Read mesh data from file.
Parameters
----------
fname : str
File name to read. Format will be inferred from the filename.
Currently only '.obj' and '.obj.gz' are supported.
Returns
-------
vertices : array
Vertices.
faces : array | None
... | def read_mesh(fname):
"""Read mesh data from file.
Parameters
----------
fname : str
File name to read. Format will be inferred from the filename.
Currently only '.obj' and '.obj.gz' are supported.
Returns
-------
vertices : array
Vertices.
faces : array | None
... | [
"Read",
"mesh",
"data",
"from",
"file",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/mesh.py#L13-L43 | [
"def",
"read_mesh",
"(",
"fname",
")",
":",
"# Check format",
"fmt",
"=",
"op",
".",
"splitext",
"(",
"fname",
")",
"[",
"1",
"]",
".",
"lower",
"(",
")",
"if",
"fmt",
"==",
"'.gz'",
":",
"fmt",
"=",
"op",
".",
"splitext",
"(",
"op",
".",
"splite... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | write_mesh | Write mesh data to file.
Parameters
----------
fname : str
Filename to write. Must end with ".obj" or ".gz".
vertices : array
Vertices.
faces : array | None
Triangle face definitions.
normals : array
Normals for the mesh.
texcoords : array | None
Text... | glue_vispy_viewers/extern/vispy/io/mesh.py | def write_mesh(fname, vertices, faces, normals, texcoords, name='',
format='obj', overwrite=False, reshape_faces=True):
""" Write mesh data to file.
Parameters
----------
fname : str
Filename to write. Must end with ".obj" or ".gz".
vertices : array
Vertices.
face... | def write_mesh(fname, vertices, faces, normals, texcoords, name='',
format='obj', overwrite=False, reshape_faces=True):
""" Write mesh data to file.
Parameters
----------
fname : str
Filename to write. Must end with ".obj" or ".gz".
vertices : array
Vertices.
face... | [
"Write",
"mesh",
"data",
"to",
"file",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/io/mesh.py#L46-L80 | [
"def",
"write_mesh",
"(",
"fname",
",",
"vertices",
",",
"faces",
",",
"normals",
",",
"texcoords",
",",
"name",
"=",
"''",
",",
"format",
"=",
"'obj'",
",",
"overwrite",
"=",
"False",
",",
"reshape_faces",
"=",
"True",
")",
":",
"# Check file",
"if",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | _set_config | Set gl configuration | glue_vispy_viewers/extern/vispy/app/backends/_pyglet.py | def _set_config(config):
"""Set gl configuration"""
pyglet_config = pyglet.gl.Config()
pyglet_config.red_size = config['red_size']
pyglet_config.green_size = config['green_size']
pyglet_config.blue_size = config['blue_size']
pyglet_config.alpha_size = config['alpha_size']
pyglet_config.acc... | def _set_config(config):
"""Set gl configuration"""
pyglet_config = pyglet.gl.Config()
pyglet_config.red_size = config['red_size']
pyglet_config.green_size = config['green_size']
pyglet_config.blue_size = config['blue_size']
pyglet_config.alpha_size = config['alpha_size']
pyglet_config.acc... | [
"Set",
"gl",
"configuration"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/backends/_pyglet.py#L118-L137 | [
"def",
"_set_config",
"(",
"config",
")",
":",
"pyglet_config",
"=",
"pyglet",
".",
"gl",
".",
"Config",
"(",
")",
"pyglet_config",
".",
"red_size",
"=",
"config",
"[",
"'red_size'",
"]",
"pyglet_config",
".",
"green_size",
"=",
"config",
"[",
"'green_size'"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Program.set_shaders | Set the vertex and fragment shaders.
Parameters
----------
vert : str
Source code for vertex shader.
frag : str
Source code for fragment shaders. | glue_vispy_viewers/extern/vispy/gloo/program.py | def set_shaders(self, vert, frag):
""" Set the vertex and fragment shaders.
Parameters
----------
vert : str
Source code for vertex shader.
frag : str
Source code for fragment shaders.
"""
if not vert or not frag:
raise... | def set_shaders(self, vert, frag):
""" Set the vertex and fragment shaders.
Parameters
----------
vert : str
Source code for vertex shader.
frag : str
Source code for fragment shaders.
"""
if not vert or not frag:
raise... | [
"Set",
"the",
"vertex",
"and",
"fragment",
"shaders",
".",
"Parameters",
"----------",
"vert",
":",
"str",
"Source",
"code",
"for",
"vertex",
"shader",
".",
"frag",
":",
"str",
"Source",
"code",
"for",
"fragment",
"shaders",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/program.py#L134-L159 | [
"def",
"set_shaders",
"(",
"self",
",",
"vert",
",",
"frag",
")",
":",
"if",
"not",
"vert",
"or",
"not",
"frag",
":",
"raise",
"ValueError",
"(",
"'Vertex and fragment code must both be non-empty'",
")",
"# pre-process shader code for #include directives",
"vert",
","... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Program._parse_variables_from_code | Parse uniforms, attributes and varyings from the source code. | glue_vispy_viewers/extern/vispy/gloo/program.py | def _parse_variables_from_code(self):
""" Parse uniforms, attributes and varyings from the source code.
"""
# Get one string of code with comments removed
code = '\n\n'.join(self._shaders)
code = re.sub(r'(.*)(//.*)', r'\1', code, re.M)
# Regexp to look ... | def _parse_variables_from_code(self):
""" Parse uniforms, attributes and varyings from the source code.
"""
# Get one string of code with comments removed
code = '\n\n'.join(self._shaders)
code = re.sub(r'(.*)(//.*)', r'\1', code, re.M)
# Regexp to look ... | [
"Parse",
"uniforms",
"attributes",
"and",
"varyings",
"from",
"the",
"source",
"code",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/program.py#L184-L222 | [
"def",
"_parse_variables_from_code",
"(",
"self",
")",
":",
"# Get one string of code with comments removed",
"code",
"=",
"'\\n\\n'",
".",
"join",
"(",
"self",
".",
"_shaders",
")",
"code",
"=",
"re",
".",
"sub",
"(",
"r'(.*)(//.*)'",
",",
"r'\\1'",
",",
"code"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Program.bind | Bind a VertexBuffer that has structured data
Parameters
----------
data : VertexBuffer
The vertex buffer to bind. The field names of the array
are mapped to attribute names in GLSL. | glue_vispy_viewers/extern/vispy/gloo/program.py | def bind(self, data):
""" Bind a VertexBuffer that has structured data
Parameters
----------
data : VertexBuffer
The vertex buffer to bind. The field names of the array
are mapped to attribute names in GLSL.
"""
# Check
if not isin... | def bind(self, data):
""" Bind a VertexBuffer that has structured data
Parameters
----------
data : VertexBuffer
The vertex buffer to bind. The field names of the array
are mapped to attribute names in GLSL.
"""
# Check
if not isin... | [
"Bind",
"a",
"VertexBuffer",
"that",
"has",
"structured",
"data",
"Parameters",
"----------",
"data",
":",
"VertexBuffer",
"The",
"vertex",
"buffer",
"to",
"bind",
".",
"The",
"field",
"names",
"of",
"the",
"array",
"are",
"mapped",
"to",
"attribute",
"names",... | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/program.py#L224-L238 | [
"def",
"bind",
"(",
"self",
",",
"data",
")",
":",
"# Check",
"if",
"not",
"isinstance",
"(",
"data",
",",
"VertexBuffer",
")",
":",
"raise",
"ValueError",
"(",
"'Program.bind() requires a VertexBuffer.'",
")",
"# Apply",
"for",
"name",
"in",
"data",
".",
"d... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Program._process_pending_variables | Try to apply the variables that were set but not known yet. | glue_vispy_viewers/extern/vispy/gloo/program.py | def _process_pending_variables(self):
""" Try to apply the variables that were set but not known yet.
"""
# Clear our list of pending variables
self._pending_variables, pending = {}, self._pending_variables
# Try to apply it. On failure, it will be added again
for name, d... | def _process_pending_variables(self):
""" Try to apply the variables that were set but not known yet.
"""
# Clear our list of pending variables
self._pending_variables, pending = {}, self._pending_variables
# Try to apply it. On failure, it will be added again
for name, d... | [
"Try",
"to",
"apply",
"the",
"variables",
"that",
"were",
"set",
"but",
"not",
"known",
"yet",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/program.py#L240-L247 | [
"def",
"_process_pending_variables",
"(",
"self",
")",
":",
"# Clear our list of pending variables",
"self",
".",
"_pending_variables",
",",
"pending",
"=",
"{",
"}",
",",
"self",
".",
"_pending_variables",
"# Try to apply it. On failure, it will be added again",
"for",
"na... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | Program.draw | Draw the attribute arrays in the specified mode.
Parameters
----------
mode : str | GL_ENUM
'points', 'lines', 'line_strip', 'line_loop', 'triangles',
'triangle_strip', or 'triangle_fan'.
indices : array
Array of indices to draw.
check_error:
... | glue_vispy_viewers/extern/vispy/gloo/program.py | def draw(self, mode='triangles', indices=None, check_error=True):
""" Draw the attribute arrays in the specified mode.
Parameters
----------
mode : str | GL_ENUM
'points', 'lines', 'line_strip', 'line_loop', 'triangles',
'triangle_strip', or 'triangle_fan'.
... | def draw(self, mode='triangles', indices=None, check_error=True):
""" Draw the attribute arrays in the specified mode.
Parameters
----------
mode : str | GL_ENUM
'points', 'lines', 'line_strip', 'line_loop', 'triangles',
'triangle_strip', or 'triangle_fan'.
... | [
"Draw",
"the",
"attribute",
"arrays",
"in",
"the",
"specified",
"mode",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/program.py#L404-L470 | [
"def",
"draw",
"(",
"self",
",",
"mode",
"=",
"'triangles'",
",",
"indices",
"=",
"None",
",",
"check_error",
"=",
"True",
")",
":",
"# Invalidate buffer (data has already been sent)",
"self",
".",
"_buffer",
"=",
"None",
"# Check if mode is valid",
"mode",
"=",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | SurfacePlotVisual.set_data | Update the data in this surface plot.
Parameters
----------
x : ndarray | None
1D array of values specifying the x positions of vertices in the
grid. If None, values will be assumed to be integers.
y : ndarray | None
1D array of values specifying the ... | glue_vispy_viewers/extern/vispy/visuals/surface_plot.py | def set_data(self, x=None, y=None, z=None, colors=None):
"""Update the data in this surface plot.
Parameters
----------
x : ndarray | None
1D array of values specifying the x positions of vertices in the
grid. If None, values will be assumed to be integers.
... | def set_data(self, x=None, y=None, z=None, colors=None):
"""Update the data in this surface plot.
Parameters
----------
x : ndarray | None
1D array of values specifying the x positions of vertices in the
grid. If None, values will be assumed to be integers.
... | [
"Update",
"the",
"data",
"in",
"this",
"surface",
"plot",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/surface_plot.py#L52-L135 | [
"def",
"set_data",
"(",
"self",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"z",
"=",
"None",
",",
"colors",
"=",
"None",
")",
":",
"if",
"x",
"is",
"not",
"None",
":",
"if",
"self",
".",
"_x",
"is",
"None",
"or",
"len",
"(",
"x",
")... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | ChainTransform.simplified | A simplified representation of the same transformation. | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | def simplified(self):
"""A simplified representation of the same transformation.
"""
if self._simplified is None:
self._simplified = SimplifiedChainTransform(self)
return self._simplified | def simplified(self):
"""A simplified representation of the same transformation.
"""
if self._simplified is None:
self._simplified = SimplifiedChainTransform(self)
return self._simplified | [
"A",
"simplified",
"representation",
"of",
"the",
"same",
"transformation",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L99-L104 | [
"def",
"simplified",
"(",
"self",
")",
":",
"if",
"self",
".",
"_simplified",
"is",
"None",
":",
"self",
".",
"_simplified",
"=",
"SimplifiedChainTransform",
"(",
"self",
")",
"return",
"self",
".",
"_simplified"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | ChainTransform.map | Map coordinates
Parameters
----------
coords : array-like
Coordinates to map.
Returns
-------
coords : ndarray
Coordinates. | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | def map(self, coords):
"""Map coordinates
Parameters
----------
coords : array-like
Coordinates to map.
Returns
-------
coords : ndarray
Coordinates.
"""
for tr in reversed(self.transforms):
coords = tr.map(coo... | def map(self, coords):
"""Map coordinates
Parameters
----------
coords : array-like
Coordinates to map.
Returns
-------
coords : ndarray
Coordinates.
"""
for tr in reversed(self.transforms):
coords = tr.map(coo... | [
"Map",
"coordinates"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L134-L149 | [
"def",
"map",
"(",
"self",
",",
"coords",
")",
":",
"for",
"tr",
"in",
"reversed",
"(",
"self",
".",
"transforms",
")",
":",
"coords",
"=",
"tr",
".",
"map",
"(",
"coords",
")",
"return",
"coords"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | ChainTransform.imap | Inverse map coordinates
Parameters
----------
coords : array-like
Coordinates to inverse map.
Returns
-------
coords : ndarray
Coordinates. | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | def imap(self, coords):
"""Inverse map coordinates
Parameters
----------
coords : array-like
Coordinates to inverse map.
Returns
-------
coords : ndarray
Coordinates.
"""
for tr in self.transforms:
coords = tr.... | def imap(self, coords):
"""Inverse map coordinates
Parameters
----------
coords : array-like
Coordinates to inverse map.
Returns
-------
coords : ndarray
Coordinates.
"""
for tr in self.transforms:
coords = tr.... | [
"Inverse",
"map",
"coordinates"
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L151-L166 | [
"def",
"imap",
"(",
"self",
",",
"coords",
")",
":",
"for",
"tr",
"in",
"self",
".",
"transforms",
":",
"coords",
"=",
"tr",
".",
"imap",
"(",
"coords",
")",
"return",
"coords"
] | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | ChainTransform.append | Add a new transform to the end of this chain.
Parameters
----------
tr : instance of Transform
The transform to use. | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | def append(self, tr):
"""
Add a new transform to the end of this chain.
Parameters
----------
tr : instance of Transform
The transform to use.
"""
self.transforms.append(tr)
tr.changed.connect(self._subtr_changed)
self._rebuild_shaders... | def append(self, tr):
"""
Add a new transform to the end of this chain.
Parameters
----------
tr : instance of Transform
The transform to use.
"""
self.transforms.append(tr)
tr.changed.connect(self._subtr_changed)
self._rebuild_shaders... | [
"Add",
"a",
"new",
"transform",
"to",
"the",
"end",
"of",
"this",
"chain",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L181-L193 | [
"def",
"append",
"(",
"self",
",",
"tr",
")",
":",
"self",
".",
"transforms",
".",
"append",
"(",
"tr",
")",
"tr",
".",
"changed",
".",
"connect",
"(",
"self",
".",
"_subtr_changed",
")",
"self",
".",
"_rebuild_shaders",
"(",
")",
"self",
".",
"updat... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | ChainTransform.prepend | Add a new transform to the beginning of this chain.
Parameters
----------
tr : instance of Transform
The transform to use. | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | def prepend(self, tr):
"""
Add a new transform to the beginning of this chain.
Parameters
----------
tr : instance of Transform
The transform to use.
"""
self.transforms.insert(0, tr)
tr.changed.connect(self._subtr_changed)
self._rebui... | def prepend(self, tr):
"""
Add a new transform to the beginning of this chain.
Parameters
----------
tr : instance of Transform
The transform to use.
"""
self.transforms.insert(0, tr)
tr.changed.connect(self._subtr_changed)
self._rebui... | [
"Add",
"a",
"new",
"transform",
"to",
"the",
"beginning",
"of",
"this",
"chain",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L195-L207 | [
"def",
"prepend",
"(",
"self",
",",
"tr",
")",
":",
"self",
".",
"transforms",
".",
"insert",
"(",
"0",
",",
"tr",
")",
"tr",
".",
"changed",
".",
"connect",
"(",
"self",
".",
"_subtr_changed",
")",
"self",
".",
"_rebuild_shaders",
"(",
")",
"self",
... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | SimplifiedChainTransform.source_changed | Generate a simplified chain by joining adjacent transforms. | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | def source_changed(self, event):
"""Generate a simplified chain by joining adjacent transforms.
"""
# bail out early if the chain is empty
transforms = self._chain.transforms[:]
if len(transforms) == 0:
self.transforms = []
return
# If the... | def source_changed(self, event):
"""Generate a simplified chain by joining adjacent transforms.
"""
# bail out early if the chain is empty
transforms = self._chain.transforms[:]
if len(transforms) == 0:
self.transforms = []
return
# If the... | [
"Generate",
"a",
"simplified",
"chain",
"by",
"joining",
"adjacent",
"transforms",
"."
] | glue-viz/glue-vispy-viewers | python | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L251-L295 | [
"def",
"source_changed",
"(",
"self",
",",
"event",
")",
":",
"# bail out early if the chain is empty",
"transforms",
"=",
"self",
".",
"_chain",
".",
"transforms",
"[",
":",
"]",
"if",
"len",
"(",
"transforms",
")",
"==",
"0",
":",
"self",
".",
"transforms"... | 54a4351d98c1f90dfb1a557d1b447c1f57470eea |
train | pack_iterable | Pack an iterable of messages in the TCP protocol format | nsq/util.py | def pack_iterable(messages):
'''Pack an iterable of messages in the TCP protocol format'''
# [ 4-byte body size ]
# [ 4-byte num messages ]
# [ 4-byte message #1 size ][ N-byte binary data ]
# ... (repeated <num_messages> times)
return pack_string(
struct.pack('>l', len(messages)) +... | def pack_iterable(messages):
'''Pack an iterable of messages in the TCP protocol format'''
# [ 4-byte body size ]
# [ 4-byte num messages ]
# [ 4-byte message #1 size ][ N-byte binary data ]
# ... (repeated <num_messages> times)
return pack_string(
struct.pack('>l', len(messages)) +... | [
"Pack",
"an",
"iterable",
"of",
"messages",
"in",
"the",
"TCP",
"protocol",
"format"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/util.py#L12-L20 | [
"def",
"pack_iterable",
"(",
"messages",
")",
":",
"# [ 4-byte body size ]",
"# [ 4-byte num messages ]",
"# [ 4-byte message #1 size ][ N-byte binary data ]",
"# ... (repeated <num_messages> times)",
"return",
"pack_string",
"(",
"struct",
".",
"pack",
"(",
"'>l'",
",",
"... | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | hexify | Print out printable characters, but others in hex | nsq/util.py | def hexify(message):
'''Print out printable characters, but others in hex'''
import string
hexified = []
for char in message:
if (char in '\n\r \t') or (char not in string.printable):
hexified.append('\\x%02x' % ord(char))
else:
hexified.append(char)
return ''... | def hexify(message):
'''Print out printable characters, but others in hex'''
import string
hexified = []
for char in message:
if (char in '\n\r \t') or (char not in string.printable):
hexified.append('\\x%02x' % ord(char))
else:
hexified.append(char)
return ''... | [
"Print",
"out",
"printable",
"characters",
"but",
"others",
"in",
"hex"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/util.py#L31-L40 | [
"def",
"hexify",
"(",
"message",
")",
":",
"import",
"string",
"hexified",
"=",
"[",
"]",
"for",
"char",
"in",
"message",
":",
"if",
"(",
"char",
"in",
"'\\n\\r \\t'",
")",
"or",
"(",
"char",
"not",
"in",
"string",
".",
"printable",
")",
":",
"hexifi... | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | distribute | Generator for (count, object) tuples that distributes count evenly among
the provided objects | nsq/util.py | def distribute(total, objects):
'''Generator for (count, object) tuples that distributes count evenly among
the provided objects'''
for index, obj in enumerate(objects):
start = (index * total) / len(objects)
stop = ((index + 1) * total) / len(objects)
yield (stop - start, obj) | def distribute(total, objects):
'''Generator for (count, object) tuples that distributes count evenly among
the provided objects'''
for index, obj in enumerate(objects):
start = (index * total) / len(objects)
stop = ((index + 1) * total) / len(objects)
yield (stop - start, obj) | [
"Generator",
"for",
"(",
"count",
"object",
")",
"tuples",
"that",
"distributes",
"count",
"evenly",
"among",
"the",
"provided",
"objects"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/util.py#L43-L49 | [
"def",
"distribute",
"(",
"total",
",",
"objects",
")",
":",
"for",
"index",
",",
"obj",
"in",
"enumerate",
"(",
"objects",
")",
":",
"start",
"=",
"(",
"index",
"*",
"total",
")",
"/",
"len",
"(",
"objects",
")",
"stop",
"=",
"(",
"(",
"index",
... | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | Queue.clean | Clean queue items from a previous session.
In case a previous session crashed and there are still some running
entries in the queue ('running', 'stopping', 'killing'), we clean those
and enqueue them again. | pueue/daemon/queue.py | def clean(self):
"""Clean queue items from a previous session.
In case a previous session crashed and there are still some running
entries in the queue ('running', 'stopping', 'killing'), we clean those
and enqueue them again.
"""
for _, item in self.queue.items():
... | def clean(self):
"""Clean queue items from a previous session.
In case a previous session crashed and there are still some running
entries in the queue ('running', 'stopping', 'killing'), we clean those
and enqueue them again.
"""
for _, item in self.queue.items():
... | [
"Clean",
"queue",
"items",
"from",
"a",
"previous",
"session",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L56-L67 | [
"def",
"clean",
"(",
"self",
")",
":",
"for",
"_",
",",
"item",
"in",
"self",
".",
"queue",
".",
"items",
"(",
")",
":",
"if",
"item",
"[",
"'status'",
"]",
"in",
"[",
"'paused'",
",",
"'running'",
",",
"'stopping'",
",",
"'killing'",
"]",
":",
"... | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | Queue.clear | Remove all completed tasks from the queue. | pueue/daemon/queue.py | def clear(self):
"""Remove all completed tasks from the queue."""
for key in list(self.queue.keys()):
if self.queue[key]['status'] in ['done', 'failed']:
del self.queue[key]
self.write() | def clear(self):
"""Remove all completed tasks from the queue."""
for key in list(self.queue.keys()):
if self.queue[key]['status'] in ['done', 'failed']:
del self.queue[key]
self.write() | [
"Remove",
"all",
"completed",
"tasks",
"from",
"the",
"queue",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L69-L74 | [
"def",
"clear",
"(",
"self",
")",
":",
"for",
"key",
"in",
"list",
"(",
"self",
".",
"queue",
".",
"keys",
"(",
")",
")",
":",
"if",
"self",
".",
"queue",
"[",
"key",
"]",
"[",
"'status'",
"]",
"in",
"[",
"'done'",
",",
"'failed'",
"]",
":",
... | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | Queue.next | Get the next processable item of the queue.
A processable item is supposed to have the status `queued`.
Returns:
None : If no key is found.
Int: If a valid entry is found. | pueue/daemon/queue.py | def next(self):
"""Get the next processable item of the queue.
A processable item is supposed to have the status `queued`.
Returns:
None : If no key is found.
Int: If a valid entry is found.
"""
smallest = None
for key in self.queue.keys():
... | def next(self):
"""Get the next processable item of the queue.
A processable item is supposed to have the status `queued`.
Returns:
None : If no key is found.
Int: If a valid entry is found.
"""
smallest = None
for key in self.queue.keys():
... | [
"Get",
"the",
"next",
"processable",
"item",
"of",
"the",
"queue",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L76-L91 | [
"def",
"next",
"(",
"self",
")",
":",
"smallest",
"=",
"None",
"for",
"key",
"in",
"self",
".",
"queue",
".",
"keys",
"(",
")",
":",
"if",
"self",
".",
"queue",
"[",
"key",
"]",
"[",
"'status'",
"]",
"==",
"'queued'",
":",
"if",
"smallest",
"is",... | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | Queue.read | Read the queue of the last pueue session or set `self.queue = {}`. | pueue/daemon/queue.py | def read(self):
"""Read the queue of the last pueue session or set `self.queue = {}`."""
queue_path = os.path.join(self.config_dir, 'queue')
if os.path.exists(queue_path):
queue_file = open(queue_path, 'rb')
try:
self.queue = pickle.load(queue_file)
... | def read(self):
"""Read the queue of the last pueue session or set `self.queue = {}`."""
queue_path = os.path.join(self.config_dir, 'queue')
if os.path.exists(queue_path):
queue_file = open(queue_path, 'rb')
try:
self.queue = pickle.load(queue_file)
... | [
"Read",
"the",
"queue",
"of",
"the",
"last",
"pueue",
"session",
"or",
"set",
"self",
".",
"queue",
"=",
"{}",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L93-L106 | [
"def",
"read",
"(",
"self",
")",
":",
"queue_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"config_dir",
",",
"'queue'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"queue_path",
")",
":",
"queue_file",
"=",
"open",
"(",
"queu... | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | Queue.write | Write the current queue to a file. We need this to continue an earlier session. | pueue/daemon/queue.py | def write(self):
"""Write the current queue to a file. We need this to continue an earlier session."""
queue_path = os.path.join(self.config_dir, 'queue')
queue_file = open(queue_path, 'wb+')
try:
pickle.dump(self.queue, queue_file, -1)
except Exception:
p... | def write(self):
"""Write the current queue to a file. We need this to continue an earlier session."""
queue_path = os.path.join(self.config_dir, 'queue')
queue_file = open(queue_path, 'wb+')
try:
pickle.dump(self.queue, queue_file, -1)
except Exception:
p... | [
"Write",
"the",
"current",
"queue",
"to",
"a",
"file",
".",
"We",
"need",
"this",
"to",
"continue",
"an",
"earlier",
"session",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L108-L116 | [
"def",
"write",
"(",
"self",
")",
":",
"queue_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"config_dir",
",",
"'queue'",
")",
"queue_file",
"=",
"open",
"(",
"queue_path",
",",
"'wb+'",
")",
"try",
":",
"pickle",
".",
"dump",
"(",
... | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | Queue.add_new | Add a new entry to the queue. | pueue/daemon/queue.py | def add_new(self, command):
"""Add a new entry to the queue."""
self.queue[self.next_key] = command
self.queue[self.next_key]['status'] = 'queued'
self.queue[self.next_key]['returncode'] = ''
self.queue[self.next_key]['stdout'] = ''
self.queue[self.next_key]['stderr'] = '... | def add_new(self, command):
"""Add a new entry to the queue."""
self.queue[self.next_key] = command
self.queue[self.next_key]['status'] = 'queued'
self.queue[self.next_key]['returncode'] = ''
self.queue[self.next_key]['stdout'] = ''
self.queue[self.next_key]['stderr'] = '... | [
"Add",
"a",
"new",
"entry",
"to",
"the",
"queue",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L118-L129 | [
"def",
"add_new",
"(",
"self",
",",
"command",
")",
":",
"self",
".",
"queue",
"[",
"self",
".",
"next_key",
"]",
"=",
"command",
"self",
".",
"queue",
"[",
"self",
".",
"next_key",
"]",
"[",
"'status'",
"]",
"=",
"'queued'",
"self",
".",
"queue",
... | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | Queue.remove | Remove a key from the queue, return `False` if no such key exists. | pueue/daemon/queue.py | def remove(self, key):
"""Remove a key from the queue, return `False` if no such key exists."""
if key in self.queue:
del self.queue[key]
self.write()
return True
return False | def remove(self, key):
"""Remove a key from the queue, return `False` if no such key exists."""
if key in self.queue:
del self.queue[key]
self.write()
return True
return False | [
"Remove",
"a",
"key",
"from",
"the",
"queue",
"return",
"False",
"if",
"no",
"such",
"key",
"exists",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L131-L137 | [
"def",
"remove",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"queue",
":",
"del",
"self",
".",
"queue",
"[",
"key",
"]",
"self",
".",
"write",
"(",
")",
"return",
"True",
"return",
"False"
] | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | Queue.restart | Restart a previously finished entry. | pueue/daemon/queue.py | def restart(self, key):
"""Restart a previously finished entry."""
if key in self.queue:
if self.queue[key]['status'] in ['failed', 'done']:
new_entry = {'command': self.queue[key]['command'],
'path': self.queue[key]['path']}
self.... | def restart(self, key):
"""Restart a previously finished entry."""
if key in self.queue:
if self.queue[key]['status'] in ['failed', 'done']:
new_entry = {'command': self.queue[key]['command'],
'path': self.queue[key]['path']}
self.... | [
"Restart",
"a",
"previously",
"finished",
"entry",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L139-L148 | [
"def",
"restart",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"queue",
":",
"if",
"self",
".",
"queue",
"[",
"key",
"]",
"[",
"'status'",
"]",
"in",
"[",
"'failed'",
",",
"'done'",
"]",
":",
"new_entry",
"=",
"{",
"'command... | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | Queue.switch | Switch two entries in the queue. Return False if an entry doesn't exist. | pueue/daemon/queue.py | def switch(self, first, second):
"""Switch two entries in the queue. Return False if an entry doesn't exist."""
allowed_states = ['queued', 'stashed']
if first in self.queue and second in self.queue \
and self.queue[first]['status'] in allowed_states\
and self.que... | def switch(self, first, second):
"""Switch two entries in the queue. Return False if an entry doesn't exist."""
allowed_states = ['queued', 'stashed']
if first in self.queue and second in self.queue \
and self.queue[first]['status'] in allowed_states\
and self.que... | [
"Switch",
"two",
"entries",
"in",
"the",
"queue",
".",
"Return",
"False",
"if",
"an",
"entry",
"doesn",
"t",
"exist",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/queue.py#L150-L162 | [
"def",
"switch",
"(",
"self",
",",
"first",
",",
"second",
")",
":",
"allowed_states",
"=",
"[",
"'queued'",
",",
"'stashed'",
"]",
"if",
"first",
"in",
"self",
".",
"queue",
"and",
"second",
"in",
"self",
".",
"queue",
"and",
"self",
".",
"queue",
"... | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | receive_data | Receive an answer from the daemon and return the response.
Args:
socket (socket.socket): A socket that is connected to the daemon.
Returns:
dir or string: The unpickled answer. | pueue/client/socket.py | def receive_data(socket):
"""Receive an answer from the daemon and return the response.
Args:
socket (socket.socket): A socket that is connected to the daemon.
Returns:
dir or string: The unpickled answer.
"""
answer = b""
while True:
packet = socket.recv(4096)
if n... | def receive_data(socket):
"""Receive an answer from the daemon and return the response.
Args:
socket (socket.socket): A socket that is connected to the daemon.
Returns:
dir or string: The unpickled answer.
"""
answer = b""
while True:
packet = socket.recv(4096)
if n... | [
"Receive",
"an",
"answer",
"from",
"the",
"daemon",
"and",
"return",
"the",
"response",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/socket.py#L7-L23 | [
"def",
"receive_data",
"(",
"socket",
")",
":",
"answer",
"=",
"b\"\"",
"while",
"True",
":",
"packet",
"=",
"socket",
".",
"recv",
"(",
"4096",
")",
"if",
"not",
"packet",
":",
"break",
"answer",
"+=",
"packet",
"response",
"=",
"pickle",
".",
"loads"... | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | connect_socket | Connect to a daemon's socket.
Args:
root_dir (str): The directory that used as root by the daemon.
Returns:
socket.socket: A socket that is connected to the daemon. | pueue/client/socket.py | def connect_socket(root_dir):
"""Connect to a daemon's socket.
Args:
root_dir (str): The directory that used as root by the daemon.
Returns:
socket.socket: A socket that is connected to the daemon.
"""
# Get config directory where the daemon socket is located
config_dir = os.pa... | def connect_socket(root_dir):
"""Connect to a daemon's socket.
Args:
root_dir (str): The directory that used as root by the daemon.
Returns:
socket.socket: A socket that is connected to the daemon.
"""
# Get config directory where the daemon socket is located
config_dir = os.pa... | [
"Connect",
"to",
"a",
"daemon",
"s",
"socket",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/socket.py#L34-L58 | [
"def",
"connect_socket",
"(",
"root_dir",
")",
":",
"# Get config directory where the daemon socket is located",
"config_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root_dir",
",",
"'.config/pueue'",
")",
"# Create Socket and exit with 1, if socket can't be created",
"tr... | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | Response.from_raw | Return a new response from a raw buffer | nsq/response.py | def from_raw(conn, raw):
'''Return a new response from a raw buffer'''
frame_type = struct.unpack('>l', raw[0:4])[0]
message = raw[4:]
if frame_type == FRAME_TYPE_MESSAGE:
return Message(conn, frame_type, message)
elif frame_type == FRAME_TYPE_RESPONSE:
re... | def from_raw(conn, raw):
'''Return a new response from a raw buffer'''
frame_type = struct.unpack('>l', raw[0:4])[0]
message = raw[4:]
if frame_type == FRAME_TYPE_MESSAGE:
return Message(conn, frame_type, message)
elif frame_type == FRAME_TYPE_RESPONSE:
re... | [
"Return",
"a",
"new",
"response",
"from",
"a",
"raw",
"buffer"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/response.py#L19-L30 | [
"def",
"from_raw",
"(",
"conn",
",",
"raw",
")",
":",
"frame_type",
"=",
"struct",
".",
"unpack",
"(",
"'>l'",
",",
"raw",
"[",
"0",
":",
"4",
"]",
")",
"[",
"0",
"]",
"message",
"=",
"raw",
"[",
"4",
":",
"]",
"if",
"frame_type",
"==",
"FRAME_... | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | Response.pack | Pack the provided data into a Response | nsq/response.py | def pack(cls, data):
'''Pack the provided data into a Response'''
return struct.pack('>ll', len(data) + 4, cls.FRAME_TYPE) + data | def pack(cls, data):
'''Pack the provided data into a Response'''
return struct.pack('>ll', len(data) + 4, cls.FRAME_TYPE) + data | [
"Pack",
"the",
"provided",
"data",
"into",
"a",
"Response"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/response.py#L33-L35 | [
"def",
"pack",
"(",
"cls",
",",
"data",
")",
":",
"return",
"struct",
".",
"pack",
"(",
"'>ll'",
",",
"len",
"(",
"data",
")",
"+",
"4",
",",
"cls",
".",
"FRAME_TYPE",
")",
"+",
"data"
] | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | Message.fin | Indicate that this message is finished processing | nsq/response.py | def fin(self):
'''Indicate that this message is finished processing'''
self.connection.fin(self.id)
self.processed = True | def fin(self):
'''Indicate that this message is finished processing'''
self.connection.fin(self.id)
self.processed = True | [
"Indicate",
"that",
"this",
"message",
"is",
"finished",
"processing"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/response.py#L86-L89 | [
"def",
"fin",
"(",
"self",
")",
":",
"self",
".",
"connection",
".",
"fin",
"(",
"self",
".",
"id",
")",
"self",
".",
"processed",
"=",
"True"
] | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | Message.req | Re-queue a message | nsq/response.py | def req(self, timeout):
'''Re-queue a message'''
self.connection.req(self.id, timeout)
self.processed = True | def req(self, timeout):
'''Re-queue a message'''
self.connection.req(self.id, timeout)
self.processed = True | [
"Re",
"-",
"queue",
"a",
"message"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/response.py#L91-L94 | [
"def",
"req",
"(",
"self",
",",
"timeout",
")",
":",
"self",
".",
"connection",
".",
"req",
"(",
"self",
".",
"id",
",",
"timeout",
")",
"self",
".",
"processed",
"=",
"True"
] | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | Message.handle | Make sure this message gets either 'fin' or 'req'd | nsq/response.py | def handle(self):
'''Make sure this message gets either 'fin' or 'req'd'''
try:
yield self
except:
# Requeue the message and raise the original exception
typ, value, trace = sys.exc_info()
if not self.processed:
try:
... | def handle(self):
'''Make sure this message gets either 'fin' or 'req'd'''
try:
yield self
except:
# Requeue the message and raise the original exception
typ, value, trace = sys.exc_info()
if not self.processed:
try:
... | [
"Make",
"sure",
"this",
"message",
"gets",
"either",
"fin",
"or",
"req",
"d"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/response.py#L105-L123 | [
"def",
"handle",
"(",
"self",
")",
":",
"try",
":",
"yield",
"self",
"except",
":",
"# Requeue the message and raise the original exception",
"typ",
",",
"value",
",",
"trace",
"=",
"sys",
".",
"exc_info",
"(",
")",
"if",
"not",
"self",
".",
"processed",
":"... | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | Error.find | Find the exception class by name | nsq/response.py | def find(cls, name):
'''Find the exception class by name'''
if not cls.mapping: # pragma: no branch
for _, obj in inspect.getmembers(exceptions):
if inspect.isclass(obj):
if issubclass(obj, exceptions.NSQException): # pragma: no branch
... | def find(cls, name):
'''Find the exception class by name'''
if not cls.mapping: # pragma: no branch
for _, obj in inspect.getmembers(exceptions):
if inspect.isclass(obj):
if issubclass(obj, exceptions.NSQException): # pragma: no branch
... | [
"Find",
"the",
"exception",
"class",
"by",
"name"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/response.py#L134-L145 | [
"def",
"find",
"(",
"cls",
",",
"name",
")",
":",
"if",
"not",
"cls",
".",
"mapping",
":",
"# pragma: no branch",
"for",
"_",
",",
"obj",
"in",
"inspect",
".",
"getmembers",
"(",
"exceptions",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"obj",
")... | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | Error.exception | Return an instance of the corresponding exception | nsq/response.py | def exception(self):
'''Return an instance of the corresponding exception'''
code, _, message = self.data.partition(' ')
return self.find(code)(message) | def exception(self):
'''Return an instance of the corresponding exception'''
code, _, message = self.data.partition(' ')
return self.find(code)(message) | [
"Return",
"an",
"instance",
"of",
"the",
"corresponding",
"exception"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/response.py#L147-L150 | [
"def",
"exception",
"(",
"self",
")",
":",
"code",
",",
"_",
",",
"message",
"=",
"self",
".",
"data",
".",
"partition",
"(",
"' '",
")",
"return",
"self",
".",
"find",
"(",
"code",
")",
"(",
"message",
")"
] | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | parse_gdb_version | r"""Parse the gdb version from the gdb header.
From GNU coding standards: the version starts after the last space of the
first line.
>>> DOCTEST_GDB_VERSIONS = [
... r'~"GNU gdb (GDB) 7.5.1\n"',
... r'~"GNU gdb (Sourcery CodeBench Lite 2011.09-69) 7.2.50.20100908-cvs\n"',
... r'~"GNU gdb (GDB)... | lib/pdb_clone/attach.py | def parse_gdb_version(line):
r"""Parse the gdb version from the gdb header.
From GNU coding standards: the version starts after the last space of the
first line.
>>> DOCTEST_GDB_VERSIONS = [
... r'~"GNU gdb (GDB) 7.5.1\n"',
... r'~"GNU gdb (Sourcery CodeBench Lite 2011.09-69) 7.2.50.20100908-c... | def parse_gdb_version(line):
r"""Parse the gdb version from the gdb header.
From GNU coding standards: the version starts after the last space of the
first line.
>>> DOCTEST_GDB_VERSIONS = [
... r'~"GNU gdb (GDB) 7.5.1\n"',
... r'~"GNU gdb (Sourcery CodeBench Lite 2011.09-69) 7.2.50.20100908-c... | [
"r",
"Parse",
"the",
"gdb",
"version",
"from",
"the",
"gdb",
"header",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/attach.py#L466-L497 | [
"def",
"parse_gdb_version",
"(",
"line",
")",
":",
"if",
"line",
".",
"startswith",
"(",
"'~\"'",
")",
"and",
"line",
".",
"endswith",
"(",
"r'\\n\"'",
")",
":",
"version",
"=",
"line",
"[",
"2",
":",
"-",
"3",
"]",
".",
"rsplit",
"(",
"' '",
",",
... | f781537c243a4874b246d43dbdef8c4279f0094d |
train | spawn_gdb | Spawn gdb and attach to a process. | lib/pdb_clone/attach.py | def spawn_gdb(pid, address=DFLT_ADDRESS, gdb='gdb', verbose=False,
ctx=None, proc_iut=None):
"""Spawn gdb and attach to a process."""
parent, child = socket.socketpair()
proc = Popen([gdb, '--interpreter=mi', '-nx'],
bufsize=0, stdin=child, stdout=child, stderr=STDOUT)
... | def spawn_gdb(pid, address=DFLT_ADDRESS, gdb='gdb', verbose=False,
ctx=None, proc_iut=None):
"""Spawn gdb and attach to a process."""
parent, child = socket.socketpair()
proc = Popen([gdb, '--interpreter=mi', '-nx'],
bufsize=0, stdin=child, stdout=child, stderr=STDOUT)
... | [
"Spawn",
"gdb",
"and",
"attach",
"to",
"a",
"process",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/attach.py#L503-L519 | [
"def",
"spawn_gdb",
"(",
"pid",
",",
"address",
"=",
"DFLT_ADDRESS",
",",
"gdb",
"=",
"'gdb'",
",",
"verbose",
"=",
"False",
",",
"ctx",
"=",
"None",
",",
"proc_iut",
"=",
"None",
")",
":",
"parent",
",",
"child",
"=",
"socket",
".",
"socketpair",
"(... | f781537c243a4874b246d43dbdef8c4279f0094d |
train | attach_loop | Spawn the process, then repeatedly attach to the process. | lib/pdb_clone/attach.py | def attach_loop(argv):
"""Spawn the process, then repeatedly attach to the process."""
# Check if the pdbhandler module is built into python.
p = Popen((sys.executable, '-X', 'pdbhandler', '-c',
'import pdbhandler; pdbhandler.get_handler().host'),
stdout=PIPE, stderr=STDOUT)
... | def attach_loop(argv):
"""Spawn the process, then repeatedly attach to the process."""
# Check if the pdbhandler module is built into python.
p = Popen((sys.executable, '-X', 'pdbhandler', '-c',
'import pdbhandler; pdbhandler.get_handler().host'),
stdout=PIPE, stderr=STDOUT)
... | [
"Spawn",
"the",
"process",
"then",
"repeatedly",
"attach",
"to",
"the",
"process",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/attach.py#L521-L570 | [
"def",
"attach_loop",
"(",
"argv",
")",
":",
"# Check if the pdbhandler module is built into python.",
"p",
"=",
"Popen",
"(",
"(",
"sys",
".",
"executable",
",",
"'-X'",
",",
"'pdbhandler'",
",",
"'-c'",
",",
"'import pdbhandler; pdbhandler.get_handler().host'",
")",
... | f781537c243a4874b246d43dbdef8c4279f0094d |
train | StatementLine.skip | Skip this py-pdb command to avoid attaching within the same loop. | lib/pdb_clone/attach.py | def skip(self):
"""Skip this py-pdb command to avoid attaching within the same loop."""
line = self.line
self.line = ''
# 'line' is the statement line of the previous py-pdb command.
if line in self.lines:
if not self.skipping:
self.skipping = True
... | def skip(self):
"""Skip this py-pdb command to avoid attaching within the same loop."""
line = self.line
self.line = ''
# 'line' is the statement line of the previous py-pdb command.
if line in self.lines:
if not self.skipping:
self.skipping = True
... | [
"Skip",
"this",
"py",
"-",
"pdb",
"command",
"to",
"avoid",
"attaching",
"within",
"the",
"same",
"loop",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/attach.py#L242-L259 | [
"def",
"skip",
"(",
"self",
")",
":",
"line",
"=",
"self",
".",
"line",
"self",
".",
"line",
"=",
"''",
"# 'line' is the statement line of the previous py-pdb command.",
"if",
"line",
"in",
"self",
".",
"lines",
":",
"if",
"not",
"self",
".",
"skipping",
":"... | f781537c243a4874b246d43dbdef8c4279f0094d |
train | Logger.rotate | Move the current log to a new file with timestamp and create a new empty log file. | pueue/daemon/logger.py | def rotate(self, log):
"""Move the current log to a new file with timestamp and create a new empty log file."""
self.write(log, rotate=True)
self.write({}) | def rotate(self, log):
"""Move the current log to a new file with timestamp and create a new empty log file."""
self.write(log, rotate=True)
self.write({}) | [
"Move",
"the",
"current",
"log",
"to",
"a",
"new",
"file",
"with",
"timestamp",
"and",
"create",
"a",
"new",
"empty",
"log",
"file",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/logger.py#L72-L75 | [
"def",
"rotate",
"(",
"self",
",",
"log",
")",
":",
"self",
".",
"write",
"(",
"log",
",",
"rotate",
"=",
"True",
")",
"self",
".",
"write",
"(",
"{",
"}",
")"
] | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | Logger.write | Write the output of all finished processes to a compiled log file. | pueue/daemon/logger.py | def write(self, log, rotate=False):
"""Write the output of all finished processes to a compiled log file."""
# Get path for logfile
if rotate:
timestamp = time.strftime('-%Y%m%d-%H%M')
logPath = os.path.join(self.log_dir, 'queue{}.log'.format(timestamp))
else:
... | def write(self, log, rotate=False):
"""Write the output of all finished processes to a compiled log file."""
# Get path for logfile
if rotate:
timestamp = time.strftime('-%Y%m%d-%H%M')
logPath = os.path.join(self.log_dir, 'queue{}.log'.format(timestamp))
else:
... | [
"Write",
"the",
"output",
"of",
"all",
"finished",
"processes",
"to",
"a",
"compiled",
"log",
"file",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/logger.py#L77-L129 | [
"def",
"write",
"(",
"self",
",",
"log",
",",
"rotate",
"=",
"False",
")",
":",
"# Get path for logfile",
"if",
"rotate",
":",
"timestamp",
"=",
"time",
".",
"strftime",
"(",
"'-%Y%m%d-%H%M'",
")",
"logPath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"... | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | Logger.remove_old | Remove all logs which are older than the specified time. | pueue/daemon/logger.py | def remove_old(self, max_log_time):
"""Remove all logs which are older than the specified time."""
files = glob.glob('{}/queue-*'.format(self.log_dir))
files = list(map(lambda x: os.path.basename(x), files))
for log_file in files:
# Get time stamp from filename
n... | def remove_old(self, max_log_time):
"""Remove all logs which are older than the specified time."""
files = glob.glob('{}/queue-*'.format(self.log_dir))
files = list(map(lambda x: os.path.basename(x), files))
for log_file in files:
# Get time stamp from filename
n... | [
"Remove",
"all",
"logs",
"which",
"are",
"older",
"than",
"the",
"specified",
"time",
"."
] | Nukesor/pueue | python | https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/logger.py#L131-L152 | [
"def",
"remove_old",
"(",
"self",
",",
"max_log_time",
")",
":",
"files",
"=",
"glob",
".",
"glob",
"(",
"'{}/queue-*'",
".",
"format",
"(",
"self",
".",
"log_dir",
")",
")",
"files",
"=",
"list",
"(",
"map",
"(",
"lambda",
"x",
":",
"os",
".",
"pa... | f1d276360454d4dd2738658a13df1e20caa4b926 |
train | wrap | Wrap a function that returns a request with some exception handling | nsq/http/__init__.py | def wrap(function, *args, **kwargs):
'''Wrap a function that returns a request with some exception handling'''
try:
req = function(*args, **kwargs)
logger.debug('Got %s: %s', req.status_code, req.content)
if req.status_code == 200:
return req
else:
raise C... | def wrap(function, *args, **kwargs):
'''Wrap a function that returns a request with some exception handling'''
try:
req = function(*args, **kwargs)
logger.debug('Got %s: %s', req.status_code, req.content)
if req.status_code == 200:
return req
else:
raise C... | [
"Wrap",
"a",
"function",
"that",
"returns",
"a",
"request",
"with",
"some",
"exception",
"handling"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/__init__.py#L12-L24 | [
"def",
"wrap",
"(",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"req",
"=",
"function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"logger",
".",
"debug",
"(",
"'Got %s: %s'",
",",
"req",
".",
"status_code",
... | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | json_wrap | Return the json content of a function that returns a request | nsq/http/__init__.py | def json_wrap(function, *args, **kwargs):
'''Return the json content of a function that returns a request'''
try:
# Some responses have data = None, but they generally signal a
# successful API call as well.
response = json.loads(function(*args, **kwargs).content)
if 'data' in re... | def json_wrap(function, *args, **kwargs):
'''Return the json content of a function that returns a request'''
try:
# Some responses have data = None, but they generally signal a
# successful API call as well.
response = json.loads(function(*args, **kwargs).content)
if 'data' in re... | [
"Return",
"the",
"json",
"content",
"of",
"a",
"function",
"that",
"returns",
"a",
"request"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/__init__.py#L28-L39 | [
"def",
"json_wrap",
"(",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"# Some responses have data = None, but they generally signal a",
"# successful API call as well.",
"response",
"=",
"json",
".",
"loads",
"(",
"function",
"(",
"*"... | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | ok_check | Ensure that the response body is OK | nsq/http/__init__.py | def ok_check(function, *args, **kwargs):
'''Ensure that the response body is OK'''
req = function(*args, **kwargs)
if req.content.lower() != 'ok':
raise ClientException(req.content)
return req.content | def ok_check(function, *args, **kwargs):
'''Ensure that the response body is OK'''
req = function(*args, **kwargs)
if req.content.lower() != 'ok':
raise ClientException(req.content)
return req.content | [
"Ensure",
"that",
"the",
"response",
"body",
"is",
"OK"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/__init__.py#L43-L48 | [
"def",
"ok_check",
"(",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"req",
"=",
"function",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"req",
".",
"content",
".",
"lower",
"(",
")",
"!=",
"'ok'",
":",
"raise",
"C... | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | BaseClient.get | GET the provided endpoint | nsq/http/__init__.py | def get(self, path, *args, **kwargs):
'''GET the provided endpoint'''
target = self._host.relative(path).utf8
if not isinstance(target, basestring):
# on older versions of the `url` library, .utf8 is a method, not a property
target = target()
params = kwargs.get('... | def get(self, path, *args, **kwargs):
'''GET the provided endpoint'''
target = self._host.relative(path).utf8
if not isinstance(target, basestring):
# on older versions of the `url` library, .utf8 is a method, not a property
target = target()
params = kwargs.get('... | [
"GET",
"the",
"provided",
"endpoint"
] | dlecocq/nsq-py | python | https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/__init__.py#L67-L77 | [
"def",
"get",
"(",
"self",
",",
"path",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"target",
"=",
"self",
".",
"_host",
".",
"relative",
"(",
"path",
")",
".",
"utf8",
"if",
"not",
"isinstance",
"(",
"target",
",",
"basestring",
")",
":... | 3ecacf6ab7719d38031179277113d875554a0c16 |
train | decode_resumable_upload_bitmap | Decodes bitmap_node to hash of unit_id: is_uploaded
bitmap_node -- bitmap node of resumable_upload with
'count' number and 'words' containing array
number_of_units -- number of units we are uploading to
define the number of bits for bitmap | mediafire/uploader.py | def decode_resumable_upload_bitmap(bitmap_node, number_of_units):
"""Decodes bitmap_node to hash of unit_id: is_uploaded
bitmap_node -- bitmap node of resumable_upload with
'count' number and 'words' containing array
number_of_units -- number of units we are uploading to
... | def decode_resumable_upload_bitmap(bitmap_node, number_of_units):
"""Decodes bitmap_node to hash of unit_id: is_uploaded
bitmap_node -- bitmap node of resumable_upload with
'count' number and 'words' containing array
number_of_units -- number of units we are uploading to
... | [
"Decodes",
"bitmap_node",
"to",
"hash",
"of",
"unit_id",
":",
"is_uploaded"
] | MediaFire/mediafire-python-open-sdk | python | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L117-L136 | [
"def",
"decode_resumable_upload_bitmap",
"(",
"bitmap_node",
",",
"number_of_units",
")",
":",
"bitmap",
"=",
"0",
"for",
"token_id",
"in",
"range",
"(",
"int",
"(",
"bitmap_node",
"[",
"'count'",
"]",
")",
")",
":",
"value",
"=",
"int",
"(",
"bitmap_node",
... | 8f1f23db1b16f16e026f5c6777aec32d00baa05f |
train | compute_hash_info | Get MediaFireHashInfo structure from the fd, unit_size
fd -- file descriptor - expects exclusive access because of seeking
unit_size -- size of a single unit
Returns MediaFireHashInfo:
hi.file -- sha256 of the whole file
hi.units -- list of sha256 hashes for each unit | mediafire/uploader.py | def compute_hash_info(fd, unit_size=None):
"""Get MediaFireHashInfo structure from the fd, unit_size
fd -- file descriptor - expects exclusive access because of seeking
unit_size -- size of a single unit
Returns MediaFireHashInfo:
hi.file -- sha256 of the whole file
hi.units -- list of sha256 ... | def compute_hash_info(fd, unit_size=None):
"""Get MediaFireHashInfo structure from the fd, unit_size
fd -- file descriptor - expects exclusive access because of seeking
unit_size -- size of a single unit
Returns MediaFireHashInfo:
hi.file -- sha256 of the whole file
hi.units -- list of sha256 ... | [
"Get",
"MediaFireHashInfo",
"structure",
"from",
"the",
"fd",
"unit_size"
] | MediaFire/mediafire-python-open-sdk | python | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L139-L184 | [
"def",
"compute_hash_info",
"(",
"fd",
",",
"unit_size",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"compute_hash_info(%s, unit_size=%s)\"",
",",
"fd",
",",
"unit_size",
")",
"fd",
".",
"seek",
"(",
"0",
",",
"os",
".",
"SEEK_END",
")",
"file_si... | 8f1f23db1b16f16e026f5c6777aec32d00baa05f |
train | MediaFireUploader.upload | Upload file, returns UploadResult object
fd -- file-like object to upload from, expects exclusive access
name -- file name
folder_key -- folderkey of the target folder
path -- path to file relative to folder_key
filedrop_key -- filedrop to use instead of folder_key
actio... | mediafire/uploader.py | def upload(self, fd, name=None, folder_key=None, filedrop_key=None,
path=None, action_on_duplicate=None):
"""Upload file, returns UploadResult object
fd -- file-like object to upload from, expects exclusive access
name -- file name
folder_key -- folderkey of the target fo... | def upload(self, fd, name=None, folder_key=None, filedrop_key=None,
path=None, action_on_duplicate=None):
"""Upload file, returns UploadResult object
fd -- file-like object to upload from, expects exclusive access
name -- file name
folder_key -- folderkey of the target fo... | [
"Upload",
"file",
"returns",
"UploadResult",
"object"
] | MediaFire/mediafire-python-open-sdk | python | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L198-L289 | [
"def",
"upload",
"(",
"self",
",",
"fd",
",",
"name",
"=",
"None",
",",
"folder_key",
"=",
"None",
",",
"filedrop_key",
"=",
"None",
",",
"path",
"=",
"None",
",",
"action_on_duplicate",
"=",
"None",
")",
":",
"# Get file handle content length in the most reli... | 8f1f23db1b16f16e026f5c6777aec32d00baa05f |
train | MediaFireUploader._poll_upload | Poll upload until quickkey is found
upload_key -- upload_key returned by upload/* functions | mediafire/uploader.py | def _poll_upload(self, upload_key, action):
"""Poll upload until quickkey is found
upload_key -- upload_key returned by upload/* functions
"""
if len(upload_key) != UPLOAD_KEY_LENGTH:
# not a regular 11-char-long upload key
# There is no API to poll filedrop upl... | def _poll_upload(self, upload_key, action):
"""Poll upload until quickkey is found
upload_key -- upload_key returned by upload/* functions
"""
if len(upload_key) != UPLOAD_KEY_LENGTH:
# not a regular 11-char-long upload key
# There is no API to poll filedrop upl... | [
"Poll",
"upload",
"until",
"quickkey",
"is",
"found"
] | MediaFire/mediafire-python-open-sdk | python | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L292-L351 | [
"def",
"_poll_upload",
"(",
"self",
",",
"upload_key",
",",
"action",
")",
":",
"if",
"len",
"(",
"upload_key",
")",
"!=",
"UPLOAD_KEY_LENGTH",
":",
"# not a regular 11-char-long upload key",
"# There is no API to poll filedrop uploads",
"return",
"UploadResult",
"(",
"... | 8f1f23db1b16f16e026f5c6777aec32d00baa05f |
train | MediaFireUploader._upload_check | Wrapper around upload/check | mediafire/uploader.py | def _upload_check(self, upload_info, resumable=False):
"""Wrapper around upload/check"""
return self._api.upload_check(
filename=upload_info.name,
size=upload_info.size,
hash_=upload_info.hash_info.file,
folder_key=upload_info.folder_key,
filed... | def _upload_check(self, upload_info, resumable=False):
"""Wrapper around upload/check"""
return self._api.upload_check(
filename=upload_info.name,
size=upload_info.size,
hash_=upload_info.hash_info.file,
folder_key=upload_info.folder_key,
filed... | [
"Wrapper",
"around",
"upload",
"/",
"check"
] | MediaFire/mediafire-python-open-sdk | python | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L353-L363 | [
"def",
"_upload_check",
"(",
"self",
",",
"upload_info",
",",
"resumable",
"=",
"False",
")",
":",
"return",
"self",
".",
"_api",
".",
"upload_check",
"(",
"filename",
"=",
"upload_info",
".",
"name",
",",
"size",
"=",
"upload_info",
".",
"size",
",",
"h... | 8f1f23db1b16f16e026f5c6777aec32d00baa05f |
train | MediaFireUploader._upload_none | Dummy upload function for when we don't actually upload | mediafire/uploader.py | def _upload_none(self, upload_info, check_result):
"""Dummy upload function for when we don't actually upload"""
return UploadResult(
action=None,
quickkey=check_result['duplicate_quickkey'],
hash_=upload_info.hash_info.file,
filename=upload_info.name,
... | def _upload_none(self, upload_info, check_result):
"""Dummy upload function for when we don't actually upload"""
return UploadResult(
action=None,
quickkey=check_result['duplicate_quickkey'],
hash_=upload_info.hash_info.file,
filename=upload_info.name,
... | [
"Dummy",
"upload",
"function",
"for",
"when",
"we",
"don",
"t",
"actually",
"upload"
] | MediaFire/mediafire-python-open-sdk | python | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L367-L377 | [
"def",
"_upload_none",
"(",
"self",
",",
"upload_info",
",",
"check_result",
")",
":",
"return",
"UploadResult",
"(",
"action",
"=",
"None",
",",
"quickkey",
"=",
"check_result",
"[",
"'duplicate_quickkey'",
"]",
",",
"hash_",
"=",
"upload_info",
".",
"hash_in... | 8f1f23db1b16f16e026f5c6777aec32d00baa05f |
train | MediaFireUploader._upload_instant | Instant upload and return quickkey
Can be used when the file is already stored somewhere in MediaFire
upload_info -- UploadInfo object
check_result -- ignored | mediafire/uploader.py | def _upload_instant(self, upload_info, _=None):
"""Instant upload and return quickkey
Can be used when the file is already stored somewhere in MediaFire
upload_info -- UploadInfo object
check_result -- ignored
"""
result = self._api.upload_instant(
upload_i... | def _upload_instant(self, upload_info, _=None):
"""Instant upload and return quickkey
Can be used when the file is already stored somewhere in MediaFire
upload_info -- UploadInfo object
check_result -- ignored
"""
result = self._api.upload_instant(
upload_i... | [
"Instant",
"upload",
"and",
"return",
"quickkey"
] | MediaFire/mediafire-python-open-sdk | python | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L380-L407 | [
"def",
"_upload_instant",
"(",
"self",
",",
"upload_info",
",",
"_",
"=",
"None",
")",
":",
"result",
"=",
"self",
".",
"_api",
".",
"upload_instant",
"(",
"upload_info",
".",
"name",
",",
"upload_info",
".",
"size",
",",
"upload_info",
".",
"hash_info",
... | 8f1f23db1b16f16e026f5c6777aec32d00baa05f |
train | MediaFireUploader._upload_simple | Simple upload and return quickkey
Can be used for small files smaller than UPLOAD_SIMPLE_LIMIT_BYTES
upload_info -- UploadInfo object
check_result -- ignored | mediafire/uploader.py | def _upload_simple(self, upload_info, _=None):
"""Simple upload and return quickkey
Can be used for small files smaller than UPLOAD_SIMPLE_LIMIT_BYTES
upload_info -- UploadInfo object
check_result -- ignored
"""
upload_result = self._api.upload_simple(
uplo... | def _upload_simple(self, upload_info, _=None):
"""Simple upload and return quickkey
Can be used for small files smaller than UPLOAD_SIMPLE_LIMIT_BYTES
upload_info -- UploadInfo object
check_result -- ignored
"""
upload_result = self._api.upload_simple(
uplo... | [
"Simple",
"upload",
"and",
"return",
"quickkey"
] | MediaFire/mediafire-python-open-sdk | python | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L409-L432 | [
"def",
"_upload_simple",
"(",
"self",
",",
"upload_info",
",",
"_",
"=",
"None",
")",
":",
"upload_result",
"=",
"self",
".",
"_api",
".",
"upload_simple",
"(",
"upload_info",
".",
"fd",
",",
"upload_info",
".",
"name",
",",
"folder_key",
"=",
"upload_info... | 8f1f23db1b16f16e026f5c6777aec32d00baa05f |
train | MediaFireUploader._upload_resumable_unit | Upload a single unit and return raw upload/resumable result
uu_info -- UploadUnitInfo instance | mediafire/uploader.py | def _upload_resumable_unit(self, uu_info):
"""Upload a single unit and return raw upload/resumable result
uu_info -- UploadUnitInfo instance
"""
# Get actual unit size
unit_size = uu_info.fd.len
if uu_info.hash_ is None:
raise ValueError('UploadUnitInfo.has... | def _upload_resumable_unit(self, uu_info):
"""Upload a single unit and return raw upload/resumable result
uu_info -- UploadUnitInfo instance
"""
# Get actual unit size
unit_size = uu_info.fd.len
if uu_info.hash_ is None:
raise ValueError('UploadUnitInfo.has... | [
"Upload",
"a",
"single",
"unit",
"and",
"return",
"raw",
"upload",
"/",
"resumable",
"result"
] | MediaFire/mediafire-python-open-sdk | python | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L434-L456 | [
"def",
"_upload_resumable_unit",
"(",
"self",
",",
"uu_info",
")",
":",
"# Get actual unit size",
"unit_size",
"=",
"uu_info",
".",
"fd",
".",
"len",
"if",
"uu_info",
".",
"hash_",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'UploadUnitInfo.hash_ is now requir... | 8f1f23db1b16f16e026f5c6777aec32d00baa05f |
train | MediaFireUploader._upload_resumable_all | Prepare and upload all resumable units and return upload_key
upload_info -- UploadInfo object
bitmap -- bitmap node of upload/check
number_of_units -- number of units requested
unit_size -- size of a single upload unit in bytes | mediafire/uploader.py | def _upload_resumable_all(self, upload_info, bitmap,
number_of_units, unit_size):
"""Prepare and upload all resumable units and return upload_key
upload_info -- UploadInfo object
bitmap -- bitmap node of upload/check
number_of_units -- number of units reque... | def _upload_resumable_all(self, upload_info, bitmap,
number_of_units, unit_size):
"""Prepare and upload all resumable units and return upload_key
upload_info -- UploadInfo object
bitmap -- bitmap node of upload/check
number_of_units -- number of units reque... | [
"Prepare",
"and",
"upload",
"all",
"resumable",
"units",
"and",
"return",
"upload_key"
] | MediaFire/mediafire-python-open-sdk | python | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L458-L500 | [
"def",
"_upload_resumable_all",
"(",
"self",
",",
"upload_info",
",",
"bitmap",
",",
"number_of_units",
",",
"unit_size",
")",
":",
"fd",
"=",
"upload_info",
".",
"fd",
"upload_key",
"=",
"None",
"for",
"unit_id",
"in",
"range",
"(",
"number_of_units",
")",
... | 8f1f23db1b16f16e026f5c6777aec32d00baa05f |
train | MediaFireUploader._upload_resumable | Resumable upload and return quickkey
upload_info -- UploadInfo object
check_result -- dict of upload/check call result | mediafire/uploader.py | def _upload_resumable(self, upload_info, check_result):
"""Resumable upload and return quickkey
upload_info -- UploadInfo object
check_result -- dict of upload/check call result
"""
resumable_upload = check_result['resumable_upload']
unit_size = int(resumable_upload['u... | def _upload_resumable(self, upload_info, check_result):
"""Resumable upload and return quickkey
upload_info -- UploadInfo object
check_result -- dict of upload/check call result
"""
resumable_upload = check_result['resumable_upload']
unit_size = int(resumable_upload['u... | [
"Resumable",
"upload",
"and",
"return",
"quickkey"
] | MediaFire/mediafire-python-open-sdk | python | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/uploader.py#L502-L549 | [
"def",
"_upload_resumable",
"(",
"self",
",",
"upload_info",
",",
"check_result",
")",
":",
"resumable_upload",
"=",
"check_result",
"[",
"'resumable_upload'",
"]",
"unit_size",
"=",
"int",
"(",
"resumable_upload",
"[",
"'unit_size'",
"]",
")",
"number_of_units",
... | 8f1f23db1b16f16e026f5c6777aec32d00baa05f |
train | ModuleFinder.reset | Remove from sys.modules the modules imported by the debuggee. | lib/pdb_clone/bdb.py | def reset(self):
"""Remove from sys.modules the modules imported by the debuggee."""
if not self.hooked:
self.hooked = True
sys.path_hooks.append(self)
sys.path.insert(0, self.PATH_ENTRY)
return
for modname in self:
if modname in sys.m... | def reset(self):
"""Remove from sys.modules the modules imported by the debuggee."""
if not self.hooked:
self.hooked = True
sys.path_hooks.append(self)
sys.path.insert(0, self.PATH_ENTRY)
return
for modname in self:
if modname in sys.m... | [
"Remove",
"from",
"sys",
".",
"modules",
"the",
"modules",
"imported",
"by",
"the",
"debuggee",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/bdb.py#L56-L76 | [
"def",
"reset",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"hooked",
":",
"self",
".",
"hooked",
"=",
"True",
"sys",
".",
"path_hooks",
".",
"append",
"(",
"self",
")",
"sys",
".",
"path",
".",
"insert",
"(",
"0",
",",
"self",
".",
"PATH_EN... | f781537c243a4874b246d43dbdef8c4279f0094d |
train | BdbModule.get_func_lno | The first line number of the last defined 'funcname' function. | lib/pdb_clone/bdb.py | def get_func_lno(self, funcname):
"""The first line number of the last defined 'funcname' function."""
class FuncLineno(ast.NodeVisitor):
def __init__(self):
self.clss = []
def generic_visit(self, node):
for child in ast.iter_child_nodes(node):
... | def get_func_lno(self, funcname):
"""The first line number of the last defined 'funcname' function."""
class FuncLineno(ast.NodeVisitor):
def __init__(self):
self.clss = []
def generic_visit(self, node):
for child in ast.iter_child_nodes(node):
... | [
"The",
"first",
"line",
"number",
"of",
"the",
"last",
"defined",
"funcname",
"function",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/bdb.py#L255-L288 | [
"def",
"get_func_lno",
"(",
"self",
",",
"funcname",
")",
":",
"class",
"FuncLineno",
"(",
"ast",
".",
"NodeVisitor",
")",
":",
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"clss",
"=",
"[",
"]",
"def",
"generic_visit",
"(",
"self",
",",
"n... | f781537c243a4874b246d43dbdef8c4279f0094d |
train | BdbModule.get_actual_bp | Get the actual breakpoint line number.
When an exact match cannot be found in the lnotab expansion of the
module code object or one of its subcodes, pick up the next valid
statement line number.
Return the statement line defined by the tuple (code firstlineno,
statement line nu... | lib/pdb_clone/bdb.py | def get_actual_bp(self, lineno):
"""Get the actual breakpoint line number.
When an exact match cannot be found in the lnotab expansion of the
module code object or one of its subcodes, pick up the next valid
statement line number.
Return the statement line defined by the tuple ... | def get_actual_bp(self, lineno):
"""Get the actual breakpoint line number.
When an exact match cannot be found in the lnotab expansion of the
module code object or one of its subcodes, pick up the next valid
statement line number.
Return the statement line defined by the tuple ... | [
"Get",
"the",
"actual",
"breakpoint",
"line",
"number",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/bdb.py#L290-L349 | [
"def",
"get_actual_bp",
"(",
"self",
",",
"lineno",
")",
":",
"def",
"_distance",
"(",
"code",
",",
"module_level",
"=",
"False",
")",
":",
"\"\"\"The shortest distance to the next valid statement.\"\"\"",
"subcodes",
"=",
"dict",
"(",
"(",
"c",
".",
"co_firstline... | f781537c243a4874b246d43dbdef8c4279f0094d |
train | ModuleBreakpoints.get_breakpoints | Return the list of breakpoints set at lineno. | lib/pdb_clone/bdb.py | def get_breakpoints(self, lineno):
"""Return the list of breakpoints set at lineno."""
try:
firstlineno, actual_lno = self.bdb_module.get_actual_bp(lineno)
except BdbSourceError:
return []
if firstlineno not in self:
return []
code_bps = self[f... | def get_breakpoints(self, lineno):
"""Return the list of breakpoints set at lineno."""
try:
firstlineno, actual_lno = self.bdb_module.get_actual_bp(lineno)
except BdbSourceError:
return []
if firstlineno not in self:
return []
code_bps = self[f... | [
"Return",
"the",
"list",
"of",
"breakpoints",
"set",
"at",
"lineno",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/bdb.py#L417-L429 | [
"def",
"get_breakpoints",
"(",
"self",
",",
"lineno",
")",
":",
"try",
":",
"firstlineno",
",",
"actual_lno",
"=",
"self",
".",
"bdb_module",
".",
"get_actual_bp",
"(",
"lineno",
")",
"except",
"BdbSourceError",
":",
"return",
"[",
"]",
"if",
"firstlineno",
... | f781537c243a4874b246d43dbdef8c4279f0094d |
train | Tracer.settrace | Set or remove the trace function. | lib/pdb_clone/bdb.py | def settrace(self, do_set):
"""Set or remove the trace function."""
if do_set:
sys.settrace(self.trace_dispatch)
else:
sys.settrace(None) | def settrace(self, do_set):
"""Set or remove the trace function."""
if do_set:
sys.settrace(self.trace_dispatch)
else:
sys.settrace(None) | [
"Set",
"or",
"remove",
"the",
"trace",
"function",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/bdb.py#L587-L592 | [
"def",
"settrace",
"(",
"self",
",",
"do_set",
")",
":",
"if",
"do_set",
":",
"sys",
".",
"settrace",
"(",
"self",
".",
"trace_dispatch",
")",
"else",
":",
"sys",
".",
"settrace",
"(",
"None",
")"
] | f781537c243a4874b246d43dbdef8c4279f0094d |
train | Bdb.restart | Restart the debugger after source code changes. | lib/pdb_clone/bdb.py | def restart(self):
"""Restart the debugger after source code changes."""
_module_finder.reset()
linecache.checkcache()
for module_bpts in self.breakpoints.values():
module_bpts.reset() | def restart(self):
"""Restart the debugger after source code changes."""
_module_finder.reset()
linecache.checkcache()
for module_bpts in self.breakpoints.values():
module_bpts.reset() | [
"Restart",
"the",
"debugger",
"after",
"source",
"code",
"changes",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/bdb.py#L631-L636 | [
"def",
"restart",
"(",
"self",
")",
":",
"_module_finder",
".",
"reset",
"(",
")",
"linecache",
".",
"checkcache",
"(",
")",
"for",
"module_bpts",
"in",
"self",
".",
"breakpoints",
".",
"values",
"(",
")",
":",
"module_bpts",
".",
"reset",
"(",
")"
] | f781537c243a4874b246d43dbdef8c4279f0094d |
train | Bdb.set_until | Stop when the current line number in frame is greater than lineno or
when returning from frame. | lib/pdb_clone/bdb.py | def set_until(self, frame, lineno=None):
"""Stop when the current line number in frame is greater than lineno or
when returning from frame."""
if lineno is None:
lineno = frame.f_lineno + 1
self._set_stopinfo(frame, lineno) | def set_until(self, frame, lineno=None):
"""Stop when the current line number in frame is greater than lineno or
when returning from frame."""
if lineno is None:
lineno = frame.f_lineno + 1
self._set_stopinfo(frame, lineno) | [
"Stop",
"when",
"the",
"current",
"line",
"number",
"in",
"frame",
"is",
"greater",
"than",
"lineno",
"or",
"when",
"returning",
"from",
"frame",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/bdb.py#L713-L718 | [
"def",
"set_until",
"(",
"self",
",",
"frame",
",",
"lineno",
"=",
"None",
")",
":",
"if",
"lineno",
"is",
"None",
":",
"lineno",
"=",
"frame",
".",
"f_lineno",
"+",
"1",
"self",
".",
"_set_stopinfo",
"(",
"frame",
",",
"lineno",
")"
] | f781537c243a4874b246d43dbdef8c4279f0094d |
train | Bdb.set_trace | Start debugging from `frame`.
If frame is not specified, debugging starts from caller's frame. | lib/pdb_clone/bdb.py | def set_trace(self, frame=None):
"""Start debugging from `frame`.
If frame is not specified, debugging starts from caller's frame.
"""
# First disable tracing temporarily as set_trace() may be called while
# tracing is in use. For example when called from a signal handler and
... | def set_trace(self, frame=None):
"""Start debugging from `frame`.
If frame is not specified, debugging starts from caller's frame.
"""
# First disable tracing temporarily as set_trace() may be called while
# tracing is in use. For example when called from a signal handler and
... | [
"Start",
"debugging",
"from",
"frame",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/bdb.py#L732-L763 | [
"def",
"set_trace",
"(",
"self",
",",
"frame",
"=",
"None",
")",
":",
"# First disable tracing temporarily as set_trace() may be called while",
"# tracing is in use. For example when called from a signal handler and",
"# within a debugging session started with runcall().",
"self",
".",
... | f781537c243a4874b246d43dbdef8c4279f0094d |
train | Breakpoint.process_hit_event | Return (stop_state, delete_temporary) at a breakpoint hit event. | lib/pdb_clone/bdb.py | def process_hit_event(self, frame):
"""Return (stop_state, delete_temporary) at a breakpoint hit event."""
if not self.enabled:
return False, False
# Count every hit when breakpoint is enabled.
self.hits += 1
# A conditional breakpoint.
if self.cond:
... | def process_hit_event(self, frame):
"""Return (stop_state, delete_temporary) at a breakpoint hit event."""
if not self.enabled:
return False, False
# Count every hit when breakpoint is enabled.
self.hits += 1
# A conditional breakpoint.
if self.cond:
... | [
"Return",
"(",
"stop_state",
"delete_temporary",
")",
"at",
"a",
"breakpoint",
"hit",
"event",
"."
] | corpusops/pdbclone | python | https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/bdb.py#L1061-L1080 | [
"def",
"process_hit_event",
"(",
"self",
",",
"frame",
")",
":",
"if",
"not",
"self",
".",
"enabled",
":",
"return",
"False",
",",
"False",
"# Count every hit when breakpoint is enabled.",
"self",
".",
"hits",
"+=",
"1",
"# A conditional breakpoint.",
"if",
"self"... | f781537c243a4874b246d43dbdef8c4279f0094d |
train | listdir | Returns list of nested files and directories for local directory by path
:param directory: absolute or relative path to local directory
:return: list nested of file or directory names | src/webdav/client.py | def listdir(directory):
"""Returns list of nested files and directories for local directory by path
:param directory: absolute or relative path to local directory
:return: list nested of file or directory names
"""
file_names = list()
for filename in os.listdir(directory):
file_path = o... | def listdir(directory):
"""Returns list of nested files and directories for local directory by path
:param directory: absolute or relative path to local directory
:return: list nested of file or directory names
"""
file_names = list()
for filename in os.listdir(directory):
file_path = o... | [
"Returns",
"list",
"of",
"nested",
"files",
"and",
"directories",
"for",
"local",
"directory",
"by",
"path"
] | kamikaze/webdav | python | https://github.com/kamikaze/webdav/blob/6facff7224023d3e28c8e1592f3c58401c91a0e6/src/webdav/client.py#L28-L40 | [
"def",
"listdir",
"(",
"directory",
")",
":",
"file_names",
"=",
"list",
"(",
")",
"for",
"filename",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
":",
"file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"filename",
")",
"i... | 6facff7224023d3e28c8e1592f3c58401c91a0e6 |
train | get_options | Extract options for specified option type from all options
:param option_type: the object of specified type of options
:param from_options: all options dictionary
:return: the dictionary of options for specified type, each option can be filled by value from all options
dictionary or blank in c... | src/webdav/client.py | def get_options(option_type, from_options):
"""Extract options for specified option type from all options
:param option_type: the object of specified type of options
:param from_options: all options dictionary
:return: the dictionary of options for specified type, each option can be filled by value fro... | def get_options(option_type, from_options):
"""Extract options for specified option type from all options
:param option_type: the object of specified type of options
:param from_options: all options dictionary
:return: the dictionary of options for specified type, each option can be filled by value fro... | [
"Extract",
"options",
"for",
"specified",
"option",
"type",
"from",
"all",
"options"
] | kamikaze/webdav | python | https://github.com/kamikaze/webdav/blob/6facff7224023d3e28c8e1592f3c58401c91a0e6/src/webdav/client.py#L43-L62 | [
"def",
"get_options",
"(",
"option_type",
",",
"from_options",
")",
":",
"_options",
"=",
"dict",
"(",
")",
"for",
"key",
"in",
"option_type",
".",
"keys",
":",
"key_with_prefix",
"=",
"f'{option_type.prefix}{key}'",
"if",
"key",
"not",
"in",
"from_options",
"... | 6facff7224023d3e28c8e1592f3c58401c91a0e6 |
train | Client.get_headers | Returns HTTP headers of specified WebDAV actions.
:param action: the identifier of action.
:param headers_ext: (optional) the addition headers list witch sgould be added to basic HTTP headers for
the specified action.
:return: the dictionary of headers for specified ... | src/webdav/client.py | def get_headers(self, action, headers_ext=None):
"""Returns HTTP headers of specified WebDAV actions.
:param action: the identifier of action.
:param headers_ext: (optional) the addition headers list witch sgould be added to basic HTTP headers for
the specified actio... | def get_headers(self, action, headers_ext=None):
"""Returns HTTP headers of specified WebDAV actions.
:param action: the identifier of action.
:param headers_ext: (optional) the addition headers list witch sgould be added to basic HTTP headers for
the specified actio... | [
"Returns",
"HTTP",
"headers",
"of",
"specified",
"WebDAV",
"actions",
"."
] | kamikaze/webdav | python | https://github.com/kamikaze/webdav/blob/6facff7224023d3e28c8e1592f3c58401c91a0e6/src/webdav/client.py#L107-L129 | [
"def",
"get_headers",
"(",
"self",
",",
"action",
",",
"headers_ext",
"=",
"None",
")",
":",
"if",
"action",
"in",
"Client",
".",
"http_header",
":",
"try",
":",
"headers",
"=",
"Client",
".",
"http_header",
"[",
"action",
"]",
".",
"copy",
"(",
")",
... | 6facff7224023d3e28c8e1592f3c58401c91a0e6 |
train | Client.execute_request | Generate request to WebDAV server for specified action and path and execute it.
:param action: the action for WebDAV server which should be executed.
:param path: the path to resource for action
:param data: (optional) Dictionary or list of tuples ``[(key, value)]`` (will be form-encoded), byte... | src/webdav/client.py | def execute_request(self, action, path, data=None, headers_ext=None):
"""Generate request to WebDAV server for specified action and path and execute it.
:param action: the action for WebDAV server which should be executed.
:param path: the path to resource for action
:param data: (optio... | def execute_request(self, action, path, data=None, headers_ext=None):
"""Generate request to WebDAV server for specified action and path and execute it.
:param action: the action for WebDAV server which should be executed.
:param path: the path to resource for action
:param data: (optio... | [
"Generate",
"request",
"to",
"WebDAV",
"server",
"for",
"specified",
"action",
"and",
"path",
"and",
"execute",
"it",
"."
] | kamikaze/webdav | python | https://github.com/kamikaze/webdav/blob/6facff7224023d3e28c8e1592f3c58401c91a0e6/src/webdav/client.py#L147-L172 | [
"def",
"execute_request",
"(",
"self",
",",
"action",
",",
"path",
",",
"data",
"=",
"None",
",",
"headers_ext",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"session",
".",
"request",
"(",
"method",
"=",
"Client",
".",
"requests",
"[",
"action... | 6facff7224023d3e28c8e1592f3c58401c91a0e6 |
train | Client.valid | Validates of WebDAV and proxy settings.
:return: True in case settings are valid and False otherwise. | src/webdav/client.py | def valid(self):
"""Validates of WebDAV and proxy settings.
:return: True in case settings are valid and False otherwise.
"""
return True if self.webdav.valid() and self.proxy.valid() else False | def valid(self):
"""Validates of WebDAV and proxy settings.
:return: True in case settings are valid and False otherwise.
"""
return True if self.webdav.valid() and self.proxy.valid() else False | [
"Validates",
"of",
"WebDAV",
"and",
"proxy",
"settings",
"."
] | kamikaze/webdav | python | https://github.com/kamikaze/webdav/blob/6facff7224023d3e28c8e1592f3c58401c91a0e6/src/webdav/client.py#L227-L232 | [
"def",
"valid",
"(",
"self",
")",
":",
"return",
"True",
"if",
"self",
".",
"webdav",
".",
"valid",
"(",
")",
"and",
"self",
".",
"proxy",
".",
"valid",
"(",
")",
"else",
"False"
] | 6facff7224023d3e28c8e1592f3c58401c91a0e6 |
train | Client.list | Returns list of nested files and directories for remote WebDAV directory by path.
More information you can find by link http://webdav.org/specs/rfc4918.html#METHOD_PROPFIND
:param remote_path: path to remote directory.
:return: list of nested file or directory names. | src/webdav/client.py | def list(self, remote_path=root):
"""Returns list of nested files and directories for remote WebDAV directory by path.
More information you can find by link http://webdav.org/specs/rfc4918.html#METHOD_PROPFIND
:param remote_path: path to remote directory.
:return: list of nested file or... | def list(self, remote_path=root):
"""Returns list of nested files and directories for remote WebDAV directory by path.
More information you can find by link http://webdav.org/specs/rfc4918.html#METHOD_PROPFIND
:param remote_path: path to remote directory.
:return: list of nested file or... | [
"Returns",
"list",
"of",
"nested",
"files",
"and",
"directories",
"for",
"remote",
"WebDAV",
"directory",
"by",
"path",
".",
"More",
"information",
"you",
"can",
"find",
"by",
"link",
"http",
":",
"//",
"webdav",
".",
"org",
"/",
"specs",
"/",
"rfc4918",
... | kamikaze/webdav | python | https://github.com/kamikaze/webdav/blob/6facff7224023d3e28c8e1592f3c58401c91a0e6/src/webdav/client.py#L235-L251 | [
"def",
"list",
"(",
"self",
",",
"remote_path",
"=",
"root",
")",
":",
"directory_urn",
"=",
"Urn",
"(",
"remote_path",
",",
"directory",
"=",
"True",
")",
"if",
"directory_urn",
".",
"path",
"(",
")",
"!=",
"Client",
".",
"root",
":",
"if",
"not",
"... | 6facff7224023d3e28c8e1592f3c58401c91a0e6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.