id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
37,700 | cwoebker/pen | pen/edit.py | EditDisplay.save_file | def save_file(self):
"""Write the file out to disk."""
l = []
walk = self.walker
for edit in walk.lines:
# collect the text already stored in edit widgets
if edit.original_text.expandtabs() == edit.edit_text:
l.append(edit.original_text)
... | python | def save_file(self):
"""Write the file out to disk."""
l = []
walk = self.walker
for edit in walk.lines:
# collect the text already stored in edit widgets
if edit.original_text.expandtabs() == edit.edit_text:
l.append(edit.original_text)
... | [
"def",
"save_file",
"(",
"self",
")",
":",
"l",
"=",
"[",
"]",
"walk",
"=",
"self",
".",
"walker",
"for",
"edit",
"in",
"walk",
".",
"lines",
":",
"# collect the text already stored in edit widgets",
"if",
"edit",
".",
"original_text",
".",
"expandtabs",
"("... | Write the file out to disk. | [
"Write",
"the",
"file",
"out",
"to",
"disk",
"."
] | 996dfcdc018f2fc14a376835a2622fb4a7230a2f | https://github.com/cwoebker/pen/blob/996dfcdc018f2fc14a376835a2622fb4a7230a2f/pen/edit.py#L152-L184 |
37,701 | moccu/django-markymark | markymark/widgets.py | MarkdownTextarea._media | def _media(self):
"""
Returns a forms.Media instance with the basic editor media and media
from all registered extensions.
"""
css = ['markymark/css/markdown-editor.css']
iconlibrary_css = getattr(
settings,
'MARKYMARK_FONTAWESOME_CSS',
... | python | def _media(self):
"""
Returns a forms.Media instance with the basic editor media and media
from all registered extensions.
"""
css = ['markymark/css/markdown-editor.css']
iconlibrary_css = getattr(
settings,
'MARKYMARK_FONTAWESOME_CSS',
... | [
"def",
"_media",
"(",
"self",
")",
":",
"css",
"=",
"[",
"'markymark/css/markdown-editor.css'",
"]",
"iconlibrary_css",
"=",
"getattr",
"(",
"settings",
",",
"'MARKYMARK_FONTAWESOME_CSS'",
",",
"'markymark/fontawesome/fontawesome.min.css'",
")",
"if",
"iconlibrary_css",
... | Returns a forms.Media instance with the basic editor media and media
from all registered extensions. | [
"Returns",
"a",
"forms",
".",
"Media",
"instance",
"with",
"the",
"basic",
"editor",
"media",
"and",
"media",
"from",
"all",
"registered",
"extensions",
"."
] | c1bf69f439981d6295e5b4d13c26dadf3dba2e9d | https://github.com/moccu/django-markymark/blob/c1bf69f439981d6295e5b4d13c26dadf3dba2e9d/markymark/widgets.py#L22-L48 |
37,702 | NiklasRosenstein-Python/nr-deprecated | nr/path.py | getsuffix | def getsuffix(subject):
"""
Returns the suffix of a filename. If the file has no suffix, returns None.
Can return an empty string if the filenam ends with a period.
"""
index = subject.rfind('.')
if index > subject.replace('\\', '/').rfind('/'):
return subject[index+1:]
return None | python | def getsuffix(subject):
"""
Returns the suffix of a filename. If the file has no suffix, returns None.
Can return an empty string if the filenam ends with a period.
"""
index = subject.rfind('.')
if index > subject.replace('\\', '/').rfind('/'):
return subject[index+1:]
return None | [
"def",
"getsuffix",
"(",
"subject",
")",
":",
"index",
"=",
"subject",
".",
"rfind",
"(",
"'.'",
")",
"if",
"index",
">",
"subject",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
".",
"rfind",
"(",
"'/'",
")",
":",
"return",
"subject",
"[",
"inde... | Returns the suffix of a filename. If the file has no suffix, returns None.
Can return an empty string if the filenam ends with a period. | [
"Returns",
"the",
"suffix",
"of",
"a",
"filename",
".",
"If",
"the",
"file",
"has",
"no",
"suffix",
"returns",
"None",
".",
"Can",
"return",
"an",
"empty",
"string",
"if",
"the",
"filenam",
"ends",
"with",
"a",
"period",
"."
] | f9f8b89ea1b084841a8ab65784eaf68852686b2a | https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/path.py#L257-L266 |
37,703 | Robpol86/Flask-Statics-Helper | flask_statics/__init__.py | Statics.init_app | def init_app(self, app):
"""Initialize the extension."""
# Set default Flask config option.
app.config.setdefault('STATICS_MINIFY', False)
# Select resources.
self.all_resources = ALL_RESOURCES_MINIFIED if app.config.get('STATICS_MINIFY') else ALL_RESOURCES
self.all_vari... | python | def init_app(self, app):
"""Initialize the extension."""
# Set default Flask config option.
app.config.setdefault('STATICS_MINIFY', False)
# Select resources.
self.all_resources = ALL_RESOURCES_MINIFIED if app.config.get('STATICS_MINIFY') else ALL_RESOURCES
self.all_vari... | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"# Set default Flask config option.",
"app",
".",
"config",
".",
"setdefault",
"(",
"'STATICS_MINIFY'",
",",
"False",
")",
"# Select resources.",
"self",
".",
"all_resources",
"=",
"ALL_RESOURCES_MINIFIED",
"if",... | Initialize the extension. | [
"Initialize",
"the",
"extension",
"."
] | b1771e65225f62b760b3ef841b710ff23ef6f83c | https://github.com/Robpol86/Flask-Statics-Helper/blob/b1771e65225f62b760b3ef841b710ff23ef6f83c/flask_statics/__init__.py#L56-L79 |
37,704 | wheeler-microfluidics/dmf-control-board-firmware | dmf_control_board_firmware/calibrate/hv_attenuator.py | measure_board_rms | def measure_board_rms(control_board, n_samples=10, sampling_ms=10,
delay_between_samples_ms=0):
'''
Read RMS voltage samples from control board high-voltage feedback circuit.
'''
try:
results = control_board.measure_impedance(n_samples, sampling_ms,
... | python | def measure_board_rms(control_board, n_samples=10, sampling_ms=10,
delay_between_samples_ms=0):
'''
Read RMS voltage samples from control board high-voltage feedback circuit.
'''
try:
results = control_board.measure_impedance(n_samples, sampling_ms,
... | [
"def",
"measure_board_rms",
"(",
"control_board",
",",
"n_samples",
"=",
"10",
",",
"sampling_ms",
"=",
"10",
",",
"delay_between_samples_ms",
"=",
"0",
")",
":",
"try",
":",
"results",
"=",
"control_board",
".",
"measure_impedance",
"(",
"n_samples",
",",
"sa... | Read RMS voltage samples from control board high-voltage feedback circuit. | [
"Read",
"RMS",
"voltage",
"samples",
"from",
"control",
"board",
"high",
"-",
"voltage",
"feedback",
"circuit",
"."
] | 1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c | https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/calibrate/hv_attenuator.py#L15-L34 |
37,705 | wheeler-microfluidics/dmf-control-board-firmware | dmf_control_board_firmware/calibrate/hv_attenuator.py | find_good | def find_good(control_board, actuation_steps, resistor_index, start_index,
end_index):
'''
Use a binary search over the range of provided actuation_steps to find the
maximum actuation voltage that is measured by the board feedback circuit
using the specified feedback resistor.
'''
... | python | def find_good(control_board, actuation_steps, resistor_index, start_index,
end_index):
'''
Use a binary search over the range of provided actuation_steps to find the
maximum actuation voltage that is measured by the board feedback circuit
using the specified feedback resistor.
'''
... | [
"def",
"find_good",
"(",
"control_board",
",",
"actuation_steps",
",",
"resistor_index",
",",
"start_index",
",",
"end_index",
")",
":",
"lower",
"=",
"start_index",
"upper",
"=",
"end_index",
"while",
"lower",
"<",
"upper",
"-",
"1",
":",
"index",
"=",
"low... | Use a binary search over the range of provided actuation_steps to find the
maximum actuation voltage that is measured by the board feedback circuit
using the specified feedback resistor. | [
"Use",
"a",
"binary",
"search",
"over",
"the",
"range",
"of",
"provided",
"actuation_steps",
"to",
"find",
"the",
"maximum",
"actuation",
"voltage",
"that",
"is",
"measured",
"by",
"the",
"board",
"feedback",
"circuit",
"using",
"the",
"specified",
"feedback",
... | 1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c | https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/calibrate/hv_attenuator.py#L37-L60 |
37,706 | wheeler-microfluidics/dmf-control-board-firmware | dmf_control_board_firmware/calibrate/hv_attenuator.py | resistor_max_actuation_readings | def resistor_max_actuation_readings(control_board, frequencies,
oscope_reading_func):
'''
For each resistor in the high-voltage feedback resistor bank, read the
board measured voltage and the oscilloscope measured voltage for an
actuation voltage that nearly saturates... | python | def resistor_max_actuation_readings(control_board, frequencies,
oscope_reading_func):
'''
For each resistor in the high-voltage feedback resistor bank, read the
board measured voltage and the oscilloscope measured voltage for an
actuation voltage that nearly saturates... | [
"def",
"resistor_max_actuation_readings",
"(",
"control_board",
",",
"frequencies",
",",
"oscope_reading_func",
")",
":",
"# Set board amplifier gain to 1.",
"# __NB__ This is likely _far_ lower than the actual gain _(which may be a",
"# factor of several hundred)_..",
"control_board",
"... | For each resistor in the high-voltage feedback resistor bank, read the
board measured voltage and the oscilloscope measured voltage for an
actuation voltage that nearly saturates the feedback resistor.
By searching for an actuation voltage near saturation, the signal-to-noise
ratio is minimized. | [
"For",
"each",
"resistor",
"in",
"the",
"high",
"-",
"voltage",
"feedback",
"resistor",
"bank",
"read",
"the",
"board",
"measured",
"voltage",
"and",
"the",
"oscilloscope",
"measured",
"voltage",
"for",
"an",
"actuation",
"voltage",
"that",
"nearly",
"saturates"... | 1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c | https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/calibrate/hv_attenuator.py#L63-L127 |
37,707 | wheeler-microfluidics/dmf-control-board-firmware | dmf_control_board_firmware/calibrate/hv_attenuator.py | fit_feedback_params | def fit_feedback_params(calibration, max_resistor_readings):
'''
Fit model of control board high-voltage feedback resistor and
parasitic capacitance values based on measured voltage readings.
'''
R1 = 10e6
# Get transfer function to compute the amplitude of the high-voltage input
# to the c... | python | def fit_feedback_params(calibration, max_resistor_readings):
'''
Fit model of control board high-voltage feedback resistor and
parasitic capacitance values based on measured voltage readings.
'''
R1 = 10e6
# Get transfer function to compute the amplitude of the high-voltage input
# to the c... | [
"def",
"fit_feedback_params",
"(",
"calibration",
",",
"max_resistor_readings",
")",
":",
"R1",
"=",
"10e6",
"# Get transfer function to compute the amplitude of the high-voltage input",
"# to the control board _(i.e., the output of the amplifier)_ based on the",
"# attenuated voltage meas... | Fit model of control board high-voltage feedback resistor and
parasitic capacitance values based on measured voltage readings. | [
"Fit",
"model",
"of",
"control",
"board",
"high",
"-",
"voltage",
"feedback",
"resistor",
"and",
"parasitic",
"capacitance",
"values",
"based",
"on",
"measured",
"voltage",
"readings",
"."
] | 1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c | https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/calibrate/hv_attenuator.py#L130-L175 |
37,708 | wheeler-microfluidics/dmf-control-board-firmware | dmf_control_board_firmware/calibrate/hv_attenuator.py | update_control_board_calibration | def update_control_board_calibration(control_board, fitted_params):
'''
Update the control board with the specified fitted parameters.
'''
# Update the control board with the new fitted capacitor and resistor
# values for the reference load analog input (channel 0).
control_board.a0_series_resis... | python | def update_control_board_calibration(control_board, fitted_params):
'''
Update the control board with the specified fitted parameters.
'''
# Update the control board with the new fitted capacitor and resistor
# values for the reference load analog input (channel 0).
control_board.a0_series_resis... | [
"def",
"update_control_board_calibration",
"(",
"control_board",
",",
"fitted_params",
")",
":",
"# Update the control board with the new fitted capacitor and resistor",
"# values for the reference load analog input (channel 0).",
"control_board",
".",
"a0_series_resistance",
"=",
"fitte... | Update the control board with the specified fitted parameters. | [
"Update",
"the",
"control",
"board",
"with",
"the",
"specified",
"fitted",
"parameters",
"."
] | 1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c | https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/calibrate/hv_attenuator.py#L249-L256 |
37,709 | nimbusproject/dashi | dashi/bootstrap/config.py | Config.load | def load(self):
""" Load each path in order. Remember paths already loaded and only load new ones. """
data = self.dict_class()
for path in self.paths:
if path in self.paths_loaded: continue
try:
with open(path, 'r') as file:
... | python | def load(self):
""" Load each path in order. Remember paths already loaded and only load new ones. """
data = self.dict_class()
for path in self.paths:
if path in self.paths_loaded: continue
try:
with open(path, 'r') as file:
... | [
"def",
"load",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"dict_class",
"(",
")",
"for",
"path",
"in",
"self",
".",
"paths",
":",
"if",
"path",
"in",
"self",
".",
"paths_loaded",
":",
"continue",
"try",
":",
"with",
"open",
"(",
"path",
",",
... | Load each path in order. Remember paths already loaded and only load new ones. | [
"Load",
"each",
"path",
"in",
"order",
".",
"Remember",
"paths",
"already",
"loaded",
"and",
"only",
"load",
"new",
"ones",
"."
] | 368b3963ec8abd60aebe0f81915429b45cbf4b5a | https://github.com/nimbusproject/dashi/blob/368b3963ec8abd60aebe0f81915429b45cbf4b5a/dashi/bootstrap/config.py#L29-L46 |
37,710 | VikParuchuri/percept | percept/conf/base.py | Settings._initialize | def _initialize(self, settings_module):
"""
Initialize the settings from a given settings_module
settings_module - path to settings module
"""
#Get the global settings values and assign them as self attributes
self.settings_list = []
for setting in dir(global_sett... | python | def _initialize(self, settings_module):
"""
Initialize the settings from a given settings_module
settings_module - path to settings module
"""
#Get the global settings values and assign them as self attributes
self.settings_list = []
for setting in dir(global_sett... | [
"def",
"_initialize",
"(",
"self",
",",
"settings_module",
")",
":",
"#Get the global settings values and assign them as self attributes",
"self",
".",
"settings_list",
"=",
"[",
"]",
"for",
"setting",
"in",
"dir",
"(",
"global_settings",
")",
":",
"#Only get upper case... | Initialize the settings from a given settings_module
settings_module - path to settings module | [
"Initialize",
"the",
"settings",
"from",
"a",
"given",
"settings_module",
"settings_module",
"-",
"path",
"to",
"settings",
"module"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/conf/base.py#L20-L60 |
37,711 | VikParuchuri/percept | percept/conf/base.py | Settings._setup | def _setup(self):
"""
Perform initial setup of the settings class, such as getting the settings module and setting the settings
"""
settings_module = None
#Get the settings module from the environment variables
try:
settings_module = os.environ[global_setting... | python | def _setup(self):
"""
Perform initial setup of the settings class, such as getting the settings module and setting the settings
"""
settings_module = None
#Get the settings module from the environment variables
try:
settings_module = os.environ[global_setting... | [
"def",
"_setup",
"(",
"self",
")",
":",
"settings_module",
"=",
"None",
"#Get the settings module from the environment variables",
"try",
":",
"settings_module",
"=",
"os",
".",
"environ",
"[",
"global_settings",
".",
"MODULE_VARIABLE",
"]",
"except",
"KeyError",
":",... | Perform initial setup of the settings class, such as getting the settings module and setting the settings | [
"Perform",
"initial",
"setup",
"of",
"the",
"settings",
"class",
"such",
"as",
"getting",
"the",
"settings",
"module",
"and",
"setting",
"the",
"settings"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/conf/base.py#L62-L75 |
37,712 | VikParuchuri/percept | percept/conf/base.py | Settings._configure_logging | def _configure_logging(self):
"""
Setting up logging from logging config in settings
"""
if not self.LOGGING_CONFIG:
#Fallback to default logging in global settings if needed
dictConfig(self.DEFAULT_LOGGING)
else:
dictConfig(self.LOGGING_CONFIG... | python | def _configure_logging(self):
"""
Setting up logging from logging config in settings
"""
if not self.LOGGING_CONFIG:
#Fallback to default logging in global settings if needed
dictConfig(self.DEFAULT_LOGGING)
else:
dictConfig(self.LOGGING_CONFIG... | [
"def",
"_configure_logging",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"LOGGING_CONFIG",
":",
"#Fallback to default logging in global settings if needed",
"dictConfig",
"(",
"self",
".",
"DEFAULT_LOGGING",
")",
"else",
":",
"dictConfig",
"(",
"self",
".",
"LO... | Setting up logging from logging config in settings | [
"Setting",
"up",
"logging",
"from",
"logging",
"config",
"in",
"settings"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/conf/base.py#L91-L99 |
37,713 | frascoweb/frasco | frasco/actions/context.py | ensure_context | def ensure_context(**vars):
"""Ensures that a context is in the stack, creates one otherwise.
"""
ctx = _context_stack.top
stacked = False
if not ctx:
ctx = Context()
stacked = True
_context_stack.push(ctx)
ctx.update(vars)
try:
yield ctx
finally:
... | python | def ensure_context(**vars):
"""Ensures that a context is in the stack, creates one otherwise.
"""
ctx = _context_stack.top
stacked = False
if not ctx:
ctx = Context()
stacked = True
_context_stack.push(ctx)
ctx.update(vars)
try:
yield ctx
finally:
... | [
"def",
"ensure_context",
"(",
"*",
"*",
"vars",
")",
":",
"ctx",
"=",
"_context_stack",
".",
"top",
"stacked",
"=",
"False",
"if",
"not",
"ctx",
":",
"ctx",
"=",
"Context",
"(",
")",
"stacked",
"=",
"True",
"_context_stack",
".",
"push",
"(",
"ctx",
... | Ensures that a context is in the stack, creates one otherwise. | [
"Ensures",
"that",
"a",
"context",
"is",
"in",
"the",
"stack",
"creates",
"one",
"otherwise",
"."
] | ea519d69dd5ca6deaf3650175692ee4a1a02518f | https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/actions/context.py#L25-L39 |
37,714 | frascoweb/frasco | frasco/actions/context.py | request_context | def request_context(app, request):
"""Creates a Context instance from the given request object
"""
vars = {}
if request.view_args is not None:
vars.update(request.view_args)
vars.update({
"request": request,
"GET": AttrDict(request.args.to_dict()),
"POST" : AttrDict(r... | python | def request_context(app, request):
"""Creates a Context instance from the given request object
"""
vars = {}
if request.view_args is not None:
vars.update(request.view_args)
vars.update({
"request": request,
"GET": AttrDict(request.args.to_dict()),
"POST" : AttrDict(r... | [
"def",
"request_context",
"(",
"app",
",",
"request",
")",
":",
"vars",
"=",
"{",
"}",
"if",
"request",
".",
"view_args",
"is",
"not",
"None",
":",
"vars",
".",
"update",
"(",
"request",
".",
"view_args",
")",
"vars",
".",
"update",
"(",
"{",
"\"requ... | Creates a Context instance from the given request object | [
"Creates",
"a",
"Context",
"instance",
"from",
"the",
"given",
"request",
"object"
] | ea519d69dd5ca6deaf3650175692ee4a1a02518f | https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/actions/context.py#L111-L130 |
37,715 | frascoweb/frasco | frasco/actions/context.py | Context.clone | def clone(self, **override_vars):
"""Creates a copy of this context"""
c = Context(self.vars, self.data)
c.executed_actions = set(self.executed_actions)
c.vars.update(override_vars)
return c | python | def clone(self, **override_vars):
"""Creates a copy of this context"""
c = Context(self.vars, self.data)
c.executed_actions = set(self.executed_actions)
c.vars.update(override_vars)
return c | [
"def",
"clone",
"(",
"self",
",",
"*",
"*",
"override_vars",
")",
":",
"c",
"=",
"Context",
"(",
"self",
".",
"vars",
",",
"self",
".",
"data",
")",
"c",
".",
"executed_actions",
"=",
"set",
"(",
"self",
".",
"executed_actions",
")",
"c",
".",
"var... | Creates a copy of this context | [
"Creates",
"a",
"copy",
"of",
"this",
"context"
] | ea519d69dd5ca6deaf3650175692ee4a1a02518f | https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/actions/context.py#L86-L91 |
37,716 | m-weigand/sip_models | lib/sip_models/plot_helper.py | mpl_get_cb_bound_below_plot | def mpl_get_cb_bound_below_plot(ax):
"""
Return the coordinates for a colorbar axes below the provided axes object.
Take into account the changes of the axes due to aspect ratio settings.
Parts of this code are taken from the transforms.py file from matplotlib
Important: Use only AFTER fig.subplot... | python | def mpl_get_cb_bound_below_plot(ax):
"""
Return the coordinates for a colorbar axes below the provided axes object.
Take into account the changes of the axes due to aspect ratio settings.
Parts of this code are taken from the transforms.py file from matplotlib
Important: Use only AFTER fig.subplot... | [
"def",
"mpl_get_cb_bound_below_plot",
"(",
"ax",
")",
":",
"position",
"=",
"ax",
".",
"get_position",
"(",
")",
"figW",
",",
"figH",
"=",
"ax",
".",
"get_figure",
"(",
")",
".",
"get_size_inches",
"(",
")",
"fig_aspect",
"=",
"figH",
"/",
"figW",
"box_a... | Return the coordinates for a colorbar axes below the provided axes object.
Take into account the changes of the axes due to aspect ratio settings.
Parts of this code are taken from the transforms.py file from matplotlib
Important: Use only AFTER fig.subplots_adjust(...)
Use as:
======= | [
"Return",
"the",
"coordinates",
"for",
"a",
"colorbar",
"axes",
"below",
"the",
"provided",
"axes",
"object",
".",
"Take",
"into",
"account",
"the",
"changes",
"of",
"the",
"axes",
"due",
"to",
"aspect",
"ratio",
"settings",
"."
] | 917da5d956215d9df2bf65b24123ba020e3e17c0 | https://github.com/m-weigand/sip_models/blob/917da5d956215d9df2bf65b24123ba020e3e17c0/lib/sip_models/plot_helper.py#L129-L154 |
37,717 | jkeyes/python-docraptor | example/basic_xls.py | main | def main():
"""Generate an XLS with specified content."""
table = """<table>
<thead>
<tr><th>First Name</th><th>Last Name</th></tr>
</thead>
<tbody>
<tr><td>Paul</td><td>McGrath</td></tr>
<tr><td>Liam</td><td>Brady</td></tr>
<tr><td>John</td><td>Giles</td></tr>
</tbody>
</tab... | python | def main():
"""Generate an XLS with specified content."""
table = """<table>
<thead>
<tr><th>First Name</th><th>Last Name</th></tr>
</thead>
<tbody>
<tr><td>Paul</td><td>McGrath</td></tr>
<tr><td>Liam</td><td>Brady</td></tr>
<tr><td>John</td><td>Giles</td></tr>
</tbody>
</tab... | [
"def",
"main",
"(",
")",
":",
"table",
"=",
"\"\"\"<table>\n <thead>\n <tr><th>First Name</th><th>Last Name</th></tr>\n </thead>\n <tbody>\n <tr><td>Paul</td><td>McGrath</td></tr>\n <tr><td>Liam</td><td>Brady</td></tr>\n <tr><td>John</td><td>Giles</td></tr>\n </tbody>\n </ta... | Generate an XLS with specified content. | [
"Generate",
"an",
"XLS",
"with",
"specified",
"content",
"."
] | 4be5b641f92820539b2c42165fec9251a6603dea | https://github.com/jkeyes/python-docraptor/blob/4be5b641f92820539b2c42165fec9251a6603dea/example/basic_xls.py#L5-L25 |
37,718 | mdickinson/refcycle | refcycle/gc_utils.py | restore_gc_state | def restore_gc_state():
"""
Restore the garbage collector state on leaving the with block.
"""
old_isenabled = gc.isenabled()
old_flags = gc.get_debug()
try:
yield
finally:
gc.set_debug(old_flags)
(gc.enable if old_isenabled else gc.disable)() | python | def restore_gc_state():
"""
Restore the garbage collector state on leaving the with block.
"""
old_isenabled = gc.isenabled()
old_flags = gc.get_debug()
try:
yield
finally:
gc.set_debug(old_flags)
(gc.enable if old_isenabled else gc.disable)() | [
"def",
"restore_gc_state",
"(",
")",
":",
"old_isenabled",
"=",
"gc",
".",
"isenabled",
"(",
")",
"old_flags",
"=",
"gc",
".",
"get_debug",
"(",
")",
"try",
":",
"yield",
"finally",
":",
"gc",
".",
"set_debug",
"(",
"old_flags",
")",
"(",
"gc",
".",
... | Restore the garbage collector state on leaving the with block. | [
"Restore",
"the",
"garbage",
"collector",
"state",
"on",
"leaving",
"the",
"with",
"block",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/gc_utils.py#L23-L34 |
37,719 | frascoweb/frasco | frasco/declarative/loaders.py | ViewsLoader.add_view_file_mapping | def add_view_file_mapping(self, pattern, cls):
"""Adds a mapping between a file and a view class.
Pattern can be an extension in the form .EXT or a filename.
"""
if isinstance(pattern, str):
if not pattern.endswith("*"):
_, ext = os.path.splitext(pattern)
... | python | def add_view_file_mapping(self, pattern, cls):
"""Adds a mapping between a file and a view class.
Pattern can be an extension in the form .EXT or a filename.
"""
if isinstance(pattern, str):
if not pattern.endswith("*"):
_, ext = os.path.splitext(pattern)
... | [
"def",
"add_view_file_mapping",
"(",
"self",
",",
"pattern",
",",
"cls",
")",
":",
"if",
"isinstance",
"(",
"pattern",
",",
"str",
")",
":",
"if",
"not",
"pattern",
".",
"endswith",
"(",
"\"*\"",
")",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
"... | Adds a mapping between a file and a view class.
Pattern can be an extension in the form .EXT or a filename. | [
"Adds",
"a",
"mapping",
"between",
"a",
"file",
"and",
"a",
"view",
"class",
".",
"Pattern",
"can",
"be",
"an",
"extension",
"in",
"the",
"form",
".",
"EXT",
"or",
"a",
"filename",
"."
] | ea519d69dd5ca6deaf3650175692ee4a1a02518f | https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/declarative/loaders.py#L113-L122 |
37,720 | frascoweb/frasco | frasco/declarative/loaders.py | ViewsLoader.get_file_view_cls | def get_file_view_cls(self, filename):
"""Returns the view class associated to a filename
"""
if filename is None:
return self.default_view_class
for pattern, cls in self.view_class_files_map:
if pattern.match(filename):
return cls
return s... | python | def get_file_view_cls(self, filename):
"""Returns the view class associated to a filename
"""
if filename is None:
return self.default_view_class
for pattern, cls in self.view_class_files_map:
if pattern.match(filename):
return cls
return s... | [
"def",
"get_file_view_cls",
"(",
"self",
",",
"filename",
")",
":",
"if",
"filename",
"is",
"None",
":",
"return",
"self",
".",
"default_view_class",
"for",
"pattern",
",",
"cls",
"in",
"self",
".",
"view_class_files_map",
":",
"if",
"pattern",
".",
"match",... | Returns the view class associated to a filename | [
"Returns",
"the",
"view",
"class",
"associated",
"to",
"a",
"filename"
] | ea519d69dd5ca6deaf3650175692ee4a1a02518f | https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/declarative/loaders.py#L179-L187 |
37,721 | mdickinson/refcycle | refcycle/i_directed_graph.py | IDirectedGraph.children | def children(self, vertex):
"""
Return the list of immediate children of the given vertex.
"""
return [self.head(edge) for edge in self.out_edges(vertex)] | python | def children(self, vertex):
"""
Return the list of immediate children of the given vertex.
"""
return [self.head(edge) for edge in self.out_edges(vertex)] | [
"def",
"children",
"(",
"self",
",",
"vertex",
")",
":",
"return",
"[",
"self",
".",
"head",
"(",
"edge",
")",
"for",
"edge",
"in",
"self",
".",
"out_edges",
"(",
"vertex",
")",
"]"
] | Return the list of immediate children of the given vertex. | [
"Return",
"the",
"list",
"of",
"immediate",
"children",
"of",
"the",
"given",
"vertex",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/i_directed_graph.py#L141-L146 |
37,722 | mdickinson/refcycle | refcycle/i_directed_graph.py | IDirectedGraph.parents | def parents(self, vertex):
"""
Return the list of immediate parents of this vertex.
"""
return [self.tail(edge) for edge in self.in_edges(vertex)] | python | def parents(self, vertex):
"""
Return the list of immediate parents of this vertex.
"""
return [self.tail(edge) for edge in self.in_edges(vertex)] | [
"def",
"parents",
"(",
"self",
",",
"vertex",
")",
":",
"return",
"[",
"self",
".",
"tail",
"(",
"edge",
")",
"for",
"edge",
"in",
"self",
".",
"in_edges",
"(",
"vertex",
")",
"]"
] | Return the list of immediate parents of this vertex. | [
"Return",
"the",
"list",
"of",
"immediate",
"parents",
"of",
"this",
"vertex",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/i_directed_graph.py#L148-L153 |
37,723 | mdickinson/refcycle | refcycle/i_directed_graph.py | IDirectedGraph.descendants | def descendants(self, start, generations=None):
"""
Return the subgraph of all nodes reachable
from the given start vertex, including that vertex.
If specified, the optional `generations` argument specifies how
many generations to limit to.
"""
visited = self.ve... | python | def descendants(self, start, generations=None):
"""
Return the subgraph of all nodes reachable
from the given start vertex, including that vertex.
If specified, the optional `generations` argument specifies how
many generations to limit to.
"""
visited = self.ve... | [
"def",
"descendants",
"(",
"self",
",",
"start",
",",
"generations",
"=",
"None",
")",
":",
"visited",
"=",
"self",
".",
"vertex_set",
"(",
")",
"visited",
".",
"add",
"(",
"start",
")",
"to_visit",
"=",
"deque",
"(",
"[",
"(",
"start",
",",
"0",
"... | Return the subgraph of all nodes reachable
from the given start vertex, including that vertex.
If specified, the optional `generations` argument specifies how
many generations to limit to. | [
"Return",
"the",
"subgraph",
"of",
"all",
"nodes",
"reachable",
"from",
"the",
"given",
"start",
"vertex",
"including",
"that",
"vertex",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/i_directed_graph.py#L167-L187 |
37,724 | mdickinson/refcycle | refcycle/i_directed_graph.py | IDirectedGraph.ancestors | def ancestors(self, start, generations=None):
"""
Return the subgraph of all nodes from which the given vertex is
reachable, including that vertex.
If specified, the optional `generations` argument specifies how
many generations to limit to.
"""
visited = self.v... | python | def ancestors(self, start, generations=None):
"""
Return the subgraph of all nodes from which the given vertex is
reachable, including that vertex.
If specified, the optional `generations` argument specifies how
many generations to limit to.
"""
visited = self.v... | [
"def",
"ancestors",
"(",
"self",
",",
"start",
",",
"generations",
"=",
"None",
")",
":",
"visited",
"=",
"self",
".",
"vertex_set",
"(",
")",
"visited",
".",
"add",
"(",
"start",
")",
"to_visit",
"=",
"deque",
"(",
"[",
"(",
"start",
",",
"0",
")"... | Return the subgraph of all nodes from which the given vertex is
reachable, including that vertex.
If specified, the optional `generations` argument specifies how
many generations to limit to. | [
"Return",
"the",
"subgraph",
"of",
"all",
"nodes",
"from",
"which",
"the",
"given",
"vertex",
"is",
"reachable",
"including",
"that",
"vertex",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/i_directed_graph.py#L189-L209 |
37,725 | mdickinson/refcycle | refcycle/i_directed_graph.py | IDirectedGraph._component_graph | def _component_graph(self):
"""
Compute the graph of strongly connected components.
Each strongly connected component is itself represented as a list of
pairs, giving information not only about the vertices belonging to
this strongly connected component, but also the edges leadi... | python | def _component_graph(self):
"""
Compute the graph of strongly connected components.
Each strongly connected component is itself represented as a list of
pairs, giving information not only about the vertices belonging to
this strongly connected component, but also the edges leadi... | [
"def",
"_component_graph",
"(",
"self",
")",
":",
"sccs",
"=",
"[",
"]",
"stack",
"=",
"[",
"]",
"boundaries",
"=",
"[",
"]",
"identified",
"=",
"self",
".",
"vertex_set",
"(",
")",
"index",
"=",
"self",
".",
"vertex_dict",
"(",
")",
"to_do",
"=",
... | Compute the graph of strongly connected components.
Each strongly connected component is itself represented as a list of
pairs, giving information not only about the vertices belonging to
this strongly connected component, but also the edges leading from
this strongly connected componen... | [
"Compute",
"the",
"graph",
"of",
"strongly",
"connected",
"components",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/i_directed_graph.py#L290-L358 |
37,726 | mdickinson/refcycle | refcycle/i_directed_graph.py | IDirectedGraph.source_components | def source_components(self):
"""
Return the strongly connected components not reachable from any other
component. Any component in the graph is reachable from one of these.
"""
raw_sccs = self._component_graph()
# Construct a dictionary mapping each vertex to the root ... | python | def source_components(self):
"""
Return the strongly connected components not reachable from any other
component. Any component in the graph is reachable from one of these.
"""
raw_sccs = self._component_graph()
# Construct a dictionary mapping each vertex to the root ... | [
"def",
"source_components",
"(",
"self",
")",
":",
"raw_sccs",
"=",
"self",
".",
"_component_graph",
"(",
")",
"# Construct a dictionary mapping each vertex to the root of its scc.",
"vertex_to_root",
"=",
"self",
".",
"vertex_dict",
"(",
")",
"# And keep track of which SCC... | Return the strongly connected components not reachable from any other
component. Any component in the graph is reachable from one of these. | [
"Return",
"the",
"strongly",
"connected",
"components",
"not",
"reachable",
"from",
"any",
"other",
"component",
".",
"Any",
"component",
"in",
"the",
"graph",
"is",
"reachable",
"from",
"one",
"of",
"these",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/i_directed_graph.py#L360-L390 |
37,727 | mdickinson/refcycle | refcycle/i_directed_graph.py | IDirectedGraph.strongly_connected_components | def strongly_connected_components(self):
"""
Return list of strongly connected components of this graph.
Returns a list of subgraphs.
Algorithm is based on that described in "Path-based depth-first search
for strong and biconnected components" by Harold N. Gabow,
Inf.Pr... | python | def strongly_connected_components(self):
"""
Return list of strongly connected components of this graph.
Returns a list of subgraphs.
Algorithm is based on that described in "Path-based depth-first search
for strong and biconnected components" by Harold N. Gabow,
Inf.Pr... | [
"def",
"strongly_connected_components",
"(",
"self",
")",
":",
"raw_sccs",
"=",
"self",
".",
"_component_graph",
"(",
")",
"sccs",
"=",
"[",
"]",
"for",
"raw_scc",
"in",
"raw_sccs",
":",
"sccs",
".",
"append",
"(",
"[",
"v",
"for",
"vtype",
",",
"v",
"... | Return list of strongly connected components of this graph.
Returns a list of subgraphs.
Algorithm is based on that described in "Path-based depth-first search
for strong and biconnected components" by Harold N. Gabow,
Inf.Process.Lett. 74 (2000) 107--114. | [
"Return",
"list",
"of",
"strongly",
"connected",
"components",
"of",
"this",
"graph",
"."
] | 627fad74c74efc601209c96405f8118cd99b2241 | https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/i_directed_graph.py#L392-L409 |
37,728 | presslabs/django-payu-ro | payu/forms.py | PayULiveUpdateForm.signature | def signature(self):
"""
Compute the ORDER_HASH of the request.
The hashable string is composed by getting the values from:
MERCHANT
ORDER_REF
ORDER_DATE
ORDER_PNAME[]
ORDER_PCODE[]
ORDER_PINFO[]
ORDER_PRICE[]
... | python | def signature(self):
"""
Compute the ORDER_HASH of the request.
The hashable string is composed by getting the values from:
MERCHANT
ORDER_REF
ORDER_DATE
ORDER_PNAME[]
ORDER_PCODE[]
ORDER_PINFO[]
ORDER_PRICE[]
... | [
"def",
"signature",
"(",
"self",
")",
":",
"hashable_fields",
"=",
"[",
"'MERCHANT'",
",",
"'ORDER_REF'",
",",
"'ORDER_DATE'",
",",
"'ORDER_SHIPPING'",
",",
"'PRICES_CURRENCY'",
",",
"'DISCOUNT'",
",",
"'DESTINATION_CITY'",
",",
"'DESTINATION_STATE'",
",",
"'DESTINA... | Compute the ORDER_HASH of the request.
The hashable string is composed by getting the values from:
MERCHANT
ORDER_REF
ORDER_DATE
ORDER_PNAME[]
ORDER_PCODE[]
ORDER_PINFO[]
ORDER_PRICE[]
ORDER_QTY[]
ORDER_... | [
"Compute",
"the",
"ORDER_HASH",
"of",
"the",
"request",
"."
] | fda9432c57cee7a78789873b6e6f439d912e4c7b | https://github.com/presslabs/django-payu-ro/blob/fda9432c57cee7a78789873b6e6f439d912e4c7b/payu/forms.py#L143-L224 |
37,729 | presslabs/django-payu-ro | payu/forms.py | PayULiveUpdateForm._prepare_orders | def _prepare_orders(self, orders):
"""
Each order needs to have all it's details filled with default value,
or None, in case those are not already filled.
"""
for detail in PAYU_ORDER_DETAILS:
if not any([detail in order for order in orders]):
for ord... | python | def _prepare_orders(self, orders):
"""
Each order needs to have all it's details filled with default value,
or None, in case those are not already filled.
"""
for detail in PAYU_ORDER_DETAILS:
if not any([detail in order for order in orders]):
for ord... | [
"def",
"_prepare_orders",
"(",
"self",
",",
"orders",
")",
":",
"for",
"detail",
"in",
"PAYU_ORDER_DETAILS",
":",
"if",
"not",
"any",
"(",
"[",
"detail",
"in",
"order",
"for",
"order",
"in",
"orders",
"]",
")",
":",
"for",
"order",
"in",
"orders",
":",... | Each order needs to have all it's details filled with default value,
or None, in case those are not already filled. | [
"Each",
"order",
"needs",
"to",
"have",
"all",
"it",
"s",
"details",
"filled",
"with",
"default",
"value",
"or",
"None",
"in",
"case",
"those",
"are",
"not",
"already",
"filled",
"."
] | fda9432c57cee7a78789873b6e6f439d912e4c7b | https://github.com/presslabs/django-payu-ro/blob/fda9432c57cee7a78789873b6e6f439d912e4c7b/payu/forms.py#L226-L237 |
37,730 | WhyNotHugo/django-renderpdf | django_renderpdf/helpers.py | staticfiles_url_fetcher | def staticfiles_url_fetcher(url):
"""
Returns the file matching url.
This method will handle any URL resources that rendering HTML requires
(eg: images pointed my ``img`` tags, stylesheets, etc).
The default behaviour will fetch any http(s) files normally, and will
also attempt to resolve stat... | python | def staticfiles_url_fetcher(url):
"""
Returns the file matching url.
This method will handle any URL resources that rendering HTML requires
(eg: images pointed my ``img`` tags, stylesheets, etc).
The default behaviour will fetch any http(s) files normally, and will
also attempt to resolve stat... | [
"def",
"staticfiles_url_fetcher",
"(",
"url",
")",
":",
"if",
"url",
".",
"startswith",
"(",
"'/'",
")",
":",
"base_url",
"=",
"staticfiles_storage",
".",
"base_url",
"filename",
"=",
"url",
".",
"replace",
"(",
"base_url",
",",
"''",
",",
"1",
")",
"pat... | Returns the file matching url.
This method will handle any URL resources that rendering HTML requires
(eg: images pointed my ``img`` tags, stylesheets, etc).
The default behaviour will fetch any http(s) files normally, and will
also attempt to resolve staticfiles internally (this should mostly
aff... | [
"Returns",
"the",
"file",
"matching",
"url",
"."
] | 56de11326e61d317b5eb08c340790ef9955778e3 | https://github.com/WhyNotHugo/django-renderpdf/blob/56de11326e61d317b5eb08c340790ef9955778e3/django_renderpdf/helpers.py#L9-L50 |
37,731 | WhyNotHugo/django-renderpdf | django_renderpdf/helpers.py | render_pdf | def render_pdf(
template,
file_,
url_fetcher=staticfiles_url_fetcher,
context=None,
):
"""
Writes the PDF data into ``file_``. Note that ``file_`` can actually be a
Django Response object as well.
This function may be used as a helper that can be used to save a PDF file
to a file (o... | python | def render_pdf(
template,
file_,
url_fetcher=staticfiles_url_fetcher,
context=None,
):
"""
Writes the PDF data into ``file_``. Note that ``file_`` can actually be a
Django Response object as well.
This function may be used as a helper that can be used to save a PDF file
to a file (o... | [
"def",
"render_pdf",
"(",
"template",
",",
"file_",
",",
"url_fetcher",
"=",
"staticfiles_url_fetcher",
",",
"context",
"=",
"None",
",",
")",
":",
"context",
"=",
"context",
"or",
"{",
"}",
"html",
"=",
"get_template",
"(",
"template",
")",
".",
"render",... | Writes the PDF data into ``file_``. Note that ``file_`` can actually be a
Django Response object as well.
This function may be used as a helper that can be used to save a PDF file
to a file (or anything else outside of a request/response cycle), eg::
:param str html: A rendered HTML.
:param file f... | [
"Writes",
"the",
"PDF",
"data",
"into",
"file_",
".",
"Note",
"that",
"file_",
"can",
"actually",
"be",
"a",
"Django",
"Response",
"object",
"as",
"well",
"."
] | 56de11326e61d317b5eb08c340790ef9955778e3 | https://github.com/WhyNotHugo/django-renderpdf/blob/56de11326e61d317b5eb08c340790ef9955778e3/django_renderpdf/helpers.py#L53-L79 |
37,732 | kcallin/mqtt-codec | mqtt_codec/io.py | encode_bytes | def encode_bytes(src_buf, dst_file):
"""Encode a buffer length followed by the bytes of the buffer
itself.
Parameters
----------
src_buf: bytes
Source bytes to be encoded. Function asserts that
0 <= len(src_buf) <= 2**16-1.
dst_file: file
File-like object with write met... | python | def encode_bytes(src_buf, dst_file):
"""Encode a buffer length followed by the bytes of the buffer
itself.
Parameters
----------
src_buf: bytes
Source bytes to be encoded. Function asserts that
0 <= len(src_buf) <= 2**16-1.
dst_file: file
File-like object with write met... | [
"def",
"encode_bytes",
"(",
"src_buf",
",",
"dst_file",
")",
":",
"if",
"not",
"isinstance",
"(",
"src_buf",
",",
"bytes",
")",
":",
"raise",
"TypeError",
"(",
"'src_buf must by bytes.'",
")",
"len_src_buf",
"=",
"len",
"(",
"src_buf",
")",
"assert",
"0",
... | Encode a buffer length followed by the bytes of the buffer
itself.
Parameters
----------
src_buf: bytes
Source bytes to be encoded. Function asserts that
0 <= len(src_buf) <= 2**16-1.
dst_file: file
File-like object with write method.
Returns
-------
int
... | [
"Encode",
"a",
"buffer",
"length",
"followed",
"by",
"the",
"bytes",
"of",
"the",
"buffer",
"itself",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/io.py#L14-L42 |
37,733 | kcallin/mqtt-codec | mqtt_codec/io.py | decode_bytes | def decode_bytes(f):
"""Decode a buffer length from a 2-byte unsigned int then read the
subsequent bytes.
Parameters
----------
f: file
File-like object with read method.
Raises
------
UnderflowDecodeError
When the end of stream is encountered before the end of the
... | python | def decode_bytes(f):
"""Decode a buffer length from a 2-byte unsigned int then read the
subsequent bytes.
Parameters
----------
f: file
File-like object with read method.
Raises
------
UnderflowDecodeError
When the end of stream is encountered before the end of the
... | [
"def",
"decode_bytes",
"(",
"f",
")",
":",
"buf",
"=",
"f",
".",
"read",
"(",
"FIELD_U16",
".",
"size",
")",
"if",
"len",
"(",
"buf",
")",
"<",
"FIELD_U16",
".",
"size",
":",
"raise",
"UnderflowDecodeError",
"(",
")",
"(",
"num_bytes",
",",
")",
"=... | Decode a buffer length from a 2-byte unsigned int then read the
subsequent bytes.
Parameters
----------
f: file
File-like object with read method.
Raises
------
UnderflowDecodeError
When the end of stream is encountered before the end of the
encoded bytes.
Retu... | [
"Decode",
"a",
"buffer",
"length",
"from",
"a",
"2",
"-",
"byte",
"unsigned",
"int",
"then",
"read",
"the",
"subsequent",
"bytes",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/io.py#L45-L79 |
37,734 | kcallin/mqtt-codec | mqtt_codec/io.py | encode_utf8 | def encode_utf8(s, f):
"""UTF-8 encodes string `s` to file-like object `f` according to
the MQTT Version 3.1.1 specification in section 1.5.3.
The maximum length for the encoded string is 2**16-1 (65535) bytes.
An assertion error will result if the encoded string is longer.
Parameters
--------... | python | def encode_utf8(s, f):
"""UTF-8 encodes string `s` to file-like object `f` according to
the MQTT Version 3.1.1 specification in section 1.5.3.
The maximum length for the encoded string is 2**16-1 (65535) bytes.
An assertion error will result if the encoded string is longer.
Parameters
--------... | [
"def",
"encode_utf8",
"(",
"s",
",",
"f",
")",
":",
"encode",
"=",
"codecs",
".",
"getencoder",
"(",
"'utf8'",
")",
"encoded_str_bytes",
",",
"num_encoded_chars",
"=",
"encode",
"(",
"s",
")",
"num_encoded_str_bytes",
"=",
"len",
"(",
"encoded_str_bytes",
")... | UTF-8 encodes string `s` to file-like object `f` according to
the MQTT Version 3.1.1 specification in section 1.5.3.
The maximum length for the encoded string is 2**16-1 (65535) bytes.
An assertion error will result if the encoded string is longer.
Parameters
----------
s: str
String t... | [
"UTF",
"-",
"8",
"encodes",
"string",
"s",
"to",
"file",
"-",
"like",
"object",
"f",
"according",
"to",
"the",
"MQTT",
"Version",
"3",
".",
"1",
".",
"1",
"specification",
"in",
"section",
"1",
".",
"5",
".",
"3",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/io.py#L82-L112 |
37,735 | kcallin/mqtt-codec | mqtt_codec/io.py | encode_varint | def encode_varint(v, f):
"""Encode integer `v` to file `f`.
Parameters
----------
v: int
Integer v >= 0.
f: file
Object containing a write method.
Returns
-------
int
Number of bytes written.
"""
assert v >= 0
num_bytes = 0
while True:
b... | python | def encode_varint(v, f):
"""Encode integer `v` to file `f`.
Parameters
----------
v: int
Integer v >= 0.
f: file
Object containing a write method.
Returns
-------
int
Number of bytes written.
"""
assert v >= 0
num_bytes = 0
while True:
b... | [
"def",
"encode_varint",
"(",
"v",
",",
"f",
")",
":",
"assert",
"v",
">=",
"0",
"num_bytes",
"=",
"0",
"while",
"True",
":",
"b",
"=",
"v",
"%",
"0x80",
"v",
"=",
"v",
"//",
"0x80",
"if",
"v",
">",
"0",
":",
"b",
"=",
"b",
"|",
"0x80",
"f",... | Encode integer `v` to file `f`.
Parameters
----------
v: int
Integer v >= 0.
f: file
Object containing a write method.
Returns
-------
int
Number of bytes written. | [
"Encode",
"integer",
"v",
"to",
"file",
"f",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/io.py#L161-L192 |
37,736 | kcallin/mqtt-codec | mqtt_codec/io.py | FileDecoder.unpack | def unpack(self, struct):
"""Read as many bytes as are required to extract struct then
unpack and return a tuple of the values.
Raises
------
UnderflowDecodeError
Raised when a read failed to extract enough bytes from the
underlying stream to extract the ... | python | def unpack(self, struct):
"""Read as many bytes as are required to extract struct then
unpack and return a tuple of the values.
Raises
------
UnderflowDecodeError
Raised when a read failed to extract enough bytes from the
underlying stream to extract the ... | [
"def",
"unpack",
"(",
"self",
",",
"struct",
")",
":",
"v",
"=",
"struct",
".",
"unpack",
"(",
"self",
".",
"read",
"(",
"struct",
".",
"size",
")",
")",
"return",
"v"
] | Read as many bytes as are required to extract struct then
unpack and return a tuple of the values.
Raises
------
UnderflowDecodeError
Raised when a read failed to extract enough bytes from the
underlying stream to extract the bytes.
Parameters
--... | [
"Read",
"as",
"many",
"bytes",
"as",
"are",
"required",
"to",
"extract",
"struct",
"then",
"unpack",
"and",
"return",
"a",
"tuple",
"of",
"the",
"values",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/io.py#L295-L315 |
37,737 | kcallin/mqtt-codec | mqtt_codec/io.py | FileDecoder.unpack_bytes | def unpack_bytes(self):
"""Unpack a utf-8 string encoded as described in MQTT Version
3.1.1 section 1.5.3 line 177. This is a 16-bit unsigned length
followed by a utf-8 encoded string.
Returns
-------
int
Number of bytes consumed
bytes
A ... | python | def unpack_bytes(self):
"""Unpack a utf-8 string encoded as described in MQTT Version
3.1.1 section 1.5.3 line 177. This is a 16-bit unsigned length
followed by a utf-8 encoded string.
Returns
-------
int
Number of bytes consumed
bytes
A ... | [
"def",
"unpack_bytes",
"(",
"self",
")",
":",
"num_bytes_consumed",
",",
"b",
"=",
"decode_bytes",
"(",
"self",
".",
"__f",
")",
"self",
".",
"__num_bytes_consumed",
"+=",
"num_bytes_consumed",
"return",
"num_bytes_consumed",
",",
"b"
] | Unpack a utf-8 string encoded as described in MQTT Version
3.1.1 section 1.5.3 line 177. This is a 16-bit unsigned length
followed by a utf-8 encoded string.
Returns
-------
int
Number of bytes consumed
bytes
A bytes object extracted from the und... | [
"Unpack",
"a",
"utf",
"-",
"8",
"string",
"encoded",
"as",
"described",
"in",
"MQTT",
"Version",
"3",
".",
"1",
".",
"1",
"section",
"1",
".",
"5",
".",
"3",
"line",
"177",
".",
"This",
"is",
"a",
"16",
"-",
"bit",
"unsigned",
"length",
"followed",... | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/io.py#L341-L355 |
37,738 | kcallin/mqtt-codec | mqtt_codec/io.py | FileDecoder.read | def read(self, num_bytes):
"""Read `num_bytes` and return them.
Parameters
----------
num_bytes : int
Number of bytes to extract from the underlying stream.
Raises
------
UnderflowDecodeError
Raised when a read failed to extract enough by... | python | def read(self, num_bytes):
"""Read `num_bytes` and return them.
Parameters
----------
num_bytes : int
Number of bytes to extract from the underlying stream.
Raises
------
UnderflowDecodeError
Raised when a read failed to extract enough by... | [
"def",
"read",
"(",
"self",
",",
"num_bytes",
")",
":",
"buf",
"=",
"self",
".",
"__f",
".",
"read",
"(",
"num_bytes",
")",
"assert",
"len",
"(",
"buf",
")",
"<=",
"num_bytes",
"if",
"len",
"(",
"buf",
")",
"<",
"num_bytes",
":",
"raise",
"Underflo... | Read `num_bytes` and return them.
Parameters
----------
num_bytes : int
Number of bytes to extract from the underlying stream.
Raises
------
UnderflowDecodeError
Raised when a read failed to extract enough bytes from the
underlying st... | [
"Read",
"num_bytes",
"and",
"return",
"them",
"."
] | 0f754250cc3f44f4376777e7e8b3676c5a4d413a | https://github.com/kcallin/mqtt-codec/blob/0f754250cc3f44f4376777e7e8b3676c5a4d413a/mqtt_codec/io.py#L388-L413 |
37,739 | ooici/elasticpy | elasticpy/search.py | ElasticSearch.timeout | def timeout(self, value):
'''
Specifies a timeout on the search query
'''
if not self.params:
self.params = dict(timeout=value)
return self
self.params['timeout'] = value
return self | python | def timeout(self, value):
'''
Specifies a timeout on the search query
'''
if not self.params:
self.params = dict(timeout=value)
return self
self.params['timeout'] = value
return self | [
"def",
"timeout",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"params",
":",
"self",
".",
"params",
"=",
"dict",
"(",
"timeout",
"=",
"value",
")",
"return",
"self",
"self",
".",
"params",
"[",
"'timeout'",
"]",
"=",
"value",
"re... | Specifies a timeout on the search query | [
"Specifies",
"a",
"timeout",
"on",
"the",
"search",
"query"
] | ec221800a80c39e80d8c31667c5b138da39219f2 | https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/search.py#L26-L34 |
37,740 | ooici/elasticpy | elasticpy/search.py | ElasticSearch.filtered | def filtered(self, efilter):
'''
Applies a filter to the search
'''
if not self.params:
self.params={'filter' : efilter}
return self
if not self.params.has_key('filter'):
self.params['filter'] = efilter
return self
self.para... | python | def filtered(self, efilter):
'''
Applies a filter to the search
'''
if not self.params:
self.params={'filter' : efilter}
return self
if not self.params.has_key('filter'):
self.params['filter'] = efilter
return self
self.para... | [
"def",
"filtered",
"(",
"self",
",",
"efilter",
")",
":",
"if",
"not",
"self",
".",
"params",
":",
"self",
".",
"params",
"=",
"{",
"'filter'",
":",
"efilter",
"}",
"return",
"self",
"if",
"not",
"self",
".",
"params",
".",
"has_key",
"(",
"'filter'"... | Applies a filter to the search | [
"Applies",
"a",
"filter",
"to",
"the",
"search"
] | ec221800a80c39e80d8c31667c5b138da39219f2 | https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/search.py#L37-L48 |
37,741 | ooici/elasticpy | elasticpy/search.py | ElasticSearch.size | def size(self,value):
'''
The number of hits to return. Defaults to 10
'''
if not self.params:
self.params = dict(size=value)
return self
self.params['size'] = value
return self | python | def size(self,value):
'''
The number of hits to return. Defaults to 10
'''
if not self.params:
self.params = dict(size=value)
return self
self.params['size'] = value
return self | [
"def",
"size",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"params",
":",
"self",
".",
"params",
"=",
"dict",
"(",
"size",
"=",
"value",
")",
"return",
"self",
"self",
".",
"params",
"[",
"'size'",
"]",
"=",
"value",
"return",
... | The number of hits to return. Defaults to 10 | [
"The",
"number",
"of",
"hits",
"to",
"return",
".",
"Defaults",
"to",
"10"
] | ec221800a80c39e80d8c31667c5b138da39219f2 | https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/search.py#L50-L58 |
37,742 | ooici/elasticpy | elasticpy/search.py | ElasticSearch.from_offset | def from_offset(self, value):
'''
The starting from index of the hits to return. Defaults to 0.
'''
if not self.params:
self.params = dict({'from':value})
return self
self.params['from'] = value
return self | python | def from_offset(self, value):
'''
The starting from index of the hits to return. Defaults to 0.
'''
if not self.params:
self.params = dict({'from':value})
return self
self.params['from'] = value
return self | [
"def",
"from_offset",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"self",
".",
"params",
":",
"self",
".",
"params",
"=",
"dict",
"(",
"{",
"'from'",
":",
"value",
"}",
")",
"return",
"self",
"self",
".",
"params",
"[",
"'from'",
"]",
"=",
... | The starting from index of the hits to return. Defaults to 0. | [
"The",
"starting",
"from",
"index",
"of",
"the",
"hits",
"to",
"return",
".",
"Defaults",
"to",
"0",
"."
] | ec221800a80c39e80d8c31667c5b138da39219f2 | https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/search.py#L60-L68 |
37,743 | ooici/elasticpy | elasticpy/search.py | ElasticSearch.sorted | def sorted(self, fsort):
'''
Allows to add one or more sort on specific fields. Each sort can be reversed as well. The sort is defined on a per field level, with special field name for _score to sort by score.
'''
if not self.params:
self.params = dict()
self.params['... | python | def sorted(self, fsort):
'''
Allows to add one or more sort on specific fields. Each sort can be reversed as well. The sort is defined on a per field level, with special field name for _score to sort by score.
'''
if not self.params:
self.params = dict()
self.params['... | [
"def",
"sorted",
"(",
"self",
",",
"fsort",
")",
":",
"if",
"not",
"self",
".",
"params",
":",
"self",
".",
"params",
"=",
"dict",
"(",
")",
"self",
".",
"params",
"[",
"'sort'",
"]",
"=",
"fsort",
"return",
"self"
] | Allows to add one or more sort on specific fields. Each sort can be reversed as well. The sort is defined on a per field level, with special field name for _score to sort by score. | [
"Allows",
"to",
"add",
"one",
"or",
"more",
"sort",
"on",
"specific",
"fields",
".",
"Each",
"sort",
"can",
"be",
"reversed",
"as",
"well",
".",
"The",
"sort",
"is",
"defined",
"on",
"a",
"per",
"field",
"level",
"with",
"special",
"field",
"name",
"fo... | ec221800a80c39e80d8c31667c5b138da39219f2 | https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/search.py#L87-L95 |
37,744 | ooici/elasticpy | elasticpy/search.py | ElasticSearch.doc_create | def doc_create(self,index,itype,value):
'''
Creates a document
'''
request = self.session
url = 'http://%s:%s/%s/%s/' % (self.host, self.port, index, itype)
if self.verbose:
print value
response = request.post(url,value)
return response | python | def doc_create(self,index,itype,value):
'''
Creates a document
'''
request = self.session
url = 'http://%s:%s/%s/%s/' % (self.host, self.port, index, itype)
if self.verbose:
print value
response = request.post(url,value)
return response | [
"def",
"doc_create",
"(",
"self",
",",
"index",
",",
"itype",
",",
"value",
")",
":",
"request",
"=",
"self",
".",
"session",
"url",
"=",
"'http://%s:%s/%s/%s/'",
"%",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
",",
"index",
",",
"itype",
")... | Creates a document | [
"Creates",
"a",
"document"
] | ec221800a80c39e80d8c31667c5b138da39219f2 | https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/search.py#L145-L154 |
37,745 | ooici/elasticpy | elasticpy/search.py | ElasticSearch.search_index_simple | def search_index_simple(self,index,key,search_term):
'''
Search the index using a simple key and search_term
@param index Name of the index
@param key Search Key
@param search_term The term to be searched for
'''
request = self.session
url = 'http://%s:%s/... | python | def search_index_simple(self,index,key,search_term):
'''
Search the index using a simple key and search_term
@param index Name of the index
@param key Search Key
@param search_term The term to be searched for
'''
request = self.session
url = 'http://%s:%s/... | [
"def",
"search_index_simple",
"(",
"self",
",",
"index",
",",
"key",
",",
"search_term",
")",
":",
"request",
"=",
"self",
".",
"session",
"url",
"=",
"'http://%s:%s/%s/_search?q=%s:%s'",
"%",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
",",
"index... | Search the index using a simple key and search_term
@param index Name of the index
@param key Search Key
@param search_term The term to be searched for | [
"Search",
"the",
"index",
"using",
"a",
"simple",
"key",
"and",
"search_term"
] | ec221800a80c39e80d8c31667c5b138da39219f2 | https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/search.py#L157-L167 |
37,746 | ooici/elasticpy | elasticpy/search.py | ElasticSearch.search_index_advanced | def search_index_advanced(self, index, query):
'''
Advanced search query against an entire index
> query = ElasticQuery().query_string(query='imchi')
> search = ElasticSearch()
'''
request = self.session
url = 'http://%s:%s/%s/_search' % (self.host, self.port, in... | python | def search_index_advanced(self, index, query):
'''
Advanced search query against an entire index
> query = ElasticQuery().query_string(query='imchi')
> search = ElasticSearch()
'''
request = self.session
url = 'http://%s:%s/%s/_search' % (self.host, self.port, in... | [
"def",
"search_index_advanced",
"(",
"self",
",",
"index",
",",
"query",
")",
":",
"request",
"=",
"self",
".",
"session",
"url",
"=",
"'http://%s:%s/%s/_search'",
"%",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
",",
"index",
")",
"if",
"self",
... | Advanced search query against an entire index
> query = ElasticQuery().query_string(query='imchi')
> search = ElasticSearch() | [
"Advanced",
"search",
"query",
"against",
"an",
"entire",
"index"
] | ec221800a80c39e80d8c31667c5b138da39219f2 | https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/search.py#L169-L185 |
37,747 | ooici/elasticpy | elasticpy/search.py | ElasticSearch.map | def map(self,index_name, index_type, map_value):
'''
Enable a specific map for an index and type
'''
request = self.session
url = 'http://%s:%s/%s/%s/_mapping' % (self.host, self.port, index_name, index_type)
content = { index_type : { 'properties' : map_value } }
... | python | def map(self,index_name, index_type, map_value):
'''
Enable a specific map for an index and type
'''
request = self.session
url = 'http://%s:%s/%s/%s/_mapping' % (self.host, self.port, index_name, index_type)
content = { index_type : { 'properties' : map_value } }
... | [
"def",
"map",
"(",
"self",
",",
"index_name",
",",
"index_type",
",",
"map_value",
")",
":",
"request",
"=",
"self",
".",
"session",
"url",
"=",
"'http://%s:%s/%s/%s/_mapping'",
"%",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
",",
"index_name",
... | Enable a specific map for an index and type | [
"Enable",
"a",
"specific",
"map",
"for",
"an",
"index",
"and",
"type"
] | ec221800a80c39e80d8c31667c5b138da39219f2 | https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/search.py#L315-L325 |
37,748 | ooici/elasticpy | elasticpy/search.py | ElasticSearch.list_types | def list_types(index_name, host='localhost',port='9200'):
'''
Lists the context types available in an index
'''
return ElasticSearch(host=host, port=port).type_list(index_name) | python | def list_types(index_name, host='localhost',port='9200'):
'''
Lists the context types available in an index
'''
return ElasticSearch(host=host, port=port).type_list(index_name) | [
"def",
"list_types",
"(",
"index_name",
",",
"host",
"=",
"'localhost'",
",",
"port",
"=",
"'9200'",
")",
":",
"return",
"ElasticSearch",
"(",
"host",
"=",
"host",
",",
"port",
"=",
"port",
")",
".",
"type_list",
"(",
"index_name",
")"
] | Lists the context types available in an index | [
"Lists",
"the",
"context",
"types",
"available",
"in",
"an",
"index"
] | ec221800a80c39e80d8c31667c5b138da39219f2 | https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/search.py#L328-L332 |
37,749 | ooici/elasticpy | elasticpy/search.py | ElasticSearch.type_list | def type_list(self, index_name):
'''
List the types available in an index
'''
request = self.session
url = 'http://%s:%s/%s/_mapping' % (self.host, self.port, index_name)
response = request.get(url)
if request.status_code == 200:
return response[index_... | python | def type_list(self, index_name):
'''
List the types available in an index
'''
request = self.session
url = 'http://%s:%s/%s/_mapping' % (self.host, self.port, index_name)
response = request.get(url)
if request.status_code == 200:
return response[index_... | [
"def",
"type_list",
"(",
"self",
",",
"index_name",
")",
":",
"request",
"=",
"self",
".",
"session",
"url",
"=",
"'http://%s:%s/%s/_mapping'",
"%",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
",",
"index_name",
")",
"response",
"=",
"request",
"... | List the types available in an index | [
"List",
"the",
"types",
"available",
"in",
"an",
"index"
] | ec221800a80c39e80d8c31667c5b138da39219f2 | https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/search.py#L334-L344 |
37,750 | ooici/elasticpy | elasticpy/search.py | ElasticSearch.raw | def raw(self, module, method='GET', data=None):
'''
Submits or requsts raw input
'''
request = self.session
url = 'http://%s:%s/%s' % (self.host, self.port, module)
if self.verbose:
print data
if method=='GET':
response = request.get(url)
... | python | def raw(self, module, method='GET', data=None):
'''
Submits or requsts raw input
'''
request = self.session
url = 'http://%s:%s/%s' % (self.host, self.port, module)
if self.verbose:
print data
if method=='GET':
response = request.get(url)
... | [
"def",
"raw",
"(",
"self",
",",
"module",
",",
"method",
"=",
"'GET'",
",",
"data",
"=",
"None",
")",
":",
"request",
"=",
"self",
".",
"session",
"url",
"=",
"'http://%s:%s/%s'",
"%",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
",",
"modul... | Submits or requsts raw input | [
"Submits",
"or",
"requsts",
"raw",
"input"
] | ec221800a80c39e80d8c31667c5b138da39219f2 | https://github.com/ooici/elasticpy/blob/ec221800a80c39e80d8c31667c5b138da39219f2/elasticpy/search.py#L350-L369 |
37,751 | polyledger/lattice | lattice/wallet.py | secp256k1.inverse | def inverse(self, N):
"""
Returns the modular inverse of an integer with respect to the field
characteristic, P.
Use the Extended Euclidean Algorithm:
https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
"""
if N == 0:
return 0
lm, hm = ... | python | def inverse(self, N):
"""
Returns the modular inverse of an integer with respect to the field
characteristic, P.
Use the Extended Euclidean Algorithm:
https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
"""
if N == 0:
return 0
lm, hm = ... | [
"def",
"inverse",
"(",
"self",
",",
"N",
")",
":",
"if",
"N",
"==",
"0",
":",
"return",
"0",
"lm",
",",
"hm",
"=",
"1",
",",
"0",
"low",
",",
"high",
"=",
"N",
"%",
"self",
".",
"P",
",",
"self",
".",
"P",
"while",
"low",
">",
"1",
":",
... | Returns the modular inverse of an integer with respect to the field
characteristic, P.
Use the Extended Euclidean Algorithm:
https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm | [
"Returns",
"the",
"modular",
"inverse",
"of",
"an",
"integer",
"with",
"respect",
"to",
"the",
"field",
"characteristic",
"P",
"."
] | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/wallet.py#L47-L64 |
37,752 | polyledger/lattice | lattice/wallet.py | secp256k1.is_on_curve | def is_on_curve(self, point):
"""
Checks whether a point is on the curve.
Args:
point (AffinePoint): Point to be checked.
Returns:
bool: True if point is on the curve, False otherwise.
"""
X, Y = point.X, point.Y
return (
... | python | def is_on_curve(self, point):
"""
Checks whether a point is on the curve.
Args:
point (AffinePoint): Point to be checked.
Returns:
bool: True if point is on the curve, False otherwise.
"""
X, Y = point.X, point.Y
return (
... | [
"def",
"is_on_curve",
"(",
"self",
",",
"point",
")",
":",
"X",
",",
"Y",
"=",
"point",
".",
"X",
",",
"point",
".",
"Y",
"return",
"(",
"pow",
"(",
"Y",
",",
"2",
",",
"self",
".",
"P",
")",
"-",
"pow",
"(",
"X",
",",
"3",
",",
"self",
"... | Checks whether a point is on the curve.
Args:
point (AffinePoint): Point to be checked.
Returns:
bool: True if point is on the curve, False otherwise. | [
"Checks",
"whether",
"a",
"point",
"is",
"on",
"the",
"curve",
"."
] | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/wallet.py#L66-L79 |
37,753 | polyledger/lattice | lattice/wallet.py | Wallet.generate_private_key | def generate_private_key(self):
"""
Generates a private key based on the password.
SHA-256 is a member of the SHA-2 cryptographic hash functions designed by
the NSA. SHA stands for Secure Hash Algorithm. The password is converted
to bytes and hashed with SHA-256. The binary outp... | python | def generate_private_key(self):
"""
Generates a private key based on the password.
SHA-256 is a member of the SHA-2 cryptographic hash functions designed by
the NSA. SHA stands for Secure Hash Algorithm. The password is converted
to bytes and hashed with SHA-256. The binary outp... | [
"def",
"generate_private_key",
"(",
"self",
")",
":",
"random_string",
"=",
"base64",
".",
"b64encode",
"(",
"os",
".",
"urandom",
"(",
"4096",
")",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"binary_data",
"=",
"bytes",
"(",
"random_string",
",",
"'utf-8'",... | Generates a private key based on the password.
SHA-256 is a member of the SHA-2 cryptographic hash functions designed by
the NSA. SHA stands for Secure Hash Algorithm. The password is converted
to bytes and hashed with SHA-256. The binary output is converted to a hex
representation.
... | [
"Generates",
"a",
"private",
"key",
"based",
"on",
"the",
"password",
"."
] | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/wallet.py#L93-L113 |
37,754 | polyledger/lattice | lattice/wallet.py | Wallet.generate_public_key | def generate_public_key(self):
"""
Generates a public key from the hex-encoded private key using elliptic
curve cryptography. The private key is multiplied by a predetermined point
on the elliptic curve called the generator point, G, resulting in the
corresponding private key. Th... | python | def generate_public_key(self):
"""
Generates a public key from the hex-encoded private key using elliptic
curve cryptography. The private key is multiplied by a predetermined point
on the elliptic curve called the generator point, G, resulting in the
corresponding private key. Th... | [
"def",
"generate_public_key",
"(",
"self",
")",
":",
"private_key",
"=",
"int",
"(",
"self",
".",
"private_key",
",",
"16",
")",
"if",
"private_key",
">=",
"self",
".",
"N",
":",
"raise",
"Exception",
"(",
"'Invalid private key.'",
")",
"G",
"=",
"Jacobian... | Generates a public key from the hex-encoded private key using elliptic
curve cryptography. The private key is multiplied by a predetermined point
on the elliptic curve called the generator point, G, resulting in the
corresponding private key. The generator point is always the same for all
... | [
"Generates",
"a",
"public",
"key",
"from",
"the",
"hex",
"-",
"encoded",
"private",
"key",
"using",
"elliptic",
"curve",
"cryptography",
".",
"The",
"private",
"key",
"is",
"multiplied",
"by",
"a",
"predetermined",
"point",
"on",
"the",
"elliptic",
"curve",
... | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/wallet.py#L115-L149 |
37,755 | polyledger/lattice | lattice/wallet.py | JacobianPoint.to_affine | def to_affine(self):
"""
Converts this point to an affine representation.
Returns:
AffinePoint: The affine reprsentation.
"""
X, Y, Z = self.x, self.y, self.inverse(self.z)
return ((X * Z ** 2) % P, (Y * Z ** 3) % P) | python | def to_affine(self):
"""
Converts this point to an affine representation.
Returns:
AffinePoint: The affine reprsentation.
"""
X, Y, Z = self.x, self.y, self.inverse(self.z)
return ((X * Z ** 2) % P, (Y * Z ** 3) % P) | [
"def",
"to_affine",
"(",
"self",
")",
":",
"X",
",",
"Y",
",",
"Z",
"=",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"inverse",
"(",
"self",
".",
"z",
")",
"return",
"(",
"(",
"X",
"*",
"Z",
"**",
"2",
")",
"%",
"P",
",",
... | Converts this point to an affine representation.
Returns:
AffinePoint: The affine reprsentation. | [
"Converts",
"this",
"point",
"to",
"an",
"affine",
"representation",
"."
] | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/wallet.py#L279-L287 |
37,756 | polyledger/lattice | lattice/wallet.py | AffinePoint.slope | def slope(self, other):
"""
Determines the slope between this point and another point.
Args:
other (AffinePoint): The second point.
Returns:
int: Slope between self and other.
"""
X1, Y1, X2, Y2 = self.X, self.Y, other.X, other.Y
Y3 = Y1 ... | python | def slope(self, other):
"""
Determines the slope between this point and another point.
Args:
other (AffinePoint): The second point.
Returns:
int: Slope between self and other.
"""
X1, Y1, X2, Y2 = self.X, self.Y, other.X, other.Y
Y3 = Y1 ... | [
"def",
"slope",
"(",
"self",
",",
"other",
")",
":",
"X1",
",",
"Y1",
",",
"X2",
",",
"Y2",
"=",
"self",
".",
"X",
",",
"self",
".",
"Y",
",",
"other",
".",
"X",
",",
"other",
".",
"Y",
"Y3",
"=",
"Y1",
"-",
"Y2",
"X3",
"=",
"X1",
"-",
... | Determines the slope between this point and another point.
Args:
other (AffinePoint): The second point.
Returns:
int: Slope between self and other. | [
"Determines",
"the",
"slope",
"between",
"this",
"point",
"and",
"another",
"point",
"."
] | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/wallet.py#L378-L391 |
37,757 | polyledger/lattice | lattice/wallet.py | AffinePoint.to_jacobian | def to_jacobian(self):
"""
Converts this point to a Jacobian representation.
Returns:
JacobianPoint: The Jacobian representation.
"""
if not self:
return JacobianPoint(X=0, Y=0, Z=0)
return JacobianPoint(X=self.X, Y=self.Y, Z=1) | python | def to_jacobian(self):
"""
Converts this point to a Jacobian representation.
Returns:
JacobianPoint: The Jacobian representation.
"""
if not self:
return JacobianPoint(X=0, Y=0, Z=0)
return JacobianPoint(X=self.X, Y=self.Y, Z=1) | [
"def",
"to_jacobian",
"(",
"self",
")",
":",
"if",
"not",
"self",
":",
"return",
"JacobianPoint",
"(",
"X",
"=",
"0",
",",
"Y",
"=",
"0",
",",
"Z",
"=",
"0",
")",
"return",
"JacobianPoint",
"(",
"X",
"=",
"self",
".",
"X",
",",
"Y",
"=",
"self"... | Converts this point to a Jacobian representation.
Returns:
JacobianPoint: The Jacobian representation. | [
"Converts",
"this",
"point",
"to",
"a",
"Jacobian",
"representation",
"."
] | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/wallet.py#L393-L402 |
37,758 | nikcub/floyd | floyd/db/__init__.py | DataStore.import_model | def import_model(self, name, path="floyd.db.models"):
"""imports a model of name from path, returning from local model
cache if it has been previously loaded otherwise importing"""
if name in self._model_cache:
return self._model_cache[name]
try:
model = getattr(__import__(path, None, Non... | python | def import_model(self, name, path="floyd.db.models"):
"""imports a model of name from path, returning from local model
cache if it has been previously loaded otherwise importing"""
if name in self._model_cache:
return self._model_cache[name]
try:
model = getattr(__import__(path, None, Non... | [
"def",
"import_model",
"(",
"self",
",",
"name",
",",
"path",
"=",
"\"floyd.db.models\"",
")",
":",
"if",
"name",
"in",
"self",
".",
"_model_cache",
":",
"return",
"self",
".",
"_model_cache",
"[",
"name",
"]",
"try",
":",
"model",
"=",
"getattr",
"(",
... | imports a model of name from path, returning from local model
cache if it has been previously loaded otherwise importing | [
"imports",
"a",
"model",
"of",
"name",
"from",
"path",
"returning",
"from",
"local",
"model",
"cache",
"if",
"it",
"has",
"been",
"previously",
"loaded",
"otherwise",
"importing"
] | 5772d0047efb11c9ce5f7d234a9da4576ce24edc | https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/db/__init__.py#L76-L87 |
37,759 | nikcub/floyd | floyd/db/__init__.py | Model.parse_md | def parse_md(self):
"""Takes a post path and returns a dictionary of variables"""
post_content = _MARKDOWN.convert(self.raw_src)
if hasattr(_MARKDOWN, 'Meta'):
# 'Meta' in _MARKDOWN and _MARKDOWN.Meta:
for key in _MARKDOWN.Meta:
print "\t meta: %s: %s (%s)" % (key, _MARKDOWN.Meta[key][0... | python | def parse_md(self):
"""Takes a post path and returns a dictionary of variables"""
post_content = _MARKDOWN.convert(self.raw_src)
if hasattr(_MARKDOWN, 'Meta'):
# 'Meta' in _MARKDOWN and _MARKDOWN.Meta:
for key in _MARKDOWN.Meta:
print "\t meta: %s: %s (%s)" % (key, _MARKDOWN.Meta[key][0... | [
"def",
"parse_md",
"(",
"self",
")",
":",
"post_content",
"=",
"_MARKDOWN",
".",
"convert",
"(",
"self",
".",
"raw_src",
")",
"if",
"hasattr",
"(",
"_MARKDOWN",
",",
"'Meta'",
")",
":",
"# 'Meta' in _MARKDOWN and _MARKDOWN.Meta:",
"for",
"key",
"in",
"_MARKDOW... | Takes a post path and returns a dictionary of variables | [
"Takes",
"a",
"post",
"path",
"and",
"returns",
"a",
"dictionary",
"of",
"variables"
] | 5772d0047efb11c9ce5f7d234a9da4576ce24edc | https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/db/__init__.py#L140-L161 |
37,760 | VikParuchuri/percept | percept/workflows/base.py | BaseWorkflow.execute_train_task_with_dependencies | def execute_train_task_with_dependencies(self, task_cls, **kwargs):
"""
Run the training, as well as any dependencies of the training
task_cls - class of a task
"""
log.info("Task {0}".format(get_task_name(task_cls)))
#Instantiate the task
task_inst = task_cls()
... | python | def execute_train_task_with_dependencies(self, task_cls, **kwargs):
"""
Run the training, as well as any dependencies of the training
task_cls - class of a task
"""
log.info("Task {0}".format(get_task_name(task_cls)))
#Instantiate the task
task_inst = task_cls()
... | [
"def",
"execute_train_task_with_dependencies",
"(",
"self",
",",
"task_cls",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"\"Task {0}\"",
".",
"format",
"(",
"get_task_name",
"(",
"task_cls",
")",
")",
")",
"#Instantiate the task",
"task_inst",
... | Run the training, as well as any dependencies of the training
task_cls - class of a task | [
"Run",
"the",
"training",
"as",
"well",
"as",
"any",
"dependencies",
"of",
"the",
"training",
"task_cls",
"-",
"class",
"of",
"a",
"task"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/workflows/base.py#L54-L86 |
37,761 | VikParuchuri/percept | percept/workflows/base.py | BaseWorkflow.execute_predict_task | def execute_predict_task(self, task_inst, predict_data, **kwargs):
"""
Do a prediction
task_inst - instance of a task
"""
result = task_inst.predict(predict_data, **task_inst.args)
return result | python | def execute_predict_task(self, task_inst, predict_data, **kwargs):
"""
Do a prediction
task_inst - instance of a task
"""
result = task_inst.predict(predict_data, **task_inst.args)
return result | [
"def",
"execute_predict_task",
"(",
"self",
",",
"task_inst",
",",
"predict_data",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"task_inst",
".",
"predict",
"(",
"predict_data",
",",
"*",
"*",
"task_inst",
".",
"args",
")",
"return",
"result"
] | Do a prediction
task_inst - instance of a task | [
"Do",
"a",
"prediction",
"task_inst",
"-",
"instance",
"of",
"a",
"task"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/workflows/base.py#L88-L94 |
37,762 | VikParuchuri/percept | percept/workflows/base.py | BaseWorkflow.train | def train(self, **kwargs):
"""
Do the workflow training
"""
log.info("Starting to train...")
if not self.setup_run:
self.setup()
self.trained_tasks = []
for task in self.tasks:
data = self.reformatted_input[task.data_format]['data']
... | python | def train(self, **kwargs):
"""
Do the workflow training
"""
log.info("Starting to train...")
if not self.setup_run:
self.setup()
self.trained_tasks = []
for task in self.tasks:
data = self.reformatted_input[task.data_format]['data']
... | [
"def",
"train",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"info",
"(",
"\"Starting to train...\"",
")",
"if",
"not",
"self",
".",
"setup_run",
":",
"self",
".",
"setup",
"(",
")",
"self",
".",
"trained_tasks",
"=",
"[",
"]",
"for",
... | Do the workflow training | [
"Do",
"the",
"workflow",
"training"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/workflows/base.py#L96-L116 |
37,763 | VikParuchuri/percept | percept/workflows/base.py | BaseWorkflow.read_input | def read_input(self, input_cls, filename, **kwargs):
"""
Read in input and do some minimal preformatting
input_cls - the class to use to read the input
filename - input filename
"""
input_inst = input_cls()
input_inst.read_input(filename)
return input_inst... | python | def read_input(self, input_cls, filename, **kwargs):
"""
Read in input and do some minimal preformatting
input_cls - the class to use to read the input
filename - input filename
"""
input_inst = input_cls()
input_inst.read_input(filename)
return input_inst... | [
"def",
"read_input",
"(",
"self",
",",
"input_cls",
",",
"filename",
",",
"*",
"*",
"kwargs",
")",
":",
"input_inst",
"=",
"input_cls",
"(",
")",
"input_inst",
".",
"read_input",
"(",
"filename",
")",
"return",
"input_inst",
".",
"get_data",
"(",
")"
] | Read in input and do some minimal preformatting
input_cls - the class to use to read the input
filename - input filename | [
"Read",
"in",
"input",
"and",
"do",
"some",
"minimal",
"preformatting",
"input_cls",
"-",
"the",
"class",
"to",
"use",
"to",
"read",
"the",
"input",
"filename",
"-",
"input",
"filename"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/workflows/base.py#L138-L146 |
37,764 | VikParuchuri/percept | percept/workflows/base.py | BaseWorkflow.reformat_file | def reformat_file(self, input_file, input_format, output_format):
"""
Reformat input data files to a format the tasks can use
"""
#Return none if input_file or input_format do not exist
if input_file is None or input_format is None:
return None
#Find the neede... | python | def reformat_file(self, input_file, input_format, output_format):
"""
Reformat input data files to a format the tasks can use
"""
#Return none if input_file or input_format do not exist
if input_file is None or input_format is None:
return None
#Find the neede... | [
"def",
"reformat_file",
"(",
"self",
",",
"input_file",
",",
"input_format",
",",
"output_format",
")",
":",
"#Return none if input_file or input_format do not exist",
"if",
"input_file",
"is",
"None",
"or",
"input_format",
"is",
"None",
":",
"return",
"None",
"#Find ... | Reformat input data files to a format the tasks can use | [
"Reformat",
"input",
"data",
"files",
"to",
"a",
"format",
"the",
"tasks",
"can",
"use"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/workflows/base.py#L148-L174 |
37,765 | VikParuchuri/percept | percept/workflows/base.py | BaseWorkflow.reformat_input | def reformat_input(self, **kwargs):
"""
Reformat input data
"""
reformatted_input = {}
needed_formats = []
for task_cls in self.tasks:
needed_formats.append(task_cls.data_format)
self.needed_formats = list(set(needed_formats))
for output_forma... | python | def reformat_input(self, **kwargs):
"""
Reformat input data
"""
reformatted_input = {}
needed_formats = []
for task_cls in self.tasks:
needed_formats.append(task_cls.data_format)
self.needed_formats = list(set(needed_formats))
for output_forma... | [
"def",
"reformat_input",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"reformatted_input",
"=",
"{",
"}",
"needed_formats",
"=",
"[",
"]",
"for",
"task_cls",
"in",
"self",
".",
"tasks",
":",
"needed_formats",
".",
"append",
"(",
"task_cls",
".",
"data... | Reformat input data | [
"Reformat",
"input",
"data"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/workflows/base.py#L196-L216 |
37,766 | dpnova/python-xprintidle | xprintidle.py | _create_modulename | def _create_modulename(cdef_sources, source, sys_version):
"""
This is the same as CFFI's create modulename except we don't include the
CFFI version.
"""
key = '\x00'.join([sys_version[:3], source, cdef_sources])
key = key.encode('utf-8')
k1 = hex(binascii.crc32(key[0::2]) & 0xffffffff)
... | python | def _create_modulename(cdef_sources, source, sys_version):
"""
This is the same as CFFI's create modulename except we don't include the
CFFI version.
"""
key = '\x00'.join([sys_version[:3], source, cdef_sources])
key = key.encode('utf-8')
k1 = hex(binascii.crc32(key[0::2]) & 0xffffffff)
... | [
"def",
"_create_modulename",
"(",
"cdef_sources",
",",
"source",
",",
"sys_version",
")",
":",
"key",
"=",
"'\\x00'",
".",
"join",
"(",
"[",
"sys_version",
"[",
":",
"3",
"]",
",",
"source",
",",
"cdef_sources",
"]",
")",
"key",
"=",
"key",
".",
"encod... | This is the same as CFFI's create modulename except we don't include the
CFFI version. | [
"This",
"is",
"the",
"same",
"as",
"CFFI",
"s",
"create",
"modulename",
"except",
"we",
"don",
"t",
"include",
"the",
"CFFI",
"version",
"."
] | cc8f3c13a5dd578073d20f3d42208fcb8e1983b8 | https://github.com/dpnova/python-xprintidle/blob/cc8f3c13a5dd578073d20f3d42208fcb8e1983b8/xprintidle.py#L10-L21 |
37,767 | liip/requests_gpgauthlib | requests_gpgauthlib/gpgauth_session.py | GPGAuthSession.is_authenticated_with_token | def is_authenticated_with_token(self):
""" GPGAuth Stage 2 """
""" Send back the token to the server to get auth cookie """
server_login_response = post_log_in(
self,
keyid=self.user_fingerprint,
user_token_result=self.user_auth_token
)
if no... | python | def is_authenticated_with_token(self):
""" GPGAuth Stage 2 """
""" Send back the token to the server to get auth cookie """
server_login_response = post_log_in(
self,
keyid=self.user_fingerprint,
user_token_result=self.user_auth_token
)
if no... | [
"def",
"is_authenticated_with_token",
"(",
"self",
")",
":",
"\"\"\" Send back the token to the server to get auth cookie \"\"\"",
"server_login_response",
"=",
"post_log_in",
"(",
"self",
",",
"keyid",
"=",
"self",
".",
"user_fingerprint",
",",
"user_token_result",
"=",
"s... | GPGAuth Stage 2 | [
"GPGAuth",
"Stage",
"2"
] | 017711dfff6cc74cc4cb78ee05dec5e38564987e | https://github.com/liip/requests_gpgauthlib/blob/017711dfff6cc74cc4cb78ee05dec5e38564987e/requests_gpgauthlib/gpgauth_session.py#L208-L222 |
37,768 | VikParuchuri/percept | percept/utils/workflow.py | WorkflowLoader.save | def save(self, obj, run_id):
"""
Save a workflow
obj - instance of a workflow to save
run_id - unique id to give the run
"""
id_code = self.generate_save_identifier(obj, run_id)
self.store.save(obj, id_code) | python | def save(self, obj, run_id):
"""
Save a workflow
obj - instance of a workflow to save
run_id - unique id to give the run
"""
id_code = self.generate_save_identifier(obj, run_id)
self.store.save(obj, id_code) | [
"def",
"save",
"(",
"self",
",",
"obj",
",",
"run_id",
")",
":",
"id_code",
"=",
"self",
".",
"generate_save_identifier",
"(",
"obj",
",",
"run_id",
")",
"self",
".",
"store",
".",
"save",
"(",
"obj",
",",
"id_code",
")"
] | Save a workflow
obj - instance of a workflow to save
run_id - unique id to give the run | [
"Save",
"a",
"workflow",
"obj",
"-",
"instance",
"of",
"a",
"workflow",
"to",
"save",
"run_id",
"-",
"unique",
"id",
"to",
"give",
"the",
"run"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/utils/workflow.py#L30-L37 |
37,769 | VikParuchuri/percept | percept/utils/workflow.py | WorkflowWrapper.setup_tasks | def setup_tasks(self, tasks):
"""
Find task classes from category.namespace.name strings
tasks - list of strings
"""
task_classes = []
for task in tasks:
category, namespace, name = task.split(".")
try:
cls = find_in_registry(catego... | python | def setup_tasks(self, tasks):
"""
Find task classes from category.namespace.name strings
tasks - list of strings
"""
task_classes = []
for task in tasks:
category, namespace, name = task.split(".")
try:
cls = find_in_registry(catego... | [
"def",
"setup_tasks",
"(",
"self",
",",
"tasks",
")",
":",
"task_classes",
"=",
"[",
"]",
"for",
"task",
"in",
"tasks",
":",
"category",
",",
"namespace",
",",
"name",
"=",
"task",
".",
"split",
"(",
"\".\"",
")",
"try",
":",
"cls",
"=",
"find_in_reg... | Find task classes from category.namespace.name strings
tasks - list of strings | [
"Find",
"task",
"classes",
"from",
"category",
".",
"namespace",
".",
"name",
"strings",
"tasks",
"-",
"list",
"of",
"strings"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/utils/workflow.py#L100-L114 |
37,770 | VikParuchuri/percept | percept/utils/workflow.py | WorkflowWrapper.initialize_workflow | def initialize_workflow(self, workflow):
"""
Create a workflow
workflow - a workflow class
"""
self.workflow = workflow()
self.workflow.tasks = self.tasks
self.workflow.input_file = self.input_file
self.workflow.input_format = self.input_format
se... | python | def initialize_workflow(self, workflow):
"""
Create a workflow
workflow - a workflow class
"""
self.workflow = workflow()
self.workflow.tasks = self.tasks
self.workflow.input_file = self.input_file
self.workflow.input_format = self.input_format
se... | [
"def",
"initialize_workflow",
"(",
"self",
",",
"workflow",
")",
":",
"self",
".",
"workflow",
"=",
"workflow",
"(",
")",
"self",
".",
"workflow",
".",
"tasks",
"=",
"self",
".",
"tasks",
"self",
".",
"workflow",
".",
"input_file",
"=",
"self",
".",
"i... | Create a workflow
workflow - a workflow class | [
"Create",
"a",
"workflow",
"workflow",
"-",
"a",
"workflow",
"class"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/utils/workflow.py#L116-L130 |
37,771 | VikParuchuri/percept | percept/utils/workflow.py | WorkflowWrapper.reformat_filepath | def reformat_filepath(self, config_file, filename):
"""
Convert relative paths in config file to absolute
"""
if not filename.startswith("/"):
filename = self.config_file_format.format(config_file, filename)
return filename | python | def reformat_filepath(self, config_file, filename):
"""
Convert relative paths in config file to absolute
"""
if not filename.startswith("/"):
filename = self.config_file_format.format(config_file, filename)
return filename | [
"def",
"reformat_filepath",
"(",
"self",
",",
"config_file",
",",
"filename",
")",
":",
"if",
"not",
"filename",
".",
"startswith",
"(",
"\"/\"",
")",
":",
"filename",
"=",
"self",
".",
"config_file_format",
".",
"format",
"(",
"config_file",
",",
"filename"... | Convert relative paths in config file to absolute | [
"Convert",
"relative",
"paths",
"in",
"config",
"file",
"to",
"absolute"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/utils/workflow.py#L132-L138 |
37,772 | studionow/pybrightcove | pybrightcove/connection.py | item_lister | def item_lister(command, _connection, page_size, page_number, sort_by,
sort_order, item_class, result_set, **kwargs):
"""
A generator function for listing Video and Playlist objects.
"""
# pylint: disable=R0913
page = page_number
while True:
item_collection = _connection.get_list(com... | python | def item_lister(command, _connection, page_size, page_number, sort_by,
sort_order, item_class, result_set, **kwargs):
"""
A generator function for listing Video and Playlist objects.
"""
# pylint: disable=R0913
page = page_number
while True:
item_collection = _connection.get_list(com... | [
"def",
"item_lister",
"(",
"command",
",",
"_connection",
",",
"page_size",
",",
"page_number",
",",
"sort_by",
",",
"sort_order",
",",
"item_class",
",",
"result_set",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=R0913",
"page",
"=",
"page_number",
"... | A generator function for listing Video and Playlist objects. | [
"A",
"generator",
"function",
"for",
"listing",
"Video",
"and",
"Playlist",
"objects",
"."
] | 19c946b689a80156e070fe9bc35589c4b768e614 | https://github.com/studionow/pybrightcove/blob/19c946b689a80156e070fe9bc35589c4b768e614/pybrightcove/connection.py#L281-L305 |
37,773 | studionow/pybrightcove | pybrightcove/connection.py | FTPConnection.get_manifest | def get_manifest(self, asset_xml):
"""
Construct and return the xml manifest to deliver along with video file.
"""
# pylint: disable=E1101
manifest = '<?xml version="1.0" encoding="utf-8"?>'
manifest += '<publisher-upload-manifest publisher-id="%s" ' % \
self.... | python | def get_manifest(self, asset_xml):
"""
Construct and return the xml manifest to deliver along with video file.
"""
# pylint: disable=E1101
manifest = '<?xml version="1.0" encoding="utf-8"?>'
manifest += '<publisher-upload-manifest publisher-id="%s" ' % \
self.... | [
"def",
"get_manifest",
"(",
"self",
",",
"asset_xml",
")",
":",
"# pylint: disable=E1101",
"manifest",
"=",
"'<?xml version=\"1.0\" encoding=\"utf-8\"?>'",
"manifest",
"+=",
"'<publisher-upload-manifest publisher-id=\"%s\" '",
"%",
"self",
".",
"publisher_id",
"manifest",
"+=... | Construct and return the xml manifest to deliver along with video file. | [
"Construct",
"and",
"return",
"the",
"xml",
"manifest",
"to",
"deliver",
"along",
"with",
"video",
"file",
"."
] | 19c946b689a80156e070fe9bc35589c4b768e614 | https://github.com/studionow/pybrightcove/blob/19c946b689a80156e070fe9bc35589c4b768e614/pybrightcove/connection.py#L103-L120 |
37,774 | studionow/pybrightcove | pybrightcove/connection.py | FTPConnection._send_file | def _send_file(self, filename):
"""
Sends a file via FTP.
"""
# pylint: disable=E1101
ftp = ftplib.FTP(host=self.host)
ftp.login(user=self.user, passwd=self.password)
ftp.set_pasv(True)
ftp.storbinary("STOR %s" % os.path.basename(filename),
fil... | python | def _send_file(self, filename):
"""
Sends a file via FTP.
"""
# pylint: disable=E1101
ftp = ftplib.FTP(host=self.host)
ftp.login(user=self.user, passwd=self.password)
ftp.set_pasv(True)
ftp.storbinary("STOR %s" % os.path.basename(filename),
fil... | [
"def",
"_send_file",
"(",
"self",
",",
"filename",
")",
":",
"# pylint: disable=E1101",
"ftp",
"=",
"ftplib",
".",
"FTP",
"(",
"host",
"=",
"self",
".",
"host",
")",
"ftp",
".",
"login",
"(",
"user",
"=",
"self",
".",
"user",
",",
"passwd",
"=",
"sel... | Sends a file via FTP. | [
"Sends",
"a",
"file",
"via",
"FTP",
"."
] | 19c946b689a80156e070fe9bc35589c4b768e614 | https://github.com/studionow/pybrightcove/blob/19c946b689a80156e070fe9bc35589c4b768e614/pybrightcove/connection.py#L122-L131 |
37,775 | studionow/pybrightcove | pybrightcove/connection.py | APIConnection._post | def _post(self, data, file_to_upload=None):
"""
Make the POST request.
"""
# pylint: disable=E1101
params = {"JSONRPC": simplejson.dumps(data)}
req = None
if file_to_upload:
req = http_core.HttpRequest(self.write_url)
req.method = 'POST'
... | python | def _post(self, data, file_to_upload=None):
"""
Make the POST request.
"""
# pylint: disable=E1101
params = {"JSONRPC": simplejson.dumps(data)}
req = None
if file_to_upload:
req = http_core.HttpRequest(self.write_url)
req.method = 'POST'
... | [
"def",
"_post",
"(",
"self",
",",
"data",
",",
"file_to_upload",
"=",
"None",
")",
":",
"# pylint: disable=E1101",
"params",
"=",
"{",
"\"JSONRPC\"",
":",
"simplejson",
".",
"dumps",
"(",
"data",
")",
"}",
"req",
"=",
"None",
"if",
"file_to_upload",
":",
... | Make the POST request. | [
"Make",
"the",
"POST",
"request",
"."
] | 19c946b689a80156e070fe9bc35589c4b768e614 | https://github.com/studionow/pybrightcove/blob/19c946b689a80156e070fe9bc35589c4b768e614/pybrightcove/connection.py#L181-L210 |
37,776 | studionow/pybrightcove | pybrightcove/connection.py | APIConnection._get_response | def _get_response(self, **kwargs):
"""
Make the GET request.
"""
# pylint: disable=E1101
url = self.read_url + "?output=JSON&token=%s" % self.read_token
for key in kwargs:
if key and kwargs[key]:
val = kwargs[key]
if isinstance(... | python | def _get_response(self, **kwargs):
"""
Make the GET request.
"""
# pylint: disable=E1101
url = self.read_url + "?output=JSON&token=%s" % self.read_token
for key in kwargs:
if key and kwargs[key]:
val = kwargs[key]
if isinstance(... | [
"def",
"_get_response",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=E1101",
"url",
"=",
"self",
".",
"read_url",
"+",
"\"?output=JSON&token=%s\"",
"%",
"self",
".",
"read_token",
"for",
"key",
"in",
"kwargs",
":",
"if",
"key",
"and",
... | Make the GET request. | [
"Make",
"the",
"GET",
"request",
"."
] | 19c946b689a80156e070fe9bc35589c4b768e614 | https://github.com/studionow/pybrightcove/blob/19c946b689a80156e070fe9bc35589c4b768e614/pybrightcove/connection.py#L212-L234 |
37,777 | studionow/pybrightcove | pybrightcove/connection.py | APIConnection.get_list | def get_list(self, command, item_class, page_size, page_number, sort_by,
sort_order, **kwargs):
"""
Not intended to be called directly, but rather through an by the
ItemResultSet object iterator.
"""
# pylint: disable=R0913,W0221
data = self._get_response(command=... | python | def get_list(self, command, item_class, page_size, page_number, sort_by,
sort_order, **kwargs):
"""
Not intended to be called directly, but rather through an by the
ItemResultSet object iterator.
"""
# pylint: disable=R0913,W0221
data = self._get_response(command=... | [
"def",
"get_list",
"(",
"self",
",",
"command",
",",
"item_class",
",",
"page_size",
",",
"page_number",
",",
"sort_by",
",",
"sort_order",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=R0913,W0221",
"data",
"=",
"self",
".",
"_get_response",
"(",
"c... | Not intended to be called directly, but rather through an by the
ItemResultSet object iterator. | [
"Not",
"intended",
"to",
"be",
"called",
"directly",
"but",
"rather",
"through",
"an",
"by",
"the",
"ItemResultSet",
"object",
"iterator",
"."
] | 19c946b689a80156e070fe9bc35589c4b768e614 | https://github.com/studionow/pybrightcove/blob/19c946b689a80156e070fe9bc35589c4b768e614/pybrightcove/connection.py#L256-L273 |
37,778 | VikParuchuri/percept | percept/datahandlers/formatters.py | BaseFormat.setup_formats | def setup_formats(self):
"""
Inspects its methods to see what it can convert from and to
"""
methods = self.get_methods()
for m in methods:
#Methods named "from_X" will be assumed to convert from format X to the common format
if m.startswith("from_"):
... | python | def setup_formats(self):
"""
Inspects its methods to see what it can convert from and to
"""
methods = self.get_methods()
for m in methods:
#Methods named "from_X" will be assumed to convert from format X to the common format
if m.startswith("from_"):
... | [
"def",
"setup_formats",
"(",
"self",
")",
":",
"methods",
"=",
"self",
".",
"get_methods",
"(",
")",
"for",
"m",
"in",
"methods",
":",
"#Methods named \"from_X\" will be assumed to convert from format X to the common format",
"if",
"m",
".",
"startswith",
"(",
"\"from... | Inspects its methods to see what it can convert from and to | [
"Inspects",
"its",
"methods",
"to",
"see",
"what",
"it",
"can",
"convert",
"from",
"and",
"to"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/datahandlers/formatters.py#L45-L56 |
37,779 | VikParuchuri/percept | percept/datahandlers/formatters.py | BaseFormat.get_data | def get_data(self, data_format):
"""
Reads the common format and converts to output data
data_format - the format of the output data. See utils.input.dataformats
"""
if data_format not in self.output_formats:
raise Exception("Output format {0} not available with this... | python | def get_data(self, data_format):
"""
Reads the common format and converts to output data
data_format - the format of the output data. See utils.input.dataformats
"""
if data_format not in self.output_formats:
raise Exception("Output format {0} not available with this... | [
"def",
"get_data",
"(",
"self",
",",
"data_format",
")",
":",
"if",
"data_format",
"not",
"in",
"self",
".",
"output_formats",
":",
"raise",
"Exception",
"(",
"\"Output format {0} not available with this class. Available formats are {1}.\"",
".",
"format",
"(",
"data_fo... | Reads the common format and converts to output data
data_format - the format of the output data. See utils.input.dataformats | [
"Reads",
"the",
"common",
"format",
"and",
"converts",
"to",
"output",
"data",
"data_format",
"-",
"the",
"format",
"of",
"the",
"output",
"data",
".",
"See",
"utils",
".",
"input",
".",
"dataformats"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/datahandlers/formatters.py#L69-L77 |
37,780 | VikParuchuri/percept | percept/datahandlers/formatters.py | JSONFormat.from_csv | def from_csv(self, input_data):
"""
Reads csv format input data and converts to json.
"""
reformatted_data = []
for (i,row) in enumerate(input_data):
if i==0:
headers = row
else:
data_row = {}
for (j,h) in en... | python | def from_csv(self, input_data):
"""
Reads csv format input data and converts to json.
"""
reformatted_data = []
for (i,row) in enumerate(input_data):
if i==0:
headers = row
else:
data_row = {}
for (j,h) in en... | [
"def",
"from_csv",
"(",
"self",
",",
"input_data",
")",
":",
"reformatted_data",
"=",
"[",
"]",
"for",
"(",
"i",
",",
"row",
")",
"in",
"enumerate",
"(",
"input_data",
")",
":",
"if",
"i",
"==",
"0",
":",
"headers",
"=",
"row",
"else",
":",
"data_r... | Reads csv format input data and converts to json. | [
"Reads",
"csv",
"format",
"input",
"data",
"and",
"converts",
"to",
"json",
"."
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/datahandlers/formatters.py#L90-L103 |
37,781 | VikParuchuri/percept | percept/datahandlers/formatters.py | JSONFormat.to_dataframe | def to_dataframe(self):
"""
Reads the common format self.data and writes out to a dataframe.
"""
keys = self.data[0].keys()
column_list =[]
for k in keys:
key_list = []
for i in xrange(0,len(self.data)):
key_list.append(self.data[i]... | python | def to_dataframe(self):
"""
Reads the common format self.data and writes out to a dataframe.
"""
keys = self.data[0].keys()
column_list =[]
for k in keys:
key_list = []
for i in xrange(0,len(self.data)):
key_list.append(self.data[i]... | [
"def",
"to_dataframe",
"(",
"self",
")",
":",
"keys",
"=",
"self",
".",
"data",
"[",
"0",
"]",
".",
"keys",
"(",
")",
"column_list",
"=",
"[",
"]",
"for",
"k",
"in",
"keys",
":",
"key_list",
"=",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"0",
... | Reads the common format self.data and writes out to a dataframe. | [
"Reads",
"the",
"common",
"format",
"self",
".",
"data",
"and",
"writes",
"out",
"to",
"a",
"dataframe",
"."
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/datahandlers/formatters.py#L105-L120 |
37,782 | smarie/python-parsyfiles | parsyfiles/parsing_core_api.py | check_extensions | def check_extensions(extensions: Set[str], allow_multifile: bool = False):
"""
Utility method to check that all extensions in the provided set are valid
:param extensions:
:param allow_multifile:
:return:
"""
check_var(extensions, var_types=set, var_name='extensions')
# -- check them o... | python | def check_extensions(extensions: Set[str], allow_multifile: bool = False):
"""
Utility method to check that all extensions in the provided set are valid
:param extensions:
:param allow_multifile:
:return:
"""
check_var(extensions, var_types=set, var_name='extensions')
# -- check them o... | [
"def",
"check_extensions",
"(",
"extensions",
":",
"Set",
"[",
"str",
"]",
",",
"allow_multifile",
":",
"bool",
"=",
"False",
")",
":",
"check_var",
"(",
"extensions",
",",
"var_types",
"=",
"set",
",",
"var_name",
"=",
"'extensions'",
")",
"# -- check them ... | Utility method to check that all extensions in the provided set are valid
:param extensions:
:param allow_multifile:
:return: | [
"Utility",
"method",
"to",
"check",
"that",
"all",
"extensions",
"in",
"the",
"provided",
"set",
"are",
"valid"
] | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_core_api.py#L15-L27 |
37,783 | smarie/python-parsyfiles | parsyfiles/parsing_core_api.py | _BaseParserDeclarationForRegistries.are_worth_chaining | def are_worth_chaining(parser, to_type: Type[S], converter: Converter[S, T]) -> bool:
"""
Utility method to check if it makes sense to chain this parser with the given destination type, and the given
converter to create a parsing chain. Returns True if it brings value to chain them.
To ... | python | def are_worth_chaining(parser, to_type: Type[S], converter: Converter[S, T]) -> bool:
"""
Utility method to check if it makes sense to chain this parser with the given destination type, and the given
converter to create a parsing chain. Returns True if it brings value to chain them.
To ... | [
"def",
"are_worth_chaining",
"(",
"parser",
",",
"to_type",
":",
"Type",
"[",
"S",
"]",
",",
"converter",
":",
"Converter",
"[",
"S",
",",
"T",
"]",
")",
"->",
"bool",
":",
"if",
"not",
"parser",
".",
"can_chain",
":",
"# The base parser prevents chaining"... | Utility method to check if it makes sense to chain this parser with the given destination type, and the given
converter to create a parsing chain. Returns True if it brings value to chain them.
To bring value,
* the converter's output should not be a parent class of the parser's output. Otherwi... | [
"Utility",
"method",
"to",
"check",
"if",
"it",
"makes",
"sense",
"to",
"chain",
"this",
"parser",
"with",
"the",
"given",
"destination",
"type",
"and",
"the",
"given",
"converter",
"to",
"create",
"a",
"parsing",
"chain",
".",
"Returns",
"True",
"if",
"it... | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_core_api.py#L190-L224 |
37,784 | smarie/python-parsyfiles | parsyfiles/parsing_core_api.py | ParsingPlan._execute | def _execute(self, logger: Logger, options: Dict[str, Dict[str, Any]]) -> T:
"""
Implementing classes should perform the parsing here, possibly using custom methods of self.parser.
:param logger:
:param options:
:return:
"""
pass | python | def _execute(self, logger: Logger, options: Dict[str, Dict[str, Any]]) -> T:
"""
Implementing classes should perform the parsing here, possibly using custom methods of self.parser.
:param logger:
:param options:
:return:
"""
pass | [
"def",
"_execute",
"(",
"self",
",",
"logger",
":",
"Logger",
",",
"options",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
")",
"->",
"T",
":",
"pass"
] | Implementing classes should perform the parsing here, possibly using custom methods of self.parser.
:param logger:
:param options:
:return: | [
"Implementing",
"classes",
"should",
"perform",
"the",
"parsing",
"here",
"possibly",
"using",
"custom",
"methods",
"of",
"self",
".",
"parser",
"."
] | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_core_api.py#L420-L428 |
37,785 | smarie/python-parsyfiles | parsyfiles/parsing_core_api.py | Parser.create_parsing_plan | def create_parsing_plan(self, desired_type: Type[T], filesystem_object: PersistedObject, logger: Logger,
options: Dict[str, Dict[str, Any]]) -> ParsingPlan[T]:
"""
Creates a parsing plan to parse the given filesystem object into the given desired_type.
Implementing cl... | python | def create_parsing_plan(self, desired_type: Type[T], filesystem_object: PersistedObject, logger: Logger,
options: Dict[str, Dict[str, Any]]) -> ParsingPlan[T]:
"""
Creates a parsing plan to parse the given filesystem object into the given desired_type.
Implementing cl... | [
"def",
"create_parsing_plan",
"(",
"self",
",",
"desired_type",
":",
"Type",
"[",
"T",
"]",
",",
"filesystem_object",
":",
"PersistedObject",
",",
"logger",
":",
"Logger",
",",
"options",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Any",
"]",... | Creates a parsing plan to parse the given filesystem object into the given desired_type.
Implementing classes may wish to support additional parameters.
:param desired_type: the type of object that should be created as the output of parsing plan execution.
:param filesystem_object: the persiste... | [
"Creates",
"a",
"parsing",
"plan",
"to",
"parse",
"the",
"given",
"filesystem",
"object",
"into",
"the",
"given",
"desired_type",
".",
"Implementing",
"classes",
"may",
"wish",
"to",
"support",
"additional",
"parameters",
"."
] | 344b37e1151e8d4e7c2ee49ae09d6568715ae64e | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_core_api.py#L481-L495 |
37,786 | KvasirSecurity/kvasirapi-python | KvasirAPI/jsonrpc/hosts.py | Hosts.add | def add(self, f_ipaddr, f_macaddr, f_hostname, f_netbios_name, f_engineer, f_asset_group, f_confirmed):
"""
Add a t_hosts record
:param f_ipaddr: IP address
:param f_macaddr: MAC Address
:param f_hostname: Hostname
:param f_netbios_name: NetBIOS Name
:param f_eng... | python | def add(self, f_ipaddr, f_macaddr, f_hostname, f_netbios_name, f_engineer, f_asset_group, f_confirmed):
"""
Add a t_hosts record
:param f_ipaddr: IP address
:param f_macaddr: MAC Address
:param f_hostname: Hostname
:param f_netbios_name: NetBIOS Name
:param f_eng... | [
"def",
"add",
"(",
"self",
",",
"f_ipaddr",
",",
"f_macaddr",
",",
"f_hostname",
",",
"f_netbios_name",
",",
"f_engineer",
",",
"f_asset_group",
",",
"f_confirmed",
")",
":",
"return",
"self",
".",
"send",
".",
"host_add",
"(",
"f_ipaddr",
",",
"f_macaddr",
... | Add a t_hosts record
:param f_ipaddr: IP address
:param f_macaddr: MAC Address
:param f_hostname: Hostname
:param f_netbios_name: NetBIOS Name
:param f_engineer: Engineer username
:param f_asset_group: Asset group
:param f_confirmed: Confirmed boolean
:re... | [
"Add",
"a",
"t_hosts",
"record"
] | ec8c5818bd5913f3afd150f25eaec6e7cc732f4c | https://github.com/KvasirSecurity/kvasirapi-python/blob/ec8c5818bd5913f3afd150f25eaec6e7cc732f4c/KvasirAPI/jsonrpc/hosts.py#L28-L42 |
37,787 | polyledger/lattice | lattice/optimize.py | Allocator.retrieve_data | def retrieve_data(self):
"""
Retrives data as a DataFrame.
"""
#==== Retrieve data ====#
df = self.manager.get_historic_data(self.start.date(), self.end.date())
df.replace(0, np.nan, inplace=True)
return df | python | def retrieve_data(self):
"""
Retrives data as a DataFrame.
"""
#==== Retrieve data ====#
df = self.manager.get_historic_data(self.start.date(), self.end.date())
df.replace(0, np.nan, inplace=True)
return df | [
"def",
"retrieve_data",
"(",
"self",
")",
":",
"#==== Retrieve data ====#",
"df",
"=",
"self",
".",
"manager",
".",
"get_historic_data",
"(",
"self",
".",
"start",
".",
"date",
"(",
")",
",",
"self",
".",
"end",
".",
"date",
"(",
")",
")",
"df",
".",
... | Retrives data as a DataFrame. | [
"Retrives",
"data",
"as",
"a",
"DataFrame",
"."
] | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/optimize.py#L33-L42 |
37,788 | polyledger/lattice | lattice/optimize.py | Allocator.get_min_risk | def get_min_risk(self, weights, cov_matrix):
"""
Minimizes the variance of a portfolio.
"""
def func(weights):
"""The objective function that minimizes variance."""
return np.matmul(np.matmul(weights.transpose(), cov_matrix), weights)
def func_deriv(weig... | python | def get_min_risk(self, weights, cov_matrix):
"""
Minimizes the variance of a portfolio.
"""
def func(weights):
"""The objective function that minimizes variance."""
return np.matmul(np.matmul(weights.transpose(), cov_matrix), weights)
def func_deriv(weig... | [
"def",
"get_min_risk",
"(",
"self",
",",
"weights",
",",
"cov_matrix",
")",
":",
"def",
"func",
"(",
"weights",
")",
":",
"\"\"\"The objective function that minimizes variance.\"\"\"",
"return",
"np",
".",
"matmul",
"(",
"np",
".",
"matmul",
"(",
"weights",
".",... | Minimizes the variance of a portfolio. | [
"Minimizes",
"the",
"variance",
"of",
"a",
"portfolio",
"."
] | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/optimize.py#L44-L66 |
37,789 | polyledger/lattice | lattice/optimize.py | Allocator.get_max_return | def get_max_return(self, weights, returns):
"""
Maximizes the returns of a portfolio.
"""
def func(weights):
"""The objective function that maximizes returns."""
return np.dot(weights, returns.values) * -1
constraints = ({'type': 'eq', 'fun': lambda weig... | python | def get_max_return(self, weights, returns):
"""
Maximizes the returns of a portfolio.
"""
def func(weights):
"""The objective function that maximizes returns."""
return np.dot(weights, returns.values) * -1
constraints = ({'type': 'eq', 'fun': lambda weig... | [
"def",
"get_max_return",
"(",
"self",
",",
"weights",
",",
"returns",
")",
":",
"def",
"func",
"(",
"weights",
")",
":",
"\"\"\"The objective function that maximizes returns.\"\"\"",
"return",
"np",
".",
"dot",
"(",
"weights",
",",
"returns",
".",
"values",
")",... | Maximizes the returns of a portfolio. | [
"Maximizes",
"the",
"returns",
"of",
"a",
"portfolio",
"."
] | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/optimize.py#L68-L87 |
37,790 | polyledger/lattice | lattice/optimize.py | Allocator.efficient_frontier | def efficient_frontier(
self,
returns,
cov_matrix,
min_return,
max_return,
count
):
"""
Returns a DataFrame of efficient portfolio allocations for `count` risk
indices.
"""
columns = [coin for coin in self.SUPPORTED_COINS]
... | python | def efficient_frontier(
self,
returns,
cov_matrix,
min_return,
max_return,
count
):
"""
Returns a DataFrame of efficient portfolio allocations for `count` risk
indices.
"""
columns = [coin for coin in self.SUPPORTED_COINS]
... | [
"def",
"efficient_frontier",
"(",
"self",
",",
"returns",
",",
"cov_matrix",
",",
"min_return",
",",
"max_return",
",",
"count",
")",
":",
"columns",
"=",
"[",
"coin",
"for",
"coin",
"in",
"self",
".",
"SUPPORTED_COINS",
"]",
"# columns.append('Return')",
"# c... | Returns a DataFrame of efficient portfolio allocations for `count` risk
indices. | [
"Returns",
"a",
"DataFrame",
"of",
"efficient",
"portfolio",
"allocations",
"for",
"count",
"risk",
"indices",
"."
] | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/optimize.py#L89-L139 |
37,791 | polyledger/lattice | lattice/optimize.py | Allocator.solve_minimize | def solve_minimize(
self,
func,
weights,
constraints,
lower_bound=0.0,
upper_bound=1.0,
func_deriv=False
):
"""
Returns the solution to a minimization problem.
"""
bounds = ((lower_bound, upper_bound), ) * len(self.SUPPORTED_CO... | python | def solve_minimize(
self,
func,
weights,
constraints,
lower_bound=0.0,
upper_bound=1.0,
func_deriv=False
):
"""
Returns the solution to a minimization problem.
"""
bounds = ((lower_bound, upper_bound), ) * len(self.SUPPORTED_CO... | [
"def",
"solve_minimize",
"(",
"self",
",",
"func",
",",
"weights",
",",
"constraints",
",",
"lower_bound",
"=",
"0.0",
",",
"upper_bound",
"=",
"1.0",
",",
"func_deriv",
"=",
"False",
")",
":",
"bounds",
"=",
"(",
"(",
"lower_bound",
",",
"upper_bound",
... | Returns the solution to a minimization problem. | [
"Returns",
"the",
"solution",
"to",
"a",
"minimization",
"problem",
"."
] | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/optimize.py#L141-L158 |
37,792 | polyledger/lattice | lattice/optimize.py | Allocator.allocate | def allocate(self):
"""
Returns an efficient portfolio allocation for the given risk index.
"""
df = self.manager.get_historic_data()[self.SUPPORTED_COINS]
#==== Calculate the daily changes ====#
change_columns = []
for column in df:
if column in self... | python | def allocate(self):
"""
Returns an efficient portfolio allocation for the given risk index.
"""
df = self.manager.get_historic_data()[self.SUPPORTED_COINS]
#==== Calculate the daily changes ====#
change_columns = []
for column in df:
if column in self... | [
"def",
"allocate",
"(",
"self",
")",
":",
"df",
"=",
"self",
".",
"manager",
".",
"get_historic_data",
"(",
")",
"[",
"self",
".",
"SUPPORTED_COINS",
"]",
"#==== Calculate the daily changes ====#",
"change_columns",
"=",
"[",
"]",
"for",
"column",
"in",
"df",
... | Returns an efficient portfolio allocation for the given risk index. | [
"Returns",
"an",
"efficient",
"portfolio",
"allocation",
"for",
"the",
"given",
"risk",
"index",
"."
] | d68d27c93b1634ee29f5c1a1dbcd67397481323b | https://github.com/polyledger/lattice/blob/d68d27c93b1634ee29f5c1a1dbcd67397481323b/lattice/optimize.py#L160-L206 |
37,793 | VikParuchuri/percept | percept/management/commands.py | handle_default_options | def handle_default_options(options):
"""
Pass in a Values instance from OptionParser. Handle settings and pythonpath
options - Values from OptionParser
"""
if options.settings:
#Set the percept_settings_module (picked up by settings in conf.base)
os.environ['PERCEPT_SETTINGS_MODULE'... | python | def handle_default_options(options):
"""
Pass in a Values instance from OptionParser. Handle settings and pythonpath
options - Values from OptionParser
"""
if options.settings:
#Set the percept_settings_module (picked up by settings in conf.base)
os.environ['PERCEPT_SETTINGS_MODULE'... | [
"def",
"handle_default_options",
"(",
"options",
")",
":",
"if",
"options",
".",
"settings",
":",
"#Set the percept_settings_module (picked up by settings in conf.base)",
"os",
".",
"environ",
"[",
"'PERCEPT_SETTINGS_MODULE'",
"]",
"=",
"options",
".",
"settings",
"if",
... | Pass in a Values instance from OptionParser. Handle settings and pythonpath
options - Values from OptionParser | [
"Pass",
"in",
"a",
"Values",
"instance",
"from",
"OptionParser",
".",
"Handle",
"settings",
"and",
"pythonpath",
"options",
"-",
"Values",
"from",
"OptionParser"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/management/commands.py#L11-L26 |
37,794 | VikParuchuri/percept | percept/management/commands.py | BaseCommand.create_parser | def create_parser(self, prog_name, subcommand):
"""
Create an OptionParser
prog_name - Name of a command
subcommand - Name of a subcommand
"""
parser = OptionParser(prog=prog_name,
usage=self.usage(subcommand),
o... | python | def create_parser(self, prog_name, subcommand):
"""
Create an OptionParser
prog_name - Name of a command
subcommand - Name of a subcommand
"""
parser = OptionParser(prog=prog_name,
usage=self.usage(subcommand),
o... | [
"def",
"create_parser",
"(",
"self",
",",
"prog_name",
",",
"subcommand",
")",
":",
"parser",
"=",
"OptionParser",
"(",
"prog",
"=",
"prog_name",
",",
"usage",
"=",
"self",
".",
"usage",
"(",
"subcommand",
")",
",",
"option_list",
"=",
"self",
".",
"opti... | Create an OptionParser
prog_name - Name of a command
subcommand - Name of a subcommand | [
"Create",
"an",
"OptionParser",
"prog_name",
"-",
"Name",
"of",
"a",
"command",
"subcommand",
"-",
"Name",
"of",
"a",
"subcommand"
] | 90304ba82053e2a9ad2bacaab3479403d3923bcf | https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/management/commands.py#L49-L58 |
37,795 | frascoweb/frasco | frasco/decorators.py | hook | def hook(name=None, *args, **kwargs):
"""Decorator to register the function as a hook
"""
def decorator(f):
if not hasattr(f, "hooks"):
f.hooks = []
f.hooks.append((name or f.__name__, args, kwargs))
return f
return decorator | python | def hook(name=None, *args, **kwargs):
"""Decorator to register the function as a hook
"""
def decorator(f):
if not hasattr(f, "hooks"):
f.hooks = []
f.hooks.append((name or f.__name__, args, kwargs))
return f
return decorator | [
"def",
"hook",
"(",
"name",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"if",
"not",
"hasattr",
"(",
"f",
",",
"\"hooks\"",
")",
":",
"f",
".",
"hooks",
"=",
"[",
"]",
"f",
".",
... | Decorator to register the function as a hook | [
"Decorator",
"to",
"register",
"the",
"function",
"as",
"a",
"hook"
] | ea519d69dd5ca6deaf3650175692ee4a1a02518f | https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/decorators.py#L10-L18 |
37,796 | frascoweb/frasco | frasco/decorators.py | expose | def expose(rule, **options):
"""Decorator to add an url rule to a function
"""
def decorator(f):
if not hasattr(f, "urls"):
f.urls = []
if isinstance(rule, (list, tuple)):
f.urls.extend(rule)
else:
f.urls.append((rule, options))
return f
... | python | def expose(rule, **options):
"""Decorator to add an url rule to a function
"""
def decorator(f):
if not hasattr(f, "urls"):
f.urls = []
if isinstance(rule, (list, tuple)):
f.urls.extend(rule)
else:
f.urls.append((rule, options))
return f
... | [
"def",
"expose",
"(",
"rule",
",",
"*",
"*",
"options",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"if",
"not",
"hasattr",
"(",
"f",
",",
"\"urls\"",
")",
":",
"f",
".",
"urls",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"rule",
",",
"(",
... | Decorator to add an url rule to a function | [
"Decorator",
"to",
"add",
"an",
"url",
"rule",
"to",
"a",
"function"
] | ea519d69dd5ca6deaf3650175692ee4a1a02518f | https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/decorators.py#L101-L112 |
37,797 | matgrioni/betacode | betacode/conv.py | _create_unicode_map | def _create_unicode_map():
"""
Create the inverse map from unicode to betacode.
Returns:
The hash map to convert unicode characters to the beta code representation.
"""
unicode_map = {}
for beta, uni in _map.BETACODE_MAP.items():
# Include decomposed equivalent where necessary.
... | python | def _create_unicode_map():
"""
Create the inverse map from unicode to betacode.
Returns:
The hash map to convert unicode characters to the beta code representation.
"""
unicode_map = {}
for beta, uni in _map.BETACODE_MAP.items():
# Include decomposed equivalent where necessary.
... | [
"def",
"_create_unicode_map",
"(",
")",
":",
"unicode_map",
"=",
"{",
"}",
"for",
"beta",
",",
"uni",
"in",
"_map",
".",
"BETACODE_MAP",
".",
"items",
"(",
")",
":",
"# Include decomposed equivalent where necessary.",
"norm",
"=",
"unicodedata",
".",
"normalize"... | Create the inverse map from unicode to betacode.
Returns:
The hash map to convert unicode characters to the beta code representation. | [
"Create",
"the",
"inverse",
"map",
"from",
"unicode",
"to",
"betacode",
"."
] | 2f8b439c0de9cdf451b0b390161752cac9879137 | https://github.com/matgrioni/betacode/blob/2f8b439c0de9cdf451b0b390161752cac9879137/betacode/conv.py#L17-L37 |
37,798 | matgrioni/betacode | betacode/conv.py | _create_conversion_trie | def _create_conversion_trie(strict):
"""
Create the trie for betacode conversion.
Args:
text: The beta code text to convert. All of this text must be betacode.
strict: Flag to allow for flexible diacritic order on input.
Returns:
The trie for conversion.
"""
t = pygtrie.CharTrie()
... | python | def _create_conversion_trie(strict):
"""
Create the trie for betacode conversion.
Args:
text: The beta code text to convert. All of this text must be betacode.
strict: Flag to allow for flexible diacritic order on input.
Returns:
The trie for conversion.
"""
t = pygtrie.CharTrie()
... | [
"def",
"_create_conversion_trie",
"(",
"strict",
")",
":",
"t",
"=",
"pygtrie",
".",
"CharTrie",
"(",
")",
"for",
"beta",
",",
"uni",
"in",
"_map",
".",
"BETACODE_MAP",
".",
"items",
"(",
")",
":",
"if",
"strict",
":",
"t",
"[",
"beta",
"]",
"=",
"... | Create the trie for betacode conversion.
Args:
text: The beta code text to convert. All of this text must be betacode.
strict: Flag to allow for flexible diacritic order on input.
Returns:
The trie for conversion. | [
"Create",
"the",
"trie",
"for",
"betacode",
"conversion",
"."
] | 2f8b439c0de9cdf451b0b390161752cac9879137 | https://github.com/matgrioni/betacode/blob/2f8b439c0de9cdf451b0b390161752cac9879137/betacode/conv.py#L42-L71 |
37,799 | matgrioni/betacode | betacode/conv.py | _find_max_beta_token_len | def _find_max_beta_token_len():
"""
Finds the maximum length of a single betacode token.
Returns:
The length of the longest key in the betacode map, which corresponds to the
longest single betacode token.
"""
max_beta_len = -1
for beta, uni in _map.BETACODE_MAP.items():
if len(b... | python | def _find_max_beta_token_len():
"""
Finds the maximum length of a single betacode token.
Returns:
The length of the longest key in the betacode map, which corresponds to the
longest single betacode token.
"""
max_beta_len = -1
for beta, uni in _map.BETACODE_MAP.items():
if len(b... | [
"def",
"_find_max_beta_token_len",
"(",
")",
":",
"max_beta_len",
"=",
"-",
"1",
"for",
"beta",
",",
"uni",
"in",
"_map",
".",
"BETACODE_MAP",
".",
"items",
"(",
")",
":",
"if",
"len",
"(",
"beta",
")",
">",
"max_beta_len",
":",
"max_beta_len",
"=",
"l... | Finds the maximum length of a single betacode token.
Returns:
The length of the longest key in the betacode map, which corresponds to the
longest single betacode token. | [
"Finds",
"the",
"maximum",
"length",
"of",
"a",
"single",
"betacode",
"token",
"."
] | 2f8b439c0de9cdf451b0b390161752cac9879137 | https://github.com/matgrioni/betacode/blob/2f8b439c0de9cdf451b0b390161752cac9879137/betacode/conv.py#L74-L87 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.