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
ontio/ontology-python-sdk
ontology/io/binary_reader.py
BinaryReader.read_var_str
def read_var_str(self, max_size=sys.maxsize): """ Similar to `ReadString` but expects a variable length indicator instead of the fixed 1 byte indicator. Args: max_size (int): (Optional) maximum number of bytes to read. Returns: bytes: """ length ...
python
def read_var_str(self, max_size=sys.maxsize): """ Similar to `ReadString` but expects a variable length indicator instead of the fixed 1 byte indicator. Args: max_size (int): (Optional) maximum number of bytes to read. Returns: bytes: """ length ...
[ "def", "read_var_str", "(", "self", ",", "max_size", "=", "sys", ".", "maxsize", ")", ":", "length", "=", "self", ".", "read_var_int", "(", "max_size", ")", "return", "self", ".", "unpack", "(", "str", "(", "length", ")", "+", "'s'", ",", "length", "...
Similar to `ReadString` but expects a variable length indicator instead of the fixed 1 byte indicator. Args: max_size (int): (Optional) maximum number of bytes to read. Returns: bytes:
[ "Similar", "to", "ReadString", "but", "expects", "a", "variable", "length", "indicator", "instead", "of", "the", "fixed", "1", "byte", "indicator", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L311-L322
ontio/ontology-python-sdk
ontology/io/binary_reader.py
BinaryReader.read_serializable_array
def read_serializable_array(self, class_name, max_size=sys.maxsize): """ Deserialize a stream into the object specific by `class_name`. Args: class_name (str): a full path to the class to be deserialized into. e.g. 'neo.Core.Block.Block' max_size (int): (Optional) maximu...
python
def read_serializable_array(self, class_name, max_size=sys.maxsize): """ Deserialize a stream into the object specific by `class_name`. Args: class_name (str): a full path to the class to be deserialized into. e.g. 'neo.Core.Block.Block' max_size (int): (Optional) maximu...
[ "def", "read_serializable_array", "(", "self", ",", "class_name", ",", "max_size", "=", "sys", ".", "maxsize", ")", ":", "module", "=", "'.'", ".", "join", "(", "class_name", ".", "split", "(", "'.'", ")", "[", ":", "-", "1", "]", ")", "class_name", ...
Deserialize a stream into the object specific by `class_name`. Args: class_name (str): a full path to the class to be deserialized into. e.g. 'neo.Core.Block.Block' max_size (int): (Optional) maximum number of bytes to read. Returns: list: list of `class_name` objec...
[ "Deserialize", "a", "stream", "into", "the", "object", "specific", "by", "class_name", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L335-L358
ontio/ontology-python-sdk
ontology/io/binary_reader.py
BinaryReader.read_2000256_list
def read_2000256_list(self): """ Read 2000 times a 64 byte value from the stream. Returns: list: a list containing 2000 64 byte values in reversed form. """ items = [] for _ in range(0, 2000): data = self.read_bytes(64) ba = bytearray(...
python
def read_2000256_list(self): """ Read 2000 times a 64 byte value from the stream. Returns: list: a list containing 2000 64 byte values in reversed form. """ items = [] for _ in range(0, 2000): data = self.read_bytes(64) ba = bytearray(...
[ "def", "read_2000256_list", "(", "self", ")", ":", "items", "=", "[", "]", "for", "_", "in", "range", "(", "0", ",", "2000", ")", ":", "data", "=", "self", ".", "read_bytes", "(", "64", ")", "ba", "=", "bytearray", "(", "binascii", ".", "unhexlify"...
Read 2000 times a 64 byte value from the stream. Returns: list: a list containing 2000 64 byte values in reversed form.
[ "Read", "2000", "times", "a", "64", "byte", "value", "from", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L360-L373
ontio/ontology-python-sdk
ontology/io/binary_reader.py
BinaryReader.read_hashes
def read_hashes(self): """ Read Hash values from the stream. Returns: list: a list of hash values. Each value is of the bytearray type. """ var_len = self.read_var_int() items = [] for _ in range(0, var_len): ba = bytearray(self.read_bytes...
python
def read_hashes(self): """ Read Hash values from the stream. Returns: list: a list of hash values. Each value is of the bytearray type. """ var_len = self.read_var_int() items = [] for _ in range(0, var_len): ba = bytearray(self.read_bytes...
[ "def", "read_hashes", "(", "self", ")", ":", "var_len", "=", "self", ".", "read_var_int", "(", ")", "items", "=", "[", "]", "for", "_", "in", "range", "(", "0", ",", "var_len", ")", ":", "ba", "=", "bytearray", "(", "self", ".", "read_bytes", "(", ...
Read Hash values from the stream. Returns: list: a list of hash values. Each value is of the bytearray type.
[ "Read", "Hash", "values", "from", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L375-L388
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_byte
def write_byte(self, value): """ Write a single byte to the stream. Args: value (bytes, str or int): value to write to the stream. """ if isinstance(value, bytes): self.stream.write(value) elif isinstance(value, str): self.stream.write...
python
def write_byte(self, value): """ Write a single byte to the stream. Args: value (bytes, str or int): value to write to the stream. """ if isinstance(value, bytes): self.stream.write(value) elif isinstance(value, str): self.stream.write...
[ "def", "write_byte", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "self", ".", "stream", ".", "write", "(", "value", ")", "elif", "isinstance", "(", "value", ",", "str", ")", ":", "self", ".", "stre...
Write a single byte to the stream. Args: value (bytes, str or int): value to write to the stream.
[ "Write", "a", "single", "byte", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L47-L59
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.pack
def pack(self, fmt, data): """ Write bytes by packing them according to the provided format `fmt`. For more information about the `fmt` format see: https://docs.python.org/3/library/struct.html Args: fmt (str): format string. data (object): the data to write to t...
python
def pack(self, fmt, data): """ Write bytes by packing them according to the provided format `fmt`. For more information about the `fmt` format see: https://docs.python.org/3/library/struct.html Args: fmt (str): format string. data (object): the data to write to t...
[ "def", "pack", "(", "self", ",", "fmt", ",", "data", ")", ":", "return", "self", ".", "write_bytes", "(", "struct", ".", "pack", "(", "fmt", ",", "data", ")", ")" ]
Write bytes by packing them according to the provided format `fmt`. For more information about the `fmt` format see: https://docs.python.org/3/library/struct.html Args: fmt (str): format string. data (object): the data to write to the raw stream. Returns: in...
[ "Write", "bytes", "by", "packing", "them", "according", "to", "the", "provided", "format", "fmt", ".", "For", "more", "information", "about", "the", "fmt", "format", "see", ":", "https", ":", "//", "docs", ".", "python", ".", "org", "/", "3", "/", "lib...
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L69-L81
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_float
def write_float(self, value, little_endian=True): """ Pack the value as a float and write 4 bytes to the stream. Args: value (number): the value to write to the stream. little_endian (bool): specify the endianness. (Default) Little endian. Returns: i...
python
def write_float(self, value, little_endian=True): """ Pack the value as a float and write 4 bytes to the stream. Args: value (number): the value to write to the stream. little_endian (bool): specify the endianness. (Default) Little endian. Returns: i...
[ "def", "write_float", "(", "self", ",", "value", ",", "little_endian", "=", "True", ")", ":", "if", "little_endian", ":", "endian", "=", "\"<\"", "else", ":", "endian", "=", "\">\"", "return", "self", ".", "pack", "(", "'%sf'", "%", "endian", ",", "val...
Pack the value as a float and write 4 bytes to the stream. Args: value (number): the value to write to the stream. little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written.
[ "Pack", "the", "value", "as", "a", "float", "and", "write", "4", "bytes", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L95-L110
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_double
def write_double(self, value, little_endian=True): """ Pack the value as a double and write 8 bytes to the stream. Args: value (number): the value to write to the stream. little_endian (bool): specify the endianness. (Default) Little endian. Returns: ...
python
def write_double(self, value, little_endian=True): """ Pack the value as a double and write 8 bytes to the stream. Args: value (number): the value to write to the stream. little_endian (bool): specify the endianness. (Default) Little endian. Returns: ...
[ "def", "write_double", "(", "self", ",", "value", ",", "little_endian", "=", "True", ")", ":", "if", "little_endian", ":", "endian", "=", "\"<\"", "else", ":", "endian", "=", "\">\"", "return", "self", ".", "pack", "(", "'%sd'", "%", "endian", ",", "va...
Pack the value as a double and write 8 bytes to the stream. Args: value (number): the value to write to the stream. little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written.
[ "Pack", "the", "value", "as", "a", "double", "and", "write", "8", "bytes", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L112-L127
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_int8
def write_int8(self, value, little_endian=True): """ Pack the value as a signed byte and write 1 byte to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written. ...
python
def write_int8(self, value, little_endian=True): """ Pack the value as a signed byte and write 1 byte to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written. ...
[ "def", "write_int8", "(", "self", ",", "value", ",", "little_endian", "=", "True", ")", ":", "if", "little_endian", ":", "endian", "=", "\"<\"", "else", ":", "endian", "=", "\">\"", "return", "self", ".", "pack", "(", "'%sb'", "%", "endian", ",", "valu...
Pack the value as a signed byte and write 1 byte to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written.
[ "Pack", "the", "value", "as", "a", "signed", "byte", "and", "write", "1", "byte", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L129-L144
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_uint8
def write_uint8(self, value, little_endian=True): """ Pack the value as an unsigned byte and write 1 byte to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written. ...
python
def write_uint8(self, value, little_endian=True): """ Pack the value as an unsigned byte and write 1 byte to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written. ...
[ "def", "write_uint8", "(", "self", ",", "value", ",", "little_endian", "=", "True", ")", ":", "if", "little_endian", ":", "endian", "=", "\"<\"", "else", ":", "endian", "=", "\">\"", "return", "self", ".", "pack", "(", "'%sB'", "%", "endian", ",", "val...
Pack the value as an unsigned byte and write 1 byte to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written.
[ "Pack", "the", "value", "as", "an", "unsigned", "byte", "and", "write", "1", "byte", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L146-L161
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_int16
def write_int16(self, value, little_endian=True): """ Pack the value as a signed integer and write 2 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written. ...
python
def write_int16(self, value, little_endian=True): """ Pack the value as a signed integer and write 2 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written. ...
[ "def", "write_int16", "(", "self", ",", "value", ",", "little_endian", "=", "True", ")", ":", "if", "little_endian", ":", "endian", "=", "\"<\"", "else", ":", "endian", "=", "\">\"", "return", "self", ".", "pack", "(", "'%sh'", "%", "endian", ",", "val...
Pack the value as a signed integer and write 2 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written.
[ "Pack", "the", "value", "as", "a", "signed", "integer", "and", "write", "2", "bytes", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L175-L190
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_uint16
def write_uint16(self, value, little_endian=True): """ Pack the value as an unsigned integer and write 2 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes writte...
python
def write_uint16(self, value, little_endian=True): """ Pack the value as an unsigned integer and write 2 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes writte...
[ "def", "write_uint16", "(", "self", ",", "value", ",", "little_endian", "=", "True", ")", ":", "if", "little_endian", ":", "endian", "=", "\"<\"", "else", ":", "endian", "=", "\">\"", "return", "self", ".", "pack", "(", "'%sH'", "%", "endian", ",", "va...
Pack the value as an unsigned integer and write 2 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written.
[ "Pack", "the", "value", "as", "an", "unsigned", "integer", "and", "write", "2", "bytes", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L192-L207
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_int32
def write_int32(self, value, little_endian=True): """ Pack the value as a signed integer and write 4 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written. ...
python
def write_int32(self, value, little_endian=True): """ Pack the value as a signed integer and write 4 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written. ...
[ "def", "write_int32", "(", "self", ",", "value", ",", "little_endian", "=", "True", ")", ":", "if", "little_endian", ":", "endian", "=", "\"<\"", "else", ":", "endian", "=", "\">\"", "return", "self", ".", "pack", "(", "'%si'", "%", "endian", ",", "val...
Pack the value as a signed integer and write 4 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written.
[ "Pack", "the", "value", "as", "a", "signed", "integer", "and", "write", "4", "bytes", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L209-L224
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_uint32
def write_uint32(self, value, little_endian=True): """ Pack the value as an unsigned integer and write 4 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes writte...
python
def write_uint32(self, value, little_endian=True): """ Pack the value as an unsigned integer and write 4 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes writte...
[ "def", "write_uint32", "(", "self", ",", "value", ",", "little_endian", "=", "True", ")", ":", "if", "little_endian", ":", "endian", "=", "\"<\"", "else", ":", "endian", "=", "\">\"", "return", "self", ".", "pack", "(", "'%sI'", "%", "endian", ",", "va...
Pack the value as an unsigned integer and write 4 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written.
[ "Pack", "the", "value", "as", "an", "unsigned", "integer", "and", "write", "4", "bytes", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L226-L241
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_int64
def write_int64(self, value, little_endian=True): """ Pack the value as a signed integer and write 8 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written. ...
python
def write_int64(self, value, little_endian=True): """ Pack the value as a signed integer and write 8 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written. ...
[ "def", "write_int64", "(", "self", ",", "value", ",", "little_endian", "=", "True", ")", ":", "if", "little_endian", ":", "endian", "=", "\"<\"", "else", ":", "endian", "=", "\">\"", "return", "self", ".", "pack", "(", "'%sq'", "%", "endian", ",", "val...
Pack the value as a signed integer and write 8 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written.
[ "Pack", "the", "value", "as", "a", "signed", "integer", "and", "write", "8", "bytes", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L243-L258
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_uint64
def write_uint64(self, value, little_endian=True): """ Pack the value as an unsigned integer and write 8 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes writte...
python
def write_uint64(self, value, little_endian=True): """ Pack the value as an unsigned integer and write 8 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes writte...
[ "def", "write_uint64", "(", "self", ",", "value", ",", "little_endian", "=", "True", ")", ":", "if", "little_endian", ":", "endian", "=", "\"<\"", "else", ":", "endian", "=", "\">\"", "return", "self", ".", "pack", "(", "'%sQ'", "%", "endian", ",", "va...
Pack the value as an unsigned integer and write 8 bytes to the stream. Args: value: little_endian (bool): specify the endianness. (Default) Little endian. Returns: int: the number of bytes written.
[ "Pack", "the", "value", "as", "an", "unsigned", "integer", "and", "write", "8", "bytes", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L260-L275
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_var_int
def write_var_int(self, value, little_endian=True): """ Write an integer value in a space saving way to the stream. Args: value (int): little_endian (bool): specify the endianness. (Default) Little endian. Raises: SDKException: if `value` is not of t...
python
def write_var_int(self, value, little_endian=True): """ Write an integer value in a space saving way to the stream. Args: value (int): little_endian (bool): specify the endianness. (Default) Little endian. Raises: SDKException: if `value` is not of t...
[ "def", "write_var_int", "(", "self", ",", "value", ",", "little_endian", "=", "True", ")", ":", "if", "not", "isinstance", "(", "value", ",", "int", ")", ":", "raise", "SDKException", "(", "ErrorCode", ".", "param_err", "(", "'%s not int type.'", "%", "val...
Write an integer value in a space saving way to the stream. Args: value (int): little_endian (bool): specify the endianness. (Default) Little endian. Raises: SDKException: if `value` is not of type int. SDKException: if `value` is < 0. Returns: ...
[ "Write", "an", "integer", "value", "in", "a", "space", "saving", "way", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L277-L311
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_var_bytes
def write_var_bytes(self, value, little_endian: bool = True): """ Write an integer value in a space saving way to the stream. :param value: :param little_endian: specify the endianness. (Default) Little endian. :return: int: the number of bytes written. """ lengt...
python
def write_var_bytes(self, value, little_endian: bool = True): """ Write an integer value in a space saving way to the stream. :param value: :param little_endian: specify the endianness. (Default) Little endian. :return: int: the number of bytes written. """ lengt...
[ "def", "write_var_bytes", "(", "self", ",", "value", ",", "little_endian", ":", "bool", "=", "True", ")", ":", "length", "=", "len", "(", "value", ")", "self", ".", "write_var_int", "(", "length", ",", "little_endian", ")", "return", "self", ".", "write_...
Write an integer value in a space saving way to the stream. :param value: :param little_endian: specify the endianness. (Default) Little endian. :return: int: the number of bytes written.
[ "Write", "an", "integer", "value", "in", "a", "space", "saving", "way", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L313-L323
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_var_str
def write_var_str(self, value, encoding: str = 'utf-8'): """ Write a string value to the stream. :param value: value to write to the stream. :param encoding: string encoding format. """ if isinstance(value, str): value = value.encode(encoding) self.wr...
python
def write_var_str(self, value, encoding: str = 'utf-8'): """ Write a string value to the stream. :param value: value to write to the stream. :param encoding: string encoding format. """ if isinstance(value, str): value = value.encode(encoding) self.wr...
[ "def", "write_var_str", "(", "self", ",", "value", ",", "encoding", ":", "str", "=", "'utf-8'", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "value", "=", "value", ".", "encode", "(", "encoding", ")", "self", ".", "write_var_int", ...
Write a string value to the stream. :param value: value to write to the stream. :param encoding: string encoding format.
[ "Write", "a", "string", "value", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L325-L335
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_fixed_str
def write_fixed_str(self, value, length): """ Write a string value to the stream. Args: value (str): value to write to the stream. length (int): length of the string to write. """ towrite = value.encode('utf-8') slen = len(towrite) if slen...
python
def write_fixed_str(self, value, length): """ Write a string value to the stream. Args: value (str): value to write to the stream. length (int): length of the string to write. """ towrite = value.encode('utf-8') slen = len(towrite) if slen...
[ "def", "write_fixed_str", "(", "self", ",", "value", ",", "length", ")", ":", "towrite", "=", "value", ".", "encode", "(", "'utf-8'", ")", "slen", "=", "len", "(", "towrite", ")", "if", "slen", ">", "length", ":", "raise", "SDKException", "(", "ErrorCo...
Write a string value to the stream. Args: value (str): value to write to the stream. length (int): length of the string to write.
[ "Write", "a", "string", "value", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L337-L354
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_serializable_array
def write_serializable_array(self, array): """ Write an array of serializable objects to the stream. Args: array(list): a list of serializable objects. i.e. extending neo.IO.Mixins.SerializableMixin """ if array is None: self.write_byte(0) else: ...
python
def write_serializable_array(self, array): """ Write an array of serializable objects to the stream. Args: array(list): a list of serializable objects. i.e. extending neo.IO.Mixins.SerializableMixin """ if array is None: self.write_byte(0) else: ...
[ "def", "write_serializable_array", "(", "self", ",", "array", ")", ":", "if", "array", "is", "None", ":", "self", ".", "write_byte", "(", "0", ")", "else", ":", "self", ".", "write_var_int", "(", "len", "(", "array", ")", ")", "for", "item", "in", "a...
Write an array of serializable objects to the stream. Args: array(list): a list of serializable objects. i.e. extending neo.IO.Mixins.SerializableMixin
[ "Write", "an", "array", "of", "serializable", "objects", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L356-L368
ontio/ontology-python-sdk
ontology/io/binary_writer.py
BinaryWriter.write_hashes
def write_hashes(self, arr): """ Write an array of hashes to the stream. Args: arr (list): a list of 32 byte hashes. """ length = len(arr) self.write_var_int(length) for item in arr: ba = bytearray(binascii.unhexlify(item)) ba....
python
def write_hashes(self, arr): """ Write an array of hashes to the stream. Args: arr (list): a list of 32 byte hashes. """ length = len(arr) self.write_var_int(length) for item in arr: ba = bytearray(binascii.unhexlify(item)) ba....
[ "def", "write_hashes", "(", "self", ",", "arr", ")", ":", "length", "=", "len", "(", "arr", ")", "self", ".", "write_var_int", "(", "length", ")", "for", "item", "in", "arr", ":", "ba", "=", "bytearray", "(", "binascii", ".", "unhexlify", "(", "item"...
Write an array of hashes to the stream. Args: arr (list): a list of 32 byte hashes.
[ "Write", "an", "array", "of", "hashes", "to", "the", "stream", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_writer.py#L370-L382
ontio/ontology-python-sdk
ontology/smart_contract/native_contract/asset.py
Asset.get_asset_address
def get_asset_address(self, asset: str) -> bytes: """ This interface is used to get the smart contract address of ONT otr ONG. :param asset: a string which is used to indicate which asset's contract address we want to get. :return: the contract address of asset in the form of bytearray....
python
def get_asset_address(self, asset: str) -> bytes: """ This interface is used to get the smart contract address of ONT otr ONG. :param asset: a string which is used to indicate which asset's contract address we want to get. :return: the contract address of asset in the form of bytearray....
[ "def", "get_asset_address", "(", "self", ",", "asset", ":", "str", ")", "->", "bytes", ":", "if", "asset", ".", "upper", "(", ")", "==", "'ONT'", ":", "return", "self", ".", "__ont_contract", "elif", "asset", ".", "upper", "(", ")", "==", "'ONG'", ":...
This interface is used to get the smart contract address of ONT otr ONG. :param asset: a string which is used to indicate which asset's contract address we want to get. :return: the contract address of asset in the form of bytearray.
[ "This", "interface", "is", "used", "to", "get", "the", "smart", "contract", "address", "of", "ONT", "otr", "ONG", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L22-L34
ontio/ontology-python-sdk
ontology/smart_contract/native_contract/asset.py
Asset.query_balance
def query_balance(self, asset: str, b58_address: str) -> int: """ This interface is used to query the account's ONT or ONG balance. :param asset: a string which is used to indicate which asset we want to check the balance. :param b58_address: a base58 encode account address. :re...
python
def query_balance(self, asset: str, b58_address: str) -> int: """ This interface is used to query the account's ONT or ONG balance. :param asset: a string which is used to indicate which asset we want to check the balance. :param b58_address: a base58 encode account address. :re...
[ "def", "query_balance", "(", "self", ",", "asset", ":", "str", ",", "b58_address", ":", "str", ")", "->", "int", ":", "raw_address", "=", "Address", ".", "b58decode", "(", "b58_address", ")", ".", "to_bytes", "(", ")", "contract_address", "=", "self", "....
This interface is used to query the account's ONT or ONG balance. :param asset: a string which is used to indicate which asset we want to check the balance. :param b58_address: a base58 encode account address. :return: account balance.
[ "This", "interface", "is", "used", "to", "query", "the", "account", "s", "ONT", "or", "ONG", "balance", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L36-L53
ontio/ontology-python-sdk
ontology/smart_contract/native_contract/asset.py
Asset.query_unbound_ong
def query_unbound_ong(self, base58_address: str) -> int: """ This interface is used to query the amount of account's unbound ong. :param base58_address: a base58 encode address which indicate which account's unbound ong we want to query. :return: the amount of unbound ong in the form of...
python
def query_unbound_ong(self, base58_address: str) -> int: """ This interface is used to query the amount of account's unbound ong. :param base58_address: a base58 encode address which indicate which account's unbound ong we want to query. :return: the amount of unbound ong in the form of...
[ "def", "query_unbound_ong", "(", "self", ",", "base58_address", ":", "str", ")", "->", "int", ":", "contract_address", "=", "self", ".", "get_asset_address", "(", "'ont'", ")", "unbound_ong", "=", "self", ".", "__sdk", ".", "rpc", ".", "get_allowance", "(", ...
This interface is used to query the amount of account's unbound ong. :param base58_address: a base58 encode address which indicate which account's unbound ong we want to query. :return: the amount of unbound ong in the form of int.
[ "This", "interface", "is", "used", "to", "query", "the", "amount", "of", "account", "s", "unbound", "ong", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L76-L85
ontio/ontology-python-sdk
ontology/smart_contract/native_contract/asset.py
Asset.query_symbol
def query_symbol(self, asset: str) -> str: """ This interface is used to query the asset's symbol of ONT or ONG. :param asset: a string which is used to indicate which asset's symbol we want to get. :return: asset's symbol in the form of string. """ contract_address = se...
python
def query_symbol(self, asset: str) -> str: """ This interface is used to query the asset's symbol of ONT or ONG. :param asset: a string which is used to indicate which asset's symbol we want to get. :return: asset's symbol in the form of string. """ contract_address = se...
[ "def", "query_symbol", "(", "self", ",", "asset", ":", "str", ")", "->", "str", ":", "contract_address", "=", "self", ".", "get_asset_address", "(", "asset", ")", "method", "=", "'symbol'", "invoke_code", "=", "build_native_invoke_code", "(", "contract_address",...
This interface is used to query the asset's symbol of ONT or ONG. :param asset: a string which is used to indicate which asset's symbol we want to get. :return: asset's symbol in the form of string.
[ "This", "interface", "is", "used", "to", "query", "the", "asset", "s", "symbol", "of", "ONT", "or", "ONG", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L103-L116
ontio/ontology-python-sdk
ontology/smart_contract/native_contract/asset.py
Asset.query_decimals
def query_decimals(self, asset: str) -> int: """ This interface is used to query the asset's decimals of ONT or ONG. :param asset: a string which is used to indicate which asset's decimals we want to get :return: asset's decimals in the form of int """ contract_address =...
python
def query_decimals(self, asset: str) -> int: """ This interface is used to query the asset's decimals of ONT or ONG. :param asset: a string which is used to indicate which asset's decimals we want to get :return: asset's decimals in the form of int """ contract_address =...
[ "def", "query_decimals", "(", "self", ",", "asset", ":", "str", ")", "->", "int", ":", "contract_address", "=", "self", ".", "get_asset_address", "(", "asset", ")", "invoke_code", "=", "build_native_invoke_code", "(", "contract_address", ",", "b'\\x00'", ",", ...
This interface is used to query the asset's decimals of ONT or ONG. :param asset: a string which is used to indicate which asset's decimals we want to get :return: asset's decimals in the form of int
[ "This", "interface", "is", "used", "to", "query", "the", "asset", "s", "decimals", "of", "ONT", "or", "ONG", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L118-L133
ontio/ontology-python-sdk
ontology/smart_contract/native_contract/asset.py
Asset.new_transfer_transaction
def new_transfer_transaction(self, asset: str, b58_from_address: str, b58_to_address: str, amount: int, b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction: """ This interface is used to generate a Transaction object for transfer. :param asset...
python
def new_transfer_transaction(self, asset: str, b58_from_address: str, b58_to_address: str, amount: int, b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction: """ This interface is used to generate a Transaction object for transfer. :param asset...
[ "def", "new_transfer_transaction", "(", "self", ",", "asset", ":", "str", ",", "b58_from_address", ":", "str", ",", "b58_to_address", ":", "str", ",", "amount", ":", "int", ",", "b58_payer_address", ":", "str", ",", "gas_limit", ":", "int", ",", "gas_price",...
This interface is used to generate a Transaction object for transfer. :param asset: a string which is used to indicate which asset we want to transfer. :param b58_from_address: a base58 encode address which indicate where the asset from. :param b58_to_address: a base58 encode address which indi...
[ "This", "interface", "is", "used", "to", "generate", "a", "Transaction", "object", "for", "transfer", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L135-L166
ontio/ontology-python-sdk
ontology/smart_contract/native_contract/asset.py
Asset.new_approve_transaction
def new_approve_transaction(self, asset: str, b58_send_address: str, b58_recv_address: str, amount: int, b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction: """ This interface is used to generate a Transaction object for approve. :param asset:...
python
def new_approve_transaction(self, asset: str, b58_send_address: str, b58_recv_address: str, amount: int, b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction: """ This interface is used to generate a Transaction object for approve. :param asset:...
[ "def", "new_approve_transaction", "(", "self", ",", "asset", ":", "str", ",", "b58_send_address", ":", "str", ",", "b58_recv_address", ":", "str", ",", "amount", ":", "int", ",", "b58_payer_address", ":", "str", ",", "gas_limit", ":", "int", ",", "gas_price"...
This interface is used to generate a Transaction object for approve. :param asset: a string which is used to indicate which asset we want to approve. :param b58_send_address: a base58 encode address which indicate where the approve from. :param b58_recv_address: a base58 encode address which in...
[ "This", "interface", "is", "used", "to", "generate", "a", "Transaction", "object", "for", "approve", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L168-L198
ontio/ontology-python-sdk
ontology/smart_contract/native_contract/asset.py
Asset.new_transfer_from_transaction
def new_transfer_from_transaction(self, asset: str, b58_send_address: str, b58_from_address: str, b58_recv_address: str, amount: int, b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction: """ This interface is ...
python
def new_transfer_from_transaction(self, asset: str, b58_send_address: str, b58_from_address: str, b58_recv_address: str, amount: int, b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction: """ This interface is ...
[ "def", "new_transfer_from_transaction", "(", "self", ",", "asset", ":", "str", ",", "b58_send_address", ":", "str", ",", "b58_from_address", ":", "str", ",", "b58_recv_address", ":", "str", ",", "amount", ":", "int", ",", "b58_payer_address", ":", "str", ",", ...
This interface is used to generate a Transaction object that allow one account to transfer a amount of ONT or ONG Asset to another account, in the condition of the first account had been approved. :param asset: a string which is used to indicate which asset we want to transfer. :param b58_send_...
[ "This", "interface", "is", "used", "to", "generate", "a", "Transaction", "object", "that", "allow", "one", "account", "to", "transfer", "a", "amount", "of", "ONT", "or", "ONG", "Asset", "to", "another", "account", "in", "the", "condition", "of", "the", "fi...
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L200-L224
ontio/ontology-python-sdk
ontology/smart_contract/native_contract/asset.py
Asset.new_withdraw_ong_transaction
def new_withdraw_ong_transaction(self, b58_claimer_address: str, b58_recv_address: str, amount: int, b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction: """ This interface is used to generate a Transaction object that allow one account to ...
python
def new_withdraw_ong_transaction(self, b58_claimer_address: str, b58_recv_address: str, amount: int, b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction: """ This interface is used to generate a Transaction object that allow one account to ...
[ "def", "new_withdraw_ong_transaction", "(", "self", ",", "b58_claimer_address", ":", "str", ",", "b58_recv_address", ":", "str", ",", "amount", ":", "int", ",", "b58_payer_address", ":", "str", ",", "gas_limit", ":", "int", ",", "gas_price", ":", "int", ")", ...
This interface is used to generate a Transaction object that allow one account to withdraw an amount of ong and transfer them to receive address. :param b58_claimer_address: a base58 encode address which is used to indicate who is the claimer. :param b58_recv_address: a base58 encode address wh...
[ "This", "interface", "is", "used", "to", "generate", "a", "Transaction", "object", "that", "allow", "one", "account", "to", "withdraw", "an", "amount", "of", "ong", "and", "transfer", "them", "to", "receive", "address", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L226-L257
ontio/ontology-python-sdk
ontology/smart_contract/native_contract/asset.py
Asset.transfer
def transfer(self, asset: str, from_acct: Account, b58_to_address: str, amount: int, payer: Account, gas_limit: int, gas_price: int): """ This interface is used to send a transfer transaction that only for ONT or ONG. :param asset: a string which is used to indicate which asset...
python
def transfer(self, asset: str, from_acct: Account, b58_to_address: str, amount: int, payer: Account, gas_limit: int, gas_price: int): """ This interface is used to send a transfer transaction that only for ONT or ONG. :param asset: a string which is used to indicate which asset...
[ "def", "transfer", "(", "self", ",", "asset", ":", "str", ",", "from_acct", ":", "Account", ",", "b58_to_address", ":", "str", ",", "amount", ":", "int", ",", "payer", ":", "Account", ",", "gas_limit", ":", "int", ",", "gas_price", ":", "int", ")", "...
This interface is used to send a transfer transaction that only for ONT or ONG. :param asset: a string which is used to indicate which asset we want to transfer. :param from_acct: a Account object which indicate where the asset from. :param b58_to_address: a base58 encode address which indicate...
[ "This", "interface", "is", "used", "to", "send", "a", "transfer", "transaction", "that", "only", "for", "ONT", "or", "ONG", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L259-L278
ontio/ontology-python-sdk
ontology/smart_contract/native_contract/asset.py
Asset.withdraw_ong
def withdraw_ong(self, claimer: Account, b58_recv_address: str, amount: int, payer: Account, gas_limit: int, gas_price: int) -> str: """ This interface is used to withdraw a amount of ong and transfer them to receive address. :param claimer: the owner of ong that remained t...
python
def withdraw_ong(self, claimer: Account, b58_recv_address: str, amount: int, payer: Account, gas_limit: int, gas_price: int) -> str: """ This interface is used to withdraw a amount of ong and transfer them to receive address. :param claimer: the owner of ong that remained t...
[ "def", "withdraw_ong", "(", "self", ",", "claimer", ":", "Account", ",", "b58_recv_address", ":", "str", ",", "amount", ":", "int", ",", "payer", ":", "Account", ",", "gas_limit", ":", "int", ",", "gas_price", ":", "int", ")", "->", "str", ":", "if", ...
This interface is used to withdraw a amount of ong and transfer them to receive address. :param claimer: the owner of ong that remained to claim. :param b58_recv_address: the address that received the ong. :param amount: the amount of ong want to claim. :param payer: an Account class th...
[ "This", "interface", "is", "used", "to", "withdraw", "a", "amount", "of", "ong", "and", "transfer", "them", "to", "receive", "address", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L280-L309
ontio/ontology-python-sdk
ontology/smart_contract/native_contract/asset.py
Asset.approve
def approve(self, asset, sender: Account, b58_recv_address: str, amount: int, payer: Account, gas_limit: int, gas_price: int) -> str: """ This is an interface used to send an approve transaction which allow receiver to spend a amount of ONT or ONG asset in sender's account. ...
python
def approve(self, asset, sender: Account, b58_recv_address: str, amount: int, payer: Account, gas_limit: int, gas_price: int) -> str: """ This is an interface used to send an approve transaction which allow receiver to spend a amount of ONT or ONG asset in sender's account. ...
[ "def", "approve", "(", "self", ",", "asset", ",", "sender", ":", "Account", ",", "b58_recv_address", ":", "str", ",", "amount", ":", "int", ",", "payer", ":", "Account", ",", "gas_limit", ":", "int", ",", "gas_price", ":", "int", ")", "->", "str", ":...
This is an interface used to send an approve transaction which allow receiver to spend a amount of ONT or ONG asset in sender's account. :param asset: a string which is used to indicate what asset we want to approve. :param sender: an Account class that send the approve transaction. :pa...
[ "This", "is", "an", "interface", "used", "to", "send", "an", "approve", "transaction", "which", "allow", "receiver", "to", "spend", "a", "amount", "of", "ONT", "or", "ONG", "asset", "in", "sender", "s", "account", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/smart_contract/native_contract/asset.py#L311-L343
ontio/ontology-python-sdk
ontology/wallet/wallet.py
WalletData.remove_account
def remove_account(self, address: str): """ This interface is used to remove account from WalletData. :param address: a string address. """ account = self.get_account_by_b58_address(address) if account is None: raise SDKException(ErrorCode.get_account_by_addr...
python
def remove_account(self, address: str): """ This interface is used to remove account from WalletData. :param address: a string address. """ account = self.get_account_by_b58_address(address) if account is None: raise SDKException(ErrorCode.get_account_by_addr...
[ "def", "remove_account", "(", "self", ",", "address", ":", "str", ")", ":", "account", "=", "self", ".", "get_account_by_b58_address", "(", "address", ")", "if", "account", "is", "None", ":", "raise", "SDKException", "(", "ErrorCode", ".", "get_account_by_addr...
This interface is used to remove account from WalletData. :param address: a string address.
[ "This", "interface", "is", "used", "to", "remove", "account", "from", "WalletData", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/wallet/wallet.py#L101-L110
ontio/ontology-python-sdk
ontology/wallet/wallet.py
WalletData.set_default_account_by_index
def set_default_account_by_index(self, index: int): """ This interface is used to set default account by given index. :param index: an int value that indicate the account object in account list. """ if index >= len(self.accounts): raise SDKException(ErrorCode.param_e...
python
def set_default_account_by_index(self, index: int): """ This interface is used to set default account by given index. :param index: an int value that indicate the account object in account list. """ if index >= len(self.accounts): raise SDKException(ErrorCode.param_e...
[ "def", "set_default_account_by_index", "(", "self", ",", "index", ":", "int", ")", ":", "if", "index", ">=", "len", "(", "self", ".", "accounts", ")", ":", "raise", "SDKException", "(", "ErrorCode", ".", "param_error", ")", "for", "acct", "in", "self", "...
This interface is used to set default account by given index. :param index: an int value that indicate the account object in account list.
[ "This", "interface", "is", "used", "to", "set", "default", "account", "by", "given", "index", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/wallet/wallet.py#L120-L131
ontio/ontology-python-sdk
ontology/wallet/wallet.py
WalletData.set_default_account_by_address
def set_default_account_by_address(self, b58_address: str): """ This interface is used to set default account by given base58 encode address. :param b58_address: a base58 encode address. """ flag = True index = -1 for acct in self.accounts: index += 1...
python
def set_default_account_by_address(self, b58_address: str): """ This interface is used to set default account by given base58 encode address. :param b58_address: a base58 encode address. """ flag = True index = -1 for acct in self.accounts: index += 1...
[ "def", "set_default_account_by_address", "(", "self", ",", "b58_address", ":", "str", ")", ":", "flag", "=", "True", "index", "=", "-", "1", "for", "acct", "in", "self", ".", "accounts", ":", "index", "+=", "1", "if", "acct", ".", "b58_address", "==", ...
This interface is used to set default account by given base58 encode address. :param b58_address: a base58 encode address.
[ "This", "interface", "is", "used", "to", "set", "default", "account", "by", "given", "base58", "encode", "address", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/wallet/wallet.py#L133-L151
ontio/ontology-python-sdk
ontology/wallet/wallet.py
WalletData.set_default_identity_by_index
def set_default_identity_by_index(self, index: int): """ This interface is used to set default account by given an index value. :param index: an int value that indicate the position of an account object in account list. """ identities_len = len(self.identities) if index ...
python
def set_default_identity_by_index(self, index: int): """ This interface is used to set default account by given an index value. :param index: an int value that indicate the position of an account object in account list. """ identities_len = len(self.identities) if index ...
[ "def", "set_default_identity_by_index", "(", "self", ",", "index", ":", "int", ")", ":", "identities_len", "=", "len", "(", "self", ".", "identities", ")", "if", "index", ">=", "identities_len", ":", "raise", "SDKException", "(", "ErrorCode", ".", "param_error...
This interface is used to set default account by given an index value. :param index: an int value that indicate the position of an account object in account list.
[ "This", "interface", "is", "used", "to", "set", "default", "account", "by", "given", "an", "index", "value", "." ]
train
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/wallet/wallet.py#L230-L242
vicenteneto/python-cartolafc
cartolafc/api.py
Api.set_credentials
def set_credentials(self, email, password): """ Realiza a autenticação no sistema do CartolaFC utilizando o email e password informados. Args: email (str): O email do usuário password (str): A senha do usuário Raises: cartolafc.CartolaFCError: Se o conjunto ...
python
def set_credentials(self, email, password): """ Realiza a autenticação no sistema do CartolaFC utilizando o email e password informados. Args: email (str): O email do usuário password (str): A senha do usuário Raises: cartolafc.CartolaFCError: Se o conjunto ...
[ "def", "set_credentials", "(", "self", ",", "email", ",", "password", ")", ":", "self", ".", "_email", "=", "email", "self", ".", "_password", "=", "password", "response", "=", "requests", ".", "post", "(", "self", ".", "_auth_url", ",", "json", "=", "...
Realiza a autenticação no sistema do CartolaFC utilizando o email e password informados. Args: email (str): O email do usuário password (str): A senha do usuário Raises: cartolafc.CartolaFCError: Se o conjunto (email, password) não conseguiu realizar a autenticação ...
[ "Realiza", "a", "autenticação", "no", "sistema", "do", "CartolaFC", "utilizando", "o", "email", "e", "password", "informados", "." ]
train
https://github.com/vicenteneto/python-cartolafc/blob/15b2a192d7745f454d69a55ac9b7ef7c7abb53b9/cartolafc/api.py#L91-L110
vicenteneto/python-cartolafc
cartolafc/api.py
Api.set_redis
def set_redis(self, redis_url, redis_timeout=10): """ Realiza a autenticação no servidor Redis utilizando a URL informada. Args: redis_url (str): URL para conectar ao servidor Redis, exemplo: redis://user:password@localhost:6379/2. redis_timeout (int): O timeout padrão (em segun...
python
def set_redis(self, redis_url, redis_timeout=10): """ Realiza a autenticação no servidor Redis utilizando a URL informada. Args: redis_url (str): URL para conectar ao servidor Redis, exemplo: redis://user:password@localhost:6379/2. redis_timeout (int): O timeout padrão (em segun...
[ "def", "set_redis", "(", "self", ",", "redis_url", ",", "redis_timeout", "=", "10", ")", ":", "self", ".", "_redis_url", "=", "redis_url", "self", ".", "_redis_timeout", "=", "redis_timeout", "if", "isinstance", "(", "redis_timeout", ",", "int", ")", "and", ...
Realiza a autenticação no servidor Redis utilizando a URL informada. Args: redis_url (str): URL para conectar ao servidor Redis, exemplo: redis://user:password@localhost:6379/2. redis_timeout (int): O timeout padrão (em segundos). kwargs (dict): Raises: ...
[ "Realiza", "a", "autenticação", "no", "servidor", "Redis", "utilizando", "a", "URL", "informada", "." ]
train
https://github.com/vicenteneto/python-cartolafc/blob/15b2a192d7745f454d69a55ac9b7ef7c7abb53b9/cartolafc/api.py#L112-L130
vicenteneto/python-cartolafc
cartolafc/api.py
Api.liga
def liga(self, nome=None, slug=None, page=1, order_by=CAMPEONATO): """ Este serviço requer que a API esteja autenticada, e realiza uma busca pelo nome ou slug informados. Este serviço obtém apenas 20 times por página, portanto, caso sua liga possua mais que 20 membros, deve-se utilizar o argumen...
python
def liga(self, nome=None, slug=None, page=1, order_by=CAMPEONATO): """ Este serviço requer que a API esteja autenticada, e realiza uma busca pelo nome ou slug informados. Este serviço obtém apenas 20 times por página, portanto, caso sua liga possua mais que 20 membros, deve-se utilizar o argumen...
[ "def", "liga", "(", "self", ",", "nome", "=", "None", ",", "slug", "=", "None", ",", "page", "=", "1", ",", "order_by", "=", "CAMPEONATO", ")", ":", "if", "not", "any", "(", "(", "nome", ",", "slug", ")", ")", ":", "raise", "CartolaFCError", "(",...
Este serviço requer que a API esteja autenticada, e realiza uma busca pelo nome ou slug informados. Este serviço obtém apenas 20 times por página, portanto, caso sua liga possua mais que 20 membros, deve-se utilizar o argumento "page" para obter mais times. Args: nome (str): Nome da...
[ "Este", "serviço", "requer", "que", "a", "API", "esteja", "autenticada", "e", "realiza", "uma", "busca", "pelo", "nome", "ou", "slug", "informados", ".", "Este", "serviço", "obtém", "apenas", "20", "times", "por", "página", "portanto", "caso", "sua", "liga",...
train
https://github.com/vicenteneto/python-cartolafc/blob/15b2a192d7745f454d69a55ac9b7ef7c7abb53b9/cartolafc/api.py#L139-L165
vicenteneto/python-cartolafc
cartolafc/api.py
Api.ligas
def ligas(self, query): """ Retorna o resultado da busca ao Cartola por um determinado termo de pesquisa. Args: query (str): Termo para utilizar na busca. Returns: Uma lista de instâncias de cartolafc.Liga, uma para cada liga contento o termo utilizado na busca. ...
python
def ligas(self, query): """ Retorna o resultado da busca ao Cartola por um determinado termo de pesquisa. Args: query (str): Termo para utilizar na busca. Returns: Uma lista de instâncias de cartolafc.Liga, uma para cada liga contento o termo utilizado na busca. ...
[ "def", "ligas", "(", "self", ",", "query", ")", ":", "url", "=", "'{api_url}/ligas'", ".", "format", "(", "api_url", "=", "self", ".", "_api_url", ")", "data", "=", "self", ".", "_request", "(", "url", ",", "params", "=", "dict", "(", "q", "=", "qu...
Retorna o resultado da busca ao Cartola por um determinado termo de pesquisa. Args: query (str): Termo para utilizar na busca. Returns: Uma lista de instâncias de cartolafc.Liga, uma para cada liga contento o termo utilizado na busca.
[ "Retorna", "o", "resultado", "da", "busca", "ao", "Cartola", "por", "um", "determinado", "termo", "de", "pesquisa", "." ]
train
https://github.com/vicenteneto/python-cartolafc/blob/15b2a192d7745f454d69a55ac9b7ef7c7abb53b9/cartolafc/api.py#L185-L197
vicenteneto/python-cartolafc
cartolafc/api.py
Api.mercado
def mercado(self): """ Obtém o status do mercado na rodada atual. Returns: Uma instância de cartolafc.Mercado representando o status do mercado na rodada atual. """ url = '{api_url}/mercado/status'.format(api_url=self._api_url) data = self._request(url) retu...
python
def mercado(self): """ Obtém o status do mercado na rodada atual. Returns: Uma instância de cartolafc.Mercado representando o status do mercado na rodada atual. """ url = '{api_url}/mercado/status'.format(api_url=self._api_url) data = self._request(url) retu...
[ "def", "mercado", "(", "self", ")", ":", "url", "=", "'{api_url}/mercado/status'", ".", "format", "(", "api_url", "=", "self", ".", "_api_url", ")", "data", "=", "self", ".", "_request", "(", "url", ")", "return", "Mercado", ".", "from_dict", "(", "data"...
Obtém o status do mercado na rodada atual. Returns: Uma instância de cartolafc.Mercado representando o status do mercado na rodada atual.
[ "Obtém", "o", "status", "do", "mercado", "na", "rodada", "atual", "." ]
train
https://github.com/vicenteneto/python-cartolafc/blob/15b2a192d7745f454d69a55ac9b7ef7c7abb53b9/cartolafc/api.py#L205-L214
vicenteneto/python-cartolafc
cartolafc/api.py
Api.parciais
def parciais(self): """ Obtém um mapa com todos os atletas que já pontuaram na rodada atual (aberta). Returns: Uma mapa, onde a key é um inteiro representando o id do atleta e o valor é uma instância de cartolafc.Atleta Raises: CartolaFCError: Se o mercado atual estiver...
python
def parciais(self): """ Obtém um mapa com todos os atletas que já pontuaram na rodada atual (aberta). Returns: Uma mapa, onde a key é um inteiro representando o id do atleta e o valor é uma instância de cartolafc.Atleta Raises: CartolaFCError: Se o mercado atual estiver...
[ "def", "parciais", "(", "self", ")", ":", "if", "self", ".", "mercado", "(", ")", ".", "status", ".", "id", "==", "MERCADO_FECHADO", ":", "url", "=", "'{api_url}/atletas/pontuados'", ".", "format", "(", "api_url", "=", "self", ".", "_api_url", ")", "data...
Obtém um mapa com todos os atletas que já pontuaram na rodada atual (aberta). Returns: Uma mapa, onde a key é um inteiro representando o id do atleta e o valor é uma instância de cartolafc.Atleta Raises: CartolaFCError: Se o mercado atual estiver com o status fechado.
[ "Obtém", "um", "mapa", "com", "todos", "os", "atletas", "que", "já", "pontuaram", "na", "rodada", "atual", "(", "aberta", ")", "." ]
train
https://github.com/vicenteneto/python-cartolafc/blob/15b2a192d7745f454d69a55ac9b7ef7c7abb53b9/cartolafc/api.py#L222-L239
vicenteneto/python-cartolafc
cartolafc/api.py
Api.time
def time(self, id=None, nome=None, slug=None, as_json=False): """ Obtém um time específico, baseando-se no nome ou no slug utilizado. Ao menos um dos dois devem ser informado. Args: id (int): Id to time que se deseja obter. *Este argumento sempre será utilizado primeiro* ...
python
def time(self, id=None, nome=None, slug=None, as_json=False): """ Obtém um time específico, baseando-se no nome ou no slug utilizado. Ao menos um dos dois devem ser informado. Args: id (int): Id to time que se deseja obter. *Este argumento sempre será utilizado primeiro* ...
[ "def", "time", "(", "self", ",", "id", "=", "None", ",", "nome", "=", "None", ",", "slug", "=", "None", ",", "as_json", "=", "False", ")", ":", "if", "not", "any", "(", "(", "id", ",", "nome", ",", "slug", ")", ")", ":", "raise", "CartolaFCErro...
Obtém um time específico, baseando-se no nome ou no slug utilizado. Ao menos um dos dois devem ser informado. Args: id (int): Id to time que se deseja obter. *Este argumento sempre será utilizado primeiro* nome (str): Nome do time que se deseja obter. Requerido se o slug não for...
[ "Obtém", "um", "time", "específico", "baseando", "-", "se", "no", "nome", "ou", "no", "slug", "utilizado", ".", "Ao", "menos", "um", "dos", "dois", "devem", "ser", "informado", "." ]
train
https://github.com/vicenteneto/python-cartolafc/blob/15b2a192d7745f454d69a55ac9b7ef7c7abb53b9/cartolafc/api.py#L255-L283
vicenteneto/python-cartolafc
cartolafc/api.py
Api.times
def times(self, query): """ Retorna o resultado da busca ao Cartola por um determinado termo de pesquisa. Args: query (str): Termo para utilizar na busca. Returns: Uma lista de instâncias de cartolafc.TimeInfo, uma para cada time contento o termo utilizado na busca. ...
python
def times(self, query): """ Retorna o resultado da busca ao Cartola por um determinado termo de pesquisa. Args: query (str): Termo para utilizar na busca. Returns: Uma lista de instâncias de cartolafc.TimeInfo, uma para cada time contento o termo utilizado na busca. ...
[ "def", "times", "(", "self", ",", "query", ")", ":", "url", "=", "'{api_url}/times'", ".", "format", "(", "api_url", "=", "self", ".", "_api_url", ")", "data", "=", "self", ".", "_request", "(", "url", ",", "params", "=", "dict", "(", "q", "=", "qu...
Retorna o resultado da busca ao Cartola por um determinado termo de pesquisa. Args: query (str): Termo para utilizar na busca. Returns: Uma lista de instâncias de cartolafc.TimeInfo, uma para cada time contento o termo utilizado na busca.
[ "Retorna", "o", "resultado", "da", "busca", "ao", "Cartola", "por", "um", "determinado", "termo", "de", "pesquisa", "." ]
train
https://github.com/vicenteneto/python-cartolafc/blob/15b2a192d7745f454d69a55ac9b7ef7c7abb53b9/cartolafc/api.py#L293-L304
openvax/gtfparse
gtfparse/read_gtf.py
parse_gtf
def parse_gtf( filepath_or_buffer, chunksize=1024 * 1024, features=None, intern_columns=["seqname", "source", "strand", "frame"], fix_quotes_columns=["attribute"]): """ Parameters ---------- filepath_or_buffer : str or buffer object chunksize : int feat...
python
def parse_gtf( filepath_or_buffer, chunksize=1024 * 1024, features=None, intern_columns=["seqname", "source", "strand", "frame"], fix_quotes_columns=["attribute"]): """ Parameters ---------- filepath_or_buffer : str or buffer object chunksize : int feat...
[ "def", "parse_gtf", "(", "filepath_or_buffer", ",", "chunksize", "=", "1024", "*", "1024", ",", "features", "=", "None", ",", "intern_columns", "=", "[", "\"seqname\"", ",", "\"source\"", ",", "\"strand\"", ",", "\"frame\"", "]", ",", "fix_quotes_columns", "="...
Parameters ---------- filepath_or_buffer : str or buffer object chunksize : int features : set or None Drop entries which aren't one of these features intern_columns : list These columns are short strings which should be interned fix_quotes_columns : list Most common...
[ "Parameters", "----------" ]
train
https://github.com/openvax/gtfparse/blob/c79cab0c2a5ac3d08de9f932fa29a56d334a712b/gtfparse/read_gtf.py#L32-L126
openvax/gtfparse
gtfparse/read_gtf.py
parse_gtf_and_expand_attributes
def parse_gtf_and_expand_attributes( filepath_or_buffer, chunksize=1024 * 1024, restrict_attribute_columns=None, features=None): """ Parse lines into column->values dictionary and then expand the 'attribute' column into multiple columns. This expansion happens by replacin...
python
def parse_gtf_and_expand_attributes( filepath_or_buffer, chunksize=1024 * 1024, restrict_attribute_columns=None, features=None): """ Parse lines into column->values dictionary and then expand the 'attribute' column into multiple columns. This expansion happens by replacin...
[ "def", "parse_gtf_and_expand_attributes", "(", "filepath_or_buffer", ",", "chunksize", "=", "1024", "*", "1024", ",", "restrict_attribute_columns", "=", "None", ",", "features", "=", "None", ")", ":", "result", "=", "parse_gtf", "(", "filepath_or_buffer", ",", "ch...
Parse lines into column->values dictionary and then expand the 'attribute' column into multiple columns. This expansion happens by replacing strings of semi-colon separated key-value values in the 'attribute' column with one column per distinct key, with a list of values for each row (using None for row...
[ "Parse", "lines", "into", "column", "-", ">", "values", "dictionary", "and", "then", "expand", "the", "attribute", "column", "into", "multiple", "columns", ".", "This", "expansion", "happens", "by", "replacing", "strings", "of", "semi", "-", "colon", "separate...
train
https://github.com/openvax/gtfparse/blob/c79cab0c2a5ac3d08de9f932fa29a56d334a712b/gtfparse/read_gtf.py#L129-L162
openvax/gtfparse
gtfparse/read_gtf.py
read_gtf
def read_gtf( filepath_or_buffer, expand_attribute_column=True, infer_biotype_column=False, column_converters={}, usecols=None, features=None, chunksize=1024 * 1024): """ Parse a GTF into a dictionary mapping column names to sequences of values. Param...
python
def read_gtf( filepath_or_buffer, expand_attribute_column=True, infer_biotype_column=False, column_converters={}, usecols=None, features=None, chunksize=1024 * 1024): """ Parse a GTF into a dictionary mapping column names to sequences of values. Param...
[ "def", "read_gtf", "(", "filepath_or_buffer", ",", "expand_attribute_column", "=", "True", ",", "infer_biotype_column", "=", "False", ",", "column_converters", "=", "{", "}", ",", "usecols", "=", "None", ",", "features", "=", "None", ",", "chunksize", "=", "10...
Parse a GTF into a dictionary mapping column names to sequences of values. Parameters ---------- filepath_or_buffer : str or buffer object Path to GTF file (may be gzip compressed) or buffer object such as StringIO expand_attribute_column : bool Replace strings of semi-colon se...
[ "Parse", "a", "GTF", "into", "a", "dictionary", "mapping", "column", "names", "to", "sequences", "of", "values", "." ]
train
https://github.com/openvax/gtfparse/blob/c79cab0c2a5ac3d08de9f932fa29a56d334a712b/gtfparse/read_gtf.py#L165-L247
openvax/gtfparse
gtfparse/attribute_parsing.py
expand_attribute_strings
def expand_attribute_strings( attribute_strings, quote_char='\"', missing_value="", usecols=None): """ The last column of GTF has a variable number of key value pairs of the format: "key1 value1; key2 value2;" Parse these into a dictionary mapping each key onto a list of ...
python
def expand_attribute_strings( attribute_strings, quote_char='\"', missing_value="", usecols=None): """ The last column of GTF has a variable number of key value pairs of the format: "key1 value1; key2 value2;" Parse these into a dictionary mapping each key onto a list of ...
[ "def", "expand_attribute_strings", "(", "attribute_strings", ",", "quote_char", "=", "'\\\"'", ",", "missing_value", "=", "\"\"", ",", "usecols", "=", "None", ")", ":", "n", "=", "len", "(", "attribute_strings", ")", "extra_columns", "=", "{", "}", "column_ord...
The last column of GTF has a variable number of key value pairs of the format: "key1 value1; key2 value2;" Parse these into a dictionary mapping each key onto a list of values, where the value is None for any row where the key was missing. Parameters ---------- attribute_strings : list of str ...
[ "The", "last", "column", "of", "GTF", "has", "a", "variable", "number", "of", "key", "value", "pairs", "of", "the", "format", ":", "key1", "value1", ";", "key2", "value2", ";", "Parse", "these", "into", "a", "dictionary", "mapping", "each", "key", "onto"...
train
https://github.com/openvax/gtfparse/blob/c79cab0c2a5ac3d08de9f932fa29a56d334a712b/gtfparse/attribute_parsing.py#L25-L121
openvax/gtfparse
gtfparse/create_missing_features.py
create_missing_features
def create_missing_features( dataframe, unique_keys={}, extra_columns={}, missing_value=None): """ Helper function used to construct a missing feature such as 'transcript' or 'gene'. Some GTF files only have 'exon' and 'CDS' entries, but have transcript_id and gene_id ann...
python
def create_missing_features( dataframe, unique_keys={}, extra_columns={}, missing_value=None): """ Helper function used to construct a missing feature such as 'transcript' or 'gene'. Some GTF files only have 'exon' and 'CDS' entries, but have transcript_id and gene_id ann...
[ "def", "create_missing_features", "(", "dataframe", ",", "unique_keys", "=", "{", "}", ",", "extra_columns", "=", "{", "}", ",", "missing_value", "=", "None", ")", ":", "extra_dataframes", "=", "[", "]", "existing_features", "=", "set", "(", "dataframe", "["...
Helper function used to construct a missing feature such as 'transcript' or 'gene'. Some GTF files only have 'exon' and 'CDS' entries, but have transcript_id and gene_id annotations which allow us to construct those missing features. Parameters ---------- dataframe : pandas.DataFrame Sh...
[ "Helper", "function", "used", "to", "construct", "a", "missing", "feature", "such", "as", "transcript", "or", "gene", ".", "Some", "GTF", "files", "only", "have", "exon", "and", "CDS", "entries", "but", "have", "transcript_id", "and", "gene_id", "annotations",...
train
https://github.com/openvax/gtfparse/blob/c79cab0c2a5ac3d08de9f932fa29a56d334a712b/gtfparse/create_missing_features.py#L25-L121
MichaelAquilina/S4
s4/clients/__init__.py
SyncClient.get_action
def get_action(self, key): """ returns the action to perform on this key based on its state before the last sync. """ index_local_timestamp = self.get_index_local_timestamp(key) real_local_timestamp = self.get_real_local_timestamp(key) remote_timestamp = self.get_...
python
def get_action(self, key): """ returns the action to perform on this key based on its state before the last sync. """ index_local_timestamp = self.get_index_local_timestamp(key) real_local_timestamp = self.get_real_local_timestamp(key) remote_timestamp = self.get_...
[ "def", "get_action", "(", "self", ",", "key", ")", ":", "index_local_timestamp", "=", "self", ".", "get_index_local_timestamp", "(", "key", ")", "real_local_timestamp", "=", "self", ".", "get_real_local_timestamp", "(", "key", ")", "remote_timestamp", "=", "self",...
returns the action to perform on this key based on its state before the last sync.
[ "returns", "the", "action", "to", "perform", "on", "this", "key", "based", "on", "its", "state", "before", "the", "last", "sync", "." ]
train
https://github.com/MichaelAquilina/S4/blob/05d74697e6ec683f0329c983f7c3f05ab75fd57e/s4/clients/__init__.py#L191-L201
MichaelAquilina/S4
s4/clients/local.py
LocalSyncClient.lock
def lock(self, timeout=10): """ Advisory lock. Use to ensure that only one LocalSyncClient is working on the Target at the same time. """ logger.debug("Locking %s", self.lock_file) if not os.path.exists(self.lock_file): self.ensure_path(self.lock_file) ...
python
def lock(self, timeout=10): """ Advisory lock. Use to ensure that only one LocalSyncClient is working on the Target at the same time. """ logger.debug("Locking %s", self.lock_file) if not os.path.exists(self.lock_file): self.ensure_path(self.lock_file) ...
[ "def", "lock", "(", "self", ",", "timeout", "=", "10", ")", ":", "logger", ".", "debug", "(", "\"Locking %s\"", ",", "self", ".", "lock_file", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "lock_file", ")", ":", "self", ".",...
Advisory lock. Use to ensure that only one LocalSyncClient is working on the Target at the same time.
[ "Advisory", "lock", ".", "Use", "to", "ensure", "that", "only", "one", "LocalSyncClient", "is", "working", "on", "the", "Target", "at", "the", "same", "time", "." ]
train
https://github.com/MichaelAquilina/S4/blob/05d74697e6ec683f0329c983f7c3f05ab75fd57e/s4/clients/local.py#L65-L75
MichaelAquilina/S4
s4/clients/local.py
LocalSyncClient.unlock
def unlock(self): """ Unlock the active advisory lock. """ logger.debug("Releasing lock %s", self.lock_file) self._lock.release() try: os.unlink(self.lock_file) except FileNotFoundError: pass
python
def unlock(self): """ Unlock the active advisory lock. """ logger.debug("Releasing lock %s", self.lock_file) self._lock.release() try: os.unlink(self.lock_file) except FileNotFoundError: pass
[ "def", "unlock", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"Releasing lock %s\"", ",", "self", ".", "lock_file", ")", "self", ".", "_lock", ".", "release", "(", ")", "try", ":", "os", ".", "unlink", "(", "self", ".", "lock_file", ")", "ex...
Unlock the active advisory lock.
[ "Unlock", "the", "active", "advisory", "lock", "." ]
train
https://github.com/MichaelAquilina/S4/blob/05d74697e6ec683f0329c983f7c3f05ab75fd57e/s4/clients/local.py#L77-L86
MichaelAquilina/S4
s4/utils.py
get_input
def get_input(*args, secret=False, required=False, blank=False, **kwargs): """ secret: Don't show user input when they are typing. required: Keep prompting if the user enters an empty value. blank: turn all empty strings into None. """ while True: if secret: value = getpass....
python
def get_input(*args, secret=False, required=False, blank=False, **kwargs): """ secret: Don't show user input when they are typing. required: Keep prompting if the user enters an empty value. blank: turn all empty strings into None. """ while True: if secret: value = getpass....
[ "def", "get_input", "(", "*", "args", ",", "secret", "=", "False", ",", "required", "=", "False", ",", "blank", "=", "False", ",", "*", "*", "kwargs", ")", ":", "while", "True", ":", "if", "secret", ":", "value", "=", "getpass", ".", "getpass", "("...
secret: Don't show user input when they are typing. required: Keep prompting if the user enters an empty value. blank: turn all empty strings into None.
[ "secret", ":", "Don", "t", "show", "user", "input", "when", "they", "are", "typing", ".", "required", ":", "Keep", "prompting", "if", "the", "user", "enters", "an", "empty", "value", ".", "blank", ":", "turn", "all", "empty", "strings", "into", "None", ...
train
https://github.com/MichaelAquilina/S4/blob/05d74697e6ec683f0329c983f7c3f05ab75fd57e/s4/utils.py#L17-L36
gazpachoking/jsonref
proxytypes.py
ProxyMetaClass._no_proxy
def _no_proxy(method): """ Returns a wrapped version of `method`, such that proxying is turned off during the method call. """ @wraps(method) def wrapper(self, *args, **kwargs): notproxied = _oga(self, "__notproxied__") _osa(self, "__notproxied__...
python
def _no_proxy(method): """ Returns a wrapped version of `method`, such that proxying is turned off during the method call. """ @wraps(method) def wrapper(self, *args, **kwargs): notproxied = _oga(self, "__notproxied__") _osa(self, "__notproxied__...
[ "def", "_no_proxy", "(", "method", ")", ":", "@", "wraps", "(", "method", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "notproxied", "=", "_oga", "(", "self", ",", "\"__notproxied__\"", ")", "_osa", "(", ...
Returns a wrapped version of `method`, such that proxying is turned off during the method call.
[ "Returns", "a", "wrapped", "version", "of", "method", "such", "that", "proxying", "is", "turned", "off", "during", "the", "method", "call", "." ]
train
https://github.com/gazpachoking/jsonref/blob/066132e527f8115f75bcadfd0eca12f8973a6309/proxytypes.py#L122-L138
gazpachoking/jsonref
proxytypes.py
Proxy._should_proxy
def _should_proxy(self, attr): """ Determines whether `attr` should be looked up on the proxied object, or the proxy itself. """ if attr in type(self).__notproxied__: return False if _oga(self, "__notproxied__") is True: return False retur...
python
def _should_proxy(self, attr): """ Determines whether `attr` should be looked up on the proxied object, or the proxy itself. """ if attr in type(self).__notproxied__: return False if _oga(self, "__notproxied__") is True: return False retur...
[ "def", "_should_proxy", "(", "self", ",", "attr", ")", ":", "if", "attr", "in", "type", "(", "self", ")", ".", "__notproxied__", ":", "return", "False", "if", "_oga", "(", "self", ",", "\"__notproxied__\"", ")", "is", "True", ":", "return", "False", "r...
Determines whether `attr` should be looked up on the proxied object, or the proxy itself.
[ "Determines", "whether", "attr", "should", "be", "looked", "up", "on", "the", "proxied", "object", "or", "the", "proxy", "itself", "." ]
train
https://github.com/gazpachoking/jsonref/blob/066132e527f8115f75bcadfd0eca12f8973a6309/proxytypes.py#L161-L171
gazpachoking/jsonref
proxytypes.py
Proxy.add_proxy_meth
def add_proxy_meth(cls, name, func, arg_pos=0): """ Add a method `name` to the class, which returns the value of `func`, called with the proxied value inserted at `arg_pos` """ @wraps(func) def proxied(self, *args, **kwargs): args = list(args) ar...
python
def add_proxy_meth(cls, name, func, arg_pos=0): """ Add a method `name` to the class, which returns the value of `func`, called with the proxied value inserted at `arg_pos` """ @wraps(func) def proxied(self, *args, **kwargs): args = list(args) ar...
[ "def", "add_proxy_meth", "(", "cls", ",", "name", ",", "func", ",", "arg_pos", "=", "0", ")", ":", "@", "wraps", "(", "func", ")", "def", "proxied", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "args", "=", "list", "(", "ar...
Add a method `name` to the class, which returns the value of `func`, called with the proxied value inserted at `arg_pos`
[ "Add", "a", "method", "name", "to", "the", "class", "which", "returns", "the", "value", "of", "func", "called", "with", "the", "proxied", "value", "inserted", "at", "arg_pos" ]
train
https://github.com/gazpachoking/jsonref/blob/066132e527f8115f75bcadfd0eca12f8973a6309/proxytypes.py#L192-L206
gazpachoking/jsonref
jsonref.py
load
def load(fp, base_uri="", loader=None, jsonschema=False, load_on_repr=True, **kwargs): """ Drop in replacement for :func:`json.load`, where JSON references are proxied to their referent data. :param fp: File-like object containing JSON document :param kwargs: This function takes any of the keyword ...
python
def load(fp, base_uri="", loader=None, jsonschema=False, load_on_repr=True, **kwargs): """ Drop in replacement for :func:`json.load`, where JSON references are proxied to their referent data. :param fp: File-like object containing JSON document :param kwargs: This function takes any of the keyword ...
[ "def", "load", "(", "fp", ",", "base_uri", "=", "\"\"", ",", "loader", "=", "None", ",", "jsonschema", "=", "False", ",", "load_on_repr", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "loader", "is", "None", ":", "loader", "=", "functools", ...
Drop in replacement for :func:`json.load`, where JSON references are proxied to their referent data. :param fp: File-like object containing JSON document :param kwargs: This function takes any of the keyword arguments from :meth:`JsonRef.replace_refs`. Any other keyword arguments will be passed to ...
[ "Drop", "in", "replacement", "for", ":", "func", ":", "json", ".", "load", "where", "JSON", "references", "are", "proxied", "to", "their", "referent", "data", "." ]
train
https://github.com/gazpachoking/jsonref/blob/066132e527f8115f75bcadfd0eca12f8973a6309/jsonref.py#L324-L345
gazpachoking/jsonref
jsonref.py
loads
def loads(s, base_uri="", loader=None, jsonschema=False, load_on_repr=True, **kwargs): """ Drop in replacement for :func:`json.loads`, where JSON references are proxied to their referent data. :param s: String containing JSON document :param kwargs: This function takes any of the keyword arguments ...
python
def loads(s, base_uri="", loader=None, jsonschema=False, load_on_repr=True, **kwargs): """ Drop in replacement for :func:`json.loads`, where JSON references are proxied to their referent data. :param s: String containing JSON document :param kwargs: This function takes any of the keyword arguments ...
[ "def", "loads", "(", "s", ",", "base_uri", "=", "\"\"", ",", "loader", "=", "None", ",", "jsonschema", "=", "False", ",", "load_on_repr", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "loader", "is", "None", ":", "loader", "=", "functools", ...
Drop in replacement for :func:`json.loads`, where JSON references are proxied to their referent data. :param s: String containing JSON document :param kwargs: This function takes any of the keyword arguments from :meth:`JsonRef.replace_refs`. Any other keyword arguments will be passed to :f...
[ "Drop", "in", "replacement", "for", ":", "func", ":", "json", ".", "loads", "where", "JSON", "references", "are", "proxied", "to", "their", "referent", "data", "." ]
train
https://github.com/gazpachoking/jsonref/blob/066132e527f8115f75bcadfd0eca12f8973a6309/jsonref.py#L348-L369
gazpachoking/jsonref
jsonref.py
load_uri
def load_uri(uri, base_uri=None, loader=None, jsonschema=False, load_on_repr=True): """ Load JSON data from ``uri`` with JSON references proxied to their referent data. :param uri: URI to fetch the JSON from :param kwargs: This function takes any of the keyword arguments from :meth:`JsonRef...
python
def load_uri(uri, base_uri=None, loader=None, jsonschema=False, load_on_repr=True): """ Load JSON data from ``uri`` with JSON references proxied to their referent data. :param uri: URI to fetch the JSON from :param kwargs: This function takes any of the keyword arguments from :meth:`JsonRef...
[ "def", "load_uri", "(", "uri", ",", "base_uri", "=", "None", ",", "loader", "=", "None", ",", "jsonschema", "=", "False", ",", "load_on_repr", "=", "True", ")", ":", "if", "loader", "is", "None", ":", "loader", "=", "jsonloader", "if", "base_uri", "is"...
Load JSON data from ``uri`` with JSON references proxied to their referent data. :param uri: URI to fetch the JSON from :param kwargs: This function takes any of the keyword arguments from :meth:`JsonRef.replace_refs`
[ "Load", "JSON", "data", "from", "uri", "with", "JSON", "references", "proxied", "to", "their", "referent", "data", "." ]
train
https://github.com/gazpachoking/jsonref/blob/066132e527f8115f75bcadfd0eca12f8973a6309/jsonref.py#L372-L394
gazpachoking/jsonref
jsonref.py
dumps
def dumps(obj, **kwargs): """ Serialize `obj`, which may contain :class:`JsonRef` objects, to a JSON formatted string. `JsonRef` objects will be dumped as the original reference object they were created from. :param obj: Object to serialize :param kwargs: Keyword arguments are the same as to :f...
python
def dumps(obj, **kwargs): """ Serialize `obj`, which may contain :class:`JsonRef` objects, to a JSON formatted string. `JsonRef` objects will be dumped as the original reference object they were created from. :param obj: Object to serialize :param kwargs: Keyword arguments are the same as to :f...
[ "def", "dumps", "(", "obj", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"cls\"", "]", "=", "_ref_encoder_factory", "(", "kwargs", ".", "get", "(", "\"cls\"", ",", "json", ".", "JSONEncoder", ")", ")", "return", "json", ".", "dumps", "(", "obj...
Serialize `obj`, which may contain :class:`JsonRef` objects, to a JSON formatted string. `JsonRef` objects will be dumped as the original reference object they were created from. :param obj: Object to serialize :param kwargs: Keyword arguments are the same as to :func:`json.dumps`
[ "Serialize", "obj", "which", "may", "contain", ":", "class", ":", "JsonRef", "objects", "to", "a", "JSON", "formatted", "string", ".", "JsonRef", "objects", "will", "be", "dumped", "as", "the", "original", "reference", "object", "they", "were", "created", "f...
train
https://github.com/gazpachoking/jsonref/blob/066132e527f8115f75bcadfd0eca12f8973a6309/jsonref.py#L413-L424
gazpachoking/jsonref
jsonref.py
JsonRef.replace_refs
def replace_refs(cls, obj, _recursive=False, **kwargs): """ Returns a deep copy of `obj` with all contained JSON reference objects replaced with :class:`JsonRef` instances. :param obj: If this is a JSON reference object, a :class:`JsonRef` instance will be created. If `obj` ...
python
def replace_refs(cls, obj, _recursive=False, **kwargs): """ Returns a deep copy of `obj` with all contained JSON reference objects replaced with :class:`JsonRef` instances. :param obj: If this is a JSON reference object, a :class:`JsonRef` instance will be created. If `obj` ...
[ "def", "replace_refs", "(", "cls", ",", "obj", ",", "_recursive", "=", "False", ",", "*", "*", "kwargs", ")", ":", "store", "=", "kwargs", ".", "setdefault", "(", "\"_store\"", ",", "_URIDict", "(", ")", ")", "base_uri", ",", "frag", "=", "urlparse", ...
Returns a deep copy of `obj` with all contained JSON reference objects replaced with :class:`JsonRef` instances. :param obj: If this is a JSON reference object, a :class:`JsonRef` instance will be created. If `obj` is not a JSON reference object, a deep copy of it will be create...
[ "Returns", "a", "deep", "copy", "of", "obj", "with", "all", "contained", "JSON", "reference", "objects", "replaced", "with", ":", "class", ":", "JsonRef", "instances", "." ]
train
https://github.com/gazpachoking/jsonref/blob/066132e527f8115f75bcadfd0eca12f8973a6309/jsonref.py#L70-L130
gazpachoking/jsonref
jsonref.py
JsonRef.resolve_pointer
def resolve_pointer(self, document, pointer): """ Resolve a json pointer ``pointer`` within the referenced ``document``. :argument document: the referent document :argument str pointer: a json pointer URI fragment to resolve within it """ # Do only split at single forwa...
python
def resolve_pointer(self, document, pointer): """ Resolve a json pointer ``pointer`` within the referenced ``document``. :argument document: the referent document :argument str pointer: a json pointer URI fragment to resolve within it """ # Do only split at single forwa...
[ "def", "resolve_pointer", "(", "self", ",", "document", ",", "pointer", ")", ":", "# Do only split at single forward slashes which are not prefixed by a caret", "parts", "=", "re", ".", "split", "(", "r\"(?<!\\^)/\"", ",", "unquote", "(", "pointer", ".", "lstrip", "("...
Resolve a json pointer ``pointer`` within the referenced ``document``. :argument document: the referent document :argument str pointer: a json pointer URI fragment to resolve within it
[ "Resolve", "a", "json", "pointer", "pointer", "within", "the", "referenced", "document", "." ]
train
https://github.com/gazpachoking/jsonref/blob/066132e527f8115f75bcadfd0eca12f8973a6309/jsonref.py#L191-L220
Iotic-Labs/py-ubjson
ubjson/encoder.py
dump
def dump(obj, fp, container_count=False, sort_keys=False, no_float32=True, default=None): """Writes the given object as UBJSON to the provided file-like object Args: obj: The object to encode fp: write([size])-able object container_count (bool): Specify length for container types (inclu...
python
def dump(obj, fp, container_count=False, sort_keys=False, no_float32=True, default=None): """Writes the given object as UBJSON to the provided file-like object Args: obj: The object to encode fp: write([size])-able object container_count (bool): Specify length for container types (inclu...
[ "def", "dump", "(", "obj", ",", "fp", ",", "container_count", "=", "False", ",", "sort_keys", "=", "False", ",", "no_float32", "=", "True", ",", "default", "=", "None", ")", ":", "if", "not", "callable", "(", "fp", ".", "write", ")", ":", "raise", ...
Writes the given object as UBJSON to the provided file-like object Args: obj: The object to encode fp: write([size])-able object container_count (bool): Specify length for container types (including for empty ones). This can aid decoding speed ...
[ "Writes", "the", "given", "object", "as", "UBJSON", "to", "the", "provided", "file", "-", "like", "object" ]
train
https://github.com/Iotic-Labs/py-ubjson/blob/80dcacbc7bba1759c69759fb3109ac1c6574da68/ubjson/encoder.py#L233-L305
Iotic-Labs/py-ubjson
ubjson/encoder.py
dumpb
def dumpb(obj, container_count=False, sort_keys=False, no_float32=True, default=None): """Returns the given object as UBJSON in a bytes instance. See dump() for available arguments.""" with BytesIO() as fp: dump(obj, fp, container_count=container_count, sort_keys=sort_keys, no_float32=no_float32,...
python
def dumpb(obj, container_count=False, sort_keys=False, no_float32=True, default=None): """Returns the given object as UBJSON in a bytes instance. See dump() for available arguments.""" with BytesIO() as fp: dump(obj, fp, container_count=container_count, sort_keys=sort_keys, no_float32=no_float32,...
[ "def", "dumpb", "(", "obj", ",", "container_count", "=", "False", ",", "sort_keys", "=", "False", ",", "no_float32", "=", "True", ",", "default", "=", "None", ")", ":", "with", "BytesIO", "(", ")", "as", "fp", ":", "dump", "(", "obj", ",", "fp", ",...
Returns the given object as UBJSON in a bytes instance. See dump() for available arguments.
[ "Returns", "the", "given", "object", "as", "UBJSON", "in", "a", "bytes", "instance", ".", "See", "dump", "()", "for", "available", "arguments", "." ]
train
https://github.com/Iotic-Labs/py-ubjson/blob/80dcacbc7bba1759c69759fb3109ac1c6574da68/ubjson/encoder.py#L308-L313
Iotic-Labs/py-ubjson
ez_setup.py
_resolve_version
def _resolve_version(version): """ Resolve LATEST version """ if version is not LATEST: return version resp = urlopen('https://pypi.python.org/pypi/setuptools/json') with contextlib.closing(resp): try: charset = resp.info().get_content_charset() except Except...
python
def _resolve_version(version): """ Resolve LATEST version """ if version is not LATEST: return version resp = urlopen('https://pypi.python.org/pypi/setuptools/json') with contextlib.closing(resp): try: charset = resp.info().get_content_charset() except Except...
[ "def", "_resolve_version", "(", "version", ")", ":", "if", "version", "is", "not", "LATEST", ":", "return", "version", "resp", "=", "urlopen", "(", "'https://pypi.python.org/pypi/setuptools/json'", ")", "with", "contextlib", ".", "closing", "(", "resp", ")", ":"...
Resolve LATEST version
[ "Resolve", "LATEST", "version" ]
train
https://github.com/Iotic-Labs/py-ubjson/blob/80dcacbc7bba1759c69759fb3109ac1c6574da68/ez_setup.py#L340-L357
Iotic-Labs/py-ubjson
ubjson/decoder.py
load
def load(fp, no_bytes=False, object_hook=None, object_pairs_hook=None, intern_object_keys=False): """Decodes and returns UBJSON from the given file-like object Args: fp: read([size])-able object no_bytes (bool): If set, typed UBJSON arrays (uint8) will not be converted ...
python
def load(fp, no_bytes=False, object_hook=None, object_pairs_hook=None, intern_object_keys=False): """Decodes and returns UBJSON from the given file-like object Args: fp: read([size])-able object no_bytes (bool): If set, typed UBJSON arrays (uint8) will not be converted ...
[ "def", "load", "(", "fp", ",", "no_bytes", "=", "False", ",", "object_hook", "=", "None", ",", "object_pairs_hook", "=", "None", ",", "intern_object_keys", "=", "False", ")", ":", "if", "object_pairs_hook", "is", "None", "and", "object_hook", "is", "None", ...
Decodes and returns UBJSON from the given file-like object Args: fp: read([size])-able object no_bytes (bool): If set, typed UBJSON arrays (uint8) will not be converted to a bytes instance and instead treated like any other array (i.e. result in a l...
[ "Decodes", "and", "returns", "UBJSON", "from", "the", "given", "file", "-", "like", "object" ]
train
https://github.com/Iotic-Labs/py-ubjson/blob/80dcacbc7bba1759c69759fb3109ac1c6574da68/ubjson/decoder.py#L307-L383
Iotic-Labs/py-ubjson
ubjson/decoder.py
loadb
def loadb(chars, no_bytes=False, object_hook=None, object_pairs_hook=None, intern_object_keys=False): """Decodes and returns UBJSON from the given bytes or bytesarray object. See load() for available arguments.""" with BytesIO(chars) as fp: return load(fp, no_bytes=no_bytes, object_hook=object_ho...
python
def loadb(chars, no_bytes=False, object_hook=None, object_pairs_hook=None, intern_object_keys=False): """Decodes and returns UBJSON from the given bytes or bytesarray object. See load() for available arguments.""" with BytesIO(chars) as fp: return load(fp, no_bytes=no_bytes, object_hook=object_ho...
[ "def", "loadb", "(", "chars", ",", "no_bytes", "=", "False", ",", "object_hook", "=", "None", ",", "object_pairs_hook", "=", "None", ",", "intern_object_keys", "=", "False", ")", ":", "with", "BytesIO", "(", "chars", ")", "as", "fp", ":", "return", "load...
Decodes and returns UBJSON from the given bytes or bytesarray object. See load() for available arguments.
[ "Decodes", "and", "returns", "UBJSON", "from", "the", "given", "bytes", "or", "bytesarray", "object", ".", "See", "load", "()", "for", "available", "arguments", "." ]
train
https://github.com/Iotic-Labs/py-ubjson/blob/80dcacbc7bba1759c69759fb3109ac1c6574da68/ubjson/decoder.py#L386-L391
jborean93/requests-credssp
requests_credssp/asn_structures.py
TSRequest.check_error_code
def check_error_code(self): """ For CredSSP version of 3 or newer, the server can response with an NtStatus error code with details of what error occurred. This method will check if the error code exists and throws an NTStatusException if it is no STATUS_SUCCESS. """ ...
python
def check_error_code(self): """ For CredSSP version of 3 or newer, the server can response with an NtStatus error code with details of what error occurred. This method will check if the error code exists and throws an NTStatusException if it is no STATUS_SUCCESS. """ ...
[ "def", "check_error_code", "(", "self", ")", ":", "# start off with STATUS_SUCCESS as a baseline", "status", "=", "NtStatusCodes", ".", "STATUS_SUCCESS", "error_code", "=", "self", "[", "'errorCode'", "]", "if", "error_code", ".", "isValue", ":", "# ASN.1 Integer is sto...
For CredSSP version of 3 or newer, the server can response with an NtStatus error code with details of what error occurred. This method will check if the error code exists and throws an NTStatusException if it is no STATUS_SUCCESS.
[ "For", "CredSSP", "version", "of", "3", "or", "newer", "the", "server", "can", "response", "with", "an", "NtStatus", "error", "code", "with", "details", "of", "what", "error", "occurred", ".", "This", "method", "will", "check", "if", "the", "error", "code"...
train
https://github.com/jborean93/requests-credssp/blob/470db8d74dff919da67cf382e9ff784d4e8dd053/requests_credssp/asn_structures.py#L108-L125
jborean93/requests-credssp
requests_credssp/spnego.py
get_auth_context
def get_auth_context(hostname, username, password, auth_mech): """ Returns an AuthContext used in the CredSSP authentication process and to wrap/unwrap tokens sent to and from the client. This step get's the context based on the auth_mech configured and what is available on the server. It tries to f...
python
def get_auth_context(hostname, username, password, auth_mech): """ Returns an AuthContext used in the CredSSP authentication process and to wrap/unwrap tokens sent to and from the client. This step get's the context based on the auth_mech configured and what is available on the server. It tries to f...
[ "def", "get_auth_context", "(", "hostname", ",", "username", ",", "password", ",", "auth_mech", ")", ":", "if", "auth_mech", "not", "in", "[", "\"auto\"", ",", "\"ntlm\"", ",", "\"kerberos\"", "]", ":", "raise", "InvalidConfigurationException", "(", "\"Invalid a...
Returns an AuthContext used in the CredSSP authentication process and to wrap/unwrap tokens sent to and from the client. This step get's the context based on the auth_mech configured and what is available on the server. It tries to favour system libraries like SSPI (Windows) or GSSAPI (Unix) if possible...
[ "Returns", "an", "AuthContext", "used", "in", "the", "CredSSP", "authentication", "process", "and", "to", "wrap", "/", "unwrap", "tokens", "sent", "to", "and", "from", "the", "client", ".", "This", "step", "get", "s", "the", "context", "based", "on", "the"...
train
https://github.com/jborean93/requests-credssp/blob/470db8d74dff919da67cf382e9ff784d4e8dd053/requests_credssp/spnego.py#L34-L129
jborean93/requests-credssp
requests_credssp/spnego.py
GSSAPIContext.get_mechs_available
def get_mechs_available(): """ Returns a list of auth mechanisms that are available to the local GSSAPI instance. Because we are interacting with Windows, we only care if SPNEGO, Kerberos and NTLM are available where NTLM is the only wildcard that may not be available by default....
python
def get_mechs_available(): """ Returns a list of auth mechanisms that are available to the local GSSAPI instance. Because we are interacting with Windows, we only care if SPNEGO, Kerberos and NTLM are available where NTLM is the only wildcard that may not be available by default....
[ "def", "get_mechs_available", "(", ")", ":", "ntlm_oid", "=", "GSSAPIContext", ".", "_AUTH_MECHANISMS", "[", "'ntlm'", "]", "ntlm_mech", "=", "gssapi", ".", "OID", ".", "from_int_seq", "(", "ntlm_oid", ")", "# GSS_NTLMSSP_RESET_CRYPTO_OID_LENGTH", "# github.com/simo5/...
Returns a list of auth mechanisms that are available to the local GSSAPI instance. Because we are interacting with Windows, we only care if SPNEGO, Kerberos and NTLM are available where NTLM is the only wildcard that may not be available by default. The only NTLM implementation that wor...
[ "Returns", "a", "list", "of", "auth", "mechanisms", "that", "are", "available", "to", "the", "local", "GSSAPI", "instance", ".", "Because", "we", "are", "interacting", "with", "Windows", "we", "only", "care", "if", "SPNEGO", "Kerberos", "and", "NTLM", "are",...
train
https://github.com/jborean93/requests-credssp/blob/470db8d74dff919da67cf382e9ff784d4e8dd053/requests_credssp/spnego.py#L397-L440
jborean93/requests-credssp
requests_credssp/credssp.py
CredSSPContext.credssp_generator
def credssp_generator(self): """ [MS-CSSP] 3.1.5 Processing Events and Sequencing Rules https://msdn.microsoft.com/en-us/library/cc226791.aspx Generator function that yields each CredSSP token to sent to the server. CredSSP has multiple steps that must be run for the client to ...
python
def credssp_generator(self): """ [MS-CSSP] 3.1.5 Processing Events and Sequencing Rules https://msdn.microsoft.com/en-us/library/cc226791.aspx Generator function that yields each CredSSP token to sent to the server. CredSSP has multiple steps that must be run for the client to ...
[ "def", "credssp_generator", "(", "self", ")", ":", "log", ".", "debug", "(", "\"Starting TLS handshake process\"", ")", "self", ".", "tls_connection", "=", "SSL", ".", "Connection", "(", "self", ".", "tls_context", ")", "self", ".", "tls_connection", ".", "set...
[MS-CSSP] 3.1.5 Processing Events and Sequencing Rules https://msdn.microsoft.com/en-us/library/cc226791.aspx Generator function that yields each CredSSP token to sent to the server. CredSSP has multiple steps that must be run for the client to successfully authenticate with the server ...
[ "[", "MS", "-", "CSSP", "]", "3", ".", "1", ".", "5", "Processing", "Events", "and", "Sequencing", "Rules", "https", ":", "//", "msdn", ".", "microsoft", ".", "com", "/", "en", "-", "us", "/", "library", "/", "cc226791", ".", "aspx" ]
train
https://github.com/jborean93/requests-credssp/blob/470db8d74dff919da67cf382e9ff784d4e8dd053/requests_credssp/credssp.py#L68-L173
jborean93/requests-credssp
requests_credssp/credssp.py
CredSSPContext._build_pub_key_auth
def _build_pub_key_auth(self, context, nonce, auth_token, public_key): """ [MS-CSSP] 3.1.5 Processing Events and Sequencing Rules - Step 3 https://msdn.microsoft.com/en-us/library/cc226791.aspx This step sends the final SPNEGO token to the server if required and computes the val...
python
def _build_pub_key_auth(self, context, nonce, auth_token, public_key): """ [MS-CSSP] 3.1.5 Processing Events and Sequencing Rules - Step 3 https://msdn.microsoft.com/en-us/library/cc226791.aspx This step sends the final SPNEGO token to the server if required and computes the val...
[ "def", "_build_pub_key_auth", "(", "self", ",", "context", ",", "nonce", ",", "auth_token", ",", "public_key", ")", ":", "ts_request", "=", "TSRequest", "(", ")", "if", "auth_token", "is", "not", "None", ":", "nego_token", "=", "NegoToken", "(", ")", "nego...
[MS-CSSP] 3.1.5 Processing Events and Sequencing Rules - Step 3 https://msdn.microsoft.com/en-us/library/cc226791.aspx This step sends the final SPNEGO token to the server if required and computes the value for the pubKeyAuth field for the protocol version negotiated. The forma...
[ "[", "MS", "-", "CSSP", "]", "3", ".", "1", ".", "5", "Processing", "Events", "and", "Sequencing", "Rules", "-", "Step", "3", "https", ":", "//", "msdn", ".", "microsoft", ".", "com", "/", "en", "-", "us", "/", "library", "/", "cc226791", ".", "a...
train
https://github.com/jborean93/requests-credssp/blob/470db8d74dff919da67cf382e9ff784d4e8dd053/requests_credssp/credssp.py#L175-L221
jborean93/requests-credssp
requests_credssp/credssp.py
CredSSPContext._verify_public_keys
def _verify_public_keys(self, nonce, server_key, public_key): """ [MS-CSSP] 3.1.5 Processing Events and Sequencing Rules - Step 4 https://msdn.microsoft.com/en-us/library/cc226791.aspx The rules vary depending on the server version For version 2 to 4: After the server r...
python
def _verify_public_keys(self, nonce, server_key, public_key): """ [MS-CSSP] 3.1.5 Processing Events and Sequencing Rules - Step 4 https://msdn.microsoft.com/en-us/library/cc226791.aspx The rules vary depending on the server version For version 2 to 4: After the server r...
[ "def", "_verify_public_keys", "(", "self", ",", "nonce", ",", "server_key", ",", "public_key", ")", ":", "if", "nonce", "is", "not", "None", ":", "hash_input", "=", "b\"CredSSP Server-To-Client Binding Hash\\x00\"", "+", "nonce", "+", "public_key", "actual", "=", ...
[MS-CSSP] 3.1.5 Processing Events and Sequencing Rules - Step 4 https://msdn.microsoft.com/en-us/library/cc226791.aspx The rules vary depending on the server version For version 2 to 4: After the server received the public key in Step 3 it verifies the key with what was in the ...
[ "[", "MS", "-", "CSSP", "]", "3", ".", "1", ".", "5", "Processing", "Events", "and", "Sequencing", "Rules", "-", "Step", "4", "https", ":", "//", "msdn", ".", "microsoft", ".", "com", "/", "en", "-", "us", "/", "library", "/", "cc226791", ".", "a...
train
https://github.com/jborean93/requests-credssp/blob/470db8d74dff919da67cf382e9ff784d4e8dd053/requests_credssp/credssp.py#L223-L265
jborean93/requests-credssp
requests_credssp/credssp.py
CredSSPContext._get_encrypted_credentials
def _get_encrypted_credentials(self, context): """ [MS-CSSP] 3.1.5 Processing Events and Sequencing Rules - Step 5 https://msdn.microsoft.com/en-us/library/cc226791.aspx After the client has verified the server's authenticity, it encrypts the user's credentials with the authenti...
python
def _get_encrypted_credentials(self, context): """ [MS-CSSP] 3.1.5 Processing Events and Sequencing Rules - Step 5 https://msdn.microsoft.com/en-us/library/cc226791.aspx After the client has verified the server's authenticity, it encrypts the user's credentials with the authenti...
[ "def", "_get_encrypted_credentials", "(", "self", ",", "context", ")", ":", "ts_password", "=", "TSPasswordCreds", "(", ")", "ts_password", "[", "'domainName'", "]", "=", "context", ".", "domain", ".", "encode", "(", "'utf-16-le'", ")", "ts_password", "[", "'u...
[MS-CSSP] 3.1.5 Processing Events and Sequencing Rules - Step 5 https://msdn.microsoft.com/en-us/library/cc226791.aspx After the client has verified the server's authenticity, it encrypts the user's credentials with the authentication protocol's encryption services. The resulting value ...
[ "[", "MS", "-", "CSSP", "]", "3", ".", "1", ".", "5", "Processing", "Events", "and", "Sequencing", "Rules", "-", "Step", "5", "https", ":", "//", "msdn", ".", "microsoft", ".", "com", "/", "en", "-", "us", "/", "library", "/", "cc226791", ".", "a...
train
https://github.com/jborean93/requests-credssp/blob/470db8d74dff919da67cf382e9ff784d4e8dd053/requests_credssp/credssp.py#L267-L294
jborean93/requests-credssp
requests_credssp/credssp.py
CredSSPContext.wrap
def wrap(self, data): """ Encrypts the data in preparation for sending to the server. The data is encrypted using the TLS channel negotiated between the client and the server. :param data: a byte string of data to encrypt :return: a byte string of the encrypted data ...
python
def wrap(self, data): """ Encrypts the data in preparation for sending to the server. The data is encrypted using the TLS channel negotiated between the client and the server. :param data: a byte string of data to encrypt :return: a byte string of the encrypted data ...
[ "def", "wrap", "(", "self", ",", "data", ")", ":", "length", "=", "self", ".", "tls_connection", ".", "send", "(", "data", ")", "encrypted_data", "=", "b''", "counter", "=", "0", "while", "True", ":", "try", ":", "encrypted_chunk", "=", "self", ".", ...
Encrypts the data in preparation for sending to the server. The data is encrypted using the TLS channel negotiated between the client and the server. :param data: a byte string of data to encrypt :return: a byte string of the encrypted data
[ "Encrypts", "the", "data", "in", "preparation", "for", "sending", "to", "the", "server", ".", "The", "data", "is", "encrypted", "using", "the", "TLS", "channel", "negotiated", "between", "the", "client", "and", "the", "server", "." ]
train
https://github.com/jborean93/requests-credssp/blob/470db8d74dff919da67cf382e9ff784d4e8dd053/requests_credssp/credssp.py#L296-L324
jborean93/requests-credssp
requests_credssp/credssp.py
CredSSPContext.unwrap
def unwrap(self, encrypted_data): """ Decrypts the data send by the server using the TLS channel negotiated between the client and the server. :param encrypted_data: the byte string of the encrypted data :return: a byte string of the decrypted data """ length = s...
python
def unwrap(self, encrypted_data): """ Decrypts the data send by the server using the TLS channel negotiated between the client and the server. :param encrypted_data: the byte string of the encrypted data :return: a byte string of the decrypted data """ length = s...
[ "def", "unwrap", "(", "self", ",", "encrypted_data", ")", ":", "length", "=", "self", ".", "tls_connection", ".", "bio_write", "(", "encrypted_data", ")", "data", "=", "b''", "counter", "=", "0", "while", "True", ":", "try", ":", "data_chunk", "=", "self...
Decrypts the data send by the server using the TLS channel negotiated between the client and the server. :param encrypted_data: the byte string of the encrypted data :return: a byte string of the decrypted data
[ "Decrypts", "the", "data", "send", "by", "the", "server", "using", "the", "TLS", "channel", "negotiated", "between", "the", "client", "and", "the", "server", "." ]
train
https://github.com/jborean93/requests-credssp/blob/470db8d74dff919da67cf382e9ff784d4e8dd053/requests_credssp/credssp.py#L326-L349
jborean93/requests-credssp
requests_credssp/credssp.py
CredSSPContext._get_subject_public_key
def _get_subject_public_key(cert): """ Returns the SubjectPublicKey asn.1 field of the SubjectPublicKeyInfo field of the server's certificate. This is used in the server verification steps to thwart MitM attacks. :param cert: X509 certificate from pyOpenSSL .get_peer_certificate...
python
def _get_subject_public_key(cert): """ Returns the SubjectPublicKey asn.1 field of the SubjectPublicKeyInfo field of the server's certificate. This is used in the server verification steps to thwart MitM attacks. :param cert: X509 certificate from pyOpenSSL .get_peer_certificate...
[ "def", "_get_subject_public_key", "(", "cert", ")", ":", "public_key", "=", "cert", ".", "get_pubkey", "(", ")", "cryptographic_key", "=", "public_key", ".", "to_cryptography_key", "(", ")", "subject_public_key", "=", "cryptographic_key", ".", "public_bytes", "(", ...
Returns the SubjectPublicKey asn.1 field of the SubjectPublicKeyInfo field of the server's certificate. This is used in the server verification steps to thwart MitM attacks. :param cert: X509 certificate from pyOpenSSL .get_peer_certificate() :return: byte string of the asn.1 DER encode...
[ "Returns", "the", "SubjectPublicKey", "asn", ".", "1", "field", "of", "the", "SubjectPublicKeyInfo", "field", "of", "the", "server", "s", "certificate", ".", "This", "is", "used", "in", "the", "server", "verification", "steps", "to", "thwart", "MitM", "attacks...
train
https://github.com/jborean93/requests-credssp/blob/470db8d74dff919da67cf382e9ff784d4e8dd053/requests_credssp/credssp.py#L352-L365
msuozzo/Lector
lector/reader.py
_KindleCloudReaderBrowser._to_reader_home
def _to_reader_home(self): """Navigate to the Cloud Reader library page. Raises: BrowserError: If the KCR homepage could not be loaded. ConnectionError: If there was a connection error. """ # NOTE: Prevents QueryInterface error caused by getting a URL # while switched to an iframe s...
python
def _to_reader_home(self): """Navigate to the Cloud Reader library page. Raises: BrowserError: If the KCR homepage could not be loaded. ConnectionError: If there was a connection error. """ # NOTE: Prevents QueryInterface error caused by getting a URL # while switched to an iframe s...
[ "def", "_to_reader_home", "(", "self", ")", ":", "# NOTE: Prevents QueryInterface error caused by getting a URL", "# while switched to an iframe", "self", ".", "switch_to_default_content", "(", ")", "self", ".", "get", "(", "_KindleCloudReaderBrowser", ".", "_CLOUD_READER_URL",...
Navigate to the Cloud Reader library page. Raises: BrowserError: If the KCR homepage could not be loaded. ConnectionError: If there was a connection error.
[ "Navigate", "to", "the", "Cloud", "Reader", "library", "page", "." ]
train
https://github.com/msuozzo/Lector/blob/1570f7734a1c68f294648f44088a7ccb09c26241/lector/reader.py#L199-L225
msuozzo/Lector
lector/reader.py
_KindleCloudReaderBrowser._login
def _login(self, max_tries=2): """Logs in to Kindle Cloud Reader. Args: max_tries: The maximum number of login attempts that will be made. Raises: BrowserError: If method called when browser not at a signin URL. LoginError: If login unsuccessful after `max_tries` attempts. """ i...
python
def _login(self, max_tries=2): """Logs in to Kindle Cloud Reader. Args: max_tries: The maximum number of login attempts that will be made. Raises: BrowserError: If method called when browser not at a signin URL. LoginError: If login unsuccessful after `max_tries` attempts. """ i...
[ "def", "_login", "(", "self", ",", "max_tries", "=", "2", ")", ":", "if", "not", "self", ".", "current_url", ".", "startswith", "(", "_KindleCloudReaderBrowser", ".", "_SIGNIN_URL", ")", ":", "raise", "BrowserError", "(", "'Current url \"%s\" is not a signin url (...
Logs in to Kindle Cloud Reader. Args: max_tries: The maximum number of login attempts that will be made. Raises: BrowserError: If method called when browser not at a signin URL. LoginError: If login unsuccessful after `max_tries` attempts.
[ "Logs", "in", "to", "Kindle", "Cloud", "Reader", "." ]
train
https://github.com/msuozzo/Lector/blob/1570f7734a1c68f294648f44088a7ccb09c26241/lector/reader.py#L227-L274
msuozzo/Lector
lector/reader.py
_KindleCloudReaderBrowser._to_reader_frame
def _to_reader_frame(self): """Navigate to the KindleReader iframe.""" reader_frame = 'KindleReaderIFrame' frame_loaded = lambda br: br.find_elements_by_id(reader_frame) self._wait().until(frame_loaded) self.switch_to.frame(reader_frame) # pylint: disable=no-member reader_loaded = lambda br:...
python
def _to_reader_frame(self): """Navigate to the KindleReader iframe.""" reader_frame = 'KindleReaderIFrame' frame_loaded = lambda br: br.find_elements_by_id(reader_frame) self._wait().until(frame_loaded) self.switch_to.frame(reader_frame) # pylint: disable=no-member reader_loaded = lambda br:...
[ "def", "_to_reader_frame", "(", "self", ")", ":", "reader_frame", "=", "'KindleReaderIFrame'", "frame_loaded", "=", "lambda", "br", ":", "br", ".", "find_elements_by_id", "(", "reader_frame", ")", "self", ".", "_wait", "(", ")", ".", "until", "(", "frame_loade...
Navigate to the KindleReader iframe.
[ "Navigate", "to", "the", "KindleReader", "iframe", "." ]
train
https://github.com/msuozzo/Lector/blob/1570f7734a1c68f294648f44088a7ccb09c26241/lector/reader.py#L276-L286
msuozzo/Lector
lector/reader.py
_KindleCloudReaderBrowser._wait_for_js
def _wait_for_js(self): """Wait for the Kindle Cloud Reader JS modules to initialize. These modules provide the interface used to execute API queries. """ # Wait for the Module Manager to load mod_mgr_script = ur"return window.hasOwnProperty('KindleModuleManager');" mod_mgr_loaded = lambda br: ...
python
def _wait_for_js(self): """Wait for the Kindle Cloud Reader JS modules to initialize. These modules provide the interface used to execute API queries. """ # Wait for the Module Manager to load mod_mgr_script = ur"return window.hasOwnProperty('KindleModuleManager');" mod_mgr_loaded = lambda br: ...
[ "def", "_wait_for_js", "(", "self", ")", ":", "# Wait for the Module Manager to load", "mod_mgr_script", "=", "ur\"return window.hasOwnProperty('KindleModuleManager');\"", "mod_mgr_loaded", "=", "lambda", "br", ":", "br", ".", "execute_script", "(", "mod_mgr_script", ")", "...
Wait for the Kindle Cloud Reader JS modules to initialize. These modules provide the interface used to execute API queries.
[ "Wait", "for", "the", "Kindle", "Cloud", "Reader", "JS", "modules", "to", "initialize", "." ]
train
https://github.com/msuozzo/Lector/blob/1570f7734a1c68f294648f44088a7ccb09c26241/lector/reader.py#L288-L314
msuozzo/Lector
lector/reader.py
KindleCloudReaderAPI._get_api_call
def _get_api_call(self, function_name, *args): """Runs an api call with javascript-formatted arguments. Args: function_name: The name of the KindleAPI call to run. *args: Javascript-formatted arguments to pass to the API call. Returns: The result of the API call. Raises: APIEr...
python
def _get_api_call(self, function_name, *args): """Runs an api call with javascript-formatted arguments. Args: function_name: The name of the KindleAPI call to run. *args: Javascript-formatted arguments to pass to the API call. Returns: The result of the API call. Raises: APIEr...
[ "def", "_get_api_call", "(", "self", ",", "function_name", ",", "*", "args", ")", ":", "api_call", "=", "dedent", "(", "\"\"\"\n var done = arguments[0];\n KindleAPI.%(api_call)s(%(args)s).always(function(a) {\n done(a);\n });\n \"\"\"", ")", "%",...
Runs an api call with javascript-formatted arguments. Args: function_name: The name of the KindleAPI call to run. *args: Javascript-formatted arguments to pass to the API call. Returns: The result of the API call. Raises: APIError: If the API call fails or times out.
[ "Runs", "an", "api", "call", "with", "javascript", "-", "formatted", "arguments", "." ]
train
https://github.com/msuozzo/Lector/blob/1570f7734a1c68f294648f44088a7ccb09c26241/lector/reader.py#L328-L355
msuozzo/Lector
lector/reader.py
KindleCloudReaderAPI.get_book_metadata
def get_book_metadata(self, asin): """Returns a book's metadata. Args: asin: The ASIN of the book to be queried. Returns: A `KindleBook` instance corresponding to the book associated with `asin`. """ kbm = self._get_api_call('get_book_metadata', '"%s"' % asin) return KindleCl...
python
def get_book_metadata(self, asin): """Returns a book's metadata. Args: asin: The ASIN of the book to be queried. Returns: A `KindleBook` instance corresponding to the book associated with `asin`. """ kbm = self._get_api_call('get_book_metadata', '"%s"' % asin) return KindleCl...
[ "def", "get_book_metadata", "(", "self", ",", "asin", ")", ":", "kbm", "=", "self", ".", "_get_api_call", "(", "'get_book_metadata'", ",", "'\"%s\"'", "%", "asin", ")", "return", "KindleCloudReaderAPI", ".", "_kbm_to_book", "(", "kbm", ")" ]
Returns a book's metadata. Args: asin: The ASIN of the book to be queried. Returns: A `KindleBook` instance corresponding to the book associated with `asin`.
[ "Returns", "a", "book", "s", "metadata", "." ]
train
https://github.com/msuozzo/Lector/blob/1570f7734a1c68f294648f44088a7ccb09c26241/lector/reader.py#L387-L398
msuozzo/Lector
lector/reader.py
KindleCloudReaderAPI.get_book_progress
def get_book_progress(self, asin): """Returns the progress data available for a book. NOTE: A summary of the two progress formats can be found in the docstring for `ReadingProgress`. Args: asin: The asin of the book to be queried. Returns: A `ReadingProgress` instance corresponding to...
python
def get_book_progress(self, asin): """Returns the progress data available for a book. NOTE: A summary of the two progress formats can be found in the docstring for `ReadingProgress`. Args: asin: The asin of the book to be queried. Returns: A `ReadingProgress` instance corresponding to...
[ "def", "get_book_progress", "(", "self", ",", "asin", ")", ":", "kbp", "=", "self", ".", "_get_api_call", "(", "'get_book_progress'", ",", "'\"%s\"'", "%", "asin", ")", "return", "KindleCloudReaderAPI", ".", "_kbp_to_progress", "(", "kbp", ")" ]
Returns the progress data available for a book. NOTE: A summary of the two progress formats can be found in the docstring for `ReadingProgress`. Args: asin: The asin of the book to be queried. Returns: A `ReadingProgress` instance corresponding to the book associated with `asin`.
[ "Returns", "the", "progress", "data", "available", "for", "a", "book", "." ]
train
https://github.com/msuozzo/Lector/blob/1570f7734a1c68f294648f44088a7ccb09c26241/lector/reader.py#L410-L424
msuozzo/Lector
lector/reader.py
KindleCloudReaderAPI.get_library_progress
def get_library_progress(self): """Returns the reading progress for all books in the kindle library. Returns: A mapping of ASINs to `ReadingProgress` instances corresponding to the books in the current user's library. """ kbp_dict = self._get_api_call('get_library_progress') return {asi...
python
def get_library_progress(self): """Returns the reading progress for all books in the kindle library. Returns: A mapping of ASINs to `ReadingProgress` instances corresponding to the books in the current user's library. """ kbp_dict = self._get_api_call('get_library_progress') return {asi...
[ "def", "get_library_progress", "(", "self", ")", ":", "kbp_dict", "=", "self", ".", "_get_api_call", "(", "'get_library_progress'", ")", "return", "{", "asin", ":", "KindleCloudReaderAPI", ".", "_kbp_to_progress", "(", "kbp", ")", "for", "asin", ",", "kbp", "i...
Returns the reading progress for all books in the kindle library. Returns: A mapping of ASINs to `ReadingProgress` instances corresponding to the books in the current user's library.
[ "Returns", "the", "reading", "progress", "for", "all", "books", "in", "the", "kindle", "library", "." ]
train
https://github.com/msuozzo/Lector/blob/1570f7734a1c68f294648f44088a7ccb09c26241/lector/reader.py#L426-L435
msuozzo/Lector
lector/reader.py
KindleCloudReaderAPI.get_instance
def get_instance(*args, **kwargs): """Context manager for an instance of `KindleCloudReaderAPI`.""" inst = KindleCloudReaderAPI(*args, **kwargs) try: yield inst except Exception: raise finally: inst.close()
python
def get_instance(*args, **kwargs): """Context manager for an instance of `KindleCloudReaderAPI`.""" inst = KindleCloudReaderAPI(*args, **kwargs) try: yield inst except Exception: raise finally: inst.close()
[ "def", "get_instance", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "inst", "=", "KindleCloudReaderAPI", "(", "*", "args", ",", "*", "*", "kwargs", ")", "try", ":", "yield", "inst", "except", "Exception", ":", "raise", "finally", ":", "inst", ...
Context manager for an instance of `KindleCloudReaderAPI`.
[ "Context", "manager", "for", "an", "instance", "of", "KindleCloudReaderAPI", "." ]
train
https://github.com/msuozzo/Lector/blob/1570f7734a1c68f294648f44088a7ccb09c26241/lector/reader.py#L443-L452
alexanderlukanin13/coolname
coolname/loader.py
load_config
def load_config(path): """ Loads configuration from a path. Path can be a json file, or a directory containing config.json and zero or more *.txt files with word lists or phrase lists. Returns config dict. Raises InitializationError when something is wrong. """ path = os.path.abspath(...
python
def load_config(path): """ Loads configuration from a path. Path can be a json file, or a directory containing config.json and zero or more *.txt files with word lists or phrase lists. Returns config dict. Raises InitializationError when something is wrong. """ path = os.path.abspath(...
[ "def", "load_config", "(", "path", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "config", ",", "wordlists", "=", "_load_data", "(", "path", ")", "elif", ...
Loads configuration from a path. Path can be a json file, or a directory containing config.json and zero or more *.txt files with word lists or phrase lists. Returns config dict. Raises InitializationError when something is wrong.
[ "Loads", "configuration", "from", "a", "path", "." ]
train
https://github.com/alexanderlukanin13/coolname/blob/416cc39254ab9e921fd5be77dfe6cdafbad0300c/coolname/loader.py#L19-L45
alexanderlukanin13/coolname
coolname/loader.py
_load_data
def _load_data(path): """ Loads data from a directory. Returns tuple (config_dict, wordlists). Raises Exception on failure (e.g. if data is corrupted). """ path = os.path.abspath(path) if not os.path.isdir(path): raise InitializationError('Directory not found: {0}'.format(path)) ...
python
def _load_data(path): """ Loads data from a directory. Returns tuple (config_dict, wordlists). Raises Exception on failure (e.g. if data is corrupted). """ path = os.path.abspath(path) if not os.path.isdir(path): raise InitializationError('Directory not found: {0}'.format(path)) ...
[ "def", "_load_data", "(", "path", ")", ":", "path", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "raise", "InitializationError", "(", "'Directory not found: {0}'", ".", "...
Loads data from a directory. Returns tuple (config_dict, wordlists). Raises Exception on failure (e.g. if data is corrupted).
[ "Loads", "data", "from", "a", "directory", ".", "Returns", "tuple", "(", "config_dict", "wordlists", ")", ".", "Raises", "Exception", "on", "failure", "(", "e", ".", "g", ".", "if", "data", "is", "corrupted", ")", "." ]
train
https://github.com/alexanderlukanin13/coolname/blob/416cc39254ab9e921fd5be77dfe6cdafbad0300c/coolname/loader.py#L48-L69
alexanderlukanin13/coolname
coolname/loader.py
_parse_option
def _parse_option(line): """ Parses option line. Returns (name, value). Raises ValueError on invalid syntax or unknown option. """ match = _OPTION_REGEX.match(line) if not match: raise ValueError('Invalid syntax') for name, type_ in _OPTIONS: if name == match.group(1): ...
python
def _parse_option(line): """ Parses option line. Returns (name, value). Raises ValueError on invalid syntax or unknown option. """ match = _OPTION_REGEX.match(line) if not match: raise ValueError('Invalid syntax') for name, type_ in _OPTIONS: if name == match.group(1): ...
[ "def", "_parse_option", "(", "line", ")", ":", "match", "=", "_OPTION_REGEX", ".", "match", "(", "line", ")", "if", "not", "match", ":", "raise", "ValueError", "(", "'Invalid syntax'", ")", "for", "name", ",", "type_", "in", "_OPTIONS", ":", "if", "name"...
Parses option line. Returns (name, value). Raises ValueError on invalid syntax or unknown option.
[ "Parses", "option", "line", ".", "Returns", "(", "name", "value", ")", ".", "Raises", "ValueError", "on", "invalid", "syntax", "or", "unknown", "option", "." ]
train
https://github.com/alexanderlukanin13/coolname/blob/416cc39254ab9e921fd5be77dfe6cdafbad0300c/coolname/loader.py#L95-L107
alexanderlukanin13/coolname
coolname/loader.py
_load_wordlist
def _load_wordlist(name, stream): """ Loads list of words or phrases from file. Returns "words" or "phrases" dictionary, the same as used in config. Raises Exception if file is missing or invalid. """ items = [] max_length = None multiword = False multiword_start = None number_o...
python
def _load_wordlist(name, stream): """ Loads list of words or phrases from file. Returns "words" or "phrases" dictionary, the same as used in config. Raises Exception if file is missing or invalid. """ items = [] max_length = None multiword = False multiword_start = None number_o...
[ "def", "_load_wordlist", "(", "name", ",", "stream", ")", ":", "items", "=", "[", "]", "max_length", "=", "None", "multiword", "=", "False", "multiword_start", "=", "None", "number_of_words", "=", "None", "for", "i", ",", "line", "in", "enumerate", "(", ...
Loads list of words or phrases from file. Returns "words" or "phrases" dictionary, the same as used in config. Raises Exception if file is missing or invalid.
[ "Loads", "list", "of", "words", "or", "phrases", "from", "file", "." ]
train
https://github.com/alexanderlukanin13/coolname/blob/416cc39254ab9e921fd5be77dfe6cdafbad0300c/coolname/loader.py#L110-L182
alexanderlukanin13/coolname
coolname/impl.py
_validate_config
def _validate_config(config): """ A big and ugly method for config validation. It would be nice to use cerberus, but we don't want to introduce dependencies just for that. """ try: referenced_sublists = set() for key, listdef in list(config.items()): # Check if sectio...
python
def _validate_config(config): """ A big and ugly method for config validation. It would be nice to use cerberus, but we don't want to introduce dependencies just for that. """ try: referenced_sublists = set() for key, listdef in list(config.items()): # Check if sectio...
[ "def", "_validate_config", "(", "config", ")", ":", "try", ":", "referenced_sublists", "=", "set", "(", ")", "for", "key", ",", "listdef", "in", "list", "(", "config", ".", "items", "(", ")", ")", ":", "# Check if section is a list", "if", "not", "isinstan...
A big and ugly method for config validation. It would be nice to use cerberus, but we don't want to introduce dependencies just for that.
[ "A", "big", "and", "ugly", "method", "for", "config", "validation", ".", "It", "would", "be", "nice", "to", "use", "cerberus", "but", "we", "don", "t", "want", "to", "introduce", "dependencies", "just", "for", "that", "." ]
train
https://github.com/alexanderlukanin13/coolname/blob/416cc39254ab9e921fd5be77dfe6cdafbad0300c/coolname/impl.py#L403-L505
alexanderlukanin13/coolname
coolname/impl.py
_create_lists
def _create_lists(config, results, current, stack, inside_cartesian=None): """ An ugly recursive method to transform config dict into a tree of AbstractNestedList. """ # Have we done it already? try: return results[current] except KeyError: pass # Check recursion depth an...
python
def _create_lists(config, results, current, stack, inside_cartesian=None): """ An ugly recursive method to transform config dict into a tree of AbstractNestedList. """ # Have we done it already? try: return results[current] except KeyError: pass # Check recursion depth an...
[ "def", "_create_lists", "(", "config", ",", "results", ",", "current", ",", "stack", ",", "inside_cartesian", "=", "None", ")", ":", "# Have we done it already?", "try", ":", "return", "results", "[", "current", "]", "except", "KeyError", ":", "pass", "# Check...
An ugly recursive method to transform config dict into a tree of AbstractNestedList.
[ "An", "ugly", "recursive", "method", "to", "transform", "config", "dict", "into", "a", "tree", "of", "AbstractNestedList", "." ]
train
https://github.com/alexanderlukanin13/coolname/blob/416cc39254ab9e921fd5be77dfe6cdafbad0300c/coolname/impl.py#L508-L559
alexanderlukanin13/coolname
coolname/impl.py
RandomGenerator.generate
def generate(self, pattern=None): """ Generates and returns random name as a list of strings. """ lst = self._lists[pattern] while True: result = lst[self._randrange(lst.length)] # 1. Check that there are no duplicates # 2. Check that there are...
python
def generate(self, pattern=None): """ Generates and returns random name as a list of strings. """ lst = self._lists[pattern] while True: result = lst[self._randrange(lst.length)] # 1. Check that there are no duplicates # 2. Check that there are...
[ "def", "generate", "(", "self", ",", "pattern", "=", "None", ")", ":", "lst", "=", "self", ".", "_lists", "[", "pattern", "]", "while", "True", ":", "result", "=", "lst", "[", "self", ".", "_randrange", "(", "lst", ".", "length", ")", "]", "# 1. Ch...
Generates and returns random name as a list of strings.
[ "Generates", "and", "returns", "random", "name", "as", "a", "list", "of", "strings", "." ]
train
https://github.com/alexanderlukanin13/coolname/blob/416cc39254ab9e921fd5be77dfe6cdafbad0300c/coolname/impl.py#L306-L321
alexanderlukanin13/coolname
coolname/impl.py
RandomGenerator._dump
def _dump(self, stream, pattern=None, object_ids=False): """Dumps current tree into a text stream.""" return self._lists[pattern]._dump(stream, '', object_ids=object_ids)
python
def _dump(self, stream, pattern=None, object_ids=False): """Dumps current tree into a text stream.""" return self._lists[pattern]._dump(stream, '', object_ids=object_ids)
[ "def", "_dump", "(", "self", ",", "stream", ",", "pattern", "=", "None", ",", "object_ids", "=", "False", ")", ":", "return", "self", ".", "_lists", "[", "pattern", "]", ".", "_dump", "(", "stream", ",", "''", ",", "object_ids", "=", "object_ids", ")...
Dumps current tree into a text stream.
[ "Dumps", "current", "tree", "into", "a", "text", "stream", "." ]
train
https://github.com/alexanderlukanin13/coolname/blob/416cc39254ab9e921fd5be77dfe6cdafbad0300c/coolname/impl.py#L337-L339
alexanderlukanin13/coolname
coolname/impl.py
RandomGenerator._check_not_hanging
def _check_not_hanging(self): """ Rough check that generate() will not hang or be very slow. Raises ConfigurationError if generate() spends too much time in retry loop. Issues a warning.warn() if there is a risk of slowdown. """ # (field_name, predicate, warning_msg, exc...
python
def _check_not_hanging(self): """ Rough check that generate() will not hang or be very slow. Raises ConfigurationError if generate() spends too much time in retry loop. Issues a warning.warn() if there is a risk of slowdown. """ # (field_name, predicate, warning_msg, exc...
[ "def", "_check_not_hanging", "(", "self", ")", ":", "# (field_name, predicate, warning_msg, exception_msg)", "# predicate(g) is a function that returns True if generated combination g must be rejected,", "# see checks in generate()", "checks", "=", "[", "]", "# ensure_unique can lead to in...
Rough check that generate() will not hang or be very slow. Raises ConfigurationError if generate() spends too much time in retry loop. Issues a warning.warn() if there is a risk of slowdown.
[ "Rough", "check", "that", "generate", "()", "will", "not", "hang", "or", "be", "very", "slow", "." ]
train
https://github.com/alexanderlukanin13/coolname/blob/416cc39254ab9e921fd5be77dfe6cdafbad0300c/coolname/impl.py#L341-L388
kvesteri/postgresql-audit
postgresql_audit/migrations.py
alter_column
def alter_column(conn, table, column_name, func, schema=None): """ Run given callable against given table and given column in activity table jsonb data columns. This function is useful when you want to reflect type changes in your schema to activity table. In the following example we change the dat...
python
def alter_column(conn, table, column_name, func, schema=None): """ Run given callable against given table and given column in activity table jsonb data columns. This function is useful when you want to reflect type changes in your schema to activity table. In the following example we change the dat...
[ "def", "alter_column", "(", "conn", ",", "table", ",", "column_name", ",", "func", ",", "schema", "=", "None", ")", ":", "activity_table", "=", "get_activity_table", "(", "schema", "=", "schema", ")", "query", "=", "(", "activity_table", ".", "update", "("...
Run given callable against given table and given column in activity table jsonb data columns. This function is useful when you want to reflect type changes in your schema to activity table. In the following example we change the data type of User's age column from string to integer. :: f...
[ "Run", "given", "callable", "against", "given", "table", "and", "given", "column", "in", "activity", "table", "jsonb", "data", "columns", ".", "This", "function", "is", "useful", "when", "you", "want", "to", "reflect", "type", "changes", "in", "your", "schem...
train
https://github.com/kvesteri/postgresql-audit/blob/91b497ced2e04dd44bb757b02983d2a64a2b1514/postgresql_audit/migrations.py#L20-L93
kvesteri/postgresql-audit
postgresql_audit/migrations.py
change_column_name
def change_column_name( conn, table, old_column_name, new_column_name, schema=None ): """ Changes given `activity` jsonb data column key. This function is useful when you want to reflect column name changes to activity table. :: from alembic import op from postgresq...
python
def change_column_name( conn, table, old_column_name, new_column_name, schema=None ): """ Changes given `activity` jsonb data column key. This function is useful when you want to reflect column name changes to activity table. :: from alembic import op from postgresq...
[ "def", "change_column_name", "(", "conn", ",", "table", ",", "old_column_name", ",", "new_column_name", ",", "schema", "=", "None", ")", ":", "activity_table", "=", "get_activity_table", "(", "schema", "=", "schema", ")", "query", "=", "(", "activity_table", "...
Changes given `activity` jsonb data column key. This function is useful when you want to reflect column name changes to activity table. :: from alembic import op from postgresql_audit import change_column_name def upgrade(): op.alter_column( 'my_table', ...
[ "Changes", "given", "activity", "jsonb", "data", "column", "key", ".", "This", "function", "is", "useful", "when", "you", "want", "to", "reflect", "column", "name", "changes", "to", "activity", "table", "." ]
train
https://github.com/kvesteri/postgresql-audit/blob/91b497ced2e04dd44bb757b02983d2a64a2b1514/postgresql_audit/migrations.py#L96-L153
kvesteri/postgresql-audit
postgresql_audit/migrations.py
add_column
def add_column(conn, table, column_name, default_value=None, schema=None): """ Adds given column to `activity` table jsonb data columns. In the following example we reflect the changes made to our schema to activity table. :: import sqlalchemy as sa from alembic import op ...
python
def add_column(conn, table, column_name, default_value=None, schema=None): """ Adds given column to `activity` table jsonb data columns. In the following example we reflect the changes made to our schema to activity table. :: import sqlalchemy as sa from alembic import op ...
[ "def", "add_column", "(", "conn", ",", "table", ",", "column_name", ",", "default_value", "=", "None", ",", "schema", "=", "None", ")", ":", "activity_table", "=", "get_activity_table", "(", "schema", "=", "schema", ")", "data", "=", "{", "column_name", ":...
Adds given column to `activity` table jsonb data columns. In the following example we reflect the changes made to our schema to activity table. :: import sqlalchemy as sa from alembic import op from postgresql_audit import add_column def upgrade(): op.add_col...
[ "Adds", "given", "column", "to", "activity", "table", "jsonb", "data", "columns", "." ]
train
https://github.com/kvesteri/postgresql-audit/blob/91b497ced2e04dd44bb757b02983d2a64a2b1514/postgresql_audit/migrations.py#L156-L220