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,900
VikParuchuri/percept
percept/utils/registry.py
import_task_modules
def import_task_modules(): """ Import all installed apps and add modules to registry """ top_level_modules = settings.INSTALLED_APPS module_names = [] for module in top_level_modules: #Import package mod = import_module(module) #Find all modules in package path fo...
python
def import_task_modules(): """ Import all installed apps and add modules to registry """ top_level_modules = settings.INSTALLED_APPS module_names = [] for module in top_level_modules: #Import package mod = import_module(module) #Find all modules in package path fo...
[ "def", "import_task_modules", "(", ")", ":", "top_level_modules", "=", "settings", ".", "INSTALLED_APPS", "module_names", "=", "[", "]", "for", "module", "in", "top_level_modules", ":", "#Import package", "mod", "=", "import_module", "(", "module", ")", "#Find all...
Import all installed apps and add modules to registry
[ "Import", "all", "installed", "apps", "and", "add", "modules", "to", "registry" ]
90304ba82053e2a9ad2bacaab3479403d3923bcf
https://github.com/VikParuchuri/percept/blob/90304ba82053e2a9ad2bacaab3479403d3923bcf/percept/utils/registry.py#L12-L29
37,901
KvasirSecurity/kvasirapi-python
KvasirAPI/jsonrpc/services.py
Services.list
def list(self, service_rec=None, host_rec=None, hostfilter=None): """ List a specific service or all services :param service_rec: t_services.id :param host_rec: t_hosts.id :param hostfilter: Valid hostfilter or None :return: [(svc.t_services.id, svc.t_services.f_hosts_id...
python
def list(self, service_rec=None, host_rec=None, hostfilter=None): """ List a specific service or all services :param service_rec: t_services.id :param host_rec: t_hosts.id :param hostfilter: Valid hostfilter or None :return: [(svc.t_services.id, svc.t_services.f_hosts_id...
[ "def", "list", "(", "self", ",", "service_rec", "=", "None", ",", "host_rec", "=", "None", ",", "hostfilter", "=", "None", ")", ":", "return", "self", ".", "send", ".", "service_list", "(", "service_rec", ",", "host_rec", ",", "hostfilter", ")" ]
List a specific service or all services :param service_rec: t_services.id :param host_rec: t_hosts.id :param hostfilter: Valid hostfilter or None :return: [(svc.t_services.id, svc.t_services.f_hosts_id, svc.t_hosts.f_ipaddr, svc.t_hosts.f_hostname, svc.t_services.f_proto, ...
[ "List", "a", "specific", "service", "or", "all", "services" ]
ec8c5818bd5913f3afd150f25eaec6e7cc732f4c
https://github.com/KvasirSecurity/kvasirapi-python/blob/ec8c5818bd5913f3afd150f25eaec6e7cc732f4c/KvasirAPI/jsonrpc/services.py#L20-L32
37,902
KvasirSecurity/kvasirapi-python
KvasirAPI/jsonrpc/services.py
Services.info
def info(self, svc_rec=None, ipaddr=None, proto=None, port=None): """ Information about a service. :param svc_rec: t_services.id :param ipaddr: IP Address :param proto: Protocol (tcp, udp, info) :param port: Port (0-65535) :return: [ service_id, host_id, ipv4, ip...
python
def info(self, svc_rec=None, ipaddr=None, proto=None, port=None): """ Information about a service. :param svc_rec: t_services.id :param ipaddr: IP Address :param proto: Protocol (tcp, udp, info) :param port: Port (0-65535) :return: [ service_id, host_id, ipv4, ip...
[ "def", "info", "(", "self", ",", "svc_rec", "=", "None", ",", "ipaddr", "=", "None", ",", "proto", "=", "None", ",", "port", "=", "None", ")", ":", "return", "self", ".", "send", ".", "service_info", "(", "svc_rec", ",", "ipaddr", ",", "proto", ","...
Information about a service. :param svc_rec: t_services.id :param ipaddr: IP Address :param proto: Protocol (tcp, udp, info) :param port: Port (0-65535) :return: [ service_id, host_id, ipv4, ipv6, hostname, proto, number, status, name, banner ]
[ "Information", "about", "a", "service", "." ]
ec8c5818bd5913f3afd150f25eaec6e7cc732f4c
https://github.com/KvasirSecurity/kvasirapi-python/blob/ec8c5818bd5913f3afd150f25eaec6e7cc732f4c/KvasirAPI/jsonrpc/services.py#L44-L54
37,903
KvasirSecurity/kvasirapi-python
KvasirAPI/jsonrpc/services.py
Services.add
def add(self, ipaddr=None, proto=None, port=None, fields=None): """ Add a service record :param ipaddr: IP Address :param proto: Protocol (tcp, udp, info) :param port: Port (0-65535) :param fields: Extra fields :return: (True/False, t_services.id or response mess...
python
def add(self, ipaddr=None, proto=None, port=None, fields=None): """ Add a service record :param ipaddr: IP Address :param proto: Protocol (tcp, udp, info) :param port: Port (0-65535) :param fields: Extra fields :return: (True/False, t_services.id or response mess...
[ "def", "add", "(", "self", ",", "ipaddr", "=", "None", ",", "proto", "=", "None", ",", "port", "=", "None", ",", "fields", "=", "None", ")", ":", "return", "self", ".", "send", ".", "service_add", "(", "ipaddr", ",", "proto", ",", "port", ",", "f...
Add a service record :param ipaddr: IP Address :param proto: Protocol (tcp, udp, info) :param port: Port (0-65535) :param fields: Extra fields :return: (True/False, t_services.id or response message)
[ "Add", "a", "service", "record" ]
ec8c5818bd5913f3afd150f25eaec6e7cc732f4c
https://github.com/KvasirSecurity/kvasirapi-python/blob/ec8c5818bd5913f3afd150f25eaec6e7cc732f4c/KvasirAPI/jsonrpc/services.py#L56-L66
37,904
KvasirSecurity/kvasirapi-python
KvasirAPI/jsonrpc/services.py
Services.delete
def delete(self, svc_rec=None, ipaddr=None, proto=None, port=None): """ Delete a t_services record :param svc_rec: t_services.id :param ipaddr: IP Address or t_hosts.id :param proto: Protocol (tcp, udp, info) :param port: Port (0-65535) :return: [True, Response M...
python
def delete(self, svc_rec=None, ipaddr=None, proto=None, port=None): """ Delete a t_services record :param svc_rec: t_services.id :param ipaddr: IP Address or t_hosts.id :param proto: Protocol (tcp, udp, info) :param port: Port (0-65535) :return: [True, Response M...
[ "def", "delete", "(", "self", ",", "svc_rec", "=", "None", ",", "ipaddr", "=", "None", ",", "proto", "=", "None", ",", "port", "=", "None", ")", ":", "return", "self", ".", "send", ".", "service_del", "(", "svc_rec", ",", "ipaddr", ",", "proto", ",...
Delete a t_services record :param svc_rec: t_services.id :param ipaddr: IP Address or t_hosts.id :param proto: Protocol (tcp, udp, info) :param port: Port (0-65535) :return: [True, Response Message]
[ "Delete", "a", "t_services", "record" ]
ec8c5818bd5913f3afd150f25eaec6e7cc732f4c
https://github.com/KvasirSecurity/kvasirapi-python/blob/ec8c5818bd5913f3afd150f25eaec6e7cc732f4c/KvasirAPI/jsonrpc/services.py#L68-L78
37,905
KvasirSecurity/kvasirapi-python
KvasirAPI/jsonrpc/services.py
Services.vulns_list
def vulns_list(self, service_id=None, service_port=None, hostfilter=None): """ List of vulnerabilities for a service :param service_id: t_services.id :param service_port: tcp/#, udp/# or info/# :param hostfilter: Valid hostfilter or None :return: t_services.rows.as_list(...
python
def vulns_list(self, service_id=None, service_port=None, hostfilter=None): """ List of vulnerabilities for a service :param service_id: t_services.id :param service_port: tcp/#, udp/# or info/# :param hostfilter: Valid hostfilter or None :return: t_services.rows.as_list(...
[ "def", "vulns_list", "(", "self", ",", "service_id", "=", "None", ",", "service_port", "=", "None", ",", "hostfilter", "=", "None", ")", ":", "return", "self", ".", "send", ".", "service_vulns_list", "(", "service_id", ",", "service_port", ",", "hostfilter",...
List of vulnerabilities for a service :param service_id: t_services.id :param service_port: tcp/#, udp/# or info/# :param hostfilter: Valid hostfilter or None :return: t_services.rows.as_list()
[ "List", "of", "vulnerabilities", "for", "a", "service" ]
ec8c5818bd5913f3afd150f25eaec6e7cc732f4c
https://github.com/KvasirSecurity/kvasirapi-python/blob/ec8c5818bd5913f3afd150f25eaec6e7cc732f4c/KvasirAPI/jsonrpc/services.py#L101-L110
37,906
Nagasaki45/fluteline
fluteline/utils.py
connect
def connect(nodes): ''' Connect a list of nodes. Connected nodes have an ``output`` member which is the following node in the line. The last node's ``output`` is a :class:`Queue` for easy plumbing. ''' for a, b in zip(nodes[:-1], nodes[1:]): a.output = b b.output = queues.Queue(...
python
def connect(nodes): ''' Connect a list of nodes. Connected nodes have an ``output`` member which is the following node in the line. The last node's ``output`` is a :class:`Queue` for easy plumbing. ''' for a, b in zip(nodes[:-1], nodes[1:]): a.output = b b.output = queues.Queue(...
[ "def", "connect", "(", "nodes", ")", ":", "for", "a", ",", "b", "in", "zip", "(", "nodes", "[", ":", "-", "1", "]", ",", "nodes", "[", "1", ":", "]", ")", ":", "a", ".", "output", "=", "b", "b", ".", "output", "=", "queues", ".", "Queue", ...
Connect a list of nodes. Connected nodes have an ``output`` member which is the following node in the line. The last node's ``output`` is a :class:`Queue` for easy plumbing.
[ "Connect", "a", "list", "of", "nodes", "." ]
c4d238aa9711abfe8c7e94bb0dd4e170d0f48601
https://github.com/Nagasaki45/fluteline/blob/c4d238aa9711abfe8c7e94bb0dd4e170d0f48601/fluteline/utils.py#L5-L15
37,907
frascoweb/frasco
frasco/templating/__init__.py
render_layout
def render_layout(layout_name, content, **context): """Uses a jinja template to wrap the content inside a layout. Wraps the content inside a block and adds the extend statement before rendering it with jinja. The block name can be specified in the layout_name after the filename separated by a colon. The...
python
def render_layout(layout_name, content, **context): """Uses a jinja template to wrap the content inside a layout. Wraps the content inside a block and adds the extend statement before rendering it with jinja. The block name can be specified in the layout_name after the filename separated by a colon. The...
[ "def", "render_layout", "(", "layout_name", ",", "content", ",", "*", "*", "context", ")", ":", "layout_block", "=", "\"content\"", "if", "\":\"", "in", "layout_name", ":", "layout_name", ",", "layout_block", "=", "layout_name", ".", "split", "(", "\":\"", "...
Uses a jinja template to wrap the content inside a layout. Wraps the content inside a block and adds the extend statement before rendering it with jinja. The block name can be specified in the layout_name after the filename separated by a colon. The default block name is "content".
[ "Uses", "a", "jinja", "template", "to", "wrap", "the", "content", "inside", "a", "layout", ".", "Wraps", "the", "content", "inside", "a", "block", "and", "adds", "the", "extend", "statement", "before", "rendering", "it", "with", "jinja", ".", "The", "block...
ea519d69dd5ca6deaf3650175692ee4a1a02518f
https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/templating/__init__.py#L174-L184
37,908
frascoweb/frasco
frasco/templating/__init__.py
parse_template
def parse_template(app, filename): """Parses the given template using the jinja environment of the given app and returns the AST. ASTs are cached in parse_template.cache """ if not hasattr(parse_template, "cache"): parse_template.cache = {} if filename not in parse_template.cache: so...
python
def parse_template(app, filename): """Parses the given template using the jinja environment of the given app and returns the AST. ASTs are cached in parse_template.cache """ if not hasattr(parse_template, "cache"): parse_template.cache = {} if filename not in parse_template.cache: so...
[ "def", "parse_template", "(", "app", ",", "filename", ")", ":", "if", "not", "hasattr", "(", "parse_template", ",", "\"cache\"", ")", ":", "parse_template", ".", "cache", "=", "{", "}", "if", "filename", "not", "in", "parse_template", ".", "cache", ":", ...
Parses the given template using the jinja environment of the given app and returns the AST. ASTs are cached in parse_template.cache
[ "Parses", "the", "given", "template", "using", "the", "jinja", "environment", "of", "the", "given", "app", "and", "returns", "the", "AST", ".", "ASTs", "are", "cached", "in", "parse_template", ".", "cache" ]
ea519d69dd5ca6deaf3650175692ee4a1a02518f
https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/templating/__init__.py#L192-L201
37,909
frascoweb/frasco
frasco/templating/__init__.py
jinja_node_to_python
def jinja_node_to_python(node): """Converts a Jinja2 node to its python equivalent """ if isinstance(node, nodes.Const): return node.value if isinstance(node, nodes.Neg): return -jinja_node_to_python(node.node) if isinstance(node, nodes.Name): return node.name if isinstan...
python
def jinja_node_to_python(node): """Converts a Jinja2 node to its python equivalent """ if isinstance(node, nodes.Const): return node.value if isinstance(node, nodes.Neg): return -jinja_node_to_python(node.node) if isinstance(node, nodes.Name): return node.name if isinstan...
[ "def", "jinja_node_to_python", "(", "node", ")", ":", "if", "isinstance", "(", "node", ",", "nodes", ".", "Const", ")", ":", "return", "node", ".", "value", "if", "isinstance", "(", "node", ",", "nodes", ".", "Neg", ")", ":", "return", "-", "jinja_node...
Converts a Jinja2 node to its python equivalent
[ "Converts", "a", "Jinja2", "node", "to", "its", "python", "equivalent" ]
ea519d69dd5ca6deaf3650175692ee4a1a02518f
https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/templating/__init__.py#L204-L227
37,910
liam-middlebrook/csh_ldap
csh_ldap/member.py
CSHMember.in_group
def in_group(self, group, dn=False): """Get whether or not the bound CSH LDAP member object is part of a group. Arguments: group -- the CSHGroup object (or distinguished name) of the group to check membership for """ if dn: return group in se...
python
def in_group(self, group, dn=False): """Get whether or not the bound CSH LDAP member object is part of a group. Arguments: group -- the CSHGroup object (or distinguished name) of the group to check membership for """ if dn: return group in se...
[ "def", "in_group", "(", "self", ",", "group", ",", "dn", "=", "False", ")", ":", "if", "dn", ":", "return", "group", "in", "self", ".", "groups", "(", ")", "return", "group", ".", "check_member", "(", "self", ")" ]
Get whether or not the bound CSH LDAP member object is part of a group. Arguments: group -- the CSHGroup object (or distinguished name) of the group to check membership for
[ "Get", "whether", "or", "not", "the", "bound", "CSH", "LDAP", "member", "object", "is", "part", "of", "a", "group", "." ]
90bd334a20e13c03af07bce4f104ad96baf620e4
https://github.com/liam-middlebrook/csh_ldap/blob/90bd334a20e13c03af07bce4f104ad96baf620e4/csh_ldap/member.py#L59-L69
37,911
wheeler-microfluidics/dmf-control-board-firmware
dmf_control_board_firmware/__init__.py
savgol_filter
def savgol_filter(x, window_length, polyorder, deriv=0, delta=1.0, axis=-1, mode='interp', cval=0.0): ''' Wrapper for the scipy.signal.savgol_filter function that handles Nan values. See: https://github.com/wheeler-microfluidics/dmf-control-board-firmware/issues/3 Returns ------- y : ndarray, ...
python
def savgol_filter(x, window_length, polyorder, deriv=0, delta=1.0, axis=-1, mode='interp', cval=0.0): ''' Wrapper for the scipy.signal.savgol_filter function that handles Nan values. See: https://github.com/wheeler-microfluidics/dmf-control-board-firmware/issues/3 Returns ------- y : ndarray, ...
[ "def", "savgol_filter", "(", "x", ",", "window_length", ",", "polyorder", ",", "deriv", "=", "0", ",", "delta", "=", "1.0", ",", "axis", "=", "-", "1", ",", "mode", "=", "'interp'", ",", "cval", "=", "0.0", ")", ":", "# linearly interpolate missing value...
Wrapper for the scipy.signal.savgol_filter function that handles Nan values. See: https://github.com/wheeler-microfluidics/dmf-control-board-firmware/issues/3 Returns ------- y : ndarray, same shape as `x` The filtered data.
[ "Wrapper", "for", "the", "scipy", ".", "signal", ".", "savgol_filter", "function", "that", "handles", "Nan", "values", "." ]
1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c
https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L50-L72
37,912
wheeler-microfluidics/dmf-control-board-firmware
dmf_control_board_firmware/__init__.py
feedback_results_to_measurements_frame
def feedback_results_to_measurements_frame(feedback_result): ''' Extract measured data from `FeedbackResults` instance into `pandas.DataFrame`. ''' index = pd.Index(feedback_result.time * 1e-3, name='seconds') df_feedback = pd.DataFrame(np.column_stack([feedback_result.V_fb, ...
python
def feedback_results_to_measurements_frame(feedback_result): ''' Extract measured data from `FeedbackResults` instance into `pandas.DataFrame`. ''' index = pd.Index(feedback_result.time * 1e-3, name='seconds') df_feedback = pd.DataFrame(np.column_stack([feedback_result.V_fb, ...
[ "def", "feedback_results_to_measurements_frame", "(", "feedback_result", ")", ":", "index", "=", "pd", ".", "Index", "(", "feedback_result", ".", "time", "*", "1e-3", ",", "name", "=", "'seconds'", ")", "df_feedback", "=", "pd", ".", "DataFrame", "(", "np", ...
Extract measured data from `FeedbackResults` instance into `pandas.DataFrame`.
[ "Extract", "measured", "data", "from", "FeedbackResults", "instance", "into", "pandas", ".", "DataFrame", "." ]
1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c
https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L158-L172
37,913
wheeler-microfluidics/dmf-control-board-firmware
dmf_control_board_firmware/__init__.py
feedback_results_to_impedance_frame
def feedback_results_to_impedance_frame(feedback_result): ''' Extract computed impedance data from `FeedbackResults` instance into `pandas.DataFrame`. ''' index = pd.Index(feedback_result.time * 1e-3, name='seconds') df_feedback = pd.DataFrame(np.column_stack([feedback_result.V_actuation() ...
python
def feedback_results_to_impedance_frame(feedback_result): ''' Extract computed impedance data from `FeedbackResults` instance into `pandas.DataFrame`. ''' index = pd.Index(feedback_result.time * 1e-3, name='seconds') df_feedback = pd.DataFrame(np.column_stack([feedback_result.V_actuation() ...
[ "def", "feedback_results_to_impedance_frame", "(", "feedback_result", ")", ":", "index", "=", "pd", ".", "Index", "(", "feedback_result", ".", "time", "*", "1e-3", ",", "name", "=", "'seconds'", ")", "df_feedback", "=", "pd", ".", "DataFrame", "(", "np", "."...
Extract computed impedance data from `FeedbackResults` instance into `pandas.DataFrame`.
[ "Extract", "computed", "impedance", "data", "from", "FeedbackResults", "instance", "into", "pandas", ".", "DataFrame", "." ]
1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c
https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L175-L192
37,914
wheeler-microfluidics/dmf-control-board-firmware
dmf_control_board_firmware/__init__.py
get_firmwares
def get_firmwares(): ''' Return `dmf_control_board` compiled Arduino hex file paths. This function may be used to locate firmware binaries that are available for flashing to [Arduino Mega2560][1] boards. [1]: http://arduino.cc/en/Main/arduinoBoardMega2560 ''' return OrderedDict([(board_dir...
python
def get_firmwares(): ''' Return `dmf_control_board` compiled Arduino hex file paths. This function may be used to locate firmware binaries that are available for flashing to [Arduino Mega2560][1] boards. [1]: http://arduino.cc/en/Main/arduinoBoardMega2560 ''' return OrderedDict([(board_dir...
[ "def", "get_firmwares", "(", ")", ":", "return", "OrderedDict", "(", "[", "(", "board_dir", ".", "name", ",", "[", "f", ".", "abspath", "(", ")", "for", "f", "in", "board_dir", ".", "walkfiles", "(", "'*.hex'", ")", "]", ")", "for", "board_dir", "in"...
Return `dmf_control_board` compiled Arduino hex file paths. This function may be used to locate firmware binaries that are available for flashing to [Arduino Mega2560][1] boards. [1]: http://arduino.cc/en/Main/arduinoBoardMega2560
[ "Return", "dmf_control_board", "compiled", "Arduino", "hex", "file", "paths", "." ]
1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c
https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L227-L239
37,915
wheeler-microfluidics/dmf-control-board-firmware
dmf_control_board_firmware/__init__.py
remote_command
def remote_command(function, self, *args, **kwargs): ''' Catch `RuntimeError` exceptions raised by remote control board firmware commands and re-raise as more specific `FirmwareError` exception type, which includes command code and return code. ''' try: return function(self, *args, **kwa...
python
def remote_command(function, self, *args, **kwargs): ''' Catch `RuntimeError` exceptions raised by remote control board firmware commands and re-raise as more specific `FirmwareError` exception type, which includes command code and return code. ''' try: return function(self, *args, **kwa...
[ "def", "remote_command", "(", "function", ",", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "function", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", "except", "RuntimeError", ",", "exception", ":"...
Catch `RuntimeError` exceptions raised by remote control board firmware commands and re-raise as more specific `FirmwareError` exception type, which includes command code and return code.
[ "Catch", "RuntimeError", "exceptions", "raised", "by", "remote", "control", "board", "firmware", "commands", "and", "re", "-", "raise", "as", "more", "specific", "FirmwareError", "exception", "type", "which", "includes", "command", "code", "and", "return", "code",...
1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c
https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L1117-L1143
37,916
wheeler-microfluidics/dmf-control-board-firmware
dmf_control_board_firmware/__init__.py
FeedbackResults.to_frame
def to_frame(self, filter_order=3): """ Convert data to a `pandas.DataFrame`. Parameters ---------- filter_order : int Filter order to use when filtering Z_device, capacitance, x_position, and dxdt. Data is filtered using a Savitzky-Golay filter with a wi...
python
def to_frame(self, filter_order=3): """ Convert data to a `pandas.DataFrame`. Parameters ---------- filter_order : int Filter order to use when filtering Z_device, capacitance, x_position, and dxdt. Data is filtered using a Savitzky-Golay filter with a wi...
[ "def", "to_frame", "(", "self", ",", "filter_order", "=", "3", ")", ":", "window_size", "=", "self", ".", "_get_window_size", "(", ")", "L", "=", "np", ".", "sqrt", "(", "self", ".", "area", ")", "velocity_results", "=", "self", ".", "mean_velocity", "...
Convert data to a `pandas.DataFrame`. Parameters ---------- filter_order : int Filter order to use when filtering Z_device, capacitance, x_position, and dxdt. Data is filtered using a Savitzky-Golay filter with a window size that is adjusted based on the mean...
[ "Convert", "data", "to", "a", "pandas", ".", "DataFrame", "." ]
1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c
https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L721-L821
37,917
wheeler-microfluidics/dmf-control-board-firmware
dmf_control_board_firmware/__init__.py
DMFControlBoard.set_series_capacitance
def set_series_capacitance(self, channel, value, resistor_index=None): ''' Set the current series capacitance value for the specified channel. Parameters ---------- channel : int Analog channel index. value : float Series capacitance value. ...
python
def set_series_capacitance(self, channel, value, resistor_index=None): ''' Set the current series capacitance value for the specified channel. Parameters ---------- channel : int Analog channel index. value : float Series capacitance value. ...
[ "def", "set_series_capacitance", "(", "self", ",", "channel", ",", "value", ",", "resistor_index", "=", "None", ")", ":", "if", "resistor_index", "is", "None", ":", "resistor_index", "=", "self", ".", "series_resistor_index", "(", "channel", ")", "try", ":", ...
Set the current series capacitance value for the specified channel. Parameters ---------- channel : int Analog channel index. value : float Series capacitance value. resistor_index : int, optional Series resistor channel index. If...
[ "Set", "the", "current", "series", "capacitance", "value", "for", "the", "specified", "channel", "." ]
1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c
https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L1261-L1296
37,918
wheeler-microfluidics/dmf-control-board-firmware
dmf_control_board_firmware/__init__.py
DMFControlBoard.set_series_resistance
def set_series_resistance(self, channel, value, resistor_index=None): ''' Set the current series resistance value for the specified channel. Parameters ---------- channel : int Analog channel index. value : float Series resistance value. r...
python
def set_series_resistance(self, channel, value, resistor_index=None): ''' Set the current series resistance value for the specified channel. Parameters ---------- channel : int Analog channel index. value : float Series resistance value. r...
[ "def", "set_series_resistance", "(", "self", ",", "channel", ",", "value", ",", "resistor_index", "=", "None", ")", ":", "if", "resistor_index", "is", "None", ":", "resistor_index", "=", "self", ".", "series_resistor_index", "(", "channel", ")", "try", ":", ...
Set the current series resistance value for the specified channel. Parameters ---------- channel : int Analog channel index. value : float Series resistance value. resistor_index : int, optional Series resistor channel index. If :...
[ "Set", "the", "current", "series", "resistance", "value", "for", "the", "specified", "channel", "." ]
1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c
https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L1299-L1337
37,919
wheeler-microfluidics/dmf-control-board-firmware
dmf_control_board_firmware/__init__.py
DMFControlBoard.persistent_write
def persistent_write(self, address, byte, refresh_config=False): ''' Write a single byte to an address in persistent memory. Parameters ---------- address : int Address in persistent memory (e.g., EEPROM). byte : int Value to write to address. ...
python
def persistent_write(self, address, byte, refresh_config=False): ''' Write a single byte to an address in persistent memory. Parameters ---------- address : int Address in persistent memory (e.g., EEPROM). byte : int Value to write to address. ...
[ "def", "persistent_write", "(", "self", ",", "address", ",", "byte", ",", "refresh_config", "=", "False", ")", ":", "self", ".", "_persistent_write", "(", "address", ",", "byte", ")", "if", "refresh_config", ":", "self", ".", "load_config", "(", "False", "...
Write a single byte to an address in persistent memory. Parameters ---------- address : int Address in persistent memory (e.g., EEPROM). byte : int Value to write to address. refresh_config : bool, optional Is ``True``, :meth:`load_config()` i...
[ "Write", "a", "single", "byte", "to", "an", "address", "in", "persistent", "memory", "." ]
1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c
https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L1504-L1520
37,920
wheeler-microfluidics/dmf-control-board-firmware
dmf_control_board_firmware/__init__.py
DMFControlBoard.persistent_read_multibyte
def persistent_read_multibyte(self, address, count=None, dtype=np.uint8): ''' Read a chunk of data from persistent memory. Parameters ---------- address : int Address in persistent memory (e.g., EEPROM). count : int, optional Number of values to r...
python
def persistent_read_multibyte(self, address, count=None, dtype=np.uint8): ''' Read a chunk of data from persistent memory. Parameters ---------- address : int Address in persistent memory (e.g., EEPROM). count : int, optional Number of values to r...
[ "def", "persistent_read_multibyte", "(", "self", ",", "address", ",", "count", "=", "None", ",", "dtype", "=", "np", ".", "uint8", ")", ":", "nbytes", "=", "np", ".", "dtype", "(", "dtype", ")", ".", "itemsize", "if", "count", "is", "not", "None", ":...
Read a chunk of data from persistent memory. Parameters ---------- address : int Address in persistent memory (e.g., EEPROM). count : int, optional Number of values to read. If not set, read a single value of the specified :data:`dtype`. dtyp...
[ "Read", "a", "chunk", "of", "data", "from", "persistent", "memory", "." ]
1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c
https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L1522-L1560
37,921
wheeler-microfluidics/dmf-control-board-firmware
dmf_control_board_firmware/__init__.py
DMFControlBoard.persistent_write_multibyte
def persistent_write_multibyte(self, address, data, refresh_config=False): ''' Write multiple bytes to an address in persistent memory. Parameters ---------- address : int Address in persistent memory (e.g., EEPROM). data : numpy.array Data to wri...
python
def persistent_write_multibyte(self, address, data, refresh_config=False): ''' Write multiple bytes to an address in persistent memory. Parameters ---------- address : int Address in persistent memory (e.g., EEPROM). data : numpy.array Data to wri...
[ "def", "persistent_write_multibyte", "(", "self", ",", "address", ",", "data", ",", "refresh_config", "=", "False", ")", ":", "for", "i", ",", "byte", "in", "enumerate", "(", "data", ".", "view", "(", "np", ".", "uint8", ")", ")", ":", "self", ".", "...
Write multiple bytes to an address in persistent memory. Parameters ---------- address : int Address in persistent memory (e.g., EEPROM). data : numpy.array Data to write. refresh_config : bool, optional Is ``True``, :meth:`load_config()` is c...
[ "Write", "multiple", "bytes", "to", "an", "address", "in", "persistent", "memory", "." ]
1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c
https://github.com/wheeler-microfluidics/dmf-control-board-firmware/blob/1cd8cc9a148d530f9a11f634f2dbfe73f08aa27c/dmf_control_board_firmware/__init__.py#L1562-L1579
37,922
inveniosoftware/kwalitee
kwalitee/hooks.py
_get_files_modified
def _get_files_modified(): """Get the list of modified files that are Python or Jinja2.""" cmd = "git diff-index --cached --name-only --diff-filter=ACMRTUXB HEAD" _, files_modified, _ = run(cmd) extensions = [re.escape(ext) for ext in list(SUPPORTED_FILES) + [".rst"]] test = "(?:{0})$".format("|".j...
python
def _get_files_modified(): """Get the list of modified files that are Python or Jinja2.""" cmd = "git diff-index --cached --name-only --diff-filter=ACMRTUXB HEAD" _, files_modified, _ = run(cmd) extensions = [re.escape(ext) for ext in list(SUPPORTED_FILES) + [".rst"]] test = "(?:{0})$".format("|".j...
[ "def", "_get_files_modified", "(", ")", ":", "cmd", "=", "\"git diff-index --cached --name-only --diff-filter=ACMRTUXB HEAD\"", "_", ",", "files_modified", ",", "_", "=", "run", "(", "cmd", ")", "extensions", "=", "[", "re", ".", "escape", "(", "ext", ")", "for"...
Get the list of modified files that are Python or Jinja2.
[ "Get", "the", "list", "of", "modified", "files", "that", "are", "Python", "or", "Jinja2", "." ]
9124f8f55b15547fef08c6c43cabced314e70674
https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/hooks.py#L42-L49
37,923
inveniosoftware/kwalitee
kwalitee/hooks.py
_get_git_author
def _get_git_author(): """Return the git author from the git variables.""" _, stdout, _ = run("git var GIT_AUTHOR_IDENT") git_author = stdout[0] return git_author[:git_author.find(">") + 1]
python
def _get_git_author(): """Return the git author from the git variables.""" _, stdout, _ = run("git var GIT_AUTHOR_IDENT") git_author = stdout[0] return git_author[:git_author.find(">") + 1]
[ "def", "_get_git_author", "(", ")", ":", "_", ",", "stdout", ",", "_", "=", "run", "(", "\"git var GIT_AUTHOR_IDENT\"", ")", "git_author", "=", "stdout", "[", "0", "]", "return", "git_author", "[", ":", "git_author", ".", "find", "(", "\">\"", ")", "+", ...
Return the git author from the git variables.
[ "Return", "the", "git", "author", "from", "the", "git", "variables", "." ]
9124f8f55b15547fef08c6c43cabced314e70674
https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/hooks.py#L52-L57
37,924
inveniosoftware/kwalitee
kwalitee/hooks.py
_get_component
def _get_component(filename, default="global"): """Get component name from filename.""" if hasattr(filename, "decode"): filename = filename.decode() parts = filename.split(os.path.sep) if len(parts) >= 3: if parts[1] in "modules legacy ext".split(): return parts[2] if le...
python
def _get_component(filename, default="global"): """Get component name from filename.""" if hasattr(filename, "decode"): filename = filename.decode() parts = filename.split(os.path.sep) if len(parts) >= 3: if parts[1] in "modules legacy ext".split(): return parts[2] if le...
[ "def", "_get_component", "(", "filename", ",", "default", "=", "\"global\"", ")", ":", "if", "hasattr", "(", "filename", ",", "\"decode\"", ")", ":", "filename", "=", "filename", ".", "decode", "(", ")", "parts", "=", "filename", ".", "split", "(", "os",...
Get component name from filename.
[ "Get", "component", "name", "from", "filename", "." ]
9124f8f55b15547fef08c6c43cabced314e70674
https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/hooks.py#L60-L75
37,925
inveniosoftware/kwalitee
kwalitee/hooks.py
_prepare_commit_msg
def _prepare_commit_msg(tmp_file, author, files_modified=None, template=None): """Prepare the commit message in tmp_file. It will build the commit message prefilling the component line, as well as the signature using the git author and the modified files. The file remains untouched if it is not empty....
python
def _prepare_commit_msg(tmp_file, author, files_modified=None, template=None): """Prepare the commit message in tmp_file. It will build the commit message prefilling the component line, as well as the signature using the git author and the modified files. The file remains untouched if it is not empty....
[ "def", "_prepare_commit_msg", "(", "tmp_file", ",", "author", ",", "files_modified", "=", "None", ",", "template", "=", "None", ")", ":", "files_modified", "=", "files_modified", "or", "[", "]", "template", "=", "template", "or", "\"{component}:\\n\\nSigned-off-by...
Prepare the commit message in tmp_file. It will build the commit message prefilling the component line, as well as the signature using the git author and the modified files. The file remains untouched if it is not empty.
[ "Prepare", "the", "commit", "message", "in", "tmp_file", "." ]
9124f8f55b15547fef08c6c43cabced314e70674
https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/hooks.py#L83-L118
37,926
inveniosoftware/kwalitee
kwalitee/hooks.py
_check_message
def _check_message(message, options): """Checking the message and printing the errors.""" options = options or dict() options.update(get_options()) options.update(_read_local_kwalitee_configuration()) errors = check_message(message, **options) if errors: for error in errors: ...
python
def _check_message(message, options): """Checking the message and printing the errors.""" options = options or dict() options.update(get_options()) options.update(_read_local_kwalitee_configuration()) errors = check_message(message, **options) if errors: for error in errors: ...
[ "def", "_check_message", "(", "message", ",", "options", ")", ":", "options", "=", "options", "or", "dict", "(", ")", "options", ".", "update", "(", "get_options", "(", ")", ")", "options", ".", "update", "(", "_read_local_kwalitee_configuration", "(", ")", ...
Checking the message and printing the errors.
[ "Checking", "the", "message", "and", "printing", "the", "errors", "." ]
9124f8f55b15547fef08c6c43cabced314e70674
https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/hooks.py#L121-L134
37,927
inveniosoftware/kwalitee
kwalitee/hooks.py
_read_local_kwalitee_configuration
def _read_local_kwalitee_configuration(directory="."): """Check if the repo has a ``.kwalitee.yaml`` file.""" filepath = os.path.abspath(os.path.join(directory, '.kwalitee.yml')) data = {} if os.path.exists(filepath): with open(filepath, 'r') as file_read: data = yaml.load(file_read....
python
def _read_local_kwalitee_configuration(directory="."): """Check if the repo has a ``.kwalitee.yaml`` file.""" filepath = os.path.abspath(os.path.join(directory, '.kwalitee.yml')) data = {} if os.path.exists(filepath): with open(filepath, 'r') as file_read: data = yaml.load(file_read....
[ "def", "_read_local_kwalitee_configuration", "(", "directory", "=", "\".\"", ")", ":", "filepath", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "directory", ",", "'.kwalitee.yml'", ")", ")", "data", "=", "{", "}", "if...
Check if the repo has a ``.kwalitee.yaml`` file.
[ "Check", "if", "the", "repo", "has", "a", ".", "kwalitee", ".", "yaml", "file", "." ]
9124f8f55b15547fef08c6c43cabced314e70674
https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/hooks.py#L185-L192
37,928
inveniosoftware/kwalitee
kwalitee/hooks.py
_pre_commit
def _pre_commit(files, options): """Run the check on files of the added version. They might be different than the one on disk. Equivalent than doing a git stash, check, and git stash pop. """ errors = [] tmpdir = mkdtemp() files_to_check = [] try: for (file_, content) in files: ...
python
def _pre_commit(files, options): """Run the check on files of the added version. They might be different than the one on disk. Equivalent than doing a git stash, check, and git stash pop. """ errors = [] tmpdir = mkdtemp() files_to_check = [] try: for (file_, content) in files: ...
[ "def", "_pre_commit", "(", "files", ",", "options", ")", ":", "errors", "=", "[", "]", "tmpdir", "=", "mkdtemp", "(", ")", "files_to_check", "=", "[", "]", "try", ":", "for", "(", "file_", ",", "content", ")", "in", "files", ":", "# write staged versio...
Run the check on files of the added version. They might be different than the one on disk. Equivalent than doing a git stash, check, and git stash pop.
[ "Run", "the", "check", "on", "files", "of", "the", "added", "version", "." ]
9124f8f55b15547fef08c6c43cabced314e70674
https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/hooks.py#L221-L250
37,929
inveniosoftware/kwalitee
kwalitee/hooks.py
run
def run(command, raw_output=False): """Run a command using subprocess. :param command: command line to be run :type command: str :param raw_output: does not attempt to convert the output as unicode :type raw_output: bool :return: error code, output (``stdout``) and error (``stderr``) :rtype...
python
def run(command, raw_output=False): """Run a command using subprocess. :param command: command line to be run :type command: str :param raw_output: does not attempt to convert the output as unicode :type raw_output: bool :return: error code, output (``stdout``) and error (``stderr``) :rtype...
[ "def", "run", "(", "command", ",", "raw_output", "=", "False", ")", ":", "p", "=", "Popen", "(", "command", ".", "split", "(", ")", ",", "stdout", "=", "PIPE", ",", "stderr", "=", "PIPE", ")", "(", "stdout", ",", "stderr", ")", "=", "p", ".", "...
Run a command using subprocess. :param command: command line to be run :type command: str :param raw_output: does not attempt to convert the output as unicode :type raw_output: bool :return: error code, output (``stdout``) and error (``stderr``) :rtype: tuple
[ "Run", "a", "command", "using", "subprocess", "." ]
9124f8f55b15547fef08c6c43cabced314e70674
https://github.com/inveniosoftware/kwalitee/blob/9124f8f55b15547fef08c6c43cabced314e70674/kwalitee/hooks.py#L285-L306
37,930
Chilipp/psy-simple
psy_simple/widgets/texts.py
mpl_weight2qt
def mpl_weight2qt(weight): """Convert a weight from matplotlib definition to a Qt weight Parameters ---------- weight: int or string Either an integer between 1 and 1000 or a string out of :attr:`weights_mpl2qt` Returns ------- int One type of the PyQt5.QtGui.QFont....
python
def mpl_weight2qt(weight): """Convert a weight from matplotlib definition to a Qt weight Parameters ---------- weight: int or string Either an integer between 1 and 1000 or a string out of :attr:`weights_mpl2qt` Returns ------- int One type of the PyQt5.QtGui.QFont....
[ "def", "mpl_weight2qt", "(", "weight", ")", ":", "try", ":", "weight", "=", "weights_mpl2qt", "[", "weight", "]", "except", "KeyError", ":", "try", ":", "weight", "=", "float", "(", "weight", ")", "/", "10", "except", "(", "ValueError", ",", "TypeError",...
Convert a weight from matplotlib definition to a Qt weight Parameters ---------- weight: int or string Either an integer between 1 and 1000 or a string out of :attr:`weights_mpl2qt` Returns ------- int One type of the PyQt5.QtGui.QFont.Weight
[ "Convert", "a", "weight", "from", "matplotlib", "definition", "to", "a", "Qt", "weight" ]
7d916406a6d3c3c27c0b7102f98fef07a4da0a61
https://github.com/Chilipp/psy-simple/blob/7d916406a6d3c3c27c0b7102f98fef07a4da0a61/psy_simple/widgets/texts.py#L66-L92
37,931
Chilipp/psy-simple
psy_simple/widgets/texts.py
FontPropertiesWidget.choose_font
def choose_font(self, font=None): """Choose a font for the label through a dialog""" fmt_widget = self.parent() if font is None: if self.current_font: font, ok = QFontDialog.getFont( self.current_font, fmt_widget, 'Select %s fon...
python
def choose_font(self, font=None): """Choose a font for the label through a dialog""" fmt_widget = self.parent() if font is None: if self.current_font: font, ok = QFontDialog.getFont( self.current_font, fmt_widget, 'Select %s fon...
[ "def", "choose_font", "(", "self", ",", "font", "=", "None", ")", ":", "fmt_widget", "=", "self", ".", "parent", "(", ")", "if", "font", "is", "None", ":", "if", "self", ".", "current_font", ":", "font", ",", "ok", "=", "QFontDialog", ".", "getFont",...
Choose a font for the label through a dialog
[ "Choose", "a", "font", "for", "the", "label", "through", "a", "dialog" ]
7d916406a6d3c3c27c0b7102f98fef07a4da0a61
https://github.com/Chilipp/psy-simple/blob/7d916406a6d3c3c27c0b7102f98fef07a4da0a61/psy_simple/widgets/texts.py#L401-L418
37,932
Chilipp/psy-simple
psy_simple/widgets/texts.py
FontPropertiesWidget.refresh
def refresh(self): """Refresh the widgets from the current font""" font = self.current_font # refresh btn_bold self.btn_bold.blockSignals(True) self.btn_bold.setChecked(font.weight() > 50) self.btn_bold.blockSignals(False) # refresh btn_italic self.btn_i...
python
def refresh(self): """Refresh the widgets from the current font""" font = self.current_font # refresh btn_bold self.btn_bold.blockSignals(True) self.btn_bold.setChecked(font.weight() > 50) self.btn_bold.blockSignals(False) # refresh btn_italic self.btn_i...
[ "def", "refresh", "(", "self", ")", ":", "font", "=", "self", ".", "current_font", "# refresh btn_bold", "self", ".", "btn_bold", ".", "blockSignals", "(", "True", ")", "self", ".", "btn_bold", ".", "setChecked", "(", "font", ".", "weight", "(", ")", ">"...
Refresh the widgets from the current font
[ "Refresh", "the", "widgets", "from", "the", "current", "font" ]
7d916406a6d3c3c27c0b7102f98fef07a4da0a61
https://github.com/Chilipp/psy-simple/blob/7d916406a6d3c3c27c0b7102f98fef07a4da0a61/psy_simple/widgets/texts.py#L420-L437
37,933
rclement/flask-pretty
flask_pretty.py
Prettify._prettify_response
def _prettify_response(self, response): """ Prettify the HTML response. :param response: A Flask Response object. """ if response.content_type == 'text/html; charset=utf-8': ugly = response.get_data(as_text=True) soup = BeautifulSoup(ugly, 'html.parser') ...
python
def _prettify_response(self, response): """ Prettify the HTML response. :param response: A Flask Response object. """ if response.content_type == 'text/html; charset=utf-8': ugly = response.get_data(as_text=True) soup = BeautifulSoup(ugly, 'html.parser') ...
[ "def", "_prettify_response", "(", "self", ",", "response", ")", ":", "if", "response", ".", "content_type", "==", "'text/html; charset=utf-8'", ":", "ugly", "=", "response", ".", "get_data", "(", "as_text", "=", "True", ")", "soup", "=", "BeautifulSoup", "(", ...
Prettify the HTML response. :param response: A Flask Response object.
[ "Prettify", "the", "HTML", "response", "." ]
74f3c2d9f344d5cd8611a4c25a2a30e85f4ef1d4
https://github.com/rclement/flask-pretty/blob/74f3c2d9f344d5cd8611a4c25a2a30e85f4ef1d4/flask_pretty.py#L52-L65
37,934
jeradM/pysabnzbd
pysabnzbd/__init__.py
SabnzbdApi._call
async def _call(self, params): """Call the SABnzbd API""" if self._session.closed: raise SabnzbdApiException('Session already closed') p = {**self._default_params, **params} try: async with timeout(self._timeout, loop=self._session.loop): async wi...
python
async def _call(self, params): """Call the SABnzbd API""" if self._session.closed: raise SabnzbdApiException('Session already closed') p = {**self._default_params, **params} try: async with timeout(self._timeout, loop=self._session.loop): async wi...
[ "async", "def", "_call", "(", "self", ",", "params", ")", ":", "if", "self", ".", "_session", ".", "closed", ":", "raise", "SabnzbdApiException", "(", "'Session already closed'", ")", "p", "=", "{", "*", "*", "self", ".", "_default_params", ",", "*", "*"...
Call the SABnzbd API
[ "Call", "the", "SABnzbd", "API" ]
2b365a1f7d8fef437151570a430f8493d6d04795
https://github.com/jeradM/pysabnzbd/blob/2b365a1f7d8fef437151570a430f8493d6d04795/pysabnzbd/__init__.py#L34-L51
37,935
jeradM/pysabnzbd
pysabnzbd/__init__.py
SabnzbdApi.refresh_data
async def refresh_data(self): """Refresh the cached SABnzbd queue data""" queue = await self.get_queue() history = await self.get_history() totals = {} for k in history: if k[-4:] == 'size': totals[k] = self._convert_size(history.get(k)) self.q...
python
async def refresh_data(self): """Refresh the cached SABnzbd queue data""" queue = await self.get_queue() history = await self.get_history() totals = {} for k in history: if k[-4:] == 'size': totals[k] = self._convert_size(history.get(k)) self.q...
[ "async", "def", "refresh_data", "(", "self", ")", ":", "queue", "=", "await", "self", ".", "get_queue", "(", ")", "history", "=", "await", "self", ".", "get_history", "(", ")", "totals", "=", "{", "}", "for", "k", "in", "history", ":", "if", "k", "...
Refresh the cached SABnzbd queue data
[ "Refresh", "the", "cached", "SABnzbd", "queue", "data" ]
2b365a1f7d8fef437151570a430f8493d6d04795
https://github.com/jeradM/pysabnzbd/blob/2b365a1f7d8fef437151570a430f8493d6d04795/pysabnzbd/__init__.py#L53-L61
37,936
jeradM/pysabnzbd
pysabnzbd/__init__.py
SabnzbdApi._convert_size
def _convert_size(self, size_str): """Convert units to GB""" suffix = size_str[-1] if suffix == 'K': multiplier = 1.0 / (1024.0 * 1024.0) elif suffix == 'M': multiplier = 1.0 / 1024.0 elif suffix == 'T': multiplier = 1024.0 else: ...
python
def _convert_size(self, size_str): """Convert units to GB""" suffix = size_str[-1] if suffix == 'K': multiplier = 1.0 / (1024.0 * 1024.0) elif suffix == 'M': multiplier = 1.0 / 1024.0 elif suffix == 'T': multiplier = 1024.0 else: ...
[ "def", "_convert_size", "(", "self", ",", "size_str", ")", ":", "suffix", "=", "size_str", "[", "-", "1", "]", "if", "suffix", "==", "'K'", ":", "multiplier", "=", "1.0", "/", "(", "1024.0", "*", "1024.0", ")", "elif", "suffix", "==", "'M'", ":", "...
Convert units to GB
[ "Convert", "units", "to", "GB" ]
2b365a1f7d8fef437151570a430f8493d6d04795
https://github.com/jeradM/pysabnzbd/blob/2b365a1f7d8fef437151570a430f8493d6d04795/pysabnzbd/__init__.py#L96-L112
37,937
jeradM/pysabnzbd
pysabnzbd/__init__.py
SabnzbdApi._handle_error
def _handle_error(self, data, params): """Handle an error response from the SABnzbd API""" error = data.get('error', 'API call failed') mode = params.get('mode') raise SabnzbdApiException(error, mode=mode)
python
def _handle_error(self, data, params): """Handle an error response from the SABnzbd API""" error = data.get('error', 'API call failed') mode = params.get('mode') raise SabnzbdApiException(error, mode=mode)
[ "def", "_handle_error", "(", "self", ",", "data", ",", "params", ")", ":", "error", "=", "data", ".", "get", "(", "'error'", ",", "'API call failed'", ")", "mode", "=", "params", ".", "get", "(", "'mode'", ")", "raise", "SabnzbdApiException", "(", "error...
Handle an error response from the SABnzbd API
[ "Handle", "an", "error", "response", "from", "the", "SABnzbd", "API" ]
2b365a1f7d8fef437151570a430f8493d6d04795
https://github.com/jeradM/pysabnzbd/blob/2b365a1f7d8fef437151570a430f8493d6d04795/pysabnzbd/__init__.py#L114-L118
37,938
toumorokoshi/sprinter
sprinter/formula/ssh.py
SSHFormula.__generate_key
def __generate_key(self, config): """ Generate the ssh key, and return the ssh config location """ cwd = config.get('ssh_path', self._install_directory()) if config.is_affirmative('create', default="yes"): if not os.path.exists(cwd): os.makedirs(cwd) ...
python
def __generate_key(self, config): """ Generate the ssh key, and return the ssh config location """ cwd = config.get('ssh_path', self._install_directory()) if config.is_affirmative('create', default="yes"): if not os.path.exists(cwd): os.makedirs(cwd) ...
[ "def", "__generate_key", "(", "self", ",", "config", ")", ":", "cwd", "=", "config", ".", "get", "(", "'ssh_path'", ",", "self", ".", "_install_directory", "(", ")", ")", "if", "config", ".", "is_affirmative", "(", "'create'", ",", "default", "=", "\"yes...
Generate the ssh key, and return the ssh config location
[ "Generate", "the", "ssh", "key", "and", "return", "the", "ssh", "config", "location" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/formula/ssh.py#L68-L81
37,939
toumorokoshi/sprinter
sprinter/formula/ssh.py
SSHFormula.__install_ssh_config
def __install_ssh_config(self, config): """ Install the ssh configuration """ if not config.is_affirmative('use_global_ssh', default="no"): ssh_config_injection = self._build_ssh_config(config) if not os.path.exists(ssh_config_path): if self.inje...
python
def __install_ssh_config(self, config): """ Install the ssh configuration """ if not config.is_affirmative('use_global_ssh', default="no"): ssh_config_injection = self._build_ssh_config(config) if not os.path.exists(ssh_config_path): if self.inje...
[ "def", "__install_ssh_config", "(", "self", ",", "config", ")", ":", "if", "not", "config", ".", "is_affirmative", "(", "'use_global_ssh'", ",", "default", "=", "\"no\"", ")", ":", "ssh_config_injection", "=", "self", ".", "_build_ssh_config", "(", "config", "...
Install the ssh configuration
[ "Install", "the", "ssh", "configuration" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/formula/ssh.py#L83-L101
37,940
toumorokoshi/sprinter
sprinter/formula/ssh.py
SSHFormula._build_ssh_config
def _build_ssh_config(self, config): """ build the ssh injection configuration """ ssh_config_injection = ssh_config_template % { 'host': config.get('host'), 'hostname': config.get('hostname'), 'ssh_key_path': config.get('ssh_key_path'), 'user': config.get...
python
def _build_ssh_config(self, config): """ build the ssh injection configuration """ ssh_config_injection = ssh_config_template % { 'host': config.get('host'), 'hostname': config.get('hostname'), 'ssh_key_path': config.get('ssh_key_path'), 'user': config.get...
[ "def", "_build_ssh_config", "(", "self", ",", "config", ")", ":", "ssh_config_injection", "=", "ssh_config_template", "%", "{", "'host'", ":", "config", ".", "get", "(", "'host'", ")", ",", "'hostname'", ":", "config", ".", "get", "(", "'hostname'", ")", "...
build the ssh injection configuration
[ "build", "the", "ssh", "injection", "configuration" ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/formula/ssh.py#L112-L122
37,941
Cadasta/cadasta-workertoolbox
cadasta/workertoolbox/utils.py
extract_followups
def extract_followups(task): """ Retrieve callbacks and errbacks from provided task instance, disables tasks callbacks. """ callbacks = task.request.callbacks errbacks = task.request.errbacks task.request.callbacks = None return {'link': callbacks, 'link_error': errbacks}
python
def extract_followups(task): """ Retrieve callbacks and errbacks from provided task instance, disables tasks callbacks. """ callbacks = task.request.callbacks errbacks = task.request.errbacks task.request.callbacks = None return {'link': callbacks, 'link_error': errbacks}
[ "def", "extract_followups", "(", "task", ")", ":", "callbacks", "=", "task", ".", "request", ".", "callbacks", "errbacks", "=", "task", ".", "request", ".", "errbacks", "task", ".", "request", ".", "callbacks", "=", "None", "return", "{", "'link'", ":", ...
Retrieve callbacks and errbacks from provided task instance, disables tasks callbacks.
[ "Retrieve", "callbacks", "and", "errbacks", "from", "provided", "task", "instance", "disables", "tasks", "callbacks", "." ]
e17cf376538cee0b32c7a21afd5319e3549b954f
https://github.com/Cadasta/cadasta-workertoolbox/blob/e17cf376538cee0b32c7a21afd5319e3549b954f/cadasta/workertoolbox/utils.py#L4-L12
37,942
frascoweb/frasco
frasco/cli/scaffold.py
gen_procfile
def gen_procfile(ctx, wsgi, dev): """Generates Procfiles which can be used with honcho or foreman. """ if wsgi is None: if os.path.exists("wsgi.py"): wsgi = "wsgi.py" elif os.path.exists("app.py"): wsgi = "app.py" else: wsgi = "app.py" ...
python
def gen_procfile(ctx, wsgi, dev): """Generates Procfiles which can be used with honcho or foreman. """ if wsgi is None: if os.path.exists("wsgi.py"): wsgi = "wsgi.py" elif os.path.exists("app.py"): wsgi = "app.py" else: wsgi = "app.py" ...
[ "def", "gen_procfile", "(", "ctx", ",", "wsgi", ",", "dev", ")", ":", "if", "wsgi", "is", "None", ":", "if", "os", ".", "path", ".", "exists", "(", "\"wsgi.py\"", ")", ":", "wsgi", "=", "\"wsgi.py\"", "elif", "os", ".", "path", ".", "exists", "(", ...
Generates Procfiles which can be used with honcho or foreman.
[ "Generates", "Procfiles", "which", "can", "be", "used", "with", "honcho", "or", "foreman", "." ]
ea519d69dd5ca6deaf3650175692ee4a1a02518f
https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/cli/scaffold.py#L55-L77
37,943
nikcub/floyd
floyd/util/dateformat.py
TimeFormat.g
def g(self): "Hour, 12-hour format without leading zeros; i.e. '1' to '12'" if self.data.hour == 0: return 12 if self.data.hour > 12: return self.data.hour - 12 return self.data.hour
python
def g(self): "Hour, 12-hour format without leading zeros; i.e. '1' to '12'" if self.data.hour == 0: return 12 if self.data.hour > 12: return self.data.hour - 12 return self.data.hour
[ "def", "g", "(", "self", ")", ":", "if", "self", ".", "data", ".", "hour", "==", "0", ":", "return", "12", "if", "self", ".", "data", ".", "hour", ">", "12", ":", "return", "self", ".", "data", ".", "hour", "-", "12", "return", "self", ".", "...
Hour, 12-hour format without leading zeros; i.e. '1' to '12
[ "Hour", "12", "-", "hour", "format", "without", "leading", "zeros", ";", "i", ".", "e", ".", "1", "to", "12" ]
5772d0047efb11c9ce5f7d234a9da4576ce24edc
https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/dateformat.py#L122-L128
37,944
nikcub/floyd
floyd/util/dateformat.py
DateFormat.I
def I(self): "'1' if Daylight Savings Time, '0' otherwise." if self.timezone and self.timezone.dst(self.data): return u'1' else: return u'0'
python
def I(self): "'1' if Daylight Savings Time, '0' otherwise." if self.timezone and self.timezone.dst(self.data): return u'1' else: return u'0'
[ "def", "I", "(", "self", ")", ":", "if", "self", ".", "timezone", "and", "self", ".", "timezone", ".", "dst", "(", "self", ".", "data", ")", ":", "return", "u'1'", "else", ":", "return", "u'0'" ]
1' if Daylight Savings Time, '0' otherwise.
[ "1", "if", "Daylight", "Savings", "Time", "0", "otherwise", "." ]
5772d0047efb11c9ce5f7d234a9da4576ce24edc
https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/dateformat.py#L257-L262
37,945
nikcub/floyd
floyd/util/dateformat.py
DateFormat.S
def S(self): "English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th'" if self.data.day in (11, 12, 13): # Special case return u'th' last = self.data.day % 10 if last == 1: return u'st' if last == 2: return u'nd' if last == 3: return u...
python
def S(self): "English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th'" if self.data.day in (11, 12, 13): # Special case return u'th' last = self.data.day % 10 if last == 1: return u'st' if last == 2: return u'nd' if last == 3: return u...
[ "def", "S", "(", "self", ")", ":", "if", "self", ".", "data", ".", "day", "in", "(", "11", ",", "12", ",", "13", ")", ":", "# Special case", "return", "u'th'", "last", "=", "self", ".", "data", ".", "day", "%", "10", "if", "last", "==", "1", ...
English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th
[ "English", "ordinal", "suffix", "for", "the", "day", "of", "the", "month", "2", "characters", ";", "i", ".", "e", ".", "st", "nd", "rd", "or", "th" ]
5772d0047efb11c9ce5f7d234a9da4576ce24edc
https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/dateformat.py#L301-L312
37,946
nikcub/floyd
floyd/util/dateformat.py
DateFormat.t
def t(self): "Number of days in the given month; i.e. '28' to '31'" return u'%02d' % calendar.monthrange(self.data.year, self.data.month)[1]
python
def t(self): "Number of days in the given month; i.e. '28' to '31'" return u'%02d' % calendar.monthrange(self.data.year, self.data.month)[1]
[ "def", "t", "(", "self", ")", ":", "return", "u'%02d'", "%", "calendar", ".", "monthrange", "(", "self", ".", "data", ".", "year", ",", "self", ".", "data", ".", "month", ")", "[", "1", "]" ]
Number of days in the given month; i.e. '28' to '31
[ "Number", "of", "days", "in", "the", "given", "month", ";", "i", ".", "e", ".", "28", "to", "31" ]
5772d0047efb11c9ce5f7d234a9da4576ce24edc
https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/dateformat.py#L314-L316
37,947
nikcub/floyd
floyd/util/dateformat.py
DateFormat.W
def W(self): "ISO-8601 week number of year, weeks starting on Monday" # Algorithm from http://www.personal.ecu.edu/mccartyr/ISOwdALG.txt week_number = None jan1_weekday = self.data.replace(month=1, day=1).weekday() + 1 weekday = self.data.weekday() + 1 day_of_year = self.z() if day_of_year <...
python
def W(self): "ISO-8601 week number of year, weeks starting on Monday" # Algorithm from http://www.personal.ecu.edu/mccartyr/ISOwdALG.txt week_number = None jan1_weekday = self.data.replace(month=1, day=1).weekday() + 1 weekday = self.data.weekday() + 1 day_of_year = self.z() if day_of_year <...
[ "def", "W", "(", "self", ")", ":", "# Algorithm from http://www.personal.ecu.edu/mccartyr/ISOwdALG.txt", "week_number", "=", "None", "jan1_weekday", "=", "self", ".", "data", ".", "replace", "(", "month", "=", "1", ",", "day", "=", "1", ")", ".", "weekday", "(...
ISO-8601 week number of year, weeks starting on Monday
[ "ISO", "-", "8601", "week", "number", "of", "year", "weeks", "starting", "on", "Monday" ]
5772d0047efb11c9ce5f7d234a9da4576ce24edc
https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/dateformat.py#L336-L360
37,948
nikcub/floyd
floyd/util/dateformat.py
DateFormat.z
def z(self): "Day of the year; i.e. '0' to '365'" doy = self.year_days[self.data.month] + self.data.day if self.L() and self.data.month > 2: doy += 1 return doy
python
def z(self): "Day of the year; i.e. '0' to '365'" doy = self.year_days[self.data.month] + self.data.day if self.L() and self.data.month > 2: doy += 1 return doy
[ "def", "z", "(", "self", ")", ":", "doy", "=", "self", ".", "year_days", "[", "self", ".", "data", ".", "month", "]", "+", "self", ".", "data", ".", "day", "if", "self", ".", "L", "(", ")", "and", "self", ".", "data", ".", "month", ">", "2", ...
Day of the year; i.e. '0' to '365
[ "Day", "of", "the", "year", ";", "i", ".", "e", ".", "0", "to", "365" ]
5772d0047efb11c9ce5f7d234a9da4576ce24edc
https://github.com/nikcub/floyd/blob/5772d0047efb11c9ce5f7d234a9da4576ce24edc/floyd/util/dateformat.py#L370-L375
37,949
wearpants/instrument
instrument/output/__init__.py
print_metric
def print_metric(name, count, elapsed): """A metric function that prints to standard output :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds """ _do_print(name, count, elapsed, file=sys.stdout)
python
def print_metric(name, count, elapsed): """A metric function that prints to standard output :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds """ _do_print(name, count, elapsed, file=sys.stdout)
[ "def", "print_metric", "(", "name", ",", "count", ",", "elapsed", ")", ":", "_do_print", "(", "name", ",", "count", ",", "elapsed", ",", "file", "=", "sys", ".", "stdout", ")" ]
A metric function that prints to standard output :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds
[ "A", "metric", "function", "that", "prints", "to", "standard", "output" ]
a0f6103574ab58a82361a951e5e56b69aedfe294
https://github.com/wearpants/instrument/blob/a0f6103574ab58a82361a951e5e56b69aedfe294/instrument/output/__init__.py#L9-L16
37,950
wearpants/instrument
instrument/output/__init__.py
stderr_metric
def stderr_metric(name, count, elapsed): """A metric function that prints to standard error :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds """ _do_print(name, count, elapsed, file=sys.stderr)
python
def stderr_metric(name, count, elapsed): """A metric function that prints to standard error :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds """ _do_print(name, count, elapsed, file=sys.stderr)
[ "def", "stderr_metric", "(", "name", ",", "count", ",", "elapsed", ")", ":", "_do_print", "(", "name", ",", "count", ",", "elapsed", ",", "file", "=", "sys", ".", "stderr", ")" ]
A metric function that prints to standard error :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds
[ "A", "metric", "function", "that", "prints", "to", "standard", "error" ]
a0f6103574ab58a82361a951e5e56b69aedfe294
https://github.com/wearpants/instrument/blob/a0f6103574ab58a82361a951e5e56b69aedfe294/instrument/output/__init__.py#L18-L25
37,951
wearpants/instrument
instrument/output/__init__.py
make_multi_metric
def make_multi_metric(*metrics): """Make a new metric function that calls the supplied metrics :arg functions metrics: metric functions :rtype: function """ def multi_metric(name, count, elapsed): """Calls multiple metrics (closure)""" for m in metrics: m(name, count, el...
python
def make_multi_metric(*metrics): """Make a new metric function that calls the supplied metrics :arg functions metrics: metric functions :rtype: function """ def multi_metric(name, count, elapsed): """Calls multiple metrics (closure)""" for m in metrics: m(name, count, el...
[ "def", "make_multi_metric", "(", "*", "metrics", ")", ":", "def", "multi_metric", "(", "name", ",", "count", ",", "elapsed", ")", ":", "\"\"\"Calls multiple metrics (closure)\"\"\"", "for", "m", "in", "metrics", ":", "m", "(", "name", ",", "count", ",", "ela...
Make a new metric function that calls the supplied metrics :arg functions metrics: metric functions :rtype: function
[ "Make", "a", "new", "metric", "function", "that", "calls", "the", "supplied", "metrics" ]
a0f6103574ab58a82361a951e5e56b69aedfe294
https://github.com/wearpants/instrument/blob/a0f6103574ab58a82361a951e5e56b69aedfe294/instrument/output/__init__.py#L27-L37
37,952
mdickinson/refcycle
refcycle/__init__.py
_is_orphan
def _is_orphan(scc, graph): """ Return False iff the given scc is reachable from elsewhere. """ return all(p in scc for v in scc for p in graph.parents(v))
python
def _is_orphan(scc, graph): """ Return False iff the given scc is reachable from elsewhere. """ return all(p in scc for v in scc for p in graph.parents(v))
[ "def", "_is_orphan", "(", "scc", ",", "graph", ")", ":", "return", "all", "(", "p", "in", "scc", "for", "v", "in", "scc", "for", "p", "in", "graph", ".", "parents", "(", "v", ")", ")" ]
Return False iff the given scc is reachable from elsewhere.
[ "Return", "False", "iff", "the", "given", "scc", "is", "reachable", "from", "elsewhere", "." ]
627fad74c74efc601209c96405f8118cd99b2241
https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/__init__.py#L34-L39
37,953
mdickinson/refcycle
refcycle/__init__.py
key_cycles
def key_cycles(): """ Collect cyclic garbage, and return the strongly connected components that were keeping the garbage alive. """ graph = garbage() sccs = graph.strongly_connected_components() return [scc for scc in sccs if _is_orphan(scc, graph)]
python
def key_cycles(): """ Collect cyclic garbage, and return the strongly connected components that were keeping the garbage alive. """ graph = garbage() sccs = graph.strongly_connected_components() return [scc for scc in sccs if _is_orphan(scc, graph)]
[ "def", "key_cycles", "(", ")", ":", "graph", "=", "garbage", "(", ")", "sccs", "=", "graph", ".", "strongly_connected_components", "(", ")", "return", "[", "scc", "for", "scc", "in", "sccs", "if", "_is_orphan", "(", "scc", ",", "graph", ")", "]" ]
Collect cyclic garbage, and return the strongly connected components that were keeping the garbage alive.
[ "Collect", "cyclic", "garbage", "and", "return", "the", "strongly", "connected", "components", "that", "were", "keeping", "the", "garbage", "alive", "." ]
627fad74c74efc601209c96405f8118cd99b2241
https://github.com/mdickinson/refcycle/blob/627fad74c74efc601209c96405f8118cd99b2241/refcycle/__init__.py#L42-L50
37,954
StorjOld/plowshare-wrapper
plowshare/plowshare.py
Plowshare._run_command
def _run_command(self, command, **kwargs): """Wrapper to pass command to plowshare. :param command: The command to pass to plowshare. :type command: str :param **kwargs: Additional keywords passed into :type **kwargs: dict :returns: Object containing either output of plo...
python
def _run_command(self, command, **kwargs): """Wrapper to pass command to plowshare. :param command: The command to pass to plowshare. :type command: str :param **kwargs: Additional keywords passed into :type **kwargs: dict :returns: Object containing either output of plo...
[ "def", "_run_command", "(", "self", ",", "command", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "{", "'output'", ":", "subprocess", ".", "check_output", "(", "command", ",", "*", "*", "kwargs", ")", "}", "except", "Exception", "as", "e", ...
Wrapper to pass command to plowshare. :param command: The command to pass to plowshare. :type command: str :param **kwargs: Additional keywords passed into :type **kwargs: dict :returns: Object containing either output of plowshare command or an error message. ...
[ "Wrapper", "to", "pass", "command", "to", "plowshare", "." ]
edb38d01fd1decabf92cc4f536d7404dca6a977c
https://github.com/StorjOld/plowshare-wrapper/blob/edb38d01fd1decabf92cc4f536d7404dca6a977c/plowshare/plowshare.py#L53-L68
37,955
StorjOld/plowshare-wrapper
plowshare/plowshare.py
Plowshare._filter_sources
def _filter_sources(self, sources): """Remove sources with errors and return ordered by host success. :param sources: List of potential sources to connect to. :type sources: list :returns: Sorted list of potential sources without errors. :rtype: list """ filtered...
python
def _filter_sources(self, sources): """Remove sources with errors and return ordered by host success. :param sources: List of potential sources to connect to. :type sources: list :returns: Sorted list of potential sources without errors. :rtype: list """ filtered...
[ "def", "_filter_sources", "(", "self", ",", "sources", ")", ":", "filtered", ",", "hosts", "=", "[", "]", ",", "[", "]", "for", "source", "in", "sources", ":", "if", "'error'", "in", "source", ":", "continue", "filtered", ".", "append", "(", "source", ...
Remove sources with errors and return ordered by host success. :param sources: List of potential sources to connect to. :type sources: list :returns: Sorted list of potential sources without errors. :rtype: list
[ "Remove", "sources", "with", "errors", "and", "return", "ordered", "by", "host", "success", "." ]
edb38d01fd1decabf92cc4f536d7404dca6a977c
https://github.com/StorjOld/plowshare-wrapper/blob/edb38d01fd1decabf92cc4f536d7404dca6a977c/plowshare/plowshare.py#L81-L97
37,956
StorjOld/plowshare-wrapper
plowshare/plowshare.py
Plowshare.upload
def upload(self, filename, number_of_hosts): """Upload the given file to the specified number of hosts. :param filename: The filename of the file to upload. :type filename: str :param number_of_hosts: The number of hosts to connect to. :type number_of_hosts: int :returns...
python
def upload(self, filename, number_of_hosts): """Upload the given file to the specified number of hosts. :param filename: The filename of the file to upload. :type filename: str :param number_of_hosts: The number of hosts to connect to. :type number_of_hosts: int :returns...
[ "def", "upload", "(", "self", ",", "filename", ",", "number_of_hosts", ")", ":", "return", "self", ".", "multiupload", "(", "filename", ",", "self", ".", "random_hosts", "(", "number_of_hosts", ")", ")" ]
Upload the given file to the specified number of hosts. :param filename: The filename of the file to upload. :type filename: str :param number_of_hosts: The number of hosts to connect to. :type number_of_hosts: int :returns: A list of dicts with 'host_name' and 'url' keys for a...
[ "Upload", "the", "given", "file", "to", "the", "specified", "number", "of", "hosts", "." ]
edb38d01fd1decabf92cc4f536d7404dca6a977c
https://github.com/StorjOld/plowshare-wrapper/blob/edb38d01fd1decabf92cc4f536d7404dca6a977c/plowshare/plowshare.py#L114-L125
37,957
StorjOld/plowshare-wrapper
plowshare/plowshare.py
Plowshare.download
def download(self, sources, output_directory, filename): """Download a file from one of the provided sources The sources will be ordered by least amount of errors, so most successful hosts will be tried first. In case of failure, the next source will be attempted, until the first succes...
python
def download(self, sources, output_directory, filename): """Download a file from one of the provided sources The sources will be ordered by least amount of errors, so most successful hosts will be tried first. In case of failure, the next source will be attempted, until the first succes...
[ "def", "download", "(", "self", ",", "sources", ",", "output_directory", ",", "filename", ")", ":", "valid_sources", "=", "self", ".", "_filter_sources", "(", "sources", ")", "if", "not", "valid_sources", ":", "return", "{", "'error'", ":", "'no valid sources'...
Download a file from one of the provided sources The sources will be ordered by least amount of errors, so most successful hosts will be tried first. In case of failure, the next source will be attempted, until the first successful download is completed or all sources have been depleted...
[ "Download", "a", "file", "from", "one", "of", "the", "provided", "sources" ]
edb38d01fd1decabf92cc4f536d7404dca6a977c
https://github.com/StorjOld/plowshare-wrapper/blob/edb38d01fd1decabf92cc4f536d7404dca6a977c/plowshare/plowshare.py#L127-L163
37,958
StorjOld/plowshare-wrapper
plowshare/plowshare.py
Plowshare.download_from_host
def download_from_host(self, source, output_directory, filename): """Download a file from a given host. This method renames the file to the given string. :param source: Dictionary containing information about host. :type source: dict :param output_directory: Directory to place ...
python
def download_from_host(self, source, output_directory, filename): """Download a file from a given host. This method renames the file to the given string. :param source: Dictionary containing information about host. :type source: dict :param output_directory: Directory to place ...
[ "def", "download_from_host", "(", "self", ",", "source", ",", "output_directory", ",", "filename", ")", ":", "result", "=", "self", ".", "_run_command", "(", "[", "\"plowdown\"", ",", "source", "[", "\"url\"", "]", ",", "\"-o\"", ",", "output_directory", ","...
Download a file from a given host. This method renames the file to the given string. :param source: Dictionary containing information about host. :type source: dict :param output_directory: Directory to place output in. :type output_directory: str :param filename: The f...
[ "Download", "a", "file", "from", "a", "given", "host", "." ]
edb38d01fd1decabf92cc4f536d7404dca6a977c
https://github.com/StorjOld/plowshare-wrapper/blob/edb38d01fd1decabf92cc4f536d7404dca6a977c/plowshare/plowshare.py#L165-L197
37,959
StorjOld/plowshare-wrapper
plowshare/plowshare.py
Plowshare.multiupload
def multiupload(self, filename, hosts): """Upload file to multiple hosts simultaneously The upload will be attempted for each host until the optimal file redundancy is achieved (a percentage of successful uploads) or the host list is depleted. :param filename: The filename of t...
python
def multiupload(self, filename, hosts): """Upload file to multiple hosts simultaneously The upload will be attempted for each host until the optimal file redundancy is achieved (a percentage of successful uploads) or the host list is depleted. :param filename: The filename of t...
[ "def", "multiupload", "(", "self", ",", "filename", ",", "hosts", ")", ":", "manager", "=", "Manager", "(", ")", "successful_uploads", "=", "manager", ".", "list", "(", "[", "]", ")", "def", "f", "(", "host", ")", ":", "if", "len", "(", "successful_u...
Upload file to multiple hosts simultaneously The upload will be attempted for each host until the optimal file redundancy is achieved (a percentage of successful uploads) or the host list is depleted. :param filename: The filename of the file to upload. :type filename: str ...
[ "Upload", "file", "to", "multiple", "hosts", "simultaneously" ]
edb38d01fd1decabf92cc4f536d7404dca6a977c
https://github.com/StorjOld/plowshare-wrapper/blob/edb38d01fd1decabf92cc4f536d7404dca6a977c/plowshare/plowshare.py#L199-L230
37,960
StorjOld/plowshare-wrapper
plowshare/plowshare.py
Plowshare.upload_to_host
def upload_to_host(self, filename, hostname): """Upload a file to the given host. This method relies on 'plowup' being installed on the system. If it succeeds, this method returns a dictionary with the host name, and the final URL. Otherwise, it returns a dictionary with the hos...
python
def upload_to_host(self, filename, hostname): """Upload a file to the given host. This method relies on 'plowup' being installed on the system. If it succeeds, this method returns a dictionary with the host name, and the final URL. Otherwise, it returns a dictionary with the hos...
[ "def", "upload_to_host", "(", "self", ",", "filename", ",", "hostname", ")", ":", "result", "=", "self", ".", "_run_command", "(", "[", "\"plowup\"", ",", "hostname", ",", "filename", "]", ",", "stderr", "=", "open", "(", "\"/dev/null\"", ",", "\"w\"", "...
Upload a file to the given host. This method relies on 'plowup' being installed on the system. If it succeeds, this method returns a dictionary with the host name, and the final URL. Otherwise, it returns a dictionary with the host name and an error flag. :param filename: The f...
[ "Upload", "a", "file", "to", "the", "given", "host", "." ]
edb38d01fd1decabf92cc4f536d7404dca6a977c
https://github.com/StorjOld/plowshare-wrapper/blob/edb38d01fd1decabf92cc4f536d7404dca6a977c/plowshare/plowshare.py#L232-L256
37,961
StorjOld/plowshare-wrapper
plowshare/plowshare.py
Plowshare.parse_output
def parse_output(self, hostname, output): """Parse plowup's output. For now, we just return the last line. :param hostname: Name of host you are working with. :type hostname: str :param output: Dictionary containing information about a plowshare action. ...
python
def parse_output(self, hostname, output): """Parse plowup's output. For now, we just return the last line. :param hostname: Name of host you are working with. :type hostname: str :param output: Dictionary containing information about a plowshare action. ...
[ "def", "parse_output", "(", "self", ",", "hostname", ",", "output", ")", ":", "if", "isinstance", "(", "output", ",", "bytes", ")", ":", "output", "=", "output", ".", "decode", "(", "'utf-8'", ")", "return", "output", ".", "split", "(", ")", "[", "-"...
Parse plowup's output. For now, we just return the last line. :param hostname: Name of host you are working with. :type hostname: str :param output: Dictionary containing information about a plowshare action. :type output: dict :returns: Parsed an...
[ "Parse", "plowup", "s", "output", "." ]
edb38d01fd1decabf92cc4f536d7404dca6a977c
https://github.com/StorjOld/plowshare-wrapper/blob/edb38d01fd1decabf92cc4f536d7404dca6a977c/plowshare/plowshare.py#L258-L273
37,962
Cadasta/cadasta-workertoolbox
cadasta/workertoolbox/conf.py
Config._generate_queues
def _generate_queues(queues, exchange, platform_queue): """ Queues known by this worker """ return set([ Queue('celery', exchange, routing_key='celery'), Queue(platform_queue, exchange, routing_key='#'), ] + [ Queue(q_name, exchange, routing_key=q_name) ...
python
def _generate_queues(queues, exchange, platform_queue): """ Queues known by this worker """ return set([ Queue('celery', exchange, routing_key='celery'), Queue(platform_queue, exchange, routing_key='#'), ] + [ Queue(q_name, exchange, routing_key=q_name) ...
[ "def", "_generate_queues", "(", "queues", ",", "exchange", ",", "platform_queue", ")", ":", "return", "set", "(", "[", "Queue", "(", "'celery'", ",", "exchange", ",", "routing_key", "=", "'celery'", ")", ",", "Queue", "(", "platform_queue", ",", "exchange", ...
Queues known by this worker
[ "Queues", "known", "by", "this", "worker" ]
e17cf376538cee0b32c7a21afd5319e3549b954f
https://github.com/Cadasta/cadasta-workertoolbox/blob/e17cf376538cee0b32c7a21afd5319e3549b954f/cadasta/workertoolbox/conf.py#L202-L210
37,963
dougthor42/PyErf
pyerf/pyerf.py
_erf
def _erf(x): """ Port of cephes ``ndtr.c`` ``erf`` function. See https://github.com/jeremybarnes/cephes/blob/master/cprob/ndtr.c """ T = [ 9.60497373987051638749E0, 9.00260197203842689217E1, 2.23200534594684319226E3, 7.00332514112805075473E3, 5.55923013010394...
python
def _erf(x): """ Port of cephes ``ndtr.c`` ``erf`` function. See https://github.com/jeremybarnes/cephes/blob/master/cprob/ndtr.c """ T = [ 9.60497373987051638749E0, 9.00260197203842689217E1, 2.23200534594684319226E3, 7.00332514112805075473E3, 5.55923013010394...
[ "def", "_erf", "(", "x", ")", ":", "T", "=", "[", "9.60497373987051638749E0", ",", "9.00260197203842689217E1", ",", "2.23200534594684319226E3", ",", "7.00332514112805075473E3", ",", "5.55923013010394962768E4", ",", "]", "U", "=", "[", "3.35617141647503099647E1", ",", ...
Port of cephes ``ndtr.c`` ``erf`` function. See https://github.com/jeremybarnes/cephes/blob/master/cprob/ndtr.c
[ "Port", "of", "cephes", "ndtr", ".", "c", "erf", "function", "." ]
cf38a2c62556cbd4927c9b3f5523f39b6a492472
https://github.com/dougthor42/PyErf/blob/cf38a2c62556cbd4927c9b3f5523f39b6a492472/pyerf/pyerf.py#L36-L70
37,964
dougthor42/PyErf
pyerf/pyerf.py
_erfc
def _erfc(a): """ Port of cephes ``ndtr.c`` ``erfc`` function. See https://github.com/jeremybarnes/cephes/blob/master/cprob/ndtr.c """ # approximation for abs(a) < 8 and abs(a) >= 1 P = [ 2.46196981473530512524E-10, 5.64189564831068821977E-1, 7.46321056442269912687E0, ...
python
def _erfc(a): """ Port of cephes ``ndtr.c`` ``erfc`` function. See https://github.com/jeremybarnes/cephes/blob/master/cprob/ndtr.c """ # approximation for abs(a) < 8 and abs(a) >= 1 P = [ 2.46196981473530512524E-10, 5.64189564831068821977E-1, 7.46321056442269912687E0, ...
[ "def", "_erfc", "(", "a", ")", ":", "# approximation for abs(a) < 8 and abs(a) >= 1", "P", "=", "[", "2.46196981473530512524E-10", ",", "5.64189564831068821977E-1", ",", "7.46321056442269912687E0", ",", "4.86371970985681366614E1", ",", "1.96520832956077098242E2", ",", "5.2644...
Port of cephes ``ndtr.c`` ``erfc`` function. See https://github.com/jeremybarnes/cephes/blob/master/cprob/ndtr.c
[ "Port", "of", "cephes", "ndtr", ".", "c", "erfc", "function", "." ]
cf38a2c62556cbd4927c9b3f5523f39b6a492472
https://github.com/dougthor42/PyErf/blob/cf38a2c62556cbd4927c9b3f5523f39b6a492472/pyerf/pyerf.py#L73-L154
37,965
dougthor42/PyErf
pyerf/pyerf.py
erfinv
def erfinv(z): """ Calculate the inverse error function at point ``z``. This is a direct port of the SciPy ``erfinv`` function, originally written in C. Parameters ---------- z : numeric Returns ------- float References ---------- + https://en.wikipedia.org/wiki/E...
python
def erfinv(z): """ Calculate the inverse error function at point ``z``. This is a direct port of the SciPy ``erfinv`` function, originally written in C. Parameters ---------- z : numeric Returns ------- float References ---------- + https://en.wikipedia.org/wiki/E...
[ "def", "erfinv", "(", "z", ")", ":", "if", "abs", "(", "z", ")", ">", "1", ":", "raise", "ValueError", "(", "\"`z` must be between -1 and 1 inclusive\"", ")", "# Shortcut special cases", "if", "z", "==", "0", ":", "return", "0", "if", "z", "==", "1", ":"...
Calculate the inverse error function at point ``z``. This is a direct port of the SciPy ``erfinv`` function, originally written in C. Parameters ---------- z : numeric Returns ------- float References ---------- + https://en.wikipedia.org/wiki/Error_function#Inverse_funct...
[ "Calculate", "the", "inverse", "error", "function", "at", "point", "z", "." ]
cf38a2c62556cbd4927c9b3f5523f39b6a492472
https://github.com/dougthor42/PyErf/blob/cf38a2c62556cbd4927c9b3f5523f39b6a492472/pyerf/pyerf.py#L290-L343
37,966
Chilipp/psy-simple
psy_simple/colors.py
get_cmap
def get_cmap(name, lut=None): """ Returns the specified colormap. Parameters ---------- name: str or :class:`matplotlib.colors.Colormap` If a colormap, it returned unchanged. %(cmap_note)s lut: int An integer giving the number of entries desired in the lookup table ...
python
def get_cmap(name, lut=None): """ Returns the specified colormap. Parameters ---------- name: str or :class:`matplotlib.colors.Colormap` If a colormap, it returned unchanged. %(cmap_note)s lut: int An integer giving the number of entries desired in the lookup table ...
[ "def", "get_cmap", "(", "name", ",", "lut", "=", "None", ")", ":", "if", "name", "in", "rcParams", "[", "'colors.cmaps'", "]", ":", "colors", "=", "rcParams", "[", "'colors.cmaps'", "]", "[", "name", "]", "lut", "=", "lut", "or", "len", "(", "colors"...
Returns the specified colormap. Parameters ---------- name: str or :class:`matplotlib.colors.Colormap` If a colormap, it returned unchanged. %(cmap_note)s lut: int An integer giving the number of entries desired in the lookup table Returns ------- matplotlib.colors....
[ "Returns", "the", "specified", "colormap", "." ]
7d916406a6d3c3c27c0b7102f98fef07a4da0a61
https://github.com/Chilipp/psy-simple/blob/7d916406a6d3c3c27c0b7102f98fef07a4da0a61/psy_simple/colors.py#L155-L198
37,967
Chilipp/psy-simple
psy_simple/colors.py
_get_cmaps
def _get_cmaps(names): """Filter the given `names` for colormaps""" import matplotlib.pyplot as plt available_cmaps = list( chain(plt.cm.cmap_d, _cmapnames, rcParams['colors.cmaps'])) names = list(names) wrongs = [] for arg in (arg for arg in names if (not isinstance(arg, Colormap) and ...
python
def _get_cmaps(names): """Filter the given `names` for colormaps""" import matplotlib.pyplot as plt available_cmaps = list( chain(plt.cm.cmap_d, _cmapnames, rcParams['colors.cmaps'])) names = list(names) wrongs = [] for arg in (arg for arg in names if (not isinstance(arg, Colormap) and ...
[ "def", "_get_cmaps", "(", "names", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "available_cmaps", "=", "list", "(", "chain", "(", "plt", ".", "cm", ".", "cmap_d", ",", "_cmapnames", ",", "rcParams", "[", "'colors.cmaps'", "]", ")", ")",...
Filter the given `names` for colormaps
[ "Filter", "the", "given", "names", "for", "colormaps" ]
7d916406a6d3c3c27c0b7102f98fef07a4da0a61
https://github.com/Chilipp/psy-simple/blob/7d916406a6d3c3c27c0b7102f98fef07a4da0a61/psy_simple/colors.py#L201-L222
37,968
Chilipp/psy-simple
psy_simple/colors.py
show_colormaps
def show_colormaps(names=[], N=10, show=True, use_qt=None): """Function to show standard colormaps from pyplot Parameters ---------- ``*args``: str or :class:`matplotlib.colors.Colormap` If a colormap, it returned unchanged. %(cmap_note)s N: int, optional Default: 11. The nu...
python
def show_colormaps(names=[], N=10, show=True, use_qt=None): """Function to show standard colormaps from pyplot Parameters ---------- ``*args``: str or :class:`matplotlib.colors.Colormap` If a colormap, it returned unchanged. %(cmap_note)s N: int, optional Default: 11. The nu...
[ "def", "show_colormaps", "(", "names", "=", "[", "]", ",", "N", "=", "10", ",", "show", "=", "True", ",", "use_qt", "=", "None", ")", ":", "names", "=", "safe_list", "(", "names", ")", "if", "use_qt", "or", "(", "use_qt", "is", "None", "and", "ps...
Function to show standard colormaps from pyplot Parameters ---------- ``*args``: str or :class:`matplotlib.colors.Colormap` If a colormap, it returned unchanged. %(cmap_note)s N: int, optional Default: 11. The number of increments in the colormap. show: bool, optional ...
[ "Function", "to", "show", "standard", "colormaps", "from", "pyplot" ]
7d916406a6d3c3c27c0b7102f98fef07a4da0a61
https://github.com/Chilipp/psy-simple/blob/7d916406a6d3c3c27c0b7102f98fef07a4da0a61/psy_simple/colors.py#L227-L284
37,969
toumorokoshi/sprinter
sprinter/next/script.py
_create_stdout_logger
def _create_stdout_logger(logging_level): """ create a logger to stdout. This creates logger for a series of module we would like to log information on. """ out_hdlr = logging.StreamHandler(sys.stdout) out_hdlr.setFormatter(logging.Formatter( '[%(asctime)s] %(message)s', "%H:%M:%S" )...
python
def _create_stdout_logger(logging_level): """ create a logger to stdout. This creates logger for a series of module we would like to log information on. """ out_hdlr = logging.StreamHandler(sys.stdout) out_hdlr.setFormatter(logging.Formatter( '[%(asctime)s] %(message)s', "%H:%M:%S" )...
[ "def", "_create_stdout_logger", "(", "logging_level", ")", ":", "out_hdlr", "=", "logging", ".", "StreamHandler", "(", "sys", ".", "stdout", ")", "out_hdlr", ".", "setFormatter", "(", "logging", ".", "Formatter", "(", "'[%(asctime)s] %(message)s'", ",", "\"%H:%M:%...
create a logger to stdout. This creates logger for a series of module we would like to log information on.
[ "create", "a", "logger", "to", "stdout", ".", "This", "creates", "logger", "for", "a", "series", "of", "module", "we", "would", "like", "to", "log", "information", "on", "." ]
846697a7a087e69c61d075232e754d6975a64152
https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/next/script.py#L62-L75
37,970
jkeyes/python-docraptor
example/async.py
main
def main(): """Generate a PDF using the async method.""" docraptor = DocRaptor() print("Create PDF") resp = docraptor.create( { "document_content": "<h1>python-docraptor</h1><p>Async Test</p>", "test": True, "async": True, } ) print("Status ID...
python
def main(): """Generate a PDF using the async method.""" docraptor = DocRaptor() print("Create PDF") resp = docraptor.create( { "document_content": "<h1>python-docraptor</h1><p>Async Test</p>", "test": True, "async": True, } ) print("Status ID...
[ "def", "main", "(", ")", ":", "docraptor", "=", "DocRaptor", "(", ")", "print", "(", "\"Create PDF\"", ")", "resp", "=", "docraptor", ".", "create", "(", "{", "\"document_content\"", ":", "\"<h1>python-docraptor</h1><p>Async Test</p>\"", ",", "\"test\"", ":", "T...
Generate a PDF using the async method.
[ "Generate", "a", "PDF", "using", "the", "async", "method", "." ]
4be5b641f92820539b2c42165fec9251a6603dea
https://github.com/jkeyes/python-docraptor/blob/4be5b641f92820539b2c42165fec9251a6603dea/example/async.py#L6-L32
37,971
smarie/python-parsyfiles
parsyfiles/type_inspection_tools.py
get_alternate_types_resolving_forwardref_union_and_typevar
def get_alternate_types_resolving_forwardref_union_and_typevar(typ, _memo: List[Any] = None) \ -> Tuple[Any, ...]: """ Returns a tuple of all alternate types allowed by the `typ` type annotation. If typ is a TypeVar, * if the typevar is bound, return get_alternate_types_resolving_forwardref_un...
python
def get_alternate_types_resolving_forwardref_union_and_typevar(typ, _memo: List[Any] = None) \ -> Tuple[Any, ...]: """ Returns a tuple of all alternate types allowed by the `typ` type annotation. If typ is a TypeVar, * if the typevar is bound, return get_alternate_types_resolving_forwardref_un...
[ "def", "get_alternate_types_resolving_forwardref_union_and_typevar", "(", "typ", ",", "_memo", ":", "List", "[", "Any", "]", "=", "None", ")", "->", "Tuple", "[", "Any", ",", "...", "]", ":", "# avoid infinite recursion by using a _memo", "_memo", "=", "_memo", "o...
Returns a tuple of all alternate types allowed by the `typ` type annotation. If typ is a TypeVar, * if the typevar is bound, return get_alternate_types_resolving_forwardref_union_and_typevar(bound) * if the typevar has constraints, return a tuple containing all the types listed in the constraints (with ...
[ "Returns", "a", "tuple", "of", "all", "alternate", "types", "allowed", "by", "the", "typ", "type", "annotation", "." ]
344b37e1151e8d4e7c2ee49ae09d6568715ae64e
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/type_inspection_tools.py#L22-L87
37,972
smarie/python-parsyfiles
parsyfiles/type_inspection_tools.py
robust_isinstance
def robust_isinstance(inst, typ) -> bool: """ Similar to isinstance, but if 'typ' is a parametrized generic Type, it is first transformed into its base generic class so that the instance check works. It is also robust to Union and Any. :param inst: :param typ: :return: """ if typ is Any...
python
def robust_isinstance(inst, typ) -> bool: """ Similar to isinstance, but if 'typ' is a parametrized generic Type, it is first transformed into its base generic class so that the instance check works. It is also robust to Union and Any. :param inst: :param typ: :return: """ if typ is Any...
[ "def", "robust_isinstance", "(", "inst", ",", "typ", ")", "->", "bool", ":", "if", "typ", "is", "Any", ":", "return", "True", "if", "is_typevar", "(", "typ", ")", ":", "if", "hasattr", "(", "typ", ",", "'__constraints__'", ")", "and", "typ", ".", "__...
Similar to isinstance, but if 'typ' is a parametrized generic Type, it is first transformed into its base generic class so that the instance check works. It is also robust to Union and Any. :param inst: :param typ: :return:
[ "Similar", "to", "isinstance", "but", "if", "typ", "is", "a", "parametrized", "generic", "Type", "it", "is", "first", "transformed", "into", "its", "base", "generic", "class", "so", "that", "the", "instance", "check", "works", ".", "It", "is", "also", "rob...
344b37e1151e8d4e7c2ee49ae09d6568715ae64e
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/type_inspection_tools.py#L90-L115
37,973
smarie/python-parsyfiles
parsyfiles/type_inspection_tools.py
eval_forward_ref
def eval_forward_ref(typ: _ForwardRef): """ Climbs the current stack until the given Forward reference has been resolved, or raises an InvalidForwardRefError :param typ: the forward reference to resolve :return: """ for frame in stack(): m = getmodule(frame[0]) m_name = m.__name...
python
def eval_forward_ref(typ: _ForwardRef): """ Climbs the current stack until the given Forward reference has been resolved, or raises an InvalidForwardRefError :param typ: the forward reference to resolve :return: """ for frame in stack(): m = getmodule(frame[0]) m_name = m.__name...
[ "def", "eval_forward_ref", "(", "typ", ":", "_ForwardRef", ")", ":", "for", "frame", "in", "stack", "(", ")", ":", "m", "=", "getmodule", "(", "frame", "[", "0", "]", ")", "m_name", "=", "m", ".", "__name__", "if", "m", "is", "not", "None", "else",...
Climbs the current stack until the given Forward reference has been resolved, or raises an InvalidForwardRefError :param typ: the forward reference to resolve :return:
[ "Climbs", "the", "current", "stack", "until", "the", "given", "Forward", "reference", "has", "been", "resolved", "or", "raises", "an", "InvalidForwardRefError" ]
344b37e1151e8d4e7c2ee49ae09d6568715ae64e
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/type_inspection_tools.py#L330-L347
37,974
smarie/python-parsyfiles
parsyfiles/type_inspection_tools.py
is_valid_pep484_type_hint
def is_valid_pep484_type_hint(typ_hint, allow_forward_refs: bool = False): """ Returns True if the provided type is a valid PEP484 type hint, False otherwise. Note: string type hints (forward references) are not supported by default, since callers of this function in parsyfiles lib actually require the...
python
def is_valid_pep484_type_hint(typ_hint, allow_forward_refs: bool = False): """ Returns True if the provided type is a valid PEP484 type hint, False otherwise. Note: string type hints (forward references) are not supported by default, since callers of this function in parsyfiles lib actually require the...
[ "def", "is_valid_pep484_type_hint", "(", "typ_hint", ",", "allow_forward_refs", ":", "bool", "=", "False", ")", ":", "# most common case first, to be faster", "try", ":", "if", "isinstance", "(", "typ_hint", ",", "type", ")", ":", "return", "True", "except", ":", ...
Returns True if the provided type is a valid PEP484 type hint, False otherwise. Note: string type hints (forward references) are not supported by default, since callers of this function in parsyfiles lib actually require them to be resolved already. :param typ_hint: :param allow_forward_refs: :ret...
[ "Returns", "True", "if", "the", "provided", "type", "is", "a", "valid", "PEP484", "type", "hint", "False", "otherwise", "." ]
344b37e1151e8d4e7c2ee49ae09d6568715ae64e
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/type_inspection_tools.py#L363-L392
37,975
smarie/python-parsyfiles
parsyfiles/type_inspection_tools.py
is_pep484_nonable
def is_pep484_nonable(typ): """ Checks if a given type is nonable, meaning that it explicitly or implicitly declares a Union with NoneType. Nested TypeVars and Unions are supported. :param typ: :return: """ # TODO rely on typing_inspect if there is an answer to https://github.com/ilevkivsky...
python
def is_pep484_nonable(typ): """ Checks if a given type is nonable, meaning that it explicitly or implicitly declares a Union with NoneType. Nested TypeVars and Unions are supported. :param typ: :return: """ # TODO rely on typing_inspect if there is an answer to https://github.com/ilevkivsky...
[ "def", "is_pep484_nonable", "(", "typ", ")", ":", "# TODO rely on typing_inspect if there is an answer to https://github.com/ilevkivskyi/typing_inspect/issues/14", "if", "typ", "is", "type", "(", "None", ")", ":", "return", "True", "elif", "is_typevar", "(", "typ", ")", "...
Checks if a given type is nonable, meaning that it explicitly or implicitly declares a Union with NoneType. Nested TypeVars and Unions are supported. :param typ: :return:
[ "Checks", "if", "a", "given", "type", "is", "nonable", "meaning", "that", "it", "explicitly", "or", "implicitly", "declares", "a", "Union", "with", "NoneType", ".", "Nested", "TypeVars", "and", "Unions", "are", "supported", "." ]
344b37e1151e8d4e7c2ee49ae09d6568715ae64e
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/type_inspection_tools.py#L395-L409
37,976
smarie/python-parsyfiles
parsyfiles/type_inspection_tools.py
InvalidPEP484TypeHint.create_for_collection_items
def create_for_collection_items(item_type, hint): """ Helper method for collection items :param item_type: :return: """ # this leads to infinite loops # try: # prt_type = get_pretty_type_str(item_type) # except: # prt_type = str(it...
python
def create_for_collection_items(item_type, hint): """ Helper method for collection items :param item_type: :return: """ # this leads to infinite loops # try: # prt_type = get_pretty_type_str(item_type) # except: # prt_type = str(it...
[ "def", "create_for_collection_items", "(", "item_type", ",", "hint", ")", ":", "# this leads to infinite loops", "# try:", "# prt_type = get_pretty_type_str(item_type)", "# except:", "# prt_type = str(item_type)", "return", "TypeInformationRequiredError", "(", "\"Cannot parse...
Helper method for collection items :param item_type: :return:
[ "Helper", "method", "for", "collection", "items" ]
344b37e1151e8d4e7c2ee49ae09d6568715ae64e
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/type_inspection_tools.py#L691-L706
37,977
smarie/python-parsyfiles
parsyfiles/type_inspection_tools.py
InvalidPEP484TypeHint.create_for_object_attributes
def create_for_object_attributes(item_type, faulty_attribute_name: str, hint): """ Helper method for constructor attributes :param item_type: :return: """ # this leads to infinite loops # try: # prt_type = get_pretty_type_str(item_type) # exce...
python
def create_for_object_attributes(item_type, faulty_attribute_name: str, hint): """ Helper method for constructor attributes :param item_type: :return: """ # this leads to infinite loops # try: # prt_type = get_pretty_type_str(item_type) # exce...
[ "def", "create_for_object_attributes", "(", "item_type", ",", "faulty_attribute_name", ":", "str", ",", "hint", ")", ":", "# this leads to infinite loops", "# try:", "# prt_type = get_pretty_type_str(item_type)", "# except:", "# prt_type = str(item_type)", "return", "Type...
Helper method for constructor attributes :param item_type: :return:
[ "Helper", "method", "for", "constructor", "attributes" ]
344b37e1151e8d4e7c2ee49ae09d6568715ae64e
https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/type_inspection_tools.py#L709-L723
37,978
martinrusev/solid-python
solidpy/handlers/django.py
SolidDjangoMiddleware.exception_class
def exception_class(self, exception): """Return a name representing the class of an exception.""" cls = type(exception) if cls.__module__ == 'exceptions': # Built-in exception. return cls.__name__ return "%s.%s" % (cls.__module__, cls.__name__)
python
def exception_class(self, exception): """Return a name representing the class of an exception.""" cls = type(exception) if cls.__module__ == 'exceptions': # Built-in exception. return cls.__name__ return "%s.%s" % (cls.__module__, cls.__name__)
[ "def", "exception_class", "(", "self", ",", "exception", ")", ":", "cls", "=", "type", "(", "exception", ")", "if", "cls", ".", "__module__", "==", "'exceptions'", ":", "# Built-in exception.", "return", "cls", ".", "__name__", "return", "\"%s.%s\"", "%", "(...
Return a name representing the class of an exception.
[ "Return", "a", "name", "representing", "the", "class", "of", "an", "exception", "." ]
c5c39ad43c19e6746ea0297e0d440a2fccfb25ed
https://github.com/martinrusev/solid-python/blob/c5c39ad43c19e6746ea0297e0d440a2fccfb25ed/solidpy/handlers/django.py#L27-L33
37,979
martinrusev/solid-python
solidpy/handlers/django.py
SolidDjangoMiddleware.request_info
def request_info(self, request): """ Return a dictionary of information for a given request. This will be run once for every request. """ # We have to re-resolve the request path here, because the information # is not stored on the request. view, args, kwargs = resolve(request.path) for i, arg in enu...
python
def request_info(self, request): """ Return a dictionary of information for a given request. This will be run once for every request. """ # We have to re-resolve the request path here, because the information # is not stored on the request. view, args, kwargs = resolve(request.path) for i, arg in enu...
[ "def", "request_info", "(", "self", ",", "request", ")", ":", "# We have to re-resolve the request path here, because the information", "# is not stored on the request.", "view", ",", "args", ",", "kwargs", "=", "resolve", "(", "request", ".", "path", ")", "for", "i", ...
Return a dictionary of information for a given request. This will be run once for every request.
[ "Return", "a", "dictionary", "of", "information", "for", "a", "given", "request", "." ]
c5c39ad43c19e6746ea0297e0d440a2fccfb25ed
https://github.com/martinrusev/solid-python/blob/c5c39ad43c19e6746ea0297e0d440a2fccfb25ed/solidpy/handlers/django.py#L35-L66
37,980
bioidiap/bob.ip.facedetect
bob/ip/facedetect/train/Bootstrap.py
Bootstrap._save
def _save(self, hdf5, model, positives, negatives): """Saves the given intermediate state of the bootstrapping to file.""" # write the model and the training set indices to the given HDF5 file hdf5.set("PositiveIndices", sorted(list(positives))) hdf5.set("NegativeIndices", sorted(list(negatives))) h...
python
def _save(self, hdf5, model, positives, negatives): """Saves the given intermediate state of the bootstrapping to file.""" # write the model and the training set indices to the given HDF5 file hdf5.set("PositiveIndices", sorted(list(positives))) hdf5.set("NegativeIndices", sorted(list(negatives))) h...
[ "def", "_save", "(", "self", ",", "hdf5", ",", "model", ",", "positives", ",", "negatives", ")", ":", "# write the model and the training set indices to the given HDF5 file", "hdf5", ".", "set", "(", "\"PositiveIndices\"", ",", "sorted", "(", "list", "(", "positives...
Saves the given intermediate state of the bootstrapping to file.
[ "Saves", "the", "given", "intermediate", "state", "of", "the", "bootstrapping", "to", "file", "." ]
601da5141ca7302ad36424d1421b33190ba46779
https://github.com/bioidiap/bob.ip.facedetect/blob/601da5141ca7302ad36424d1421b33190ba46779/bob/ip/facedetect/train/Bootstrap.py#L121-L129
37,981
bioidiap/bob.ip.facedetect
bob/ip/facedetect/train/Bootstrap.py
Bootstrap._load
def _load(self, hdf5): """Loads the intermediate state of the bootstrapping from file.""" positives = set(hdf5.get("PositiveIndices")) negatives = set(hdf5.get("NegativeIndices")) hdf5.cd("Model") model = bob.learn.boosting.BoostedMachine(hdf5) return model, positives, negatives
python
def _load(self, hdf5): """Loads the intermediate state of the bootstrapping from file.""" positives = set(hdf5.get("PositiveIndices")) negatives = set(hdf5.get("NegativeIndices")) hdf5.cd("Model") model = bob.learn.boosting.BoostedMachine(hdf5) return model, positives, negatives
[ "def", "_load", "(", "self", ",", "hdf5", ")", ":", "positives", "=", "set", "(", "hdf5", ".", "get", "(", "\"PositiveIndices\"", ")", ")", "negatives", "=", "set", "(", "hdf5", ".", "get", "(", "\"NegativeIndices\"", ")", ")", "hdf5", ".", "cd", "("...
Loads the intermediate state of the bootstrapping from file.
[ "Loads", "the", "intermediate", "state", "of", "the", "bootstrapping", "from", "file", "." ]
601da5141ca7302ad36424d1421b33190ba46779
https://github.com/bioidiap/bob.ip.facedetect/blob/601da5141ca7302ad36424d1421b33190ba46779/bob/ip/facedetect/train/Bootstrap.py#L132-L138
37,982
bniemczyk/automata
automata/VM.py
CodeBlock.undelay
def undelay(self): '''resolves all delayed arguments''' i = 0 while i < len(self): op = self[i] i += 1 if hasattr(op, 'arg1'): if isinstance(op.arg1,DelayedArg): op.arg1 = op.arg1.resolve() if isinst...
python
def undelay(self): '''resolves all delayed arguments''' i = 0 while i < len(self): op = self[i] i += 1 if hasattr(op, 'arg1'): if isinstance(op.arg1,DelayedArg): op.arg1 = op.arg1.resolve() if isinst...
[ "def", "undelay", "(", "self", ")", ":", "i", "=", "0", "while", "i", "<", "len", "(", "self", ")", ":", "op", "=", "self", "[", "i", "]", "i", "+=", "1", "if", "hasattr", "(", "op", ",", "'arg1'", ")", ":", "if", "isinstance", "(", "op", "...
resolves all delayed arguments
[ "resolves", "all", "delayed", "arguments" ]
b4e21ba8b881f2cb1a07a813a4011209a3f1e017
https://github.com/bniemczyk/automata/blob/b4e21ba8b881f2cb1a07a813a4011209a3f1e017/automata/VM.py#L126-L136
37,983
liam-middlebrook/csh_ldap
csh_ldap/__init__.py
CSHLDAP.get_directorship_heads
def get_directorship_heads(self, val): """Get the head of a directorship Arguments: val -- the cn of the directorship """ __ldap_group_ou__ = "cn=groups,cn=accounts,dc=csh,dc=rit,dc=edu" res = self.__con__.search_s( __ldap_group_ou__, ld...
python
def get_directorship_heads(self, val): """Get the head of a directorship Arguments: val -- the cn of the directorship """ __ldap_group_ou__ = "cn=groups,cn=accounts,dc=csh,dc=rit,dc=edu" res = self.__con__.search_s( __ldap_group_ou__, ld...
[ "def", "get_directorship_heads", "(", "self", ",", "val", ")", ":", "__ldap_group_ou__", "=", "\"cn=groups,cn=accounts,dc=csh,dc=rit,dc=edu\"", "res", "=", "self", ".", "__con__", ".", "search_s", "(", "__ldap_group_ou__", ",", "ldap", ".", "SCOPE_SUBTREE", ",", "\"...
Get the head of a directorship Arguments: val -- the cn of the directorship
[ "Get", "the", "head", "of", "a", "directorship" ]
90bd334a20e13c03af07bce4f104ad96baf620e4
https://github.com/liam-middlebrook/csh_ldap/blob/90bd334a20e13c03af07bce4f104ad96baf620e4/csh_ldap/__init__.py#L108-L135
37,984
liam-middlebrook/csh_ldap
csh_ldap/__init__.py
CSHLDAP.enqueue_mod
def enqueue_mod(self, dn, mod): """Enqueue a LDAP modification. Arguments: dn -- the distinguished name of the object to modify mod -- an ldap modfication entry to enqueue """ # mark for update if dn not in self.__pending_mod_dn__: self.__pending_mod_...
python
def enqueue_mod(self, dn, mod): """Enqueue a LDAP modification. Arguments: dn -- the distinguished name of the object to modify mod -- an ldap modfication entry to enqueue """ # mark for update if dn not in self.__pending_mod_dn__: self.__pending_mod_...
[ "def", "enqueue_mod", "(", "self", ",", "dn", ",", "mod", ")", ":", "# mark for update", "if", "dn", "not", "in", "self", ".", "__pending_mod_dn__", ":", "self", ".", "__pending_mod_dn__", ".", "append", "(", "dn", ")", "self", ".", "__mod_queue__", "[", ...
Enqueue a LDAP modification. Arguments: dn -- the distinguished name of the object to modify mod -- an ldap modfication entry to enqueue
[ "Enqueue", "a", "LDAP", "modification", "." ]
90bd334a20e13c03af07bce4f104ad96baf620e4
https://github.com/liam-middlebrook/csh_ldap/blob/90bd334a20e13c03af07bce4f104ad96baf620e4/csh_ldap/__init__.py#L137-L149
37,985
liam-middlebrook/csh_ldap
csh_ldap/__init__.py
CSHLDAP.flush_mod
def flush_mod(self): """Flush all pending LDAP modifications.""" for dn in self.__pending_mod_dn__: try: if self.__ro__: for mod in self.__mod_queue__[dn]: if mod[0] == ldap.MOD_DELETE: mod_str = "DELETE"...
python
def flush_mod(self): """Flush all pending LDAP modifications.""" for dn in self.__pending_mod_dn__: try: if self.__ro__: for mod in self.__mod_queue__[dn]: if mod[0] == ldap.MOD_DELETE: mod_str = "DELETE"...
[ "def", "flush_mod", "(", "self", ")", ":", "for", "dn", "in", "self", ".", "__pending_mod_dn__", ":", "try", ":", "if", "self", ".", "__ro__", ":", "for", "mod", "in", "self", ".", "__mod_queue__", "[", "dn", "]", ":", "if", "mod", "[", "0", "]", ...
Flush all pending LDAP modifications.
[ "Flush", "all", "pending", "LDAP", "modifications", "." ]
90bd334a20e13c03af07bce4f104ad96baf620e4
https://github.com/liam-middlebrook/csh_ldap/blob/90bd334a20e13c03af07bce4f104ad96baf620e4/csh_ldap/__init__.py#L151-L178
37,986
davidwtbuxton/notrequests
notrequests.py
detect_encoding
def detect_encoding(value): """Returns the character encoding for a JSON string.""" # https://tools.ietf.org/html/rfc4627#section-3 if six.PY2: null_pattern = tuple(bool(ord(char)) for char in value[:4]) else: null_pattern = tuple(bool(char) for char in value[:4]) encodings = { ...
python
def detect_encoding(value): """Returns the character encoding for a JSON string.""" # https://tools.ietf.org/html/rfc4627#section-3 if six.PY2: null_pattern = tuple(bool(ord(char)) for char in value[:4]) else: null_pattern = tuple(bool(char) for char in value[:4]) encodings = { ...
[ "def", "detect_encoding", "(", "value", ")", ":", "# https://tools.ietf.org/html/rfc4627#section-3", "if", "six", ".", "PY2", ":", "null_pattern", "=", "tuple", "(", "bool", "(", "ord", "(", "char", ")", ")", "for", "char", "in", "value", "[", ":", "4", "]...
Returns the character encoding for a JSON string.
[ "Returns", "the", "character", "encoding", "for", "a", "JSON", "string", "." ]
e48ee6107a58c2f373c33f78e3302608edeba7f3
https://github.com/davidwtbuxton/notrequests/blob/e48ee6107a58c2f373c33f78e3302608edeba7f3/notrequests.py#L193-L209
37,987
davidwtbuxton/notrequests
notrequests.py
_merge_params
def _merge_params(url, params): """Merge and encode query parameters with an URL.""" if isinstance(params, dict): params = list(params.items()) scheme, netloc, path, query, fragment = urllib.parse.urlsplit(url) url_params = urllib.parse.parse_qsl(query, keep_blank_values=True) url_params.ex...
python
def _merge_params(url, params): """Merge and encode query parameters with an URL.""" if isinstance(params, dict): params = list(params.items()) scheme, netloc, path, query, fragment = urllib.parse.urlsplit(url) url_params = urllib.parse.parse_qsl(query, keep_blank_values=True) url_params.ex...
[ "def", "_merge_params", "(", "url", ",", "params", ")", ":", "if", "isinstance", "(", "params", ",", "dict", ")", ":", "params", "=", "list", "(", "params", ".", "items", "(", ")", ")", "scheme", ",", "netloc", ",", "path", ",", "query", ",", "frag...
Merge and encode query parameters with an URL.
[ "Merge", "and", "encode", "query", "parameters", "with", "an", "URL", "." ]
e48ee6107a58c2f373c33f78e3302608edeba7f3
https://github.com/davidwtbuxton/notrequests/blob/e48ee6107a58c2f373c33f78e3302608edeba7f3/notrequests.py#L332-L343
37,988
davidwtbuxton/notrequests
notrequests.py
Response.json
def json(self, **kwargs): """Decodes response as JSON.""" encoding = detect_encoding(self.content[:4]) value = self.content.decode(encoding) return simplejson.loads(value, **kwargs)
python
def json(self, **kwargs): """Decodes response as JSON.""" encoding = detect_encoding(self.content[:4]) value = self.content.decode(encoding) return simplejson.loads(value, **kwargs)
[ "def", "json", "(", "self", ",", "*", "*", "kwargs", ")", ":", "encoding", "=", "detect_encoding", "(", "self", ".", "content", "[", ":", "4", "]", ")", "value", "=", "self", ".", "content", ".", "decode", "(", "encoding", ")", "return", "simplejson"...
Decodes response as JSON.
[ "Decodes", "response", "as", "JSON", "." ]
e48ee6107a58c2f373c33f78e3302608edeba7f3
https://github.com/davidwtbuxton/notrequests/blob/e48ee6107a58c2f373c33f78e3302608edeba7f3/notrequests.py#L121-L126
37,989
davidwtbuxton/notrequests
notrequests.py
Response.raise_for_status
def raise_for_status(self): """Raises HTTPError if the request got an error.""" if 400 <= self.status_code < 600: message = 'Error %s for %s' % (self.status_code, self.url) raise HTTPError(message)
python
def raise_for_status(self): """Raises HTTPError if the request got an error.""" if 400 <= self.status_code < 600: message = 'Error %s for %s' % (self.status_code, self.url) raise HTTPError(message)
[ "def", "raise_for_status", "(", "self", ")", ":", "if", "400", "<=", "self", ".", "status_code", "<", "600", ":", "message", "=", "'Error %s for %s'", "%", "(", "self", ".", "status_code", ",", "self", ".", "url", ")", "raise", "HTTPError", "(", "message...
Raises HTTPError if the request got an error.
[ "Raises", "HTTPError", "if", "the", "request", "got", "an", "error", "." ]
e48ee6107a58c2f373c33f78e3302608edeba7f3
https://github.com/davidwtbuxton/notrequests/blob/e48ee6107a58c2f373c33f78e3302608edeba7f3/notrequests.py#L173-L177
37,990
wearpants/instrument
instrument/output/_numpy.py
NumpyMetric.metric
def metric(cls, name, count, elapsed): """A metric function that buffers through numpy :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds """ if name is None: warnings.warn("Ignoring unnamed metric", stackle...
python
def metric(cls, name, count, elapsed): """A metric function that buffers through numpy :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds """ if name is None: warnings.warn("Ignoring unnamed metric", stackle...
[ "def", "metric", "(", "cls", ",", "name", ",", "count", ",", "elapsed", ")", ":", "if", "name", "is", "None", ":", "warnings", ".", "warn", "(", "\"Ignoring unnamed metric\"", ",", "stacklevel", "=", "3", ")", "return", "with", "cls", ".", "lock", ":",...
A metric function that buffers through numpy :arg str name: name of the metric :arg int count: number of items :arg float elapsed: time in seconds
[ "A", "metric", "function", "that", "buffers", "through", "numpy" ]
a0f6103574ab58a82361a951e5e56b69aedfe294
https://github.com/wearpants/instrument/blob/a0f6103574ab58a82361a951e5e56b69aedfe294/instrument/output/_numpy.py#L38-L60
37,991
wearpants/instrument
instrument/output/_numpy.py
NumpyMetric._dump
def _dump(self): """dump data for an individual metric. For internal use only.""" try: self.temp.seek(0) # seek to beginning arr = np.fromfile(self.temp, self.dtype) self.count_arr = arr['count'] self.elapsed_arr = arr['elapsed'] if self.calc...
python
def _dump(self): """dump data for an individual metric. For internal use only.""" try: self.temp.seek(0) # seek to beginning arr = np.fromfile(self.temp, self.dtype) self.count_arr = arr['count'] self.elapsed_arr = arr['elapsed'] if self.calc...
[ "def", "_dump", "(", "self", ")", ":", "try", ":", "self", ".", "temp", ".", "seek", "(", "0", ")", "# seek to beginning", "arr", "=", "np", ".", "fromfile", "(", "self", ".", "temp", ",", "self", ".", "dtype", ")", "self", ".", "count_arr", "=", ...
dump data for an individual metric. For internal use only.
[ "dump", "data", "for", "an", "individual", "metric", ".", "For", "internal", "use", "only", "." ]
a0f6103574ab58a82361a951e5e56b69aedfe294
https://github.com/wearpants/instrument/blob/a0f6103574ab58a82361a951e5e56b69aedfe294/instrument/output/_numpy.py#L76-L95
37,992
KvasirSecurity/kvasirapi-python
KvasirAPI/jsonrpc/vulns.py
Vulns.list
def list(self, host_rec=None, service_rec=None, hostfilter=None): """ Returns a list of vulnerabilities based on t_hosts.id or t_services.id. If neither are set then statistical results are added :param host_rec: db.t_hosts.id :param service_rec: db.t_services.id :param ...
python
def list(self, host_rec=None, service_rec=None, hostfilter=None): """ Returns a list of vulnerabilities based on t_hosts.id or t_services.id. If neither are set then statistical results are added :param host_rec: db.t_hosts.id :param service_rec: db.t_services.id :param ...
[ "def", "list", "(", "self", ",", "host_rec", "=", "None", ",", "service_rec", "=", "None", ",", "hostfilter", "=", "None", ")", ":", "return", "self", ".", "send", ".", "vuln_list", "(", "host_rec", ",", "service_rec", ",", "hostfilter", ")" ]
Returns a list of vulnerabilities based on t_hosts.id or t_services.id. If neither are set then statistical results are added :param host_rec: db.t_hosts.id :param service_rec: db.t_services.id :param hostfilter: Valid hostfilter or None :return: [(vulndata) ...] if host_rec or ...
[ "Returns", "a", "list", "of", "vulnerabilities", "based", "on", "t_hosts", ".", "id", "or", "t_services", ".", "id", ".", "If", "neither", "are", "set", "then", "statistical", "results", "are", "added" ]
ec8c5818bd5913f3afd150f25eaec6e7cc732f4c
https://github.com/KvasirSecurity/kvasirapi-python/blob/ec8c5818bd5913f3afd150f25eaec6e7cc732f4c/KvasirAPI/jsonrpc/vulns.py#L20-L31
37,993
KvasirSecurity/kvasirapi-python
KvasirAPI/jsonrpc/vulns.py
Vulns.ip_info
def ip_info(self, vuln_name=None, vuln_id=None, ip_list_only=True, hostfilter=None): """ List of all IP Addresses with a vulnerability :param vuln_name: t_vulndata.f_vulnid :param vuln_id: t_vulndata.id :param ip_list_only: IP List only (default) or rest of t_hosts fields ...
python
def ip_info(self, vuln_name=None, vuln_id=None, ip_list_only=True, hostfilter=None): """ List of all IP Addresses with a vulnerability :param vuln_name: t_vulndata.f_vulnid :param vuln_id: t_vulndata.id :param ip_list_only: IP List only (default) or rest of t_hosts fields ...
[ "def", "ip_info", "(", "self", ",", "vuln_name", "=", "None", ",", "vuln_id", "=", "None", ",", "ip_list_only", "=", "True", ",", "hostfilter", "=", "None", ")", ":", "return", "self", ".", "send", ".", "vuln_ip_info", "(", "vuln_name", ",", "vuln_id", ...
List of all IP Addresses with a vulnerability :param vuln_name: t_vulndata.f_vulnid :param vuln_id: t_vulndata.id :param ip_list_only: IP List only (default) or rest of t_hosts fields :param hostfilter: Valid hostfilter or none :return: [(ip, hostname) ...] or [(ip, hostname, t_...
[ "List", "of", "all", "IP", "Addresses", "with", "a", "vulnerability" ]
ec8c5818bd5913f3afd150f25eaec6e7cc732f4c
https://github.com/KvasirSecurity/kvasirapi-python/blob/ec8c5818bd5913f3afd150f25eaec6e7cc732f4c/KvasirAPI/jsonrpc/vulns.py#L43-L53
37,994
KvasirSecurity/kvasirapi-python
KvasirAPI/jsonrpc/vulns.py
Vulns.service_list
def service_list(self, vuln_name=None, vuln_id=None, hostfilter=None): """ Returns a dictionary of vulns with services and IP Addresses :param vuln_name: t_vulndata.f_vulnid :param vuln_id: t_vulndata.id :param hostfilter: Valid hostfilter or none :return: {'vuln-id': {'...
python
def service_list(self, vuln_name=None, vuln_id=None, hostfilter=None): """ Returns a dictionary of vulns with services and IP Addresses :param vuln_name: t_vulndata.f_vulnid :param vuln_id: t_vulndata.id :param hostfilter: Valid hostfilter or none :return: {'vuln-id': {'...
[ "def", "service_list", "(", "self", ",", "vuln_name", "=", "None", ",", "vuln_id", "=", "None", ",", "hostfilter", "=", "None", ")", ":", "return", "self", ".", "send", ".", "vuln_service_list", "(", "vuln_name", ",", "vuln_id", ",", "hostfilter", ")" ]
Returns a dictionary of vulns with services and IP Addresses :param vuln_name: t_vulndata.f_vulnid :param vuln_id: t_vulndata.id :param hostfilter: Valid hostfilter or none :return: {'vuln-id': {'port': [ ip, hostname ]} ...} ...
[ "Returns", "a", "dictionary", "of", "vulns", "with", "services", "and", "IP", "Addresses" ]
ec8c5818bd5913f3afd150f25eaec6e7cc732f4c
https://github.com/KvasirSecurity/kvasirapi-python/blob/ec8c5818bd5913f3afd150f25eaec6e7cc732f4c/KvasirAPI/jsonrpc/vulns.py#L55-L64
37,995
AoiKuiyuyou/AoikImportUtil-Python
src/aoikimportutil/aoikimportutil.py
import_name
def import_name(mod_name): """Import a module by module name. @param mod_name: module name. """ try: mod_obj_old = sys.modules[mod_name] except KeyError: mod_obj_old = None if mod_obj_old is not None: return mod_obj_old __import__(mod_name) mod_obj = sys.modul...
python
def import_name(mod_name): """Import a module by module name. @param mod_name: module name. """ try: mod_obj_old = sys.modules[mod_name] except KeyError: mod_obj_old = None if mod_obj_old is not None: return mod_obj_old __import__(mod_name) mod_obj = sys.modul...
[ "def", "import_name", "(", "mod_name", ")", ":", "try", ":", "mod_obj_old", "=", "sys", ".", "modules", "[", "mod_name", "]", "except", "KeyError", ":", "mod_obj_old", "=", "None", "if", "mod_obj_old", "is", "not", "None", ":", "return", "mod_obj_old", "__...
Import a module by module name. @param mod_name: module name.
[ "Import", "a", "module", "by", "module", "name", "." ]
c6711719f5190cec81c8f29b989fc7609175b403
https://github.com/AoiKuiyuyou/AoikImportUtil-Python/blob/c6711719f5190cec81c8f29b989fc7609175b403/src/aoikimportutil/aoikimportutil.py#L68-L85
37,996
AoiKuiyuyou/AoikImportUtil-Python
src/aoikimportutil/aoikimportutil.py
import_path
def import_path(mod_path, mod_name): """Import a module by module file path. @param mod_path: module file path. @param mod_name: module name. """ mod_code = open(mod_path).read() mod_obj = import_code( mod_code=mod_code, mod_name=mod_name, ) if not hasattr(mod_obj, '_...
python
def import_path(mod_path, mod_name): """Import a module by module file path. @param mod_path: module file path. @param mod_name: module name. """ mod_code = open(mod_path).read() mod_obj = import_code( mod_code=mod_code, mod_name=mod_name, ) if not hasattr(mod_obj, '_...
[ "def", "import_path", "(", "mod_path", ",", "mod_name", ")", ":", "mod_code", "=", "open", "(", "mod_path", ")", ".", "read", "(", ")", "mod_obj", "=", "import_code", "(", "mod_code", "=", "mod_code", ",", "mod_name", "=", "mod_name", ",", ")", "if", "...
Import a module by module file path. @param mod_path: module file path. @param mod_name: module name.
[ "Import", "a", "module", "by", "module", "file", "path", "." ]
c6711719f5190cec81c8f29b989fc7609175b403
https://github.com/AoiKuiyuyou/AoikImportUtil-Python/blob/c6711719f5190cec81c8f29b989fc7609175b403/src/aoikimportutil/aoikimportutil.py#L88-L105
37,997
AoiKuiyuyou/AoikImportUtil-Python
src/aoikimportutil/aoikimportutil.py
import_obj
def import_obj( uri, mod_name=None, mod_attr_sep='::', attr_chain_sep='.', retn_mod=False, ): """Load an object from a module. @param uri: an uri specifying which object to load. An `uri` consists of two parts: module URI and attribute chain, e.g. `a/b/c.py::x.y.z` or `a.b.c::x.y.z...
python
def import_obj( uri, mod_name=None, mod_attr_sep='::', attr_chain_sep='.', retn_mod=False, ): """Load an object from a module. @param uri: an uri specifying which object to load. An `uri` consists of two parts: module URI and attribute chain, e.g. `a/b/c.py::x.y.z` or `a.b.c::x.y.z...
[ "def", "import_obj", "(", "uri", ",", "mod_name", "=", "None", ",", "mod_attr_sep", "=", "'::'", ",", "attr_chain_sep", "=", "'.'", ",", "retn_mod", "=", "False", ",", ")", ":", "if", "mod_attr_sep", "is", "None", ":", "mod_attr_sep", "=", "'::'", "uri_p...
Load an object from a module. @param uri: an uri specifying which object to load. An `uri` consists of two parts: module URI and attribute chain, e.g. `a/b/c.py::x.y.z` or `a.b.c::x.y.z` # Module URI E.g. `a/b/c.py` or `a.b.c`. Can be either a module name or a file path. Whether it is a ...
[ "Load", "an", "object", "from", "a", "module", "." ]
c6711719f5190cec81c8f29b989fc7609175b403
https://github.com/AoiKuiyuyou/AoikImportUtil-Python/blob/c6711719f5190cec81c8f29b989fc7609175b403/src/aoikimportutil/aoikimportutil.py#L108-L176
37,998
AoiKuiyuyou/AoikImportUtil-Python
src/aoikimportutil/aoikimportutil.py
add_to_sys_modules
def add_to_sys_modules(mod_name, mod_obj=None): """Add a module object to `sys.modules`. @param mod_name: module name, used as key to `sys.modules`. If `mod_name` is `a.b.c` while modules `a` and `a.b` are not existing, empty modules will be created for `a` and `a.b` as well. @param mod_obj: a mod...
python
def add_to_sys_modules(mod_name, mod_obj=None): """Add a module object to `sys.modules`. @param mod_name: module name, used as key to `sys.modules`. If `mod_name` is `a.b.c` while modules `a` and `a.b` are not existing, empty modules will be created for `a` and `a.b` as well. @param mod_obj: a mod...
[ "def", "add_to_sys_modules", "(", "mod_name", ",", "mod_obj", "=", "None", ")", ":", "mod_snames", "=", "mod_name", ".", "split", "(", "'.'", ")", "parent_mod_name", "=", "''", "parent_mod_obj", "=", "None", "for", "mod_sname", "in", "mod_snames", ":", "if",...
Add a module object to `sys.modules`. @param mod_name: module name, used as key to `sys.modules`. If `mod_name` is `a.b.c` while modules `a` and `a.b` are not existing, empty modules will be created for `a` and `a.b` as well. @param mod_obj: a module object. If None, an empty module object will be...
[ "Add", "a", "module", "object", "to", "sys", ".", "modules", "." ]
c6711719f5190cec81c8f29b989fc7609175b403
https://github.com/AoiKuiyuyou/AoikImportUtil-Python/blob/c6711719f5190cec81c8f29b989fc7609175b403/src/aoikimportutil/aoikimportutil.py#L179-L216
37,999
martinrusev/solid-python
solidpy/utils/wsgi.py
get_host
def get_host(environ): """Return the real host for the given WSGI environment. This takes care of the `X-Forwarded-Host` header. :param environ: the WSGI environment to get the host of. """ scheme = environ.get('wsgi.url_scheme') if 'HTTP_X_FORWARDED_HOST' in environ: result = environ[...
python
def get_host(environ): """Return the real host for the given WSGI environment. This takes care of the `X-Forwarded-Host` header. :param environ: the WSGI environment to get the host of. """ scheme = environ.get('wsgi.url_scheme') if 'HTTP_X_FORWARDED_HOST' in environ: result = environ[...
[ "def", "get_host", "(", "environ", ")", ":", "scheme", "=", "environ", ".", "get", "(", "'wsgi.url_scheme'", ")", "if", "'HTTP_X_FORWARDED_HOST'", "in", "environ", ":", "result", "=", "environ", "[", "'HTTP_X_FORWARDED_HOST'", "]", "elif", "'HTTP_HOST'", "in", ...
Return the real host for the given WSGI environment. This takes care of the `X-Forwarded-Host` header. :param environ: the WSGI environment to get the host of.
[ "Return", "the", "real", "host", "for", "the", "given", "WSGI", "environment", ".", "This", "takes", "care", "of", "the", "X", "-", "Forwarded", "-", "Host", "header", "." ]
c5c39ad43c19e6746ea0297e0d440a2fccfb25ed
https://github.com/martinrusev/solid-python/blob/c5c39ad43c19e6746ea0297e0d440a2fccfb25ed/solidpy/utils/wsgi.py#L25-L45