repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
hover2pi/svo_filters | svo_filters/svo.py | Filter.bin | def bin(self, n_bins=1, pixels_per_bin=None, wave_min=None, wave_max=None):
"""
Break the filter up into bins and apply a throughput to each bin,
useful for G141, G102, and other grisms
Parameters
----------
n_bins: int
The number of bins to dice the throughp... | python | def bin(self, n_bins=1, pixels_per_bin=None, wave_min=None, wave_max=None):
"""
Break the filter up into bins and apply a throughput to each bin,
useful for G141, G102, and other grisms
Parameters
----------
n_bins: int
The number of bins to dice the throughp... | [
"def",
"bin",
"(",
"self",
",",
"n_bins",
"=",
"1",
",",
"pixels_per_bin",
"=",
"None",
",",
"wave_min",
"=",
"None",
",",
"wave_max",
"=",
"None",
")",
":",
"if",
"wave_min",
"is",
"not",
"None",
":",
"self",
".",
"wave_min",
"=",
"wave_min",
"if",
... | Break the filter up into bins and apply a throughput to each bin,
useful for G141, G102, and other grisms
Parameters
----------
n_bins: int
The number of bins to dice the throughput curve into
pixels_per_bin: int (optional)
The number of channels per bin,... | [
"Break",
"the",
"filter",
"up",
"into",
"bins",
"and",
"apply",
"a",
"throughput",
"to",
"each",
"bin",
"useful",
"for",
"G141",
"G102",
"and",
"other",
"grisms"
] | f0587c4908baf636d4bdf030fa95029e8f31b975 | https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L326-L376 | train |
hover2pi/svo_filters | svo_filters/svo.py | Filter.centers | def centers(self):
"""A getter for the wavelength bin centers and average fluxes"""
# Get the bin centers
w_cen = np.nanmean(self.wave.value, axis=1)
f_cen = np.nanmean(self.throughput, axis=1)
return np.asarray([w_cen, f_cen]) | python | def centers(self):
"""A getter for the wavelength bin centers and average fluxes"""
# Get the bin centers
w_cen = np.nanmean(self.wave.value, axis=1)
f_cen = np.nanmean(self.throughput, axis=1)
return np.asarray([w_cen, f_cen]) | [
"def",
"centers",
"(",
"self",
")",
":",
"w_cen",
"=",
"np",
".",
"nanmean",
"(",
"self",
".",
"wave",
".",
"value",
",",
"axis",
"=",
"1",
")",
"f_cen",
"=",
"np",
".",
"nanmean",
"(",
"self",
".",
"throughput",
",",
"axis",
"=",
"1",
")",
"re... | A getter for the wavelength bin centers and average fluxes | [
"A",
"getter",
"for",
"the",
"wavelength",
"bin",
"centers",
"and",
"average",
"fluxes"
] | f0587c4908baf636d4bdf030fa95029e8f31b975 | https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L379-L385 | train |
hover2pi/svo_filters | svo_filters/svo.py | Filter.flux_units | def flux_units(self, units):
"""
A setter for the flux units
Parameters
----------
units: str, astropy.units.core.PrefixUnit
The desired units of the zeropoint flux density
"""
# Check that the units are valid
dtypes = (q.core.PrefixUnit, q.qu... | python | def flux_units(self, units):
"""
A setter for the flux units
Parameters
----------
units: str, astropy.units.core.PrefixUnit
The desired units of the zeropoint flux density
"""
# Check that the units are valid
dtypes = (q.core.PrefixUnit, q.qu... | [
"def",
"flux_units",
"(",
"self",
",",
"units",
")",
":",
"dtypes",
"=",
"(",
"q",
".",
"core",
".",
"PrefixUnit",
",",
"q",
".",
"quantity",
".",
"Quantity",
",",
"q",
".",
"core",
".",
"CompositeUnit",
")",
"if",
"not",
"isinstance",
"(",
"units",
... | A setter for the flux units
Parameters
----------
units: str, astropy.units.core.PrefixUnit
The desired units of the zeropoint flux density | [
"A",
"setter",
"for",
"the",
"flux",
"units"
] | f0587c4908baf636d4bdf030fa95029e8f31b975 | https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L393-L415 | train |
hover2pi/svo_filters | svo_filters/svo.py | Filter.info | def info(self, fetch=False):
"""
Print a table of info about the current filter
"""
# Get the info from the class
tp = (int, bytes, bool, str, float, tuple, list, np.ndarray)
info = [[k, str(v)] for k, v in vars(self).items() if isinstance(v, tp)
and k not... | python | def info(self, fetch=False):
"""
Print a table of info about the current filter
"""
# Get the info from the class
tp = (int, bytes, bool, str, float, tuple, list, np.ndarray)
info = [[k, str(v)] for k, v in vars(self).items() if isinstance(v, tp)
and k not... | [
"def",
"info",
"(",
"self",
",",
"fetch",
"=",
"False",
")",
":",
"tp",
"=",
"(",
"int",
",",
"bytes",
",",
"bool",
",",
"str",
",",
"float",
",",
"tuple",
",",
"list",
",",
"np",
".",
"ndarray",
")",
"info",
"=",
"[",
"[",
"k",
",",
"str",
... | Print a table of info about the current filter | [
"Print",
"a",
"table",
"of",
"info",
"about",
"the",
"current",
"filter"
] | f0587c4908baf636d4bdf030fa95029e8f31b975 | https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L417-L436 | train |
hover2pi/svo_filters | svo_filters/svo.py | Filter.load_TopHat | def load_TopHat(self, wave_min, wave_max, pixels_per_bin=100):
"""
Loads a top hat filter given wavelength min and max values
Parameters
----------
wave_min: astropy.units.quantity (optional)
The minimum wavelength to use
wave_max: astropy.units.quantity (opt... | python | def load_TopHat(self, wave_min, wave_max, pixels_per_bin=100):
"""
Loads a top hat filter given wavelength min and max values
Parameters
----------
wave_min: astropy.units.quantity (optional)
The minimum wavelength to use
wave_max: astropy.units.quantity (opt... | [
"def",
"load_TopHat",
"(",
"self",
",",
"wave_min",
",",
"wave_max",
",",
"pixels_per_bin",
"=",
"100",
")",
":",
"self",
".",
"pixels_per_bin",
"=",
"pixels_per_bin",
"self",
".",
"n_bins",
"=",
"1",
"self",
".",
"_wave_units",
"=",
"q",
".",
"AA",
"wav... | Loads a top hat filter given wavelength min and max values
Parameters
----------
wave_min: astropy.units.quantity (optional)
The minimum wavelength to use
wave_max: astropy.units.quantity (optional)
The maximum wavelength to use
n_pixels: int
... | [
"Loads",
"a",
"top",
"hat",
"filter",
"given",
"wavelength",
"min",
"and",
"max",
"values"
] | f0587c4908baf636d4bdf030fa95029e8f31b975 | https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L438-L492 | train |
hover2pi/svo_filters | svo_filters/svo.py | Filter.overlap | def overlap(self, spectrum):
"""Tests for overlap of this filter with a spectrum
Example of full overlap:
|---------- spectrum ----------|
|------ self ------|
Examples of partial overlap: :
|---------- self ----------|
|------ spectrum -... | python | def overlap(self, spectrum):
"""Tests for overlap of this filter with a spectrum
Example of full overlap:
|---------- spectrum ----------|
|------ self ------|
Examples of partial overlap: :
|---------- self ----------|
|------ spectrum -... | [
"def",
"overlap",
"(",
"self",
",",
"spectrum",
")",
":",
"swave",
"=",
"self",
".",
"wave",
"[",
"np",
".",
"where",
"(",
"self",
".",
"throughput",
"!=",
"0",
")",
"]",
"s1",
",",
"s2",
"=",
"swave",
".",
"min",
"(",
")",
",",
"swave",
".",
... | Tests for overlap of this filter with a spectrum
Example of full overlap:
|---------- spectrum ----------|
|------ self ------|
Examples of partial overlap: :
|---------- self ----------|
|------ spectrum ------|
|---- spectrum ----|... | [
"Tests",
"for",
"overlap",
"of",
"this",
"filter",
"with",
"a",
"spectrum"
] | f0587c4908baf636d4bdf030fa95029e8f31b975 | https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L588-L638 | train |
hover2pi/svo_filters | svo_filters/svo.py | Filter.plot | def plot(self, fig=None, draw=True):
"""
Plot the filter
Parameters
----------
fig: bokeh.plotting.figure (optional)
A figure to plot on
draw: bool
Draw the figure, else return it
Returns
-------
bokeh.plotting.figure
... | python | def plot(self, fig=None, draw=True):
"""
Plot the filter
Parameters
----------
fig: bokeh.plotting.figure (optional)
A figure to plot on
draw: bool
Draw the figure, else return it
Returns
-------
bokeh.plotting.figure
... | [
"def",
"plot",
"(",
"self",
",",
"fig",
"=",
"None",
",",
"draw",
"=",
"True",
")",
":",
"COLORS",
"=",
"color_gen",
"(",
"'Category10'",
")",
"if",
"fig",
"is",
"None",
":",
"xlab",
"=",
"'Wavelength [{}]'",
".",
"format",
"(",
"self",
".",
"wave_un... | Plot the filter
Parameters
----------
fig: bokeh.plotting.figure (optional)
A figure to plot on
draw: bool
Draw the figure, else return it
Returns
-------
bokeh.plotting.figure
The filter figure | [
"Plot",
"the",
"filter"
] | f0587c4908baf636d4bdf030fa95029e8f31b975 | https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L640-L677 | train |
hover2pi/svo_filters | svo_filters/svo.py | Filter.throughput | def throughput(self, points):
"""A setter for the throughput
Parameters
----------
throughput: sequence
The array of throughput points
"""
# Test shape
if not points.shape == self.wave.shape:
raise ValueError("Throughput and wavelength mus... | python | def throughput(self, points):
"""A setter for the throughput
Parameters
----------
throughput: sequence
The array of throughput points
"""
# Test shape
if not points.shape == self.wave.shape:
raise ValueError("Throughput and wavelength mus... | [
"def",
"throughput",
"(",
"self",
",",
"points",
")",
":",
"if",
"not",
"points",
".",
"shape",
"==",
"self",
".",
"wave",
".",
"shape",
":",
"raise",
"ValueError",
"(",
"\"Throughput and wavelength must be same shape.\"",
")",
"self",
".",
"_throughput",
"=",... | A setter for the throughput
Parameters
----------
throughput: sequence
The array of throughput points | [
"A",
"setter",
"for",
"the",
"throughput"
] | f0587c4908baf636d4bdf030fa95029e8f31b975 | https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L692-L704 | train |
hover2pi/svo_filters | svo_filters/svo.py | Filter.wave | def wave(self, wavelength):
"""A setter for the wavelength
Parameters
----------
wavelength: astropy.units.quantity.Quantity
The array with units
"""
# Test units
if not isinstance(wavelength, q.quantity.Quantity):
raise ValueError("Wavele... | python | def wave(self, wavelength):
"""A setter for the wavelength
Parameters
----------
wavelength: astropy.units.quantity.Quantity
The array with units
"""
# Test units
if not isinstance(wavelength, q.quantity.Quantity):
raise ValueError("Wavele... | [
"def",
"wave",
"(",
"self",
",",
"wavelength",
")",
":",
"if",
"not",
"isinstance",
"(",
"wavelength",
",",
"q",
".",
"quantity",
".",
"Quantity",
")",
":",
"raise",
"ValueError",
"(",
"\"Wavelength must be in length units.\"",
")",
"self",
".",
"_wave",
"="... | A setter for the wavelength
Parameters
----------
wavelength: astropy.units.quantity.Quantity
The array with units | [
"A",
"setter",
"for",
"the",
"wavelength"
] | f0587c4908baf636d4bdf030fa95029e8f31b975 | https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L712-L725 | train |
hover2pi/svo_filters | svo_filters/svo.py | Filter.wave_units | def wave_units(self, units):
"""
A setter for the wavelength units
Parameters
----------
units: str, astropy.units.core.PrefixUnit
The wavelength units
"""
# Make sure it's length units
if not units.is_equivalent(q.m):
raise ValueE... | python | def wave_units(self, units):
"""
A setter for the wavelength units
Parameters
----------
units: str, astropy.units.core.PrefixUnit
The wavelength units
"""
# Make sure it's length units
if not units.is_equivalent(q.m):
raise ValueE... | [
"def",
"wave_units",
"(",
"self",
",",
"units",
")",
":",
"if",
"not",
"units",
".",
"is_equivalent",
"(",
"q",
".",
"m",
")",
":",
"raise",
"ValueError",
"(",
"units",
",",
"\": New wavelength units must be a length.\"",
")",
"self",
".",
"_wave_units",
"="... | A setter for the wavelength units
Parameters
----------
units: str, astropy.units.core.PrefixUnit
The wavelength units | [
"A",
"setter",
"for",
"the",
"wavelength",
"units"
] | f0587c4908baf636d4bdf030fa95029e8f31b975 | https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L733-L760 | train |
bitesofcode/projexui | projexui/widgets/xdocktoolbar.py | XDockToolbar.clear | def clear(self):
"""
Clears out all the actions and items from this toolbar.
"""
# clear the actions from this widget
for act in self.actions():
act.setParent(None)
act.deleteLater()
# clear the labels from this widget
fo... | python | def clear(self):
"""
Clears out all the actions and items from this toolbar.
"""
# clear the actions from this widget
for act in self.actions():
act.setParent(None)
act.deleteLater()
# clear the labels from this widget
fo... | [
"def",
"clear",
"(",
"self",
")",
":",
"for",
"act",
"in",
"self",
".",
"actions",
"(",
")",
":",
"act",
".",
"setParent",
"(",
"None",
")",
"act",
".",
"deleteLater",
"(",
")",
"for",
"lbl",
"in",
"self",
".",
"actionLabels",
"(",
")",
":",
"lbl... | Clears out all the actions and items from this toolbar. | [
"Clears",
"out",
"all",
"the",
"actions",
"and",
"items",
"from",
"this",
"toolbar",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xdocktoolbar.py#L242-L254 | train |
bitesofcode/projexui | projexui/widgets/xdocktoolbar.py | XDockToolbar.resizeToMinimum | def resizeToMinimum(self):
"""
Resizes the dock toolbar to the minimum sizes.
"""
offset = self.padding()
min_size = self.minimumPixmapSize()
if self.position() in (XDockToolbar.Position.East,
XDockToolbar.Position.West):
... | python | def resizeToMinimum(self):
"""
Resizes the dock toolbar to the minimum sizes.
"""
offset = self.padding()
min_size = self.minimumPixmapSize()
if self.position() in (XDockToolbar.Position.East,
XDockToolbar.Position.West):
... | [
"def",
"resizeToMinimum",
"(",
"self",
")",
":",
"offset",
"=",
"self",
".",
"padding",
"(",
")",
"min_size",
"=",
"self",
".",
"minimumPixmapSize",
"(",
")",
"if",
"self",
".",
"position",
"(",
")",
"in",
"(",
"XDockToolbar",
".",
"Position",
".",
"Ea... | Resizes the dock toolbar to the minimum sizes. | [
"Resizes",
"the",
"dock",
"toolbar",
"to",
"the",
"minimum",
"sizes",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xdocktoolbar.py#L490-L503 | train |
bitesofcode/projexui | projexui/widgets/xdocktoolbar.py | XDockToolbar.unholdAction | def unholdAction(self):
"""
Unholds the action from being blocked on the leave event.
"""
self._actionHeld = False
point = self.mapFromGlobal(QCursor.pos())
self.setCurrentAction(self.actionAt(point)) | python | def unholdAction(self):
"""
Unholds the action from being blocked on the leave event.
"""
self._actionHeld = False
point = self.mapFromGlobal(QCursor.pos())
self.setCurrentAction(self.actionAt(point)) | [
"def",
"unholdAction",
"(",
"self",
")",
":",
"self",
".",
"_actionHeld",
"=",
"False",
"point",
"=",
"self",
".",
"mapFromGlobal",
"(",
"QCursor",
".",
"pos",
"(",
")",
")",
"self",
".",
"setCurrentAction",
"(",
"self",
".",
"actionAt",
"(",
"point",
... | Unholds the action from being blocked on the leave event. | [
"Unholds",
"the",
"action",
"from",
"being",
"blocked",
"on",
"the",
"leave",
"event",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xdocktoolbar.py#L741-L748 | train |
bitesofcode/projexui | projexui/xscheme.py | XScheme.apply | def apply( self ):
"""
Applies the scheme to the current application.
"""
font = self.value('font')
try:
font.setPointSize(self.value('fontSize'))
# errors in linux for some reason
except TypeError:
pass
... | python | def apply( self ):
"""
Applies the scheme to the current application.
"""
font = self.value('font')
try:
font.setPointSize(self.value('fontSize'))
# errors in linux for some reason
except TypeError:
pass
... | [
"def",
"apply",
"(",
"self",
")",
":",
"font",
"=",
"self",
".",
"value",
"(",
"'font'",
")",
"try",
":",
"font",
".",
"setPointSize",
"(",
"self",
".",
"value",
"(",
"'fontSize'",
")",
")",
"except",
"TypeError",
":",
"pass",
"palette",
"=",
"self",... | Applies the scheme to the current application. | [
"Applies",
"the",
"scheme",
"to",
"the",
"current",
"application",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xscheme.py#L38-L62 | train |
bitesofcode/projexui | projexui/xscheme.py | XScheme.reset | def reset( self ):
"""
Resets the values to the current application information.
"""
self.setValue('colorSet', XPaletteColorSet())
self.setValue('font', QApplication.font())
self.setValue('fontSize', QApplication.font().pointSize()) | python | def reset( self ):
"""
Resets the values to the current application information.
"""
self.setValue('colorSet', XPaletteColorSet())
self.setValue('font', QApplication.font())
self.setValue('fontSize', QApplication.font().pointSize()) | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"setValue",
"(",
"'colorSet'",
",",
"XPaletteColorSet",
"(",
")",
")",
"self",
".",
"setValue",
"(",
"'font'",
",",
"QApplication",
".",
"font",
"(",
")",
")",
"self",
".",
"setValue",
"(",
"'fontSize... | Resets the values to the current application information. | [
"Resets",
"the",
"values",
"to",
"the",
"current",
"application",
"information",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xscheme.py#L64-L70 | train |
bitesofcode/projexui | projexui/widgets/xcommentedit.py | XCommentEdit.pickAttachment | def pickAttachment(self):
"""
Prompts the user to select an attachment to add to this edit.
"""
filename = QFileDialog.getOpenFileName(self.window(),
'Select Attachment',
'',
... | python | def pickAttachment(self):
"""
Prompts the user to select an attachment to add to this edit.
"""
filename = QFileDialog.getOpenFileName(self.window(),
'Select Attachment',
'',
... | [
"def",
"pickAttachment",
"(",
"self",
")",
":",
"filename",
"=",
"QFileDialog",
".",
"getOpenFileName",
"(",
"self",
".",
"window",
"(",
")",
",",
"'Select Attachment'",
",",
"''",
",",
"'All Files (*.*)'",
")",
"if",
"type",
"(",
"filename",
")",
"==",
"t... | Prompts the user to select an attachment to add to this edit. | [
"Prompts",
"the",
"user",
"to",
"select",
"an",
"attachment",
"to",
"add",
"to",
"this",
"edit",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcommentedit.py#L145-L159 | train |
bitesofcode/projexui | projexui/widgets/xcommentedit.py | XCommentEdit.resizeToContents | def resizeToContents(self):
"""
Resizes this toolbar based on the contents of its text.
"""
if self._toolbar.isVisible():
doc = self.document()
h = doc.documentLayout().documentSize().height()
offset = 34
... | python | def resizeToContents(self):
"""
Resizes this toolbar based on the contents of its text.
"""
if self._toolbar.isVisible():
doc = self.document()
h = doc.documentLayout().documentSize().height()
offset = 34
... | [
"def",
"resizeToContents",
"(",
"self",
")",
":",
"if",
"self",
".",
"_toolbar",
".",
"isVisible",
"(",
")",
":",
"doc",
"=",
"self",
".",
"document",
"(",
")",
"h",
"=",
"doc",
".",
"documentLayout",
"(",
")",
".",
"documentSize",
"(",
")",
".",
"... | Resizes this toolbar based on the contents of its text. | [
"Resizes",
"this",
"toolbar",
"based",
"on",
"the",
"contents",
"of",
"its",
"text",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xcommentedit.py#L183-L208 | train |
johnnoone/aioconsul | aioconsul/client/operator_endpoint.py | OperatorEndpoint.configuration | async def configuration(self, *, dc=None, consistency=None):
"""Inspects the Raft configuration
Parameters:
dc (str): Specify datacenter that will be used.
Defaults to the agent's local datacenter.
consistency (str): Read the Raft configuration from any of ... | python | async def configuration(self, *, dc=None, consistency=None):
"""Inspects the Raft configuration
Parameters:
dc (str): Specify datacenter that will be used.
Defaults to the agent's local datacenter.
consistency (str): Read the Raft configuration from any of ... | [
"async",
"def",
"configuration",
"(",
"self",
",",
"*",
",",
"dc",
"=",
"None",
",",
"consistency",
"=",
"None",
")",
":",
"response",
"=",
"await",
"self",
".",
"_api",
".",
"get",
"(",
"\"/v1/operator/raft/configuration\"",
",",
"params",
"=",
"{",
"\"... | Inspects the Raft configuration
Parameters:
dc (str): Specify datacenter that will be used.
Defaults to the agent's local datacenter.
consistency (str): Read the Raft configuration from any of the
Consul servers, otherwise raise an ex... | [
"Inspects",
"the",
"Raft",
"configuration"
] | 02f7a529d7dc2e49bed942111067aa5faf320e90 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/operator_endpoint.py#L7-L72 | train |
johnnoone/aioconsul | aioconsul/client/operator_endpoint.py | OperatorEndpoint.peer_delete | async def peer_delete(self, *, dc=None, address):
"""Remove the server with given address from the Raft configuration
Parameters:
dc (str): Specify datacenter that will be used.
Defaults to the agent's local datacenter.
address (str): "IP:port" of the serve... | python | async def peer_delete(self, *, dc=None, address):
"""Remove the server with given address from the Raft configuration
Parameters:
dc (str): Specify datacenter that will be used.
Defaults to the agent's local datacenter.
address (str): "IP:port" of the serve... | [
"async",
"def",
"peer_delete",
"(",
"self",
",",
"*",
",",
"dc",
"=",
"None",
",",
"address",
")",
":",
"address",
"=",
"extract_attr",
"(",
"address",
",",
"keys",
"=",
"[",
"\"Address\"",
"]",
")",
"params",
"=",
"{",
"\"dc\"",
":",
"dc",
",",
"\... | Remove the server with given address from the Raft configuration
Parameters:
dc (str): Specify datacenter that will be used.
Defaults to the agent's local datacenter.
address (str): "IP:port" of the server to remove.
Returns:
bool: ``True`` on s... | [
"Remove",
"the",
"server",
"with",
"given",
"address",
"from",
"the",
"Raft",
"configuration"
] | 02f7a529d7dc2e49bed942111067aa5faf320e90 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/operator_endpoint.py#L74-L93 | train |
bitesofcode/projexui | projexui/widgets/xwalkthroughwidget/xwalkthroughwidget.py | XWalkthroughWidget.autoLayout | def autoLayout(self):
"""
Automatically lays out the contents for this widget.
"""
try:
direction = self.currentSlide().scene().direction()
except AttributeError:
direction = QtGui.QBoxLayout.TopToBottom
size = self.size()
... | python | def autoLayout(self):
"""
Automatically lays out the contents for this widget.
"""
try:
direction = self.currentSlide().scene().direction()
except AttributeError:
direction = QtGui.QBoxLayout.TopToBottom
size = self.size()
... | [
"def",
"autoLayout",
"(",
"self",
")",
":",
"try",
":",
"direction",
"=",
"self",
".",
"currentSlide",
"(",
")",
".",
"scene",
"(",
")",
".",
"direction",
"(",
")",
"except",
"AttributeError",
":",
"direction",
"=",
"QtGui",
".",
"QBoxLayout",
".",
"To... | Automatically lays out the contents for this widget. | [
"Automatically",
"lays",
"out",
"the",
"contents",
"for",
"this",
"widget",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xwalkthroughwidget/xwalkthroughwidget.py#L113-L139 | train |
bitesofcode/projexui | projexui/widgets/xwalkthroughwidget/xwalkthroughwidget.py | XWalkthroughWidget.goForward | def goForward(self):
"""
Moves to the next slide or finishes the walkthrough.
"""
if self._slideshow.currentIndex() == self._slideshow.count() - 1:
self.finished.emit()
else:
self._slideshow.slideInNext() | python | def goForward(self):
"""
Moves to the next slide or finishes the walkthrough.
"""
if self._slideshow.currentIndex() == self._slideshow.count() - 1:
self.finished.emit()
else:
self._slideshow.slideInNext() | [
"def",
"goForward",
"(",
"self",
")",
":",
"if",
"self",
".",
"_slideshow",
".",
"currentIndex",
"(",
")",
"==",
"self",
".",
"_slideshow",
".",
"count",
"(",
")",
"-",
"1",
":",
"self",
".",
"finished",
".",
"emit",
"(",
")",
"else",
":",
"self",
... | Moves to the next slide or finishes the walkthrough. | [
"Moves",
"to",
"the",
"next",
"slide",
"or",
"finishes",
"the",
"walkthrough",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xwalkthroughwidget/xwalkthroughwidget.py#L187-L194 | train |
bitesofcode/projexui | projexui/widgets/xwalkthroughwidget/xwalkthroughwidget.py | XWalkthroughWidget.updateUi | def updateUi(self):
"""
Updates the interface to show the selection buttons.
"""
index = self._slideshow.currentIndex()
count = self._slideshow.count()
self._previousButton.setVisible(index != 0)
self._nextButton.setText('Finish' if index == count... | python | def updateUi(self):
"""
Updates the interface to show the selection buttons.
"""
index = self._slideshow.currentIndex()
count = self._slideshow.count()
self._previousButton.setVisible(index != 0)
self._nextButton.setText('Finish' if index == count... | [
"def",
"updateUi",
"(",
"self",
")",
":",
"index",
"=",
"self",
".",
"_slideshow",
".",
"currentIndex",
"(",
")",
"count",
"=",
"self",
".",
"_slideshow",
".",
"count",
"(",
")",
"self",
".",
"_previousButton",
".",
"setVisible",
"(",
"index",
"!=",
"0... | Updates the interface to show the selection buttons. | [
"Updates",
"the",
"interface",
"to",
"show",
"the",
"selection",
"buttons",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xwalkthroughwidget/xwalkthroughwidget.py#L247-L256 | train |
fitnr/buoyant | buoyant/buoy.py | parse_unit | def parse_unit(prop, dictionary, dt=None):
'''Do a fuzzy match for `prop` in the dictionary, taking into account unit suffix.'''
# add the observation's time
try:
dt = timezone.parse_datetime(dictionary.get('date_time'))
except TypeError:
dt = None
# 'prop' is a stub of the property... | python | def parse_unit(prop, dictionary, dt=None):
'''Do a fuzzy match for `prop` in the dictionary, taking into account unit suffix.'''
# add the observation's time
try:
dt = timezone.parse_datetime(dictionary.get('date_time'))
except TypeError:
dt = None
# 'prop' is a stub of the property... | [
"def",
"parse_unit",
"(",
"prop",
",",
"dictionary",
",",
"dt",
"=",
"None",
")",
":",
"try",
":",
"dt",
"=",
"timezone",
".",
"parse_datetime",
"(",
"dictionary",
".",
"get",
"(",
"'date_time'",
")",
")",
"except",
"TypeError",
":",
"dt",
"=",
"None",... | Do a fuzzy match for `prop` in the dictionary, taking into account unit suffix. | [
"Do",
"a",
"fuzzy",
"match",
"for",
"prop",
"in",
"the",
"dictionary",
"taking",
"into",
"account",
"unit",
"suffix",
"."
] | ef7a74f9ebd4774629508ccf2c9abb43aa0235c9 | https://github.com/fitnr/buoyant/blob/ef7a74f9ebd4774629508ccf2c9abb43aa0235c9/buoyant/buoy.py#L37-L70 | train |
bitesofcode/projexui | projexui/widgets/xorbquerywidget/xorbquerywidget.py | XOrbQueryWidget.clear | def clear(self):
"""
Clears all the container for this query widget.
"""
for i in range(self.count()):
widget = self.widget(i)
if widget is not None:
widget.close()
widget.setParent(None)
widget.deleteLater(... | python | def clear(self):
"""
Clears all the container for this query widget.
"""
for i in range(self.count()):
widget = self.widget(i)
if widget is not None:
widget.close()
widget.setParent(None)
widget.deleteLater(... | [
"def",
"clear",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"count",
"(",
")",
")",
":",
"widget",
"=",
"self",
".",
"widget",
"(",
"i",
")",
"if",
"widget",
"is",
"not",
"None",
":",
"widget",
".",
"close",
"(",
")",
... | Clears all the container for this query widget. | [
"Clears",
"all",
"the",
"container",
"for",
"this",
"query",
"widget",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbquerywidget/xorbquerywidget.py#L78-L87 | train |
bitesofcode/projexui | projexui/widgets/xorbquerywidget/xorbquerywidget.py | XOrbQueryWidget.cleanupContainers | def cleanupContainers(self):
"""
Cleans up all containers to the right of the current one.
"""
for i in range(self.count() - 1, self.currentIndex(), -1):
widget = self.widget(i)
widget.close()
widget.setParent(None)
widget.deleteLat... | python | def cleanupContainers(self):
"""
Cleans up all containers to the right of the current one.
"""
for i in range(self.count() - 1, self.currentIndex(), -1):
widget = self.widget(i)
widget.close()
widget.setParent(None)
widget.deleteLat... | [
"def",
"cleanupContainers",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"count",
"(",
")",
"-",
"1",
",",
"self",
".",
"currentIndex",
"(",
")",
",",
"-",
"1",
")",
":",
"widget",
"=",
"self",
".",
"widget",
"(",
"i",
")... | Cleans up all containers to the right of the current one. | [
"Cleans",
"up",
"all",
"containers",
"to",
"the",
"right",
"of",
"the",
"current",
"one",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbquerywidget/xorbquerywidget.py#L89-L97 | train |
bitesofcode/projexui | projexui/widgets/xorbquerywidget/xorbquerywidget.py | XOrbQueryWidget.exitContainer | def exitContainer(self):
"""
Removes the current query container.
"""
try:
entry = self._compoundStack.pop()
except IndexError:
return
container = self.currentContainer()
entry.setQuery(container.query())
... | python | def exitContainer(self):
"""
Removes the current query container.
"""
try:
entry = self._compoundStack.pop()
except IndexError:
return
container = self.currentContainer()
entry.setQuery(container.query())
... | [
"def",
"exitContainer",
"(",
"self",
")",
":",
"try",
":",
"entry",
"=",
"self",
".",
"_compoundStack",
".",
"pop",
"(",
")",
"except",
"IndexError",
":",
"return",
"container",
"=",
"self",
".",
"currentContainer",
"(",
")",
"entry",
".",
"setQuery",
"(... | Removes the current query container. | [
"Removes",
"the",
"current",
"query",
"container",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbquerywidget/xorbquerywidget.py#L143-L155 | train |
bitesofcode/projexui | projexui/widgets/xorbrecordedit.py | XOrbRecordEdit.rebuild | def rebuild( self ):
"""
Rebuilds the interface for this widget based on the current model.
"""
self.setUpdatesEnabled(False)
self.blockSignals(True)
# clear out all the subwidgets for this widget
for child in self.findChildren(QObject):
... | python | def rebuild( self ):
"""
Rebuilds the interface for this widget based on the current model.
"""
self.setUpdatesEnabled(False)
self.blockSignals(True)
# clear out all the subwidgets for this widget
for child in self.findChildren(QObject):
... | [
"def",
"rebuild",
"(",
"self",
")",
":",
"self",
".",
"setUpdatesEnabled",
"(",
"False",
")",
"self",
".",
"blockSignals",
"(",
"True",
")",
"for",
"child",
"in",
"self",
".",
"findChildren",
"(",
"QObject",
")",
":",
"child",
".",
"setParent",
"(",
"N... | Rebuilds the interface for this widget based on the current model. | [
"Rebuilds",
"the",
"interface",
"for",
"this",
"widget",
"based",
"on",
"the",
"current",
"model",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbrecordedit.py#L78-L146 | train |
bitesofcode/projexui | projexui/widgets/xorbrecordedit.py | XOrbRecordEdit.save | def save( self ):
"""
Saves the values from the editor to the system.
"""
schema = self.schema()
if ( not schema ):
self.saved.emit()
return
record = self.record()
if not record:
record = self._model()
... | python | def save( self ):
"""
Saves the values from the editor to the system.
"""
schema = self.schema()
if ( not schema ):
self.saved.emit()
return
record = self.record()
if not record:
record = self._model()
... | [
"def",
"save",
"(",
"self",
")",
":",
"schema",
"=",
"self",
".",
"schema",
"(",
")",
"if",
"(",
"not",
"schema",
")",
":",
"self",
".",
"saved",
".",
"emit",
"(",
")",
"return",
"record",
"=",
"self",
".",
"record",
"(",
")",
"if",
"not",
"rec... | Saves the values from the editor to the system. | [
"Saves",
"the",
"values",
"from",
"the",
"editor",
"to",
"the",
"system",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbrecordedit.py#L149-L210 | train |
bitesofcode/projexui | projexui/widgets/xtextedit.py | XTextEdit.acceptText | def acceptText(self):
"""
Emits the editing finished signals for this widget.
"""
if not self.signalsBlocked():
self.textEntered.emit(self.toPlainText())
self.htmlEntered.emit(self.toHtml())
self.returnPressed.emit() | python | def acceptText(self):
"""
Emits the editing finished signals for this widget.
"""
if not self.signalsBlocked():
self.textEntered.emit(self.toPlainText())
self.htmlEntered.emit(self.toHtml())
self.returnPressed.emit() | [
"def",
"acceptText",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"signalsBlocked",
"(",
")",
":",
"self",
".",
"textEntered",
".",
"emit",
"(",
"self",
".",
"toPlainText",
"(",
")",
")",
"self",
".",
"htmlEntered",
".",
"emit",
"(",
"self",
".",... | Emits the editing finished signals for this widget. | [
"Emits",
"the",
"editing",
"finished",
"signals",
"for",
"this",
"widget",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtextedit.py#L51-L58 | train |
bitesofcode/projexui | projexui/widgets/xtextedit.py | XTextEdit.clear | def clear(self):
"""
Clears the text for this edit and resizes the toolbar information.
"""
super(XTextEdit, self).clear()
self.textEntered.emit('')
self.htmlEntered.emit('')
if self.autoResizeToContents():
self.resizeToCont... | python | def clear(self):
"""
Clears the text for this edit and resizes the toolbar information.
"""
super(XTextEdit, self).clear()
self.textEntered.emit('')
self.htmlEntered.emit('')
if self.autoResizeToContents():
self.resizeToCont... | [
"def",
"clear",
"(",
"self",
")",
":",
"super",
"(",
"XTextEdit",
",",
"self",
")",
".",
"clear",
"(",
")",
"self",
".",
"textEntered",
".",
"emit",
"(",
"''",
")",
"self",
".",
"htmlEntered",
".",
"emit",
"(",
"''",
")",
"if",
"self",
".",
"auto... | Clears the text for this edit and resizes the toolbar information. | [
"Clears",
"the",
"text",
"for",
"this",
"edit",
"and",
"resizes",
"the",
"toolbar",
"information",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtextedit.py#L70-L80 | train |
bitesofcode/projexui | projexui/widgets/xtextedit.py | XTextEdit.paste | def paste(self):
"""
Pastes text from the clipboard into this edit.
"""
html = QApplication.clipboard().text()
if not self.isRichTextEditEnabled():
self.insertPlainText(projex.text.toAscii(html))
else:
super(XTextEdit, self).paste() | python | def paste(self):
"""
Pastes text from the clipboard into this edit.
"""
html = QApplication.clipboard().text()
if not self.isRichTextEditEnabled():
self.insertPlainText(projex.text.toAscii(html))
else:
super(XTextEdit, self).paste() | [
"def",
"paste",
"(",
"self",
")",
":",
"html",
"=",
"QApplication",
".",
"clipboard",
"(",
")",
".",
"text",
"(",
")",
"if",
"not",
"self",
".",
"isRichTextEditEnabled",
"(",
")",
":",
"self",
".",
"insertPlainText",
"(",
"projex",
".",
"text",
".",
... | Pastes text from the clipboard into this edit. | [
"Pastes",
"text",
"from",
"the",
"clipboard",
"into",
"this",
"edit",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtextedit.py#L198-L206 | train |
bitesofcode/projexui | projexui/widgets/xtextedit.py | XTextEdit.resizeToContents | def resizeToContents(self):
"""
Resizes this widget to fit the contents of its text.
"""
doc = self.document()
h = doc.documentLayout().documentSize().height()
self.setFixedHeight(h + 4) | python | def resizeToContents(self):
"""
Resizes this widget to fit the contents of its text.
"""
doc = self.document()
h = doc.documentLayout().documentSize().height()
self.setFixedHeight(h + 4) | [
"def",
"resizeToContents",
"(",
"self",
")",
":",
"doc",
"=",
"self",
".",
"document",
"(",
")",
"h",
"=",
"doc",
".",
"documentLayout",
"(",
")",
".",
"documentSize",
"(",
")",
".",
"height",
"(",
")",
"self",
".",
"setFixedHeight",
"(",
"h",
"+",
... | Resizes this widget to fit the contents of its text. | [
"Resizes",
"this",
"widget",
"to",
"fit",
"the",
"contents",
"of",
"its",
"text",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xtextedit.py#L231-L237 | train |
bitesofcode/projexui | projexui/widgets/xgroupbox.py | XGroupBox.matchCollapsedState | def matchCollapsedState( self ):
"""
Matches the collapsed state for this groupbox.
"""
collapsed = not self.isChecked()
if self._inverted:
collapsed = not collapsed
if ( not self.isCollapsible() or not collapsed ):
for child in self.c... | python | def matchCollapsedState( self ):
"""
Matches the collapsed state for this groupbox.
"""
collapsed = not self.isChecked()
if self._inverted:
collapsed = not collapsed
if ( not self.isCollapsible() or not collapsed ):
for child in self.c... | [
"def",
"matchCollapsedState",
"(",
"self",
")",
":",
"collapsed",
"=",
"not",
"self",
".",
"isChecked",
"(",
")",
"if",
"self",
".",
"_inverted",
":",
"collapsed",
"=",
"not",
"collapsed",
"if",
"(",
"not",
"self",
".",
"isCollapsible",
"(",
")",
"or",
... | Matches the collapsed state for this groupbox. | [
"Matches",
"the",
"collapsed",
"state",
"for",
"this",
"groupbox",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xgroupbox.py#L99-L126 | train |
bitesofcode/projexui | projexui/xcommands.py | import_qt | def import_qt(glbls):
""" Delayed qt loader. """
if 'QtCore' in glbls:
return
from projexui.qt import QtCore, QtGui, wrapVariant, uic
from projexui.widgets.xloggersplashscreen import XLoggerSplashScreen
glbls['QtCore'] = QtCore
glbls['QtGui'] = QtGui
glbls['wr... | python | def import_qt(glbls):
""" Delayed qt loader. """
if 'QtCore' in glbls:
return
from projexui.qt import QtCore, QtGui, wrapVariant, uic
from projexui.widgets.xloggersplashscreen import XLoggerSplashScreen
glbls['QtCore'] = QtCore
glbls['QtGui'] = QtGui
glbls['wr... | [
"def",
"import_qt",
"(",
"glbls",
")",
":",
"if",
"'QtCore'",
"in",
"glbls",
":",
"return",
"from",
"projexui",
".",
"qt",
"import",
"QtCore",
",",
"QtGui",
",",
"wrapVariant",
",",
"uic",
"from",
"projexui",
".",
"widgets",
".",
"xloggersplashscreen",
"im... | Delayed qt loader. | [
"Delayed",
"qt",
"loader",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xcommands.py#L255-L267 | train |
johnnoone/aioconsul | aioconsul/encoders/__init__.py | encode_value | def encode_value(value, flags=None, base64=False):
"""Mostly used by payloads
"""
if flags:
# still a no-operation
logger.debug("Flag %s encoding not implemented yet" % flags)
if not isinstance(value, bytes):
raise ValueError("value must be bytes")
return b64encode(value) if ... | python | def encode_value(value, flags=None, base64=False):
"""Mostly used by payloads
"""
if flags:
# still a no-operation
logger.debug("Flag %s encoding not implemented yet" % flags)
if not isinstance(value, bytes):
raise ValueError("value must be bytes")
return b64encode(value) if ... | [
"def",
"encode_value",
"(",
"value",
",",
"flags",
"=",
"None",
",",
"base64",
"=",
"False",
")",
":",
"if",
"flags",
":",
"logger",
".",
"debug",
"(",
"\"Flag %s encoding not implemented yet\"",
"%",
"flags",
")",
"if",
"not",
"isinstance",
"(",
"value",
... | Mostly used by payloads | [
"Mostly",
"used",
"by",
"payloads"
] | 02f7a529d7dc2e49bed942111067aa5faf320e90 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/encoders/__init__.py#L8-L16 | train |
bitesofcode/projexui | projexui/widgets/xstackedwidget.py | XStackedWidget._finishAnimation | def _finishAnimation(self):
"""
Cleans up post-animation.
"""
self.setCurrentIndex(self._nextIndex)
self.widget(self._lastIndex).hide()
self.widget(self._lastIndex).move(self._lastPoint)
self._active = False
if not self.signalsBlocked():
... | python | def _finishAnimation(self):
"""
Cleans up post-animation.
"""
self.setCurrentIndex(self._nextIndex)
self.widget(self._lastIndex).hide()
self.widget(self._lastIndex).move(self._lastPoint)
self._active = False
if not self.signalsBlocked():
... | [
"def",
"_finishAnimation",
"(",
"self",
")",
":",
"self",
".",
"setCurrentIndex",
"(",
"self",
".",
"_nextIndex",
")",
"self",
".",
"widget",
"(",
"self",
".",
"_lastIndex",
")",
".",
"hide",
"(",
")",
"self",
".",
"widget",
"(",
"self",
".",
"_lastInd... | Cleans up post-animation. | [
"Cleans",
"up",
"post",
"-",
"animation",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xstackedwidget.py#L66-L76 | train |
bitesofcode/projexui | projexui/widgets/xstackedwidget.py | XStackedWidget.clear | def clear(self):
"""
Clears out the widgets from this stack.
"""
for i in range(self.count() - 1, -1, -1):
w = self.widget(i)
if w:
self.removeWidget(w)
w.close()
w.deleteLater() | python | def clear(self):
"""
Clears out the widgets from this stack.
"""
for i in range(self.count() - 1, -1, -1):
w = self.widget(i)
if w:
self.removeWidget(w)
w.close()
w.deleteLater() | [
"def",
"clear",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"count",
"(",
")",
"-",
"1",
",",
"-",
"1",
",",
"-",
"1",
")",
":",
"w",
"=",
"self",
".",
"widget",
"(",
"i",
")",
"if",
"w",
":",
"self",
".",
"removeW... | Clears out the widgets from this stack. | [
"Clears",
"out",
"the",
"widgets",
"from",
"this",
"stack",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xstackedwidget.py#L86-L95 | train |
talkincode/txradius | txradius/openvpn/statusdb.py | list | def list(conf):
""" OpenVPN status list method
"""
try:
config = init_config(conf)
conn = get_conn(config.get('DEFAULT','statusdb'))
cur = conn.cursor()
sqlstr = '''select * from client_status order by ctime desc '''
cur.execute(sqlstr)
result = cur.fetchall()... | python | def list(conf):
""" OpenVPN status list method
"""
try:
config = init_config(conf)
conn = get_conn(config.get('DEFAULT','statusdb'))
cur = conn.cursor()
sqlstr = '''select * from client_status order by ctime desc '''
cur.execute(sqlstr)
result = cur.fetchall()... | [
"def",
"list",
"(",
"conf",
")",
":",
"try",
":",
"config",
"=",
"init_config",
"(",
"conf",
")",
"conn",
"=",
"get_conn",
"(",
"config",
".",
"get",
"(",
"'DEFAULT'",
",",
"'statusdb'",
")",
")",
"cur",
"=",
"conn",
".",
"cursor",
"(",
")",
"sqlst... | OpenVPN status list method | [
"OpenVPN",
"status",
"list",
"method"
] | b86fdbc9be41183680b82b07d3a8e8ea10926e01 | https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/openvpn/statusdb.py#L130-L145 | train |
talkincode/txradius | txradius/openvpn/statusdb.py | cli | def cli(conf):
""" OpenVPN status initdb method
"""
try:
config = init_config(conf)
debug = config.getboolean('DEFAULT', 'debug')
conn = get_conn(config.get('DEFAULT','statusdb'))
cur = conn.cursor()
sqlstr = '''create table client_status
(session_id text PRIM... | python | def cli(conf):
""" OpenVPN status initdb method
"""
try:
config = init_config(conf)
debug = config.getboolean('DEFAULT', 'debug')
conn = get_conn(config.get('DEFAULT','statusdb'))
cur = conn.cursor()
sqlstr = '''create table client_status
(session_id text PRIM... | [
"def",
"cli",
"(",
"conf",
")",
":",
"try",
":",
"config",
"=",
"init_config",
"(",
"conf",
")",
"debug",
"=",
"config",
".",
"getboolean",
"(",
"'DEFAULT'",
",",
"'debug'",
")",
"conn",
"=",
"get_conn",
"(",
"config",
".",
"get",
"(",
"'DEFAULT'",
"... | OpenVPN status initdb method | [
"OpenVPN",
"status",
"initdb",
"method"
] | b86fdbc9be41183680b82b07d3a8e8ea10926e01 | https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/openvpn/statusdb.py#L150-L173 | train |
johnnoone/aioconsul | aioconsul/client/services_endpoint.py | ServicesEndpoint.register | async def register(self, service):
"""Registers a new local service.
Returns:
bool: ``True`` on success
The register endpoint is used to add a new service,
with an optional health check, to the local agent.
The request body must look like::
{
... | python | async def register(self, service):
"""Registers a new local service.
Returns:
bool: ``True`` on success
The register endpoint is used to add a new service,
with an optional health check, to the local agent.
The request body must look like::
{
... | [
"async",
"def",
"register",
"(",
"self",
",",
"service",
")",
":",
"response",
"=",
"await",
"self",
".",
"_api",
".",
"put",
"(",
"\"/v1/agent/service/register\"",
",",
"data",
"=",
"service",
")",
"return",
"response",
".",
"status",
"==",
"200"
] | Registers a new local service.
Returns:
bool: ``True`` on success
The register endpoint is used to add a new service,
with an optional health check, to the local agent.
The request body must look like::
{
"ID": "redis1",
"Name":... | [
"Registers",
"a",
"new",
"local",
"service",
"."
] | 02f7a529d7dc2e49bed942111067aa5faf320e90 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/services_endpoint.py#L31-L116 | train |
johnnoone/aioconsul | aioconsul/client/services_endpoint.py | ServicesEndpoint.deregister | async def deregister(self, service):
"""Deregisters a local service
Parameters:
service (ObjectID): Service ID
Returns:
bool: ``True`` on success
The deregister endpoint is used to remove a service from the local
agent. The agent will take care of deregi... | python | async def deregister(self, service):
"""Deregisters a local service
Parameters:
service (ObjectID): Service ID
Returns:
bool: ``True`` on success
The deregister endpoint is used to remove a service from the local
agent. The agent will take care of deregi... | [
"async",
"def",
"deregister",
"(",
"self",
",",
"service",
")",
":",
"service_id",
"=",
"extract_attr",
"(",
"service",
",",
"keys",
"=",
"[",
"\"ServiceID\"",
",",
"\"ID\"",
"]",
")",
"response",
"=",
"await",
"self",
".",
"_api",
".",
"get",
"(",
"\"... | Deregisters a local service
Parameters:
service (ObjectID): Service ID
Returns:
bool: ``True`` on success
The deregister endpoint is used to remove a service from the local
agent. The agent will take care of deregistering the service with the
Catalog. If... | [
"Deregisters",
"a",
"local",
"service"
] | 02f7a529d7dc2e49bed942111067aa5faf320e90 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/services_endpoint.py#L118-L133 | train |
johnnoone/aioconsul | aioconsul/client/services_endpoint.py | ServicesEndpoint.disable | async def disable(self, service, *, reason=None):
"""Enters maintenance mode for service
Parameters:
service (ObjectID): Service ID
reason (str): Text string explaining the reason for placing the
service into maintenance mode.
Returns:
... | python | async def disable(self, service, *, reason=None):
"""Enters maintenance mode for service
Parameters:
service (ObjectID): Service ID
reason (str): Text string explaining the reason for placing the
service into maintenance mode.
Returns:
... | [
"async",
"def",
"disable",
"(",
"self",
",",
"service",
",",
"*",
",",
"reason",
"=",
"None",
")",
":",
"return",
"await",
"self",
".",
"maintenance",
"(",
"service",
",",
"False",
",",
"reason",
"=",
"reason",
")"
] | Enters maintenance mode for service
Parameters:
service (ObjectID): Service ID
reason (str): Text string explaining the reason for placing the
service into maintenance mode.
Returns:
bool: ``True`` on success
Places a given service ... | [
"Enters",
"maintenance",
"mode",
"for",
"service"
] | 02f7a529d7dc2e49bed942111067aa5faf320e90 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/services_endpoint.py#L135-L152 | train |
johnnoone/aioconsul | aioconsul/client/services_endpoint.py | ServicesEndpoint.enable | async def enable(self, service, *, reason=None):
"""Resumes normal operation for service
Parameters:
service (ObjectID): Service ID
reason (str): Text string explaining the reason for placing the
service into normal mode.
Returns:
bo... | python | async def enable(self, service, *, reason=None):
"""Resumes normal operation for service
Parameters:
service (ObjectID): Service ID
reason (str): Text string explaining the reason for placing the
service into normal mode.
Returns:
bo... | [
"async",
"def",
"enable",
"(",
"self",
",",
"service",
",",
"*",
",",
"reason",
"=",
"None",
")",
":",
"return",
"await",
"self",
".",
"maintenance",
"(",
"service",
",",
"False",
",",
"reason",
"=",
"reason",
")"
] | Resumes normal operation for service
Parameters:
service (ObjectID): Service ID
reason (str): Text string explaining the reason for placing the
service into normal mode.
Returns:
bool: ``True`` on success | [
"Resumes",
"normal",
"operation",
"for",
"service"
] | 02f7a529d7dc2e49bed942111067aa5faf320e90 | https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/services_endpoint.py#L154-L164 | train |
talkincode/txradius | txradius/mschap/mppe.py | mppe_chap2_gen_keys | def mppe_chap2_gen_keys(password, nt_response):
"""
3.3. Generating 128-bit Session Keys
When used in conjunction with MS-CHAP-2 authentication, the initial
MPPE session keys are derived from the peer's Windows NT password.
The first step is to obfuscate the peer's password using
NtPasswordHash() fun... | python | def mppe_chap2_gen_keys(password, nt_response):
"""
3.3. Generating 128-bit Session Keys
When used in conjunction with MS-CHAP-2 authentication, the initial
MPPE session keys are derived from the peer's Windows NT password.
The first step is to obfuscate the peer's password using
NtPasswordHash() fun... | [
"def",
"mppe_chap2_gen_keys",
"(",
"password",
",",
"nt_response",
")",
":",
"password_hash",
"=",
"mschap",
".",
"nt_password_hash",
"(",
"password",
")",
"password_hash_hash",
"=",
"mschap",
".",
"hash_nt_password_hash",
"(",
"password_hash",
")",
"master_key",
"=... | 3.3. Generating 128-bit Session Keys
When used in conjunction with MS-CHAP-2 authentication, the initial
MPPE session keys are derived from the peer's Windows NT password.
The first step is to obfuscate the peer's password using
NtPasswordHash() function as described in [8].
NtPasswordHash(Passwor... | [
"3",
".",
"3",
".",
"Generating",
"128",
"-",
"bit",
"Session",
"Keys"
] | b86fdbc9be41183680b82b07d3a8e8ea10926e01 | https://github.com/talkincode/txradius/blob/b86fdbc9be41183680b82b07d3a8e8ea10926e01/txradius/mschap/mppe.py#L45-L93 | train |
whiteclover/dbpy | db/_db.py | DB.query | def query(self, sql, args=None, many=None, as_dict=False):
"""The connection raw sql query, when select table, show table
to fetch records, it is compatible the dbi execute method.
:param sql string: the sql stamtement like 'select * from %s'
:param args list: Wen set None, will... | python | def query(self, sql, args=None, many=None, as_dict=False):
"""The connection raw sql query, when select table, show table
to fetch records, it is compatible the dbi execute method.
:param sql string: the sql stamtement like 'select * from %s'
:param args list: Wen set None, will... | [
"def",
"query",
"(",
"self",
",",
"sql",
",",
"args",
"=",
"None",
",",
"many",
"=",
"None",
",",
"as_dict",
"=",
"False",
")",
":",
"con",
"=",
"self",
".",
"pool",
".",
"pop",
"(",
")",
"c",
"=",
"None",
"try",
":",
"c",
"=",
"con",
".",
... | The connection raw sql query, when select table, show table
to fetch records, it is compatible the dbi execute method.
:param sql string: the sql stamtement like 'select * from %s'
:param args list: Wen set None, will use dbi execute(sql), else
dbi execute(sql, args), the ar... | [
"The",
"connection",
"raw",
"sql",
"query",
"when",
"select",
"table",
"show",
"table",
"to",
"fetch",
"records",
"it",
"is",
"compatible",
"the",
"dbi",
"execute",
"method",
"."
] | 3d9ce85f55cfb39cced22081e525f79581b26b3a | https://github.com/whiteclover/dbpy/blob/3d9ce85f55cfb39cced22081e525f79581b26b3a/db/_db.py#L85-L112 | train |
whiteclover/dbpy | db/_db.py | DB.connection_class | def connection_class(self, adapter):
"""Get connection class by adapter"""
if self.adapters.get(adapter):
return self.adapters[adapter]
try:
class_prefix = getattr(
__import__('db.' + adapter, globals(), locals(),
['__class_prefi... | python | def connection_class(self, adapter):
"""Get connection class by adapter"""
if self.adapters.get(adapter):
return self.adapters[adapter]
try:
class_prefix = getattr(
__import__('db.' + adapter, globals(), locals(),
['__class_prefi... | [
"def",
"connection_class",
"(",
"self",
",",
"adapter",
")",
":",
"if",
"self",
".",
"adapters",
".",
"get",
"(",
"adapter",
")",
":",
"return",
"self",
".",
"adapters",
"[",
"adapter",
"]",
"try",
":",
"class_prefix",
"=",
"getattr",
"(",
"__import__",
... | Get connection class by adapter | [
"Get",
"connection",
"class",
"by",
"adapter"
] | 3d9ce85f55cfb39cced22081e525f79581b26b3a | https://github.com/whiteclover/dbpy/blob/3d9ce85f55cfb39cced22081e525f79581b26b3a/db/_db.py#L164-L179 | train |
whiteclover/dbpy | db/_db.py | DB.dialect_class | def dialect_class(self, adapter):
"""Get dialect sql class by adapter"""
if self.dialects.get(adapter):
return self.dialects[adapter]
try:
class_prefix = getattr(
__import__('db.' + adapter, globals(), locals(),
['__class_prefix_... | python | def dialect_class(self, adapter):
"""Get dialect sql class by adapter"""
if self.dialects.get(adapter):
return self.dialects[adapter]
try:
class_prefix = getattr(
__import__('db.' + adapter, globals(), locals(),
['__class_prefix_... | [
"def",
"dialect_class",
"(",
"self",
",",
"adapter",
")",
":",
"if",
"self",
".",
"dialects",
".",
"get",
"(",
"adapter",
")",
":",
"return",
"self",
".",
"dialects",
"[",
"adapter",
"]",
"try",
":",
"class_prefix",
"=",
"getattr",
"(",
"__import__",
"... | Get dialect sql class by adapter | [
"Get",
"dialect",
"sql",
"class",
"by",
"adapter"
] | 3d9ce85f55cfb39cced22081e525f79581b26b3a | https://github.com/whiteclover/dbpy/blob/3d9ce85f55cfb39cced22081e525f79581b26b3a/db/_db.py#L181-L196 | train |
whiteclover/dbpy | db/_db.py | DB._import_class | def _import_class(self, module2cls):
"""Import class by module dot split string"""
d = module2cls.rfind(".")
classname = module2cls[d + 1: len(module2cls)]
m = __import__(module2cls[0:d], globals(), locals(), [classname])
return getattr(m, classname) | python | def _import_class(self, module2cls):
"""Import class by module dot split string"""
d = module2cls.rfind(".")
classname = module2cls[d + 1: len(module2cls)]
m = __import__(module2cls[0:d], globals(), locals(), [classname])
return getattr(m, classname) | [
"def",
"_import_class",
"(",
"self",
",",
"module2cls",
")",
":",
"d",
"=",
"module2cls",
".",
"rfind",
"(",
"\".\"",
")",
"classname",
"=",
"module2cls",
"[",
"d",
"+",
"1",
":",
"len",
"(",
"module2cls",
")",
"]",
"m",
"=",
"__import__",
"(",
"modu... | Import class by module dot split string | [
"Import",
"class",
"by",
"module",
"dot",
"split",
"string"
] | 3d9ce85f55cfb39cced22081e525f79581b26b3a | https://github.com/whiteclover/dbpy/blob/3d9ce85f55cfb39cced22081e525f79581b26b3a/db/_db.py#L198-L203 | train |
bitesofcode/projexui | projexui/widgets/xchartwidget/xcharttrackeritem.py | XChartTrackerItem.rebuild | def rebuild( self, gridRect ):
"""
Rebuilds the tracker item.
"""
scene = self.scene()
if ( not scene ):
return
self.setVisible(gridRect.contains(self.pos()))
self.setZValue(100)
path = QPainterPath()
path.... | python | def rebuild( self, gridRect ):
"""
Rebuilds the tracker item.
"""
scene = self.scene()
if ( not scene ):
return
self.setVisible(gridRect.contains(self.pos()))
self.setZValue(100)
path = QPainterPath()
path.... | [
"def",
"rebuild",
"(",
"self",
",",
"gridRect",
")",
":",
"scene",
"=",
"self",
".",
"scene",
"(",
")",
"if",
"(",
"not",
"scene",
")",
":",
"return",
"self",
".",
"setVisible",
"(",
"gridRect",
".",
"contains",
"(",
"self",
".",
"pos",
"(",
")",
... | Rebuilds the tracker item. | [
"Rebuilds",
"the",
"tracker",
"item",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchartwidget/xcharttrackeritem.py#L65-L124 | train |
ReneNulschDE/mercedesmejsonpy | mercedesmejsonpy/oauth.py | MercedesMeClientCredentials.get_access_token | def get_access_token(self):
"""
If a valid access token is in memory, returns it
Else feches a new token and returns it
"""
if self.token_info and not self.is_token_expired(self.token_info):
return self.token_info['access_token']
token_info = self._request_ac... | python | def get_access_token(self):
"""
If a valid access token is in memory, returns it
Else feches a new token and returns it
"""
if self.token_info and not self.is_token_expired(self.token_info):
return self.token_info['access_token']
token_info = self._request_ac... | [
"def",
"get_access_token",
"(",
"self",
")",
":",
"if",
"self",
".",
"token_info",
"and",
"not",
"self",
".",
"is_token_expired",
"(",
"self",
".",
"token_info",
")",
":",
"return",
"self",
".",
"token_info",
"[",
"'access_token'",
"]",
"token_info",
"=",
... | If a valid access token is in memory, returns it
Else feches a new token and returns it | [
"If",
"a",
"valid",
"access",
"token",
"is",
"in",
"memory",
"returns",
"it",
"Else",
"feches",
"a",
"new",
"token",
"and",
"returns",
"it"
] | 0618a0b49d6bb46599d11a8f66dc8d08d112ceec | https://github.com/ReneNulschDE/mercedesmejsonpy/blob/0618a0b49d6bb46599d11a8f66dc8d08d112ceec/mercedesmejsonpy/oauth.py#L56-L67 | train |
ReneNulschDE/mercedesmejsonpy | mercedesmejsonpy/oauth.py | MercedesMeClientCredentials._request_access_token | def _request_access_token(self):
"""Gets client credentials access token """
payload = {'grant_type': 'authorization_code',
'code': code,
'redirect_uri': self.redirect_uri}
headers = _make_authorization_headers(self.client_id,
... | python | def _request_access_token(self):
"""Gets client credentials access token """
payload = {'grant_type': 'authorization_code',
'code': code,
'redirect_uri': self.redirect_uri}
headers = _make_authorization_headers(self.client_id,
... | [
"def",
"_request_access_token",
"(",
"self",
")",
":",
"payload",
"=",
"{",
"'grant_type'",
":",
"'authorization_code'",
",",
"'code'",
":",
"code",
",",
"'redirect_uri'",
":",
"self",
".",
"redirect_uri",
"}",
"headers",
"=",
"_make_authorization_headers",
"(",
... | Gets client credentials access token | [
"Gets",
"client",
"credentials",
"access",
"token"
] | 0618a0b49d6bb46599d11a8f66dc8d08d112ceec | https://github.com/ReneNulschDE/mercedesmejsonpy/blob/0618a0b49d6bb46599d11a8f66dc8d08d112ceec/mercedesmejsonpy/oauth.py#L69-L85 | train |
ReneNulschDE/mercedesmejsonpy | mercedesmejsonpy/oauth.py | MercedesMeOAuth.get_cached_token | def get_cached_token(self):
''' Gets a cached auth token
'''
token_info = None
if self.cache_path:
try:
f = open(self.cache_path)
token_info_string = f.read()
f.close()
token_info = json.loads(token_info_string)
... | python | def get_cached_token(self):
''' Gets a cached auth token
'''
token_info = None
if self.cache_path:
try:
f = open(self.cache_path)
token_info_string = f.read()
f.close()
token_info = json.loads(token_info_string)
... | [
"def",
"get_cached_token",
"(",
"self",
")",
":",
"token_info",
"=",
"None",
"if",
"self",
".",
"cache_path",
":",
"try",
":",
"f",
"=",
"open",
"(",
"self",
".",
"cache_path",
")",
"token_info_string",
"=",
"f",
".",
"read",
"(",
")",
"f",
".",
"clo... | Gets a cached auth token | [
"Gets",
"a",
"cached",
"auth",
"token"
] | 0618a0b49d6bb46599d11a8f66dc8d08d112ceec | https://github.com/ReneNulschDE/mercedesmejsonpy/blob/0618a0b49d6bb46599d11a8f66dc8d08d112ceec/mercedesmejsonpy/oauth.py#L126-L142 | train |
ReneNulschDE/mercedesmejsonpy | mercedesmejsonpy/oauth.py | MercedesMeOAuth.get_authorize_url | def get_authorize_url(self, state=None):
""" Gets the URL to use to authorize this app
"""
payload = {'client_id': self.client_id,
'response_type': 'code',
'redirect_uri': self.redirect_uri,
'scope': self.scope}
urlparams = urllib... | python | def get_authorize_url(self, state=None):
""" Gets the URL to use to authorize this app
"""
payload = {'client_id': self.client_id,
'response_type': 'code',
'redirect_uri': self.redirect_uri,
'scope': self.scope}
urlparams = urllib... | [
"def",
"get_authorize_url",
"(",
"self",
",",
"state",
"=",
"None",
")",
":",
"payload",
"=",
"{",
"'client_id'",
":",
"self",
".",
"client_id",
",",
"'response_type'",
":",
"'code'",
",",
"'redirect_uri'",
":",
"self",
".",
"redirect_uri",
",",
"'scope'",
... | Gets the URL to use to authorize this app | [
"Gets",
"the",
"URL",
"to",
"use",
"to",
"authorize",
"this",
"app"
] | 0618a0b49d6bb46599d11a8f66dc8d08d112ceec | https://github.com/ReneNulschDE/mercedesmejsonpy/blob/0618a0b49d6bb46599d11a8f66dc8d08d112ceec/mercedesmejsonpy/oauth.py#L156-L166 | train |
ReneNulschDE/mercedesmejsonpy | mercedesmejsonpy/oauth.py | MercedesMeOAuth.get_access_token | def get_access_token(self, code):
""" Gets the access token for the app given the code
Parameters:
- code - the response code
"""
payload = {'redirect_uri': self.redirect_uri,
'code': code,
'grant_type': 'authorization_code'}
... | python | def get_access_token(self, code):
""" Gets the access token for the app given the code
Parameters:
- code - the response code
"""
payload = {'redirect_uri': self.redirect_uri,
'code': code,
'grant_type': 'authorization_code'}
... | [
"def",
"get_access_token",
"(",
"self",
",",
"code",
")",
":",
"payload",
"=",
"{",
"'redirect_uri'",
":",
"self",
".",
"redirect_uri",
",",
"'code'",
":",
"code",
",",
"'grant_type'",
":",
"'authorization_code'",
"}",
"headers",
"=",
"self",
".",
"_make_aut... | Gets the access token for the app given the code
Parameters:
- code - the response code | [
"Gets",
"the",
"access",
"token",
"for",
"the",
"app",
"given",
"the",
"code"
] | 0618a0b49d6bb46599d11a8f66dc8d08d112ceec | https://github.com/ReneNulschDE/mercedesmejsonpy/blob/0618a0b49d6bb46599d11a8f66dc8d08d112ceec/mercedesmejsonpy/oauth.py#L183-L203 | train |
ReneNulschDE/mercedesmejsonpy | mercedesmejsonpy/oauth.py | MercedesMeOAuth._add_custom_values_to_token_info | def _add_custom_values_to_token_info(self, token_info):
'''
Store some values that aren't directly provided by a Web API
response.
'''
token_info['expires_at'] = int(time.time()) + token_info['expires_in']
token_info['scope'] = self.scope
return token_info | python | def _add_custom_values_to_token_info(self, token_info):
'''
Store some values that aren't directly provided by a Web API
response.
'''
token_info['expires_at'] = int(time.time()) + token_info['expires_in']
token_info['scope'] = self.scope
return token_info | [
"def",
"_add_custom_values_to_token_info",
"(",
"self",
",",
"token_info",
")",
":",
"token_info",
"[",
"'expires_at'",
"]",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"+",
"token_info",
"[",
"'expires_in'",
"]",
"token_info",
"[",
"'scope'",
"]",
... | Store some values that aren't directly provided by a Web API
response. | [
"Store",
"some",
"values",
"that",
"aren",
"t",
"directly",
"provided",
"by",
"a",
"Web",
"API",
"response",
"."
] | 0618a0b49d6bb46599d11a8f66dc8d08d112ceec | https://github.com/ReneNulschDE/mercedesmejsonpy/blob/0618a0b49d6bb46599d11a8f66dc8d08d112ceec/mercedesmejsonpy/oauth.py#L226-L233 | train |
bitesofcode/projexui | projexui/widgets/xsplitbutton.py | XSplitButton.clear | def clear(self, autoBuild=True):
"""
Clears the actions for this widget.
"""
for action in self._actionGroup.actions():
self._actionGroup.removeAction(action)
action = QAction('', self)
action.setObjectName('place_holder')
self._actio... | python | def clear(self, autoBuild=True):
"""
Clears the actions for this widget.
"""
for action in self._actionGroup.actions():
self._actionGroup.removeAction(action)
action = QAction('', self)
action.setObjectName('place_holder')
self._actio... | [
"def",
"clear",
"(",
"self",
",",
"autoBuild",
"=",
"True",
")",
":",
"for",
"action",
"in",
"self",
".",
"_actionGroup",
".",
"actions",
"(",
")",
":",
"self",
".",
"_actionGroup",
".",
"removeAction",
"(",
"action",
")",
"action",
"=",
"QAction",
"("... | Clears the actions for this widget. | [
"Clears",
"the",
"actions",
"for",
"this",
"widget",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xsplitbutton.py#L187-L198 | train |
bitesofcode/projexui | projexui/widgets/xfilepathedit.py | XFilepathEdit.copyFilepath | def copyFilepath( self ):
"""
Copies the current filepath contents to the current clipboard.
"""
clipboard = QApplication.instance().clipboard()
clipboard.setText(self.filepath())
clipboard.setText(self.filepath(), clipboard.Selection) | python | def copyFilepath( self ):
"""
Copies the current filepath contents to the current clipboard.
"""
clipboard = QApplication.instance().clipboard()
clipboard.setText(self.filepath())
clipboard.setText(self.filepath(), clipboard.Selection) | [
"def",
"copyFilepath",
"(",
"self",
")",
":",
"clipboard",
"=",
"QApplication",
".",
"instance",
"(",
")",
".",
"clipboard",
"(",
")",
"clipboard",
".",
"setText",
"(",
"self",
".",
"filepath",
"(",
")",
")",
"clipboard",
".",
"setText",
"(",
"self",
"... | Copies the current filepath contents to the current clipboard. | [
"Copies",
"the",
"current",
"filepath",
"contents",
"to",
"the",
"current",
"clipboard",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xfilepathedit.py#L136-L142 | train |
bitesofcode/projexui | projexui/widgets/xfilepathedit.py | XFilepathEdit.pickFilepath | def pickFilepath( self ):
"""
Prompts the user to select a filepath from the system based on the \
current filepath mode.
"""
mode = self.filepathMode()
filepath = ''
filepaths = []
curr_dir = nativestring(self._filepathEdit.text())
if (... | python | def pickFilepath( self ):
"""
Prompts the user to select a filepath from the system based on the \
current filepath mode.
"""
mode = self.filepathMode()
filepath = ''
filepaths = []
curr_dir = nativestring(self._filepathEdit.text())
if (... | [
"def",
"pickFilepath",
"(",
"self",
")",
":",
"mode",
"=",
"self",
".",
"filepathMode",
"(",
")",
"filepath",
"=",
"''",
"filepaths",
"=",
"[",
"]",
"curr_dir",
"=",
"nativestring",
"(",
"self",
".",
"_filepathEdit",
".",
"text",
"(",
")",
")",
"if",
... | Prompts the user to select a filepath from the system based on the \
current filepath mode. | [
"Prompts",
"the",
"user",
"to",
"select",
"a",
"filepath",
"from",
"the",
"system",
"based",
"on",
"the",
"\\",
"current",
"filepath",
"mode",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xfilepathedit.py#L322-L363 | train |
bitesofcode/projexui | projexui/widgets/xfilepathedit.py | XFilepathEdit.showMenu | def showMenu( self, pos ):
"""
Popups a menu for this widget.
"""
menu = QMenu(self)
menu.setAttribute(Qt.WA_DeleteOnClose)
menu.addAction('Clear').triggered.connect(self.clearFilepath)
menu.addSeparator()
menu.addAction('Copy Filepath').triggered.connect(... | python | def showMenu( self, pos ):
"""
Popups a menu for this widget.
"""
menu = QMenu(self)
menu.setAttribute(Qt.WA_DeleteOnClose)
menu.addAction('Clear').triggered.connect(self.clearFilepath)
menu.addSeparator()
menu.addAction('Copy Filepath').triggered.connect(... | [
"def",
"showMenu",
"(",
"self",
",",
"pos",
")",
":",
"menu",
"=",
"QMenu",
"(",
"self",
")",
"menu",
".",
"setAttribute",
"(",
"Qt",
".",
"WA_DeleteOnClose",
")",
"menu",
".",
"addAction",
"(",
"'Clear'",
")",
".",
"triggered",
".",
"connect",
"(",
... | Popups a menu for this widget. | [
"Popups",
"a",
"menu",
"for",
"this",
"widget",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xfilepathedit.py#L519-L529 | train |
bitesofcode/projexui | projexui/widgets/xfilepathedit.py | XFilepathEdit.validateFilepath | def validateFilepath( self ):
"""
Alters the color scheme based on the validation settings.
"""
if ( not self.isValidated() ):
return
valid = self.isValid()
if ( not valid ):
fg = self.invalidForeground()
bg = self.invalidBackg... | python | def validateFilepath( self ):
"""
Alters the color scheme based on the validation settings.
"""
if ( not self.isValidated() ):
return
valid = self.isValid()
if ( not valid ):
fg = self.invalidForeground()
bg = self.invalidBackg... | [
"def",
"validateFilepath",
"(",
"self",
")",
":",
"if",
"(",
"not",
"self",
".",
"isValidated",
"(",
")",
")",
":",
"return",
"valid",
"=",
"self",
".",
"isValid",
"(",
")",
"if",
"(",
"not",
"valid",
")",
":",
"fg",
"=",
"self",
".",
"invalidForeg... | Alters the color scheme based on the validation settings. | [
"Alters",
"the",
"color",
"scheme",
"based",
"on",
"the",
"validation",
"settings",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xfilepathedit.py#L547-L565 | train |
bitesofcode/projexui | projexui/widgets/xorbrecordsetedit/xorbrecordsetedit.py | XOrbRecordSetEdit.clear | def clear( self ):
"""
Clears the information for this edit.
"""
self.uiQueryTXT.setText('')
self.uiQueryTREE.clear()
self.uiGroupingTXT.setText('')
self.uiSortingTXT.setText('') | python | def clear( self ):
"""
Clears the information for this edit.
"""
self.uiQueryTXT.setText('')
self.uiQueryTREE.clear()
self.uiGroupingTXT.setText('')
self.uiSortingTXT.setText('') | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"uiQueryTXT",
".",
"setText",
"(",
"''",
")",
"self",
".",
"uiQueryTREE",
".",
"clear",
"(",
")",
"self",
".",
"uiGroupingTXT",
".",
"setText",
"(",
"''",
")",
"self",
".",
"uiSortingTXT",
".",
"set... | Clears the information for this edit. | [
"Clears",
"the",
"information",
"for",
"this",
"edit",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbrecordsetedit/xorbrecordsetedit.py#L216-L223 | train |
bitesofcode/projexui | projexui/widgets/xorbrecordwidget.py | XOrbRecordWidget.save | def save(self):
"""
Saves the changes from the ui to this widgets record instance.
"""
record = self.record()
if not record:
logger.warning('No record has been defined for %s.' % self)
return False
if not self.signalsBlocked():
... | python | def save(self):
"""
Saves the changes from the ui to this widgets record instance.
"""
record = self.record()
if not record:
logger.warning('No record has been defined for %s.' % self)
return False
if not self.signalsBlocked():
... | [
"def",
"save",
"(",
"self",
")",
":",
"record",
"=",
"self",
".",
"record",
"(",
")",
"if",
"not",
"record",
":",
"logger",
".",
"warning",
"(",
"'No record has been defined for %s.'",
"%",
"self",
")",
"return",
"False",
"if",
"not",
"self",
".",
"signa... | Saves the changes from the ui to this widgets record instance. | [
"Saves",
"the",
"changes",
"from",
"the",
"ui",
"to",
"this",
"widgets",
"record",
"instance",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbrecordwidget.py#L201-L275 | train |
intelsdi-x/snap-plugin-lib-py | snap_plugin/v1/namespace.py | Namespace.add_dynamic_element | def add_dynamic_element(self, name, description):
"""Adds a dynamic namespace element to the end of the Namespace.
A dynamic namespace element is defined by an element that contains a
non-static data relative to the metric being collected. For instance,
when collecting metrics for a gi... | python | def add_dynamic_element(self, name, description):
"""Adds a dynamic namespace element to the end of the Namespace.
A dynamic namespace element is defined by an element that contains a
non-static data relative to the metric being collected. For instance,
when collecting metrics for a gi... | [
"def",
"add_dynamic_element",
"(",
"self",
",",
"name",
",",
"description",
")",
":",
"self",
".",
"_pb",
".",
"add",
"(",
"Name",
"=",
"name",
",",
"Description",
"=",
"description",
",",
"Value",
"=",
"\"*\"",
")",
"return",
"self"
] | Adds a dynamic namespace element to the end of the Namespace.
A dynamic namespace element is defined by an element that contains a
non-static data relative to the metric being collected. For instance,
when collecting metrics for a given virtual machine the namespace
element that contai... | [
"Adds",
"a",
"dynamic",
"namespace",
"element",
"to",
"the",
"end",
"of",
"the",
"Namespace",
"."
] | 8da5d00ac5f9d2b48a7239563ac7788209891ca4 | https://github.com/intelsdi-x/snap-plugin-lib-py/blob/8da5d00ac5f9d2b48a7239563ac7788209891ca4/snap_plugin/v1/namespace.py#L71-L90 | train |
SkullTech/webdriver-start | wdstart/webdriver.py | Chrome | def Chrome(headless=False, user_agent=None, profile_path=None):
"""
Starts and returns a Selenium webdriver object for Chrome.
Starts a Selenium webdriver according to the given specifications,
and returns the corresponding `selenium.webdriver.Chrome` object.
Parameters
----------
headles... | python | def Chrome(headless=False, user_agent=None, profile_path=None):
"""
Starts and returns a Selenium webdriver object for Chrome.
Starts a Selenium webdriver according to the given specifications,
and returns the corresponding `selenium.webdriver.Chrome` object.
Parameters
----------
headles... | [
"def",
"Chrome",
"(",
"headless",
"=",
"False",
",",
"user_agent",
"=",
"None",
",",
"profile_path",
"=",
"None",
")",
":",
"chromedriver",
"=",
"drivers",
".",
"ChromeDriver",
"(",
"headless",
",",
"user_agent",
",",
"profile_path",
")",
"return",
"chromedr... | Starts and returns a Selenium webdriver object for Chrome.
Starts a Selenium webdriver according to the given specifications,
and returns the corresponding `selenium.webdriver.Chrome` object.
Parameters
----------
headless : bool
Whether to start the browser in headless mode.
user_age... | [
"Starts",
"and",
"returns",
"a",
"Selenium",
"webdriver",
"object",
"for",
"Chrome",
"."
] | 26285fd84c4deaf8906828e0ec0758a650b7ba49 | https://github.com/SkullTech/webdriver-start/blob/26285fd84c4deaf8906828e0ec0758a650b7ba49/wdstart/webdriver.py#L9-L31 | train |
SkullTech/webdriver-start | wdstart/webdriver.py | Firefox | def Firefox(headless=False, user_agent=None, profile_path=None):
"""
Starts and returns a Selenium webdriver object for Firefox.
Starts a Selenium webdriver according to the given specifications,
and returns the corresponding `selenium.webdriver.Chrome` object.
Parameters
----------
headl... | python | def Firefox(headless=False, user_agent=None, profile_path=None):
"""
Starts and returns a Selenium webdriver object for Firefox.
Starts a Selenium webdriver according to the given specifications,
and returns the corresponding `selenium.webdriver.Chrome` object.
Parameters
----------
headl... | [
"def",
"Firefox",
"(",
"headless",
"=",
"False",
",",
"user_agent",
"=",
"None",
",",
"profile_path",
"=",
"None",
")",
":",
"firefoxdriver",
"=",
"drivers",
".",
"FirefoxDriver",
"(",
"headless",
",",
"user_agent",
",",
"profile_path",
")",
"return",
"firef... | Starts and returns a Selenium webdriver object for Firefox.
Starts a Selenium webdriver according to the given specifications,
and returns the corresponding `selenium.webdriver.Chrome` object.
Parameters
----------
headless : bool
Whether to start the browser in headless mode.
user_ag... | [
"Starts",
"and",
"returns",
"a",
"Selenium",
"webdriver",
"object",
"for",
"Firefox",
"."
] | 26285fd84c4deaf8906828e0ec0758a650b7ba49 | https://github.com/SkullTech/webdriver-start/blob/26285fd84c4deaf8906828e0ec0758a650b7ba49/wdstart/webdriver.py#L34-L56 | train |
bitesofcode/projexui | projexui/xorblookupworker.py | XOrbLookupWorker.cancel | def cancel(self):
"""
Cancels the current lookup.
"""
if self._running:
self.interrupt()
self._running = False
self._cancelled = True
self.loadingFinished.emit() | python | def cancel(self):
"""
Cancels the current lookup.
"""
if self._running:
self.interrupt()
self._running = False
self._cancelled = True
self.loadingFinished.emit() | [
"def",
"cancel",
"(",
"self",
")",
":",
"if",
"self",
".",
"_running",
":",
"self",
".",
"interrupt",
"(",
")",
"self",
".",
"_running",
"=",
"False",
"self",
".",
"_cancelled",
"=",
"True",
"self",
".",
"loadingFinished",
".",
"emit",
"(",
")"
] | Cancels the current lookup. | [
"Cancels",
"the",
"current",
"lookup",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xorblookupworker.py#L56-L64 | train |
bitesofcode/projexui | projexui/xorblookupworker.py | XOrbLookupWorker.loadBatch | def loadBatch(self, records):
"""
Loads the records for this instance in a batched mode.
"""
try:
curr_batch = records[:self.batchSize()]
next_batch = records[self.batchSize():]
curr_records = list(curr_batch)
if self.... | python | def loadBatch(self, records):
"""
Loads the records for this instance in a batched mode.
"""
try:
curr_batch = records[:self.batchSize()]
next_batch = records[self.batchSize():]
curr_records = list(curr_batch)
if self.... | [
"def",
"loadBatch",
"(",
"self",
",",
"records",
")",
":",
"try",
":",
"curr_batch",
"=",
"records",
"[",
":",
"self",
".",
"batchSize",
"(",
")",
"]",
"next_batch",
"=",
"records",
"[",
"self",
".",
"batchSize",
"(",
")",
":",
"]",
"curr_records",
"... | Loads the records for this instance in a batched mode. | [
"Loads",
"the",
"records",
"for",
"this",
"instance",
"in",
"a",
"batched",
"mode",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xorblookupworker.py#L104-L127 | train |
xflr6/fileconfig | fileconfig/bases.py | Config.names | def names(self):
"""Names, by which the instance can be retrieved."""
if getattr(self, 'key', None) is None:
result = []
else:
result = [self.key]
if hasattr(self, 'aliases'):
result.extend(self.aliases)
return result | python | def names(self):
"""Names, by which the instance can be retrieved."""
if getattr(self, 'key', None) is None:
result = []
else:
result = [self.key]
if hasattr(self, 'aliases'):
result.extend(self.aliases)
return result | [
"def",
"names",
"(",
"self",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"'key'",
",",
"None",
")",
"is",
"None",
":",
"result",
"=",
"[",
"]",
"else",
":",
"result",
"=",
"[",
"self",
".",
"key",
"]",
"if",
"hasattr",
"(",
"self",
",",
"'alia... | Names, by which the instance can be retrieved. | [
"Names",
"by",
"which",
"the",
"instance",
"can",
"be",
"retrieved",
"."
] | 473d65f6442eb1ac49ada0b6e56cab45f8018c15 | https://github.com/xflr6/fileconfig/blob/473d65f6442eb1ac49ada0b6e56cab45f8018c15/fileconfig/bases.py#L27-L35 | train |
bitesofcode/projexui | projexui/widgets/xwalkthroughwidget/xwalkthroughscene.py | XWalkthroughScene.autoLayout | def autoLayout(self, size=None):
"""
Updates the layout for the graphics within this scene.
"""
if size is None:
size = self._view.size()
self.setSceneRect(0, 0, size.width(), size.height())
for item in self.items():
if isinstance... | python | def autoLayout(self, size=None):
"""
Updates the layout for the graphics within this scene.
"""
if size is None:
size = self._view.size()
self.setSceneRect(0, 0, size.width(), size.height())
for item in self.items():
if isinstance... | [
"def",
"autoLayout",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"self",
".",
"_view",
".",
"size",
"(",
")",
"self",
".",
"setSceneRect",
"(",
"0",
",",
"0",
",",
"size",
".",
"width",
"(",
")... | Updates the layout for the graphics within this scene. | [
"Updates",
"the",
"layout",
"for",
"the",
"graphics",
"within",
"this",
"scene",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xwalkthroughwidget/xwalkthroughscene.py#L46-L56 | train |
bitesofcode/projexui | projexui/widgets/xwalkthroughwidget/xwalkthroughscene.py | XWalkthroughScene.prepare | def prepare(self):
"""
Prepares the items for display.
"""
for item in self.items():
if isinstance(item, XWalkthroughGraphic):
item.prepare() | python | def prepare(self):
"""
Prepares the items for display.
"""
for item in self.items():
if isinstance(item, XWalkthroughGraphic):
item.prepare() | [
"def",
"prepare",
"(",
"self",
")",
":",
"for",
"item",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"XWalkthroughGraphic",
")",
":",
"item",
".",
"prepare",
"(",
")"
] | Prepares the items for display. | [
"Prepares",
"the",
"items",
"for",
"display",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xwalkthroughwidget/xwalkthroughscene.py#L83-L89 | train |
bitesofcode/projexui | projexui/widgets/xwalkthroughwidget/xwalkthroughgraphics.py | XWalkthroughGraphic.autoLayout | def autoLayout(self, size):
"""
Lays out this widget within the graphics scene.
"""
# update the children alignment
direction = self.property('direction', QtGui.QBoxLayout.TopToBottom)
x = 0
y = 0
base_off_x = 0
base_off_y = 0
... | python | def autoLayout(self, size):
"""
Lays out this widget within the graphics scene.
"""
# update the children alignment
direction = self.property('direction', QtGui.QBoxLayout.TopToBottom)
x = 0
y = 0
base_off_x = 0
base_off_y = 0
... | [
"def",
"autoLayout",
"(",
"self",
",",
"size",
")",
":",
"direction",
"=",
"self",
".",
"property",
"(",
"'direction'",
",",
"QtGui",
".",
"QBoxLayout",
".",
"TopToBottom",
")",
"x",
"=",
"0",
"y",
"=",
"0",
"base_off_x",
"=",
"0",
"base_off_y",
"=",
... | Lays out this widget within the graphics scene. | [
"Lays",
"out",
"this",
"widget",
"within",
"the",
"graphics",
"scene",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xwalkthroughwidget/xwalkthroughgraphics.py#L105-L177 | train |
bitesofcode/projexui | projexui/widgets/xwalkthroughwidget/xwalkthroughgraphics.py | XWalkthroughGraphic.prepare | def prepare(self):
"""
Prepares this graphic item to be displayed.
"""
text = self.property('caption')
if text:
capw = int(self.property('caption_width', 0))
item = self.addText(text, capw) | python | def prepare(self):
"""
Prepares this graphic item to be displayed.
"""
text = self.property('caption')
if text:
capw = int(self.property('caption_width', 0))
item = self.addText(text, capw) | [
"def",
"prepare",
"(",
"self",
")",
":",
"text",
"=",
"self",
".",
"property",
"(",
"'caption'",
")",
"if",
"text",
":",
"capw",
"=",
"int",
"(",
"self",
".",
"property",
"(",
"'caption_width'",
",",
"0",
")",
")",
"item",
"=",
"self",
".",
"addTex... | Prepares this graphic item to be displayed. | [
"Prepares",
"this",
"graphic",
"item",
"to",
"be",
"displayed",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xwalkthroughwidget/xwalkthroughgraphics.py#L209-L216 | train |
bitesofcode/projexui | projexui/widgets/xwalkthroughwidget/xwalkthroughgraphics.py | XWalkthroughSnapshot.prepare | def prepare(self):
"""
Prepares the information for this graphic.
"""
# determine if we already have a snapshot setup
pixmap = self.property('pixmap')
if pixmap is not None:
return super(XWalkthroughSnapshot, self).prepare()
# otherwi... | python | def prepare(self):
"""
Prepares the information for this graphic.
"""
# determine if we already have a snapshot setup
pixmap = self.property('pixmap')
if pixmap is not None:
return super(XWalkthroughSnapshot, self).prepare()
# otherwi... | [
"def",
"prepare",
"(",
"self",
")",
":",
"pixmap",
"=",
"self",
".",
"property",
"(",
"'pixmap'",
")",
"if",
"pixmap",
"is",
"not",
"None",
":",
"return",
"super",
"(",
"XWalkthroughSnapshot",
",",
"self",
")",
".",
"prepare",
"(",
")",
"widget",
"=",
... | Prepares the information for this graphic. | [
"Prepares",
"the",
"information",
"for",
"this",
"graphic",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xwalkthroughwidget/xwalkthroughgraphics.py#L280-L342 | train |
nprapps/mapturner | mapturner/__init__.py | MapTurner.get_real_layer_path | def get_real_layer_path(self, path):
"""
Get the path the actual layer file.
"""
filename = path.split('/')[-1]
local_path = path
filetype = os.path.splitext(filename)[1]
# Url
if re.match(r'^[a-zA-Z]+://', path):
local_path = os.path.join(DAT... | python | def get_real_layer_path(self, path):
"""
Get the path the actual layer file.
"""
filename = path.split('/')[-1]
local_path = path
filetype = os.path.splitext(filename)[1]
# Url
if re.match(r'^[a-zA-Z]+://', path):
local_path = os.path.join(DAT... | [
"def",
"get_real_layer_path",
"(",
"self",
",",
"path",
")",
":",
"filename",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"local_path",
"=",
"path",
"filetype",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"[",
... | Get the path the actual layer file. | [
"Get",
"the",
"path",
"the",
"actual",
"layer",
"file",
"."
] | fc9747c9d1584af2053bff3df229a460ef2a5f62 | https://github.com/nprapps/mapturner/blob/fc9747c9d1584af2053bff3df229a460ef2a5f62/mapturner/__init__.py#L122-L157 | train |
nprapps/mapturner | mapturner/__init__.py | MapTurner.download_file | def download_file(self, url, local_path):
"""
Download a file from a remote host.
"""
response = requests.get(url, stream=True)
with open(local_path, 'wb') as f:
for chunk in tqdm(response.iter_content(chunk_size=1024), unit='KB'):
if chunk: # filter ... | python | def download_file(self, url, local_path):
"""
Download a file from a remote host.
"""
response = requests.get(url, stream=True)
with open(local_path, 'wb') as f:
for chunk in tqdm(response.iter_content(chunk_size=1024), unit='KB'):
if chunk: # filter ... | [
"def",
"download_file",
"(",
"self",
",",
"url",
",",
"local_path",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"stream",
"=",
"True",
")",
"with",
"open",
"(",
"local_path",
",",
"'wb'",
")",
"as",
"f",
":",
"for",
"chunk",
... | Download a file from a remote host. | [
"Download",
"a",
"file",
"from",
"a",
"remote",
"host",
"."
] | fc9747c9d1584af2053bff3df229a460ef2a5f62 | https://github.com/nprapps/mapturner/blob/fc9747c9d1584af2053bff3df229a460ef2a5f62/mapturner/__init__.py#L159-L169 | train |
nprapps/mapturner | mapturner/__init__.py | MapTurner.unzip_file | def unzip_file(self, zip_path, output_path):
"""
Unzip a local file into a specified directory.
"""
with zipfile.ZipFile(zip_path, 'r') as z:
z.extractall(output_path) | python | def unzip_file(self, zip_path, output_path):
"""
Unzip a local file into a specified directory.
"""
with zipfile.ZipFile(zip_path, 'r') as z:
z.extractall(output_path) | [
"def",
"unzip_file",
"(",
"self",
",",
"zip_path",
",",
"output_path",
")",
":",
"with",
"zipfile",
".",
"ZipFile",
"(",
"zip_path",
",",
"'r'",
")",
"as",
"z",
":",
"z",
".",
"extractall",
"(",
"output_path",
")"
] | Unzip a local file into a specified directory. | [
"Unzip",
"a",
"local",
"file",
"into",
"a",
"specified",
"directory",
"."
] | fc9747c9d1584af2053bff3df229a460ef2a5f62 | https://github.com/nprapps/mapturner/blob/fc9747c9d1584af2053bff3df229a460ef2a5f62/mapturner/__init__.py#L171-L176 | train |
nprapps/mapturner | mapturner/__init__.py | MapTurner.process_ogr2ogr | def process_ogr2ogr(self, name, layer, input_path):
"""
Process a layer using ogr2ogr.
"""
output_path = os.path.join(TEMP_DIRECTORY, '%s.json' % name)
if os.path.exists(output_path):
os.remove(output_path)
ogr2ogr_cmd = [
'ogr2ogr',
... | python | def process_ogr2ogr(self, name, layer, input_path):
"""
Process a layer using ogr2ogr.
"""
output_path = os.path.join(TEMP_DIRECTORY, '%s.json' % name)
if os.path.exists(output_path):
os.remove(output_path)
ogr2ogr_cmd = [
'ogr2ogr',
... | [
"def",
"process_ogr2ogr",
"(",
"self",
",",
"name",
",",
"layer",
",",
"input_path",
")",
":",
"output_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"TEMP_DIRECTORY",
",",
"'%s.json'",
"%",
"name",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
... | Process a layer using ogr2ogr. | [
"Process",
"a",
"layer",
"using",
"ogr2ogr",
"."
] | fc9747c9d1584af2053bff3df229a460ef2a5f62 | https://github.com/nprapps/mapturner/blob/fc9747c9d1584af2053bff3df229a460ef2a5f62/mapturner/__init__.py#L193-L228 | train |
nprapps/mapturner | mapturner/__init__.py | MapTurner.process_topojson | def process_topojson(self, name, layer, input_path):
"""
Process layer using topojson.
"""
output_path = os.path.join(TEMP_DIRECTORY, '%s.topojson' % name)
# Use local topojson binary
topojson_binary = 'node_modules/bin/topojson'
if not os.path.exists(topojson_b... | python | def process_topojson(self, name, layer, input_path):
"""
Process layer using topojson.
"""
output_path = os.path.join(TEMP_DIRECTORY, '%s.topojson' % name)
# Use local topojson binary
topojson_binary = 'node_modules/bin/topojson'
if not os.path.exists(topojson_b... | [
"def",
"process_topojson",
"(",
"self",
",",
"name",
",",
"layer",
",",
"input_path",
")",
":",
"output_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"TEMP_DIRECTORY",
",",
"'%s.topojson'",
"%",
"name",
")",
"topojson_binary",
"=",
"'node_modules/bin/topojs... | Process layer using topojson. | [
"Process",
"layer",
"using",
"topojson",
"."
] | fc9747c9d1584af2053bff3df229a460ef2a5f62 | https://github.com/nprapps/mapturner/blob/fc9747c9d1584af2053bff3df229a460ef2a5f62/mapturner/__init__.py#L230-L275 | train |
nprapps/mapturner | mapturner/__init__.py | MapTurner.merge | def merge(self, paths):
"""
Merge data layers into a single topojson file.
"""
# Use local topojson binary
topojson_binary = 'node_modules/bin/topojson'
if not os.path.exists(topojson_binary):
# try with global topojson binary
topojson_binary = '... | python | def merge(self, paths):
"""
Merge data layers into a single topojson file.
"""
# Use local topojson binary
topojson_binary = 'node_modules/bin/topojson'
if not os.path.exists(topojson_binary):
# try with global topojson binary
topojson_binary = '... | [
"def",
"merge",
"(",
"self",
",",
"paths",
")",
":",
"topojson_binary",
"=",
"'node_modules/bin/topojson'",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"topojson_binary",
")",
":",
"topojson_binary",
"=",
"'topojson'",
"merge_cmd",
"=",
"'%(binary)s -o %... | Merge data layers into a single topojson file. | [
"Merge",
"data",
"layers",
"into",
"a",
"single",
"topojson",
"file",
"."
] | fc9747c9d1584af2053bff3df229a460ef2a5f62 | https://github.com/nprapps/mapturner/blob/fc9747c9d1584af2053bff3df229a460ef2a5f62/mapturner/__init__.py#L277-L303 | train |
bitesofcode/projexui | projexui/widgets/xmenutemplatewidget/xmenutemplatewidget.py | XMenuTemplateWidget.createMenu | def createMenu( self ):
"""
Creates a new menu with the given name.
"""
name, accepted = QInputDialog.getText( self,
'Create Menu',
'Name: ')
if ( accepted ):
self.a... | python | def createMenu( self ):
"""
Creates a new menu with the given name.
"""
name, accepted = QInputDialog.getText( self,
'Create Menu',
'Name: ')
if ( accepted ):
self.a... | [
"def",
"createMenu",
"(",
"self",
")",
":",
"name",
",",
"accepted",
"=",
"QInputDialog",
".",
"getText",
"(",
"self",
",",
"'Create Menu'",
",",
"'Name: '",
")",
"if",
"(",
"accepted",
")",
":",
"self",
".",
"addMenuItem",
"(",
"self",
".",
"createMenuI... | Creates a new menu with the given name. | [
"Creates",
"a",
"new",
"menu",
"with",
"the",
"given",
"name",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xmenutemplatewidget/xmenutemplatewidget.py#L120-L130 | train |
bitesofcode/projexui | projexui/widgets/xmenutemplatewidget/xmenutemplatewidget.py | XMenuTemplateWidget.removeItem | def removeItem( self ):
"""
Removes the item from the menu.
"""
item = self.uiMenuTREE.currentItem()
if ( not item ):
return
opts = QMessageBox.Yes | QMessageBox.No
answer = QMessageBox.question( self,
'R... | python | def removeItem( self ):
"""
Removes the item from the menu.
"""
item = self.uiMenuTREE.currentItem()
if ( not item ):
return
opts = QMessageBox.Yes | QMessageBox.No
answer = QMessageBox.question( self,
'R... | [
"def",
"removeItem",
"(",
"self",
")",
":",
"item",
"=",
"self",
".",
"uiMenuTREE",
".",
"currentItem",
"(",
")",
"if",
"(",
"not",
"item",
")",
":",
"return",
"opts",
"=",
"QMessageBox",
".",
"Yes",
"|",
"QMessageBox",
".",
"No",
"answer",
"=",
"QMe... | Removes the item from the menu. | [
"Removes",
"the",
"item",
"from",
"the",
"menu",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xmenutemplatewidget/xmenutemplatewidget.py#L248-L269 | train |
bitesofcode/projexui | projexui/widgets/xmenutemplatewidget/xmenutemplatewidget.py | XMenuTemplateWidget.renameMenu | def renameMenu( self ):
"""
Prompts the user to supply a new name for the menu.
"""
item = self.uiMenuTREE.currentItem()
name, accepted = QInputDialog.getText( self,
'Rename Menu',
... | python | def renameMenu( self ):
"""
Prompts the user to supply a new name for the menu.
"""
item = self.uiMenuTREE.currentItem()
name, accepted = QInputDialog.getText( self,
'Rename Menu',
... | [
"def",
"renameMenu",
"(",
"self",
")",
":",
"item",
"=",
"self",
".",
"uiMenuTREE",
".",
"currentItem",
"(",
")",
"name",
",",
"accepted",
"=",
"QInputDialog",
".",
"getText",
"(",
"self",
",",
"'Rename Menu'",
",",
"'Name:'",
",",
"QLineEdit",
".",
"Nor... | Prompts the user to supply a new name for the menu. | [
"Prompts",
"the",
"user",
"to",
"supply",
"a",
"new",
"name",
"for",
"the",
"menu",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xmenutemplatewidget/xmenutemplatewidget.py#L271-L283 | train |
bitesofcode/projexui | projexui/widgets/xmenutemplatewidget/xmenutemplatewidget.py | XMenuTemplateWidget.showMenu | def showMenu( self ):
"""
Creates a menu to display for the editing of template information.
"""
item = self.uiMenuTREE.currentItem()
menu = QMenu(self)
act = menu.addAction('Add Menu...')
act.setIcon(QIcon(projexui.resources.find('img/folder.png')))
... | python | def showMenu( self ):
"""
Creates a menu to display for the editing of template information.
"""
item = self.uiMenuTREE.currentItem()
menu = QMenu(self)
act = menu.addAction('Add Menu...')
act.setIcon(QIcon(projexui.resources.find('img/folder.png')))
... | [
"def",
"showMenu",
"(",
"self",
")",
":",
"item",
"=",
"self",
".",
"uiMenuTREE",
".",
"currentItem",
"(",
")",
"menu",
"=",
"QMenu",
"(",
"self",
")",
"act",
"=",
"menu",
".",
"addAction",
"(",
"'Add Menu...'",
")",
"act",
".",
"setIcon",
"(",
"QIco... | Creates a menu to display for the editing of template information. | [
"Creates",
"a",
"menu",
"to",
"display",
"for",
"the",
"editing",
"of",
"template",
"information",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xmenutemplatewidget/xmenutemplatewidget.py#L350-L378 | train |
solarnz/Flask-Stats | flask_stats/__init__.py | Stats.init_app | def init_app(self, app):
"""Inititialise the extension with the app object.
:param app: Your application object
"""
host = app.config.get('STATS_HOSTNAME', 'localhost')
port = app.config.get('STATS_PORT', 8125)
base_key = app.config.get('STATS_BASE_KEY', app.name)
... | python | def init_app(self, app):
"""Inititialise the extension with the app object.
:param app: Your application object
"""
host = app.config.get('STATS_HOSTNAME', 'localhost')
port = app.config.get('STATS_PORT', 8125)
base_key = app.config.get('STATS_BASE_KEY', app.name)
... | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"host",
"=",
"app",
".",
"config",
".",
"get",
"(",
"'STATS_HOSTNAME'",
",",
"'localhost'",
")",
"port",
"=",
"app",
".",
"config",
".",
"get",
"(",
"'STATS_PORT'",
",",
"8125",
")",
"base_key",
"... | Inititialise the extension with the app object.
:param app: Your application object | [
"Inititialise",
"the",
"extension",
"with",
"the",
"app",
"object",
"."
] | de9e476a30a98c9aa0eec4b9a18b150c905c382e | https://github.com/solarnz/Flask-Stats/blob/de9e476a30a98c9aa0eec4b9a18b150c905c382e/flask_stats/__init__.py#L50-L73 | train |
Zitrax/nose-dep | nosedep.py | depends | def depends(func=None, after=None, before=None, priority=None):
"""Decorator to specify test dependencies
:param after: The test needs to run after this/these tests. String or list of strings.
:param before: The test needs to run before this/these tests. String or list of strings.
"""
if not (func ... | python | def depends(func=None, after=None, before=None, priority=None):
"""Decorator to specify test dependencies
:param after: The test needs to run after this/these tests. String or list of strings.
:param before: The test needs to run before this/these tests. String or list of strings.
"""
if not (func ... | [
"def",
"depends",
"(",
"func",
"=",
"None",
",",
"after",
"=",
"None",
",",
"before",
"=",
"None",
",",
"priority",
"=",
"None",
")",
":",
"if",
"not",
"(",
"func",
"is",
"None",
"or",
"inspect",
".",
"ismethod",
"(",
"func",
")",
"or",
"inspect",
... | Decorator to specify test dependencies
:param after: The test needs to run after this/these tests. String or list of strings.
:param before: The test needs to run before this/these tests. String or list of strings. | [
"Decorator",
"to",
"specify",
"test",
"dependencies"
] | fd29c95e0e5eb2dbd821f6566b72dfcf42631226 | https://github.com/Zitrax/nose-dep/blob/fd29c95e0e5eb2dbd821f6566b72dfcf42631226/nosedep.py#L84-L127 | train |
Zitrax/nose-dep | nosedep.py | split_on_condition | def split_on_condition(seq, condition):
"""Split a sequence into two iterables without looping twice"""
l1, l2 = tee((condition(item), item) for item in seq)
return (i for p, i in l1 if p), (i for p, i in l2 if not p) | python | def split_on_condition(seq, condition):
"""Split a sequence into two iterables without looping twice"""
l1, l2 = tee((condition(item), item) for item in seq)
return (i for p, i in l1 if p), (i for p, i in l2 if not p) | [
"def",
"split_on_condition",
"(",
"seq",
",",
"condition",
")",
":",
"l1",
",",
"l2",
"=",
"tee",
"(",
"(",
"condition",
"(",
"item",
")",
",",
"item",
")",
"for",
"item",
"in",
"seq",
")",
"return",
"(",
"i",
"for",
"p",
",",
"i",
"in",
"l1",
... | Split a sequence into two iterables without looping twice | [
"Split",
"a",
"sequence",
"into",
"two",
"iterables",
"without",
"looping",
"twice"
] | fd29c95e0e5eb2dbd821f6566b72dfcf42631226 | https://github.com/Zitrax/nose-dep/blob/fd29c95e0e5eb2dbd821f6566b72dfcf42631226/nosedep.py#L195-L198 | train |
Zitrax/nose-dep | nosedep.py | NoseDep.prepare_suite | def prepare_suite(self, suite):
"""Prepare suite and determine test ordering"""
all_tests = {}
for s in suite:
m = re.match(r'(\w+)\s+\(.+\)', str(s))
if m:
name = m.group(1)
else:
name = str(s).split('.')[-1]
all_te... | python | def prepare_suite(self, suite):
"""Prepare suite and determine test ordering"""
all_tests = {}
for s in suite:
m = re.match(r'(\w+)\s+\(.+\)', str(s))
if m:
name = m.group(1)
else:
name = str(s).split('.')[-1]
all_te... | [
"def",
"prepare_suite",
"(",
"self",
",",
"suite",
")",
":",
"all_tests",
"=",
"{",
"}",
"for",
"s",
"in",
"suite",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r'(\\w+)\\s+\\(.+\\)'",
",",
"str",
"(",
"s",
")",
")",
"if",
"m",
":",
"name",
"=",
"m",... | Prepare suite and determine test ordering | [
"Prepare",
"suite",
"and",
"determine",
"test",
"ordering"
] | fd29c95e0e5eb2dbd821f6566b72dfcf42631226 | https://github.com/Zitrax/nose-dep/blob/fd29c95e0e5eb2dbd821f6566b72dfcf42631226/nosedep.py#L268-L279 | train |
Zitrax/nose-dep | nosedep.py | NoseDep.dependency_ran | def dependency_ran(self, test):
"""Returns an error string if any of the dependencies did not run"""
for d in (self.test_name(i) for i in dependencies[test]):
if d not in self.ok_results:
return "Required test '{}' did not run (does it exist?)".format(d)
return None | python | def dependency_ran(self, test):
"""Returns an error string if any of the dependencies did not run"""
for d in (self.test_name(i) for i in dependencies[test]):
if d not in self.ok_results:
return "Required test '{}' did not run (does it exist?)".format(d)
return None | [
"def",
"dependency_ran",
"(",
"self",
",",
"test",
")",
":",
"for",
"d",
"in",
"(",
"self",
".",
"test_name",
"(",
"i",
")",
"for",
"i",
"in",
"dependencies",
"[",
"test",
"]",
")",
":",
"if",
"d",
"not",
"in",
"self",
".",
"ok_results",
":",
"re... | Returns an error string if any of the dependencies did not run | [
"Returns",
"an",
"error",
"string",
"if",
"any",
"of",
"the",
"dependencies",
"did",
"not",
"run"
] | fd29c95e0e5eb2dbd821f6566b72dfcf42631226 | https://github.com/Zitrax/nose-dep/blob/fd29c95e0e5eb2dbd821f6566b72dfcf42631226/nosedep.py#L332-L337 | train |
xflr6/fileconfig | fileconfig/tools.py | class_path | def class_path(cls):
"""Return the path to the source file of the given class."""
if cls.__module__ == '__main__':
path = None
else:
path = os.path.dirname(inspect.getfile(cls))
if not path:
path = os.getcwd()
return os.path.realpath(path) | python | def class_path(cls):
"""Return the path to the source file of the given class."""
if cls.__module__ == '__main__':
path = None
else:
path = os.path.dirname(inspect.getfile(cls))
if not path:
path = os.getcwd()
return os.path.realpath(path) | [
"def",
"class_path",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"__module__",
"==",
"'__main__'",
":",
"path",
"=",
"None",
"else",
":",
"path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"inspect",
".",
"getfile",
"(",
"cls",
")",
")",
"if",
"not",... | Return the path to the source file of the given class. | [
"Return",
"the",
"path",
"to",
"the",
"source",
"file",
"of",
"the",
"given",
"class",
"."
] | 473d65f6442eb1ac49ada0b6e56cab45f8018c15 | https://github.com/xflr6/fileconfig/blob/473d65f6442eb1ac49ada0b6e56cab45f8018c15/fileconfig/tools.py#L10-L20 | train |
xflr6/fileconfig | fileconfig/tools.py | caller_path | def caller_path(steps=1):
"""Return the path to the source file of the current frames' caller."""
frame = sys._getframe(steps + 1)
try:
path = os.path.dirname(frame.f_code.co_filename)
finally:
del frame
if not path:
path = os.getcwd()
return os.path.realpath(path) | python | def caller_path(steps=1):
"""Return the path to the source file of the current frames' caller."""
frame = sys._getframe(steps + 1)
try:
path = os.path.dirname(frame.f_code.co_filename)
finally:
del frame
if not path:
path = os.getcwd()
return os.path.realpath(path) | [
"def",
"caller_path",
"(",
"steps",
"=",
"1",
")",
":",
"frame",
"=",
"sys",
".",
"_getframe",
"(",
"steps",
"+",
"1",
")",
"try",
":",
"path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"frame",
".",
"f_code",
".",
"co_filename",
")",
"finally",... | Return the path to the source file of the current frames' caller. | [
"Return",
"the",
"path",
"to",
"the",
"source",
"file",
"of",
"the",
"current",
"frames",
"caller",
"."
] | 473d65f6442eb1ac49ada0b6e56cab45f8018c15 | https://github.com/xflr6/fileconfig/blob/473d65f6442eb1ac49ada0b6e56cab45f8018c15/fileconfig/tools.py#L23-L35 | train |
viatoriche/microservices | microservices/http/client.py | Resource.resource | def resource(self, *resources):
"""Resource builder with resources url
:param resources: 'one', 'two', 'three'
:return: instance of Resource
"""
resources = tuple(self.resources) + resources
return Resource(self.client, resources) | python | def resource(self, *resources):
"""Resource builder with resources url
:param resources: 'one', 'two', 'three'
:return: instance of Resource
"""
resources = tuple(self.resources) + resources
return Resource(self.client, resources) | [
"def",
"resource",
"(",
"self",
",",
"*",
"resources",
")",
":",
"resources",
"=",
"tuple",
"(",
"self",
".",
"resources",
")",
"+",
"resources",
"return",
"Resource",
"(",
"self",
".",
"client",
",",
"resources",
")"
] | Resource builder with resources url
:param resources: 'one', 'two', 'three'
:return: instance of Resource | [
"Resource",
"builder",
"with",
"resources",
"url"
] | 3510563edd15dc6131b8a948d6062856cd904ac7 | https://github.com/viatoriche/microservices/blob/3510563edd15dc6131b8a948d6062856cd904ac7/microservices/http/client.py#L57-L64 | train |
pmuller/versions | versions/constraint.py | Constraint.match | def match(self, version):
"""Match ``version`` with the constraint.
:param version: Version to match against the constraint.
:type version: :ref:`version expression <version-expressions>` or \
:class:`.Version`
:rtype: ``True`` if ``version`` satisfies the constraint, \
... | python | def match(self, version):
"""Match ``version`` with the constraint.
:param version: Version to match against the constraint.
:type version: :ref:`version expression <version-expressions>` or \
:class:`.Version`
:rtype: ``True`` if ``version`` satisfies the constraint, \
... | [
"def",
"match",
"(",
"self",
",",
"version",
")",
":",
"if",
"isinstance",
"(",
"version",
",",
"basestring",
")",
":",
"version",
"=",
"Version",
".",
"parse",
"(",
"version",
")",
"return",
"self",
".",
"operator",
"(",
"version",
",",
"self",
".",
... | Match ``version`` with the constraint.
:param version: Version to match against the constraint.
:type version: :ref:`version expression <version-expressions>` or \
:class:`.Version`
:rtype: ``True`` if ``version`` satisfies the constraint, \
``False`` if it doesn't. | [
"Match",
"version",
"with",
"the",
"constraint",
"."
] | 951bc3fd99b6a675190f11ee0752af1d7ff5b440 | https://github.com/pmuller/versions/blob/951bc3fd99b6a675190f11ee0752af1d7ff5b440/versions/constraint.py#L61-L72 | train |
ponty/pyavrutils | pyavrutils/cli/arduino/build.py | warnings | def warnings(filename,
board='pro',
hwpack='arduino',
mcu='',
f_cpu='',
extra_lib='',
ver='',
# home='auto',
backend='arscons',
):
'''
build Arduino sketch and dis... | python | def warnings(filename,
board='pro',
hwpack='arduino',
mcu='',
f_cpu='',
extra_lib='',
ver='',
# home='auto',
backend='arscons',
):
'''
build Arduino sketch and dis... | [
"def",
"warnings",
"(",
"filename",
",",
"board",
"=",
"'pro'",
",",
"hwpack",
"=",
"'arduino'",
",",
"mcu",
"=",
"''",
",",
"f_cpu",
"=",
"''",
",",
"extra_lib",
"=",
"''",
",",
"ver",
"=",
"''",
",",
"backend",
"=",
"'arscons'",
",",
")",
":",
... | build Arduino sketch and display results | [
"build",
"Arduino",
"sketch",
"and",
"display",
"results"
] | 7a396a25b3ac076ede07b5cd5cbd416ebb578a28 | https://github.com/ponty/pyavrutils/blob/7a396a25b3ac076ede07b5cd5cbd416ebb578a28/pyavrutils/cli/arduino/build.py#L7-L64 | train |
bitesofcode/projexui | projexui/dialogs/xshortcutdialog/xshortcutdialog.py | XShortcutDialog.accept | def accept( self ):
"""
Saves the current settings for the actions in the list and exits the
dialog.
"""
if ( not self.save() ):
return
for i in range(self.uiActionTREE.topLevelItemCount()):
item = self.uiActionTREE.topLevelItem(i)
... | python | def accept( self ):
"""
Saves the current settings for the actions in the list and exits the
dialog.
"""
if ( not self.save() ):
return
for i in range(self.uiActionTREE.topLevelItemCount()):
item = self.uiActionTREE.topLevelItem(i)
... | [
"def",
"accept",
"(",
"self",
")",
":",
"if",
"(",
"not",
"self",
".",
"save",
"(",
")",
")",
":",
"return",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"uiActionTREE",
".",
"topLevelItemCount",
"(",
")",
")",
":",
"item",
"=",
"self",
".",
"uiA... | Saves the current settings for the actions in the list and exits the
dialog. | [
"Saves",
"the",
"current",
"settings",
"for",
"the",
"actions",
"in",
"the",
"list",
"and",
"exits",
"the",
"dialog",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xshortcutdialog/xshortcutdialog.py#L77-L90 | train |
bitesofcode/projexui | projexui/dialogs/xshortcutdialog/xshortcutdialog.py | XShortcutDialog.clear | def clear( self ):
"""
Clears the current settings for the current action.
"""
item = self.uiActionTREE.currentItem()
if ( not item ):
return
self.uiShortcutTXT.setText('')
item.setText(1, '') | python | def clear( self ):
"""
Clears the current settings for the current action.
"""
item = self.uiActionTREE.currentItem()
if ( not item ):
return
self.uiShortcutTXT.setText('')
item.setText(1, '') | [
"def",
"clear",
"(",
"self",
")",
":",
"item",
"=",
"self",
".",
"uiActionTREE",
".",
"currentItem",
"(",
")",
"if",
"(",
"not",
"item",
")",
":",
"return",
"self",
".",
"uiShortcutTXT",
".",
"setText",
"(",
"''",
")",
"item",
".",
"setText",
"(",
... | Clears the current settings for the current action. | [
"Clears",
"the",
"current",
"settings",
"for",
"the",
"current",
"action",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xshortcutdialog/xshortcutdialog.py#L103-L112 | train |
bitesofcode/projexui | projexui/dialogs/xshortcutdialog/xshortcutdialog.py | XShortcutDialog.updateAction | def updateAction( self ):
"""
Updates the action to edit based on the current item.
"""
item = self.uiActionTREE.currentItem()
if ( item ):
action = item.action()
else:
action = QAction()
self.uiShortcutTXT.setText(action.short... | python | def updateAction( self ):
"""
Updates the action to edit based on the current item.
"""
item = self.uiActionTREE.currentItem()
if ( item ):
action = item.action()
else:
action = QAction()
self.uiShortcutTXT.setText(action.short... | [
"def",
"updateAction",
"(",
"self",
")",
":",
"item",
"=",
"self",
".",
"uiActionTREE",
".",
"currentItem",
"(",
")",
"if",
"(",
"item",
")",
":",
"action",
"=",
"item",
".",
"action",
"(",
")",
"else",
":",
"action",
"=",
"QAction",
"(",
")",
"sel... | Updates the action to edit based on the current item. | [
"Updates",
"the",
"action",
"to",
"edit",
"based",
"on",
"the",
"current",
"item",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/dialogs/xshortcutdialog/xshortcutdialog.py#L181-L191 | train |
damnit/pymite | pymite/utils.py | declassify | def declassify(to_remove, *args, **kwargs):
""" flatten the return values of the mite api.
"""
def argdecorate(fn):
""" enable the to_remove argument to the decorator. """
# wrap the function to get the original docstring
@wraps(fn)
def declassed(*args, **kwargs):
... | python | def declassify(to_remove, *args, **kwargs):
""" flatten the return values of the mite api.
"""
def argdecorate(fn):
""" enable the to_remove argument to the decorator. """
# wrap the function to get the original docstring
@wraps(fn)
def declassed(*args, **kwargs):
... | [
"def",
"declassify",
"(",
"to_remove",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"def",
"argdecorate",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"declassed",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"ret",
"=",
"fn"... | flatten the return values of the mite api. | [
"flatten",
"the",
"return",
"values",
"of",
"the",
"mite",
"api",
"."
] | 1e9b9bf6aef790af2d8781f9f77c098c54ca0342 | https://github.com/damnit/pymite/blob/1e9b9bf6aef790af2d8781f9f77c098c54ca0342/pymite/utils.py#L13-L32 | train |
damnit/pymite | pymite/utils.py | clean_dict | def clean_dict(d):
""" remove the keys with None values. """
ktd = list()
for k, v in d.items():
if not v:
ktd.append(k)
elif type(v) is dict:
d[k] = clean_dict(v)
for k in ktd:
d.pop(k)
return d | python | def clean_dict(d):
""" remove the keys with None values. """
ktd = list()
for k, v in d.items():
if not v:
ktd.append(k)
elif type(v) is dict:
d[k] = clean_dict(v)
for k in ktd:
d.pop(k)
return d | [
"def",
"clean_dict",
"(",
"d",
")",
":",
"ktd",
"=",
"list",
"(",
")",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
":",
"if",
"not",
"v",
":",
"ktd",
".",
"append",
"(",
"k",
")",
"elif",
"type",
"(",
"v",
")",
"is",
"dict",
... | remove the keys with None values. | [
"remove",
"the",
"keys",
"with",
"None",
"values",
"."
] | 1e9b9bf6aef790af2d8781f9f77c098c54ca0342 | https://github.com/damnit/pymite/blob/1e9b9bf6aef790af2d8781f9f77c098c54ca0342/pymite/utils.py#L35-L45 | train |
bitesofcode/projexui | projexui/widgets/xorbcolumnnavigator.py | XOrbColumnItem.load | def load(self):
"""
Loads the children for this item.
"""
if self._loaded:
return
self.setChildIndicatorPolicy(self.DontShowIndicatorWhenChildless)
self._loaded = True
column = self.schemaColumn()
if not column.isRe... | python | def load(self):
"""
Loads the children for this item.
"""
if self._loaded:
return
self.setChildIndicatorPolicy(self.DontShowIndicatorWhenChildless)
self._loaded = True
column = self.schemaColumn()
if not column.isRe... | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"self",
".",
"_loaded",
":",
"return",
"self",
".",
"setChildIndicatorPolicy",
"(",
"self",
".",
"DontShowIndicatorWhenChildless",
")",
"self",
".",
"_loaded",
"=",
"True",
"column",
"=",
"self",
".",
"schemaColumn... | Loads the children for this item. | [
"Loads",
"the",
"children",
"for",
"this",
"item",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbcolumnnavigator.py#L49-L70 | train |
bitesofcode/projexui | projexui/widgets/xorbcolumnnavigator.py | XOrbColumnNavigator.refresh | def refresh(self):
"""
Resets the data for this navigator.
"""
self.setUpdatesEnabled(False)
self.blockSignals(True)
self.clear()
tableType = self.tableType()
if not tableType:
self.setUpdatesEnabled(True)
self.blockSignal... | python | def refresh(self):
"""
Resets the data for this navigator.
"""
self.setUpdatesEnabled(False)
self.blockSignals(True)
self.clear()
tableType = self.tableType()
if not tableType:
self.setUpdatesEnabled(True)
self.blockSignal... | [
"def",
"refresh",
"(",
"self",
")",
":",
"self",
".",
"setUpdatesEnabled",
"(",
"False",
")",
"self",
".",
"blockSignals",
"(",
"True",
")",
"self",
".",
"clear",
"(",
")",
"tableType",
"=",
"self",
".",
"tableType",
"(",
")",
"if",
"not",
"tableType",... | Resets the data for this navigator. | [
"Resets",
"the",
"data",
"for",
"this",
"navigator",
"."
] | f18a73bec84df90b034ca69b9deea118dbedfc4d | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xorbcolumnnavigator.py#L185-L205 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.