partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
EnvironmentKernelSpecManager.find_kernel_specs
Returns a dict mapping kernel names to resource directories.
environment_kernels/core.py
def find_kernel_specs(self): """Returns a dict mapping kernel names to resource directories.""" # let real installed kernels overwrite envs with the same name: # this is the same order as the get_kernel_spec way, which also prefers # kernels from the jupyter dir over env kernels. ...
def find_kernel_specs(self): """Returns a dict mapping kernel names to resource directories.""" # let real installed kernels overwrite envs with the same name: # this is the same order as the get_kernel_spec way, which also prefers # kernels from the jupyter dir over env kernels. ...
[ "Returns", "a", "dict", "mapping", "kernel", "names", "to", "resource", "directories", "." ]
Cadair/jupyter_environment_kernels
python
https://github.com/Cadair/jupyter_environment_kernels/blob/3da304550b511bda7d5d39280379b5ca39bb31bc/environment_kernels/core.py#L187-L195
[ "def", "find_kernel_specs", "(", "self", ")", ":", "# let real installed kernels overwrite envs with the same name:", "# this is the same order as the get_kernel_spec way, which also prefers", "# kernels from the jupyter dir over env kernels.", "specs", "=", "self", ".", "find_kernel_specs...
3da304550b511bda7d5d39280379b5ca39bb31bc
train
EnvironmentKernelSpecManager.get_all_specs
Returns a dict mapping kernel names and resource directories.
environment_kernels/core.py
def get_all_specs(self): """Returns a dict mapping kernel names and resource directories. """ # This is new in 4.1 -> https://github.com/jupyter/jupyter_client/pull/93 specs = self.get_all_kernel_specs_for_envs() specs.update(super(EnvironmentKernelSpecManager, self).get_all_spec...
def get_all_specs(self): """Returns a dict mapping kernel names and resource directories. """ # This is new in 4.1 -> https://github.com/jupyter/jupyter_client/pull/93 specs = self.get_all_kernel_specs_for_envs() specs.update(super(EnvironmentKernelSpecManager, self).get_all_spec...
[ "Returns", "a", "dict", "mapping", "kernel", "names", "and", "resource", "directories", "." ]
Cadair/jupyter_environment_kernels
python
https://github.com/Cadair/jupyter_environment_kernels/blob/3da304550b511bda7d5d39280379b5ca39bb31bc/environment_kernels/core.py#L197-L203
[ "def", "get_all_specs", "(", "self", ")", ":", "# This is new in 4.1 -> https://github.com/jupyter/jupyter_client/pull/93", "specs", "=", "self", ".", "get_all_kernel_specs_for_envs", "(", ")", "specs", ".", "update", "(", "super", "(", "EnvironmentKernelSpecManager", ",", ...
3da304550b511bda7d5d39280379b5ca39bb31bc
train
EnvironmentKernelSpecManager.get_kernel_spec
Returns a :class:`KernelSpec` instance for the given kernel_name. Raises :exc:`NoSuchKernel` if the given kernel name is not found.
environment_kernels/core.py
def get_kernel_spec(self, kernel_name): """Returns a :class:`KernelSpec` instance for the given kernel_name. Raises :exc:`NoSuchKernel` if the given kernel name is not found. """ try: return super(EnvironmentKernelSpecManager, self).get_kernel_spec(k...
def get_kernel_spec(self, kernel_name): """Returns a :class:`KernelSpec` instance for the given kernel_name. Raises :exc:`NoSuchKernel` if the given kernel name is not found. """ try: return super(EnvironmentKernelSpecManager, self).get_kernel_spec(k...
[ "Returns", "a", ":", "class", ":", "KernelSpec", "instance", "for", "the", "given", "kernel_name", "." ]
Cadair/jupyter_environment_kernels
python
https://github.com/Cadair/jupyter_environment_kernels/blob/3da304550b511bda7d5d39280379b5ca39bb31bc/environment_kernels/core.py#L205-L219
[ "def", "get_kernel_spec", "(", "self", ",", "kernel_name", ")", ":", "try", ":", "return", "super", "(", "EnvironmentKernelSpecManager", ",", "self", ")", ".", "get_kernel_spec", "(", "kernel_name", ")", "except", "(", "NoSuchKernel", ",", "FileNotFoundError", "...
3da304550b511bda7d5d39280379b5ca39bb31bc
train
to_latin
Transliterate serbian cyrillic string of characters to latin string of characters. :param string_to_transliterate: The cyrillic string to transliterate into latin characters. :param lang_code: Indicates the cyrillic language code we are translating from. Defaults to Serbian (sr). :return: A string of latin ...
cyrtranslit/__init__.py
def to_latin(string_to_transliterate, lang_code='sr'): ''' Transliterate serbian cyrillic string of characters to latin string of characters. :param string_to_transliterate: The cyrillic string to transliterate into latin characters. :param lang_code: Indicates the cyrillic language code we are translating ...
def to_latin(string_to_transliterate, lang_code='sr'): ''' Transliterate serbian cyrillic string of characters to latin string of characters. :param string_to_transliterate: The cyrillic string to transliterate into latin characters. :param lang_code: Indicates the cyrillic language code we are translating ...
[ "Transliterate", "serbian", "cyrillic", "string", "of", "characters", "to", "latin", "string", "of", "characters", ".", ":", "param", "string_to_transliterate", ":", "The", "cyrillic", "string", "to", "transliterate", "into", "latin", "characters", ".", ":", "para...
opendatakosovo/cyrillic-transliteration
python
https://github.com/opendatakosovo/cyrillic-transliteration/blob/84dad6208759d1dc540161e28414026d0e2908f6/cyrtranslit/__init__.py#L17-L59
[ "def", "to_latin", "(", "string_to_transliterate", ",", "lang_code", "=", "'sr'", ")", ":", "# First check if we support the cyrillic alphabet we want to transliterate to latin.", "if", "lang_code", ".", "lower", "(", ")", "not", "in", "TRANSLIT_DICT", ":", "# If we don't s...
84dad6208759d1dc540161e28414026d0e2908f6
train
to_cyrillic
Transliterate serbian latin string of characters to cyrillic string of characters. :param string_to_transliterate: The latin string to transliterate into cyrillic characters. :param lang_code: Indicates the cyrillic language code we are translating to. Defaults to Serbian (sr). :return: A string of cyrillic...
cyrtranslit/__init__.py
def to_cyrillic(string_to_transliterate, lang_code='sr'): ''' Transliterate serbian latin string of characters to cyrillic string of characters. :param string_to_transliterate: The latin string to transliterate into cyrillic characters. :param lang_code: Indicates the cyrillic language code we are translati...
def to_cyrillic(string_to_transliterate, lang_code='sr'): ''' Transliterate serbian latin string of characters to cyrillic string of characters. :param string_to_transliterate: The latin string to transliterate into cyrillic characters. :param lang_code: Indicates the cyrillic language code we are translati...
[ "Transliterate", "serbian", "latin", "string", "of", "characters", "to", "cyrillic", "string", "of", "characters", ".", ":", "param", "string_to_transliterate", ":", "The", "latin", "string", "to", "transliterate", "into", "cyrillic", "characters", ".", ":", "para...
opendatakosovo/cyrillic-transliteration
python
https://github.com/opendatakosovo/cyrillic-transliteration/blob/84dad6208759d1dc540161e28414026d0e2908f6/cyrtranslit/__init__.py#L62-L137
[ "def", "to_cyrillic", "(", "string_to_transliterate", ",", "lang_code", "=", "'sr'", ")", ":", "# First check if we support the cyrillic alphabet we want to transliterate to latin.", "if", "lang_code", ".", "lower", "(", ")", "not", "in", "TRANSLIT_DICT", ":", "# If we don'...
84dad6208759d1dc540161e28414026d0e2908f6
train
XMLParser.parse
Parses the incoming bytestream as XML and returns the resulting data.
rest_framework_xml/parsers.py
def parse(self, stream, media_type=None, parser_context=None): """ Parses the incoming bytestream as XML and returns the resulting data. """ assert etree, 'XMLParser requires defusedxml to be installed' parser_context = parser_context or {} encoding = parser_context.get(...
def parse(self, stream, media_type=None, parser_context=None): """ Parses the incoming bytestream as XML and returns the resulting data. """ assert etree, 'XMLParser requires defusedxml to be installed' parser_context = parser_context or {} encoding = parser_context.get(...
[ "Parses", "the", "incoming", "bytestream", "as", "XML", "and", "returns", "the", "resulting", "data", "." ]
jpadilla/django-rest-framework-xml
python
https://github.com/jpadilla/django-rest-framework-xml/blob/71c2f88b40c80ffd5029022147a57cc7341ef013/rest_framework_xml/parsers.py#L23-L38
[ "def", "parse", "(", "self", ",", "stream", ",", "media_type", "=", "None", ",", "parser_context", "=", "None", ")", ":", "assert", "etree", ",", "'XMLParser requires defusedxml to be installed'", "parser_context", "=", "parser_context", "or", "{", "}", "encoding"...
71c2f88b40c80ffd5029022147a57cc7341ef013
train
XMLParser._xml_convert
convert the xml `element` into the corresponding python object
rest_framework_xml/parsers.py
def _xml_convert(self, element): """ convert the xml `element` into the corresponding python object """ children = list(element) if len(children) == 0: return self._type_convert(element.text) else: # if the fist child tag is list-item means all c...
def _xml_convert(self, element): """ convert the xml `element` into the corresponding python object """ children = list(element) if len(children) == 0: return self._type_convert(element.text) else: # if the fist child tag is list-item means all c...
[ "convert", "the", "xml", "element", "into", "the", "corresponding", "python", "object" ]
jpadilla/django-rest-framework-xml
python
https://github.com/jpadilla/django-rest-framework-xml/blob/71c2f88b40c80ffd5029022147a57cc7341ef013/rest_framework_xml/parsers.py#L40-L60
[ "def", "_xml_convert", "(", "self", ",", "element", ")", ":", "children", "=", "list", "(", "element", ")", "if", "len", "(", "children", ")", "==", "0", ":", "return", "self", ".", "_type_convert", "(", "element", ".", "text", ")", "else", ":", "# i...
71c2f88b40c80ffd5029022147a57cc7341ef013
train
XMLParser._type_convert
Converts the value returned by the XMl parse into the equivalent Python type
rest_framework_xml/parsers.py
def _type_convert(self, value): """ Converts the value returned by the XMl parse into the equivalent Python type """ if value is None: return value try: return datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S') except ValueError: ...
def _type_convert(self, value): """ Converts the value returned by the XMl parse into the equivalent Python type """ if value is None: return value try: return datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S') except ValueError: ...
[ "Converts", "the", "value", "returned", "by", "the", "XMl", "parse", "into", "the", "equivalent", "Python", "type" ]
jpadilla/django-rest-framework-xml
python
https://github.com/jpadilla/django-rest-framework-xml/blob/71c2f88b40c80ffd5029022147a57cc7341ef013/rest_framework_xml/parsers.py#L62-L85
[ "def", "_type_convert", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "value", "try", ":", "return", "datetime", ".", "datetime", ".", "strptime", "(", "value", ",", "'%Y-%m-%d %H:%M:%S'", ")", "except", "ValueError", ":"...
71c2f88b40c80ffd5029022147a57cc7341ef013
train
XMLRenderer.render
Renders `data` into serialized XML.
rest_framework_xml/renderers.py
def render(self, data, accepted_media_type=None, renderer_context=None): """ Renders `data` into serialized XML. """ if data is None: return '' stream = StringIO() xml = SimplerXMLGenerator(stream, self.charset) xml.startDocument() xml.startE...
def render(self, data, accepted_media_type=None, renderer_context=None): """ Renders `data` into serialized XML. """ if data is None: return '' stream = StringIO() xml = SimplerXMLGenerator(stream, self.charset) xml.startDocument() xml.startE...
[ "Renders", "data", "into", "serialized", "XML", "." ]
jpadilla/django-rest-framework-xml
python
https://github.com/jpadilla/django-rest-framework-xml/blob/71c2f88b40c80ffd5029022147a57cc7341ef013/rest_framework_xml/renderers.py#L24-L41
[ "def", "render", "(", "self", ",", "data", ",", "accepted_media_type", "=", "None", ",", "renderer_context", "=", "None", ")", ":", "if", "data", "is", "None", ":", "return", "''", "stream", "=", "StringIO", "(", ")", "xml", "=", "SimplerXMLGenerator", "...
71c2f88b40c80ffd5029022147a57cc7341ef013
train
IOSDriver.open
Open a connection to the device.
napalm_ios/ios.py
def open(self): """Open a connection to the device.""" device_type = 'cisco_ios' if self.transport == 'telnet': device_type = 'cisco_ios_telnet' self.device = ConnectHandler(device_type=device_type, host=self.hostname, ...
def open(self): """Open a connection to the device.""" device_type = 'cisco_ios' if self.transport == 'telnet': device_type = 'cisco_ios_telnet' self.device = ConnectHandler(device_type=device_type, host=self.hostname, ...
[ "Open", "a", "connection", "to", "the", "device", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L131-L142
[ "def", "open", "(", "self", ")", ":", "device_type", "=", "'cisco_ios'", "if", "self", ".", "transport", "==", "'telnet'", ":", "device_type", "=", "'cisco_ios_telnet'", "self", ".", "device", "=", "ConnectHandler", "(", "device_type", "=", "device_type", ",",...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver._create_tmp_file
Write temp file and for use with inline config and SCP.
napalm_ios/ios.py
def _create_tmp_file(config): """Write temp file and for use with inline config and SCP.""" tmp_dir = tempfile.gettempdir() rand_fname = py23_compat.text_type(uuid.uuid4()) filename = os.path.join(tmp_dir, rand_fname) with open(filename, 'wt') as fobj: fobj.write(conf...
def _create_tmp_file(config): """Write temp file and for use with inline config and SCP.""" tmp_dir = tempfile.gettempdir() rand_fname = py23_compat.text_type(uuid.uuid4()) filename = os.path.join(tmp_dir, rand_fname) with open(filename, 'wt') as fobj: fobj.write(conf...
[ "Write", "temp", "file", "and", "for", "use", "with", "inline", "config", "and", "SCP", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L201-L208
[ "def", "_create_tmp_file", "(", "config", ")", ":", "tmp_dir", "=", "tempfile", ".", "gettempdir", "(", ")", "rand_fname", "=", "py23_compat", ".", "text_type", "(", "uuid", ".", "uuid4", "(", ")", ")", "filename", "=", "os", ".", "path", ".", "join", ...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver._load_candidate_wrapper
Transfer file to remote device for either merge or replace operations Returns (return_status, msg)
napalm_ios/ios.py
def _load_candidate_wrapper(self, source_file=None, source_config=None, dest_file=None, file_system=None): """ Transfer file to remote device for either merge or replace operations Returns (return_status, msg) """ return_status = False msg...
def _load_candidate_wrapper(self, source_file=None, source_config=None, dest_file=None, file_system=None): """ Transfer file to remote device for either merge or replace operations Returns (return_status, msg) """ return_status = False msg...
[ "Transfer", "file", "to", "remote", "device", "for", "either", "merge", "or", "replace", "operations" ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L210-L245
[ "def", "_load_candidate_wrapper", "(", "self", ",", "source_file", "=", "None", ",", "source_config", "=", "None", ",", "dest_file", "=", "None", ",", "file_system", "=", "None", ")", ":", "return_status", "=", "False", "msg", "=", "''", "if", "source_file",...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.load_replace_candidate
SCP file to device filesystem, defaults to candidate_config. Return None or raise exception
napalm_ios/ios.py
def load_replace_candidate(self, filename=None, config=None): """ SCP file to device filesystem, defaults to candidate_config. Return None or raise exception """ self.config_replace = True return_status, msg = self._load_candidate_wrapper(source_file=filename, ...
def load_replace_candidate(self, filename=None, config=None): """ SCP file to device filesystem, defaults to candidate_config. Return None or raise exception """ self.config_replace = True return_status, msg = self._load_candidate_wrapper(source_file=filename, ...
[ "SCP", "file", "to", "device", "filesystem", "defaults", "to", "candidate_config", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L247-L259
[ "def", "load_replace_candidate", "(", "self", ",", "filename", "=", "None", ",", "config", "=", "None", ")", ":", "self", ".", "config_replace", "=", "True", "return_status", ",", "msg", "=", "self", ".", "_load_candidate_wrapper", "(", "source_file", "=", "...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.load_merge_candidate
SCP file to remote device. Merge configuration in: copy <file> running-config
napalm_ios/ios.py
def load_merge_candidate(self, filename=None, config=None): """ SCP file to remote device. Merge configuration in: copy <file> running-config """ self.config_replace = False return_status, msg = self._load_candidate_wrapper(source_file=filename, ...
def load_merge_candidate(self, filename=None, config=None): """ SCP file to remote device. Merge configuration in: copy <file> running-config """ self.config_replace = False return_status, msg = self._load_candidate_wrapper(source_file=filename, ...
[ "SCP", "file", "to", "remote", "device", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L261-L273
[ "def", "load_merge_candidate", "(", "self", ",", "filename", "=", "None", ",", "config", "=", "None", ")", ":", "self", ".", "config_replace", "=", "False", "return_status", ",", "msg", "=", "self", ".", "_load_candidate_wrapper", "(", "source_file", "=", "f...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver._commit_hostname_handler
Special handler for hostname change on commit operation.
napalm_ios/ios.py
def _commit_hostname_handler(self, cmd): """Special handler for hostname change on commit operation.""" current_prompt = self.device.find_prompt().strip() terminating_char = current_prompt[-1] pattern = r"[>#{}]\s*$".format(terminating_char) # Look exclusively for trailing patter...
def _commit_hostname_handler(self, cmd): """Special handler for hostname change on commit operation.""" current_prompt = self.device.find_prompt().strip() terminating_char = current_prompt[-1] pattern = r"[>#{}]\s*$".format(terminating_char) # Look exclusively for trailing patter...
[ "Special", "handler", "for", "hostname", "change", "on", "commit", "operation", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L378-L387
[ "def", "_commit_hostname_handler", "(", "self", ",", "cmd", ")", ":", "current_prompt", "=", "self", ".", "device", ".", "find_prompt", "(", ")", ".", "strip", "(", ")", "terminating_char", "=", "current_prompt", "[", "-", "1", "]", "pattern", "=", "r\"[>#...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.commit_config
If replacement operation, perform 'configure replace' for the entire config. If merge operation, perform copy <file> running-config.
napalm_ios/ios.py
def commit_config(self): """ If replacement operation, perform 'configure replace' for the entire config. If merge operation, perform copy <file> running-config. """ # Always generate a rollback config on commit self._gen_rollback_cfg() if self.config_replace: ...
def commit_config(self): """ If replacement operation, perform 'configure replace' for the entire config. If merge operation, perform copy <file> running-config. """ # Always generate a rollback config on commit self._gen_rollback_cfg() if self.config_replace: ...
[ "If", "replacement", "operation", "perform", "configure", "replace", "for", "the", "entire", "config", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L389-L434
[ "def", "commit_config", "(", "self", ")", ":", "# Always generate a rollback config on commit", "self", ".", "_gen_rollback_cfg", "(", ")", "if", "self", ".", "config_replace", ":", "# Replace operation", "filename", "=", "self", ".", "candidate_cfg", "cfg_file", "=",...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.discard_config
Set candidate_cfg to current running-config. Erase the merge_cfg file.
napalm_ios/ios.py
def discard_config(self): """Set candidate_cfg to current running-config. Erase the merge_cfg file.""" discard_candidate = 'copy running-config {}'.format(self._gen_full_path(self.candidate_cfg)) discard_merge = 'copy null: {}'.format(self._gen_full_path(self.merge_cfg)) self._disable_co...
def discard_config(self): """Set candidate_cfg to current running-config. Erase the merge_cfg file.""" discard_candidate = 'copy running-config {}'.format(self._gen_full_path(self.candidate_cfg)) discard_merge = 'copy null: {}'.format(self._gen_full_path(self.merge_cfg)) self._disable_co...
[ "Set", "candidate_cfg", "to", "current", "running", "-", "config", ".", "Erase", "the", "merge_cfg", "file", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L436-L443
[ "def", "discard_config", "(", "self", ")", ":", "discard_candidate", "=", "'copy running-config {}'", ".", "format", "(", "self", ".", "_gen_full_path", "(", "self", ".", "candidate_cfg", ")", ")", "discard_merge", "=", "'copy null: {}'", ".", "format", "(", "se...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver._xfer_file
Transfer file to remote device. By default, this will use Secure Copy if self.inline_transfer is set, then will use Netmiko InlineTransfer method to transfer inline using either SSH or telnet (plus TCL onbox). Return (status, msg) status = boolean msg = details on what ...
napalm_ios/ios.py
def _xfer_file(self, source_file=None, source_config=None, dest_file=None, file_system=None, TransferClass=FileTransfer): """Transfer file to remote device. By default, this will use Secure Copy if self.inline_transfer is set, then will use Netmiko InlineTransfer method to tr...
def _xfer_file(self, source_file=None, source_config=None, dest_file=None, file_system=None, TransferClass=FileTransfer): """Transfer file to remote device. By default, this will use Secure Copy if self.inline_transfer is set, then will use Netmiko InlineTransfer method to tr...
[ "Transfer", "file", "to", "remote", "device", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L485-L534
[ "def", "_xfer_file", "(", "self", ",", "source_file", "=", "None", ",", "source_config", "=", "None", ",", "dest_file", "=", "None", ",", "file_system", "=", "None", ",", "TransferClass", "=", "FileTransfer", ")", ":", "if", "not", "source_file", "and", "n...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver._gen_full_path
Generate full file path on remote device.
napalm_ios/ios.py
def _gen_full_path(self, filename, file_system=None): """Generate full file path on remote device.""" if file_system is None: return '{}/{}'.format(self.dest_file_system, filename) else: if ":" not in file_system: raise ValueError("Invalid file_system spec...
def _gen_full_path(self, filename, file_system=None): """Generate full file path on remote device.""" if file_system is None: return '{}/{}'.format(self.dest_file_system, filename) else: if ":" not in file_system: raise ValueError("Invalid file_system spec...
[ "Generate", "full", "file", "path", "on", "remote", "device", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L546-L553
[ "def", "_gen_full_path", "(", "self", ",", "filename", ",", "file_system", "=", "None", ")", ":", "if", "file_system", "is", "None", ":", "return", "'{}/{}'", ".", "format", "(", "self", ".", "dest_file_system", ",", "filename", ")", "else", ":", "if", "...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver._gen_rollback_cfg
Save a configuration that can be used for rollback.
napalm_ios/ios.py
def _gen_rollback_cfg(self): """Save a configuration that can be used for rollback.""" cfg_file = self._gen_full_path(self.rollback_cfg) cmd = 'copy running-config {}'.format(cfg_file) self._disable_confirm() self.device.send_command_expect(cmd) self._enable_confirm()
def _gen_rollback_cfg(self): """Save a configuration that can be used for rollback.""" cfg_file = self._gen_full_path(self.rollback_cfg) cmd = 'copy running-config {}'.format(cfg_file) self._disable_confirm() self.device.send_command_expect(cmd) self._enable_confirm()
[ "Save", "a", "configuration", "that", "can", "be", "used", "for", "rollback", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L555-L561
[ "def", "_gen_rollback_cfg", "(", "self", ")", ":", "cfg_file", "=", "self", ".", "_gen_full_path", "(", "self", ".", "rollback_cfg", ")", "cmd", "=", "'copy running-config {}'", ".", "format", "(", "cfg_file", ")", "self", ".", "_disable_confirm", "(", ")", ...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver._check_file_exists
Check that the file exists on remote device using full path. cfg_file is full path i.e. flash:/file_name For example # dir flash:/candidate_config.txt Directory of flash:/candidate_config.txt 33 -rw- 5592 Dec 18 2015 10:50:22 -08:00 candidate_config.txt retu...
napalm_ios/ios.py
def _check_file_exists(self, cfg_file): """ Check that the file exists on remote device using full path. cfg_file is full path i.e. flash:/file_name For example # dir flash:/candidate_config.txt Directory of flash:/candidate_config.txt 33 -rw- 5592 Dec...
def _check_file_exists(self, cfg_file): """ Check that the file exists on remote device using full path. cfg_file is full path i.e. flash:/file_name For example # dir flash:/candidate_config.txt Directory of flash:/candidate_config.txt 33 -rw- 5592 Dec...
[ "Check", "that", "the", "file", "exists", "on", "remote", "device", "using", "full", "path", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L563-L584
[ "def", "_check_file_exists", "(", "self", ",", "cfg_file", ")", ":", "cmd", "=", "'dir {}'", ".", "format", "(", "cfg_file", ")", "success_pattern", "=", "'Directory of {}'", ".", "format", "(", "cfg_file", ")", "output", "=", "self", ".", "device", ".", "...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver._expand_interface_name
Obtain the full interface name from the abbreviated name. Cache mappings in self.interface_map.
napalm_ios/ios.py
def _expand_interface_name(self, interface_brief): """ Obtain the full interface name from the abbreviated name. Cache mappings in self.interface_map. """ if self.interface_map.get(interface_brief): return self.interface_map.get(interface_brief) command = 'sh...
def _expand_interface_name(self, interface_brief): """ Obtain the full interface name from the abbreviated name. Cache mappings in self.interface_map. """ if self.interface_map.get(interface_brief): return self.interface_map.get(interface_brief) command = 'sh...
[ "Obtain", "the", "full", "interface", "name", "from", "the", "abbreviated", "name", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L586-L602
[ "def", "_expand_interface_name", "(", "self", ",", "interface_brief", ")", ":", "if", "self", ".", "interface_map", ".", "get", "(", "interface_brief", ")", ":", "return", "self", ".", "interface_map", ".", "get", "(", "interface_brief", ")", "command", "=", ...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.get_lldp_neighbors
IOS implementation of get_lldp_neighbors.
napalm_ios/ios.py
def get_lldp_neighbors(self): """IOS implementation of get_lldp_neighbors.""" lldp = {} command = 'show lldp neighbors' output = self._send_command(command) # Check if router supports the command if '% Invalid input' in output: return {} # Process th...
def get_lldp_neighbors(self): """IOS implementation of get_lldp_neighbors.""" lldp = {} command = 'show lldp neighbors' output = self._send_command(command) # Check if router supports the command if '% Invalid input' in output: return {} # Process th...
[ "IOS", "implementation", "of", "get_lldp_neighbors", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L690-L738
[ "def", "get_lldp_neighbors", "(", "self", ")", ":", "lldp", "=", "{", "}", "command", "=", "'show lldp neighbors'", "output", "=", "self", ".", "_send_command", "(", "command", ")", "# Check if router supports the command", "if", "'% Invalid input'", "in", "output",...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.get_lldp_neighbors_detail
IOS implementation of get_lldp_neighbors_detail. Calls get_lldp_neighbors.
napalm_ios/ios.py
def get_lldp_neighbors_detail(self, interface=''): """ IOS implementation of get_lldp_neighbors_detail. Calls get_lldp_neighbors. """ lldp = {} lldp_neighbors = self.get_lldp_neighbors() # Filter to specific interface if interface: lldp_data ...
def get_lldp_neighbors_detail(self, interface=''): """ IOS implementation of get_lldp_neighbors_detail. Calls get_lldp_neighbors. """ lldp = {} lldp_neighbors = self.get_lldp_neighbors() # Filter to specific interface if interface: lldp_data ...
[ "IOS", "implementation", "of", "get_lldp_neighbors_detail", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L773-L828
[ "def", "get_lldp_neighbors_detail", "(", "self", ",", "interface", "=", "''", ")", ":", "lldp", "=", "{", "}", "lldp_neighbors", "=", "self", ".", "get_lldp_neighbors", "(", ")", "# Filter to specific interface", "if", "interface", ":", "lldp_data", "=", "lldp_n...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.get_facts
Return a set of facts from the devices.
napalm_ios/ios.py
def get_facts(self): """Return a set of facts from the devices.""" # default values. vendor = u'Cisco' uptime = -1 serial_number, fqdn, os_version, hostname, domain_name = ('Unknown',) * 5 # obtain output from device show_ver = self._send_command('show version') ...
def get_facts(self): """Return a set of facts from the devices.""" # default values. vendor = u'Cisco' uptime = -1 serial_number, fqdn, os_version, hostname, domain_name = ('Unknown',) * 5 # obtain output from device show_ver = self._send_command('show version') ...
[ "Return", "a", "set", "of", "facts", "from", "the", "devices", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L858-L926
[ "def", "get_facts", "(", "self", ")", ":", "# default values.", "vendor", "=", "u'Cisco'", "uptime", "=", "-", "1", "serial_number", ",", "fqdn", ",", "os_version", ",", "hostname", ",", "domain_name", "=", "(", "'Unknown'", ",", ")", "*", "5", "# obtain o...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.get_interfaces
Get interface details. last_flapped is not implemented Example Output: { u'Vlan1': { 'description': u'N/A', 'is_enabled': True, 'is_up': True, 'last_flapped': -1.0, 'mac_address': u'a493.4cc1.67a7', ...
napalm_ios/ios.py
def get_interfaces(self): """ Get interface details. last_flapped is not implemented Example Output: { u'Vlan1': { 'description': u'N/A', 'is_enabled': True, 'is_up': True, 'last_flapped': -1.0, ...
def get_interfaces(self): """ Get interface details. last_flapped is not implemented Example Output: { u'Vlan1': { 'description': u'N/A', 'is_enabled': True, 'is_up': True, 'last_flapped': -1.0, ...
[ "Get", "interface", "details", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L928-L1023
[ "def", "get_interfaces", "(", "self", ")", ":", "# default values.", "last_flapped", "=", "-", "1.0", "command", "=", "'show interfaces'", "output", "=", "self", ".", "_send_command", "(", "command", ")", "interface", "=", "description", "=", "mac_address", "=",...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.get_interfaces_ip
Get interface ip details. Returns a dict of dicts Example Output: { u'FastEthernet8': { 'ipv4': { u'10.66.43.169': { 'prefix_length': 22}}}, u'Loopback555': { 'ipv4': { u'192.168.1.1': { 'prefix_length': 24}}, 'ipv6': { u'1::1': { ...
napalm_ios/ios.py
def get_interfaces_ip(self): """ Get interface ip details. Returns a dict of dicts Example Output: { u'FastEthernet8': { 'ipv4': { u'10.66.43.169': { 'prefix_length': 22}}}, u'Loopback555': { 'ipv4': { u'192.168.1.1': { 'prefix_length': 24}}, ...
def get_interfaces_ip(self): """ Get interface ip details. Returns a dict of dicts Example Output: { u'FastEthernet8': { 'ipv4': { u'10.66.43.169': { 'prefix_length': 22}}}, u'Loopback555': { 'ipv4': { u'192.168.1.1': { 'prefix_length': 24}}, ...
[ "Get", "interface", "ip", "details", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L1025-L1091
[ "def", "get_interfaces_ip", "(", "self", ")", ":", "interfaces", "=", "{", "}", "command", "=", "'show ip interface'", "show_ip_interface", "=", "self", ".", "_send_command", "(", "command", ")", "command", "=", "'show ipv6 interface'", "show_ipv6_interface", "=", ...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.bgp_time_conversion
Convert string time to seconds. Examples 00:14:23 00:13:40 00:00:21 00:00:13 00:00:49 1d11h 1d17h 1w0d 8w5d 1y28w never
napalm_ios/ios.py
def bgp_time_conversion(bgp_uptime): """ Convert string time to seconds. Examples 00:14:23 00:13:40 00:00:21 00:00:13 00:00:49 1d11h 1d17h 1w0d 8w5d 1y28w never """ bgp_uptime = bgp_uptime.st...
def bgp_time_conversion(bgp_uptime): """ Convert string time to seconds. Examples 00:14:23 00:13:40 00:00:21 00:00:13 00:00:49 1d11h 1d17h 1w0d 8w5d 1y28w never """ bgp_uptime = bgp_uptime.st...
[ "Convert", "string", "time", "to", "seconds", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L1094-L1141
[ "def", "bgp_time_conversion", "(", "bgp_uptime", ")", ":", "bgp_uptime", "=", "bgp_uptime", ".", "strip", "(", ")", "uptime_letters", "=", "set", "(", "[", "'w'", ",", "'h'", ",", "'d'", "]", ")", "if", "'never'", "in", "bgp_uptime", ":", "return", "-", ...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.get_bgp_neighbors
BGP neighbor information. Currently no VRF support. Supports both IPv4 and IPv6.
napalm_ios/ios.py
def get_bgp_neighbors(self): """BGP neighbor information. Currently no VRF support. Supports both IPv4 and IPv6. """ supported_afi = ['ipv4', 'ipv6'] bgp_neighbor_data = dict() bgp_neighbor_data['global'] = {} # get summary output from device cmd_bgp_al...
def get_bgp_neighbors(self): """BGP neighbor information. Currently no VRF support. Supports both IPv4 and IPv6. """ supported_afi = ['ipv4', 'ipv6'] bgp_neighbor_data = dict() bgp_neighbor_data['global'] = {} # get summary output from device cmd_bgp_al...
[ "BGP", "neighbor", "information", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L1143-L1419
[ "def", "get_bgp_neighbors", "(", "self", ")", ":", "supported_afi", "=", "[", "'ipv4'", ",", "'ipv6'", "]", "bgp_neighbor_data", "=", "dict", "(", ")", "bgp_neighbor_data", "[", "'global'", "]", "=", "{", "}", "# get summary output from device", "cmd_bgp_all_sum",...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.get_environment
Get environment facts. power and fan are currently not implemented cpu is using 1-minute average cpu hard-coded to cpu0 (i.e. only a single CPU)
napalm_ios/ios.py
def get_environment(self): """ Get environment facts. power and fan are currently not implemented cpu is using 1-minute average cpu hard-coded to cpu0 (i.e. only a single CPU) """ environment = {} cpu_cmd = 'show proc cpu' mem_cmd = 'show memory s...
def get_environment(self): """ Get environment facts. power and fan are currently not implemented cpu is using 1-minute average cpu hard-coded to cpu0 (i.e. only a single CPU) """ environment = {} cpu_cmd = 'show proc cpu' mem_cmd = 'show memory s...
[ "Get", "environment", "facts", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L1520-L1581
[ "def", "get_environment", "(", "self", ")", ":", "environment", "=", "{", "}", "cpu_cmd", "=", "'show proc cpu'", "mem_cmd", "=", "'show memory statistics'", "temp_cmd", "=", "'show env temperature status'", "output", "=", "self", ".", "_send_command", "(", "cpu_cmd...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.get_arp_table
Get arp table information. Return a list of dictionaries having the following set of keys: * interface (string) * mac (string) * ip (string) * age (float) For example:: [ { 'interface' : 'MgmtEth0/RSP0/CPU0...
napalm_ios/ios.py
def get_arp_table(self): """ Get arp table information. Return a list of dictionaries having the following set of keys: * interface (string) * mac (string) * ip (string) * age (float) For example:: [ { ...
def get_arp_table(self): """ Get arp table information. Return a list of dictionaries having the following set of keys: * interface (string) * mac (string) * ip (string) * age (float) For example:: [ { ...
[ "Get", "arp", "table", "information", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L1583-L1650
[ "def", "get_arp_table", "(", "self", ")", ":", "arp_table", "=", "[", "]", "command", "=", "'show arp | exclude Incomplete'", "output", "=", "self", ".", "_send_command", "(", "command", ")", "# Skip the first line which is a header", "output", "=", "output", ".", ...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.cli
Execute a list of commands and return the output in a dictionary format using the command as the key. Example input: ['show clock', 'show calendar'] Output example: { 'show calendar': u'22:02:01 UTC Thu Feb 18 2016', 'show clock': u'*22:01:51.165 UTC Thu Feb 18 20...
napalm_ios/ios.py
def cli(self, commands): """ Execute a list of commands and return the output in a dictionary format using the command as the key. Example input: ['show clock', 'show calendar'] Output example: { 'show calendar': u'22:02:01 UTC Thu Feb 18 2016', 's...
def cli(self, commands): """ Execute a list of commands and return the output in a dictionary format using the command as the key. Example input: ['show clock', 'show calendar'] Output example: { 'show calendar': u'22:02:01 UTC Thu Feb 18 2016', 's...
[ "Execute", "a", "list", "of", "commands", "and", "return", "the", "output", "in", "a", "dictionary", "format", "using", "the", "command", "as", "the", "key", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L1652-L1676
[ "def", "cli", "(", "self", ",", "commands", ")", ":", "cli_output", "=", "dict", "(", ")", "if", "type", "(", "commands", ")", "is", "not", "list", ":", "raise", "TypeError", "(", "'Please enter a valid list of commands!'", ")", "for", "command", "in", "co...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.get_mac_address_table
Returns a lists of dictionaries. Each dictionary represents an entry in the MAC Address Table, having the following keys * mac (string) * interface (string) * vlan (int) * active (boolean) * static (boolean) * moves (int) * last...
napalm_ios/ios.py
def get_mac_address_table(self): """ Returns a lists of dictionaries. Each dictionary represents an entry in the MAC Address Table, having the following keys * mac (string) * interface (string) * vlan (int) * active (boolean) * static (...
def get_mac_address_table(self): """ Returns a lists of dictionaries. Each dictionary represents an entry in the MAC Address Table, having the following keys * mac (string) * interface (string) * vlan (int) * active (boolean) * static (...
[ "Returns", "a", "lists", "of", "dictionaries", ".", "Each", "dictionary", "represents", "an", "entry", "in", "the", "MAC", "Address", "Table", "having", "the", "following", "keys", "*", "mac", "(", "string", ")", "*", "interface", "(", "string", ")", "*", ...
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L1742-L1903
[ "def", "get_mac_address_table", "(", "self", ")", ":", "RE_MACTABLE_DEFAULT", "=", "r\"^\"", "+", "MAC_REGEX", "RE_MACTABLE_6500_1", "=", "r\"^\\*\\s+{}\\s+{}\\s+\"", ".", "format", "(", "VLAN_REGEX", ",", "MAC_REGEX", ")", "# 7 fields", "RE_MACTABLE_6500_2", "=", "r\...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.traceroute
Executes traceroute on the device and returns a dictionary with the result. :param destination: Host or IP Address of the destination :param source (optional): Use a specific IP Address to execute the traceroute :param ttl (optional): Maimum number of hops -> int (0-255) :param timeout ...
napalm_ios/ios.py
def traceroute(self, destination, source=C.TRACEROUTE_SOURCE, ttl=C.TRACEROUTE_TTL, timeout=C.TRACEROUTE_TIMEOUT, vrf=C.TRACEROUTE_VRF): """ Executes traceroute on the device and returns a dictionary with the result. :param destination: Host or IP Address of the destination ...
def traceroute(self, destination, source=C.TRACEROUTE_SOURCE, ttl=C.TRACEROUTE_TTL, timeout=C.TRACEROUTE_TIMEOUT, vrf=C.TRACEROUTE_VRF): """ Executes traceroute on the device and returns a dictionary with the result. :param destination: Host or IP Address of the destination ...
[ "Executes", "traceroute", "on", "the", "device", "and", "returns", "a", "dictionary", "with", "the", "result", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L2033-L2147
[ "def", "traceroute", "(", "self", ",", "destination", ",", "source", "=", "C", ".", "TRACEROUTE_SOURCE", ",", "ttl", "=", "C", ".", "TRACEROUTE_TTL", ",", "timeout", "=", "C", ".", "TRACEROUTE_TIMEOUT", ",", "vrf", "=", "C", ".", "TRACEROUTE_VRF", ")", "...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
IOSDriver.get_config
Implementation of get_config for IOS. Returns the startup or/and running configuration as dictionary. The keys of the dictionary represent the type of configuration (startup or running). The candidate is always empty string, since IOS does not support candidate configuration.
napalm_ios/ios.py
def get_config(self, retrieve='all'): """Implementation of get_config for IOS. Returns the startup or/and running configuration as dictionary. The keys of the dictionary represent the type of configuration (startup or running). The candidate is always empty string, since IOS doe...
def get_config(self, retrieve='all'): """Implementation of get_config for IOS. Returns the startup or/and running configuration as dictionary. The keys of the dictionary represent the type of configuration (startup or running). The candidate is always empty string, since IOS doe...
[ "Implementation", "of", "get_config", "for", "IOS", "." ]
napalm-automation/napalm-ios
python
https://github.com/napalm-automation/napalm-ios/blob/7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81/napalm_ios/ios.py#L2149-L2174
[ "def", "get_config", "(", "self", ",", "retrieve", "=", "'all'", ")", ":", "configs", "=", "{", "'startup'", ":", "''", ",", "'running'", ":", "''", ",", "'candidate'", ":", "''", ",", "}", "if", "retrieve", "in", "(", "'startup'", ",", "'all'", ")",...
7bbbc6a4d9f70a5b8cf32b7c7072a7ab437ddb81
train
ADXL345.set_range
Set the range of the accelerometer to the provided value. Range value should be one of these constants: - ADXL345_RANGE_2_G = +/-2G - ADXL345_RANGE_4_G = +/-4G - ADXL345_RANGE_8_G = +/-8G - ADXL345_RANGE_16_G = +/-16G
Adafruit_ADXL345/ADXL345.py
def set_range(self, value): """Set the range of the accelerometer to the provided value. Range value should be one of these constants: - ADXL345_RANGE_2_G = +/-2G - ADXL345_RANGE_4_G = +/-4G - ADXL345_RANGE_8_G = +/-8G - ADXL345_RANGE_16_G = +/-16G ...
def set_range(self, value): """Set the range of the accelerometer to the provided value. Range value should be one of these constants: - ADXL345_RANGE_2_G = +/-2G - ADXL345_RANGE_4_G = +/-4G - ADXL345_RANGE_8_G = +/-8G - ADXL345_RANGE_16_G = +/-16G ...
[ "Set", "the", "range", "of", "the", "accelerometer", "to", "the", "provided", "value", ".", "Range", "value", "should", "be", "one", "of", "these", "constants", ":", "-", "ADXL345_RANGE_2_G", "=", "+", "/", "-", "2G", "-", "ADXL345_RANGE_4_G", "=", "+", ...
adafruit/Adafruit_Python_ADXL345
python
https://github.com/adafruit/Adafruit_Python_ADXL345/blob/d897bcaa16b5fe365463ae0c2791d0c155becd05/Adafruit_ADXL345/ADXL345.py#L70-L84
[ "def", "set_range", "(", "self", ",", "value", ")", ":", "# Read the data format register to preserve bits. Update the data", "# rate, make sure that the FULL-RES bit is enabled for range scaling", "format_reg", "=", "self", ".", "_device", ".", "readU8", "(", "ADXL345_REG_DATA_...
d897bcaa16b5fe365463ae0c2791d0c155becd05
train
ADXL345.read
Read the current value of the accelerometer and return it as a tuple of signed 16-bit X, Y, Z axis values.
Adafruit_ADXL345/ADXL345.py
def read(self): """Read the current value of the accelerometer and return it as a tuple of signed 16-bit X, Y, Z axis values. """ raw = self._device.readList(ADXL345_REG_DATAX0, 6) return struct.unpack('<hhh', raw)
def read(self): """Read the current value of the accelerometer and return it as a tuple of signed 16-bit X, Y, Z axis values. """ raw = self._device.readList(ADXL345_REG_DATAX0, 6) return struct.unpack('<hhh', raw)
[ "Read", "the", "current", "value", "of", "the", "accelerometer", "and", "return", "it", "as", "a", "tuple", "of", "signed", "16", "-", "bit", "X", "Y", "Z", "axis", "values", "." ]
adafruit/Adafruit_Python_ADXL345
python
https://github.com/adafruit/Adafruit_Python_ADXL345/blob/d897bcaa16b5fe365463ae0c2791d0c155becd05/Adafruit_ADXL345/ADXL345.py#L122-L127
[ "def", "read", "(", "self", ")", ":", "raw", "=", "self", ".", "_device", ".", "readList", "(", "ADXL345_REG_DATAX0", ",", "6", ")", "return", "struct", ".", "unpack", "(", "'<hhh'", ",", "raw", ")" ]
d897bcaa16b5fe365463ae0c2791d0c155becd05
train
deinit
Stops interrupts on all boards. Only required when using :func:`digital_read` and :func:`digital_write`. :param bus: SPI bus /dev/spidev<bus>.<chipselect> (default: {bus}) :type bus: int :param chip_select: SPI chip select /dev/spidev<bus>.<chipselect> (default: {chip}) :type chip_select: i...
pifacedigitalio/core.py
def deinit(bus=DEFAULT_SPI_BUS, chip_select=DEFAULT_SPI_CHIP_SELECT): """Stops interrupts on all boards. Only required when using :func:`digital_read` and :func:`digital_write`. :param bus: SPI bus /dev/spidev<bus>.<chipselect> (default: {bus}) :type bus: int :param chip_select: SPI chip...
def deinit(bus=DEFAULT_SPI_BUS, chip_select=DEFAULT_SPI_CHIP_SELECT): """Stops interrupts on all boards. Only required when using :func:`digital_read` and :func:`digital_write`. :param bus: SPI bus /dev/spidev<bus>.<chipselect> (default: {bus}) :type bus: int :param chip_select: SPI chip...
[ "Stops", "interrupts", "on", "all", "boards", ".", "Only", "required", "when", "using", ":", "func", ":", "digital_read", "and", ":", "func", ":", "digital_write", "." ]
piface/pifacedigitalio
python
https://github.com/piface/pifacedigitalio/blob/d231a82bdb55d5f57f44ba7aec00bfd6c0b9a9d4/pifacedigitalio/core.py#L176-L192
[ "def", "deinit", "(", "bus", "=", "DEFAULT_SPI_BUS", ",", "chip_select", "=", "DEFAULT_SPI_CHIP_SELECT", ")", ":", "global", "_pifacedigitals", "for", "pfd", "in", "_pifacedigitals", ":", "try", ":", "pfd", ".", "deinit_board", "(", ")", "except", "AttributeErro...
d231a82bdb55d5f57f44ba7aec00bfd6c0b9a9d4
train
digital_write
Writes the value to the input pin specified. .. note:: This function is for familiarality with users of other types of IO board. Consider accessing the ``output_pins`` attribute of a PiFaceDigital object: >>> pfd = PiFaceDigital(hardware_addr) >>> pfd.output_pins[pin_num].value = 1 ...
pifacedigitalio/core.py
def digital_write(pin_num, value, hardware_addr=0): """Writes the value to the input pin specified. .. note:: This function is for familiarality with users of other types of IO board. Consider accessing the ``output_pins`` attribute of a PiFaceDigital object: >>> pfd = PiFaceDigital(hardw...
def digital_write(pin_num, value, hardware_addr=0): """Writes the value to the input pin specified. .. note:: This function is for familiarality with users of other types of IO board. Consider accessing the ``output_pins`` attribute of a PiFaceDigital object: >>> pfd = PiFaceDigital(hardw...
[ "Writes", "the", "value", "to", "the", "input", "pin", "specified", "." ]
piface/pifacedigitalio
python
https://github.com/piface/pifacedigitalio/blob/d231a82bdb55d5f57f44ba7aec00bfd6c0b9a9d4/pifacedigitalio/core.py#L216-L233
[ "def", "digital_write", "(", "pin_num", ",", "value", ",", "hardware_addr", "=", "0", ")", ":", "_get_pifacedigital", "(", "hardware_addr", ")", ".", "output_pins", "[", "pin_num", "]", ".", "value", "=", "value" ]
d231a82bdb55d5f57f44ba7aec00bfd6c0b9a9d4
train
digital_write_pullup
Writes the value to the input pullup specified. .. note:: This function is for familiarality with users of other types of IO board. Consider accessing the ``gppub`` attribute of a PiFaceDigital object: >>> pfd = PiFaceDigital(hardware_addr) >>> hex(pfd.gppub.value) 0xff >...
pifacedigitalio/core.py
def digital_write_pullup(pin_num, value, hardware_addr=0): """Writes the value to the input pullup specified. .. note:: This function is for familiarality with users of other types of IO board. Consider accessing the ``gppub`` attribute of a PiFaceDigital object: >>> pfd = PiFaceDigital(h...
def digital_write_pullup(pin_num, value, hardware_addr=0): """Writes the value to the input pullup specified. .. note:: This function is for familiarality with users of other types of IO board. Consider accessing the ``gppub`` attribute of a PiFaceDigital object: >>> pfd = PiFaceDigital(h...
[ "Writes", "the", "value", "to", "the", "input", "pullup", "specified", "." ]
piface/pifacedigitalio
python
https://github.com/piface/pifacedigitalio/blob/d231a82bdb55d5f57f44ba7aec00bfd6c0b9a9d4/pifacedigitalio/core.py#L258-L277
[ "def", "digital_write_pullup", "(", "pin_num", ",", "value", ",", "hardware_addr", "=", "0", ")", ":", "_get_pifacedigital", "(", "hardware_addr", ")", ".", "gppub", ".", "bits", "[", "pin_num", "]", ".", "value", "=", "value" ]
d231a82bdb55d5f57f44ba7aec00bfd6c0b9a9d4
train
get_my_ip
Returns this computers IP address as a string.
examples/simplewebcontrol.py
def get_my_ip(): """Returns this computers IP address as a string.""" ip = subprocess.check_output(GET_IP_CMD, shell=True).decode('utf-8')[:-1] return ip.strip()
def get_my_ip(): """Returns this computers IP address as a string.""" ip = subprocess.check_output(GET_IP_CMD, shell=True).decode('utf-8')[:-1] return ip.strip()
[ "Returns", "this", "computers", "IP", "address", "as", "a", "string", "." ]
piface/pifacedigitalio
python
https://github.com/piface/pifacedigitalio/blob/d231a82bdb55d5f57f44ba7aec00bfd6c0b9a9d4/examples/simplewebcontrol.py#L72-L75
[ "def", "get_my_ip", "(", ")", ":", "ip", "=", "subprocess", ".", "check_output", "(", "GET_IP_CMD", ",", "shell", "=", "True", ")", ".", "decode", "(", "'utf-8'", ")", "[", ":", "-", "1", "]", "return", "ip", ".", "strip", "(", ")" ]
d231a82bdb55d5f57f44ba7aec00bfd6c0b9a9d4
train
PiFaceWebHandler.set_output_port
Sets the output port value to new_value, defaults to old_value.
examples/simplewebcontrol.py
def set_output_port(self, new_value, old_value=0): """Sets the output port value to new_value, defaults to old_value.""" print("Setting output port to {}.".format(new_value)) port_value = old_value try: port_value = int(new_value) # dec except ValueError: ...
def set_output_port(self, new_value, old_value=0): """Sets the output port value to new_value, defaults to old_value.""" print("Setting output port to {}.".format(new_value)) port_value = old_value try: port_value = int(new_value) # dec except ValueError: ...
[ "Sets", "the", "output", "port", "value", "to", "new_value", "defaults", "to", "old_value", "." ]
piface/pifacedigitalio
python
https://github.com/piface/pifacedigitalio/blob/d231a82bdb55d5f57f44ba7aec00bfd6c0b9a9d4/examples/simplewebcontrol.py#L59-L69
[ "def", "set_output_port", "(", "self", ",", "new_value", ",", "old_value", "=", "0", ")", ":", "print", "(", "\"Setting output port to {}.\"", ".", "format", "(", "new_value", ")", ")", "port_value", "=", "old_value", "try", ":", "port_value", "=", "int", "(...
d231a82bdb55d5f57f44ba7aec00bfd6c0b9a9d4
train
EtnaWrapper._request_api
Wrap the calls the url, with the given arguments. :param str url: Url to call with the given arguments :param str method: [POST | GET] Method to use on the request :param int status: Expected status code
etnawrapper/etna.py
def _request_api(self, **kwargs): """Wrap the calls the url, with the given arguments. :param str url: Url to call with the given arguments :param str method: [POST | GET] Method to use on the request :param int status: Expected status code """ _url = kwargs.get('url') ...
def _request_api(self, **kwargs): """Wrap the calls the url, with the given arguments. :param str url: Url to call with the given arguments :param str method: [POST | GET] Method to use on the request :param int status: Expected status code """ _url = kwargs.get('url') ...
[ "Wrap", "the", "calls", "the", "url", "with", "the", "given", "arguments", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L119-L147
[ "def", "_request_api", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_url", "=", "kwargs", ".", "get", "(", "'url'", ")", "_method", "=", "kwargs", ".", "get", "(", "'method'", ",", "'GET'", ")", "_status", "=", "kwargs", ".", "get", "(", "'stat...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
EtnaWrapper.get_infos_with_id
Get info about a user based on his id. :return: JSON
etnawrapper/etna.py
def get_infos_with_id(self, uid): """Get info about a user based on his id. :return: JSON """ _logid = uid _user_info_url = USER_INFO_URL.format(logid=_logid) return self._request_api(url=_user_info_url).json()
def get_infos_with_id(self, uid): """Get info about a user based on his id. :return: JSON """ _logid = uid _user_info_url = USER_INFO_URL.format(logid=_logid) return self._request_api(url=_user_info_url).json()
[ "Get", "info", "about", "a", "user", "based", "on", "his", "id", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L157-L165
[ "def", "get_infos_with_id", "(", "self", ",", "uid", ")", ":", "_logid", "=", "uid", "_user_info_url", "=", "USER_INFO_URL", ".", "format", "(", "logid", "=", "_logid", ")", "return", "self", ".", "_request_api", "(", "url", "=", "_user_info_url", ")", "."...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
EtnaWrapper.get_current_activities
Get the current activities of user. Either use the `login` param, or the client's login if unset. :return: JSON
etnawrapper/etna.py
def get_current_activities(self, login=None, **kwargs): """Get the current activities of user. Either use the `login` param, or the client's login if unset. :return: JSON """ _login = kwargs.get( 'login', login or self._login ) _activity_...
def get_current_activities(self, login=None, **kwargs): """Get the current activities of user. Either use the `login` param, or the client's login if unset. :return: JSON """ _login = kwargs.get( 'login', login or self._login ) _activity_...
[ "Get", "the", "current", "activities", "of", "user", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L175-L187
[ "def", "get_current_activities", "(", "self", ",", "login", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_login", "=", "kwargs", ".", "get", "(", "'login'", ",", "login", "or", "self", ".", "_login", ")", "_activity_url", "=", "ACTIVITY_URL", ".", ...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
EtnaWrapper.get_notifications
Get the current notifications of a user. :return: JSON
etnawrapper/etna.py
def get_notifications(self, login=None, **kwargs): """Get the current notifications of a user. :return: JSON """ _login = kwargs.get( 'login', login or self._login ) _notif_url = NOTIF_URL.format(login=_login) return self._request_api(url...
def get_notifications(self, login=None, **kwargs): """Get the current notifications of a user. :return: JSON """ _login = kwargs.get( 'login', login or self._login ) _notif_url = NOTIF_URL.format(login=_login) return self._request_api(url...
[ "Get", "the", "current", "notifications", "of", "a", "user", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L189-L200
[ "def", "get_notifications", "(", "self", ",", "login", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_login", "=", "kwargs", ".", "get", "(", "'login'", ",", "login", "or", "self", ".", "_login", ")", "_notif_url", "=", "NOTIF_URL", ".", "format", ...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
EtnaWrapper.get_grades
Get a user's grades on a single promotion based on his login. Either use the `login` param, or the client's login if unset. :return: JSON
etnawrapper/etna.py
def get_grades(self, login=None, promotion=None, **kwargs): """Get a user's grades on a single promotion based on his login. Either use the `login` param, or the client's login if unset. :return: JSON """ _login = kwargs.get( 'login', login or self._logi...
def get_grades(self, login=None, promotion=None, **kwargs): """Get a user's grades on a single promotion based on his login. Either use the `login` param, or the client's login if unset. :return: JSON """ _login = kwargs.get( 'login', login or self._logi...
[ "Get", "a", "user", "s", "grades", "on", "a", "single", "promotion", "based", "on", "his", "login", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L202-L215
[ "def", "get_grades", "(", "self", ",", "login", "=", "None", ",", "promotion", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_login", "=", "kwargs", ".", "get", "(", "'login'", ",", "login", "or", "self", ".", "_login", ")", "_promotion_id", "=", ...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
EtnaWrapper.get_picture
Get a user's picture. :param str login: Login of the user to check :return: JSON
etnawrapper/etna.py
def get_picture(self, login=None, **kwargs): """Get a user's picture. :param str login: Login of the user to check :return: JSON """ _login = kwargs.get( 'login', login or self._login ) _activities_url = PICTURE_URL.format(login=_login) ...
def get_picture(self, login=None, **kwargs): """Get a user's picture. :param str login: Login of the user to check :return: JSON """ _login = kwargs.get( 'login', login or self._login ) _activities_url = PICTURE_URL.format(login=_login) ...
[ "Get", "a", "user", "s", "picture", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L217-L229
[ "def", "get_picture", "(", "self", ",", "login", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_login", "=", "kwargs", ".", "get", "(", "'login'", ",", "login", "or", "self", ".", "_login", ")", "_activities_url", "=", "PICTURE_URL", ".", "format", ...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
EtnaWrapper.get_projects
Get a user's project. :param str login: User's login (Default: self._login) :return: JSON
etnawrapper/etna.py
def get_projects(self, **kwargs): """Get a user's project. :param str login: User's login (Default: self._login) :return: JSON """ _login = kwargs.get('login', self._login) search_url = SEARCH_URL.format(login=_login) return self._request_api(url=search_url).jso...
def get_projects(self, **kwargs): """Get a user's project. :param str login: User's login (Default: self._login) :return: JSON """ _login = kwargs.get('login', self._login) search_url = SEARCH_URL.format(login=_login) return self._request_api(url=search_url).jso...
[ "Get", "a", "user", "s", "project", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L231-L240
[ "def", "get_projects", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_login", "=", "kwargs", ".", "get", "(", "'login'", ",", "self", ".", "_login", ")", "search_url", "=", "SEARCH_URL", ".", "format", "(", "login", "=", "_login", ")", "return", "...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
EtnaWrapper.get_activities_for_project
Get the related activities of a project. :param str module: Stages of a given module :return: JSON
etnawrapper/etna.py
def get_activities_for_project(self, module=None, **kwargs): """Get the related activities of a project. :param str module: Stages of a given module :return: JSON """ _module_id = kwargs.get('module', module) _activities_url = ACTIVITIES_URL.format(module_id=_module_id)...
def get_activities_for_project(self, module=None, **kwargs): """Get the related activities of a project. :param str module: Stages of a given module :return: JSON """ _module_id = kwargs.get('module', module) _activities_url = ACTIVITIES_URL.format(module_id=_module_id)...
[ "Get", "the", "related", "activities", "of", "a", "project", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L242-L251
[ "def", "get_activities_for_project", "(", "self", ",", "module", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_module_id", "=", "kwargs", ".", "get", "(", "'module'", ",", "module", ")", "_activities_url", "=", "ACTIVITIES_URL", ".", "format", "(", "mo...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
EtnaWrapper.get_group_for_activity
Get groups for activity. :param str module: Base module :param str module: Project which contains the group requested :return: JSON
etnawrapper/etna.py
def get_group_for_activity(self, module=None, project=None, **kwargs): """Get groups for activity. :param str module: Base module :param str module: Project which contains the group requested :return: JSON """ _module_id = kwargs.get('module', module) _project_i...
def get_group_for_activity(self, module=None, project=None, **kwargs): """Get groups for activity. :param str module: Base module :param str module: Project which contains the group requested :return: JSON """ _module_id = kwargs.get('module', module) _project_i...
[ "Get", "groups", "for", "activity", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L253-L264
[ "def", "get_group_for_activity", "(", "self", ",", "module", "=", "None", ",", "project", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_module_id", "=", "kwargs", ".", "get", "(", "'module'", ",", "module", ")", "_project_id", "=", "kwargs", ".", "...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
EtnaWrapper.get_students
Get users by promotion id. :param int promotion: Promotion ID :return: JSON
etnawrapper/etna.py
def get_students(self, **kwargs): """Get users by promotion id. :param int promotion: Promotion ID :return: JSON """ _promotion_id = kwargs.get('promotion') _url = PROMOTION_URL.format(promo_id=_promotion_id) return self._request_api(url=_url).json()
def get_students(self, **kwargs): """Get users by promotion id. :param int promotion: Promotion ID :return: JSON """ _promotion_id = kwargs.get('promotion') _url = PROMOTION_URL.format(promo_id=_promotion_id) return self._request_api(url=_url).json()
[ "Get", "users", "by", "promotion", "id", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L266-L275
[ "def", "get_students", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_promotion_id", "=", "kwargs", ".", "get", "(", "'promotion'", ")", "_url", "=", "PROMOTION_URL", ".", "format", "(", "promo_id", "=", "_promotion_id", ")", "return", "self", ".", "_...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
EtnaWrapper.get_log_events
Get a user's log events. :param str login: User's login (Default: self._login) :return: JSON
etnawrapper/etna.py
def get_log_events(self, login=None, **kwargs): """Get a user's log events. :param str login: User's login (Default: self._login) :return: JSON """ _login = kwargs.get( 'login', login ) log_events_url = GSA_EVENTS_URL.format(login=_login)...
def get_log_events(self, login=None, **kwargs): """Get a user's log events. :param str login: User's login (Default: self._login) :return: JSON """ _login = kwargs.get( 'login', login ) log_events_url = GSA_EVENTS_URL.format(login=_login)...
[ "Get", "a", "user", "s", "log", "events", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L277-L289
[ "def", "get_log_events", "(", "self", ",", "login", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_login", "=", "kwargs", ".", "get", "(", "'login'", ",", "login", ")", "log_events_url", "=", "GSA_EVENTS_URL", ".", "format", "(", "login", "=", "_log...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
EtnaWrapper.get_events
Get a user's events. :param str login: User's login (Default: self._login) :param str start_date: Start date :param str end_date: To date :return: JSON
etnawrapper/etna.py
def get_events(self, login=None, start_date=None, end_date=None, **kwargs): """Get a user's events. :param str login: User's login (Default: self._login) :param str start_date: Start date :param str end_date: To date :return: JSON """ _login = kwargs.get( ...
def get_events(self, login=None, start_date=None, end_date=None, **kwargs): """Get a user's events. :param str login: User's login (Default: self._login) :param str start_date: Start date :param str end_date: To date :return: JSON """ _login = kwargs.get( ...
[ "Get", "a", "user", "s", "events", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L291-L309
[ "def", "get_events", "(", "self", ",", "login", "=", "None", ",", "start_date", "=", "None", ",", "end_date", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_login", "=", "kwargs", ".", "get", "(", "'login'", ",", "login", ")", "log_events_url", "=...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
EtnaWrapper.get_logs
Get a user's logs. :param str login: User's login (Default: self._login) :return: JSON
etnawrapper/etna.py
def get_logs(self, login=None, **kwargs): """Get a user's logs. :param str login: User's login (Default: self._login) :return: JSON """ _login = kwargs.get( 'login', login ) log_events_url = GSA_LOGS_URL.format(login=_login) retur...
def get_logs(self, login=None, **kwargs): """Get a user's logs. :param str login: User's login (Default: self._login) :return: JSON """ _login = kwargs.get( 'login', login ) log_events_url = GSA_LOGS_URL.format(login=_login) retur...
[ "Get", "a", "user", "s", "logs", "." ]
tbobm/etnawrapper
python
https://github.com/tbobm/etnawrapper/blob/0f1759646a30f658cf75fd521fd6e9cef5cd09c4/etnawrapper/etna.py#L311-L323
[ "def", "get_logs", "(", "self", ",", "login", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_login", "=", "kwargs", ".", "get", "(", "'login'", ",", "login", ")", "log_events_url", "=", "GSA_LOGS_URL", ".", "format", "(", "login", "=", "_login", "...
0f1759646a30f658cf75fd521fd6e9cef5cd09c4
train
Negotiator.negotiate
Process headers dict to return the format class (not the instance)
prometheus/negotiator.py
def negotiate(cls, headers): """ Process headers dict to return the format class (not the instance) """ # set lower keys headers = {k.lower(): v for k, v in headers.items()} accept = headers.get('accept', "*/*") parsed_accept = accept.split(";") pars...
def negotiate(cls, headers): """ Process headers dict to return the format class (not the instance) """ # set lower keys headers = {k.lower(): v for k, v in headers.items()} accept = headers.get('accept', "*/*") parsed_accept = accept.split(";") pars...
[ "Process", "headers", "dict", "to", "return", "the", "format", "class", "(", "not", "the", "instance", ")" ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/negotiator.py#L26-L51
[ "def", "negotiate", "(", "cls", ",", "headers", ")", ":", "# set lower keys", "headers", "=", "{", "k", ".", "lower", "(", ")", ":", "v", "for", "k", ",", "v", "in", "headers", ".", "items", "(", ")", "}", "accept", "=", "headers", ".", "get", "(...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
Registry.register
Registers a collector
prometheus/registry.py
def register(self, collector): """ Registers a collector""" if not isinstance(collector, Collector): raise TypeError( "Can't register instance, not a valid type of collector") if collector.name in self.collectors: raise ValueError("Collector already exist...
def register(self, collector): """ Registers a collector""" if not isinstance(collector, Collector): raise TypeError( "Can't register instance, not a valid type of collector") if collector.name in self.collectors: raise ValueError("Collector already exist...
[ "Registers", "a", "collector" ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/registry.py#L15-L25
[ "def", "register", "(", "self", ",", "collector", ")", ":", "if", "not", "isinstance", "(", "collector", ",", "Collector", ")", ":", "raise", "TypeError", "(", "\"Can't register instance, not a valid type of collector\"", ")", "if", "collector", ".", "name", "in",...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
Pusher.add
Add works like replace, but only previously pushed metrics with the same name (and the same job and instance) will be replaced. (It uses HTTP method 'POST' to push to the Pushgateway.)
prometheus/pusher.py
def add(self, registry): """ Add works like replace, but only previously pushed metrics with the same name (and the same job and instance) will be replaced. (It uses HTTP method 'POST' to push to the Pushgateway.) """ # POST payload = self.formatter.marshall(regis...
def add(self, registry): """ Add works like replace, but only previously pushed metrics with the same name (and the same job and instance) will be replaced. (It uses HTTP method 'POST' to push to the Pushgateway.) """ # POST payload = self.formatter.marshall(regis...
[ "Add", "works", "like", "replace", "but", "only", "previously", "pushed", "metrics", "with", "the", "same", "name", "(", "and", "the", "same", "job", "and", "instance", ")", "will", "be", "replaced", ".", "(", "It", "uses", "HTTP", "method", "POST", "to"...
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/pusher.py#L31-L38
[ "def", "add", "(", "self", ",", "registry", ")", ":", "# POST", "payload", "=", "self", ".", "formatter", ".", "marshall", "(", "registry", ")", "r", "=", "requests", ".", "post", "(", "self", ".", "path", ",", "data", "=", "payload", ",", "headers",...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
Pusher.replace
Push triggers a metric collection and pushes all collected metrics to the Pushgateway specified by addr Note that all previously pushed metrics with the same job and instance will be replaced with the metrics pushed by this call. (It uses HTTP method 'PUT' to push to the ...
prometheus/pusher.py
def replace(self, registry): """ Push triggers a metric collection and pushes all collected metrics to the Pushgateway specified by addr Note that all previously pushed metrics with the same job and instance will be replaced with the metrics pushed by this call. (...
def replace(self, registry): """ Push triggers a metric collection and pushes all collected metrics to the Pushgateway specified by addr Note that all previously pushed metrics with the same job and instance will be replaced with the metrics pushed by this call. (...
[ "Push", "triggers", "a", "metric", "collection", "and", "pushes", "all", "collected", "metrics", "to", "the", "Pushgateway", "specified", "by", "addr", "Note", "that", "all", "previously", "pushed", "metrics", "with", "the", "same", "job", "and", "instance", "...
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/pusher.py#L40-L49
[ "def", "replace", "(", "self", ",", "registry", ")", ":", "# PUT", "payload", "=", "self", ".", "formatter", ".", "marshall", "(", "registry", ")", "r", "=", "requests", ".", "put", "(", "self", ".", "path", ",", "data", "=", "payload", ",", "headers...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
TextFormat.marshall_lines
Marshalls a collector and returns the storage/transfer format in a tuple, this tuple has reprensentation format per element.
prometheus/formats.py
def marshall_lines(self, collector): """ Marshalls a collector and returns the storage/transfer format in a tuple, this tuple has reprensentation format per element. """ if isinstance(collector, collectors.Counter): exec_method = self._format_counter elif isinsta...
def marshall_lines(self, collector): """ Marshalls a collector and returns the storage/transfer format in a tuple, this tuple has reprensentation format per element. """ if isinstance(collector, collectors.Counter): exec_method = self._format_counter elif isinsta...
[ "Marshalls", "a", "collector", "and", "returns", "the", "storage", "/", "transfer", "format", "in", "a", "tuple", "this", "tuple", "has", "reprensentation", "format", "per", "element", "." ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/formats.py#L132-L165
[ "def", "marshall_lines", "(", "self", ",", "collector", ")", ":", "if", "isinstance", "(", "collector", ",", "collectors", ".", "Counter", ")", ":", "exec_method", "=", "self", ".", "_format_counter", "elif", "isinstance", "(", "collector", ",", "collectors", ...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
TextFormat.marshall
Marshalls a full registry (various collectors)
prometheus/formats.py
def marshall(self, registry): """Marshalls a full registry (various collectors)""" blocks = [] for i in registry.get_all(): blocks.append(self.marshall_collector(i)) # Sort? used in tests blocks = sorted(blocks) # Needs EOF blocks.append("") ...
def marshall(self, registry): """Marshalls a full registry (various collectors)""" blocks = [] for i in registry.get_all(): blocks.append(self.marshall_collector(i)) # Sort? used in tests blocks = sorted(blocks) # Needs EOF blocks.append("") ...
[ "Marshalls", "a", "full", "registry", "(", "various", "collectors", ")" ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/formats.py#L172-L185
[ "def", "marshall", "(", "self", ",", "registry", ")", ":", "blocks", "=", "[", "]", "for", "i", "in", "registry", ".", "get_all", "(", ")", ":", "blocks", ".", "append", "(", "self", ".", "marshall_collector", "(", "i", ")", ")", "# Sort? used in tests...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
ProtobufFormat.marshall
Returns bytes
prometheus/formats.py
def marshall(self, registry): """Returns bytes""" result = b"" for i in registry.get_all(): # Each message needs to be prefixed with a varint with the size of # the message (MetrycType) # https://github.com/matttproud/golang_protobuf_extensions/blob/master/ex...
def marshall(self, registry): """Returns bytes""" result = b"" for i in registry.get_all(): # Each message needs to be prefixed with a varint with the size of # the message (MetrycType) # https://github.com/matttproud/golang_protobuf_extensions/blob/master/ex...
[ "Returns", "bytes" ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/formats.py#L291-L304
[ "def", "marshall", "(", "self", ",", "registry", ")", ":", "result", "=", "b\"\"", "for", "i", "in", "registry", ".", "get_all", "(", ")", ":", "# Each message needs to be prefixed with a varint with the size of", "# the message (MetrycType)", "# https://github.com/matttp...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
gather_data
Gathers the metrics
examples/trigonometry_example.py
def gather_data(registry): """Gathers the metrics""" # Get the host name of the machine host = socket.gethostname() # Create our collectors trig_metric = Gauge("trigonometry_example", "Various trigonometry examples.", {'host': host}) # register ...
def gather_data(registry): """Gathers the metrics""" # Get the host name of the machine host = socket.gethostname() # Create our collectors trig_metric = Gauge("trigonometry_example", "Various trigonometry examples.", {'host': host}) # register ...
[ "Gathers", "the", "metrics" ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/examples/trigonometry_example.py#L20-L44
[ "def", "gather_data", "(", "registry", ")", ":", "# Get the host name of the machine", "host", "=", "socket", ".", "gethostname", "(", ")", "# Create our collectors", "trig_metric", "=", "Gauge", "(", "\"trigonometry_example\"", ",", "\"Various trigonometry examples.\"", ...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
Collector.set_value
Sets a value in the container
prometheus/collectors.py
def set_value(self, labels, value): """ Sets a value in the container""" if labels: self._label_names_correct(labels) with mutex: self.values[labels] = value
def set_value(self, labels, value): """ Sets a value in the container""" if labels: self._label_names_correct(labels) with mutex: self.values[labels] = value
[ "Sets", "a", "value", "in", "the", "container" ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/collectors.py#L38-L45
[ "def", "set_value", "(", "self", ",", "labels", ",", "value", ")", ":", "if", "labels", ":", "self", ".", "_label_names_correct", "(", "labels", ")", "with", "mutex", ":", "self", ".", "values", "[", "labels", "]", "=", "value" ]
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
Collector._label_names_correct
Raise exception (ValueError) if labels not correct
prometheus/collectors.py
def _label_names_correct(self, labels): """Raise exception (ValueError) if labels not correct""" for k, v in labels.items(): # Check reserved labels if k in RESTRICTED_LABELS_NAMES: raise ValueError("Labels not correct") # Check prefixes ...
def _label_names_correct(self, labels): """Raise exception (ValueError) if labels not correct""" for k, v in labels.items(): # Check reserved labels if k in RESTRICTED_LABELS_NAMES: raise ValueError("Labels not correct") # Check prefixes ...
[ "Raise", "exception", "(", "ValueError", ")", "if", "labels", "not", "correct" ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/collectors.py#L57-L69
[ "def", "_label_names_correct", "(", "self", ",", "labels", ")", ":", "for", "k", ",", "v", "in", "labels", ".", "items", "(", ")", ":", "# Check reserved labels", "if", "k", "in", "RESTRICTED_LABELS_NAMES", ":", "raise", "ValueError", "(", "\"Labels not correc...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
Collector.get_all
Returns a list populated by tuples of 2 elements, first one is a dict with all the labels and the second elemnt is the value of the metric itself
prometheus/collectors.py
def get_all(self): """ Returns a list populated by tuples of 2 elements, first one is a dict with all the labels and the second elemnt is the value of the metric itself """ with mutex: items = self.values.items() result = [] for k, v in items:...
def get_all(self): """ Returns a list populated by tuples of 2 elements, first one is a dict with all the labels and the second elemnt is the value of the metric itself """ with mutex: items = self.values.items() result = [] for k, v in items:...
[ "Returns", "a", "list", "populated", "by", "tuples", "of", "2", "elements", "first", "one", "is", "a", "dict", "with", "all", "the", "labels", "and", "the", "second", "elemnt", "is", "the", "value", "of", "the", "metric", "itself" ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/collectors.py#L71-L88
[ "def", "get_all", "(", "self", ")", ":", "with", "mutex", ":", "items", "=", "self", ".", "values", ".", "items", "(", ")", "result", "=", "[", "]", "for", "k", ",", "v", "in", "items", ":", "# Check if is a single value dict (custom empty key)", "if", "...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
Gauge.add
Add adds the given value to the Gauge. (The value can be negative, resulting in a decrease of the Gauge.)
prometheus/collectors.py
def add(self, labels, value): """ Add adds the given value to the Gauge. (The value can be negative, resulting in a decrease of the Gauge.) """ try: current = self.get_value(labels) except KeyError: current = 0 self.set_value(labels, current ...
def add(self, labels, value): """ Add adds the given value to the Gauge. (The value can be negative, resulting in a decrease of the Gauge.) """ try: current = self.get_value(labels) except KeyError: current = 0 self.set_value(labels, current ...
[ "Add", "adds", "the", "given", "value", "to", "the", "Gauge", ".", "(", "The", "value", "can", "be", "negative", "resulting", "in", "a", "decrease", "of", "the", "Gauge", ".", ")" ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/collectors.py#L153-L163
[ "def", "add", "(", "self", ",", "labels", ",", "value", ")", ":", "try", ":", "current", "=", "self", ".", "get_value", "(", "labels", ")", "except", "KeyError", ":", "current", "=", "0", "self", ".", "set_value", "(", "labels", ",", "current", "+", ...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
Summary.add
Add adds a single observation to the summary.
prometheus/collectors.py
def add(self, labels, value): """Add adds a single observation to the summary.""" if type(value) not in (float, int): raise TypeError("Summary only works with digits (int, float)") # We have already a lock for data but not for the estimator with mutex: try: ...
def add(self, labels, value): """Add adds a single observation to the summary.""" if type(value) not in (float, int): raise TypeError("Summary only works with digits (int, float)") # We have already a lock for data but not for the estimator with mutex: try: ...
[ "Add", "adds", "a", "single", "observation", "to", "the", "summary", "." ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/collectors.py#L195-L209
[ "def", "add", "(", "self", ",", "labels", ",", "value", ")", ":", "if", "type", "(", "value", ")", "not", "in", "(", "float", ",", "int", ")", ":", "raise", "TypeError", "(", "\"Summary only works with digits (int, float)\"", ")", "# We have already a lock for...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
Summary.get
Get gets the data in the form of 0.5, 0.9 and 0.99 percentiles. Also you get sum and count, all in a dict
prometheus/collectors.py
def get(self, labels): """ Get gets the data in the form of 0.5, 0.9 and 0.99 percentiles. Also you get sum and count, all in a dict """ return_data = {} # We have already a lock for data but not for the estimator with mutex: e = self.get_value(labels) ...
def get(self, labels): """ Get gets the data in the form of 0.5, 0.9 and 0.99 percentiles. Also you get sum and count, all in a dict """ return_data = {} # We have already a lock for data but not for the estimator with mutex: e = self.get_value(labels) ...
[ "Get", "gets", "the", "data", "in", "the", "form", "of", "0", ".", "5", "0", ".", "9", "and", "0", ".", "99", "percentiles", ".", "Also", "you", "get", "sum", "and", "count", "all", "in", "a", "dict" ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/prometheus/collectors.py#L211-L231
[ "def", "get", "(", "self", ",", "labels", ")", ":", "return_data", "=", "{", "}", "# We have already a lock for data but not for the estimator", "with", "mutex", ":", "e", "=", "self", ".", "get_value", "(", "labels", ")", "# Set invariants data (default to 0.50, 0.90...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
gather_data
Gathers the metrics
examples/memory_cpu_usage_example.py
def gather_data(registry): """Gathers the metrics""" # Get the host name of the machine host = socket.gethostname() # Create our collectors ram_metric = Gauge("memory_usage_bytes", "Memory usage in bytes.", {'host': host}) cpu_metric = Gauge("cpu_usage_percent", "CPU usa...
def gather_data(registry): """Gathers the metrics""" # Get the host name of the machine host = socket.gethostname() # Create our collectors ram_metric = Gauge("memory_usage_bytes", "Memory usage in bytes.", {'host': host}) cpu_metric = Gauge("cpu_usage_percent", "CPU usa...
[ "Gathers", "the", "metrics" ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/examples/memory_cpu_usage_example.py#L20-L50
[ "def", "gather_data", "(", "registry", ")", ":", "# Get the host name of the machine", "host", "=", "socket", ".", "gethostname", "(", ")", "# Create our collectors", "ram_metric", "=", "Gauge", "(", "\"memory_usage_bytes\"", ",", "\"Memory usage in bytes.\"", ",", "{",...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
gather_data
Gathers the metrics
examples/timing_write_io_example.py
def gather_data(registry): """Gathers the metrics""" # Get the host name of the machine host = socket.gethostname() # Create our collectors io_metric = Summary("write_file_io_example", "Writing io file in disk example.", {'host': host}) # regist...
def gather_data(registry): """Gathers the metrics""" # Get the host name of the machine host = socket.gethostname() # Create our collectors io_metric = Summary("write_file_io_example", "Writing io file in disk example.", {'host': host}) # regist...
[ "Gathers", "the", "metrics" ]
slok/prometheus-python
python
https://github.com/slok/prometheus-python/blob/51c6de3cdcd4e36eae6e1643b136f486b57a18cd/examples/timing_write_io_example.py#L20-L49
[ "def", "gather_data", "(", "registry", ")", ":", "# Get the host name of the machine", "host", "=", "socket", ".", "gethostname", "(", ")", "# Create our collectors", "io_metric", "=", "Summary", "(", "\"write_file_io_example\"", ",", "\"Writing io file in disk example.\"",...
51c6de3cdcd4e36eae6e1643b136f486b57a18cd
train
Node.get_child
Returns the first child that matches the given name and attributes.
Gelatin/generator/Builder.py
def get_child(self, name, attribs=None): """ Returns the first child that matches the given name and attributes. """ if name == '.': if attribs is None or len(attribs) == 0: return self if attribs == self.attribs: return sel...
def get_child(self, name, attribs=None): """ Returns the first child that matches the given name and attributes. """ if name == '.': if attribs is None or len(attribs) == 0: return self if attribs == self.attribs: return sel...
[ "Returns", "the", "first", "child", "that", "matches", "the", "given", "name", "and", "attributes", "." ]
knipknap/Gelatin
python
https://github.com/knipknap/Gelatin/blob/d2afa85a48034d6ee34580e49e16542f31ad208e/Gelatin/generator/Builder.py#L96-L106
[ "def", "get_child", "(", "self", ",", "name", ",", "attribs", "=", "None", ")", ":", "if", "name", "==", "'.'", ":", "if", "attribs", "is", "None", "or", "len", "(", "attribs", ")", "==", "0", ":", "return", "self", "if", "attribs", "==", "self", ...
d2afa85a48034d6ee34580e49e16542f31ad208e
train
Builder.create
Creates the given node, regardless of whether or not it already exists. Returns the new node.
Gelatin/generator/Builder.py
def create(self, path, data=None): """ Creates the given node, regardless of whether or not it already exists. Returns the new node. """ node = self.current[-1] path = self._splitpath(path) n_items = len(path) for n, item in enumerate(path): ...
def create(self, path, data=None): """ Creates the given node, regardless of whether or not it already exists. Returns the new node. """ node = self.current[-1] path = self._splitpath(path) n_items = len(path) for n, item in enumerate(path): ...
[ "Creates", "the", "given", "node", "regardless", "of", "whether", "or", "not", "it", "already", "exists", ".", "Returns", "the", "new", "node", "." ]
knipknap/Gelatin
python
https://github.com/knipknap/Gelatin/blob/d2afa85a48034d6ee34580e49e16542f31ad208e/Gelatin/generator/Builder.py#L174-L199
[ "def", "create", "(", "self", ",", "path", ",", "data", "=", "None", ")", ":", "node", "=", "self", ".", "current", "[", "-", "1", "]", "path", "=", "self", ".", "_splitpath", "(", "path", ")", "n_items", "=", "len", "(", "path", ")", "for", "n...
d2afa85a48034d6ee34580e49e16542f31ad208e
train
Builder.add
Creates the given node if it does not exist. Returns the (new or existing) node.
Gelatin/generator/Builder.py
def add(self, path, data=None, replace=False): """ Creates the given node if it does not exist. Returns the (new or existing) node. """ node = self.current[-1] for item in self._splitpath(path): tag, attribs = self._splittag(item) next_node = node....
def add(self, path, data=None, replace=False): """ Creates the given node if it does not exist. Returns the (new or existing) node. """ node = self.current[-1] for item in self._splitpath(path): tag, attribs = self._splittag(item) next_node = node....
[ "Creates", "the", "given", "node", "if", "it", "does", "not", "exist", ".", "Returns", "the", "(", "new", "or", "existing", ")", "node", "." ]
knipknap/Gelatin
python
https://github.com/knipknap/Gelatin/blob/d2afa85a48034d6ee34580e49e16542f31ad208e/Gelatin/generator/Builder.py#L201-L221
[ "def", "add", "(", "self", ",", "path", ",", "data", "=", "None", ",", "replace", "=", "False", ")", ":", "node", "=", "self", ".", "current", "[", "-", "1", "]", "for", "item", "in", "self", ".", "_splitpath", "(", "path", ")", ":", "tag", ","...
d2afa85a48034d6ee34580e49e16542f31ad208e
train
Builder.add_attribute
Creates the given attribute and sets it to the given value. Returns the (new or existing) node to which the attribute was added.
Gelatin/generator/Builder.py
def add_attribute(self, path, name, value): """ Creates the given attribute and sets it to the given value. Returns the (new or existing) node to which the attribute was added. """ node = self.add(path) node.attribs.append((name, value)) return node
def add_attribute(self, path, name, value): """ Creates the given attribute and sets it to the given value. Returns the (new or existing) node to which the attribute was added. """ node = self.add(path) node.attribs.append((name, value)) return node
[ "Creates", "the", "given", "attribute", "and", "sets", "it", "to", "the", "given", "value", ".", "Returns", "the", "(", "new", "or", "existing", ")", "node", "to", "which", "the", "attribute", "was", "added", "." ]
knipknap/Gelatin
python
https://github.com/knipknap/Gelatin/blob/d2afa85a48034d6ee34580e49e16542f31ad208e/Gelatin/generator/Builder.py#L223-L230
[ "def", "add_attribute", "(", "self", ",", "path", ",", "name", ",", "value", ")", ":", "node", "=", "self", ".", "add", "(", "path", ")", "node", ".", "attribs", ".", "append", "(", "(", "name", ",", "value", ")", ")", "return", "node" ]
d2afa85a48034d6ee34580e49e16542f31ad208e
train
Builder.open
Creates and enters the given node, regardless of whether it already exists. Returns the new node.
Gelatin/generator/Builder.py
def open(self, path): """ Creates and enters the given node, regardless of whether it already exists. Returns the new node. """ self.current.append(self.create(path)) return self.current[-1]
def open(self, path): """ Creates and enters the given node, regardless of whether it already exists. Returns the new node. """ self.current.append(self.create(path)) return self.current[-1]
[ "Creates", "and", "enters", "the", "given", "node", "regardless", "of", "whether", "it", "already", "exists", ".", "Returns", "the", "new", "node", "." ]
knipknap/Gelatin
python
https://github.com/knipknap/Gelatin/blob/d2afa85a48034d6ee34580e49e16542f31ad208e/Gelatin/generator/Builder.py#L232-L239
[ "def", "open", "(", "self", ",", "path", ")", ":", "self", ".", "current", ".", "append", "(", "self", ".", "create", "(", "path", ")", ")", "return", "self", ".", "current", "[", "-", "1", "]" ]
d2afa85a48034d6ee34580e49e16542f31ad208e
train
Builder.enter
Enters the given node. Creates it if it does not exist. Returns the node.
Gelatin/generator/Builder.py
def enter(self, path): """ Enters the given node. Creates it if it does not exist. Returns the node. """ self.current.append(self.add(path)) return self.current[-1]
def enter(self, path): """ Enters the given node. Creates it if it does not exist. Returns the node. """ self.current.append(self.add(path)) return self.current[-1]
[ "Enters", "the", "given", "node", ".", "Creates", "it", "if", "it", "does", "not", "exist", ".", "Returns", "the", "node", "." ]
knipknap/Gelatin
python
https://github.com/knipknap/Gelatin/blob/d2afa85a48034d6ee34580e49e16542f31ad208e/Gelatin/generator/Builder.py#L241-L247
[ "def", "enter", "(", "self", ",", "path", ")", ":", "self", ".", "current", ".", "append", "(", "self", ".", "add", "(", "path", ")", ")", "return", "self", ".", "current", "[", "-", "1", "]" ]
d2afa85a48034d6ee34580e49e16542f31ad208e
train
generate
Given a converter (as returned by compile()), this function reads the given input file and converts it to the requested output format. Supported output formats are 'xml', 'yaml', 'json', or 'none'. :type converter: compiler.Context :param converter: The compiled converter. :type input_file: str ...
Gelatin/util.py
def generate(converter, input_file, format='xml', encoding='utf8'): """ Given a converter (as returned by compile()), this function reads the given input file and converts it to the requested output format. Supported output formats are 'xml', 'yaml', 'json', or 'none'. :type converter: compiler.C...
def generate(converter, input_file, format='xml', encoding='utf8'): """ Given a converter (as returned by compile()), this function reads the given input file and converts it to the requested output format. Supported output formats are 'xml', 'yaml', 'json', or 'none'. :type converter: compiler.C...
[ "Given", "a", "converter", "(", "as", "returned", "by", "compile", "()", ")", "this", "function", "reads", "the", "given", "input", "file", "and", "converts", "it", "to", "the", "requested", "output", "format", "." ]
knipknap/Gelatin
python
https://github.com/knipknap/Gelatin/blob/d2afa85a48034d6ee34580e49e16542f31ad208e/Gelatin/util.py#L56-L75
[ "def", "generate", "(", "converter", ",", "input_file", ",", "format", "=", "'xml'", ",", "encoding", "=", "'utf8'", ")", ":", "with", "codecs", ".", "open", "(", "input_file", ",", "encoding", "=", "encoding", ")", "as", "thefile", ":", "return", "gener...
d2afa85a48034d6ee34580e49e16542f31ad208e
train
generate_to_file
Like generate(), but writes the output to the given output file instead. :type converter: compiler.Context :param converter: The compiled converter. :type input_file: str :param input_file: Name of a file to convert. :type output_file: str :param output_file: The output filename. :ty...
Gelatin/util.py
def generate_to_file(converter, input_file, output_file, format='xml', in_encoding='utf8', out_encoding='utf8'): """ Like generate(), but writes the output to the given output file instead. :type c...
def generate_to_file(converter, input_file, output_file, format='xml', in_encoding='utf8', out_encoding='utf8'): """ Like generate(), but writes the output to the given output file instead. :type c...
[ "Like", "generate", "()", "but", "writes", "the", "output", "to", "the", "given", "output", "file", "instead", "." ]
knipknap/Gelatin
python
https://github.com/knipknap/Gelatin/blob/d2afa85a48034d6ee34580e49e16542f31ad208e/Gelatin/util.py#L78-L105
[ "def", "generate_to_file", "(", "converter", ",", "input_file", ",", "output_file", ",", "format", "=", "'xml'", ",", "in_encoding", "=", "'utf8'", ",", "out_encoding", "=", "'utf8'", ")", ":", "with", "codecs", ".", "open", "(", "output_file", ",", "'w'", ...
d2afa85a48034d6ee34580e49e16542f31ad208e
train
generate_string
Like generate(), but reads the input from a string instead of from a file. :type converter: compiler.Context :param converter: The compiled converter. :type input: str :param input: The string to convert. :type format: str :param format: The output format. :rtype: str :return: T...
Gelatin/util.py
def generate_string(converter, input, format='xml'): """ Like generate(), but reads the input from a string instead of from a file. :type converter: compiler.Context :param converter: The compiled converter. :type input: str :param input: The string to convert. :type format: str ...
def generate_string(converter, input, format='xml'): """ Like generate(), but reads the input from a string instead of from a file. :type converter: compiler.Context :param converter: The compiled converter. :type input: str :param input: The string to convert. :type format: str ...
[ "Like", "generate", "()", "but", "reads", "the", "input", "from", "a", "string", "instead", "of", "from", "a", "file", "." ]
knipknap/Gelatin
python
https://github.com/knipknap/Gelatin/blob/d2afa85a48034d6ee34580e49e16542f31ad208e/Gelatin/util.py#L108-L127
[ "def", "generate_string", "(", "converter", ",", "input", ",", "format", "=", "'xml'", ")", ":", "serializer", "=", "generator", ".", "new", "(", "format", ")", "if", "serializer", "is", "None", ":", "raise", "TypeError", "(", "'invalid output format '", "+"...
d2afa85a48034d6ee34580e49e16542f31ad208e
train
generate_string_to_file
Like generate(), but reads the input from a string instead of from a file, and writes the output to the given output file. :type converter: compiler.Context :param converter: The compiled converter. :type input: str :param input: The string to convert. :type output_file: str :param outpu...
Gelatin/util.py
def generate_string_to_file(converter, input, output_file, format='xml', out_encoding='utf8'): """ Like generate(), but reads the input from a string instead of from a file, and writes the output ...
def generate_string_to_file(converter, input, output_file, format='xml', out_encoding='utf8'): """ Like generate(), but reads the input from a string instead of from a file, and writes the output ...
[ "Like", "generate", "()", "but", "reads", "the", "input", "from", "a", "string", "instead", "of", "from", "a", "file", "and", "writes", "the", "output", "to", "the", "given", "output", "file", "." ]
knipknap/Gelatin
python
https://github.com/knipknap/Gelatin/blob/d2afa85a48034d6ee34580e49e16542f31ad208e/Gelatin/util.py#L130-L154
[ "def", "generate_string_to_file", "(", "converter", ",", "input", ",", "output_file", ",", "format", "=", "'xml'", ",", "out_encoding", "=", "'utf8'", ")", ":", "with", "codecs", ".", "open", "(", "output_file", ",", "'w'", ",", "encoding", "=", "out_encodin...
d2afa85a48034d6ee34580e49e16542f31ad208e
train
is_now
A very simple cron-like parser to determine, if (cron-like) string is valid for this date and time. @input: s = cron-like string (minute, hour, day of month, month, day of week) dt = datetime to use as reference time, defaults to now @output: boolean of result
pycron/__init__.py
def is_now(s, dt=None): ''' A very simple cron-like parser to determine, if (cron-like) string is valid for this date and time. @input: s = cron-like string (minute, hour, day of month, month, day of week) dt = datetime to use as reference time, defaults to now @output: boolean of result...
def is_now(s, dt=None): ''' A very simple cron-like parser to determine, if (cron-like) string is valid for this date and time. @input: s = cron-like string (minute, hour, day of month, month, day of week) dt = datetime to use as reference time, defaults to now @output: boolean of result...
[ "A", "very", "simple", "cron", "-", "like", "parser", "to", "determine", "if", "(", "cron", "-", "like", ")", "string", "is", "valid", "for", "this", "date", "and", "time", "." ]
kipe/pycron
python
https://github.com/kipe/pycron/blob/25319f5ca175b9db6a5e966e1ab2f75bd57fd269/pycron/__init__.py#L92-L109
[ "def", "is_now", "(", "s", ",", "dt", "=", "None", ")", ":", "if", "dt", "is", "None", ":", "dt", "=", "datetime", ".", "now", "(", ")", "minute", ",", "hour", ",", "dom", ",", "month", ",", "dow", "=", "s", ".", "split", "(", "' '", ")", "...
25319f5ca175b9db6a5e966e1ab2f75bd57fd269
train
has_been
A parser to check whether a (cron-like) string has been true during a certain time period. Useful for applications which cannot check every minute or need to catch up during a restart. @input: s = cron-like string (minute, hour, day of month, month, day of week) since = datetime to use as refere...
pycron/__init__.py
def has_been(s, since, dt=None): ''' A parser to check whether a (cron-like) string has been true during a certain time period. Useful for applications which cannot check every minute or need to catch up during a restart. @input: s = cron-like string (minute, hour, day of month, month, day of we...
def has_been(s, since, dt=None): ''' A parser to check whether a (cron-like) string has been true during a certain time period. Useful for applications which cannot check every minute or need to catch up during a restart. @input: s = cron-like string (minute, hour, day of month, month, day of we...
[ "A", "parser", "to", "check", "whether", "a", "(", "cron", "-", "like", ")", "string", "has", "been", "true", "during", "a", "certain", "time", "period", ".", "Useful", "for", "applications", "which", "cannot", "check", "every", "minute", "or", "need", "...
kipe/pycron
python
https://github.com/kipe/pycron/blob/25319f5ca175b9db6a5e966e1ab2f75bd57fd269/pycron/__init__.py#L112-L133
[ "def", "has_been", "(", "s", ",", "since", ",", "dt", "=", "None", ")", ":", "if", "dt", "is", "None", ":", "dt", "=", "datetime", ".", "now", "(", "tz", "=", "since", ".", "tzinfo", ")", "if", "dt", "<", "since", ":", "raise", "ValueError", "(...
25319f5ca175b9db6a5e966e1ab2f75bd57fd269
train
auprc
Area under the precision-recall curve
kopt/eval_metrics.py
def auprc(y_true, y_pred): """Area under the precision-recall curve """ y_true, y_pred = _mask_value_nan(y_true, y_pred) return skm.average_precision_score(y_true, y_pred)
def auprc(y_true, y_pred): """Area under the precision-recall curve """ y_true, y_pred = _mask_value_nan(y_true, y_pred) return skm.average_precision_score(y_true, y_pred)
[ "Area", "under", "the", "precision", "-", "recall", "curve" ]
Avsecz/kopt
python
https://github.com/Avsecz/kopt/blob/fe4f929c8938590845306a759547daa5ba8bd7a9/kopt/eval_metrics.py#L49-L53
[ "def", "auprc", "(", "y_true", ",", "y_pred", ")", ":", "y_true", ",", "y_pred", "=", "_mask_value_nan", "(", "y_true", ",", "y_pred", ")", "return", "skm", ".", "average_precision_score", "(", "y_true", ",", "y_pred", ")" ]
fe4f929c8938590845306a759547daa5ba8bd7a9
train
KMongoTrials.best_trial_tid
Get tid of the best trial rank=0 means the best model rank=1 means second best ...
kopt/hyopt.py
def best_trial_tid(self, rank=0): """Get tid of the best trial rank=0 means the best model rank=1 means second best ... """ candidates = [t for t in self.trials if t['result']['status'] == STATUS_OK] if len(candidates) == 0: retu...
def best_trial_tid(self, rank=0): """Get tid of the best trial rank=0 means the best model rank=1 means second best ... """ candidates = [t for t in self.trials if t['result']['status'] == STATUS_OK] if len(candidates) == 0: retu...
[ "Get", "tid", "of", "the", "best", "trial" ]
Avsecz/kopt
python
https://github.com/Avsecz/kopt/blob/fe4f929c8938590845306a759547daa5ba8bd7a9/kopt/hyopt.py#L129-L143
[ "def", "best_trial_tid", "(", "self", ",", "rank", "=", "0", ")", ":", "candidates", "=", "[", "t", "for", "t", "in", "self", ".", "trials", "if", "t", "[", "'result'", "]", "[", "'status'", "]", "==", "STATUS_OK", "]", "if", "len", "(", "candidate...
fe4f929c8938590845306a759547daa5ba8bd7a9
train
KMongoTrials.count_by_state_unsynced
Extends the original object in order to inject checking for stalled jobs and killing them if they are running for too long
kopt/hyopt.py
def count_by_state_unsynced(self, arg): """Extends the original object in order to inject checking for stalled jobs and killing them if they are running for too long """ if self.kill_timeout is not None: self.delete_running(self.kill_timeout) return super(KMongoTrials...
def count_by_state_unsynced(self, arg): """Extends the original object in order to inject checking for stalled jobs and killing them if they are running for too long """ if self.kill_timeout is not None: self.delete_running(self.kill_timeout) return super(KMongoTrials...
[ "Extends", "the", "original", "object", "in", "order", "to", "inject", "checking", "for", "stalled", "jobs", "and", "killing", "them", "if", "they", "are", "running", "for", "too", "long" ]
Avsecz/kopt
python
https://github.com/Avsecz/kopt/blob/fe4f929c8938590845306a759547daa5ba8bd7a9/kopt/hyopt.py#L171-L177
[ "def", "count_by_state_unsynced", "(", "self", ",", "arg", ")", ":", "if", "self", ".", "kill_timeout", "is", "not", "None", ":", "self", ".", "delete_running", "(", "self", ".", "kill_timeout", ")", "return", "super", "(", "KMongoTrials", ",", "self", ")"...
fe4f929c8938590845306a759547daa5ba8bd7a9
train
KMongoTrials.plot_history
Plot the loss curves
kopt/hyopt.py
def plot_history(self, tid, scores=["loss", "f1", "accuracy"], figsize=(15, 3)): """Plot the loss curves""" history = self.train_history(tid) import matplotlib.pyplot as plt fig = plt.figure(figsize=figsize) for i, score in enumerate(scores): plt...
def plot_history(self, tid, scores=["loss", "f1", "accuracy"], figsize=(15, 3)): """Plot the loss curves""" history = self.train_history(tid) import matplotlib.pyplot as plt fig = plt.figure(figsize=figsize) for i, score in enumerate(scores): plt...
[ "Plot", "the", "loss", "curves" ]
Avsecz/kopt
python
https://github.com/Avsecz/kopt/blob/fe4f929c8938590845306a759547daa5ba8bd7a9/kopt/hyopt.py#L245-L261
[ "def", "plot_history", "(", "self", ",", "tid", ",", "scores", "=", "[", "\"loss\"", ",", "\"f1\"", ",", "\"accuracy\"", "]", ",", "figsize", "=", "(", "15", ",", "3", ")", ")", ":", "history", "=", "self", ".", "train_history", "(", "tid", ")", "i...
fe4f929c8938590845306a759547daa5ba8bd7a9
train
KMongoTrials.load_model
Load saved keras model of the trial. If tid = None, get the best model Not applicable for trials ran in cross validion (i.e. not applicable for `CompileFN.cv_n_folds is None`
kopt/hyopt.py
def load_model(self, tid, custom_objects=None): """Load saved keras model of the trial. If tid = None, get the best model Not applicable for trials ran in cross validion (i.e. not applicable for `CompileFN.cv_n_folds is None` """ if tid is None: tid = self.b...
def load_model(self, tid, custom_objects=None): """Load saved keras model of the trial. If tid = None, get the best model Not applicable for trials ran in cross validion (i.e. not applicable for `CompileFN.cv_n_folds is None` """ if tid is None: tid = self.b...
[ "Load", "saved", "keras", "model", "of", "the", "trial", "." ]
Avsecz/kopt
python
https://github.com/Avsecz/kopt/blob/fe4f929c8938590845306a759547daa5ba8bd7a9/kopt/hyopt.py#L263-L275
[ "def", "load_model", "(", "self", ",", "tid", ",", "custom_objects", "=", "None", ")", ":", "if", "tid", "is", "None", ":", "tid", "=", "self", ".", "best_trial_tid", "(", ")", "model_path", "=", "self", ".", "get_trial", "(", "tid", ")", "[", "\"res...
fe4f929c8938590845306a759547daa5ba8bd7a9
train
KMongoTrials.n_ok
Number of ok trials()
kopt/hyopt.py
def n_ok(self): """Number of ok trials() """ if len(self.trials) == 0: return 0 else: return np.sum(np.array(self.statuses()) == "ok")
def n_ok(self): """Number of ok trials() """ if len(self.trials) == 0: return 0 else: return np.sum(np.array(self.statuses()) == "ok")
[ "Number", "of", "ok", "trials", "()" ]
Avsecz/kopt
python
https://github.com/Avsecz/kopt/blob/fe4f929c8938590845306a759547daa5ba8bd7a9/kopt/hyopt.py#L277-L283
[ "def", "n_ok", "(", "self", ")", ":", "if", "len", "(", "self", ".", "trials", ")", "==", "0", ":", "return", "0", "else", ":", "return", "np", ".", "sum", "(", "np", ".", "array", "(", "self", ".", "statuses", "(", ")", ")", "==", "\"ok\"", ...
fe4f929c8938590845306a759547daa5ba8bd7a9
train
KMongoTrials.get_ok_results
Return a list of results with ok status
kopt/hyopt.py
def get_ok_results(self, verbose=True): """Return a list of results with ok status """ if len(self.trials) == 0: return [] not_ok = np.where(np.array(self.statuses()) != "ok")[0] if len(not_ok) > 0 and verbose: print("{0}/{1} trials were not ok.".format(...
def get_ok_results(self, verbose=True): """Return a list of results with ok status """ if len(self.trials) == 0: return [] not_ok = np.where(np.array(self.statuses()) != "ok")[0] if len(not_ok) > 0 and verbose: print("{0}/{1} trials were not ok.".format(...
[ "Return", "a", "list", "of", "results", "with", "ok", "status" ]
Avsecz/kopt
python
https://github.com/Avsecz/kopt/blob/fe4f929c8938590845306a759547daa5ba8bd7a9/kopt/hyopt.py#L285-L300
[ "def", "get_ok_results", "(", "self", ",", "verbose", "=", "True", ")", ":", "if", "len", "(", "self", ".", "trials", ")", "==", "0", ":", "return", "[", "]", "not_ok", "=", "np", ".", "where", "(", "np", ".", "array", "(", "self", ".", "statuses...
fe4f929c8938590845306a759547daa5ba8bd7a9
train
VerifierMiddleware
Common wrapper for the authentication modules. * Parses the request before passing it on to the authentication module. * Sets 'pyoidc' cookie if authentication succeeds. * Redirects the user to complete the authentication. * Allows the user to retry authentication if it fails. :param...
oidc-provider/simple_op/src/provider/server/server.py
def VerifierMiddleware(verifier): """Common wrapper for the authentication modules. * Parses the request before passing it on to the authentication module. * Sets 'pyoidc' cookie if authentication succeeds. * Redirects the user to complete the authentication. * Allows the user to ret...
def VerifierMiddleware(verifier): """Common wrapper for the authentication modules. * Parses the request before passing it on to the authentication module. * Sets 'pyoidc' cookie if authentication succeeds. * Redirects the user to complete the authentication. * Allows the user to ret...
[ "Common", "wrapper", "for", "the", "authentication", "modules", ".", "*", "Parses", "the", "request", "before", "passing", "it", "on", "to", "the", "authentication", "module", ".", "*", "Sets", "pyoidc", "cookie", "if", "authentication", "succeeds", ".", "*", ...
ga4gh/ga4gh-server
python
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/oidc-provider/simple_op/src/provider/server/server.py#L34-L67
[ "def", "VerifierMiddleware", "(", "verifier", ")", ":", "@", "wraps", "(", "verifier", ".", "verify", ")", "def", "wrapper", "(", "environ", ",", "start_response", ")", ":", "data", "=", "get_post", "(", "environ", ")", "kwargs", "=", "dict", "(", "urlpa...
1aa18922ef136db8604f6f098cb1732cba6f2a76
train
pyoidcMiddleware
Common wrapper for the underlying pyoidc library functions. Reads GET params and POST data before passing it on the library and converts the response from oic.utils.http_util to wsgi. :param func: underlying library function
oidc-provider/simple_op/src/provider/server/server.py
def pyoidcMiddleware(func): """Common wrapper for the underlying pyoidc library functions. Reads GET params and POST data before passing it on the library and converts the response from oic.utils.http_util to wsgi. :param func: underlying library function """ def wrapper(environ, start_response...
def pyoidcMiddleware(func): """Common wrapper for the underlying pyoidc library functions. Reads GET params and POST data before passing it on the library and converts the response from oic.utils.http_util to wsgi. :param func: underlying library function """ def wrapper(environ, start_response...
[ "Common", "wrapper", "for", "the", "underlying", "pyoidc", "library", "functions", ".", "Reads", "GET", "params", "and", "POST", "data", "before", "passing", "it", "on", "the", "library", "and", "converts", "the", "response", "from", "oic", ".", "utils", "."...
ga4gh/ga4gh-server
python
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/oidc-provider/simple_op/src/provider/server/server.py#L70-L83
[ "def", "pyoidcMiddleware", "(", "func", ")", ":", "def", "wrapper", "(", "environ", ",", "start_response", ")", ":", "data", "=", "get_or_post", "(", "environ", ")", "cookies", "=", "environ", ".", "get", "(", "\"HTTP_COOKIE\"", ",", "\"\"", ")", "resp", ...
1aa18922ef136db8604f6f098cb1732cba6f2a76
train
resp2flask
Convert an oic.utils.http_util instance to Flask.
oidc-provider/simple_op/src/provider/server/server.py
def resp2flask(resp): """Convert an oic.utils.http_util instance to Flask.""" if isinstance(resp, Redirect) or isinstance(resp, SeeOther): code = int(resp.status.split()[0]) raise cherrypy.HTTPRedirect(resp.message, code) return resp.message, resp.status, resp.headers
def resp2flask(resp): """Convert an oic.utils.http_util instance to Flask.""" if isinstance(resp, Redirect) or isinstance(resp, SeeOther): code = int(resp.status.split()[0]) raise cherrypy.HTTPRedirect(resp.message, code) return resp.message, resp.status, resp.headers
[ "Convert", "an", "oic", ".", "utils", ".", "http_util", "instance", "to", "Flask", "." ]
ga4gh/ga4gh-server
python
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/oidc-provider/simple_op/src/provider/server/server.py#L86-L91
[ "def", "resp2flask", "(", "resp", ")", ":", "if", "isinstance", "(", "resp", ",", "Redirect", ")", "or", "isinstance", "(", "resp", ",", "SeeOther", ")", ":", "code", "=", "int", "(", "resp", ".", "status", ".", "split", "(", ")", "[", "0", "]", ...
1aa18922ef136db8604f6f098cb1732cba6f2a76
train
setup_authentication_methods
Add all authentication methods specified in the configuration.
oidc-provider/simple_op/src/provider/server/server.py
def setup_authentication_methods(authn_config, template_env): """Add all authentication methods specified in the configuration.""" routing = {} ac = AuthnBroker() for authn_method in authn_config: cls = make_cls_from_name(authn_method["class"]) instance = cls(template_env=template_env, *...
def setup_authentication_methods(authn_config, template_env): """Add all authentication methods specified in the configuration.""" routing = {} ac = AuthnBroker() for authn_method in authn_config: cls = make_cls_from_name(authn_method["class"]) instance = cls(template_env=template_env, *...
[ "Add", "all", "authentication", "methods", "specified", "in", "the", "configuration", "." ]
ga4gh/ga4gh-server
python
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/oidc-provider/simple_op/src/provider/server/server.py#L94-L104
[ "def", "setup_authentication_methods", "(", "authn_config", ",", "template_env", ")", ":", "routing", "=", "{", "}", "ac", "=", "AuthnBroker", "(", ")", "for", "authn_method", "in", "authn_config", ":", "cls", "=", "make_cls_from_name", "(", "authn_method", "[",...
1aa18922ef136db8604f6f098cb1732cba6f2a76
train
setup_endpoints
Setup the OpenID Connect Provider endpoints.
oidc-provider/simple_op/src/provider/server/server.py
def setup_endpoints(provider): """Setup the OpenID Connect Provider endpoints.""" app_routing = {} endpoints = [ AuthorizationEndpoint( pyoidcMiddleware(provider.authorization_endpoint)), TokenEndpoint( pyoidcMiddleware(provider.token_endpoint)), UserinfoEndpo...
def setup_endpoints(provider): """Setup the OpenID Connect Provider endpoints.""" app_routing = {} endpoints = [ AuthorizationEndpoint( pyoidcMiddleware(provider.authorization_endpoint)), TokenEndpoint( pyoidcMiddleware(provider.token_endpoint)), UserinfoEndpo...
[ "Setup", "the", "OpenID", "Connect", "Provider", "endpoints", "." ]
ga4gh/ga4gh-server
python
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/oidc-provider/simple_op/src/provider/server/server.py#L107-L126
[ "def", "setup_endpoints", "(", "provider", ")", ":", "app_routing", "=", "{", "}", "endpoints", "=", "[", "AuthorizationEndpoint", "(", "pyoidcMiddleware", "(", "provider", ".", "authorization_endpoint", ")", ")", ",", "TokenEndpoint", "(", "pyoidcMiddleware", "("...
1aa18922ef136db8604f6f098cb1732cba6f2a76
train
_webfinger
Handle webfinger requests.
oidc-provider/simple_op/src/provider/server/server.py
def _webfinger(provider, request, **kwargs): """Handle webfinger requests.""" params = urlparse.parse_qs(request) if params["rel"][0] == OIC_ISSUER: wf = WebFinger() return Response(wf.response(params["resource"][0], provider.baseurl), headers=[("Content-Type", "appli...
def _webfinger(provider, request, **kwargs): """Handle webfinger requests.""" params = urlparse.parse_qs(request) if params["rel"][0] == OIC_ISSUER: wf = WebFinger() return Response(wf.response(params["resource"][0], provider.baseurl), headers=[("Content-Type", "appli...
[ "Handle", "webfinger", "requests", "." ]
ga4gh/ga4gh-server
python
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/oidc-provider/simple_op/src/provider/server/server.py#L129-L137
[ "def", "_webfinger", "(", "provider", ",", "request", ",", "*", "*", "kwargs", ")", ":", "params", "=", "urlparse", ".", "parse_qs", "(", "request", ")", "if", "params", "[", "\"rel\"", "]", "[", "0", "]", "==", "OIC_ISSUER", ":", "wf", "=", "WebFing...
1aa18922ef136db8604f6f098cb1732cba6f2a76
train
Gff3DbBackend.featuresQuery
Converts a dictionary of keyword arguments into a tuple of SQL select statements and the list of SQL arguments
ga4gh/server/datamodel/sequence_annotations.py
def featuresQuery(self, **kwargs): """ Converts a dictionary of keyword arguments into a tuple of SQL select statements and the list of SQL arguments """ # TODO: Optimize by refactoring out string concatenation sql = "" sql_rows = "SELECT * FROM FEATURE WHERE id >...
def featuresQuery(self, **kwargs): """ Converts a dictionary of keyword arguments into a tuple of SQL select statements and the list of SQL arguments """ # TODO: Optimize by refactoring out string concatenation sql = "" sql_rows = "SELECT * FROM FEATURE WHERE id >...
[ "Converts", "a", "dictionary", "of", "keyword", "arguments", "into", "a", "tuple", "of", "SQL", "select", "statements", "and", "the", "list", "of", "SQL", "arguments" ]
ga4gh/ga4gh-server
python
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/sequence_annotations.py#L79-L114
[ "def", "featuresQuery", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# TODO: Optimize by refactoring out string concatenation", "sql", "=", "\"\"", "sql_rows", "=", "\"SELECT * FROM FEATURE WHERE id > 1 \"", "sql_args", "=", "(", ")", "if", "'name'", "in", "kwargs...
1aa18922ef136db8604f6f098cb1732cba6f2a76
train
Gff3DbBackend.searchFeaturesInDb
Perform a full features query in database. :param startIndex: int representing first record to return :param maxResults: int representing number of records to return :param referenceName: string representing reference name, ex 'chr1' :param start: int position on reference to start sear...
ga4gh/server/datamodel/sequence_annotations.py
def searchFeaturesInDb( self, startIndex=0, maxResults=None, referenceName=None, start=None, end=None, parentId=None, featureTypes=None, name=None, geneSymbol=None): """ Perform a full features query in database. :param startIndex: int representin...
def searchFeaturesInDb( self, startIndex=0, maxResults=None, referenceName=None, start=None, end=None, parentId=None, featureTypes=None, name=None, geneSymbol=None): """ Perform a full features query in database. :param startIndex: int representin...
[ "Perform", "a", "full", "features", "query", "in", "database", "." ]
ga4gh/ga4gh-server
python
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/sequence_annotations.py#L116-L142
[ "def", "searchFeaturesInDb", "(", "self", ",", "startIndex", "=", "0", ",", "maxResults", "=", "None", ",", "referenceName", "=", "None", ",", "start", "=", "None", ",", "end", "=", "None", ",", "parentId", "=", "None", ",", "featureTypes", "=", "None", ...
1aa18922ef136db8604f6f098cb1732cba6f2a76
train
Gff3DbBackend.getFeatureById
Fetch feature by featureID. :param featureId: the FeatureID as found in GFF3 records :return: dictionary representing a feature object, or None if no match is found.
ga4gh/server/datamodel/sequence_annotations.py
def getFeatureById(self, featureId): """ Fetch feature by featureID. :param featureId: the FeatureID as found in GFF3 records :return: dictionary representing a feature object, or None if no match is found. """ sql = "SELECT * FROM FEATURE WHERE id = ?" ...
def getFeatureById(self, featureId): """ Fetch feature by featureID. :param featureId: the FeatureID as found in GFF3 records :return: dictionary representing a feature object, or None if no match is found. """ sql = "SELECT * FROM FEATURE WHERE id = ?" ...
[ "Fetch", "feature", "by", "featureID", "." ]
ga4gh/ga4gh-server
python
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/sequence_annotations.py#L144-L157
[ "def", "getFeatureById", "(", "self", ",", "featureId", ")", ":", "sql", "=", "\"SELECT * FROM FEATURE WHERE id = ?\"", "query", "=", "self", ".", "_dbconn", ".", "execute", "(", "sql", ",", "(", "featureId", ",", ")", ")", "ret", "=", "query", ".", "fetch...
1aa18922ef136db8604f6f098cb1732cba6f2a76
train
AbstractFeatureSet.toProtocolElement
Returns the representation of this FeatureSet as the corresponding ProtocolElement.
ga4gh/server/datamodel/sequence_annotations.py
def toProtocolElement(self): """ Returns the representation of this FeatureSet as the corresponding ProtocolElement. """ gaFeatureSet = protocol.FeatureSet() gaFeatureSet.id = self.getId() gaFeatureSet.dataset_id = self.getParentContainer().getId() gaFeatu...
def toProtocolElement(self): """ Returns the representation of this FeatureSet as the corresponding ProtocolElement. """ gaFeatureSet = protocol.FeatureSet() gaFeatureSet.id = self.getId() gaFeatureSet.dataset_id = self.getParentContainer().getId() gaFeatu...
[ "Returns", "the", "representation", "of", "this", "FeatureSet", "as", "the", "corresponding", "ProtocolElement", "." ]
ga4gh/ga4gh-server
python
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/sequence_annotations.py#L185-L200
[ "def", "toProtocolElement", "(", "self", ")", ":", "gaFeatureSet", "=", "protocol", ".", "FeatureSet", "(", ")", "gaFeatureSet", ".", "id", "=", "self", ".", "getId", "(", ")", "gaFeatureSet", ".", "dataset_id", "=", "self", ".", "getParentContainer", "(", ...
1aa18922ef136db8604f6f098cb1732cba6f2a76