repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
quintusdias/glymur
glymur/lib/openjp2.py
setup_encoder
def setup_encoder(codec, cparams, image): """Wraps openjp2 library function opj_setup_encoder. Setup the encoder parameters using the current image and using user parameters. Parameters ---------- codec : CODEC_TYPE codec initialized by create_compress function cparams : Compressio...
python
def setup_encoder(codec, cparams, image): """Wraps openjp2 library function opj_setup_encoder. Setup the encoder parameters using the current image and using user parameters. Parameters ---------- codec : CODEC_TYPE codec initialized by create_compress function cparams : Compressio...
[ "def", "setup_encoder", "(", "codec", ",", "cparams", ",", "image", ")", ":", "ARGTYPES", "=", "[", "CODEC_TYPE", ",", "ctypes", ".", "POINTER", "(", "CompressionParametersType", ")", ",", "ctypes", ".", "POINTER", "(", "ImageType", ")", "]", "OPENJP2", "....
Wraps openjp2 library function opj_setup_encoder. Setup the encoder parameters using the current image and using user parameters. Parameters ---------- codec : CODEC_TYPE codec initialized by create_compress function cparams : CompressionParametersType compression parameters ...
[ "Wraps", "openjp2", "library", "function", "opj_setup_encoder", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/lib/openjp2.py#L1192-L1217
quintusdias/glymur
glymur/lib/openjp2.py
start_compress
def start_compress(codec, image, stream): """Wraps openjp2 library function opj_start_compress. Start to compress the current image. Parameters ---------- codec : CODEC_TYPE Compressor handle. image : pointer to ImageType Input filled image. stream : STREAM_TYPE_P I...
python
def start_compress(codec, image, stream): """Wraps openjp2 library function opj_start_compress. Start to compress the current image. Parameters ---------- codec : CODEC_TYPE Compressor handle. image : pointer to ImageType Input filled image. stream : STREAM_TYPE_P I...
[ "def", "start_compress", "(", "codec", ",", "image", ",", "stream", ")", ":", "OPENJP2", ".", "opj_start_compress", ".", "argtypes", "=", "[", "CODEC_TYPE", ",", "ctypes", ".", "POINTER", "(", "ImageType", ")", ",", "STREAM_TYPE_P", "]", "OPENJP2", ".", "o...
Wraps openjp2 library function opj_start_compress. Start to compress the current image. Parameters ---------- codec : CODEC_TYPE Compressor handle. image : pointer to ImageType Input filled image. stream : STREAM_TYPE_P Input stream. Raises ------ RuntimeEr...
[ "Wraps", "openjp2", "library", "function", "opj_start_compress", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/lib/openjp2.py#L1220-L1244
quintusdias/glymur
glymur/lib/openjp2.py
stream_create_default_file_stream
def stream_create_default_file_stream(fname, isa_read_stream): """Wraps openjp2 library function opj_stream_create_default_vile_stream. Sets the stream to be a file stream. This function is only valid for the 2.1 version of the openjp2 library. Parameters ---------- fname : str Specif...
python
def stream_create_default_file_stream(fname, isa_read_stream): """Wraps openjp2 library function opj_stream_create_default_vile_stream. Sets the stream to be a file stream. This function is only valid for the 2.1 version of the openjp2 library. Parameters ---------- fname : str Specif...
[ "def", "stream_create_default_file_stream", "(", "fname", ",", "isa_read_stream", ")", ":", "ARGTYPES", "=", "[", "ctypes", ".", "c_char_p", ",", "ctypes", ".", "c_int32", "]", "OPENJP2", ".", "opj_stream_create_default_file_stream", ".", "argtypes", "=", "ARGTYPES"...
Wraps openjp2 library function opj_stream_create_default_vile_stream. Sets the stream to be a file stream. This function is only valid for the 2.1 version of the openjp2 library. Parameters ---------- fname : str Specifies a file. isa_read_stream: bool True (read) or False (w...
[ "Wraps", "openjp2", "library", "function", "opj_stream_create_default_vile_stream", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/lib/openjp2.py#L1247-L1272
quintusdias/glymur
glymur/lib/openjp2.py
stream_destroy
def stream_destroy(stream): """Wraps openjp2 library function opj_stream_destroy. Destroys the stream created by create_stream. Parameters ---------- stream : STREAM_TYPE_P The file stream. """ OPENJP2.opj_stream_destroy.argtypes = [STREAM_TYPE_P] OPENJP2.opj_stream_destroy.res...
python
def stream_destroy(stream): """Wraps openjp2 library function opj_stream_destroy. Destroys the stream created by create_stream. Parameters ---------- stream : STREAM_TYPE_P The file stream. """ OPENJP2.opj_stream_destroy.argtypes = [STREAM_TYPE_P] OPENJP2.opj_stream_destroy.res...
[ "def", "stream_destroy", "(", "stream", ")", ":", "OPENJP2", ".", "opj_stream_destroy", ".", "argtypes", "=", "[", "STREAM_TYPE_P", "]", "OPENJP2", ".", "opj_stream_destroy", ".", "restype", "=", "ctypes", ".", "c_void_p", "OPENJP2", ".", "opj_stream_destroy", "...
Wraps openjp2 library function opj_stream_destroy. Destroys the stream created by create_stream. Parameters ---------- stream : STREAM_TYPE_P The file stream.
[ "Wraps", "openjp2", "library", "function", "opj_stream_destroy", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/lib/openjp2.py#L1275-L1287
quintusdias/glymur
glymur/lib/openjp2.py
write_tile
def write_tile(codec, tile_index, data, data_size, stream): """Wraps openjp2 library function opj_write_tile. Write a tile into an image. Parameters ---------- codec : CODEC_TYPE The jpeg2000 codec tile_index : int The index of the tile to write, zero-indexing assumed data ...
python
def write_tile(codec, tile_index, data, data_size, stream): """Wraps openjp2 library function opj_write_tile. Write a tile into an image. Parameters ---------- codec : CODEC_TYPE The jpeg2000 codec tile_index : int The index of the tile to write, zero-indexing assumed data ...
[ "def", "write_tile", "(", "codec", ",", "tile_index", ",", "data", ",", "data_size", ",", "stream", ")", ":", "OPENJP2", ".", "opj_write_tile", ".", "argtypes", "=", "[", "CODEC_TYPE", ",", "ctypes", ".", "c_uint32", ",", "ctypes", ".", "POINTER", "(", "...
Wraps openjp2 library function opj_write_tile. Write a tile into an image. Parameters ---------- codec : CODEC_TYPE The jpeg2000 codec tile_index : int The index of the tile to write, zero-indexing assumed data : array Image data arranged in usual C-order data_size ...
[ "Wraps", "openjp2", "library", "function", "opj_write_tile", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/lib/openjp2.py#L1290-L1325
keenlabs/KeenClient-Python
keen/Padding.py
paddingLength
def paddingLength(str_len, blocksize=AES_blocksize): ''' Function to calculate the length of the required padding Input: (int) str_len - String length of the text (int) blocksize - block size of the algorithm Returns: (int) number of required pad bytes for string of size.''' assert 0 < blocksize...
python
def paddingLength(str_len, blocksize=AES_blocksize): ''' Function to calculate the length of the required padding Input: (int) str_len - String length of the text (int) blocksize - block size of the algorithm Returns: (int) number of required pad bytes for string of size.''' assert 0 < blocksize...
[ "def", "paddingLength", "(", "str_len", ",", "blocksize", "=", "AES_blocksize", ")", ":", "assert", "0", "<", "blocksize", "<", "255", ",", "'blocksize must be between 0 and 255'", "assert", "str_len", ">", "0", ",", "'string length should be non-negative'", "'If the ...
Function to calculate the length of the required padding Input: (int) str_len - String length of the text (int) blocksize - block size of the algorithm Returns: (int) number of required pad bytes for string of size.
[ "Function", "to", "calculate", "the", "length", "of", "the", "required", "padding", "Input", ":", "(", "int", ")", "str_len", "-", "String", "length", "of", "the", "text", "(", "int", ")", "blocksize", "-", "block", "size", "of", "the", "algorithm", "Ret...
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L77-L88
keenlabs/KeenClient-Python
keen/Padding.py
removeCMSPadding
def removeCMSPadding(str, blocksize=AES_blocksize): '''CMS padding: Remove padding with bytes containing the number of padding bytes ''' try: pad_len = ord(str[-1]) # last byte contains number of padding bytes except TypeError: pad_len = str[-1] assert pad_len <= blocksize, 'padding error' assert pad...
python
def removeCMSPadding(str, blocksize=AES_blocksize): '''CMS padding: Remove padding with bytes containing the number of padding bytes ''' try: pad_len = ord(str[-1]) # last byte contains number of padding bytes except TypeError: pad_len = str[-1] assert pad_len <= blocksize, 'padding error' assert pad...
[ "def", "removeCMSPadding", "(", "str", ",", "blocksize", "=", "AES_blocksize", ")", ":", "try", ":", "pad_len", "=", "ord", "(", "str", "[", "-", "1", "]", ")", "# last byte contains number of padding bytes", "except", "TypeError", ":", "pad_len", "=", "str", ...
CMS padding: Remove padding with bytes containing the number of padding bytes
[ "CMS", "padding", ":", "Remove", "padding", "with", "bytes", "containing", "the", "number", "of", "padding", "bytes" ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L104-L113
keenlabs/KeenClient-Python
keen/Padding.py
appendBitPadding
def appendBitPadding(str, blocksize=AES_blocksize): '''Bit padding a.k.a. One and Zeroes Padding A single set ('1') bit is added to the message and then as many reset ('0') bits as required (possibly none) are added. Input: (str) str - String to be padded (int) blocksize - block size of the algorithm R...
python
def appendBitPadding(str, blocksize=AES_blocksize): '''Bit padding a.k.a. One and Zeroes Padding A single set ('1') bit is added to the message and then as many reset ('0') bits as required (possibly none) are added. Input: (str) str - String to be padded (int) blocksize - block size of the algorithm R...
[ "def", "appendBitPadding", "(", "str", ",", "blocksize", "=", "AES_blocksize", ")", ":", "pad_len", "=", "paddingLength", "(", "len", "(", "str", ")", ",", "blocksize", ")", "-", "1", "padding", "=", "chr", "(", "0x80", ")", "+", "'\\0'", "*", "pad_len...
Bit padding a.k.a. One and Zeroes Padding A single set ('1') bit is added to the message and then as many reset ('0') bits as required (possibly none) are added. Input: (str) str - String to be padded (int) blocksize - block size of the algorithm Return: Padded string according to ANSI X.923 standart ...
[ "Bit", "padding", "a", ".", "k", ".", "a", ".", "One", "and", "Zeroes", "Padding", "A", "single", "set", "(", "1", ")", "bit", "is", "added", "to", "the", "message", "and", "then", "as", "many", "reset", "(", "0", ")", "bits", "as", "required", "...
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L115-L133
keenlabs/KeenClient-Python
keen/Padding.py
removeBitPadding
def removeBitPadding(str, blocksize=AES_blocksize): 'Remove bit padding with 0x80 followed by zero (null) bytes' pad_len = 0 for char in str[::-1]: # str[::-1] reverses string if char == '\0': pad_len += 1 else: break pad_len += 1 str = str[:-pad_len] ...
python
def removeBitPadding(str, blocksize=AES_blocksize): 'Remove bit padding with 0x80 followed by zero (null) bytes' pad_len = 0 for char in str[::-1]: # str[::-1] reverses string if char == '\0': pad_len += 1 else: break pad_len += 1 str = str[:-pad_len] ...
[ "def", "removeBitPadding", "(", "str", ",", "blocksize", "=", "AES_blocksize", ")", ":", "pad_len", "=", "0", "for", "char", "in", "str", "[", ":", ":", "-", "1", "]", ":", "# str[::-1] reverses string", "if", "char", "==", "'\\0'", ":", "pad_len", "+=",...
Remove bit padding with 0x80 followed by zero (null) bytes
[ "Remove", "bit", "padding", "with", "0x80", "followed", "by", "zero", "(", "null", ")", "bytes" ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L135-L146
keenlabs/KeenClient-Python
keen/Padding.py
removeZeroLenPadding
def removeZeroLenPadding(str, blocksize=AES_blocksize): 'Remove Padding with zeroes + last byte equal to the number of padding bytes' try: pad_len = ord(str[-1]) # last byte contains number of padding bytes except TypeError: pad_len = str[-1] assert pad_len < blocksize, 'padding error' assert pad_len...
python
def removeZeroLenPadding(str, blocksize=AES_blocksize): 'Remove Padding with zeroes + last byte equal to the number of padding bytes' try: pad_len = ord(str[-1]) # last byte contains number of padding bytes except TypeError: pad_len = str[-1] assert pad_len < blocksize, 'padding error' assert pad_len...
[ "def", "removeZeroLenPadding", "(", "str", ",", "blocksize", "=", "AES_blocksize", ")", ":", "try", ":", "pad_len", "=", "ord", "(", "str", "[", "-", "1", "]", ")", "# last byte contains number of padding bytes", "except", "TypeError", ":", "pad_len", "=", "st...
Remove Padding with zeroes + last byte equal to the number of padding bytes
[ "Remove", "Padding", "with", "zeroes", "+", "last", "byte", "equal", "to", "the", "number", "of", "padding", "bytes" ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L156-L165
keenlabs/KeenClient-Python
keen/Padding.py
appendNullPadding
def appendNullPadding(str, blocksize=AES_blocksize): 'Pad with null bytes' pad_len = paddingLength(len(str), blocksize) padding = '\0'*pad_len return str + padding
python
def appendNullPadding(str, blocksize=AES_blocksize): 'Pad with null bytes' pad_len = paddingLength(len(str), blocksize) padding = '\0'*pad_len return str + padding
[ "def", "appendNullPadding", "(", "str", ",", "blocksize", "=", "AES_blocksize", ")", ":", "pad_len", "=", "paddingLength", "(", "len", "(", "str", ")", ",", "blocksize", ")", "padding", "=", "'\\0'", "*", "pad_len", "return", "str", "+", "padding" ]
Pad with null bytes
[ "Pad", "with", "null", "bytes" ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L167-L173
keenlabs/KeenClient-Python
keen/Padding.py
removeNullPadding
def removeNullPadding(str, blocksize=AES_blocksize): 'Remove padding with null bytes' pad_len = 0 for char in str[::-1]: # str[::-1] reverses string if char == '\0': pad_len += 1 else: break str = str[:-pad_len] return str
python
def removeNullPadding(str, blocksize=AES_blocksize): 'Remove padding with null bytes' pad_len = 0 for char in str[::-1]: # str[::-1] reverses string if char == '\0': pad_len += 1 else: break str = str[:-pad_len] return str
[ "def", "removeNullPadding", "(", "str", ",", "blocksize", "=", "AES_blocksize", ")", ":", "pad_len", "=", "0", "for", "char", "in", "str", "[", ":", ":", "-", "1", "]", ":", "# str[::-1] reverses string", "if", "char", "==", "'\\0'", ":", "pad_len", "+="...
Remove padding with null bytes
[ "Remove", "padding", "with", "null", "bytes" ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L175-L184
keenlabs/KeenClient-Python
keen/Padding.py
appendSpacePadding
def appendSpacePadding(str, blocksize=AES_blocksize): 'Pad with spaces' pad_len = paddingLength(len(str), blocksize) padding = '\0'*pad_len return str + padding
python
def appendSpacePadding(str, blocksize=AES_blocksize): 'Pad with spaces' pad_len = paddingLength(len(str), blocksize) padding = '\0'*pad_len return str + padding
[ "def", "appendSpacePadding", "(", "str", ",", "blocksize", "=", "AES_blocksize", ")", ":", "pad_len", "=", "paddingLength", "(", "len", "(", "str", ")", ",", "blocksize", ")", "padding", "=", "'\\0'", "*", "pad_len", "return", "str", "+", "padding" ]
Pad with spaces
[ "Pad", "with", "spaces" ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L186-L192
keenlabs/KeenClient-Python
keen/Padding.py
removeSpacePadding
def removeSpacePadding(str, blocksize=AES_blocksize): 'Remove padding with spaces' pad_len = 0 for char in str[::-1]: # str[::-1] reverses string if char == ' ': pad_len += 1 else: break str = str[:-pad_len] return str
python
def removeSpacePadding(str, blocksize=AES_blocksize): 'Remove padding with spaces' pad_len = 0 for char in str[::-1]: # str[::-1] reverses string if char == ' ': pad_len += 1 else: break str = str[:-pad_len] return str
[ "def", "removeSpacePadding", "(", "str", ",", "blocksize", "=", "AES_blocksize", ")", ":", "pad_len", "=", "0", "for", "char", "in", "str", "[", ":", ":", "-", "1", "]", ":", "# str[::-1] reverses string", "if", "char", "==", "' '", ":", "pad_len", "+=",...
Remove padding with spaces
[ "Remove", "padding", "with", "spaces" ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L194-L205
keenlabs/KeenClient-Python
keen/Padding.py
appendRandomLenPadding
def appendRandomLenPadding(str, blocksize=AES_blocksize): 'ISO 10126 Padding (withdrawn, 2007): Pad with random bytes + last byte equal to the number of padding bytes' pad_len = paddingLength(len(str), blocksize) - 1 from os import urandom padding = urandom(pad_len)+chr(pad_len) return str + padding
python
def appendRandomLenPadding(str, blocksize=AES_blocksize): 'ISO 10126 Padding (withdrawn, 2007): Pad with random bytes + last byte equal to the number of padding bytes' pad_len = paddingLength(len(str), blocksize) - 1 from os import urandom padding = urandom(pad_len)+chr(pad_len) return str + padding
[ "def", "appendRandomLenPadding", "(", "str", ",", "blocksize", "=", "AES_blocksize", ")", ":", "pad_len", "=", "paddingLength", "(", "len", "(", "str", ")", ",", "blocksize", ")", "-", "1", "from", "os", "import", "urandom", "padding", "=", "urandom", "(",...
ISO 10126 Padding (withdrawn, 2007): Pad with random bytes + last byte equal to the number of padding bytes
[ "ISO", "10126", "Padding", "(", "withdrawn", "2007", ")", ":", "Pad", "with", "random", "bytes", "+", "last", "byte", "equal", "to", "the", "number", "of", "padding", "bytes" ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L207-L215
keenlabs/KeenClient-Python
keen/Padding.py
removeRandomLenPadding
def removeRandomLenPadding(str, blocksize=AES_blocksize): 'ISO 10126 Padding (withdrawn, 2007): Remove Padding with random bytes + last byte equal to the number of padding bytes' pad_len = ord(str[-1]) # last byte contains number of padding bytes assert pad_len < blocksize, 'padding error' assert pad_len < len...
python
def removeRandomLenPadding(str, blocksize=AES_blocksize): 'ISO 10126 Padding (withdrawn, 2007): Remove Padding with random bytes + last byte equal to the number of padding bytes' pad_len = ord(str[-1]) # last byte contains number of padding bytes assert pad_len < blocksize, 'padding error' assert pad_len < len...
[ "def", "removeRandomLenPadding", "(", "str", ",", "blocksize", "=", "AES_blocksize", ")", ":", "pad_len", "=", "ord", "(", "str", "[", "-", "1", "]", ")", "# last byte contains number of padding bytes", "assert", "pad_len", "<", "blocksize", ",", "'padding error'"...
ISO 10126 Padding (withdrawn, 2007): Remove Padding with random bytes + last byte equal to the number of padding bytes
[ "ISO", "10126", "Padding", "(", "withdrawn", "2007", ")", ":", "Remove", "Padding", "with", "random", "bytes", "+", "last", "byte", "equal", "to", "the", "number", "of", "padding", "bytes" ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L217-L223
keenlabs/KeenClient-Python
keen/Padding.py
appendPadding
def appendPadding(str, blocksize=AES_blocksize, mode='CMS'): ''' Pad (append padding to) string for use with symmetric encryption algorithm Input: (string) str - String to be padded (int) blocksize - block size of the encryption algorithm (string) mode - padding scheme one in (CMS, Bit, Z...
python
def appendPadding(str, blocksize=AES_blocksize, mode='CMS'): ''' Pad (append padding to) string for use with symmetric encryption algorithm Input: (string) str - String to be padded (int) blocksize - block size of the encryption algorithm (string) mode - padding scheme one in (CMS, Bit, Z...
[ "def", "appendPadding", "(", "str", ",", "blocksize", "=", "AES_blocksize", ",", "mode", "=", "'CMS'", ")", ":", "if", "mode", "not", "in", "(", "0", ",", "'CMS'", ")", ":", "for", "k", "in", "MODES", ".", "keys", "(", ")", ":", "if", "mode", "in...
Pad (append padding to) string for use with symmetric encryption algorithm Input: (string) str - String to be padded (int) blocksize - block size of the encryption algorithm (string) mode - padding scheme one in (CMS, Bit, ZeroLen, Null, Space, Random) Return:(string) Padded string acco...
[ "Pad", "(", "append", "padding", "to", ")", "string", "for", "use", "with", "symmetric", "encryption", "algorithm", "Input", ":", "(", "string", ")", "str", "-", "String", "to", "be", "padded", "(", "int", ")", "blocksize", "-", "block", "size", "of", ...
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L247-L261
keenlabs/KeenClient-Python
keen/Padding.py
removePadding
def removePadding(str, blocksize=AES_blocksize, mode='CMS'): ''' Remove padding from string Input: (str) str - String to be padded (int) blocksize - block size of the algorithm (string) mode - padding scheme one in (CMS, Bit, ZeroLen, Null, Space, Random) Return:(string) Decrypted string withou...
python
def removePadding(str, blocksize=AES_blocksize, mode='CMS'): ''' Remove padding from string Input: (str) str - String to be padded (int) blocksize - block size of the algorithm (string) mode - padding scheme one in (CMS, Bit, ZeroLen, Null, Space, Random) Return:(string) Decrypted string withou...
[ "def", "removePadding", "(", "str", ",", "blocksize", "=", "AES_blocksize", ",", "mode", "=", "'CMS'", ")", ":", "if", "mode", "not", "in", "(", "0", ",", "'CMS'", ")", ":", "for", "k", "in", "MODES", ".", "keys", "(", ")", ":", "if", "mode", "in...
Remove padding from string Input: (str) str - String to be padded (int) blocksize - block size of the algorithm (string) mode - padding scheme one in (CMS, Bit, ZeroLen, Null, Space, Random) Return:(string) Decrypted string without padding
[ "Remove", "padding", "from", "string", "Input", ":", "(", "str", ")", "str", "-", "String", "to", "be", "padded", "(", "int", ")", "blocksize", "-", "block", "size", "of", "the", "algorithm", "(", "string", ")", "mode", "-", "padding", "scheme", "one",...
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/Padding.py#L263-L277
quintusdias/glymur
glymur/jp2k.py
_default_error_handler
def _default_error_handler(msg, _): """Default error handler callback for libopenjp2.""" msg = "OpenJPEG library error: {0}".format(msg.decode('utf-8').rstrip()) opj2.set_error_message(msg)
python
def _default_error_handler(msg, _): """Default error handler callback for libopenjp2.""" msg = "OpenJPEG library error: {0}".format(msg.decode('utf-8').rstrip()) opj2.set_error_message(msg)
[ "def", "_default_error_handler", "(", "msg", ",", "_", ")", ":", "msg", "=", "\"OpenJPEG library error: {0}\"", ".", "format", "(", "msg", ".", "decode", "(", "'utf-8'", ")", ".", "rstrip", "(", ")", ")", "opj2", ".", "set_error_message", "(", "msg", ")" ...
Default error handler callback for libopenjp2.
[ "Default", "error", "handler", "callback", "for", "libopenjp2", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1874-L1877
quintusdias/glymur
glymur/jp2k.py
_default_warning_handler
def _default_warning_handler(library_msg, _): """Default warning handler callback.""" library_msg = library_msg.decode('utf-8').rstrip() msg = "OpenJPEG library warning: {0}".format(library_msg) warnings.warn(msg, UserWarning)
python
def _default_warning_handler(library_msg, _): """Default warning handler callback.""" library_msg = library_msg.decode('utf-8').rstrip() msg = "OpenJPEG library warning: {0}".format(library_msg) warnings.warn(msg, UserWarning)
[ "def", "_default_warning_handler", "(", "library_msg", ",", "_", ")", ":", "library_msg", "=", "library_msg", ".", "decode", "(", "'utf-8'", ")", ".", "rstrip", "(", ")", "msg", "=", "\"OpenJPEG library warning: {0}\"", ".", "format", "(", "library_msg", ")", ...
Default warning handler callback.
[ "Default", "warning", "handler", "callback", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1885-L1889
quintusdias/glymur
glymur/jp2k.py
Jp2k.parse
def parse(self): """Parses the JPEG 2000 file. Raises ------ IOError The file was not JPEG 2000. """ self.length = os.path.getsize(self.filename) with open(self.filename, 'rb') as fptr: # Make sure we have a JPEG2000 file. It could be e...
python
def parse(self): """Parses the JPEG 2000 file. Raises ------ IOError The file was not JPEG 2000. """ self.length = os.path.getsize(self.filename) with open(self.filename, 'rb') as fptr: # Make sure we have a JPEG2000 file. It could be e...
[ "def", "parse", "(", "self", ")", ":", "self", ".", "length", "=", "os", ".", "path", ".", "getsize", "(", "self", ".", "filename", ")", "with", "open", "(", "self", ".", "filename", ",", "'rb'", ")", "as", "fptr", ":", "# Make sure we have a JPEG2000 ...
Parses the JPEG 2000 file. Raises ------ IOError The file was not JPEG 2000.
[ "Parses", "the", "JPEG", "2000", "file", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L262-L306
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate
def _validate(self): """Validate the JPEG 2000 outermost superbox. These checks must be done at a file level. """ # A JP2 file must contain certain boxes. The 2nd box must be a file # type box. if not isinstance(self.box[1], FileTypeBox): msg = "{filename} d...
python
def _validate(self): """Validate the JPEG 2000 outermost superbox. These checks must be done at a file level. """ # A JP2 file must contain certain boxes. The 2nd box must be a file # type box. if not isinstance(self.box[1], FileTypeBox): msg = "{filename} d...
[ "def", "_validate", "(", "self", ")", ":", "# A JP2 file must contain certain boxes. The 2nd box must be a file", "# type box.", "if", "not", "isinstance", "(", "self", ".", "box", "[", "1", "]", ",", "FileTypeBox", ")", ":", "msg", "=", "\"{filename} does not contai...
Validate the JPEG 2000 outermost superbox. These checks must be done at a file level.
[ "Validate", "the", "JPEG", "2000", "outermost", "superbox", ".", "These", "checks", "must", "be", "done", "at", "a", "file", "level", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L308-L330
quintusdias/glymur
glymur/jp2k.py
Jp2k._set_cinema_params
def _set_cinema_params(self, cinema_mode, fps): """Populate compression parameters structure for cinema2K. Parameters ---------- params : ctypes struct Corresponds to compression parameters structure used by the library. cinema_mode : {'cinema2k', 'cinema...
python
def _set_cinema_params(self, cinema_mode, fps): """Populate compression parameters structure for cinema2K. Parameters ---------- params : ctypes struct Corresponds to compression parameters structure used by the library. cinema_mode : {'cinema2k', 'cinema...
[ "def", "_set_cinema_params", "(", "self", ",", "cinema_mode", ",", "fps", ")", ":", "if", "re", ".", "match", "(", "\"1.5|2.0\"", ",", "version", ".", "openjpeg_version", ")", "is", "not", "None", ":", "msg", "=", "(", "\"Writing Cinema2K or Cinema4K files is ...
Populate compression parameters structure for cinema2K. Parameters ---------- params : ctypes struct Corresponds to compression parameters structure used by the library. cinema_mode : {'cinema2k', 'cinema4k} Use either Cinema2K or Cinema4K profile. ...
[ "Populate", "compression", "parameters", "structure", "for", "cinema2K", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L332-L371
quintusdias/glymur
glymur/jp2k.py
Jp2k._populate_cparams
def _populate_cparams(self, img_array, mct=None, cratios=None, psnr=None, cinema2k=None, cinema4k=None, irreversible=None, cbsize=None, eph=None, grid_offset=None, modesw=None, numres=None, prog=None, psizes=None, sop=None, ...
python
def _populate_cparams(self, img_array, mct=None, cratios=None, psnr=None, cinema2k=None, cinema4k=None, irreversible=None, cbsize=None, eph=None, grid_offset=None, modesw=None, numres=None, prog=None, psizes=None, sop=None, ...
[ "def", "_populate_cparams", "(", "self", ",", "img_array", ",", "mct", "=", "None", ",", "cratios", "=", "None", ",", "psnr", "=", "None", ",", "cinema2k", "=", "None", ",", "cinema4k", "=", "None", ",", "irreversible", "=", "None", ",", "cbsize", "=",...
Directs processing of write method arguments. Parameters ---------- img_array : ndarray Image data to be written to file. kwargs : dictionary Non-image keyword inputs provided to write method.
[ "Directs", "processing", "of", "write", "method", "arguments", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L373-L495
quintusdias/glymur
glymur/jp2k.py
Jp2k._write
def _write(self, img_array, verbose=False, **kwargs): """Write image data to a JP2/JPX/J2k file. Intended usage of the various parameters follows that of OpenJPEG's opj_compress utility. This method can only be used to create JPEG 2000 images that can fit in memory. """ ...
python
def _write(self, img_array, verbose=False, **kwargs): """Write image data to a JP2/JPX/J2k file. Intended usage of the various parameters follows that of OpenJPEG's opj_compress utility. This method can only be used to create JPEG 2000 images that can fit in memory. """ ...
[ "def", "_write", "(", "self", ",", "img_array", ",", "verbose", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "re", ".", "match", "(", "\"0|1.[0-4]\"", ",", "version", ".", "openjpeg_version", ")", "is", "not", "None", ":", "msg", "=", "(", ...
Write image data to a JP2/JPX/J2k file. Intended usage of the various parameters follows that of OpenJPEG's opj_compress utility. This method can only be used to create JPEG 2000 images that can fit in memory.
[ "Write", "image", "data", "to", "a", "JP2", "/", "JPX", "/", "J2k", "file", ".", "Intended", "usage", "of", "the", "various", "parameters", "follows", "that", "of", "OpenJPEG", "s", "opj_compress", "utility", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L497-L515
quintusdias/glymur
glymur/jp2k.py
Jp2k._write_openjpeg
def _write_openjpeg(self, img_array, verbose=False): """ Write JPEG 2000 file using OpenJPEG 1.5 interface. """ if img_array.ndim == 2: # Force the image to be 3D. Just makes things easier later on. img_array = img_array.reshape(img_array.shape[0], ...
python
def _write_openjpeg(self, img_array, verbose=False): """ Write JPEG 2000 file using OpenJPEG 1.5 interface. """ if img_array.ndim == 2: # Force the image to be 3D. Just makes things easier later on. img_array = img_array.reshape(img_array.shape[0], ...
[ "def", "_write_openjpeg", "(", "self", ",", "img_array", ",", "verbose", "=", "False", ")", ":", "if", "img_array", ".", "ndim", "==", "2", ":", "# Force the image to be 3D. Just makes things easier later on.", "img_array", "=", "img_array", ".", "reshape", "(", ...
Write JPEG 2000 file using OpenJPEG 1.5 interface.
[ "Write", "JPEG", "2000", "file", "using", "OpenJPEG", "1", ".", "5", "interface", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L517-L582
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_j2k_colorspace
def _validate_j2k_colorspace(self, cparams, colorspace): """ Cannot specify a colorspace with J2K. """ if cparams.codec_fmt == opj2.CODEC_J2K and colorspace is not None: msg = 'Do not specify a colorspace when writing a raw codestream.' raise IOError(msg)
python
def _validate_j2k_colorspace(self, cparams, colorspace): """ Cannot specify a colorspace with J2K. """ if cparams.codec_fmt == opj2.CODEC_J2K and colorspace is not None: msg = 'Do not specify a colorspace when writing a raw codestream.' raise IOError(msg)
[ "def", "_validate_j2k_colorspace", "(", "self", ",", "cparams", ",", "colorspace", ")", ":", "if", "cparams", ".", "codec_fmt", "==", "opj2", ".", "CODEC_J2K", "and", "colorspace", "is", "not", "None", ":", "msg", "=", "'Do not specify a colorspace when writing a ...
Cannot specify a colorspace with J2K.
[ "Cannot", "specify", "a", "colorspace", "with", "J2K", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L584-L590
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_codeblock_size
def _validate_codeblock_size(self, cparams): """ Code block dimensions must satisfy certain restrictions. They must both be a power of 2 and the total area defined by the width and height cannot be either too great or too small for the codec. """ if cparams.cblockw_init ...
python
def _validate_codeblock_size(self, cparams): """ Code block dimensions must satisfy certain restrictions. They must both be a power of 2 and the total area defined by the width and height cannot be either too great or too small for the codec. """ if cparams.cblockw_init ...
[ "def", "_validate_codeblock_size", "(", "self", ",", "cparams", ")", ":", "if", "cparams", ".", "cblockw_init", "!=", "0", "and", "cparams", ".", "cblockh_init", "!=", "0", ":", "# These fields ARE zero if uninitialized.", "width", "=", "cparams", ".", "cblockw_in...
Code block dimensions must satisfy certain restrictions. They must both be a power of 2 and the total area defined by the width and height cannot be either too great or too small for the codec.
[ "Code", "block", "dimensions", "must", "satisfy", "certain", "restrictions", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L592-L617
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_precinct_size
def _validate_precinct_size(self, cparams): """ Precinct dimensions must satisfy certain restrictions if specified. They must both be a power of 2 and must both be at least twice the size of their codeblock size counterparts. """ code_block_specified = False if c...
python
def _validate_precinct_size(self, cparams): """ Precinct dimensions must satisfy certain restrictions if specified. They must both be a power of 2 and must both be at least twice the size of their codeblock size counterparts. """ code_block_specified = False if c...
[ "def", "_validate_precinct_size", "(", "self", ",", "cparams", ")", ":", "code_block_specified", "=", "False", "if", "cparams", ".", "cblockw_init", "!=", "0", "and", "cparams", ".", "cblockh_init", "!=", "0", ":", "code_block_specified", "=", "True", "if", "c...
Precinct dimensions must satisfy certain restrictions if specified. They must both be a power of 2 and must both be at least twice the size of their codeblock size counterparts.
[ "Precinct", "dimensions", "must", "satisfy", "certain", "restrictions", "if", "specified", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L619-L650
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_image_rank
def _validate_image_rank(self, img_array): """ Images must be either 2D or 3D. """ if img_array.ndim == 1 or img_array.ndim > 3: msg = "{0}D imagery is not allowed.".format(img_array.ndim) raise IOError(msg)
python
def _validate_image_rank(self, img_array): """ Images must be either 2D or 3D. """ if img_array.ndim == 1 or img_array.ndim > 3: msg = "{0}D imagery is not allowed.".format(img_array.ndim) raise IOError(msg)
[ "def", "_validate_image_rank", "(", "self", ",", "img_array", ")", ":", "if", "img_array", ".", "ndim", "==", "1", "or", "img_array", ".", "ndim", ">", "3", ":", "msg", "=", "\"{0}D imagery is not allowed.\"", ".", "format", "(", "img_array", ".", "ndim", ...
Images must be either 2D or 3D.
[ "Images", "must", "be", "either", "2D", "or", "3D", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L652-L658
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_image_datatype
def _validate_image_datatype(self, img_array): """ Only uint8 and uint16 images are currently supported. """ if img_array.dtype != np.uint8 and img_array.dtype != np.uint16: msg = ("Only uint8 and uint16 datatypes are currently supported " "when writing.") ...
python
def _validate_image_datatype(self, img_array): """ Only uint8 and uint16 images are currently supported. """ if img_array.dtype != np.uint8 and img_array.dtype != np.uint16: msg = ("Only uint8 and uint16 datatypes are currently supported " "when writing.") ...
[ "def", "_validate_image_datatype", "(", "self", ",", "img_array", ")", ":", "if", "img_array", ".", "dtype", "!=", "np", ".", "uint8", "and", "img_array", ".", "dtype", "!=", "np", ".", "uint16", ":", "msg", "=", "(", "\"Only uint8 and uint16 datatypes are cur...
Only uint8 and uint16 images are currently supported.
[ "Only", "uint8", "and", "uint16", "images", "are", "currently", "supported", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L660-L667
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_compression_params
def _validate_compression_params(self, img_array, cparams, colorspace): """Check that the compression parameters are valid. Parameters ---------- img_array : ndarray Image data to be written to file. cparams : CompressionParametersType(ctypes.Structure) C...
python
def _validate_compression_params(self, img_array, cparams, colorspace): """Check that the compression parameters are valid. Parameters ---------- img_array : ndarray Image data to be written to file. cparams : CompressionParametersType(ctypes.Structure) C...
[ "def", "_validate_compression_params", "(", "self", ",", "img_array", ",", "cparams", ",", "colorspace", ")", ":", "self", ".", "_validate_j2k_colorspace", "(", "cparams", ",", "colorspace", ")", "self", ".", "_validate_codeblock_size", "(", "cparams", ")", "self"...
Check that the compression parameters are valid. Parameters ---------- img_array : ndarray Image data to be written to file. cparams : CompressionParametersType(ctypes.Structure) Corresponds to cparameters_t type in openjp2 headers.
[ "Check", "that", "the", "compression", "parameters", "are", "valid", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L669-L683
quintusdias/glymur
glymur/jp2k.py
Jp2k._determine_colorspace
def _determine_colorspace(self, colorspace=None, **kwargs): """Determine the colorspace from the supplied inputs. Parameters ---------- colorspace : str, optional Either 'rgb' or 'gray'. """ if colorspace is None: # Must infer the colorspace from ...
python
def _determine_colorspace(self, colorspace=None, **kwargs): """Determine the colorspace from the supplied inputs. Parameters ---------- colorspace : str, optional Either 'rgb' or 'gray'. """ if colorspace is None: # Must infer the colorspace from ...
[ "def", "_determine_colorspace", "(", "self", ",", "colorspace", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "colorspace", "is", "None", ":", "# Must infer the colorspace from the image dimensions.", "if", "len", "(", "self", ".", "shape", ")", "<", "...
Determine the colorspace from the supplied inputs. Parameters ---------- colorspace : str, optional Either 'rgb' or 'gray'.
[ "Determine", "the", "colorspace", "from", "the", "supplied", "inputs", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L685-L720
quintusdias/glymur
glymur/jp2k.py
Jp2k._write_openjp2
def _write_openjp2(self, img_array, verbose=False): """ Write JPEG 2000 file using OpenJPEG 2.x interface. """ if img_array.ndim == 2: # Force the image to be 3D. Just makes things easier later on. numrows, numcols = img_array.shape img_array = img_ar...
python
def _write_openjp2(self, img_array, verbose=False): """ Write JPEG 2000 file using OpenJPEG 2.x interface. """ if img_array.ndim == 2: # Force the image to be 3D. Just makes things easier later on. numrows, numcols = img_array.shape img_array = img_ar...
[ "def", "_write_openjp2", "(", "self", ",", "img_array", ",", "verbose", "=", "False", ")", ":", "if", "img_array", ".", "ndim", "==", "2", ":", "# Force the image to be 3D. Just makes things easier later on.", "numrows", ",", "numcols", "=", "img_array", ".", "sh...
Write JPEG 2000 file using OpenJPEG 2.x interface.
[ "Write", "JPEG", "2000", "file", "using", "OpenJPEG", "2", ".", "x", "interface", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L722-L762
quintusdias/glymur
glymur/jp2k.py
Jp2k.append
def append(self, box): """Append a JP2 box to the file in-place. Parameters ---------- box : Jp2Box Instance of a JP2 box. Only UUID and XML boxes can currently be appended. """ if self._codec_format == opj2.CODEC_J2K: msg = "Only JP2...
python
def append(self, box): """Append a JP2 box to the file in-place. Parameters ---------- box : Jp2Box Instance of a JP2 box. Only UUID and XML boxes can currently be appended. """ if self._codec_format == opj2.CODEC_J2K: msg = "Only JP2...
[ "def", "append", "(", "self", ",", "box", ")", ":", "if", "self", ".", "_codec_format", "==", "opj2", ".", "CODEC_J2K", ":", "msg", "=", "\"Only JP2 files can currently have boxes appended to them.\"", "raise", "IOError", "(", "msg", ")", "if", "not", "(", "("...
Append a JP2 box to the file in-place. Parameters ---------- box : Jp2Box Instance of a JP2 box. Only UUID and XML boxes can currently be appended.
[ "Append", "a", "JP2", "box", "to", "the", "file", "in", "-", "place", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L764-L803
quintusdias/glymur
glymur/jp2k.py
Jp2k.wrap
def wrap(self, filename, boxes=None): """Create a new JP2/JPX file wrapped in a new set of JP2 boxes. This method is primarily aimed at wrapping a raw codestream in a set of of JP2 boxes (turning it into a JP2 file instead of just a raw codestream), or rewrapping a codestream in a JP2 f...
python
def wrap(self, filename, boxes=None): """Create a new JP2/JPX file wrapped in a new set of JP2 boxes. This method is primarily aimed at wrapping a raw codestream in a set of of JP2 boxes (turning it into a JP2 file instead of just a raw codestream), or rewrapping a codestream in a JP2 f...
[ "def", "wrap", "(", "self", ",", "filename", ",", "boxes", "=", "None", ")", ":", "if", "boxes", "is", "None", ":", "boxes", "=", "self", ".", "_get_default_jp2_boxes", "(", ")", "self", ".", "_validate_jp2_box_sequence", "(", "boxes", ")", "with", "open...
Create a new JP2/JPX file wrapped in a new set of JP2 boxes. This method is primarily aimed at wrapping a raw codestream in a set of of JP2 boxes (turning it into a JP2 file instead of just a raw codestream), or rewrapping a codestream in a JP2 file in a new "jacket" of JP2 boxes. ...
[ "Create", "a", "new", "JP2", "/", "JPX", "file", "wrapped", "in", "a", "new", "set", "of", "JP2", "boxes", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L805-L851
quintusdias/glymur
glymur/jp2k.py
Jp2k._write_wrapped_codestream
def _write_wrapped_codestream(self, ofile, box): """Write wrapped codestream.""" # Codestreams require a bit more care. # Am I a raw codestream? if len(self.box) == 0: # Yes, just write the codestream box header plus all # of myself out to file. ofile....
python
def _write_wrapped_codestream(self, ofile, box): """Write wrapped codestream.""" # Codestreams require a bit more care. # Am I a raw codestream? if len(self.box) == 0: # Yes, just write the codestream box header plus all # of myself out to file. ofile....
[ "def", "_write_wrapped_codestream", "(", "self", ",", "ofile", ",", "box", ")", ":", "# Codestreams require a bit more care.", "# Am I a raw codestream?", "if", "len", "(", "self", ".", "box", ")", "==", "0", ":", "# Yes, just write the codestream box header plus all", ...
Write wrapped codestream.
[ "Write", "wrapped", "codestream", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L853-L902
quintusdias/glymur
glymur/jp2k.py
Jp2k._get_default_jp2_boxes
def _get_default_jp2_boxes(self): """Create a default set of JP2 boxes.""" # Try to create a reasonable default. boxes = [JPEG2000SignatureBox(), FileTypeBox(), JP2HeaderBox(), ContiguousCodestreamBox()] height = self.codestream.segment[...
python
def _get_default_jp2_boxes(self): """Create a default set of JP2 boxes.""" # Try to create a reasonable default. boxes = [JPEG2000SignatureBox(), FileTypeBox(), JP2HeaderBox(), ContiguousCodestreamBox()] height = self.codestream.segment[...
[ "def", "_get_default_jp2_boxes", "(", "self", ")", ":", "# Try to create a reasonable default.", "boxes", "=", "[", "JPEG2000SignatureBox", "(", ")", ",", "FileTypeBox", "(", ")", ",", "JP2HeaderBox", "(", ")", ",", "ContiguousCodestreamBox", "(", ")", "]", "heigh...
Create a default set of JP2 boxes.
[ "Create", "a", "default", "set", "of", "JP2", "boxes", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L904-L930
quintusdias/glymur
glymur/jp2k.py
Jp2k._remove_ellipsis
def _remove_ellipsis(self, index, numrows, numcols, numbands): """ resolve the first ellipsis in the index so that it references the image Parameters ---------- index : tuple tuple of index arguments, presumably one of them is the Ellipsis numrows, numcols, n...
python
def _remove_ellipsis(self, index, numrows, numcols, numbands): """ resolve the first ellipsis in the index so that it references the image Parameters ---------- index : tuple tuple of index arguments, presumably one of them is the Ellipsis numrows, numcols, n...
[ "def", "_remove_ellipsis", "(", "self", ",", "index", ",", "numrows", ",", "numcols", ",", "numbands", ")", ":", "# Remove the first ellipsis we find.", "rows", "=", "slice", "(", "0", ",", "numrows", ")", "cols", "=", "slice", "(", "0", ",", "numcols", ")...
resolve the first ellipsis in the index so that it references the image Parameters ---------- index : tuple tuple of index arguments, presumably one of them is the Ellipsis numrows, numcols, numbands : int image dimensions Returns ------- ...
[ "resolve", "the", "first", "ellipsis", "in", "the", "index", "so", "that", "it", "references", "the", "image" ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L948-L987
quintusdias/glymur
glymur/jp2k.py
Jp2k._read
def _read(self, **kwargs): """Read a JPEG 2000 image. Returns ------- ndarray The image data. Raises ------ RuntimeError if the proper version of the OpenJPEG library is not available """ if re.match("0|1.[01234]", version...
python
def _read(self, **kwargs): """Read a JPEG 2000 image. Returns ------- ndarray The image data. Raises ------ RuntimeError if the proper version of the OpenJPEG library is not available """ if re.match("0|1.[01234]", version...
[ "def", "_read", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "re", ".", "match", "(", "\"0|1.[01234]\"", ",", "version", ".", "openjpeg_version", ")", ":", "msg", "=", "(", "\"You must have a version of OpenJPEG at least as high as \"", "\"1.5.0 before yo...
Read a JPEG 2000 image. Returns ------- ndarray The image data. Raises ------ RuntimeError if the proper version of the OpenJPEG library is not available
[ "Read", "a", "JPEG", "2000", "image", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1081-L1104
quintusdias/glymur
glymur/jp2k.py
Jp2k._subsampling_sanity_check
def _subsampling_sanity_check(self): """Check for differing subsample factors. """ dxs = np.array(self.codestream.segment[1].xrsiz) dys = np.array(self.codestream.segment[1].yrsiz) if np.any(dxs - dxs[0]) or np.any(dys - dys[0]): msg = ("The read_bands method should b...
python
def _subsampling_sanity_check(self): """Check for differing subsample factors. """ dxs = np.array(self.codestream.segment[1].xrsiz) dys = np.array(self.codestream.segment[1].yrsiz) if np.any(dxs - dxs[0]) or np.any(dys - dys[0]): msg = ("The read_bands method should b...
[ "def", "_subsampling_sanity_check", "(", "self", ")", ":", "dxs", "=", "np", ".", "array", "(", "self", ".", "codestream", ".", "segment", "[", "1", "]", ".", "xrsiz", ")", "dys", "=", "np", ".", "array", "(", "self", ".", "codestream", ".", "segment...
Check for differing subsample factors.
[ "Check", "for", "differing", "subsample", "factors", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1144-L1154
quintusdias/glymur
glymur/jp2k.py
Jp2k._read_openjpeg
def _read_openjpeg(self, rlevel=0, verbose=False, area=None): """Read a JPEG 2000 image using libopenjpeg. Parameters ---------- rlevel : int, optional Factor by which to rlevel output resolution. Use -1 to get the lowest resolution thumbnail. verbose : ...
python
def _read_openjpeg(self, rlevel=0, verbose=False, area=None): """Read a JPEG 2000 image using libopenjpeg. Parameters ---------- rlevel : int, optional Factor by which to rlevel output resolution. Use -1 to get the lowest resolution thumbnail. verbose : ...
[ "def", "_read_openjpeg", "(", "self", ",", "rlevel", "=", "0", ",", "verbose", "=", "False", ",", "area", "=", "None", ")", ":", "self", ".", "_subsampling_sanity_check", "(", ")", "self", ".", "_populate_dparams", "(", "rlevel", ")", "with", "ExitStack", ...
Read a JPEG 2000 image using libopenjpeg. Parameters ---------- rlevel : int, optional Factor by which to rlevel output resolution. Use -1 to get the lowest resolution thumbnail. verbose : bool, optional Print informational messages produced by the O...
[ "Read", "a", "JPEG", "2000", "image", "using", "libopenjpeg", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1156-L1225
quintusdias/glymur
glymur/jp2k.py
Jp2k._read_openjp2
def _read_openjp2(self, rlevel=0, layer=None, area=None, tile=None, verbose=False): """Read a JPEG 2000 image using libopenjp2. Parameters ---------- layer : int, optional Number of quality layer to decode. rlevel : int, optional Fac...
python
def _read_openjp2(self, rlevel=0, layer=None, area=None, tile=None, verbose=False): """Read a JPEG 2000 image using libopenjp2. Parameters ---------- layer : int, optional Number of quality layer to decode. rlevel : int, optional Fac...
[ "def", "_read_openjp2", "(", "self", ",", "rlevel", "=", "0", ",", "layer", "=", "None", ",", "area", "=", "None", ",", "tile", "=", "None", ",", "verbose", "=", "False", ")", ":", "self", ".", "layer", "=", "layer", "self", ".", "_subsampling_sanity...
Read a JPEG 2000 image using libopenjp2. Parameters ---------- layer : int, optional Number of quality layer to decode. rlevel : int, optional Factor by which to rlevel output resolution. Use -1 to get the lowest resolution thumbnail. area : ...
[ "Read", "a", "JPEG", "2000", "image", "using", "libopenjp2", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1227-L1260
quintusdias/glymur
glymur/jp2k.py
Jp2k._read_openjp2_common
def _read_openjp2_common(self): """ Read a JPEG 2000 image using libopenjp2. Returns ------- ndarray or lst Either the image as an ndarray or a list of ndarrays, each item corresponding to one band. """ with ExitStack() as stack: ...
python
def _read_openjp2_common(self): """ Read a JPEG 2000 image using libopenjp2. Returns ------- ndarray or lst Either the image as an ndarray or a list of ndarrays, each item corresponding to one band. """ with ExitStack() as stack: ...
[ "def", "_read_openjp2_common", "(", "self", ")", ":", "with", "ExitStack", "(", ")", "as", "stack", ":", "filename", "=", "self", ".", "filename", "stream", "=", "opj2", ".", "stream_create_default_file_stream", "(", "filename", ",", "True", ")", "stack", "....
Read a JPEG 2000 image using libopenjp2. Returns ------- ndarray or lst Either the image as an ndarray or a list of ndarrays, each item corresponding to one band.
[ "Read", "a", "JPEG", "2000", "image", "using", "libopenjp2", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1262-L1304
quintusdias/glymur
glymur/jp2k.py
Jp2k._populate_dparams
def _populate_dparams(self, rlevel, tile=None, area=None): """Populate decompression structure with appropriate input parameters. Parameters ---------- rlevel : int Factor by which to rlevel output resolution. area : tuple Specifies decoding image area, ...
python
def _populate_dparams(self, rlevel, tile=None, area=None): """Populate decompression structure with appropriate input parameters. Parameters ---------- rlevel : int Factor by which to rlevel output resolution. area : tuple Specifies decoding image area, ...
[ "def", "_populate_dparams", "(", "self", ",", "rlevel", ",", "tile", "=", "None", ",", "area", "=", "None", ")", ":", "if", "opj2", ".", "OPENJP2", "is", "not", "None", ":", "dparam", "=", "opj2", ".", "set_default_decoder_parameters", "(", ")", "else", ...
Populate decompression structure with appropriate input parameters. Parameters ---------- rlevel : int Factor by which to rlevel output resolution. area : tuple Specifies decoding image area, (first_row, first_col, last_row, last_col) tile : i...
[ "Populate", "decompression", "structure", "with", "appropriate", "input", "parameters", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1306-L1370
quintusdias/glymur
glymur/jp2k.py
Jp2k.read_bands
def read_bands(self, rlevel=0, layer=None, area=None, tile=None, verbose=False, ignore_pclr_cmap_cdef=False): """Read a JPEG 2000 image. The only time you should use this method is when the image has different subsampling factors across components. Otherwise you should ...
python
def read_bands(self, rlevel=0, layer=None, area=None, tile=None, verbose=False, ignore_pclr_cmap_cdef=False): """Read a JPEG 2000 image. The only time you should use this method is when the image has different subsampling factors across components. Otherwise you should ...
[ "def", "read_bands", "(", "self", ",", "rlevel", "=", "0", ",", "layer", "=", "None", ",", "area", "=", "None", ",", "tile", "=", "None", ",", "verbose", "=", "False", ",", "ignore_pclr_cmap_cdef", "=", "False", ")", ":", "if", "version", ".", "openj...
Read a JPEG 2000 image. The only time you should use this method is when the image has different subsampling factors across components. Otherwise you should use the read method. Parameters ---------- layer : int, optional Number of quality layer to decode. ...
[ "Read", "a", "JPEG", "2000", "image", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1372-L1424
quintusdias/glymur
glymur/jp2k.py
Jp2k._extract_image
def _extract_image(self, raw_image): """ Extract unequally-sized image bands. Parameters ---------- raw_image : reference to openjpeg ImageType instance The image structure initialized with image characteristics. Returns ------- list or ndarr...
python
def _extract_image(self, raw_image): """ Extract unequally-sized image bands. Parameters ---------- raw_image : reference to openjpeg ImageType instance The image structure initialized with image characteristics. Returns ------- list or ndarr...
[ "def", "_extract_image", "(", "self", ",", "raw_image", ")", ":", "ncomps", "=", "raw_image", ".", "contents", ".", "numcomps", "# Make a pass thru the image, see if any of the band datatypes or", "# dimensions differ.", "dtypes", ",", "nrows", ",", "ncols", "=", "[", ...
Extract unequally-sized image bands. Parameters ---------- raw_image : reference to openjpeg ImageType instance The image structure initialized with image characteristics. Returns ------- list or ndarray If the JPEG 2000 image has unequally-sized...
[ "Extract", "unequally", "-", "sized", "image", "bands", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1426-L1483
quintusdias/glymur
glymur/jp2k.py
Jp2k._component2dtype
def _component2dtype(self, component): """Determin the appropriate numpy datatype for an OpenJPEG component. Parameters ---------- component : ctypes pointer to ImageCompType (image_comp_t) single image component structure. Returns ------- builtins.t...
python
def _component2dtype(self, component): """Determin the appropriate numpy datatype for an OpenJPEG component. Parameters ---------- component : ctypes pointer to ImageCompType (image_comp_t) single image component structure. Returns ------- builtins.t...
[ "def", "_component2dtype", "(", "self", ",", "component", ")", ":", "if", "component", ".", "prec", ">", "16", ":", "msg", "=", "\"Unhandled precision: {0} bits.\"", ".", "format", "(", "component", ".", "prec", ")", "raise", "IOError", "(", "msg", ")", "i...
Determin the appropriate numpy datatype for an OpenJPEG component. Parameters ---------- component : ctypes pointer to ImageCompType (image_comp_t) single image component structure. Returns ------- builtins.type numpy datatype to be used to const...
[ "Determin", "the", "appropriate", "numpy", "datatype", "for", "an", "OpenJPEG", "component", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1485-L1507
quintusdias/glymur
glymur/jp2k.py
Jp2k.get_codestream
def get_codestream(self, header_only=True): """Retrieve codestream. Parameters ---------- header_only : bool, optional If True, only marker segments in the main header are parsed. Supplying False may impose a large performance penalty. Returns --...
python
def get_codestream(self, header_only=True): """Retrieve codestream. Parameters ---------- header_only : bool, optional If True, only marker segments in the main header are parsed. Supplying False may impose a large performance penalty. Returns --...
[ "def", "get_codestream", "(", "self", ",", "header_only", "=", "True", ")", ":", "with", "open", "(", "self", ".", "filename", ",", "'rb'", ")", "as", "fptr", ":", "if", "self", ".", "_codec_format", "==", "opj2", ".", "CODEC_J2K", ":", "codestream", "...
Retrieve codestream. Parameters ---------- header_only : bool, optional If True, only marker segments in the main header are parsed. Supplying False may impose a large performance penalty. Returns ------- Codestream Object describing ...
[ "Retrieve", "codestream", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1509-L1560
quintusdias/glymur
glymur/jp2k.py
Jp2k._populate_image_struct
def _populate_image_struct(self, image, imgdata): """Populates image struct needed for compression. Parameters ---------- image : ImageType(ctypes.Structure) Corresponds to image_t type in openjp2 headers. img_array : ndarray Image data to be written to f...
python
def _populate_image_struct(self, image, imgdata): """Populates image struct needed for compression. Parameters ---------- image : ImageType(ctypes.Structure) Corresponds to image_t type in openjp2 headers. img_array : ndarray Image data to be written to f...
[ "def", "_populate_image_struct", "(", "self", ",", "image", ",", "imgdata", ")", ":", "numrows", ",", "numcols", ",", "num_comps", "=", "imgdata", ".", "shape", "for", "k", "in", "range", "(", "num_comps", ")", ":", "self", ".", "_validate_nonzero_image_size...
Populates image struct needed for compression. Parameters ---------- image : ImageType(ctypes.Structure) Corresponds to image_t type in openjp2 headers. img_array : ndarray Image data to be written to file.
[ "Populates", "image", "struct", "needed", "for", "compression", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1562-L1597
quintusdias/glymur
glymur/jp2k.py
Jp2k._populate_comptparms
def _populate_comptparms(self, img_array): """Instantiate and populate comptparms structure. This structure defines the image components. Parameters ---------- img_array : ndarray Image data to be written to file. """ # Only two precisions are possib...
python
def _populate_comptparms(self, img_array): """Instantiate and populate comptparms structure. This structure defines the image components. Parameters ---------- img_array : ndarray Image data to be written to file. """ # Only two precisions are possib...
[ "def", "_populate_comptparms", "(", "self", ",", "img_array", ")", ":", "# Only two precisions are possible.", "if", "img_array", ".", "dtype", "==", "np", ".", "uint8", ":", "comp_prec", "=", "8", "else", ":", "comp_prec", "=", "16", "numrows", ",", "numcols"...
Instantiate and populate comptparms structure. This structure defines the image components. Parameters ---------- img_array : ndarray Image data to be written to file.
[ "Instantiate", "and", "populate", "comptparms", "structure", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1599-L1631
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_nonzero_image_size
def _validate_nonzero_image_size(self, nrows, ncols, component_index): """The image cannot have area of zero. """ if nrows == 0 or ncols == 0: # Letting this situation continue would segfault openjpeg. msg = "Component {0} has dimensions {1} x {2}" msg = msg.f...
python
def _validate_nonzero_image_size(self, nrows, ncols, component_index): """The image cannot have area of zero. """ if nrows == 0 or ncols == 0: # Letting this situation continue would segfault openjpeg. msg = "Component {0} has dimensions {1} x {2}" msg = msg.f...
[ "def", "_validate_nonzero_image_size", "(", "self", ",", "nrows", ",", "ncols", ",", "component_index", ")", ":", "if", "nrows", "==", "0", "or", "ncols", "==", "0", ":", "# Letting this situation continue would segfault openjpeg.", "msg", "=", "\"Component {0} has di...
The image cannot have area of zero.
[ "The", "image", "cannot", "have", "area", "of", "zero", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1633-L1640
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_jp2_box_sequence
def _validate_jp2_box_sequence(self, boxes): """Run through series of tests for JP2 box legality. This is non-exhaustive. """ JP2_IDS = ['colr', 'cdef', 'cmap', 'jp2c', 'ftyp', 'ihdr', 'jp2h', 'jP ', 'pclr', 'res ', 'resc', 'resd', 'xml ', 'ulst', ...
python
def _validate_jp2_box_sequence(self, boxes): """Run through series of tests for JP2 box legality. This is non-exhaustive. """ JP2_IDS = ['colr', 'cdef', 'cmap', 'jp2c', 'ftyp', 'ihdr', 'jp2h', 'jP ', 'pclr', 'res ', 'resc', 'resd', 'xml ', 'ulst', ...
[ "def", "_validate_jp2_box_sequence", "(", "self", ",", "boxes", ")", ":", "JP2_IDS", "=", "[", "'colr'", ",", "'cdef'", ",", "'cmap'", ",", "'jp2c'", ",", "'ftyp'", ",", "'ihdr'", ",", "'jp2h'", ",", "'jP '", ",", "'pclr'", ",", "'res '", ",", "'resc'",...
Run through series of tests for JP2 box legality. This is non-exhaustive.
[ "Run", "through", "series", "of", "tests", "for", "JP2", "box", "legality", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1642-L1665
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_jp2_colr
def _validate_jp2_colr(self, boxes): """ Validate JP2 requirements on colour specification boxes. """ lst = [box for box in boxes if box.box_id == 'jp2h'] jp2h = lst[0] for colr in [box for box in jp2h.box if box.box_id == 'colr']: if colr.approximation != 0: ...
python
def _validate_jp2_colr(self, boxes): """ Validate JP2 requirements on colour specification boxes. """ lst = [box for box in boxes if box.box_id == 'jp2h'] jp2h = lst[0] for colr in [box for box in jp2h.box if box.box_id == 'colr']: if colr.approximation != 0: ...
[ "def", "_validate_jp2_colr", "(", "self", ",", "boxes", ")", ":", "lst", "=", "[", "box", "for", "box", "in", "boxes", "if", "box", ".", "box_id", "==", "'jp2h'", "]", "jp2h", "=", "lst", "[", "0", "]", "for", "colr", "in", "[", "box", "for", "bo...
Validate JP2 requirements on colour specification boxes.
[ "Validate", "JP2", "requirements", "on", "colour", "specification", "boxes", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1667-L1677
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_jpx_box_sequence
def _validate_jpx_box_sequence(self, boxes): """Run through series of tests for JPX box legality.""" self._validate_label(boxes) self._validate_jpx_compatibility(boxes, boxes[1].compatibility_list) self._validate_singletons(boxes) self._validate_top_level(boxes)
python
def _validate_jpx_box_sequence(self, boxes): """Run through series of tests for JPX box legality.""" self._validate_label(boxes) self._validate_jpx_compatibility(boxes, boxes[1].compatibility_list) self._validate_singletons(boxes) self._validate_top_level(boxes)
[ "def", "_validate_jpx_box_sequence", "(", "self", ",", "boxes", ")", ":", "self", ".", "_validate_label", "(", "boxes", ")", "self", ".", "_validate_jpx_compatibility", "(", "boxes", ",", "boxes", "[", "1", "]", ".", "compatibility_list", ")", "self", ".", "...
Run through series of tests for JPX box legality.
[ "Run", "through", "series", "of", "tests", "for", "JPX", "box", "legality", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1679-L1684
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_signature_compatibility
def _validate_signature_compatibility(self, boxes): """Validate the file signature and compatibility status.""" # Check for a bad sequence of boxes. # 1st two boxes must be 'jP ' and 'ftyp' if boxes[0].box_id != 'jP ' or boxes[1].box_id != 'ftyp': msg = ("The first box must...
python
def _validate_signature_compatibility(self, boxes): """Validate the file signature and compatibility status.""" # Check for a bad sequence of boxes. # 1st two boxes must be 'jP ' and 'ftyp' if boxes[0].box_id != 'jP ' or boxes[1].box_id != 'ftyp': msg = ("The first box must...
[ "def", "_validate_signature_compatibility", "(", "self", ",", "boxes", ")", ":", "# Check for a bad sequence of boxes.", "# 1st two boxes must be 'jP ' and 'ftyp'", "if", "boxes", "[", "0", "]", ".", "box_id", "!=", "'jP '", "or", "boxes", "[", "1", "]", ".", "box...
Validate the file signature and compatibility status.
[ "Validate", "the", "file", "signature", "and", "compatibility", "status", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1686-L1698
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_jp2c
def _validate_jp2c(self, boxes): """Validate the codestream box in relation to other boxes.""" # jp2c must be preceeded by jp2h jp2h_lst = [idx for (idx, box) in enumerate(boxes) if box.box_id == 'jp2h'] jp2h_idx = jp2h_lst[0] jp2c_lst = [idx for (idx, box) in...
python
def _validate_jp2c(self, boxes): """Validate the codestream box in relation to other boxes.""" # jp2c must be preceeded by jp2h jp2h_lst = [idx for (idx, box) in enumerate(boxes) if box.box_id == 'jp2h'] jp2h_idx = jp2h_lst[0] jp2c_lst = [idx for (idx, box) in...
[ "def", "_validate_jp2c", "(", "self", ",", "boxes", ")", ":", "# jp2c must be preceeded by jp2h", "jp2h_lst", "=", "[", "idx", "for", "(", "idx", ",", "box", ")", "in", "enumerate", "(", "boxes", ")", "if", "box", ".", "box_id", "==", "'jp2h'", "]", "jp2...
Validate the codestream box in relation to other boxes.
[ "Validate", "the", "codestream", "box", "in", "relation", "to", "other", "boxes", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1700-L1716
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_jp2h
def _validate_jp2h(self, boxes): """Validate the JP2 Header box.""" self._check_jp2h_child_boxes(boxes, 'top-level') jp2h_lst = [box for box in boxes if box.box_id == 'jp2h'] jp2h = jp2h_lst[0] # 1st jp2 header box cannot be empty. if len(jp2h.box) == 0: msg...
python
def _validate_jp2h(self, boxes): """Validate the JP2 Header box.""" self._check_jp2h_child_boxes(boxes, 'top-level') jp2h_lst = [box for box in boxes if box.box_id == 'jp2h'] jp2h = jp2h_lst[0] # 1st jp2 header box cannot be empty. if len(jp2h.box) == 0: msg...
[ "def", "_validate_jp2h", "(", "self", ",", "boxes", ")", ":", "self", ".", "_check_jp2h_child_boxes", "(", "boxes", ",", "'top-level'", ")", "jp2h_lst", "=", "[", "box", "for", "box", "in", "boxes", "if", "box", ".", "box_id", "==", "'jp2h'", "]", "jp2h"...
Validate the JP2 Header box.
[ "Validate", "the", "JP2", "Header", "box", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1718-L1744
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_channel_definition
def _validate_channel_definition(self, jp2h, colr): """Validate the channel definition box.""" cdef_lst = [j for (j, box) in enumerate(jp2h.box) if box.box_id == 'cdef'] if len(cdef_lst) > 1: msg = ("Only one channel definition box is allowed in the " ...
python
def _validate_channel_definition(self, jp2h, colr): """Validate the channel definition box.""" cdef_lst = [j for (j, box) in enumerate(jp2h.box) if box.box_id == 'cdef'] if len(cdef_lst) > 1: msg = ("Only one channel definition box is allowed in the " ...
[ "def", "_validate_channel_definition", "(", "self", ",", "jp2h", ",", "colr", ")", ":", "cdef_lst", "=", "[", "j", "for", "(", "j", ",", "box", ")", "in", "enumerate", "(", "jp2h", ".", "box", ")", "if", "box", ".", "box_id", "==", "'cdef'", "]", "...
Validate the channel definition box.
[ "Validate", "the", "channel", "definition", "box", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1746-L1766
quintusdias/glymur
glymur/jp2k.py
Jp2k._check_jp2h_child_boxes
def _check_jp2h_child_boxes(self, boxes, parent_box_name): """Certain boxes can only reside in the JP2 header.""" JP2H_CHILDREN = set(['bpcc', 'cdef', 'cmap', 'ihdr', 'pclr']) box_ids = set([box.box_id for box in boxes]) intersection = box_ids.intersection(JP2H_CHILDREN) if len(...
python
def _check_jp2h_child_boxes(self, boxes, parent_box_name): """Certain boxes can only reside in the JP2 header.""" JP2H_CHILDREN = set(['bpcc', 'cdef', 'cmap', 'ihdr', 'pclr']) box_ids = set([box.box_id for box in boxes]) intersection = box_ids.intersection(JP2H_CHILDREN) if len(...
[ "def", "_check_jp2h_child_boxes", "(", "self", ",", "boxes", ",", "parent_box_name", ")", ":", "JP2H_CHILDREN", "=", "set", "(", "[", "'bpcc'", ",", "'cdef'", ",", "'cmap'", ",", "'ihdr'", ",", "'pclr'", "]", ")", "box_ids", "=", "set", "(", "[", "box", ...
Certain boxes can only reside in the JP2 header.
[ "Certain", "boxes", "can", "only", "reside", "in", "the", "JP2", "header", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1768-L1781
quintusdias/glymur
glymur/jp2k.py
Jp2k._collect_box_count
def _collect_box_count(self, boxes): """Count the occurences of each box type.""" count = Counter([box.box_id for box in boxes]) # Add the counts in the superboxes. for box in boxes: if hasattr(box, 'box'): count.update(self._collect_box_count(box.box)) ...
python
def _collect_box_count(self, boxes): """Count the occurences of each box type.""" count = Counter([box.box_id for box in boxes]) # Add the counts in the superboxes. for box in boxes: if hasattr(box, 'box'): count.update(self._collect_box_count(box.box)) ...
[ "def", "_collect_box_count", "(", "self", ",", "boxes", ")", ":", "count", "=", "Counter", "(", "[", "box", ".", "box_id", "for", "box", "in", "boxes", "]", ")", "# Add the counts in the superboxes.", "for", "box", "in", "boxes", ":", "if", "hasattr", "(",...
Count the occurences of each box type.
[ "Count", "the", "occurences", "of", "each", "box", "type", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1783-L1792
quintusdias/glymur
glymur/jp2k.py
Jp2k._check_superbox_for_top_levels
def _check_superbox_for_top_levels(self, boxes): """Several boxes can only occur at the top level.""" # We are only looking at the boxes contained in a superbox, so if any # of the blacklisted boxes show up here, it's an error. TOP_LEVEL_ONLY_BOXES = set(['dtbl']) box_ids = set([...
python
def _check_superbox_for_top_levels(self, boxes): """Several boxes can only occur at the top level.""" # We are only looking at the boxes contained in a superbox, so if any # of the blacklisted boxes show up here, it's an error. TOP_LEVEL_ONLY_BOXES = set(['dtbl']) box_ids = set([...
[ "def", "_check_superbox_for_top_levels", "(", "self", ",", "boxes", ")", ":", "# We are only looking at the boxes contained in a superbox, so if any", "# of the blacklisted boxes show up here, it's an error.", "TOP_LEVEL_ONLY_BOXES", "=", "set", "(", "[", "'dtbl'", "]", ")", "box...
Several boxes can only occur at the top level.
[ "Several", "boxes", "can", "only", "occur", "at", "the", "top", "level", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1794-L1808
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_top_level
def _validate_top_level(self, boxes): """Several boxes can only occur at the top level.""" # Add the counts in the superboxes. for box in boxes: if hasattr(box, 'box'): self._check_superbox_for_top_levels(box.box) count = self._collect_box_count(boxes) ...
python
def _validate_top_level(self, boxes): """Several boxes can only occur at the top level.""" # Add the counts in the superboxes. for box in boxes: if hasattr(box, 'box'): self._check_superbox_for_top_levels(box.box) count = self._collect_box_count(boxes) ...
[ "def", "_validate_top_level", "(", "self", ",", "boxes", ")", ":", "# Add the counts in the superboxes.", "for", "box", "in", "boxes", ":", "if", "hasattr", "(", "box", ",", "'box'", ")", ":", "self", ".", "_check_superbox_for_top_levels", "(", "box", ".", "bo...
Several boxes can only occur at the top level.
[ "Several", "boxes", "can", "only", "occur", "at", "the", "top", "level", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1810-L1823
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_singletons
def _validate_singletons(self, boxes): """Several boxes can only occur once.""" count = self._collect_box_count(boxes) # Which boxes occur more than once? multiples = [box_id for box_id, bcount in count.items() if bcount > 1] if 'dtbl' in multiples: raise IOError('The...
python
def _validate_singletons(self, boxes): """Several boxes can only occur once.""" count = self._collect_box_count(boxes) # Which boxes occur more than once? multiples = [box_id for box_id, bcount in count.items() if bcount > 1] if 'dtbl' in multiples: raise IOError('The...
[ "def", "_validate_singletons", "(", "self", ",", "boxes", ")", ":", "count", "=", "self", ".", "_collect_box_count", "(", "boxes", ")", "# Which boxes occur more than once?", "multiples", "=", "[", "box_id", "for", "box_id", ",", "bcount", "in", "count", ".", ...
Several boxes can only occur once.
[ "Several", "boxes", "can", "only", "occur", "once", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1825-L1831
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_jpx_compatibility
def _validate_jpx_compatibility(self, boxes, compatibility_list): """ If there is a JPX box then the compatibility list must also contain 'jpx '. """ JPX_IDS = ['asoc', 'nlst'] jpx_cl = set(compatibility_list) for box in boxes: if box.box_id in JPX_IDS...
python
def _validate_jpx_compatibility(self, boxes, compatibility_list): """ If there is a JPX box then the compatibility list must also contain 'jpx '. """ JPX_IDS = ['asoc', 'nlst'] jpx_cl = set(compatibility_list) for box in boxes: if box.box_id in JPX_IDS...
[ "def", "_validate_jpx_compatibility", "(", "self", ",", "boxes", ",", "compatibility_list", ")", ":", "JPX_IDS", "=", "[", "'asoc'", ",", "'nlst'", "]", "jpx_cl", "=", "set", "(", "compatibility_list", ")", "for", "box", "in", "boxes", ":", "if", "box", "....
If there is a JPX box then the compatibility list must also contain 'jpx '.
[ "If", "there", "is", "a", "JPX", "box", "then", "the", "compatibility", "list", "must", "also", "contain", "jpx", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1833-L1848
quintusdias/glymur
glymur/jp2k.py
Jp2k._validate_label
def _validate_label(self, boxes): """ Label boxes can only be inside association, codestream headers, or compositing layer header boxes. """ for box in boxes: if box.box_id != 'asoc': if hasattr(box, 'box'): for boxi in box.box: ...
python
def _validate_label(self, boxes): """ Label boxes can only be inside association, codestream headers, or compositing layer header boxes. """ for box in boxes: if box.box_id != 'asoc': if hasattr(box, 'box'): for boxi in box.box: ...
[ "def", "_validate_label", "(", "self", ",", "boxes", ")", ":", "for", "box", "in", "boxes", ":", "if", "box", ".", "box_id", "!=", "'asoc'", ":", "if", "hasattr", "(", "box", ",", "'box'", ")", ":", "for", "boxi", "in", "box", ".", "box", ":", "i...
Label boxes can only be inside association, codestream headers, or compositing layer header boxes.
[ "Label", "boxes", "can", "only", "be", "inside", "association", "codestream", "headers", "or", "compositing", "layer", "header", "boxes", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L1850-L1865
keenlabs/KeenClient-Python
keen/api.py
KeenApi.fulfill
def fulfill(self, method, *args, **kwargs): """ Fulfill an HTTP request to Keen's API. """ return getattr(self.session, method)(*args, **kwargs)
python
def fulfill(self, method, *args, **kwargs): """ Fulfill an HTTP request to Keen's API. """ return getattr(self.session, method)(*args, **kwargs)
[ "def", "fulfill", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "getattr", "(", "self", ".", "session", ",", "method", ")", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
Fulfill an HTTP request to Keen's API.
[ "Fulfill", "an", "HTTP", "request", "to", "Keen", "s", "API", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L90-L94
keenlabs/KeenClient-Python
keen/api.py
KeenApi.post_event
def post_event(self, event): """ Posts a single event to the Keen IO API. The write key must be set first. :param event: an Event to upload """ url = "{0}/{1}/projects/{2}/events/{3}".format(self.base_url, self.api_version, ...
python
def post_event(self, event): """ Posts a single event to the Keen IO API. The write key must be set first. :param event: an Event to upload """ url = "{0}/{1}/projects/{2}/events/{3}".format(self.base_url, self.api_version, ...
[ "def", "post_event", "(", "self", ",", "event", ")", ":", "url", "=", "\"{0}/{1}/projects/{2}/events/{3}\"", ".", "format", "(", "self", ".", "base_url", ",", "self", ".", "api_version", ",", "self", ".", "project_id", ",", "event", ".", "event_collection", ...
Posts a single event to the Keen IO API. The write key must be set first. :param event: an Event to upload
[ "Posts", "a", "single", "event", "to", "the", "Keen", "IO", "API", ".", "The", "write", "key", "must", "be", "set", "first", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L97-L110
keenlabs/KeenClient-Python
keen/api.py
KeenApi.post_events
def post_events(self, events): """ Posts a single event to the Keen IO API. The write key must be set first. :param events: an Event to upload """ url = "{0}/{1}/projects/{2}/events".format(self.base_url, self.api_version, sel...
python
def post_events(self, events): """ Posts a single event to the Keen IO API. The write key must be set first. :param events: an Event to upload """ url = "{0}/{1}/projects/{2}/events".format(self.base_url, self.api_version, sel...
[ "def", "post_events", "(", "self", ",", "events", ")", ":", "url", "=", "\"{0}/{1}/projects/{2}/events\"", ".", "format", "(", "self", ".", "base_url", ",", "self", ".", "api_version", ",", "self", ".", "project_id", ")", "headers", "=", "utilities", ".", ...
Posts a single event to the Keen IO API. The write key must be set first. :param events: an Event to upload
[ "Posts", "a", "single", "event", "to", "the", "Keen", "IO", "API", ".", "The", "write", "key", "must", "be", "set", "first", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L113-L127
keenlabs/KeenClient-Python
keen/api.py
KeenApi._order_by_is_valid_or_none
def _order_by_is_valid_or_none(self, params): """ Validates that a given order_by has proper syntax. :param params: Query params. :return: Returns True if either no order_by is present, or if the order_by is well-formed. """ if not "order_by" in params or not params["ord...
python
def _order_by_is_valid_or_none(self, params): """ Validates that a given order_by has proper syntax. :param params: Query params. :return: Returns True if either no order_by is present, or if the order_by is well-formed. """ if not "order_by" in params or not params["ord...
[ "def", "_order_by_is_valid_or_none", "(", "self", ",", "params", ")", ":", "if", "not", "\"order_by\"", "in", "params", "or", "not", "params", "[", "\"order_by\"", "]", ":", "return", "True", "def", "_order_by_dict_is_not_well_formed", "(", "d", ")", ":", "if"...
Validates that a given order_by has proper syntax. :param params: Query params. :return: Returns True if either no order_by is present, or if the order_by is well-formed.
[ "Validates", "that", "a", "given", "order_by", "has", "proper", "syntax", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L130-L166
keenlabs/KeenClient-Python
keen/api.py
KeenApi._limit_is_valid_or_none
def _limit_is_valid_or_none(self, params): """ Validates that a given limit is not present or is well-formed. :param params: Query params. :return: Returns True if a limit is present or is well-formed. """ if not "limit" in params or not params["limit"]: retu...
python
def _limit_is_valid_or_none(self, params): """ Validates that a given limit is not present or is well-formed. :param params: Query params. :return: Returns True if a limit is present or is well-formed. """ if not "limit" in params or not params["limit"]: retu...
[ "def", "_limit_is_valid_or_none", "(", "self", ",", "params", ")", ":", "if", "not", "\"limit\"", "in", "params", "or", "not", "params", "[", "\"limit\"", "]", ":", "return", "True", "if", "not", "isinstance", "(", "params", "[", "\"limit\"", "]", ",", "...
Validates that a given limit is not present or is well-formed. :param params: Query params. :return: Returns True if a limit is present or is well-formed.
[ "Validates", "that", "a", "given", "limit", "is", "not", "present", "or", "is", "well", "-", "formed", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L168-L181
keenlabs/KeenClient-Python
keen/api.py
KeenApi.query
def query(self, analysis_type, params, all_keys=False): """ Performs a query using the Keen IO analysis API. A read key must be set first. """ if not self._order_by_is_valid_or_none(params): raise ValueError("order_by given is invalid or is missing required group_by.") ...
python
def query(self, analysis_type, params, all_keys=False): """ Performs a query using the Keen IO analysis API. A read key must be set first. """ if not self._order_by_is_valid_or_none(params): raise ValueError("order_by given is invalid or is missing required group_by.") ...
[ "def", "query", "(", "self", ",", "analysis_type", ",", "params", ",", "all_keys", "=", "False", ")", ":", "if", "not", "self", ".", "_order_by_is_valid_or_none", "(", "params", ")", ":", "raise", "ValueError", "(", "\"order_by given is invalid or is missing requi...
Performs a query using the Keen IO analysis API. A read key must be set first.
[ "Performs", "a", "query", "using", "the", "Keen", "IO", "analysis", "API", ".", "A", "read", "key", "must", "be", "set", "first", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L184-L207
keenlabs/KeenClient-Python
keen/api.py
KeenApi.delete_events
def delete_events(self, event_collection, params): """ Deletes events via the Keen IO API. A master key must be set first. :param event_collection: string, the event collection from which event are being deleted """ url = "{0}/{1}/projects/{2}/events/{3}".format(self.base_url,...
python
def delete_events(self, event_collection, params): """ Deletes events via the Keen IO API. A master key must be set first. :param event_collection: string, the event collection from which event are being deleted """ url = "{0}/{1}/projects/{2}/events/{3}".format(self.base_url,...
[ "def", "delete_events", "(", "self", ",", "event_collection", ",", "params", ")", ":", "url", "=", "\"{0}/{1}/projects/{2}/events/{3}\"", ".", "format", "(", "self", ".", "base_url", ",", "self", ".", "api_version", ",", "self", ".", "project_id", ",", "event_...
Deletes events via the Keen IO API. A master key must be set first. :param event_collection: string, the event collection from which event are being deleted
[ "Deletes", "events", "via", "the", "Keen", "IO", "API", ".", "A", "master", "key", "must", "be", "set", "first", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L210-L226
keenlabs/KeenClient-Python
keen/api.py
KeenApi.get_collection
def get_collection(self, event_collection): """ Extracts info about a collection using the Keen IO API. A master key must be set first. :param event_collection: the name of the collection to retrieve info for """ url = "{0}/{1}/projects/{2}/events/{3}".format(self.base_url, sel...
python
def get_collection(self, event_collection): """ Extracts info about a collection using the Keen IO API. A master key must be set first. :param event_collection: the name of the collection to retrieve info for """ url = "{0}/{1}/projects/{2}/events/{3}".format(self.base_url, sel...
[ "def", "get_collection", "(", "self", ",", "event_collection", ")", ":", "url", "=", "\"{0}/{1}/projects/{2}/events/{3}\"", ".", "format", "(", "self", ".", "base_url", ",", "self", ".", "api_version", ",", "self", ".", "project_id", ",", "event_collection", ")"...
Extracts info about a collection using the Keen IO API. A master key must be set first. :param event_collection: the name of the collection to retrieve info for
[ "Extracts", "info", "about", "a", "collection", "using", "the", "Keen", "IO", "API", ".", "A", "master", "key", "must", "be", "set", "first", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L229-L242
keenlabs/KeenClient-Python
keen/api.py
KeenApi._update_access_key_pair
def _update_access_key_pair(self, access_key_id, key, val): """ Helper for updating access keys in a DRY fashion. """ # Get current state via HTTPS. current_access_key = self.get_access_key(access_key_id) # Copy and only change the single parameter. payload_dict ...
python
def _update_access_key_pair(self, access_key_id, key, val): """ Helper for updating access keys in a DRY fashion. """ # Get current state via HTTPS. current_access_key = self.get_access_key(access_key_id) # Copy and only change the single parameter. payload_dict ...
[ "def", "_update_access_key_pair", "(", "self", ",", "access_key_id", ",", "key", ",", "val", ")", ":", "# Get current state via HTTPS.", "current_access_key", "=", "self", ".", "get_access_key", "(", "access_key_id", ")", "# Copy and only change the single parameter.", "p...
Helper for updating access keys in a DRY fashion.
[ "Helper", "for", "updating", "access", "keys", "in", "a", "DRY", "fashion", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L328-L340
keenlabs/KeenClient-Python
keen/api.py
KeenApi.add_access_key_permissions
def add_access_key_permissions(self, access_key_id, permissions): """ Adds to the existing list of permissions on this key with the contents of this list. Will not remove any existing permissions or modify the remainder of the key. :param access_key_id: the 'key' value of the access key...
python
def add_access_key_permissions(self, access_key_id, permissions): """ Adds to the existing list of permissions on this key with the contents of this list. Will not remove any existing permissions or modify the remainder of the key. :param access_key_id: the 'key' value of the access key...
[ "def", "add_access_key_permissions", "(", "self", ",", "access_key_id", ",", "permissions", ")", ":", "# Get current state via HTTPS.", "current_access_key", "=", "self", ".", "get_access_key", "(", "access_key_id", ")", "# Copy and only change the single parameter.", "payloa...
Adds to the existing list of permissions on this key with the contents of this list. Will not remove any existing permissions or modify the remainder of the key. :param access_key_id: the 'key' value of the access key to add permissions to :param permissions: the new permissions to add to the e...
[ "Adds", "to", "the", "existing", "list", "of", "permissions", "on", "this", "key", "with", "the", "contents", "of", "this", "list", ".", "Will", "not", "remove", "any", "existing", "permissions", "or", "modify", "the", "remainder", "of", "the", "key", "." ...
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L353-L374
keenlabs/KeenClient-Python
keen/api.py
KeenApi.remove_access_key_permissions
def remove_access_key_permissions(self, access_key_id, permissions): """ Removes a list of permissions from the existing list of permissions. Will not remove all existing permissions unless all such permissions are included in this list. Not to be confused with key revocation. S...
python
def remove_access_key_permissions(self, access_key_id, permissions): """ Removes a list of permissions from the existing list of permissions. Will not remove all existing permissions unless all such permissions are included in this list. Not to be confused with key revocation. S...
[ "def", "remove_access_key_permissions", "(", "self", ",", "access_key_id", ",", "permissions", ")", ":", "# Get current state via HTTPS.", "current_access_key", "=", "self", ".", "get_access_key", "(", "access_key_id", ")", "# Copy and only change the single parameter.", "pay...
Removes a list of permissions from the existing list of permissions. Will not remove all existing permissions unless all such permissions are included in this list. Not to be confused with key revocation. See also: revoke_access_key() :param access_key_id: the 'key' value of the access...
[ "Removes", "a", "list", "of", "permissions", "from", "the", "existing", "list", "of", "permissions", ".", "Will", "not", "remove", "all", "existing", "permissions", "unless", "all", "such", "permissions", "are", "included", "in", "this", "list", ".", "Not", ...
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L377-L401
keenlabs/KeenClient-Python
keen/api.py
KeenApi.update_access_key_full
def update_access_key_full(self, access_key_id, name, is_active, permitted, options): """ Replaces the 'name', 'is_active', 'permitted', and 'options' values of a given key. A master key must be set first. :param access_key_id: the 'key' value of the access key for which the values will...
python
def update_access_key_full(self, access_key_id, name, is_active, permitted, options): """ Replaces the 'name', 'is_active', 'permitted', and 'options' values of a given key. A master key must be set first. :param access_key_id: the 'key' value of the access key for which the values will...
[ "def", "update_access_key_full", "(", "self", ",", "access_key_id", ",", "name", ",", "is_active", ",", "permitted", ",", "options", ")", ":", "url", "=", "\"{0}/{1}/projects/{2}/keys/{3}\"", ".", "format", "(", "self", ".", "base_url", ",", "self", ".", "api_...
Replaces the 'name', 'is_active', 'permitted', and 'options' values of a given key. A master key must be set first. :param access_key_id: the 'key' value of the access key for which the values will be replaced :param name: the new name desired for this access key :param is_active: wheth...
[ "Replaces", "the", "name", "is_active", "permitted", "and", "options", "values", "of", "a", "given", "key", ".", "A", "master", "key", "must", "be", "set", "first", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L429-L452
keenlabs/KeenClient-Python
keen/api.py
KeenApi._error_handling
def _error_handling(self, res): """ Helper function to do the error handling :params res: the response from a request """ # making the error handling generic so if an status_code starting with 2 doesn't exist, we raise the error if res.status_code // 100 != 2: ...
python
def _error_handling(self, res): """ Helper function to do the error handling :params res: the response from a request """ # making the error handling generic so if an status_code starting with 2 doesn't exist, we raise the error if res.status_code // 100 != 2: ...
[ "def", "_error_handling", "(", "self", ",", "res", ")", ":", "# making the error handling generic so if an status_code starting with 2 doesn't exist, we raise the error", "if", "res", ".", "status_code", "//", "100", "!=", "2", ":", "error", "=", "self", ".", "_get_respon...
Helper function to do the error handling :params res: the response from a request
[ "Helper", "function", "to", "do", "the", "error", "handling" ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L484-L494
keenlabs/KeenClient-Python
keen/api.py
KeenApi._get_response_json
def _get_response_json(self, res): """ Helper function to extract the JSON body out of a response OR throw an exception. :param res: the response from a request :return: the JSON body OR throws an exception """ try: error = res.json() except ValueErr...
python
def _get_response_json(self, res): """ Helper function to extract the JSON body out of a response OR throw an exception. :param res: the response from a request :return: the JSON body OR throws an exception """ try: error = res.json() except ValueErr...
[ "def", "_get_response_json", "(", "self", ",", "res", ")", ":", "try", ":", "error", "=", "res", ".", "json", "(", ")", "except", "ValueError", ":", "error", "=", "{", "\"message\"", ":", "\"The API did not respond with JSON, but: {0}\"", ".", "format", "(", ...
Helper function to extract the JSON body out of a response OR throw an exception. :param res: the response from a request :return: the JSON body OR throws an exception
[ "Helper", "function", "to", "extract", "the", "JSON", "body", "out", "of", "a", "response", "OR", "throw", "an", "exception", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/api.py#L496-L511
keenlabs/KeenClient-Python
keen/cached_datasets.py
CachedDatasetsInterface.all
def all(self): """ Fetch all Cached Datasets for a Project. Read key must be set. """ return self._get_json(HTTPMethods.GET, self._cached_datasets_url, self._get_master_key())
python
def all(self): """ Fetch all Cached Datasets for a Project. Read key must be set. """ return self._get_json(HTTPMethods.GET, self._cached_datasets_url, self._get_master_key())
[ "def", "all", "(", "self", ")", ":", "return", "self", ".", "_get_json", "(", "HTTPMethods", ".", "GET", ",", "self", ".", "_cached_datasets_url", ",", "self", ".", "_get_master_key", "(", ")", ")" ]
Fetch all Cached Datasets for a Project. Read key must be set.
[ "Fetch", "all", "Cached", "Datasets", "for", "a", "Project", ".", "Read", "key", "must", "be", "set", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/cached_datasets.py#L16-L21
keenlabs/KeenClient-Python
keen/cached_datasets.py
CachedDatasetsInterface.get
def get(self, dataset_name): """ Fetch a single Cached Dataset for a Project. Read key must be set. :param dataset_name: Name of Cached Dataset (not `display_name`) """ url = "{0}/{1}".format(self._cached_datasets_url, dataset_name) return self._get_json(HTTPMethods.GET, url, se...
python
def get(self, dataset_name): """ Fetch a single Cached Dataset for a Project. Read key must be set. :param dataset_name: Name of Cached Dataset (not `display_name`) """ url = "{0}/{1}".format(self._cached_datasets_url, dataset_name) return self._get_json(HTTPMethods.GET, url, se...
[ "def", "get", "(", "self", ",", "dataset_name", ")", ":", "url", "=", "\"{0}/{1}\"", ".", "format", "(", "self", ".", "_cached_datasets_url", ",", "dataset_name", ")", "return", "self", ".", "_get_json", "(", "HTTPMethods", ".", "GET", ",", "url", ",", "...
Fetch a single Cached Dataset for a Project. Read key must be set. :param dataset_name: Name of Cached Dataset (not `display_name`)
[ "Fetch", "a", "single", "Cached", "Dataset", "for", "a", "Project", ".", "Read", "key", "must", "be", "set", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/cached_datasets.py#L24-L30
keenlabs/KeenClient-Python
keen/cached_datasets.py
CachedDatasetsInterface.create
def create(self, dataset_name, query, index_by, display_name): """ Create a Cached Dataset for a Project. Master key must be set. """ url = "{0}/{1}".format(self._cached_datasets_url, dataset_name) payload = { "query": query, "index_by": index_by, "dis...
python
def create(self, dataset_name, query, index_by, display_name): """ Create a Cached Dataset for a Project. Master key must be set. """ url = "{0}/{1}".format(self._cached_datasets_url, dataset_name) payload = { "query": query, "index_by": index_by, "dis...
[ "def", "create", "(", "self", ",", "dataset_name", ",", "query", ",", "index_by", ",", "display_name", ")", ":", "url", "=", "\"{0}/{1}\"", ".", "format", "(", "self", ".", "_cached_datasets_url", ",", "dataset_name", ")", "payload", "=", "{", "\"query\"", ...
Create a Cached Dataset for a Project. Master key must be set.
[ "Create", "a", "Cached", "Dataset", "for", "a", "Project", ".", "Master", "key", "must", "be", "set", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/cached_datasets.py#L33-L42
keenlabs/KeenClient-Python
keen/cached_datasets.py
CachedDatasetsInterface.results
def results(self, dataset_name, index_by, timeframe): """ Retrieve results from a Cached Dataset. Read key must be set. """ url = "{0}/{1}/results".format(self._cached_datasets_url, dataset_name) index_by = index_by if isinstance(index_by, str) else json.dumps(index_by) timefram...
python
def results(self, dataset_name, index_by, timeframe): """ Retrieve results from a Cached Dataset. Read key must be set. """ url = "{0}/{1}/results".format(self._cached_datasets_url, dataset_name) index_by = index_by if isinstance(index_by, str) else json.dumps(index_by) timefram...
[ "def", "results", "(", "self", ",", "dataset_name", ",", "index_by", ",", "timeframe", ")", ":", "url", "=", "\"{0}/{1}/results\"", ".", "format", "(", "self", ".", "_cached_datasets_url", ",", "dataset_name", ")", "index_by", "=", "index_by", "if", "isinstanc...
Retrieve results from a Cached Dataset. Read key must be set.
[ "Retrieve", "results", "from", "a", "Cached", "Dataset", ".", "Read", "key", "must", "be", "set", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/cached_datasets.py#L45-L60
keenlabs/KeenClient-Python
keen/cached_datasets.py
CachedDatasetsInterface.delete
def delete(self, dataset_name): """ Delete a Cached Dataset. Master Key must be set. """ url = "{0}/{1}".format(self._cached_datasets_url, dataset_name) self._get_json(HTTPMethods.DELETE, url, self._get_master_key()) return True
python
def delete(self, dataset_name): """ Delete a Cached Dataset. Master Key must be set. """ url = "{0}/{1}".format(self._cached_datasets_url, dataset_name) self._get_json(HTTPMethods.DELETE, url, self._get_master_key()) return True
[ "def", "delete", "(", "self", ",", "dataset_name", ")", ":", "url", "=", "\"{0}/{1}\"", ".", "format", "(", "self", ".", "_cached_datasets_url", ",", "dataset_name", ")", "self", ".", "_get_json", "(", "HTTPMethods", ".", "DELETE", ",", "url", ",", "self",...
Delete a Cached Dataset. Master Key must be set.
[ "Delete", "a", "Cached", "Dataset", ".", "Master", "Key", "must", "be", "set", "." ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/cached_datasets.py#L63-L68
keenlabs/KeenClient-Python
keen/utilities.py
switch.match
def match(self, *args): """Whether or not to enter a given case statement""" self.fall = self.fall or not args self.fall = self.fall or (self.value in args) return self.fall
python
def match(self, *args): """Whether or not to enter a given case statement""" self.fall = self.fall or not args self.fall = self.fall or (self.value in args) return self.fall
[ "def", "match", "(", "self", ",", "*", "args", ")", ":", "self", ".", "fall", "=", "self", ".", "fall", "or", "not", "args", "self", ".", "fall", "=", "self", ".", "fall", "or", "(", "self", ".", "value", "in", "args", ")", "return", "self", "....
Whether or not to enter a given case statement
[ "Whether", "or", "not", "to", "enter", "a", "given", "case", "statement" ]
train
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/utilities.py#L50-L56
quintusdias/glymur
glymur/config.py
glymurrc_fname
def glymurrc_fname(): """Return the path to the configuration file. Search order: 1) current working directory 2) environ var XDG_CONFIG_HOME 3) $HOME/.config/glymur/glymurrc """ # Current directory. fname = os.path.join(os.getcwd(), 'glymurrc') if os.path.exists(fname)...
python
def glymurrc_fname(): """Return the path to the configuration file. Search order: 1) current working directory 2) environ var XDG_CONFIG_HOME 3) $HOME/.config/glymur/glymurrc """ # Current directory. fname = os.path.join(os.getcwd(), 'glymurrc') if os.path.exists(fname)...
[ "def", "glymurrc_fname", "(", ")", ":", "# Current directory.", "fname", "=", "os", ".", "path", ".", "join", "(", "os", ".", "getcwd", "(", ")", ",", "'glymurrc'", ")", "if", "os", ".", "path", ".", "exists", "(", "fname", ")", ":", "return", "fname...
Return the path to the configuration file. Search order: 1) current working directory 2) environ var XDG_CONFIG_HOME 3) $HOME/.config/glymur/glymurrc
[ "Return", "the", "path", "to", "the", "configuration", "file", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/config.py#L24-L45
quintusdias/glymur
glymur/config.py
load_library_handle
def load_library_handle(libname, path): """Load the library, return the ctypes handle.""" if path is None or path in ['None', 'none']: # Either could not find a library via ctypes or # user-configuration-file, or we could not find it in any of the # default locations, or possibly the us...
python
def load_library_handle(libname, path): """Load the library, return the ctypes handle.""" if path is None or path in ['None', 'none']: # Either could not find a library via ctypes or # user-configuration-file, or we could not find it in any of the # default locations, or possibly the us...
[ "def", "load_library_handle", "(", "libname", ",", "path", ")", ":", "if", "path", "is", "None", "or", "path", "in", "[", "'None'", ",", "'none'", "]", ":", "# Either could not find a library via ctypes or", "# user-configuration-file, or we could not find it in any of th...
Load the library, return the ctypes handle.
[ "Load", "the", "library", "return", "the", "ctypes", "handle", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/config.py#L86-L107
quintusdias/glymur
glymur/config.py
read_config_file
def read_config_file(libname): """ Extract library locations from a configuration file. Parameters ---------- libname : str One of either 'openjp2' or 'openjpeg' Returns ------- path : None or str None if no location is specified, otherwise a path to the library """...
python
def read_config_file(libname): """ Extract library locations from a configuration file. Parameters ---------- libname : str One of either 'openjp2' or 'openjpeg' Returns ------- path : None or str None if no location is specified, otherwise a path to the library """...
[ "def", "read_config_file", "(", "libname", ")", ":", "filename", "=", "glymurrc_fname", "(", ")", "if", "filename", "is", "None", ":", "# There's no library file path to return in this case.", "return", "None", "# Read the configuration file for the library location.", "parse...
Extract library locations from a configuration file. Parameters ---------- libname : str One of either 'openjp2' or 'openjpeg' Returns ------- path : None or str None if no location is specified, otherwise a path to the library
[ "Extract", "library", "locations", "from", "a", "configuration", "file", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/config.py#L110-L136
quintusdias/glymur
glymur/config.py
glymur_config
def glymur_config(): """ Try to ascertain locations of openjp2, openjpeg libraries. Returns ------- tuple tuple of library handles """ handles = (load_openjpeg_library(x) for x in ['openjp2', 'openjpeg']) handles = tuple(handles) if all(handle is None for handle in handles)...
python
def glymur_config(): """ Try to ascertain locations of openjp2, openjpeg libraries. Returns ------- tuple tuple of library handles """ handles = (load_openjpeg_library(x) for x in ['openjp2', 'openjpeg']) handles = tuple(handles) if all(handle is None for handle in handles)...
[ "def", "glymur_config", "(", ")", ":", "handles", "=", "(", "load_openjpeg_library", "(", "x", ")", "for", "x", "in", "[", "'openjp2'", ",", "'openjpeg'", "]", ")", "handles", "=", "tuple", "(", "handles", ")", "if", "all", "(", "handle", "is", "None",...
Try to ascertain locations of openjp2, openjpeg libraries. Returns ------- tuple tuple of library handles
[ "Try", "to", "ascertain", "locations", "of", "openjp2", "openjpeg", "libraries", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/config.py#L139-L154
quintusdias/glymur
glymur/config.py
get_configdir
def get_configdir(): """Return string representing the configuration directory. Default is $HOME/.config/glymur. You can override this with the XDG_CONFIG_HOME environment variable. """ if 'XDG_CONFIG_HOME' in os.environ: return os.path.join(os.environ['XDG_CONFIG_HOME'], 'glymur') if...
python
def get_configdir(): """Return string representing the configuration directory. Default is $HOME/.config/glymur. You can override this with the XDG_CONFIG_HOME environment variable. """ if 'XDG_CONFIG_HOME' in os.environ: return os.path.join(os.environ['XDG_CONFIG_HOME'], 'glymur') if...
[ "def", "get_configdir", "(", ")", ":", "if", "'XDG_CONFIG_HOME'", "in", "os", ".", "environ", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'XDG_CONFIG_HOME'", "]", ",", "'glymur'", ")", "if", "'HOME'", "in", "os", "."...
Return string representing the configuration directory. Default is $HOME/.config/glymur. You can override this with the XDG_CONFIG_HOME environment variable.
[ "Return", "string", "representing", "the", "configuration", "directory", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/config.py#L157-L172
quintusdias/glymur
glymur/config.py
set_option
def set_option(key, value): """Set the value of the specified option. Available options: parse.full_codestream print.xml print.codestream print.short Parameters ---------- key : str Name of a single option. value : New value of option. Opti...
python
def set_option(key, value): """Set the value of the specified option. Available options: parse.full_codestream print.xml print.codestream print.short Parameters ---------- key : str Name of a single option. value : New value of option. Opti...
[ "def", "set_option", "(", "key", ",", "value", ")", ":", "if", "key", "not", "in", "_options", ".", "keys", "(", ")", ":", "raise", "KeyError", "(", "'{key} not valid.'", ".", "format", "(", "key", "=", "key", ")", ")", "_options", "[", "key", "]", ...
Set the value of the specified option. Available options: parse.full_codestream print.xml print.codestream print.short Parameters ---------- key : str Name of a single option. value : New value of option. Option Descriptions ---------------...
[ "Set", "the", "value", "of", "the", "specified", "option", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/config.py#L184-L225
quintusdias/glymur
glymur/config.py
reset_option
def reset_option(key): """ Reset one or more options to their default value. Pass "all" as argument to reset all options. Available options: parse.full_codestream print.xml print.codestream print.short Parameter --------- key : str Name of a single...
python
def reset_option(key): """ Reset one or more options to their default value. Pass "all" as argument to reset all options. Available options: parse.full_codestream print.xml print.codestream print.short Parameter --------- key : str Name of a single...
[ "def", "reset_option", "(", "key", ")", ":", "global", "_options", "if", "key", "==", "'all'", ":", "_options", "=", "copy", ".", "deepcopy", "(", "_original_options", ")", "else", ":", "if", "key", "not", "in", "_options", ".", "keys", "(", ")", ":", ...
Reset one or more options to their default value. Pass "all" as argument to reset all options. Available options: parse.full_codestream print.xml print.codestream print.short Parameter --------- key : str Name of a single option.
[ "Reset", "one", "or", "more", "options", "to", "their", "default", "value", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/config.py#L254-L278
quintusdias/glymur
glymur/config.py
set_printoptions
def set_printoptions(**kwargs): """Set printing options. These options determine the way JPEG 2000 boxes are displayed. Parameters ---------- short : bool, optional When True, only the box ID, offset, and length are displayed. Useful for displaying only the basic structure or skel...
python
def set_printoptions(**kwargs): """Set printing options. These options determine the way JPEG 2000 boxes are displayed. Parameters ---------- short : bool, optional When True, only the box ID, offset, and length are displayed. Useful for displaying only the basic structure or skel...
[ "def", "set_printoptions", "(", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn", "(", "'Use set_option instead of set_printoptions.'", ",", "DeprecationWarning", ")", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "if", "key", ...
Set printing options. These options determine the way JPEG 2000 boxes are displayed. Parameters ---------- short : bool, optional When True, only the box ID, offset, and length are displayed. Useful for displaying only the basic structure or skeleton of a JPEG 2000 file. x...
[ "Set", "printing", "options", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/config.py#L330-L364
quintusdias/glymur
glymur/config.py
get_printoptions
def get_printoptions(): """Return the current print options. Returns ------- dict Dictionary of current print options with keys - short : bool - xml : bool - codestream : bool For a full description of these options, see `set_printoptions`. See also ...
python
def get_printoptions(): """Return the current print options. Returns ------- dict Dictionary of current print options with keys - short : bool - xml : bool - codestream : bool For a full description of these options, see `set_printoptions`. See also ...
[ "def", "get_printoptions", "(", ")", ":", "warnings", ".", "warn", "(", "'Use get_option instead of get_printoptions.'", ",", "DeprecationWarning", ")", "d", "=", "{", "}", "for", "key", "in", "[", "'short'", ",", "'xml'", ",", "'codestream'", "]", ":", "d", ...
Return the current print options. Returns ------- dict Dictionary of current print options with keys - short : bool - xml : bool - codestream : bool For a full description of these options, see `set_printoptions`. See also -------- set_printoptio...
[ "Return", "the", "current", "print", "options", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/config.py#L367-L390
quintusdias/glymur
glymur/command_line.py
main
def main(): """ Entry point for console script jp2dump. """ kwargs = {'description': 'Print JPEG2000 metadata.', 'formatter_class': argparse.ArgumentDefaultsHelpFormatter} parser = argparse.ArgumentParser(**kwargs) parser.add_argument('-x', '--noxml', help...
python
def main(): """ Entry point for console script jp2dump. """ kwargs = {'description': 'Print JPEG2000 metadata.', 'formatter_class': argparse.ArgumentDefaultsHelpFormatter} parser = argparse.ArgumentParser(**kwargs) parser.add_argument('-x', '--noxml', help...
[ "def", "main", "(", ")", ":", "kwargs", "=", "{", "'description'", ":", "'Print JPEG2000 metadata.'", ",", "'formatter_class'", ":", "argparse", ".", "ArgumentDefaultsHelpFormatter", "}", "parser", "=", "argparse", ".", "ArgumentParser", "(", "*", "*", "kwargs", ...
Entry point for console script jp2dump.
[ "Entry", "point", "for", "console", "script", "jp2dump", "." ]
train
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/command_line.py#L13-L80
Nike-Inc/cerberus-python-client
cerberus/client.py
CerberusClient._add_slash
def _add_slash(self, string=None): """ if a string doesn't end in a '/' add one """ if(not str.endswith(string, '/')): return str.join('', [string, '/']) return str(string)
python
def _add_slash(self, string=None): """ if a string doesn't end in a '/' add one """ if(not str.endswith(string, '/')): return str.join('', [string, '/']) return str(string)
[ "def", "_add_slash", "(", "self", ",", "string", "=", "None", ")", ":", "if", "(", "not", "str", ".", "endswith", "(", "string", ",", "'/'", ")", ")", ":", "return", "str", ".", "join", "(", "''", ",", "[", "string", ",", "'/'", "]", ")", "retu...
if a string doesn't end in a '/' add one
[ "if", "a", "string", "doesn", "t", "end", "in", "a", "/", "add", "one" ]
train
https://github.com/Nike-Inc/cerberus-python-client/blob/ef38356822e722fcb6a6ed4a1b38a5b493e753ae/cerberus/client.py#L68-L72
Nike-Inc/cerberus-python-client
cerberus/client.py
CerberusClient._set_token
def _set_token(self): """Set the Cerberus token based on auth type""" try: self.token = os.environ['CERBERUS_TOKEN'] if self.verbose: print("Overriding Cerberus token with environment variable.", file=sys.stderr) logger.info("Overriding Cerberus token ...
python
def _set_token(self): """Set the Cerberus token based on auth type""" try: self.token = os.environ['CERBERUS_TOKEN'] if self.verbose: print("Overriding Cerberus token with environment variable.", file=sys.stderr) logger.info("Overriding Cerberus token ...
[ "def", "_set_token", "(", "self", ")", ":", "try", ":", "self", ".", "token", "=", "os", ".", "environ", "[", "'CERBERUS_TOKEN'", "]", "if", "self", ".", "verbose", ":", "print", "(", "\"Overriding Cerberus token with environment variable.\"", ",", "file", "="...
Set the Cerberus token based on auth type
[ "Set", "the", "Cerberus", "token", "based", "on", "auth", "type" ]
train
https://github.com/Nike-Inc/cerberus-python-client/blob/ef38356822e722fcb6a6ed4a1b38a5b493e753ae/cerberus/client.py#L74-L89
Nike-Inc/cerberus-python-client
cerberus/client.py
CerberusClient.get_roles
def get_roles(self): """Return all the roles (IAM or User Groups) that can be granted to a safe deposit box. Roles are permission levels that are granted to IAM or User Groups. Associating the id for the write role would allow that IAM or User Group to write in the safe deposit box.""" ...
python
def get_roles(self): """Return all the roles (IAM or User Groups) that can be granted to a safe deposit box. Roles are permission levels that are granted to IAM or User Groups. Associating the id for the write role would allow that IAM or User Group to write in the safe deposit box.""" ...
[ "def", "get_roles", "(", "self", ")", ":", "roles_resp", "=", "get_with_retry", "(", "self", ".", "cerberus_url", "+", "'/v1/role'", ",", "headers", "=", "self", ".", "HEADERS", ")", "throw_if_bad_response", "(", "roles_resp", ")", "return", "roles_resp", ".",...
Return all the roles (IAM or User Groups) that can be granted to a safe deposit box. Roles are permission levels that are granted to IAM or User Groups. Associating the id for the write role would allow that IAM or User Group to write in the safe deposit box.
[ "Return", "all", "the", "roles", "(", "IAM", "or", "User", "Groups", ")", "that", "can", "be", "granted", "to", "a", "safe", "deposit", "box", "." ]
train
https://github.com/Nike-Inc/cerberus-python-client/blob/ef38356822e722fcb6a6ed4a1b38a5b493e753ae/cerberus/client.py#L95-L104
Nike-Inc/cerberus-python-client
cerberus/client.py
CerberusClient.get_role
def get_role(self, key): """Return id of named role.""" json_resp = self.get_roles() for item in json_resp: if key in item["name"]: return item["id"] raise CerberusClientException("Key '%s' not found" % key)
python
def get_role(self, key): """Return id of named role.""" json_resp = self.get_roles() for item in json_resp: if key in item["name"]: return item["id"] raise CerberusClientException("Key '%s' not found" % key)
[ "def", "get_role", "(", "self", ",", "key", ")", ":", "json_resp", "=", "self", ".", "get_roles", "(", ")", "for", "item", "in", "json_resp", ":", "if", "key", "in", "item", "[", "\"name\"", "]", ":", "return", "item", "[", "\"id\"", "]", "raise", ...
Return id of named role.
[ "Return", "id", "of", "named", "role", "." ]
train
https://github.com/Nike-Inc/cerberus-python-client/blob/ef38356822e722fcb6a6ed4a1b38a5b493e753ae/cerberus/client.py#L106-L113