repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
mbedmicro/pyOCD
pyocd/debug/svd/model.py
_check_type
def _check_type(value, expected_type): """Perform type checking on the provided value This is a helper that will raise ``TypeError`` if the provided value is not an instance of the provided type. This method should be used sparingly but can be good for preventing problems earlier when you want to rest...
python
def _check_type(value, expected_type): """Perform type checking on the provided value This is a helper that will raise ``TypeError`` if the provided value is not an instance of the provided type. This method should be used sparingly but can be good for preventing problems earlier when you want to rest...
[ "def", "_check_type", "(", "value", ",", "expected_type", ")", ":", "if", "not", "isinstance", "(", "value", ",", "expected_type", ")", ":", "raise", "TypeError", "(", "\"Value {value!r} has unexpected type {actual_type!r}, expected {expected_type!r}\"", ".", "format", ...
Perform type checking on the provided value This is a helper that will raise ``TypeError`` if the provided value is not an instance of the provided type. This method should be used sparingly but can be good for preventing problems earlier when you want to restrict duck typing to make the types of fiel...
[ "Perform", "type", "checking", "on", "the", "provided", "value" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/debug/svd/model.py#L26-L42
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/windows.py
_get_cached_mounted_points
def _get_cached_mounted_points(): """! Get the volumes present on the system @return List of mount points and their associated target id Ex. [{ 'mount_point': 'D:', 'target_id_usb_id': 'xxxx'}, ...] """ result = [] try: # Open the registry key for mounted devices mounted_device...
python
def _get_cached_mounted_points(): """! Get the volumes present on the system @return List of mount points and their associated target id Ex. [{ 'mount_point': 'D:', 'target_id_usb_id': 'xxxx'}, ...] """ result = [] try: # Open the registry key for mounted devices mounted_device...
[ "def", "_get_cached_mounted_points", "(", ")", ":", "result", "=", "[", "]", "try", ":", "# Open the registry key for mounted devices", "mounted_devices_key", "=", "winreg", ".", "OpenKey", "(", "winreg", ".", "HKEY_LOCAL_MACHINE", ",", "\"SYSTEM\\\\MountedDevices\"", "...
! Get the volumes present on the system @return List of mount points and their associated target id Ex. [{ 'mount_point': 'D:', 'target_id_usb_id': 'xxxx'}, ...]
[ "!", "Get", "the", "volumes", "present", "on", "the", "system" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/windows.py#L64-L96
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/windows.py
_vid_pid_path_to_usb_info
def _vid_pid_path_to_usb_info(vid_pid_path): """! Provide the vendor ID and product ID of a device based on its entry in the registry @return Returns {'vendor_id': '<vendor ID>', 'product': '<product ID>'} @details If the vendor ID or product ID can't be determined, they will be returned as None. ""...
python
def _vid_pid_path_to_usb_info(vid_pid_path): """! Provide the vendor ID and product ID of a device based on its entry in the registry @return Returns {'vendor_id': '<vendor ID>', 'product': '<product ID>'} @details If the vendor ID or product ID can't be determined, they will be returned as None. ""...
[ "def", "_vid_pid_path_to_usb_info", "(", "vid_pid_path", ")", ":", "result", "=", "{", "\"vendor_id\"", ":", "None", ",", "\"product_id\"", ":", "None", "}", "for", "component", "in", "vid_pid_path", ".", "split", "(", "\"&\"", ")", ":", "component_part", "=",...
! Provide the vendor ID and product ID of a device based on its entry in the registry @return Returns {'vendor_id': '<vendor ID>', 'product': '<product ID>'} @details If the vendor ID or product ID can't be determined, they will be returned as None.
[ "!", "Provide", "the", "vendor", "ID", "and", "product", "ID", "of", "a", "device", "based", "on", "its", "entry", "in", "the", "registry" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/windows.py#L189-L209
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/windows.py
_iter_keys_as_str
def _iter_keys_as_str(key): """! Iterate over subkeys of a key returning subkey as string """ for i in range(winreg.QueryInfoKey(key)[0]): yield winreg.EnumKey(key, i)
python
def _iter_keys_as_str(key): """! Iterate over subkeys of a key returning subkey as string """ for i in range(winreg.QueryInfoKey(key)[0]): yield winreg.EnumKey(key, i)
[ "def", "_iter_keys_as_str", "(", "key", ")", ":", "for", "i", "in", "range", "(", "winreg", ".", "QueryInfoKey", "(", "key", ")", "[", "0", "]", ")", ":", "yield", "winreg", ".", "EnumKey", "(", "key", ",", "i", ")" ]
! Iterate over subkeys of a key returning subkey as string
[ "!", "Iterate", "over", "subkeys", "of", "a", "key", "returning", "subkey", "as", "string" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/windows.py#L212-L216
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/windows.py
_iter_keys
def _iter_keys(key): """! Iterate over subkeys of a key """ for i in range(winreg.QueryInfoKey(key)[0]): yield winreg.OpenKey(key, winreg.EnumKey(key, i))
python
def _iter_keys(key): """! Iterate over subkeys of a key """ for i in range(winreg.QueryInfoKey(key)[0]): yield winreg.OpenKey(key, winreg.EnumKey(key, i))
[ "def", "_iter_keys", "(", "key", ")", ":", "for", "i", "in", "range", "(", "winreg", ".", "QueryInfoKey", "(", "key", ")", "[", "0", "]", ")", ":", "yield", "winreg", ".", "OpenKey", "(", "key", ",", "winreg", ".", "EnumKey", "(", "key", ",", "i"...
! Iterate over subkeys of a key
[ "!", "Iterate", "over", "subkeys", "of", "a", "key" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/windows.py#L219-L223
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/windows.py
_iter_vals
def _iter_vals(key): """! Iterate over values of a key """ for i in range(winreg.QueryInfoKey(key)[1]): yield winreg.EnumValue(key, i)
python
def _iter_vals(key): """! Iterate over values of a key """ for i in range(winreg.QueryInfoKey(key)[1]): yield winreg.EnumValue(key, i)
[ "def", "_iter_vals", "(", "key", ")", ":", "for", "i", "in", "range", "(", "winreg", ".", "QueryInfoKey", "(", "key", ")", "[", "1", "]", ")", ":", "yield", "winreg", ".", "EnumValue", "(", "key", ",", "i", ")" ]
! Iterate over values of a key
[ "!", "Iterate", "over", "values", "of", "a", "key" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/windows.py#L226-L230
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/windows.py
MbedLsToolsWindows.mount_point_ready
def mount_point_ready(self, path): """! Check if a mount point is ready for file operations @return Returns True if the given path exists, False otherwise @details Calling the Windows command `dir` instead of using the python `os.path.exists`. The latter causes a Python error box to appe...
python
def mount_point_ready(self, path): """! Check if a mount point is ready for file operations @return Returns True if the given path exists, False otherwise @details Calling the Windows command `dir` instead of using the python `os.path.exists`. The latter causes a Python error box to appe...
[ "def", "mount_point_ready", "(", "self", ",", "path", ")", ":", "stdout", ",", "stderr", ",", "retcode", "=", "self", ".", "_run_cli_process", "(", "\"dir %s\"", "%", "path", ")", "result", "=", "True", "if", "retcode", "==", "0", "else", "False", "retur...
! Check if a mount point is ready for file operations @return Returns True if the given path exists, False otherwise @details Calling the Windows command `dir` instead of using the python `os.path.exists`. The latter causes a Python error box to appear claiming there is "No Disk" for som...
[ "!", "Check", "if", "a", "mount", "point", "is", "ready", "for", "file", "operations" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/windows.py#L478-L490
train
mbedmicro/pyOCD
pyocd/target/pack/flash_algo.py
PackFlashAlgo._create_algo_bin
def _create_algo_bin(self, ro_rw_zi): """Create a binary blob of the flash algo which can execute from ram""" sect_ro, sect_rw, sect_zi = ro_rw_zi algo_size = sect_ro.length + sect_rw.length + sect_zi.length algo_data = bytearray(algo_size) for section in (sect_ro, sect_rw): ...
python
def _create_algo_bin(self, ro_rw_zi): """Create a binary blob of the flash algo which can execute from ram""" sect_ro, sect_rw, sect_zi = ro_rw_zi algo_size = sect_ro.length + sect_rw.length + sect_zi.length algo_data = bytearray(algo_size) for section in (sect_ro, sect_rw): ...
[ "def", "_create_algo_bin", "(", "self", ",", "ro_rw_zi", ")", ":", "sect_ro", ",", "sect_rw", ",", "sect_zi", "=", "ro_rw_zi", "algo_size", "=", "sect_ro", ".", "length", "+", "sect_rw", ".", "length", "+", "sect_zi", ".", "length", "algo_data", "=", "byte...
Create a binary blob of the flash algo which can execute from ram
[ "Create", "a", "binary", "blob", "of", "the", "flash", "algo", "which", "can", "execute", "from", "ram" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/target/pack/flash_algo.py#L232-L243
train
mbedmicro/pyOCD
pyocd/target/pack/flash_algo.py
PackFlashInfo._sector_and_sz_itr
def _sector_and_sz_itr(self, elf, data_start): """Iterator which returns starting address and sector size""" for entry_start in itertools.count(data_start, self.FLASH_SECTORS_STRUCT_SIZE): data = elf.read(entry_start, self.FLASH_SECTORS_STRUCT_SIZE) size, start = struct.unpack(se...
python
def _sector_and_sz_itr(self, elf, data_start): """Iterator which returns starting address and sector size""" for entry_start in itertools.count(data_start, self.FLASH_SECTORS_STRUCT_SIZE): data = elf.read(entry_start, self.FLASH_SECTORS_STRUCT_SIZE) size, start = struct.unpack(se...
[ "def", "_sector_and_sz_itr", "(", "self", ",", "elf", ",", "data_start", ")", ":", "for", "entry_start", "in", "itertools", ".", "count", "(", "data_start", ",", "self", ".", "FLASH_SECTORS_STRUCT_SIZE", ")", ":", "data", "=", "elf", ".", "read", "(", "ent...
Iterator which returns starting address and sector size
[ "Iterator", "which", "returns", "starting", "address", "and", "sector", "size" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/target/pack/flash_algo.py#L292-L300
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/darwin.py
_prune
def _prune(current, keys): """ Reduce the amount of data we have to sift through to only include the specified keys, and children that contain the specified keys """ pruned_current = {k: current[k] for k in keys if k in current} pruned_children = list( filter( None, [...
python
def _prune(current, keys): """ Reduce the amount of data we have to sift through to only include the specified keys, and children that contain the specified keys """ pruned_current = {k: current[k] for k in keys if k in current} pruned_children = list( filter( None, [...
[ "def", "_prune", "(", "current", ",", "keys", ")", ":", "pruned_current", "=", "{", "k", ":", "current", "[", "k", "]", "for", "k", "in", "keys", "if", "k", "in", "current", "}", "pruned_children", "=", "list", "(", "filter", "(", "None", ",", "[",...
Reduce the amount of data we have to sift through to only include the specified keys, and children that contain the specified keys
[ "Reduce", "the", "amount", "of", "data", "we", "have", "to", "sift", "through", "to", "only", "include", "the", "specified", "keys", "and", "children", "that", "contain", "the", "specified", "keys" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/darwin.py#L46-L63
train
mbedmicro/pyOCD
pyocd/gdbserver/context_facade.py
GDBDebugContextFacade.get_register_context
def get_register_context(self): """ return hexadecimal dump of registers as expected by GDB """ logging.debug("GDB getting register context") resp = b'' reg_num_list = [reg.reg_num for reg in self._register_list] vals = self._context.read_core_registers_raw(reg_nu...
python
def get_register_context(self): """ return hexadecimal dump of registers as expected by GDB """ logging.debug("GDB getting register context") resp = b'' reg_num_list = [reg.reg_num for reg in self._register_list] vals = self._context.read_core_registers_raw(reg_nu...
[ "def", "get_register_context", "(", "self", ")", ":", "logging", ".", "debug", "(", "\"GDB getting register context\"", ")", "resp", "=", "b''", "reg_num_list", "=", "[", "reg", ".", "reg_num", "for", "reg", "in", "self", ".", "_register_list", "]", "vals", ...
return hexadecimal dump of registers as expected by GDB
[ "return", "hexadecimal", "dump", "of", "registers", "as", "expected", "by", "GDB" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/gdbserver/context_facade.py#L60-L76
train
mbedmicro/pyOCD
pyocd/gdbserver/context_facade.py
GDBDebugContextFacade.set_register_context
def set_register_context(self, data): """ Set registers from GDB hexadecimal string. """ logging.debug("GDB setting register context") reg_num_list = [] reg_data_list = [] for reg in self._register_list: if reg.bitsize == 64: regValue =...
python
def set_register_context(self, data): """ Set registers from GDB hexadecimal string. """ logging.debug("GDB setting register context") reg_num_list = [] reg_data_list = [] for reg in self._register_list: if reg.bitsize == 64: regValue =...
[ "def", "set_register_context", "(", "self", ",", "data", ")", ":", "logging", ".", "debug", "(", "\"GDB setting register context\"", ")", "reg_num_list", "=", "[", "]", "reg_data_list", "=", "[", "]", "for", "reg", "in", "self", ".", "_register_list", ":", "...
Set registers from GDB hexadecimal string.
[ "Set", "registers", "from", "GDB", "hexadecimal", "string", "." ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/gdbserver/context_facade.py#L78-L95
train
mbedmicro/pyOCD
pyocd/gdbserver/context_facade.py
GDBDebugContextFacade.set_register
def set_register(self, reg, data): """ Set single register from GDB hexadecimal string. reg parameter is the index of register in targetXML sent to GDB. """ if reg < 0: return elif reg < len(self._register_list): regName = self._register_list[reg]....
python
def set_register(self, reg, data): """ Set single register from GDB hexadecimal string. reg parameter is the index of register in targetXML sent to GDB. """ if reg < 0: return elif reg < len(self._register_list): regName = self._register_list[reg]....
[ "def", "set_register", "(", "self", ",", "reg", ",", "data", ")", ":", "if", "reg", "<", "0", ":", "return", "elif", "reg", "<", "len", "(", "self", ".", "_register_list", ")", ":", "regName", "=", "self", ".", "_register_list", "[", "reg", "]", "....
Set single register from GDB hexadecimal string. reg parameter is the index of register in targetXML sent to GDB.
[ "Set", "single", "register", "from", "GDB", "hexadecimal", "string", ".", "reg", "parameter", "is", "the", "index", "of", "register", "in", "targetXML", "sent", "to", "GDB", "." ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/gdbserver/context_facade.py#L97-L112
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
_get_interfaces
def _get_interfaces(): """Get the connected USB devices""" # Get CMSIS-DAPv1 interfaces. v1_interfaces = INTERFACE[USB_BACKEND].get_all_connected_interfaces() # Get CMSIS-DAPv2 interfaces. v2_interfaces = INTERFACE[USB_BACKEND_V2].get_all_connected_interfaces() # Prefer v2 over v1 if a...
python
def _get_interfaces(): """Get the connected USB devices""" # Get CMSIS-DAPv1 interfaces. v1_interfaces = INTERFACE[USB_BACKEND].get_all_connected_interfaces() # Get CMSIS-DAPv2 interfaces. v2_interfaces = INTERFACE[USB_BACKEND_V2].get_all_connected_interfaces() # Prefer v2 over v1 if a...
[ "def", "_get_interfaces", "(", ")", ":", "# Get CMSIS-DAPv1 interfaces.", "v1_interfaces", "=", "INTERFACE", "[", "USB_BACKEND", "]", ".", "get_all_connected_interfaces", "(", ")", "# Get CMSIS-DAPv2 interfaces.", "v2_interfaces", "=", "INTERFACE", "[", "USB_BACKEND_V2", ...
Get the connected USB devices
[ "Get", "the", "connected", "USB", "devices" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L51-L66
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
_Transfer.add_response
def add_response(self, data): """ Add data read from the remote device to this object. The size of data added must match exactly the size that get_data_size returns. """ assert len(data) == self._size_bytes result = [] for i in range(0, self._size_bytes, ...
python
def add_response(self, data): """ Add data read from the remote device to this object. The size of data added must match exactly the size that get_data_size returns. """ assert len(data) == self._size_bytes result = [] for i in range(0, self._size_bytes, ...
[ "def", "add_response", "(", "self", ",", "data", ")", ":", "assert", "len", "(", "data", ")", "==", "self", ".", "_size_bytes", "result", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "self", ".", "_size_bytes", ",", "4", ")", ":", "wo...
Add data read from the remote device to this object. The size of data added must match exactly the size that get_data_size returns.
[ "Add", "data", "read", "from", "the", "remote", "device", "to", "this", "object", "." ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L107-L120
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
_Transfer.get_result
def get_result(self): """ Get the result of this transfer. """ while self._result is None: if len(self.daplink._commands_to_read) > 0: self.daplink._read_packet() else: assert not self.daplink._crnt_cmd.get_empty() s...
python
def get_result(self): """ Get the result of this transfer. """ while self._result is None: if len(self.daplink._commands_to_read) > 0: self.daplink._read_packet() else: assert not self.daplink._crnt_cmd.get_empty() s...
[ "def", "get_result", "(", "self", ")", ":", "while", "self", ".", "_result", "is", "None", ":", "if", "len", "(", "self", ".", "daplink", ".", "_commands_to_read", ")", ">", "0", ":", "self", ".", "daplink", ".", "_read_packet", "(", ")", "else", ":"...
Get the result of this transfer.
[ "Get", "the", "result", "of", "this", "transfer", "." ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L129-L148
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
_Command._get_free_words
def _get_free_words(self, blockAllowed, isRead): """ Return the number of words free in the transmit packet """ if blockAllowed: # DAP_TransferBlock request packet: # BYTE | BYTE *****| SHORT**********| BYTE *************| WORD *********| # > 0x06 | ...
python
def _get_free_words(self, blockAllowed, isRead): """ Return the number of words free in the transmit packet """ if blockAllowed: # DAP_TransferBlock request packet: # BYTE | BYTE *****| SHORT**********| BYTE *************| WORD *********| # > 0x06 | ...
[ "def", "_get_free_words", "(", "self", ",", "blockAllowed", ",", "isRead", ")", ":", "if", "blockAllowed", ":", "# DAP_TransferBlock request packet:", "# BYTE | BYTE *****| SHORT**********| BYTE *************| WORD *********|", "# > 0x06 | DAP Index | Transfer Count | Transfer Reques...
Return the number of words free in the transmit packet
[ "Return", "the", "number", "of", "words", "free", "in", "the", "transmit", "packet" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L176-L215
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
_Command.add
def add(self, count, request, data, dap_index): """ Add a single or block register transfer operation to this command """ assert self._data_encoded is False if self._dap_index is None: self._dap_index = dap_index assert self._dap_index == dap_index if...
python
def add(self, count, request, data, dap_index): """ Add a single or block register transfer operation to this command """ assert self._data_encoded is False if self._dap_index is None: self._dap_index = dap_index assert self._dap_index == dap_index if...
[ "def", "add", "(", "self", ",", "count", ",", "request", ",", "data", ",", "dap_index", ")", ":", "assert", "self", ".", "_data_encoded", "is", "False", "if", "self", ".", "_dap_index", "is", "None", ":", "self", ".", "_dap_index", "=", "dap_index", "a...
Add a single or block register transfer operation to this command
[ "Add", "a", "single", "or", "block", "register", "transfer", "operation", "to", "this", "command" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L261-L284
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
_Command.decode_data
def decode_data(self, data): """ Decode the response data """ assert self.get_empty() is False assert self._data_encoded is True if self._block_allowed: data = self._decode_transfer_block_data(data) else: data = self._decode_transfer_data(d...
python
def decode_data(self, data): """ Decode the response data """ assert self.get_empty() is False assert self._data_encoded is True if self._block_allowed: data = self._decode_transfer_block_data(data) else: data = self._decode_transfer_data(d...
[ "def", "decode_data", "(", "self", ",", "data", ")", ":", "assert", "self", ".", "get_empty", "(", ")", "is", "False", "assert", "self", ".", "_data_encoded", "is", "True", "if", "self", ".", "_block_allowed", ":", "data", "=", "self", ".", "_decode_tran...
Decode the response data
[ "Decode", "the", "response", "data" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L429-L439
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
DAPAccessCMSISDAP.get_connected_devices
def get_connected_devices(): """ Return an array of all mbed boards connected """ all_daplinks = [] all_interfaces = _get_interfaces() for interface in all_interfaces: try: new_daplink = DAPAccessCMSISDAP(None, interface=interface) ...
python
def get_connected_devices(): """ Return an array of all mbed boards connected """ all_daplinks = [] all_interfaces = _get_interfaces() for interface in all_interfaces: try: new_daplink = DAPAccessCMSISDAP(None, interface=interface) ...
[ "def", "get_connected_devices", "(", ")", ":", "all_daplinks", "=", "[", "]", "all_interfaces", "=", "_get_interfaces", "(", ")", "for", "interface", "in", "all_interfaces", ":", "try", ":", "new_daplink", "=", "DAPAccessCMSISDAP", "(", "None", ",", "interface",...
Return an array of all mbed boards connected
[ "Return", "an", "array", "of", "all", "mbed", "boards", "connected" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L452-L465
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
DAPAccessCMSISDAP.set_deferred_transfer
def set_deferred_transfer(self, enable): """ Allow transfers to be delayed and buffered By default deferred transfers are turned off. All reads and writes will be completed by the time the function returns. When enabled packets are buffered and sent all at once, which ...
python
def set_deferred_transfer(self, enable): """ Allow transfers to be delayed and buffered By default deferred transfers are turned off. All reads and writes will be completed by the time the function returns. When enabled packets are buffered and sent all at once, which ...
[ "def", "set_deferred_transfer", "(", "self", ",", "enable", ")", ":", "if", "self", ".", "_deferred_transfer", "and", "not", "enable", ":", "self", ".", "flush", "(", ")", "self", ".", "_deferred_transfer", "=", "enable" ]
Allow transfers to be delayed and buffered By default deferred transfers are turned off. All reads and writes will be completed by the time the function returns. When enabled packets are buffered and sent all at once, which increases speed. When memory is written to, the transfer ...
[ "Allow", "transfers", "to", "be", "delayed", "and", "buffered" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L626-L650
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
DAPAccessCMSISDAP._init_deferred_buffers
def _init_deferred_buffers(self): """ Initialize or reinitalize all the deferred transfer buffers Calling this method will drop all pending transactions so use with care. """ # List of transfers that have been started, but # not completed (started by write_reg, r...
python
def _init_deferred_buffers(self): """ Initialize or reinitalize all the deferred transfer buffers Calling this method will drop all pending transactions so use with care. """ # List of transfers that have been started, but # not completed (started by write_reg, r...
[ "def", "_init_deferred_buffers", "(", "self", ")", ":", "# List of transfers that have been started, but", "# not completed (started by write_reg, read_reg,", "# reg_write_repeat and reg_read_repeat)", "self", ".", "_transfer_list", "=", "collections", ".", "deque", "(", ")", "# ...
Initialize or reinitalize all the deferred transfer buffers Calling this method will drop all pending transactions so use with care.
[ "Initialize", "or", "reinitalize", "all", "the", "deferred", "transfer", "buffers" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L851-L869
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
DAPAccessCMSISDAP._read_packet
def _read_packet(self): """ Reads and decodes a single packet Reads a single packet from the device and stores the data from it in the current Command object """ # Grab command, send it and decode response cmd = self._commands_to_read.popleft() tr...
python
def _read_packet(self): """ Reads and decodes a single packet Reads a single packet from the device and stores the data from it in the current Command object """ # Grab command, send it and decode response cmd = self._commands_to_read.popleft() tr...
[ "def", "_read_packet", "(", "self", ")", ":", "# Grab command, send it and decode response", "cmd", "=", "self", ".", "_commands_to_read", ".", "popleft", "(", ")", "try", ":", "raw_data", "=", "self", ".", "_interface", ".", "read", "(", ")", "raw_data", "=",...
Reads and decodes a single packet Reads a single packet from the device and stores the data from it in the current Command object
[ "Reads", "and", "decodes", "a", "single", "packet" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L871-L912
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
DAPAccessCMSISDAP._send_packet
def _send_packet(self): """ Send a single packet to the interface This function guarentees that the number of packets that are stored in daplink's buffer (the number of packets written but not read) does not exceed the number supported by the given device. """ ...
python
def _send_packet(self): """ Send a single packet to the interface This function guarentees that the number of packets that are stored in daplink's buffer (the number of packets written but not read) does not exceed the number supported by the given device. """ ...
[ "def", "_send_packet", "(", "self", ")", ":", "cmd", "=", "self", ".", "_crnt_cmd", "if", "cmd", ".", "get_empty", "(", ")", ":", "return", "max_packets", "=", "self", ".", "_interface", ".", "get_packet_count", "(", ")", "if", "len", "(", "self", ".",...
Send a single packet to the interface This function guarentees that the number of packets that are stored in daplink's buffer (the number of packets written but not read) does not exceed the number supported by the given device.
[ "Send", "a", "single", "packet", "to", "the", "interface" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L914-L937
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
DAPAccessCMSISDAP._write
def _write(self, dap_index, transfer_count, transfer_request, transfer_data): """ Write one or more commands """ assert dap_index == 0 # dap index currently unsupported assert isinstance(transfer_count, six.integer_types) assert isinstance(transfer_request...
python
def _write(self, dap_index, transfer_count, transfer_request, transfer_data): """ Write one or more commands """ assert dap_index == 0 # dap index currently unsupported assert isinstance(transfer_count, six.integer_types) assert isinstance(transfer_request...
[ "def", "_write", "(", "self", ",", "dap_index", ",", "transfer_count", ",", "transfer_request", ",", "transfer_data", ")", ":", "assert", "dap_index", "==", "0", "# dap index currently unsupported", "assert", "isinstance", "(", "transfer_count", ",", "six", ".", "...
Write one or more commands
[ "Write", "one", "or", "more", "commands" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L939-L992
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
DAPAccessCMSISDAP._jtag_to_swd
def _jtag_to_swd(self): """ Send the command to switch from SWD to jtag """ data = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff] self._protocol.swj_sequence(data) data = [0x9e, 0xe7] self._protocol.swj_sequence(data) data = [0xff, 0xff, 0xff, 0xff, 0xff, 0x...
python
def _jtag_to_swd(self): """ Send the command to switch from SWD to jtag """ data = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff] self._protocol.swj_sequence(data) data = [0x9e, 0xe7] self._protocol.swj_sequence(data) data = [0xff, 0xff, 0xff, 0xff, 0xff, 0x...
[ "def", "_jtag_to_swd", "(", "self", ")", ":", "data", "=", "[", "0xff", ",", "0xff", ",", "0xff", ",", "0xff", ",", "0xff", ",", "0xff", ",", "0xff", "]", "self", ".", "_protocol", ".", "swj_sequence", "(", "data", ")", "data", "=", "[", "0x9e", ...
Send the command to switch from SWD to jtag
[ "Send", "the", "command", "to", "switch", "from", "SWD", "to", "jtag" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L994-L1008
train
mbedmicro/pyOCD
pyocd/probe/pydapaccess/dap_access_cmsis_dap.py
DAPAccessCMSISDAP._abort_all_transfers
def _abort_all_transfers(self, exception): """ Abort any ongoing transfers and clear all buffers """ pending_reads = len(self._commands_to_read) # invalidate _transfer_list for transfer in self._transfer_list: transfer.add_error(exception) # clear all ...
python
def _abort_all_transfers(self, exception): """ Abort any ongoing transfers and clear all buffers """ pending_reads = len(self._commands_to_read) # invalidate _transfer_list for transfer in self._transfer_list: transfer.add_error(exception) # clear all ...
[ "def", "_abort_all_transfers", "(", "self", ",", "exception", ")", ":", "pending_reads", "=", "len", "(", "self", ".", "_commands_to_read", ")", "# invalidate _transfer_list", "for", "transfer", "in", "self", ".", "_transfer_list", ":", "transfer", ".", "add_error...
Abort any ongoing transfers and clear all buffers
[ "Abort", "any", "ongoing", "transfers", "and", "clear", "all", "buffers" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L1010-L1025
train
mbedmicro/pyOCD
pyocd/target/builtin/target_nRF51822_xxAA.py
NRF51.resetn
def resetn(self): """ reset a core. After a call to this function, the core is running """ #Regular reset will kick NRF out of DBG mode logging.debug("target_nrf51.reset: enable reset pin") self.write_memory(RESET, RESET_ENABLE) #reset logging.debu...
python
def resetn(self): """ reset a core. After a call to this function, the core is running """ #Regular reset will kick NRF out of DBG mode logging.debug("target_nrf51.reset: enable reset pin") self.write_memory(RESET, RESET_ENABLE) #reset logging.debu...
[ "def", "resetn", "(", "self", ")", ":", "#Regular reset will kick NRF out of DBG mode", "logging", ".", "debug", "(", "\"target_nrf51.reset: enable reset pin\"", ")", "self", ".", "write_memory", "(", "RESET", ",", "RESET_ENABLE", ")", "#reset", "logging", ".", "debug...
reset a core. After a call to this function, the core is running
[ "reset", "a", "core", ".", "After", "a", "call", "to", "this", "function", "the", "core", "is", "running" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/target/builtin/target_nRF51822_xxAA.py#L67-L77
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/base.py
StlinkDetectBase.list_mbeds
def list_mbeds(self): """ List details of connected devices @return Returns list of structures with detailed info about each mbed @details Function returns list of dictionaries with mbed attributes 'mount_point', TargetID name etc. Function returns mbed list with platform names...
python
def list_mbeds(self): """ List details of connected devices @return Returns list of structures with detailed info about each mbed @details Function returns list of dictionaries with mbed attributes 'mount_point', TargetID name etc. Function returns mbed list with platform names...
[ "def", "list_mbeds", "(", "self", ")", ":", "platform_count", "=", "{", "}", "candidates", "=", "list", "(", "self", ".", "find_candidates", "(", ")", ")", "result", "=", "[", "]", "for", "device", "in", "candidates", ":", "if", "not", "device", ".", ...
List details of connected devices @return Returns list of structures with detailed info about each mbed @details Function returns list of dictionaries with mbed attributes 'mount_point', TargetID name etc. Function returns mbed list with platform names if possible
[ "List", "details", "of", "connected", "devices" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/base.py#L52-L69
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/base.py
StlinkDetectBase._update_device_from_fs
def _update_device_from_fs(self, device): """ Updates the device information based on files from its 'mount_point' @param device Dictionary containing device information """ try: directory_entries = listdir(device["mount_point"]) # Always try to update using ...
python
def _update_device_from_fs(self, device): """ Updates the device information based on files from its 'mount_point' @param device Dictionary containing device information """ try: directory_entries = listdir(device["mount_point"]) # Always try to update using ...
[ "def", "_update_device_from_fs", "(", "self", ",", "device", ")", ":", "try", ":", "directory_entries", "=", "listdir", "(", "device", "[", "\"mount_point\"", "]", ")", "# Always try to update using daplink compatible boards processself.", "# This is done for backwards compat...
Updates the device information based on files from its 'mount_point' @param device Dictionary containing device information
[ "Updates", "the", "device", "information", "based", "on", "files", "from", "its", "mount_point" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/base.py#L71-L91
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/base.py
StlinkDetectBase._read_htm_ids
def _read_htm_ids(self, mount_point): """! Function scans mbed.htm to get information about TargetID. @param mount_point mbed mount point (disk / drive letter) @return Function returns targetID, in case of failure returns None. @details Note: This function should be improved to scan vari...
python
def _read_htm_ids(self, mount_point): """! Function scans mbed.htm to get information about TargetID. @param mount_point mbed mount point (disk / drive letter) @return Function returns targetID, in case of failure returns None. @details Note: This function should be improved to scan vari...
[ "def", "_read_htm_ids", "(", "self", ",", "mount_point", ")", ":", "result", "=", "{", "}", "target_id", "=", "None", "for", "line", "in", "self", ".", "_htm_lines", "(", "mount_point", ")", ":", "target_id", "=", "target_id", "or", "self", ".", "_target...
! Function scans mbed.htm to get information about TargetID. @param mount_point mbed mount point (disk / drive letter) @return Function returns targetID, in case of failure returns None. @details Note: This function should be improved to scan variety of boards' mbed.htm files
[ "!", "Function", "scans", "mbed", ".", "htm", "to", "get", "information", "about", "TargetID", "." ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/base.py#L109-L120
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/base.py
StlinkDetectBase._target_id_from_htm
def _target_id_from_htm(self, line): """! Extract Target id from htm line. @return Target id or None """ # Detecting modern mbed.htm file format m = re.search("\\?code=([a-fA-F0-9]+)", line) if m: result = m.groups()[0] return result # Last...
python
def _target_id_from_htm(self, line): """! Extract Target id from htm line. @return Target id or None """ # Detecting modern mbed.htm file format m = re.search("\\?code=([a-fA-F0-9]+)", line) if m: result = m.groups()[0] return result # Last...
[ "def", "_target_id_from_htm", "(", "self", ",", "line", ")", ":", "# Detecting modern mbed.htm file format", "m", "=", "re", ".", "search", "(", "\"\\\\?code=([a-fA-F0-9]+)\"", ",", "line", ")", "if", "m", ":", "result", "=", "m", ".", "groups", "(", ")", "[...
! Extract Target id from htm line. @return Target id or None
[ "!", "Extract", "Target", "id", "from", "htm", "line", "." ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/base.py#L128-L143
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/base.py
StlinkDetectBase._run_cli_process
def _run_cli_process(cmd, shell=True): """! Runs command as a process and return stdout, stderr and ret code @param cmd Command to execute @return Tuple of (stdout, stderr, returncode) """ from subprocess import Popen, PIPE p = Popen(cmd, shell=shell, stdout=PIPE, stderr...
python
def _run_cli_process(cmd, shell=True): """! Runs command as a process and return stdout, stderr and ret code @param cmd Command to execute @return Tuple of (stdout, stderr, returncode) """ from subprocess import Popen, PIPE p = Popen(cmd, shell=shell, stdout=PIPE, stderr...
[ "def", "_run_cli_process", "(", "cmd", ",", "shell", "=", "True", ")", ":", "from", "subprocess", "import", "Popen", ",", "PIPE", "p", "=", "Popen", "(", "cmd", ",", "shell", "=", "shell", ",", "stdout", "=", "PIPE", ",", "stderr", "=", "PIPE", ")", ...
! Runs command as a process and return stdout, stderr and ret code @param cmd Command to execute @return Tuple of (stdout, stderr, returncode)
[ "!", "Runs", "command", "as", "a", "process", "and", "return", "stdout", "stderr", "and", "ret", "code" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/base.py#L151-L160
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/factory.py
create_mbed_detector
def create_mbed_detector(**kwargs): """! Factory used to create host OS specific mbed-lstools object :param kwargs: keyword arguments to pass along to the constructors @return Returns MbedLsTools object or None if host OS is not supported """ host_os = platform.system() if host_os == "Windows"...
python
def create_mbed_detector(**kwargs): """! Factory used to create host OS specific mbed-lstools object :param kwargs: keyword arguments to pass along to the constructors @return Returns MbedLsTools object or None if host OS is not supported """ host_os = platform.system() if host_os == "Windows"...
[ "def", "create_mbed_detector", "(", "*", "*", "kwargs", ")", ":", "host_os", "=", "platform", ".", "system", "(", ")", "if", "host_os", "==", "\"Windows\"", ":", "from", ".", "windows", "import", "StlinkDetectWindows", "return", "StlinkDetectWindows", "(", "*"...
! Factory used to create host OS specific mbed-lstools object :param kwargs: keyword arguments to pass along to the constructors @return Returns MbedLsTools object or None if host OS is not supported
[ "!", "Factory", "used", "to", "create", "host", "OS", "specific", "mbed", "-", "lstools", "object" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/factory.py#L22-L43
train
mbedmicro/pyOCD
pyocd/coresight/ap.py
_locked
def _locked(func): """! Decorator to automatically lock an AccessPort method.""" def _locking(self, *args, **kwargs): try: self.lock() return func(self, *args, **kwargs) finally: self.unlock() return _locking
python
def _locked(func): """! Decorator to automatically lock an AccessPort method.""" def _locking(self, *args, **kwargs): try: self.lock() return func(self, *args, **kwargs) finally: self.unlock() return _locking
[ "def", "_locked", "(", "func", ")", ":", "def", "_locking", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "lock", "(", ")", "return", "func", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ...
! Decorator to automatically lock an AccessPort method.
[ "!", "Decorator", "to", "automatically", "lock", "an", "AccessPort", "method", "." ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/ap.py#L136-L144
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/linux.py
StlinkDetectLinuxGeneric._dev_by_id
def _dev_by_id(self, device_type): """! Get a dict, USBID -> device, for a device class @param device_type The type of devices to search. For exmaple, "serial" looks for all serial devices connected to this computer @return A dict: Device USBID -> device file in /dev """ ...
python
def _dev_by_id(self, device_type): """! Get a dict, USBID -> device, for a device class @param device_type The type of devices to search. For exmaple, "serial" looks for all serial devices connected to this computer @return A dict: Device USBID -> device file in /dev """ ...
[ "def", "_dev_by_id", "(", "self", ",", "device_type", ")", ":", "dir", "=", "os", ".", "path", ".", "join", "(", "\"/dev\"", ",", "device_type", ",", "\"by-id\"", ")", "if", "os", ".", "path", ".", "isdir", "(", "dir", ")", ":", "to_ret", "=", "dic...
! Get a dict, USBID -> device, for a device class @param device_type The type of devices to search. For exmaple, "serial" looks for all serial devices connected to this computer @return A dict: Device USBID -> device file in /dev
[ "!", "Get", "a", "dict", "USBID", "-", ">", "device", "for", "a", "device", "class" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/linux.py#L63-L85
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/linux.py
StlinkDetectLinuxGeneric._hex_ids
def _hex_ids(self, dev_list): """! Build a USBID map for a device list @param disk_list List of disks in a system with USBID decoration @return Returns map USBID -> device file in /dev @details Uses regular expressions to get a USBID (TargeTIDs) a "by-id" symbolic link ...
python
def _hex_ids(self, dev_list): """! Build a USBID map for a device list @param disk_list List of disks in a system with USBID decoration @return Returns map USBID -> device file in /dev @details Uses regular expressions to get a USBID (TargeTIDs) a "by-id" symbolic link ...
[ "def", "_hex_ids", "(", "self", ",", "dev_list", ")", ":", "for", "dl", "in", "dev_list", ":", "match", "=", "self", ".", "nlp", ".", "search", "(", "dl", ")", "if", "match", ":", "yield", "match", ".", "group", "(", "\"usbid\"", ")", ",", "_readli...
! Build a USBID map for a device list @param disk_list List of disks in a system with USBID decoration @return Returns map USBID -> device file in /dev @details Uses regular expressions to get a USBID (TargeTIDs) a "by-id" symbolic link
[ "!", "Build", "a", "USBID", "map", "for", "a", "device", "list" ]
41a174718a9739f3cbe785c2ba21cb7fd1310c6f
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/linux.py#L100-L110
train
influxdata/influxdb-python
influxdb/line_protocol.py
_get_unicode
def _get_unicode(data, force=False): """Try to return a text aka unicode object from the given data.""" if isinstance(data, binary_type): return data.decode('utf-8') elif data is None: return '' elif force: if PY2: return unicode(data) else: return...
python
def _get_unicode(data, force=False): """Try to return a text aka unicode object from the given data.""" if isinstance(data, binary_type): return data.decode('utf-8') elif data is None: return '' elif force: if PY2: return unicode(data) else: return...
[ "def", "_get_unicode", "(", "data", ",", "force", "=", "False", ")", ":", "if", "isinstance", "(", "data", ",", "binary_type", ")", ":", "return", "data", ".", "decode", "(", "'utf-8'", ")", "elif", "data", "is", "None", ":", "return", "''", "elif", ...
Try to return a text aka unicode object from the given data.
[ "Try", "to", "return", "a", "text", "aka", "unicode", "object", "from", "the", "given", "data", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/line_protocol.py#L104-L116
train
influxdata/influxdb-python
influxdb/line_protocol.py
make_lines
def make_lines(data, precision=None): """Extract points from given dict. Extracts the points from the given dict and returns a Unicode string matching the line protocol introduced in InfluxDB 0.9.0. """ lines = [] static_tags = data.get('tags') for point in data['points']: elements ...
python
def make_lines(data, precision=None): """Extract points from given dict. Extracts the points from the given dict and returns a Unicode string matching the line protocol introduced in InfluxDB 0.9.0. """ lines = [] static_tags = data.get('tags') for point in data['points']: elements ...
[ "def", "make_lines", "(", "data", ",", "precision", "=", "None", ")", ":", "lines", "=", "[", "]", "static_tags", "=", "data", ".", "get", "(", "'tags'", ")", "for", "point", "in", "data", "[", "'points'", "]", ":", "elements", "=", "[", "]", "# ad...
Extract points from given dict. Extracts the points from the given dict and returns a Unicode string matching the line protocol introduced in InfluxDB 0.9.0.
[ "Extract", "points", "from", "given", "dict", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/line_protocol.py#L119-L172
train
influxdata/influxdb-python
examples/tutorial_pandas.py
main
def main(host='localhost', port=8086): """Instantiate the connection to the InfluxDB client.""" user = 'root' password = 'root' dbname = 'demo' protocol = 'json' client = DataFrameClient(host, port, user, password, dbname) print("Create pandas DataFrame") df = pd.DataFrame(data=list(ra...
python
def main(host='localhost', port=8086): """Instantiate the connection to the InfluxDB client.""" user = 'root' password = 'root' dbname = 'demo' protocol = 'json' client = DataFrameClient(host, port, user, password, dbname) print("Create pandas DataFrame") df = pd.DataFrame(data=list(ra...
[ "def", "main", "(", "host", "=", "'localhost'", ",", "port", "=", "8086", ")", ":", "user", "=", "'root'", "password", "=", "'root'", "dbname", "=", "'demo'", "protocol", "=", "'json'", "client", "=", "DataFrameClient", "(", "host", ",", "port", ",", "...
Instantiate the connection to the InfluxDB client.
[ "Instantiate", "the", "connection", "to", "the", "InfluxDB", "client", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/examples/tutorial_pandas.py#L10-L38
train
influxdata/influxdb-python
influxdb/client.py
_parse_dsn
def _parse_dsn(dsn): """Parse data source name. This is a helper function to split the data source name provided in the from_dsn classmethod """ conn_params = urlparse(dsn) init_args = {} scheme_info = conn_params.scheme.split('+') if len(scheme_info) == 1: scheme = scheme_info[...
python
def _parse_dsn(dsn): """Parse data source name. This is a helper function to split the data source name provided in the from_dsn classmethod """ conn_params = urlparse(dsn) init_args = {} scheme_info = conn_params.scheme.split('+') if len(scheme_info) == 1: scheme = scheme_info[...
[ "def", "_parse_dsn", "(", "dsn", ")", ":", "conn_params", "=", "urlparse", "(", "dsn", ")", "init_args", "=", "{", "}", "scheme_info", "=", "conn_params", ".", "scheme", ".", "split", "(", "'+'", ")", "if", "len", "(", "scheme_info", ")", "==", "1", ...
Parse data source name. This is a helper function to split the data source name provided in the from_dsn classmethod
[ "Parse", "data", "source", "name", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L1059-L1097
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.from_dsn
def from_dsn(cls, dsn, **kwargs): r"""Generate an instance of InfluxDBClient from given data source name. Return an instance of :class:`~.InfluxDBClient` from the provided data source name. Supported schemes are "influxdb", "https+influxdb" and "udp+influxdb". Parameters for the :class:...
python
def from_dsn(cls, dsn, **kwargs): r"""Generate an instance of InfluxDBClient from given data source name. Return an instance of :class:`~.InfluxDBClient` from the provided data source name. Supported schemes are "influxdb", "https+influxdb" and "udp+influxdb". Parameters for the :class:...
[ "def", "from_dsn", "(", "cls", ",", "dsn", ",", "*", "*", "kwargs", ")", ":", "init_args", "=", "_parse_dsn", "(", "dsn", ")", "host", ",", "port", "=", "init_args", ".", "pop", "(", "'hosts'", ")", "[", "0", "]", "init_args", "[", "'host'", "]", ...
r"""Generate an instance of InfluxDBClient from given data source name. Return an instance of :class:`~.InfluxDBClient` from the provided data source name. Supported schemes are "influxdb", "https+influxdb" and "udp+influxdb". Parameters for the :class:`~.InfluxDBClient` constructor may...
[ "r", "Generate", "an", "instance", "of", "InfluxDBClient", "from", "given", "data", "source", "name", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L159-L197
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.switch_user
def switch_user(self, username, password): """Change the client's username. :param username: the username to switch to :type username: str :param password: the password for the username :type password: str """ self._username = username self._password = pa...
python
def switch_user(self, username, password): """Change the client's username. :param username: the username to switch to :type username: str :param password: the password for the username :type password: str """ self._username = username self._password = pa...
[ "def", "switch_user", "(", "self", ",", "username", ",", "password", ")", ":", "self", ".", "_username", "=", "username", "self", ".", "_password", "=", "password" ]
Change the client's username. :param username: the username to switch to :type username: str :param password: the password for the username :type password: str
[ "Change", "the", "client", "s", "username", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L207-L216
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.request
def request(self, url, method='GET', params=None, data=None, expected_response_code=200, headers=None): """Make a HTTP request to the InfluxDB API. :param url: the path of the HTTP request, e.g. write, query, etc. :type url: str :param method: the HTTP method for the req...
python
def request(self, url, method='GET', params=None, data=None, expected_response_code=200, headers=None): """Make a HTTP request to the InfluxDB API. :param url: the path of the HTTP request, e.g. write, query, etc. :type url: str :param method: the HTTP method for the req...
[ "def", "request", "(", "self", ",", "url", ",", "method", "=", "'GET'", ",", "params", "=", "None", ",", "data", "=", "None", ",", "expected_response_code", "=", "200", ",", "headers", "=", "None", ")", ":", "url", "=", "\"{0}/{1}\"", ".", "format", ...
Make a HTTP request to the InfluxDB API. :param url: the path of the HTTP request, e.g. write, query, etc. :type url: str :param method: the HTTP method for the request, defaults to GET :type method: str :param params: additional parameters for the request, defaults to None ...
[ "Make", "a", "HTTP", "request", "to", "the", "InfluxDB", "API", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L218-L286
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.write
def write(self, data, params=None, expected_response_code=204, protocol='json'): """Write data to InfluxDB. :param data: the data to be written :type data: (if protocol is 'json') dict (if protocol is 'line') sequence of line protocol strings ...
python
def write(self, data, params=None, expected_response_code=204, protocol='json'): """Write data to InfluxDB. :param data: the data to be written :type data: (if protocol is 'json') dict (if protocol is 'line') sequence of line protocol strings ...
[ "def", "write", "(", "self", ",", "data", ",", "params", "=", "None", ",", "expected_response_code", "=", "204", ",", "protocol", "=", "'json'", ")", ":", "headers", "=", "self", ".", "_headers", "headers", "[", "'Content-Type'", "]", "=", "'application/oc...
Write data to InfluxDB. :param data: the data to be written :type data: (if protocol is 'json') dict (if protocol is 'line') sequence of line protocol strings or single string :param params: additional parameters for the request, d...
[ "Write", "data", "to", "InfluxDB", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L288-L329
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.query
def query(self, query, params=None, bind_params=None, epoch=None, expected_response_code=200, database=None, raise_errors=True, chunked=False, chunk_size=0, method="GET"): ...
python
def query(self, query, params=None, bind_params=None, epoch=None, expected_response_code=200, database=None, raise_errors=True, chunked=False, chunk_size=0, method="GET"): ...
[ "def", "query", "(", "self", ",", "query", ",", "params", "=", "None", ",", "bind_params", "=", "None", ",", "epoch", "=", "None", ",", "expected_response_code", "=", "200", ",", "database", "=", "None", ",", "raise_errors", "=", "True", ",", "chunked", ...
Send a query to InfluxDB. .. danger:: In order to avoid injection vulnerabilities (similar to `SQL injection <https://www.owasp.org/index.php/SQL_Injection>`_ vulnerabilities), do not directly include untrusted data into the ``query`` parameter, use ``bind_params...
[ "Send", "a", "query", "to", "InfluxDB", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L345-L452
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.ping
def ping(self): """Check connectivity to InfluxDB. :returns: The version of the InfluxDB the client is connected to """ response = self.request( url="ping", method='GET', expected_response_code=204 ) return response.headers['X-Influxd...
python
def ping(self): """Check connectivity to InfluxDB. :returns: The version of the InfluxDB the client is connected to """ response = self.request( url="ping", method='GET', expected_response_code=204 ) return response.headers['X-Influxd...
[ "def", "ping", "(", "self", ")", ":", "response", "=", "self", ".", "request", "(", "url", "=", "\"ping\"", ",", "method", "=", "'GET'", ",", "expected_response_code", "=", "204", ")", "return", "response", ".", "headers", "[", "'X-Influxdb-Version'", "]" ...
Check connectivity to InfluxDB. :returns: The version of the InfluxDB the client is connected to
[ "Check", "connectivity", "to", "InfluxDB", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L516-L527
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.create_retention_policy
def create_retention_policy(self, name, duration, replication, database=None, default=False, shard_duration="0s"): """Create a retention policy for a database. :param name: the name of the new retention policy :type name: str ...
python
def create_retention_policy(self, name, duration, replication, database=None, default=False, shard_duration="0s"): """Create a retention policy for a database. :param name: the name of the new retention policy :type name: str ...
[ "def", "create_retention_policy", "(", "self", ",", "name", ",", "duration", ",", "replication", ",", "database", "=", "None", ",", "default", "=", "False", ",", "shard_duration", "=", "\"0s\"", ")", ":", "query_string", "=", "\"CREATE RETENTION POLICY {0} ON {1} ...
Create a retention policy for a database. :param name: the name of the new retention policy :type name: str :param duration: the duration of the new retention policy. Durations such as 1h, 90m, 12h, 7d, and 4w, are all supported and mean 1 hour, 90 minutes, 12 hours, 7 d...
[ "Create", "a", "retention", "policy", "for", "a", "database", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L648-L688
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.alter_retention_policy
def alter_retention_policy(self, name, database=None, duration=None, replication=None, default=None, shard_duration=None): """Modify an existing retention policy for a database. :param name: the name of the retention policy to modify ...
python
def alter_retention_policy(self, name, database=None, duration=None, replication=None, default=None, shard_duration=None): """Modify an existing retention policy for a database. :param name: the name of the retention policy to modify ...
[ "def", "alter_retention_policy", "(", "self", ",", "name", ",", "database", "=", "None", ",", "duration", "=", "None", ",", "replication", "=", "None", ",", "default", "=", "None", ",", "shard_duration", "=", "None", ")", ":", "query_string", "=", "(", "...
Modify an existing retention policy for a database. :param name: the name of the retention policy to modify :type name: str :param database: the database for which the retention policy is modified. Defaults to current client's database :type database: str :param dura...
[ "Modify", "an", "existing", "retention", "policy", "for", "a", "database", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L690-L737
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.drop_retention_policy
def drop_retention_policy(self, name, database=None): """Drop an existing retention policy for a database. :param name: the name of the retention policy to drop :type name: str :param database: the database for which the retention policy is dropped. Defaults to current clien...
python
def drop_retention_policy(self, name, database=None): """Drop an existing retention policy for a database. :param name: the name of the retention policy to drop :type name: str :param database: the database for which the retention policy is dropped. Defaults to current clien...
[ "def", "drop_retention_policy", "(", "self", ",", "name", ",", "database", "=", "None", ")", ":", "query_string", "=", "(", "\"DROP RETENTION POLICY {0} ON {1}\"", ")", ".", "format", "(", "quote_ident", "(", "name", ")", ",", "quote_ident", "(", "database", "...
Drop an existing retention policy for a database. :param name: the name of the retention policy to drop :type name: str :param database: the database for which the retention policy is dropped. Defaults to current client's database :type database: str
[ "Drop", "an", "existing", "retention", "policy", "for", "a", "database", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L739-L751
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.get_list_retention_policies
def get_list_retention_policies(self, database=None): """Get the list of retention policies for a database. :param database: the name of the database, defaults to the client's current database :type database: str :returns: all retention policies for the database :rty...
python
def get_list_retention_policies(self, database=None): """Get the list of retention policies for a database. :param database: the name of the database, defaults to the client's current database :type database: str :returns: all retention policies for the database :rty...
[ "def", "get_list_retention_policies", "(", "self", ",", "database", "=", "None", ")", ":", "if", "not", "(", "database", "or", "self", ".", "_database", ")", ":", "raise", "InfluxDBClientError", "(", "\"get_list_retention_policies() requires a database as a \"", "\"pa...
Get the list of retention policies for a database. :param database: the name of the database, defaults to the client's current database :type database: str :returns: all retention policies for the database :rtype: list of dictionaries :Example: :: ...
[ "Get", "the", "list", "of", "retention", "policies", "for", "a", "database", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L753-L782
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.create_user
def create_user(self, username, password, admin=False): """Create a new user in InfluxDB. :param username: the new username to create :type username: str :param password: the password for the new user :type password: str :param admin: whether the user should have cluster...
python
def create_user(self, username, password, admin=False): """Create a new user in InfluxDB. :param username: the new username to create :type username: str :param password: the password for the new user :type password: str :param admin: whether the user should have cluster...
[ "def", "create_user", "(", "self", ",", "username", ",", "password", ",", "admin", "=", "False", ")", ":", "text", "=", "\"CREATE USER {0} WITH PASSWORD {1}\"", ".", "format", "(", "quote_ident", "(", "username", ")", ",", "quote_literal", "(", "password", ")"...
Create a new user in InfluxDB. :param username: the new username to create :type username: str :param password: the password for the new user :type password: str :param admin: whether the user should have cluster administration privileges or not :type admin: ...
[ "Create", "a", "new", "user", "in", "InfluxDB", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L802-L817
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.drop_user
def drop_user(self, username): """Drop a user from InfluxDB. :param username: the username to drop :type username: str """ text = "DROP USER {0}".format(quote_ident(username), method="POST") self.query(text, method="POST")
python
def drop_user(self, username): """Drop a user from InfluxDB. :param username: the username to drop :type username: str """ text = "DROP USER {0}".format(quote_ident(username), method="POST") self.query(text, method="POST")
[ "def", "drop_user", "(", "self", ",", "username", ")", ":", "text", "=", "\"DROP USER {0}\"", ".", "format", "(", "quote_ident", "(", "username", ")", ",", "method", "=", "\"POST\"", ")", "self", ".", "query", "(", "text", ",", "method", "=", "\"POST\"",...
Drop a user from InfluxDB. :param username: the username to drop :type username: str
[ "Drop", "a", "user", "from", "InfluxDB", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L819-L826
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.set_user_password
def set_user_password(self, username, password): """Change the password of an existing user. :param username: the username who's password is being changed :type username: str :param password: the new password for the user :type password: str """ text = "SET PASSW...
python
def set_user_password(self, username, password): """Change the password of an existing user. :param username: the username who's password is being changed :type username: str :param password: the new password for the user :type password: str """ text = "SET PASSW...
[ "def", "set_user_password", "(", "self", ",", "username", ",", "password", ")", ":", "text", "=", "\"SET PASSWORD FOR {0} = {1}\"", ".", "format", "(", "quote_ident", "(", "username", ")", ",", "quote_literal", "(", "password", ")", ")", "self", ".", "query", ...
Change the password of an existing user. :param username: the username who's password is being changed :type username: str :param password: the new password for the user :type password: str
[ "Change", "the", "password", "of", "an", "existing", "user", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L828-L838
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.delete_series
def delete_series(self, database=None, measurement=None, tags=None): """Delete series from a database. Series must be filtered by either measurement and tags. This method cannot be used to delete all series, use `drop_database` instead. :param database: the database from which ...
python
def delete_series(self, database=None, measurement=None, tags=None): """Delete series from a database. Series must be filtered by either measurement and tags. This method cannot be used to delete all series, use `drop_database` instead. :param database: the database from which ...
[ "def", "delete_series", "(", "self", ",", "database", "=", "None", ",", "measurement", "=", "None", ",", "tags", "=", "None", ")", ":", "database", "=", "database", "or", "self", ".", "_database", "query_str", "=", "'DROP SERIES'", "if", "measurement", ":"...
Delete series from a database. Series must be filtered by either measurement and tags. This method cannot be used to delete all series, use `drop_database` instead. :param database: the database from which the series should be deleted, defaults to client's current database ...
[ "Delete", "series", "from", "a", "database", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L840-L864
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.get_list_privileges
def get_list_privileges(self, username): """Get the list of all privileges granted to given user. :param username: the username to get privileges of :type username: str :returns: all privileges granted to given user :rtype: list of dictionaries :Example: :: ...
python
def get_list_privileges(self, username): """Get the list of all privileges granted to given user. :param username: the username to get privileges of :type username: str :returns: all privileges granted to given user :rtype: list of dictionaries :Example: :: ...
[ "def", "get_list_privileges", "(", "self", ",", "username", ")", ":", "text", "=", "\"SHOW GRANTS FOR {0}\"", ".", "format", "(", "quote_ident", "(", "username", ")", ")", "return", "list", "(", "self", ".", "query", "(", "text", ")", ".", "get_points", "(...
Get the list of all privileges granted to given user. :param username: the username to get privileges of :type username: str :returns: all privileges granted to given user :rtype: list of dictionaries :Example: :: >> privileges = client.get_list_privilege...
[ "Get", "the", "list", "of", "all", "privileges", "granted", "to", "given", "user", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L922-L942
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.get_list_continuous_queries
def get_list_continuous_queries(self): """Get the list of continuous queries in InfluxDB. :return: all CQs in InfluxDB :rtype: list of dictionaries :Example: :: >> cqs = client.get_list_cqs() >> cqs [ { u...
python
def get_list_continuous_queries(self): """Get the list of continuous queries in InfluxDB. :return: all CQs in InfluxDB :rtype: list of dictionaries :Example: :: >> cqs = client.get_list_cqs() >> cqs [ { u...
[ "def", "get_list_continuous_queries", "(", "self", ")", ":", "query_string", "=", "\"SHOW CONTINUOUS QUERIES\"", "return", "[", "{", "sk", "[", "0", "]", ":", "list", "(", "p", ")", "}", "for", "sk", ",", "p", "in", "self", ".", "query", "(", "query_stri...
Get the list of continuous queries in InfluxDB. :return: all CQs in InfluxDB :rtype: list of dictionaries :Example: :: >> cqs = client.get_list_cqs() >> cqs [ { u'db1': [] }, { ...
[ "Get", "the", "list", "of", "continuous", "queries", "in", "InfluxDB", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L944-L974
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.create_continuous_query
def create_continuous_query(self, name, select, database=None, resample_opts=None): r"""Create a continuous query for a database. :param name: the name of continuous query to create :type name: str :param select: select statement for the continuous query ...
python
def create_continuous_query(self, name, select, database=None, resample_opts=None): r"""Create a continuous query for a database. :param name: the name of continuous query to create :type name: str :param select: select statement for the continuous query ...
[ "def", "create_continuous_query", "(", "self", ",", "name", ",", "select", ",", "database", "=", "None", ",", "resample_opts", "=", "None", ")", ":", "query_string", "=", "(", "\"CREATE CONTINUOUS QUERY {0} ON {1}{2} BEGIN {3} END\"", ")", ".", "format", "(", "quo...
r"""Create a continuous query for a database. :param name: the name of continuous query to create :type name: str :param select: select statement for the continuous query :type select: str :param database: the database for which the continuous query is created. Defau...
[ "r", "Create", "a", "continuous", "query", "for", "a", "database", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L976-L1020
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.drop_continuous_query
def drop_continuous_query(self, name, database=None): """Drop an existing continuous query for a database. :param name: the name of continuous query to drop :type name: str :param database: the database for which the continuous query is dropped. Defaults to current client's ...
python
def drop_continuous_query(self, name, database=None): """Drop an existing continuous query for a database. :param name: the name of continuous query to drop :type name: str :param database: the database for which the continuous query is dropped. Defaults to current client's ...
[ "def", "drop_continuous_query", "(", "self", ",", "name", ",", "database", "=", "None", ")", ":", "query_string", "=", "(", "\"DROP CONTINUOUS QUERY {0} ON {1}\"", ")", ".", "format", "(", "quote_ident", "(", "name", ")", ",", "quote_ident", "(", "database", "...
Drop an existing continuous query for a database. :param name: the name of continuous query to drop :type name: str :param database: the database for which the continuous query is dropped. Defaults to current client's database :type database: str
[ "Drop", "an", "existing", "continuous", "query", "for", "a", "database", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L1022-L1034
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.send_packet
def send_packet(self, packet, protocol='json', time_precision=None): """Send an UDP packet. :param packet: the packet to be sent :type packet: (if protocol is 'json') dict (if protocol is 'line') list of line protocol strings :param protocol: protocol of input data...
python
def send_packet(self, packet, protocol='json', time_precision=None): """Send an UDP packet. :param packet: the packet to be sent :type packet: (if protocol is 'json') dict (if protocol is 'line') list of line protocol strings :param protocol: protocol of input data...
[ "def", "send_packet", "(", "self", ",", "packet", ",", "protocol", "=", "'json'", ",", "time_precision", "=", "None", ")", ":", "if", "protocol", "==", "'json'", ":", "data", "=", "make_lines", "(", "packet", ",", "time_precision", ")", ".", "encode", "(...
Send an UDP packet. :param packet: the packet to be sent :type packet: (if protocol is 'json') dict (if protocol is 'line') list of line protocol strings :param protocol: protocol of input data, either 'json' or 'line' :type protocol: str :param time_precis...
[ "Send", "an", "UDP", "packet", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L1036-L1051
train
influxdata/influxdb-python
influxdb/client.py
InfluxDBClient.close
def close(self): """Close http session.""" if isinstance(self._session, requests.Session): self._session.close()
python
def close(self): """Close http session.""" if isinstance(self._session, requests.Session): self._session.close()
[ "def", "close", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "_session", ",", "requests", ".", "Session", ")", ":", "self", ".", "_session", ".", "close", "(", ")" ]
Close http session.
[ "Close", "http", "session", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L1053-L1056
train
influxdata/influxdb-python
influxdb/chunked_json.py
loads
def loads(s): """Generate a sequence of JSON values from a string.""" _decoder = json.JSONDecoder() while s: s = s.strip() obj, pos = _decoder.raw_decode(s) if not pos: raise ValueError('no JSON object found at %i' % pos) yield obj s = s[pos:]
python
def loads(s): """Generate a sequence of JSON values from a string.""" _decoder = json.JSONDecoder() while s: s = s.strip() obj, pos = _decoder.raw_decode(s) if not pos: raise ValueError('no JSON object found at %i' % pos) yield obj s = s[pos:]
[ "def", "loads", "(", "s", ")", ":", "_decoder", "=", "json", ".", "JSONDecoder", "(", ")", "while", "s", ":", "s", "=", "s", ".", "strip", "(", ")", "obj", ",", "pos", "=", "_decoder", ".", "raw_decode", "(", "s", ")", "if", "not", "pos", ":", ...
Generate a sequence of JSON values from a string.
[ "Generate", "a", "sequence", "of", "JSON", "values", "from", "a", "string", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/chunked_json.py#L17-L27
train
influxdata/influxdb-python
influxdb/influxdb08/helper.py
SeriesHelper.commit
def commit(cls, client=None): """Commit everything from datapoints via the client. :param client: InfluxDBClient instance for writing points to InfluxDB. :attention: any provided client will supersede the class client. :return: result of client.write_points. """ if not c...
python
def commit(cls, client=None): """Commit everything from datapoints via the client. :param client: InfluxDBClient instance for writing points to InfluxDB. :attention: any provided client will supersede the class client. :return: result of client.write_points. """ if not c...
[ "def", "commit", "(", "cls", ",", "client", "=", "None", ")", ":", "if", "not", "client", ":", "client", "=", "cls", ".", "_client", "rtn", "=", "client", ".", "write_points", "(", "cls", ".", "_json_body_", "(", ")", ")", "cls", ".", "_reset_", "(...
Commit everything from datapoints via the client. :param client: InfluxDBClient instance for writing points to InfluxDB. :attention: any provided client will supersede the class client. :return: result of client.write_points.
[ "Commit", "everything", "from", "datapoints", "via", "the", "client", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/helper.py#L122-L133
train
influxdata/influxdb-python
influxdb/influxdb08/helper.py
SeriesHelper._json_body_
def _json_body_(cls): """Return JSON body of the datapoints. :return: JSON body of the datapoints. """ json = [] for series_name, data in six.iteritems(cls._datapoints): json.append({'name': series_name, 'columns': cls._fields, ...
python
def _json_body_(cls): """Return JSON body of the datapoints. :return: JSON body of the datapoints. """ json = [] for series_name, data in six.iteritems(cls._datapoints): json.append({'name': series_name, 'columns': cls._fields, ...
[ "def", "_json_body_", "(", "cls", ")", ":", "json", "=", "[", "]", "for", "series_name", ",", "data", "in", "six", ".", "iteritems", "(", "cls", ".", "_datapoints", ")", ":", "json", ".", "append", "(", "{", "'name'", ":", "series_name", ",", "'colum...
Return JSON body of the datapoints. :return: JSON body of the datapoints.
[ "Return", "JSON", "body", "of", "the", "datapoints", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/helper.py#L136-L148
train
influxdata/influxdb-python
influxdb/_dataframe_client.py
DataFrameClient.query
def query(self, query, params=None, bind_params=None, epoch=None, expected_response_code=200, database=None, raise_errors=True, chunked=False, chunk_size=0, method="GET", ...
python
def query(self, query, params=None, bind_params=None, epoch=None, expected_response_code=200, database=None, raise_errors=True, chunked=False, chunk_size=0, method="GET", ...
[ "def", "query", "(", "self", ",", "query", ",", "params", "=", "None", ",", "bind_params", "=", "None", ",", "epoch", "=", "None", ",", "expected_response_code", "=", "200", ",", "database", "=", "None", ",", "raise_errors", "=", "True", ",", "chunked", ...
Query data into a DataFrame. .. danger:: In order to avoid injection vulnerabilities (similar to `SQL injection <https://www.owasp.org/index.php/SQL_Injection>`_ vulnerabilities), do not directly include untrusted data into the ``query`` parameter, use ``bind_par...
[ "Query", "data", "into", "a", "DataFrame", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/_dataframe_client.py#L142-L201
train
influxdata/influxdb-python
examples/tutorial.py
main
def main(host='localhost', port=8086): """Instantiate a connection to the InfluxDB.""" user = 'root' password = 'root' dbname = 'example' dbuser = 'smly' dbuser_password = 'my_secret_password' query = 'select Float_value from cpu_load_short;' query_where = 'select Int_value from cpu_load...
python
def main(host='localhost', port=8086): """Instantiate a connection to the InfluxDB.""" user = 'root' password = 'root' dbname = 'example' dbuser = 'smly' dbuser_password = 'my_secret_password' query = 'select Float_value from cpu_load_short;' query_where = 'select Int_value from cpu_load...
[ "def", "main", "(", "host", "=", "'localhost'", ",", "port", "=", "8086", ")", ":", "user", "=", "'root'", "password", "=", "'root'", "dbname", "=", "'example'", "dbuser", "=", "'smly'", "dbuser_password", "=", "'my_secret_password'", "query", "=", "'select ...
Instantiate a connection to the InfluxDB.
[ "Instantiate", "a", "connection", "to", "the", "InfluxDB", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/examples/tutorial.py#L9-L64
train
influxdata/influxdb-python
examples/tutorial_udp.py
main
def main(uport): """Instantiate connection to the InfluxDB.""" # NOTE: structure of the UDP packet is different than that of information # sent via HTTP json_body = { "tags": { "host": "server01", "region": "us-west" }, "time": "2009-11-10T23:00:00Z"...
python
def main(uport): """Instantiate connection to the InfluxDB.""" # NOTE: structure of the UDP packet is different than that of information # sent via HTTP json_body = { "tags": { "host": "server01", "region": "us-west" }, "time": "2009-11-10T23:00:00Z"...
[ "def", "main", "(", "uport", ")", ":", "# NOTE: structure of the UDP packet is different than that of information", "# sent via HTTP", "json_body", "=", "{", "\"tags\"", ":", "{", "\"host\"", ":", "\"server01\"", ",", "\"region\"", ":", "\"us-west\"", "}", ",", "\...
Instantiate connection to the InfluxDB.
[ "Instantiate", "connection", "to", "the", "InfluxDB", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/examples/tutorial_udp.py#L23-L52
train
influxdata/influxdb-python
influxdb/helper.py
SeriesHelper._json_body_
def _json_body_(cls): """Return the JSON body of given datapoints. :return: JSON body of these datapoints. """ json = [] for series_name, data in six.iteritems(cls._datapoints): for point in data: json_point = { "measurement": seri...
python
def _json_body_(cls): """Return the JSON body of given datapoints. :return: JSON body of these datapoints. """ json = [] for series_name, data in six.iteritems(cls._datapoints): for point in data: json_point = { "measurement": seri...
[ "def", "_json_body_", "(", "cls", ")", ":", "json", "=", "[", "]", "for", "series_name", ",", "data", "in", "six", ".", "iteritems", "(", "cls", ".", "_datapoints", ")", ":", "for", "point", "in", "data", ":", "json_point", "=", "{", "\"measurement\"",...
Return the JSON body of given datapoints. :return: JSON body of these datapoints.
[ "Return", "the", "JSON", "body", "of", "given", "datapoints", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/helper.py#L151-L175
train
influxdata/influxdb-python
examples/tutorial_server_data.py
main
def main(host='localhost', port=8086, nb_day=15): """Instantiate a connection to the backend.""" nb_day = 15 # number of day to generate time series timeinterval_min = 5 # create an event every x minutes total_minutes = 1440 * nb_day total_records = int(total_minutes / timeinterval_min) now = ...
python
def main(host='localhost', port=8086, nb_day=15): """Instantiate a connection to the backend.""" nb_day = 15 # number of day to generate time series timeinterval_min = 5 # create an event every x minutes total_minutes = 1440 * nb_day total_records = int(total_minutes / timeinterval_min) now = ...
[ "def", "main", "(", "host", "=", "'localhost'", ",", "port", "=", "8086", ",", "nb_day", "=", "15", ")", ":", "nb_day", "=", "15", "# number of day to generate time series", "timeinterval_min", "=", "5", "# create an event every x minutes", "total_minutes", "=", "...
Instantiate a connection to the backend.
[ "Instantiate", "a", "connection", "to", "the", "backend", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/examples/tutorial_server_data.py#L19-L74
train
influxdata/influxdb-python
examples/tutorial_sine_wave.py
main
def main(host='localhost', port=8086): """Define function to generate the sin wave.""" now = datetime.datetime.today() points = [] for angle in range(0, 360): y = 10 + math.sin(math.radians(angle)) * 10 point = { "measurement": 'foobar', "time": int(now.strftime...
python
def main(host='localhost', port=8086): """Define function to generate the sin wave.""" now = datetime.datetime.today() points = [] for angle in range(0, 360): y = 10 + math.sin(math.radians(angle)) * 10 point = { "measurement": 'foobar', "time": int(now.strftime...
[ "def", "main", "(", "host", "=", "'localhost'", ",", "port", "=", "8086", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "today", "(", ")", "points", "=", "[", "]", "for", "angle", "in", "range", "(", "0", ",", "360", ")", ":", "y", "=...
Define function to generate the sin wave.
[ "Define", "function", "to", "generate", "the", "sin", "wave", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/examples/tutorial_sine_wave.py#L17-L61
train
influxdata/influxdb-python
influxdb/resultset.py
ResultSet.get_points
def get_points(self, measurement=None, tags=None): """Return a generator for all the points that match the given filters. :param measurement: The measurement name :type measurement: str :param tags: Tags to look for :type tags: dict :return: Points generator ""...
python
def get_points(self, measurement=None, tags=None): """Return a generator for all the points that match the given filters. :param measurement: The measurement name :type measurement: str :param tags: Tags to look for :type tags: dict :return: Points generator ""...
[ "def", "get_points", "(", "self", ",", "measurement", "=", "None", ",", "tags", "=", "None", ")", ":", "# Raise error if measurement is not str or bytes", "if", "not", "isinstance", "(", "measurement", ",", "(", "bytes", ",", "type", "(", "b''", ".", "decode",...
Return a generator for all the points that match the given filters. :param measurement: The measurement name :type measurement: str :param tags: Tags to look for :type tags: dict :return: Points generator
[ "Return", "a", "generator", "for", "all", "the", "points", "that", "match", "the", "given", "filters", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/resultset.py#L80-L115
train
influxdata/influxdb-python
influxdb/resultset.py
ResultSet.keys
def keys(self): """Return the list of keys in the ResultSet. :return: List of keys. Keys are tuples (series_name, tags) """ keys = [] for series in self._get_series(): keys.append( (series.get('measurement', series.get('nam...
python
def keys(self): """Return the list of keys in the ResultSet. :return: List of keys. Keys are tuples (series_name, tags) """ keys = [] for series in self._get_series(): keys.append( (series.get('measurement', series.get('nam...
[ "def", "keys", "(", "self", ")", ":", "keys", "=", "[", "]", "for", "series", "in", "self", ".", "_get_series", "(", ")", ":", "keys", ".", "append", "(", "(", "series", ".", "get", "(", "'measurement'", ",", "series", ".", "get", "(", "'name'", ...
Return the list of keys in the ResultSet. :return: List of keys. Keys are tuples (series_name, tags)
[ "Return", "the", "list", "of", "keys", "in", "the", "ResultSet", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/resultset.py#L153-L165
train
influxdata/influxdb-python
influxdb/resultset.py
ResultSet.items
def items(self): """Return the set of items from the ResultSet. :return: List of tuples, (key, generator) """ items = [] for series in self._get_series(): series_key = (series.get('measurement', series.get('name', 'results')), ...
python
def items(self): """Return the set of items from the ResultSet. :return: List of tuples, (key, generator) """ items = [] for series in self._get_series(): series_key = (series.get('measurement', series.get('name', 'results')), ...
[ "def", "items", "(", "self", ")", ":", "items", "=", "[", "]", "for", "series", "in", "self", ".", "_get_series", "(", ")", ":", "series_key", "=", "(", "series", ".", "get", "(", "'measurement'", ",", "series", ".", "get", "(", "'name'", ",", "'re...
Return the set of items from the ResultSet. :return: List of tuples, (key, generator)
[ "Return", "the", "set", "of", "items", "from", "the", "ResultSet", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/resultset.py#L167-L180
train
influxdata/influxdb-python
influxdb/resultset.py
ResultSet._get_points_for_series
def _get_points_for_series(self, series): """Return generator of dict from columns and values of a series. :param series: One series :return: Generator of dicts """ for point in series.get('values', []): yield self.point_from_cols_vals( series['column...
python
def _get_points_for_series(self, series): """Return generator of dict from columns and values of a series. :param series: One series :return: Generator of dicts """ for point in series.get('values', []): yield self.point_from_cols_vals( series['column...
[ "def", "_get_points_for_series", "(", "self", ",", "series", ")", ":", "for", "point", "in", "series", ".", "get", "(", "'values'", ",", "[", "]", ")", ":", "yield", "self", ".", "point_from_cols_vals", "(", "series", "[", "'columns'", "]", ",", "point",...
Return generator of dict from columns and values of a series. :param series: One series :return: Generator of dicts
[ "Return", "generator", "of", "dict", "from", "columns", "and", "values", "of", "a", "series", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/resultset.py#L182-L192
train
influxdata/influxdb-python
influxdb/resultset.py
ResultSet.point_from_cols_vals
def point_from_cols_vals(cols, vals): """Create a dict from columns and values lists. :param cols: List of columns :param vals: List of values :return: Dict where keys are columns. """ point = {} for col_index, col_name in enumerate(cols): point[col_n...
python
def point_from_cols_vals(cols, vals): """Create a dict from columns and values lists. :param cols: List of columns :param vals: List of values :return: Dict where keys are columns. """ point = {} for col_index, col_name in enumerate(cols): point[col_n...
[ "def", "point_from_cols_vals", "(", "cols", ",", "vals", ")", ":", "point", "=", "{", "}", "for", "col_index", ",", "col_name", "in", "enumerate", "(", "cols", ")", ":", "point", "[", "col_name", "]", "=", "vals", "[", "col_index", "]", "return", "poin...
Create a dict from columns and values lists. :param cols: List of columns :param vals: List of values :return: Dict where keys are columns.
[ "Create", "a", "dict", "from", "columns", "and", "values", "lists", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/resultset.py#L195-L206
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.from_dsn
def from_dsn(dsn, **kwargs): r"""Return an instaance of InfluxDBClient from given data source name. Returns an instance of InfluxDBClient from the provided data source name. Supported schemes are "influxdb", "https+influxdb", "udp+influxdb". Parameters for the InfluxDBClient constructor...
python
def from_dsn(dsn, **kwargs): r"""Return an instaance of InfluxDBClient from given data source name. Returns an instance of InfluxDBClient from the provided data source name. Supported schemes are "influxdb", "https+influxdb", "udp+influxdb". Parameters for the InfluxDBClient constructor...
[ "def", "from_dsn", "(", "dsn", ",", "*", "*", "kwargs", ")", ":", "init_args", "=", "{", "}", "conn_params", "=", "urlparse", "(", "dsn", ")", "scheme_info", "=", "conn_params", ".", "scheme", ".", "split", "(", "'+'", ")", "if", "len", "(", "scheme_...
r"""Return an instaance of InfluxDBClient from given data source name. Returns an instance of InfluxDBClient from the provided data source name. Supported schemes are "influxdb", "https+influxdb", "udp+influxdb". Parameters for the InfluxDBClient constructor may be also be passed to thi...
[ "r", "Return", "an", "instaance", "of", "InfluxDBClient", "from", "given", "data", "source", "name", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L106-L169
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.request
def request(self, url, method='GET', params=None, data=None, expected_response_code=200): """Make a http request to API.""" url = "{0}/{1}".format(self._baseurl, url) if params is None: params = {} auth = { 'u': self._username, 'p': s...
python
def request(self, url, method='GET', params=None, data=None, expected_response_code=200): """Make a http request to API.""" url = "{0}/{1}".format(self._baseurl, url) if params is None: params = {} auth = { 'u': self._username, 'p': s...
[ "def", "request", "(", "self", ",", "url", ",", "method", "=", "'GET'", ",", "params", "=", "None", ",", "data", "=", "None", ",", "expected_response_code", "=", "200", ")", ":", "url", "=", "\"{0}/{1}\"", ".", "format", "(", "self", ".", "_baseurl", ...
Make a http request to API.
[ "Make", "a", "http", "request", "to", "API", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L204-L248
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.write
def write(self, data): """Provide as convenience for influxdb v0.9.0, this may change.""" self.request( url="write", method='POST', params=None, data=data, expected_response_code=200 ) return True
python
def write(self, data): """Provide as convenience for influxdb v0.9.0, this may change.""" self.request( url="write", method='POST', params=None, data=data, expected_response_code=200 ) return True
[ "def", "write", "(", "self", ",", "data", ")", ":", "self", ".", "request", "(", "url", "=", "\"write\"", ",", "method", "=", "'POST'", ",", "params", "=", "None", ",", "data", "=", "data", ",", "expected_response_code", "=", "200", ")", "return", "T...
Provide as convenience for influxdb v0.9.0, this may change.
[ "Provide", "as", "convenience", "for", "influxdb", "v0", ".", "9", ".", "0", "this", "may", "change", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L250-L259
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.delete_points
def delete_points(self, name): """Delete an entire series.""" url = "db/{0}/series/{1}".format(self._database, name) self.request( url=url, method='DELETE', expected_response_code=204 ) return True
python
def delete_points(self, name): """Delete an entire series.""" url = "db/{0}/series/{1}".format(self._database, name) self.request( url=url, method='DELETE', expected_response_code=204 ) return True
[ "def", "delete_points", "(", "self", ",", "name", ")", ":", "url", "=", "\"db/{0}/series/{1}\"", ".", "format", "(", "self", ".", "_database", ",", "name", ")", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'DELETE'", ",", "expec...
Delete an entire series.
[ "Delete", "an", "entire", "series", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L364-L374
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.query
def query(self, query, time_precision='s', chunked=False): """Query data from the influxdb v0.8 database. :param time_precision: [Optional, default 's'] Either 's', 'm', 'ms' or 'u'. :param chunked: [Optional, default=False] True if the data shall be retrieved in chunks,...
python
def query(self, query, time_precision='s', chunked=False): """Query data from the influxdb v0.8 database. :param time_precision: [Optional, default 's'] Either 's', 'm', 'ms' or 'u'. :param chunked: [Optional, default=False] True if the data shall be retrieved in chunks,...
[ "def", "query", "(", "self", ",", "query", ",", "time_precision", "=", "'s'", ",", "chunked", "=", "False", ")", ":", "return", "self", ".", "_query", "(", "query", ",", "time_precision", "=", "time_precision", ",", "chunked", "=", "chunked", ")" ]
Query data from the influxdb v0.8 database. :param time_precision: [Optional, default 's'] Either 's', 'm', 'ms' or 'u'. :param chunked: [Optional, default=False] True if the data shall be retrieved in chunks, False otherwise.
[ "Query", "data", "from", "the", "influxdb", "v0", ".", "8", "database", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L414-L423
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.create_database
def create_database(self, database): """Create a database on the InfluxDB server. :param database: the name of the database to create :type database: string :rtype: boolean """ url = "db" data = {'name': database} self.request( url=url, ...
python
def create_database(self, database): """Create a database on the InfluxDB server. :param database: the name of the database to create :type database: string :rtype: boolean """ url = "db" data = {'name': database} self.request( url=url, ...
[ "def", "create_database", "(", "self", ",", "database", ")", ":", "url", "=", "\"db\"", "data", "=", "{", "'name'", ":", "database", "}", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'POST'", ",", "data", "=", "data", ",", "...
Create a database on the InfluxDB server. :param database: the name of the database to create :type database: string :rtype: boolean
[ "Create", "a", "database", "on", "the", "InfluxDB", "server", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L472-L490
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.delete_database
def delete_database(self, database): """Drop a database on the InfluxDB server. :param database: the name of the database to delete :type database: string :rtype: boolean """ url = "db/{0}".format(database) self.request( url=url, method='...
python
def delete_database(self, database): """Drop a database on the InfluxDB server. :param database: the name of the database to delete :type database: string :rtype: boolean """ url = "db/{0}".format(database) self.request( url=url, method='...
[ "def", "delete_database", "(", "self", ",", "database", ")", ":", "url", "=", "\"db/{0}\"", ".", "format", "(", "database", ")", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'DELETE'", ",", "expected_response_code", "=", "204", ")...
Drop a database on the InfluxDB server. :param database: the name of the database to delete :type database: string :rtype: boolean
[ "Drop", "a", "database", "on", "the", "InfluxDB", "server", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L492-L507
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.get_list_database
def get_list_database(self): """Get the list of databases.""" url = "db" response = self.request( url=url, method='GET', expected_response_code=200 ) return response.json()
python
def get_list_database(self): """Get the list of databases.""" url = "db" response = self.request( url=url, method='GET', expected_response_code=200 ) return response.json()
[ "def", "get_list_database", "(", "self", ")", ":", "url", "=", "\"db\"", "response", "=", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'GET'", ",", "expected_response_code", "=", "200", ")", "return", "response", ".", "json", "(",...
Get the list of databases.
[ "Get", "the", "list", "of", "databases", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L512-L522
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.delete_series
def delete_series(self, series): """Drop a series on the InfluxDB server. :param series: the name of the series to delete :type series: string :rtype: boolean """ url = "db/{0}/series/{1}".format( self._database, series ) self.req...
python
def delete_series(self, series): """Drop a series on the InfluxDB server. :param series: the name of the series to delete :type series: string :rtype: boolean """ url = "db/{0}/series/{1}".format( self._database, series ) self.req...
[ "def", "delete_series", "(", "self", ",", "series", ")", ":", "url", "=", "\"db/{0}/series/{1}\"", ".", "format", "(", "self", ".", "_database", ",", "series", ")", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'DELETE'", ",", "e...
Drop a series on the InfluxDB server. :param series: the name of the series to delete :type series: string :rtype: boolean
[ "Drop", "a", "series", "on", "the", "InfluxDB", "server", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L536-L554
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.get_list_cluster_admins
def get_list_cluster_admins(self): """Get list of cluster admins.""" response = self.request( url="cluster_admins", method='GET', expected_response_code=200 ) return response.json()
python
def get_list_cluster_admins(self): """Get list of cluster admins.""" response = self.request( url="cluster_admins", method='GET', expected_response_code=200 ) return response.json()
[ "def", "get_list_cluster_admins", "(", "self", ")", ":", "response", "=", "self", ".", "request", "(", "url", "=", "\"cluster_admins\"", ",", "method", "=", "'GET'", ",", "expected_response_code", "=", "200", ")", "return", "response", ".", "json", "(", ")" ...
Get list of cluster admins.
[ "Get", "list", "of", "cluster", "admins", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L597-L605
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.add_cluster_admin
def add_cluster_admin(self, new_username, new_password): """Add cluster admin.""" data = { 'name': new_username, 'password': new_password } self.request( url="cluster_admins", method='POST', data=data, expected_resp...
python
def add_cluster_admin(self, new_username, new_password): """Add cluster admin.""" data = { 'name': new_username, 'password': new_password } self.request( url="cluster_admins", method='POST', data=data, expected_resp...
[ "def", "add_cluster_admin", "(", "self", ",", "new_username", ",", "new_password", ")", ":", "data", "=", "{", "'name'", ":", "new_username", ",", "'password'", ":", "new_password", "}", "self", ".", "request", "(", "url", "=", "\"cluster_admins\"", ",", "me...
Add cluster admin.
[ "Add", "cluster", "admin", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L607-L621
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.update_cluster_admin_password
def update_cluster_admin_password(self, username, new_password): """Update cluster admin password.""" url = "cluster_admins/{0}".format(username) data = { 'password': new_password } self.request( url=url, method='POST', data=data,...
python
def update_cluster_admin_password(self, username, new_password): """Update cluster admin password.""" url = "cluster_admins/{0}".format(username) data = { 'password': new_password } self.request( url=url, method='POST', data=data,...
[ "def", "update_cluster_admin_password", "(", "self", ",", "username", ",", "new_password", ")", ":", "url", "=", "\"cluster_admins/{0}\"", ".", "format", "(", "username", ")", "data", "=", "{", "'password'", ":", "new_password", "}", "self", ".", "request", "(...
Update cluster admin password.
[ "Update", "cluster", "admin", "password", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L623-L638
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.delete_cluster_admin
def delete_cluster_admin(self, username): """Delete cluster admin.""" url = "cluster_admins/{0}".format(username) self.request( url=url, method='DELETE', expected_response_code=200 ) return True
python
def delete_cluster_admin(self, username): """Delete cluster admin.""" url = "cluster_admins/{0}".format(username) self.request( url=url, method='DELETE', expected_response_code=200 ) return True
[ "def", "delete_cluster_admin", "(", "self", ",", "username", ")", ":", "url", "=", "\"cluster_admins/{0}\"", ".", "format", "(", "username", ")", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'DELETE'", ",", "expected_response_code", "...
Delete cluster admin.
[ "Delete", "cluster", "admin", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L640-L650
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.alter_database_admin
def alter_database_admin(self, username, is_admin): """Alter the database admin.""" url = "db/{0}/users/{1}".format(self._database, username) data = {'admin': is_admin} self.request( url=url, method='POST', data=data, expected_response_co...
python
def alter_database_admin(self, username, is_admin): """Alter the database admin.""" url = "db/{0}/users/{1}".format(self._database, username) data = {'admin': is_admin} self.request( url=url, method='POST', data=data, expected_response_co...
[ "def", "alter_database_admin", "(", "self", ",", "username", ",", "is_admin", ")", ":", "url", "=", "\"db/{0}/users/{1}\"", ".", "format", "(", "self", ".", "_database", ",", "username", ")", "data", "=", "{", "'admin'", ":", "is_admin", "}", "self", ".", ...
Alter the database admin.
[ "Alter", "the", "database", "admin", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L660-L673
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.get_database_users
def get_database_users(self): """Get list of database users.""" url = "db/{0}/users".format(self._database) response = self.request( url=url, method='GET', expected_response_code=200 ) return response.json()
python
def get_database_users(self): """Get list of database users.""" url = "db/{0}/users".format(self._database) response = self.request( url=url, method='GET', expected_response_code=200 ) return response.json()
[ "def", "get_database_users", "(", "self", ")", ":", "url", "=", "\"db/{0}/users\"", ".", "format", "(", "self", ".", "_database", ")", "response", "=", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'GET'", ",", "expected_response_cod...
Get list of database users.
[ "Get", "list", "of", "database", "users", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L733-L743
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.add_database_user
def add_database_user(self, new_username, new_password, permissions=None): """Add database user. :param permissions: A ``(readFrom, writeTo)`` tuple """ url = "db/{0}/users".format(self._database) data = { 'name': new_username, 'password': new_password ...
python
def add_database_user(self, new_username, new_password, permissions=None): """Add database user. :param permissions: A ``(readFrom, writeTo)`` tuple """ url = "db/{0}/users".format(self._database) data = { 'name': new_username, 'password': new_password ...
[ "def", "add_database_user", "(", "self", ",", "new_username", ",", "new_password", ",", "permissions", "=", "None", ")", ":", "url", "=", "\"db/{0}/users\"", ".", "format", "(", "self", ".", "_database", ")", "data", "=", "{", "'name'", ":", "new_username", ...
Add database user. :param permissions: A ``(readFrom, writeTo)`` tuple
[ "Add", "database", "user", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L745-L772
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.delete_database_user
def delete_database_user(self, username): """Delete database user.""" url = "db/{0}/users/{1}".format(self._database, username) self.request( url=url, method='DELETE', expected_response_code=200 ) return True
python
def delete_database_user(self, username): """Delete database user.""" url = "db/{0}/users/{1}".format(self._database, username) self.request( url=url, method='DELETE', expected_response_code=200 ) return True
[ "def", "delete_database_user", "(", "self", ",", "username", ")", ":", "url", "=", "\"db/{0}/users/{1}\"", ".", "format", "(", "self", ".", "_database", ",", "username", ")", "self", ".", "request", "(", "url", "=", "url", ",", "method", "=", "'DELETE'", ...
Delete database user.
[ "Delete", "database", "user", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L815-L825
train
influxdata/influxdb-python
influxdb/influxdb08/client.py
InfluxDBClient.send_packet
def send_packet(self, packet): """Send a UDP packet along the wire.""" data = json.dumps(packet) byte = data.encode('utf-8') self.udp_socket.sendto(byte, (self._host, self._udp_port))
python
def send_packet(self, packet): """Send a UDP packet along the wire.""" data = json.dumps(packet) byte = data.encode('utf-8') self.udp_socket.sendto(byte, (self._host, self._udp_port))
[ "def", "send_packet", "(", "self", ",", "packet", ")", ":", "data", "=", "json", ".", "dumps", "(", "packet", ")", "byte", "=", "data", ".", "encode", "(", "'utf-8'", ")", "self", ".", "udp_socket", ".", "sendto", "(", "byte", ",", "(", "self", "."...
Send a UDP packet along the wire.
[ "Send", "a", "UDP", "packet", "along", "the", "wire", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/client.py#L839-L843
train
influxdata/influxdb-python
influxdb/influxdb08/dataframe_client.py
DataFrameClient.query
def query(self, query, time_precision='s', chunked=False): """Query data into DataFrames. Returns a DataFrame for a single time series and a map for multiple time series with the time series as value and its name as key. :param time_precision: [Optional, default 's'] Either 's', 'm', '...
python
def query(self, query, time_precision='s', chunked=False): """Query data into DataFrames. Returns a DataFrame for a single time series and a map for multiple time series with the time series as value and its name as key. :param time_precision: [Optional, default 's'] Either 's', 'm', '...
[ "def", "query", "(", "self", ",", "query", ",", "time_precision", "=", "'s'", ",", "chunked", "=", "False", ")", ":", "result", "=", "InfluxDBClient", ".", "query", "(", "self", ",", "query", "=", "query", ",", "time_precision", "=", "time_precision", ",...
Query data into DataFrames. Returns a DataFrame for a single time series and a map for multiple time series with the time series as value and its name as key. :param time_precision: [Optional, default 's'] Either 's', 'm', 'ms' or 'u'. :param chunked: [Optional, default=Fal...
[ "Query", "data", "into", "DataFrames", "." ]
d5d12499f3755199d5eedd8b363450f1cf4073bd
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/influxdb08/dataframe_client.py#L85-L108
train
groveco/django-sql-explorer
explorer/forms.py
SqlField.validate
def validate(self, value): """ Ensure that the SQL passes the blacklist. :param value: The SQL for this Query model. """ query = Query(sql=value) passes_blacklist, failing_words = query.passes_blacklist() error = MSG_FAILED_BLACKLIST % ', '.join(failing_words)...
python
def validate(self, value): """ Ensure that the SQL passes the blacklist. :param value: The SQL for this Query model. """ query = Query(sql=value) passes_blacklist, failing_words = query.passes_blacklist() error = MSG_FAILED_BLACKLIST % ', '.join(failing_words)...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "query", "=", "Query", "(", "sql", "=", "value", ")", "passes_blacklist", ",", "failing_words", "=", "query", ".", "passes_blacklist", "(", ")", "error", "=", "MSG_FAILED_BLACKLIST", "%", "', '", ".",...
Ensure that the SQL passes the blacklist. :param value: The SQL for this Query model.
[ "Ensure", "that", "the", "SQL", "passes", "the", "blacklist", "." ]
622b96354e1d7ae7f7105ae90b8da3247e028623
https://github.com/groveco/django-sql-explorer/blob/622b96354e1d7ae7f7105ae90b8da3247e028623/explorer/forms.py#L11-L28
train
groveco/django-sql-explorer
explorer/schema.py
build_schema_info
def build_schema_info(connection_alias): """ Construct schema information via engine-specific queries of the tables in the DB. :return: Schema information of the following form, sorted by db_table_name. [ ("db_table_name", [ ("...
python
def build_schema_info(connection_alias): """ Construct schema information via engine-specific queries of the tables in the DB. :return: Schema information of the following form, sorted by db_table_name. [ ("db_table_name", [ ("...
[ "def", "build_schema_info", "(", "connection_alias", ")", ":", "connection", "=", "get_valid_connection", "(", "connection_alias", ")", "ret", "=", "[", "]", "with", "connection", ".", "cursor", "(", ")", "as", "cursor", ":", "tables_to_introspect", "=", "connec...
Construct schema information via engine-specific queries of the tables in the DB. :return: Schema information of the following form, sorted by db_table_name. [ ("db_table_name", [ ("db_column_name", "DbFieldType"), ...
[ "Construct", "schema", "information", "via", "engine", "-", "specific", "queries", "of", "the", "tables", "in", "the", "DB", "." ]
622b96354e1d7ae7f7105ae90b8da3247e028623
https://github.com/groveco/django-sql-explorer/blob/622b96354e1d7ae7f7105ae90b8da3247e028623/explorer/schema.py#L52-L85
train
CodeReclaimers/neat-python
neat/graphs.py
creates_cycle
def creates_cycle(connections, test): """ Returns true if the addition of the 'test' connection would create a cycle, assuming that no cycle already exists in the graph represented by 'connections'. """ i, o = test if i == o: return True visited = {o} while True: num_add...
python
def creates_cycle(connections, test): """ Returns true if the addition of the 'test' connection would create a cycle, assuming that no cycle already exists in the graph represented by 'connections'. """ i, o = test if i == o: return True visited = {o} while True: num_add...
[ "def", "creates_cycle", "(", "connections", ",", "test", ")", ":", "i", ",", "o", "=", "test", "if", "i", "==", "o", ":", "return", "True", "visited", "=", "{", "o", "}", "while", "True", ":", "num_added", "=", "0", "for", "a", ",", "b", "in", ...
Returns true if the addition of the 'test' connection would create a cycle, assuming that no cycle already exists in the graph represented by 'connections'.
[ "Returns", "true", "if", "the", "addition", "of", "the", "test", "connection", "would", "create", "a", "cycle", "assuming", "that", "no", "cycle", "already", "exists", "in", "the", "graph", "represented", "by", "connections", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/graphs.py#L3-L24
train
CodeReclaimers/neat-python
examples/xor/evolve-feedforward-threaded.py
run
def run(config_file): """load the config, create a population, evolve and show the result""" # Load configuration. config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction, neat.DefaultSpeciesSet, neat.DefaultStagnation, config_file) # Create the population, which is the top-level object for...
python
def run(config_file): """load the config, create a population, evolve and show the result""" # Load configuration. config = neat.Config(neat.DefaultGenome, neat.DefaultReproduction, neat.DefaultSpeciesSet, neat.DefaultStagnation, config_file) # Create the population, which is the top-level object for...
[ "def", "run", "(", "config_file", ")", ":", "# Load configuration.", "config", "=", "neat", ".", "Config", "(", "neat", ".", "DefaultGenome", ",", "neat", ".", "DefaultReproduction", ",", "neat", ".", "DefaultSpeciesSet", ",", "neat", ".", "DefaultStagnation", ...
load the config, create a population, evolve and show the result
[ "load", "the", "config", "create", "a", "population", "evolve", "and", "show", "the", "result" ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/xor/evolve-feedforward-threaded.py#L49-L85
train
CodeReclaimers/neat-python
examples/memory-variable/visualize.py
plot_stats
def plot_stats(statistics, ylog=False, view=False, filename='avg_fitness.svg'): """ Plots the population's average and best fitness. """ if plt is None: warnings.warn("This display is not available due to a missing optional dependency (matplotlib)") return generation = range(len(statistics....
python
def plot_stats(statistics, ylog=False, view=False, filename='avg_fitness.svg'): """ Plots the population's average and best fitness. """ if plt is None: warnings.warn("This display is not available due to a missing optional dependency (matplotlib)") return generation = range(len(statistics....
[ "def", "plot_stats", "(", "statistics", ",", "ylog", "=", "False", ",", "view", "=", "False", ",", "filename", "=", "'avg_fitness.svg'", ")", ":", "if", "plt", "is", "None", ":", "warnings", ".", "warn", "(", "\"This display is not available due to a missing opt...
Plots the population's average and best fitness.
[ "Plots", "the", "population", "s", "average", "and", "best", "fitness", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/memory-variable/visualize.py#L12-L40
train
CodeReclaimers/neat-python
examples/memory-variable/visualize.py
plot_species
def plot_species(statistics, view=False, filename='speciation.svg'): """ Visualizes speciation throughout evolution. """ if plt is None: warnings.warn("This display is not available due to a missing optional dependency (matplotlib)") return species_sizes = statistics.get_species_sizes() ...
python
def plot_species(statistics, view=False, filename='speciation.svg'): """ Visualizes speciation throughout evolution. """ if plt is None: warnings.warn("This display is not available due to a missing optional dependency (matplotlib)") return species_sizes = statistics.get_species_sizes() ...
[ "def", "plot_species", "(", "statistics", ",", "view", "=", "False", ",", "filename", "=", "'speciation.svg'", ")", ":", "if", "plt", "is", "None", ":", "warnings", ".", "warn", "(", "\"This display is not available due to a missing optional dependency (matplotlib)\"", ...
Visualizes speciation throughout evolution.
[ "Visualizes", "speciation", "throughout", "evolution", "." ]
e3dbe77c0d776eae41d598e6439e6ac02ab90b18
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/memory-variable/visualize.py#L89-L111
train