partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
dict_as_tuple_list
Format a dict to a list of tuples :param d: the dictionary :param as_list: return a list of lists rather than a list of tuples :return: formatted dictionary list
deeputils/common.py
def dict_as_tuple_list(d, as_list=False): """ Format a dict to a list of tuples :param d: the dictionary :param as_list: return a list of lists rather than a list of tuples :return: formatted dictionary list """ dd = list() for k, v in d.items(): dd.append([k, v] if as_list else ...
def dict_as_tuple_list(d, as_list=False): """ Format a dict to a list of tuples :param d: the dictionary :param as_list: return a list of lists rather than a list of tuples :return: formatted dictionary list """ dd = list() for k, v in d.items(): dd.append([k, v] if as_list else ...
[ "Format", "a", "dict", "to", "a", "list", "of", "tuples", ":", "param", "d", ":", "the", "dictionary", ":", "param", "as_list", ":", "return", "a", "list", "of", "lists", "rather", "than", "a", "list", "of", "tuples", ":", "return", ":", "formatted", ...
valency/deeputils
python
https://github.com/valency/deeputils/blob/27efd91668de0223ed8b07cfadf2151632521520/deeputils/common.py#L199-L209
[ "def", "dict_as_tuple_list", "(", "d", ",", "as_list", "=", "False", ")", ":", "dd", "=", "list", "(", ")", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", ":", "dd", ".", "append", "(", "[", "k", ",", "v", "]", "if", "as_list", "els...
27efd91668de0223ed8b07cfadf2151632521520
valid
tuple_search
Search tuple array by index and value :param t: tuple array :param i: index of the value in each tuple :param v: value :return: the first tuple in the array with the specific index / value
deeputils/common.py
def tuple_search(t, i, v): """ Search tuple array by index and value :param t: tuple array :param i: index of the value in each tuple :param v: value :return: the first tuple in the array with the specific index / value """ for e in t: if e[i] == v: return e retur...
def tuple_search(t, i, v): """ Search tuple array by index and value :param t: tuple array :param i: index of the value in each tuple :param v: value :return: the first tuple in the array with the specific index / value """ for e in t: if e[i] == v: return e retur...
[ "Search", "tuple", "array", "by", "index", "and", "value", ":", "param", "t", ":", "tuple", "array", ":", "param", "i", ":", "index", "of", "the", "value", "in", "each", "tuple", ":", "param", "v", ":", "value", ":", "return", ":", "the", "first", ...
valency/deeputils
python
https://github.com/valency/deeputils/blob/27efd91668de0223ed8b07cfadf2151632521520/deeputils/common.py#L212-L223
[ "def", "tuple_search", "(", "t", ",", "i", ",", "v", ")", ":", "for", "e", "in", "t", ":", "if", "e", "[", "i", "]", "==", "v", ":", "return", "e", "return", "None" ]
27efd91668de0223ed8b07cfadf2151632521520
valid
parse_comment_telemetry
Looks for base91 telemetry found in comment field Returns [remaining_text, telemetry]
aprslib/parsing/telemetry.py
def parse_comment_telemetry(text): """ Looks for base91 telemetry found in comment field Returns [remaining_text, telemetry] """ parsed = {} match = re.findall(r"^(.*?)\|([!-{]{4,14})\|(.*)$", text) if match and len(match[0][1]) % 2 == 0: text, telemetry, post = match[0] tex...
def parse_comment_telemetry(text): """ Looks for base91 telemetry found in comment field Returns [remaining_text, telemetry] """ parsed = {} match = re.findall(r"^(.*?)\|([!-{]{4,14})\|(.*)$", text) if match and len(match[0][1]) % 2 == 0: text, telemetry, post = match[0] tex...
[ "Looks", "for", "base91", "telemetry", "found", "in", "comment", "field", "Returns", "[", "remaining_text", "telemetry", "]" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/parsing/telemetry.py#L12-L40
[ "def", "parse_comment_telemetry", "(", "text", ")", ":", "parsed", "=", "{", "}", "match", "=", "re", ".", "findall", "(", "r\"^(.*?)\\|([!-{]{4,14})\\|(.*)$\"", ",", "text", ")", "if", "match", "and", "len", "(", "match", "[", "0", "]", "[", "1", "]", ...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
parse
Parses an APRS packet and returns a dict with decoded data - All attributes are in metric units
aprslib/parsing/__init__.py
def parse(packet): """ Parses an APRS packet and returns a dict with decoded data - All attributes are in metric units """ if not isinstance(packet, string_type_parse): raise TypeError("Expected packet to be str/unicode/bytes, got %s", type(packet)) if len(packet) == 0: raise ...
def parse(packet): """ Parses an APRS packet and returns a dict with decoded data - All attributes are in metric units """ if not isinstance(packet, string_type_parse): raise TypeError("Expected packet to be str/unicode/bytes, got %s", type(packet)) if len(packet) == 0: raise ...
[ "Parses", "an", "APRS", "packet", "and", "returns", "a", "dict", "with", "decoded", "data" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/parsing/__init__.py#L66-L135
[ "def", "parse", "(", "packet", ")", ":", "if", "not", "isinstance", "(", "packet", ",", "string_type_parse", ")", ":", "raise", "TypeError", "(", "\"Expected packet to be str/unicode/bytes, got %s\"", ",", "type", "(", "packet", ")", ")", "if", "len", "(", "pa...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
to_decimal
Takes a base91 char string and returns decimal
aprslib/base91.py
def to_decimal(text): """ Takes a base91 char string and returns decimal """ if not isinstance(text, string_type): raise TypeError("expected str or unicode, %s given" % type(text)) if findall(r"[\x00-\x20\x7c-\xff]", text): raise ValueError("invalid character in sequence") tex...
def to_decimal(text): """ Takes a base91 char string and returns decimal """ if not isinstance(text, string_type): raise TypeError("expected str or unicode, %s given" % type(text)) if findall(r"[\x00-\x20\x7c-\xff]", text): raise ValueError("invalid character in sequence") tex...
[ "Takes", "a", "base91", "char", "string", "and", "returns", "decimal" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/base91.py#L34-L51
[ "def", "to_decimal", "(", "text", ")", ":", "if", "not", "isinstance", "(", "text", ",", "string_type", ")", ":", "raise", "TypeError", "(", "\"expected str or unicode, %s given\"", "%", "type", "(", "text", ")", ")", "if", "findall", "(", "r\"[\\x00-\\x20\\x7...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
from_decimal
Takes a decimal and returns base91 char string. With optional parameter for fix with output
aprslib/base91.py
def from_decimal(number, width=1): """ Takes a decimal and returns base91 char string. With optional parameter for fix with output """ text = [] if not isinstance(number, int_type): raise TypeError("Expected number to be int, got %s", type(number)) elif not isinstance(width, int_typ...
def from_decimal(number, width=1): """ Takes a decimal and returns base91 char string. With optional parameter for fix with output """ text = [] if not isinstance(number, int_type): raise TypeError("Expected number to be int, got %s", type(number)) elif not isinstance(width, int_typ...
[ "Takes", "a", "decimal", "and", "returns", "base91", "char", "string", ".", "With", "optional", "parameter", "for", "fix", "with", "output" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/base91.py#L54-L74
[ "def", "from_decimal", "(", "number", ",", "width", "=", "1", ")", ":", "text", "=", "[", "]", "if", "not", "isinstance", "(", "number", ",", "int_type", ")", ":", "raise", "TypeError", "(", "\"Expected number to be int, got %s\"", ",", "type", "(", "numbe...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
passcode
Takes a CALLSIGN and returns passcode
aprslib/passcode.py
def passcode(callsign): """ Takes a CALLSIGN and returns passcode """ assert isinstance(callsign, str) callsign = callsign.split('-')[0].upper() code = 0x73e2 for i, char in enumerate(callsign): code ^= ord(char) << (8 if not i % 2 else 0) return code & 0x7fff
def passcode(callsign): """ Takes a CALLSIGN and returns passcode """ assert isinstance(callsign, str) callsign = callsign.split('-')[0].upper() code = 0x73e2 for i, char in enumerate(callsign): code ^= ord(char) << (8 if not i % 2 else 0) return code & 0x7fff
[ "Takes", "a", "CALLSIGN", "and", "returns", "passcode" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/passcode.py#L22-L34
[ "def", "passcode", "(", "callsign", ")", ":", "assert", "isinstance", "(", "callsign", ",", "str", ")", "callsign", "=", "callsign", ".", "split", "(", "'-'", ")", "[", "0", "]", ".", "upper", "(", ")", "code", "=", "0x73e2", "for", "i", ",", "char...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
parse_header
Parses the header part of packet Returns a dict
aprslib/parsing/common.py
def parse_header(head): """ Parses the header part of packet Returns a dict """ try: (fromcall, path) = head.split('>', 1) except: raise ParseError("invalid packet header") if (not 1 <= len(fromcall) <= 9 or not re.findall(r"^[a-z0-9]{0,9}(\-[a-z0-9]{1,8})?$", fromcal...
def parse_header(head): """ Parses the header part of packet Returns a dict """ try: (fromcall, path) = head.split('>', 1) except: raise ParseError("invalid packet header") if (not 1 <= len(fromcall) <= 9 or not re.findall(r"^[a-z0-9]{0,9}(\-[a-z0-9]{1,8})?$", fromcal...
[ "Parses", "the", "header", "part", "of", "packet", "Returns", "a", "dict" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/parsing/common.py#L32-L73
[ "def", "parse_header", "(", "head", ")", ":", "try", ":", "(", "fromcall", ",", "path", ")", "=", "head", ".", "split", "(", "'>'", ",", "1", ")", "except", ":", "raise", "ParseError", "(", "\"invalid packet header\"", ")", "if", "(", "not", "1", "<=...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
IS.set_filter
Set a specified aprs-is filter for this connection
aprslib/inet.py
def set_filter(self, filter_text): """ Set a specified aprs-is filter for this connection """ self.filter = filter_text self.logger.info("Setting filter to: %s", self.filter) if self._connected: self._sendall("#filter %s\r\n" % self.filter)
def set_filter(self, filter_text): """ Set a specified aprs-is filter for this connection """ self.filter = filter_text self.logger.info("Setting filter to: %s", self.filter) if self._connected: self._sendall("#filter %s\r\n" % self.filter)
[ "Set", "a", "specified", "aprs", "-", "is", "filter", "for", "this", "connection" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/inet.py#L77-L86
[ "def", "set_filter", "(", "self", ",", "filter_text", ")", ":", "self", ".", "filter", "=", "filter_text", "self", ".", "logger", ".", "info", "(", "\"Setting filter to: %s\"", ",", "self", ".", "filter", ")", "if", "self", ".", "_connected", ":", "self", ...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
IS.set_login
Set callsign and password
aprslib/inet.py
def set_login(self, callsign, passwd="-1", skip_login=False): """ Set callsign and password """ self.__dict__.update(locals())
def set_login(self, callsign, passwd="-1", skip_login=False): """ Set callsign and password """ self.__dict__.update(locals())
[ "Set", "callsign", "and", "password" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/inet.py#L88-L92
[ "def", "set_login", "(", "self", ",", "callsign", ",", "passwd", "=", "\"-1\"", ",", "skip_login", "=", "False", ")", ":", "self", ".", "__dict__", ".", "update", "(", "locals", "(", ")", ")" ]
94b89a6da47a322129484efcaf1e82f6a9932891
valid
IS.connect
Initiate connection to APRS server and attempt to login blocking = False - Should we block until connected and logged-in retry = 30 - Retry interval in seconds
aprslib/inet.py
def connect(self, blocking=False, retry=30): """ Initiate connection to APRS server and attempt to login blocking = False - Should we block until connected and logged-in retry = 30 - Retry interval in seconds """ if self._connected: return ...
def connect(self, blocking=False, retry=30): """ Initiate connection to APRS server and attempt to login blocking = False - Should we block until connected and logged-in retry = 30 - Retry interval in seconds """ if self._connected: return ...
[ "Initiate", "connection", "to", "APRS", "server", "and", "attempt", "to", "login" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/inet.py#L100-L122
[ "def", "connect", "(", "self", ",", "blocking", "=", "False", ",", "retry", "=", "30", ")", ":", "if", "self", ".", "_connected", ":", "return", "while", "True", ":", "try", ":", "self", ".", "_connect", "(", ")", "if", "not", "self", ".", "skip_lo...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
IS.close
Closes the socket Called internally when Exceptions are raised
aprslib/inet.py
def close(self): """ Closes the socket Called internally when Exceptions are raised """ self._connected = False self.buf = b'' if self.sock is not None: self.sock.close()
def close(self): """ Closes the socket Called internally when Exceptions are raised """ self._connected = False self.buf = b'' if self.sock is not None: self.sock.close()
[ "Closes", "the", "socket", "Called", "internally", "when", "Exceptions", "are", "raised" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/inet.py#L124-L134
[ "def", "close", "(", "self", ")", ":", "self", ".", "_connected", "=", "False", "self", ".", "buf", "=", "b''", "if", "self", ".", "sock", "is", "not", "None", ":", "self", ".", "sock", ".", "close", "(", ")" ]
94b89a6da47a322129484efcaf1e82f6a9932891
valid
IS.sendall
Send a line, or multiple lines sperapted by '\\r\\n'
aprslib/inet.py
def sendall(self, line): """ Send a line, or multiple lines sperapted by '\\r\\n' """ if isinstance(line, APRSPacket): line = str(line) elif not isinstance(line, string_type): raise TypeError("Expected line to be str or APRSPacket, got %s", type(line)) ...
def sendall(self, line): """ Send a line, or multiple lines sperapted by '\\r\\n' """ if isinstance(line, APRSPacket): line = str(line) elif not isinstance(line, string_type): raise TypeError("Expected line to be str or APRSPacket, got %s", type(line)) ...
[ "Send", "a", "line", "or", "multiple", "lines", "sperapted", "by", "\\\\", "r", "\\\\", "n" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/inet.py#L136-L158
[ "def", "sendall", "(", "self", ",", "line", ")", ":", "if", "isinstance", "(", "line", ",", "APRSPacket", ")", ":", "line", "=", "str", "(", "line", ")", "elif", "not", "isinstance", "(", "line", ",", "string_type", ")", ":", "raise", "TypeError", "(...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
IS.consumer
When a position sentence is received, it will be passed to the callback function blocking: if true (default), runs forever, otherwise will return after one sentence You can still exit the loop, by raising StopIteration in the callback function immortal: When true, consumer will try t...
aprslib/inet.py
def consumer(self, callback, blocking=True, immortal=False, raw=False): """ When a position sentence is received, it will be passed to the callback function blocking: if true (default), runs forever, otherwise will return after one sentence You can still exit the loop, by rais...
def consumer(self, callback, blocking=True, immortal=False, raw=False): """ When a position sentence is received, it will be passed to the callback function blocking: if true (default), runs forever, otherwise will return after one sentence You can still exit the loop, by rais...
[ "When", "a", "position", "sentence", "is", "received", "it", "will", "be", "passed", "to", "the", "callback", "function" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/inet.py#L160-L213
[ "def", "consumer", "(", "self", ",", "callback", ",", "blocking", "=", "True", ",", "immortal", "=", "False", ",", "raw", "=", "False", ")", ":", "if", "not", "self", ".", "_connected", ":", "raise", "ConnectionError", "(", "\"not connected to a server\"", ...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
IS._connect
Attemps connection to the server
aprslib/inet.py
def _connect(self): """ Attemps connection to the server """ self.logger.info("Attempting connection to %s:%s", self.server[0], self.server[1]) try: self._open_socket() peer = self.sock.getpeername() self.logger.info("Connected to %s", str(...
def _connect(self): """ Attemps connection to the server """ self.logger.info("Attempting connection to %s:%s", self.server[0], self.server[1]) try: self._open_socket() peer = self.sock.getpeername() self.logger.info("Connected to %s", str(...
[ "Attemps", "connection", "to", "the", "server" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/inet.py#L221-L263
[ "def", "_connect", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Attempting connection to %s:%s\"", ",", "self", ".", "server", "[", "0", "]", ",", "self", ".", "server", "[", "1", "]", ")", "try", ":", "self", ".", "_open_socket",...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
IS._send_login
Sends login string to server
aprslib/inet.py
def _send_login(self): """ Sends login string to server """ login_str = "user {0} pass {1} vers aprslib {3}{2}\r\n" login_str = login_str.format( self.callsign, self.passwd, (" filter " + self.filter) if self.filter != "" else "", _...
def _send_login(self): """ Sends login string to server """ login_str = "user {0} pass {1} vers aprslib {3}{2}\r\n" login_str = login_str.format( self.callsign, self.passwd, (" filter " + self.filter) if self.filter != "" else "", _...
[ "Sends", "login", "string", "to", "server" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/inet.py#L265-L310
[ "def", "_send_login", "(", "self", ")", ":", "login_str", "=", "\"user {0} pass {1} vers aprslib {3}{2}\\r\\n\"", "login_str", "=", "login_str", ".", "format", "(", "self", ".", "callsign", ",", "self", ".", "passwd", ",", "(", "\" filter \"", "+", "self", ".", ...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
IS._socket_readlines
Generator for complete lines, received from the server
aprslib/inet.py
def _socket_readlines(self, blocking=False): """ Generator for complete lines, received from the server """ try: self.sock.setblocking(0) except socket.error as e: self.logger.error("socket error when setblocking(0): %s" % str(e)) raise Connect...
def _socket_readlines(self, blocking=False): """ Generator for complete lines, received from the server """ try: self.sock.setblocking(0) except socket.error as e: self.logger.error("socket error when setblocking(0): %s" % str(e)) raise Connect...
[ "Generator", "for", "complete", "lines", "received", "from", "the", "server" ]
rossengeorgiev/aprs-python
python
https://github.com/rossengeorgiev/aprs-python/blob/94b89a6da47a322129484efcaf1e82f6a9932891/aprslib/inet.py#L312-L347
[ "def", "_socket_readlines", "(", "self", ",", "blocking", "=", "False", ")", ":", "try", ":", "self", ".", "sock", ".", "setblocking", "(", "0", ")", "except", "socket", ".", "error", "as", "e", ":", "self", ".", "logger", ".", "error", "(", "\"socke...
94b89a6da47a322129484efcaf1e82f6a9932891
valid
OrderedUUIDField.db_value
Convert UUID to binary blob
old/old.py
def db_value(self, value): """ Convert UUID to binary blob """ # ensure we have a valid UUID if not isinstance(value, UUID): value = UUID(value) # reconstruct for optimal indexing parts = str(value).split("-") reordered = ''.join([parts[2], p...
def db_value(self, value): """ Convert UUID to binary blob """ # ensure we have a valid UUID if not isinstance(value, UUID): value = UUID(value) # reconstruct for optimal indexing parts = str(value).split("-") reordered = ''.join([parts[2], p...
[ "Convert", "UUID", "to", "binary", "blob" ]
foxx/peewee-extras
python
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/old/old.py#L13-L26
[ "def", "db_value", "(", "self", ",", "value", ")", ":", "# ensure we have a valid UUID", "if", "not", "isinstance", "(", "value", ",", "UUID", ")", ":", "value", "=", "UUID", "(", "value", ")", "# reconstruct for optimal indexing", "parts", "=", "str", "(", ...
327e7e63465b3f6e1afc0e6a651f4cb5c8c60889
valid
OrderedUUIDField.python_value
Convert binary blob to UUID instance
old/old.py
def python_value(self, value): """ Convert binary blob to UUID instance """ value = super(OrderedUUIDField, self).python_value(value) u = binascii.b2a_hex(value) value = u[8:16] + u[4:8] + u[0:4] + u[16:22] + u[22:32] return UUID(value.decode())
def python_value(self, value): """ Convert binary blob to UUID instance """ value = super(OrderedUUIDField, self).python_value(value) u = binascii.b2a_hex(value) value = u[8:16] + u[4:8] + u[0:4] + u[16:22] + u[22:32] return UUID(value.decode())
[ "Convert", "binary", "blob", "to", "UUID", "instance" ]
foxx/peewee-extras
python
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/old/old.py#L28-L35
[ "def", "python_value", "(", "self", ",", "value", ")", ":", "value", "=", "super", "(", "OrderedUUIDField", ",", "self", ")", ".", "python_value", "(", "value", ")", "u", "=", "binascii", ".", "b2a_hex", "(", "value", ")", "value", "=", "u", "[", "8"...
327e7e63465b3f6e1afc0e6a651f4cb5c8c60889
valid
HashField.db_value
Convert the python value for storage in the database.
old/old.py
def db_value(self, value): """Convert the python value for storage in the database.""" value = self.transform_value(value) return self.hhash.encrypt(value, salt_size=self.salt_size, rounds=self.rounds)
def db_value(self, value): """Convert the python value for storage in the database.""" value = self.transform_value(value) return self.hhash.encrypt(value, salt_size=self.salt_size, rounds=self.rounds)
[ "Convert", "the", "python", "value", "for", "storage", "in", "the", "database", "." ]
foxx/peewee-extras
python
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/old/old.py#L135-L139
[ "def", "db_value", "(", "self", ",", "value", ")", ":", "value", "=", "self", ".", "transform_value", "(", "value", ")", "return", "self", ".", "hhash", ".", "encrypt", "(", "value", ",", "salt_size", "=", "self", ".", "salt_size", ",", "rounds", "=", ...
327e7e63465b3f6e1afc0e6a651f4cb5c8c60889
valid
HashField.python_value
Convert the database value to a pythonic value.
old/old.py
def python_value(self, value): """Convert the database value to a pythonic value.""" value = coerce_to_bytes(value) obj = HashValue(value) obj.field = self return obj
def python_value(self, value): """Convert the database value to a pythonic value.""" value = coerce_to_bytes(value) obj = HashValue(value) obj.field = self return obj
[ "Convert", "the", "database", "value", "to", "a", "pythonic", "value", "." ]
foxx/peewee-extras
python
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/old/old.py#L141-L146
[ "def", "python_value", "(", "self", ",", "value", ")", ":", "value", "=", "coerce_to_bytes", "(", "value", ")", "obj", "=", "HashValue", "(", "value", ")", "obj", ".", "field", "=", "self", "return", "obj" ]
327e7e63465b3f6e1afc0e6a651f4cb5c8c60889
valid
ModelManager.register
Register model(s) with app
peewee_extras.py
def register(self, model_cls): """Register model(s) with app""" assert issubclass(model_cls, peewee.Model) assert not hasattr(model_cls._meta, 'database_manager') if model_cls in self: raise RuntimeError("Model already registered") self.append(model_cls) model...
def register(self, model_cls): """Register model(s) with app""" assert issubclass(model_cls, peewee.Model) assert not hasattr(model_cls._meta, 'database_manager') if model_cls in self: raise RuntimeError("Model already registered") self.append(model_cls) model...
[ "Register", "model", "(", "s", ")", "with", "app" ]
foxx/peewee-extras
python
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/peewee_extras.py#L28-L36
[ "def", "register", "(", "self", ",", "model_cls", ")", ":", "assert", "issubclass", "(", "model_cls", ",", "peewee", ".", "Model", ")", "assert", "not", "hasattr", "(", "model_cls", ".", "_meta", ",", "'database_manager'", ")", "if", "model_cls", "in", "se...
327e7e63465b3f6e1afc0e6a651f4cb5c8c60889
valid
DatabaseManager.disconnect
Disconnect from all databases
peewee_extras.py
def disconnect(self): """Disconnect from all databases""" for name, connection in self.items(): if not connection.is_closed(): connection.close()
def disconnect(self): """Disconnect from all databases""" for name, connection in self.items(): if not connection.is_closed(): connection.close()
[ "Disconnect", "from", "all", "databases" ]
foxx/peewee-extras
python
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/peewee_extras.py#L56-L60
[ "def", "disconnect", "(", "self", ")", ":", "for", "name", ",", "connection", "in", "self", ".", "items", "(", ")", ":", "if", "not", "connection", ".", "is_closed", "(", ")", ":", "connection", ".", "close", "(", ")" ]
327e7e63465b3f6e1afc0e6a651f4cb5c8c60889
valid
DatabaseManager.get_database
Find matching database router
peewee_extras.py
def get_database(self, model): """Find matching database router""" for router in self.routers: r = router.get_database(model) if r is not None: return r return self.get('default')
def get_database(self, model): """Find matching database router""" for router in self.routers: r = router.get_database(model) if r is not None: return r return self.get('default')
[ "Find", "matching", "database", "router" ]
foxx/peewee-extras
python
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/peewee_extras.py#L62-L68
[ "def", "get_database", "(", "self", ",", "model", ")", ":", "for", "router", "in", "self", ".", "routers", ":", "r", "=", "router", ".", "get_database", "(", "model", ")", "if", "r", "is", "not", "None", ":", "return", "r", "return", "self", ".", "...
327e7e63465b3f6e1afc0e6a651f4cb5c8c60889
valid
Model.to_cursor_ref
Returns dict of values to uniquely reference this item
peewee_extras.py
def to_cursor_ref(self): """Returns dict of values to uniquely reference this item""" fields = self._meta.get_primary_keys() assert fields values = {field.name:self.__data__[field.name] for field in fields} return values
def to_cursor_ref(self): """Returns dict of values to uniquely reference this item""" fields = self._meta.get_primary_keys() assert fields values = {field.name:self.__data__[field.name] for field in fields} return values
[ "Returns", "dict", "of", "values", "to", "uniquely", "reference", "this", "item" ]
foxx/peewee-extras
python
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/peewee_extras.py#L143-L148
[ "def", "to_cursor_ref", "(", "self", ")", ":", "fields", "=", "self", ".", "_meta", ".", "get_primary_keys", "(", ")", "assert", "fields", "values", "=", "{", "field", ".", "name", ":", "self", ".", "__data__", "[", "field", ".", "name", "]", "for", ...
327e7e63465b3f6e1afc0e6a651f4cb5c8c60889
valid
PrimaryKeyPagination.paginate_query
Apply pagination to query :attr query: Instance of `peewee.Query` :attr count: Max rows to return :attr offset: Pagination offset, str/int :attr sort: List of tuples, e.g. [('id', 'asc')] :returns: Instance of `peewee.Query`
peewee_extras.py
def paginate_query(self, query, count, offset=None, sort=None): """ Apply pagination to query :attr query: Instance of `peewee.Query` :attr count: Max rows to return :attr offset: Pagination offset, str/int :attr sort: List of tuples, e.g. [('id', 'asc')] :retur...
def paginate_query(self, query, count, offset=None, sort=None): """ Apply pagination to query :attr query: Instance of `peewee.Query` :attr count: Max rows to return :attr offset: Pagination offset, str/int :attr sort: List of tuples, e.g. [('id', 'asc')] :retur...
[ "Apply", "pagination", "to", "query" ]
foxx/peewee-extras
python
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/peewee_extras.py#L204-L258
[ "def", "paginate_query", "(", "self", ",", "query", ",", "count", ",", "offset", "=", "None", ",", "sort", "=", "None", ")", ":", "assert", "isinstance", "(", "query", ",", "peewee", ".", "Query", ")", "assert", "isinstance", "(", "count", ",", "int", ...
327e7e63465b3f6e1afc0e6a651f4cb5c8c60889
valid
ModelCRUD.apply_filters
Apply user specified filters to query
peewee_extras.py
def apply_filters(self, query, filters): """ Apply user specified filters to query """ assert isinstance(query, peewee.Query) assert isinstance(filters, dict)
def apply_filters(self, query, filters): """ Apply user specified filters to query """ assert isinstance(query, peewee.Query) assert isinstance(filters, dict)
[ "Apply", "user", "specified", "filters", "to", "query" ]
foxx/peewee-extras
python
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/peewee_extras.py#L315-L320
[ "def", "apply_filters", "(", "self", ",", "query", ",", "filters", ")", ":", "assert", "isinstance", "(", "query", ",", "peewee", ".", "Query", ")", "assert", "isinstance", "(", "filters", ",", "dict", ")" ]
327e7e63465b3f6e1afc0e6a651f4cb5c8c60889
valid
ModelCRUD.list
List items from query
peewee_extras.py
def list(self, filters, cursor, count): """ List items from query """ assert isinstance(filters, dict), "expected filters type 'dict'" assert isinstance(cursor, dict), "expected cursor type 'dict'" # start with our base query query = self.get_query() asse...
def list(self, filters, cursor, count): """ List items from query """ assert isinstance(filters, dict), "expected filters type 'dict'" assert isinstance(cursor, dict), "expected cursor type 'dict'" # start with our base query query = self.get_query() asse...
[ "List", "items", "from", "query" ]
foxx/peewee-extras
python
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/peewee_extras.py#L322-L357
[ "def", "list", "(", "self", ",", "filters", ",", "cursor", ",", "count", ")", ":", "assert", "isinstance", "(", "filters", ",", "dict", ")", ",", "\"expected filters type 'dict'\"", "assert", "isinstance", "(", "cursor", ",", "dict", ")", ",", "\"expected cu...
327e7e63465b3f6e1afc0e6a651f4cb5c8c60889
valid
ModelCRUD.retrieve
Retrieve items from query
peewee_extras.py
def retrieve(self, cursor): """ Retrieve items from query """ assert isinstance(cursor, dict), "expected cursor type 'dict'" # look for record in query query = self.get_query() assert isinstance(query, peewee.Query) query return query.get(**curso...
def retrieve(self, cursor): """ Retrieve items from query """ assert isinstance(cursor, dict), "expected cursor type 'dict'" # look for record in query query = self.get_query() assert isinstance(query, peewee.Query) query return query.get(**curso...
[ "Retrieve", "items", "from", "query" ]
foxx/peewee-extras
python
https://github.com/foxx/peewee-extras/blob/327e7e63465b3f6e1afc0e6a651f4cb5c8c60889/peewee_extras.py#L359-L370
[ "def", "retrieve", "(", "self", ",", "cursor", ")", ":", "assert", "isinstance", "(", "cursor", ",", "dict", ")", ",", "\"expected cursor type 'dict'\"", "# look for record in query", "query", "=", "self", ".", "get_query", "(", ")", "assert", "isinstance", "(",...
327e7e63465b3f6e1afc0e6a651f4cb5c8c60889
valid
AWS4Auth.regenerate_signing_key
Regenerate the signing key for this instance. Store the new key in signing_key property. Take scope elements of the new key from the equivalent properties (region, service, date) of the current AWS4Auth instance. Scope elements can be overridden for the new key by supplying arguments to...
requests_aws4auth/aws4auth.py
def regenerate_signing_key(self, secret_key=None, region=None, service=None, date=None): """ Regenerate the signing key for this instance. Store the new key in signing_key property. Take scope elements of the new key from the equivalent properties ...
def regenerate_signing_key(self, secret_key=None, region=None, service=None, date=None): """ Regenerate the signing key for this instance. Store the new key in signing_key property. Take scope elements of the new key from the equivalent properties ...
[ "Regenerate", "the", "signing", "key", "for", "this", "instance", ".", "Store", "the", "new", "key", "in", "signing_key", "property", "." ]
sam-washington/requests-aws4auth
python
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4auth.py#L264-L306
[ "def", "regenerate_signing_key", "(", "self", ",", "secret_key", "=", "None", ",", "region", "=", "None", ",", "service", "=", "None", ",", "date", "=", "None", ")", ":", "if", "secret_key", "is", "None", "and", "(", "self", ".", "signing_key", "is", "...
1201e470c6d5847b7fe42e937a55755e1895e72c
valid
AWS4Auth.get_request_date
Try to pull a date from the request by looking first at the x-amz-date header, and if that's not present then the Date header. Return a datetime.date object, or None if neither date header is found or is in a recognisable format. req -- a requests PreparedRequest object
requests_aws4auth/aws4auth.py
def get_request_date(cls, req): """ Try to pull a date from the request by looking first at the x-amz-date header, and if that's not present then the Date header. Return a datetime.date object, or None if neither date header is found or is in a recognisable format. req ...
def get_request_date(cls, req): """ Try to pull a date from the request by looking first at the x-amz-date header, and if that's not present then the Date header. Return a datetime.date object, or None if neither date header is found or is in a recognisable format. req ...
[ "Try", "to", "pull", "a", "date", "from", "the", "request", "by", "looking", "first", "at", "the", "x", "-", "amz", "-", "date", "header", "and", "if", "that", "s", "not", "present", "then", "the", "Date", "header", "." ]
sam-washington/requests-aws4auth
python
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4auth.py#L368-L394
[ "def", "get_request_date", "(", "cls", ",", "req", ")", ":", "date", "=", "None", "for", "header", "in", "[", "'x-amz-date'", ",", "'date'", "]", ":", "if", "header", "not", "in", "req", ".", "headers", ":", "continue", "try", ":", "date_str", "=", "...
1201e470c6d5847b7fe42e937a55755e1895e72c
valid
AWS4Auth.parse_date
Check if date_str is in a recognised format and return an ISO yyyy-mm-dd format version if so. Raise DateFormatError if not. Recognised formats are: * RFC 7231 (e.g. Mon, 09 Sep 2011 23:36:00 GMT) * RFC 850 (e.g. Sunday, 06-Nov-94 08:49:37 GMT) * C time (e.g. Wed Dec 4 00:00:00 ...
requests_aws4auth/aws4auth.py
def parse_date(date_str): """ Check if date_str is in a recognised format and return an ISO yyyy-mm-dd format version if so. Raise DateFormatError if not. Recognised formats are: * RFC 7231 (e.g. Mon, 09 Sep 2011 23:36:00 GMT) * RFC 850 (e.g. Sunday, 06-Nov-94 08:49:37 G...
def parse_date(date_str): """ Check if date_str is in a recognised format and return an ISO yyyy-mm-dd format version if so. Raise DateFormatError if not. Recognised formats are: * RFC 7231 (e.g. Mon, 09 Sep 2011 23:36:00 GMT) * RFC 850 (e.g. Sunday, 06-Nov-94 08:49:37 G...
[ "Check", "if", "date_str", "is", "in", "a", "recognised", "format", "and", "return", "an", "ISO", "yyyy", "-", "mm", "-", "dd", "format", "version", "if", "so", ".", "Raise", "DateFormatError", "if", "not", "." ]
sam-washington/requests-aws4auth
python
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4auth.py#L397-L452
[ "def", "parse_date", "(", "date_str", ")", ":", "months", "=", "[", "'jan'", ",", "'feb'", ",", "'mar'", ",", "'apr'", ",", "'may'", ",", "'jun'", ",", "'jul'", ",", "'aug'", ",", "'sep'", ",", "'oct'", ",", "'nov'", ",", "'dec'", "]", "formats", "...
1201e470c6d5847b7fe42e937a55755e1895e72c
valid
AWS4Auth.handle_date_mismatch
Handle a request whose date doesn't match the signing key scope date. This AWS4Auth class implementation regenerates the signing key. See StrictAWS4Auth class if you would prefer an exception to be raised. req -- a requests prepared request object
requests_aws4auth/aws4auth.py
def handle_date_mismatch(self, req): """ Handle a request whose date doesn't match the signing key scope date. This AWS4Auth class implementation regenerates the signing key. See StrictAWS4Auth class if you would prefer an exception to be raised. req -- a requests prepared requ...
def handle_date_mismatch(self, req): """ Handle a request whose date doesn't match the signing key scope date. This AWS4Auth class implementation regenerates the signing key. See StrictAWS4Auth class if you would prefer an exception to be raised. req -- a requests prepared requ...
[ "Handle", "a", "request", "whose", "date", "doesn", "t", "match", "the", "signing", "key", "scope", "date", "." ]
sam-washington/requests-aws4auth
python
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4auth.py#L454-L466
[ "def", "handle_date_mismatch", "(", "self", ",", "req", ")", ":", "req_datetime", "=", "self", ".", "get_request_date", "(", "req", ")", "new_key_date", "=", "req_datetime", ".", "strftime", "(", "'%Y%m%d'", ")", "self", ".", "regenerate_signing_key", "(", "da...
1201e470c6d5847b7fe42e937a55755e1895e72c
valid
AWS4Auth.encode_body
Encode body of request to bytes and update content-type if required. If the body of req is Unicode then encode to the charset found in content-type header if present, otherwise UTF-8, or ASCII if content-type is application/x-www-form-urlencoded. If encoding to UTF-8 then add charset to...
requests_aws4auth/aws4auth.py
def encode_body(req): """ Encode body of request to bytes and update content-type if required. If the body of req is Unicode then encode to the charset found in content-type header if present, otherwise UTF-8, or ASCII if content-type is application/x-www-form-urlencoded. If enc...
def encode_body(req): """ Encode body of request to bytes and update content-type if required. If the body of req is Unicode then encode to the charset found in content-type header if present, otherwise UTF-8, or ASCII if content-type is application/x-www-form-urlencoded. If enc...
[ "Encode", "body", "of", "request", "to", "bytes", "and", "update", "content", "-", "type", "if", "required", "." ]
sam-washington/requests-aws4auth
python
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4auth.py#L469-L495
[ "def", "encode_body", "(", "req", ")", ":", "if", "isinstance", "(", "req", ".", "body", ",", "text_type", ")", ":", "split", "=", "req", ".", "headers", ".", "get", "(", "'content-type'", ",", "'text/plain'", ")", ".", "split", "(", "';'", ")", "if"...
1201e470c6d5847b7fe42e937a55755e1895e72c
valid
AWS4Auth.get_canonical_request
Create the AWS authentication Canonical Request string. req -- Requests PreparedRequest object. Should already include an x-amz-content-sha256 header cano_headers -- Canonical Headers section of Canonical Request, as returned by get_canon...
requests_aws4auth/aws4auth.py
def get_canonical_request(self, req, cano_headers, signed_headers): """ Create the AWS authentication Canonical Request string. req -- Requests PreparedRequest object. Should already include an x-amz-content-sha256 header cano_headers -- Canonical ...
def get_canonical_request(self, req, cano_headers, signed_headers): """ Create the AWS authentication Canonical Request string. req -- Requests PreparedRequest object. Should already include an x-amz-content-sha256 header cano_headers -- Canonical ...
[ "Create", "the", "AWS", "authentication", "Canonical", "Request", "string", "." ]
sam-washington/requests-aws4auth
python
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4auth.py#L497-L520
[ "def", "get_canonical_request", "(", "self", ",", "req", ",", "cano_headers", ",", "signed_headers", ")", ":", "url", "=", "urlparse", "(", "req", ".", "url", ")", "path", "=", "self", ".", "amz_cano_path", "(", "url", ".", "path", ")", "# AWS handles \"ex...
1201e470c6d5847b7fe42e937a55755e1895e72c
valid
AWS4Auth.get_canonical_headers
Generate the Canonical Headers section of the Canonical Request. Return the Canonical Headers and the Signed Headers strs as a tuple (canonical_headers, signed_headers). req -- Requests PreparedRequest object include -- List of headers to include in the canonical and signed ...
requests_aws4auth/aws4auth.py
def get_canonical_headers(cls, req, include=None): """ Generate the Canonical Headers section of the Canonical Request. Return the Canonical Headers and the Signed Headers strs as a tuple (canonical_headers, signed_headers). req -- Requests PreparedRequest object in...
def get_canonical_headers(cls, req, include=None): """ Generate the Canonical Headers section of the Canonical Request. Return the Canonical Headers and the Signed Headers strs as a tuple (canonical_headers, signed_headers). req -- Requests PreparedRequest object in...
[ "Generate", "the", "Canonical", "Headers", "section", "of", "the", "Canonical", "Request", "." ]
sam-washington/requests-aws4auth
python
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4auth.py#L523-L573
[ "def", "get_canonical_headers", "(", "cls", ",", "req", ",", "include", "=", "None", ")", ":", "if", "include", "is", "None", ":", "include", "=", "cls", ".", "default_include_headers", "include", "=", "[", "x", ".", "lower", "(", ")", "for", "x", "in"...
1201e470c6d5847b7fe42e937a55755e1895e72c
valid
AWS4Auth.get_sig_string
Generate the AWS4 auth string to sign for the request. req -- Requests PreparedRequest object. This should already include an x-amz-date header. cano_req -- The Canonical Request, as returned by get_canonical_request()
requests_aws4auth/aws4auth.py
def get_sig_string(req, cano_req, scope): """ Generate the AWS4 auth string to sign for the request. req -- Requests PreparedRequest object. This should already include an x-amz-date header. cano_req -- The Canonical Request, as returned by g...
def get_sig_string(req, cano_req, scope): """ Generate the AWS4 auth string to sign for the request. req -- Requests PreparedRequest object. This should already include an x-amz-date header. cano_req -- The Canonical Request, as returned by g...
[ "Generate", "the", "AWS4", "auth", "string", "to", "sign", "for", "the", "request", "." ]
sam-washington/requests-aws4auth
python
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4auth.py#L576-L590
[ "def", "get_sig_string", "(", "req", ",", "cano_req", ",", "scope", ")", ":", "amz_date", "=", "req", ".", "headers", "[", "'x-amz-date'", "]", "hsh", "=", "hashlib", ".", "sha256", "(", "cano_req", ".", "encode", "(", ")", ")", "sig_items", "=", "[", ...
1201e470c6d5847b7fe42e937a55755e1895e72c
valid
AWS4Auth.amz_cano_path
Generate the canonical path as per AWS4 auth requirements. Not documented anywhere, determined from aws4_testsuite examples, problem reports and testing against the live services. path -- request path
requests_aws4auth/aws4auth.py
def amz_cano_path(self, path): """ Generate the canonical path as per AWS4 auth requirements. Not documented anywhere, determined from aws4_testsuite examples, problem reports and testing against the live services. path -- request path """ safe_chars = '/~' ...
def amz_cano_path(self, path): """ Generate the canonical path as per AWS4 auth requirements. Not documented anywhere, determined from aws4_testsuite examples, problem reports and testing against the live services. path -- request path """ safe_chars = '/~' ...
[ "Generate", "the", "canonical", "path", "as", "per", "AWS4", "auth", "requirements", "." ]
sam-washington/requests-aws4auth
python
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4auth.py#L592-L628
[ "def", "amz_cano_path", "(", "self", ",", "path", ")", ":", "safe_chars", "=", "'/~'", "qs", "=", "''", "fixed_path", "=", "path", "if", "'?'", "in", "fixed_path", ":", "fixed_path", ",", "qs", "=", "fixed_path", ".", "split", "(", "'?'", ",", "1", "...
1201e470c6d5847b7fe42e937a55755e1895e72c
valid
AWS4Auth.amz_cano_querystring
Parse and format querystring as per AWS4 auth requirements. Perform percent quoting as needed. qs -- querystring
requests_aws4auth/aws4auth.py
def amz_cano_querystring(qs): """ Parse and format querystring as per AWS4 auth requirements. Perform percent quoting as needed. qs -- querystring """ safe_qs_amz_chars = '&=+' safe_qs_unresvd = '-_.~' # If Python 2, switch to working entirely in str ...
def amz_cano_querystring(qs): """ Parse and format querystring as per AWS4 auth requirements. Perform percent quoting as needed. qs -- querystring """ safe_qs_amz_chars = '&=+' safe_qs_unresvd = '-_.~' # If Python 2, switch to working entirely in str ...
[ "Parse", "and", "format", "querystring", "as", "per", "AWS4", "auth", "requirements", "." ]
sam-washington/requests-aws4auth
python
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4auth.py#L631-L664
[ "def", "amz_cano_querystring", "(", "qs", ")", ":", "safe_qs_amz_chars", "=", "'&=+'", "safe_qs_unresvd", "=", "'-_.~'", "# If Python 2, switch to working entirely in str", "# as quote() has problems with Unicode", "if", "PY2", ":", "qs", "=", "qs", ".", "encode", "(", ...
1201e470c6d5847b7fe42e937a55755e1895e72c
valid
AWS4SigningKey.generate_key
Generate the signing key string as bytes. If intermediate is set to True, returns a 4-tuple containing the key and the intermediate keys: ( signing_key, date_key, region_key, service_key ) The intermediate keys can be used for testing against examples from Amazon.
requests_aws4auth/aws4signingkey.py
def generate_key(cls, secret_key, region, service, date, intermediates=False): """ Generate the signing key string as bytes. If intermediate is set to True, returns a 4-tuple containing the key and the intermediate keys: ( signing_key, date_key, region_key,...
def generate_key(cls, secret_key, region, service, date, intermediates=False): """ Generate the signing key string as bytes. If intermediate is set to True, returns a 4-tuple containing the key and the intermediate keys: ( signing_key, date_key, region_key,...
[ "Generate", "the", "signing", "key", "string", "as", "bytes", "." ]
sam-washington/requests-aws4auth
python
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4signingkey.py#L100-L122
[ "def", "generate_key", "(", "cls", ",", "secret_key", ",", "region", ",", "service", ",", "date", ",", "intermediates", "=", "False", ")", ":", "init_key", "=", "(", "'AWS4'", "+", "secret_key", ")", ".", "encode", "(", "'utf-8'", ")", "date_key", "=", ...
1201e470c6d5847b7fe42e937a55755e1895e72c
valid
AWS4SigningKey.sign_sha256
Generate an SHA256 HMAC, encoding msg to UTF-8 if not already encoded. key -- signing key. bytes. msg -- message to sign. unicode or bytes.
requests_aws4auth/aws4signingkey.py
def sign_sha256(key, msg): """ Generate an SHA256 HMAC, encoding msg to UTF-8 if not already encoded. key -- signing key. bytes. msg -- message to sign. unicode or bytes. """ if isinstance(msg, text_type): msg = msg.encode('utf-8') return hma...
def sign_sha256(key, msg): """ Generate an SHA256 HMAC, encoding msg to UTF-8 if not already encoded. key -- signing key. bytes. msg -- message to sign. unicode or bytes. """ if isinstance(msg, text_type): msg = msg.encode('utf-8') return hma...
[ "Generate", "an", "SHA256", "HMAC", "encoding", "msg", "to", "UTF", "-", "8", "if", "not", "already", "encoded", "." ]
sam-washington/requests-aws4auth
python
https://github.com/sam-washington/requests-aws4auth/blob/1201e470c6d5847b7fe42e937a55755e1895e72c/requests_aws4auth/aws4signingkey.py#L125-L136
[ "def", "sign_sha256", "(", "key", ",", "msg", ")", ":", "if", "isinstance", "(", "msg", ",", "text_type", ")", ":", "msg", "=", "msg", ".", "encode", "(", "'utf-8'", ")", "return", "hmac", ".", "new", "(", "key", ",", "msg", ",", "hashlib", ".", ...
1201e470c6d5847b7fe42e937a55755e1895e72c
valid
_format_datetime
Convert a datetime object into a valid STIX timestamp string. 1. Convert to timezone-aware 2. Convert to UTC 3. Format in ISO format 4. Ensure correct precision a. Add subsecond value if non-zero and precision not defined 5. Add "Z"
taxii2client/__init__.py
def _format_datetime(dttm): """Convert a datetime object into a valid STIX timestamp string. 1. Convert to timezone-aware 2. Convert to UTC 3. Format in ISO format 4. Ensure correct precision a. Add subsecond value if non-zero and precision not defined 5. Add "Z" """ if dttm.tz...
def _format_datetime(dttm): """Convert a datetime object into a valid STIX timestamp string. 1. Convert to timezone-aware 2. Convert to UTC 3. Format in ISO format 4. Ensure correct precision a. Add subsecond value if non-zero and precision not defined 5. Add "Z" """ if dttm.tz...
[ "Convert", "a", "datetime", "object", "into", "a", "valid", "STIX", "timestamp", "string", "." ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L48-L74
[ "def", "_format_datetime", "(", "dttm", ")", ":", "if", "dttm", ".", "tzinfo", "is", "None", "or", "dttm", ".", "tzinfo", ".", "utcoffset", "(", "dttm", ")", "is", "None", ":", "# dttm is timezone-naive; assume UTC", "zoned", "=", "pytz", ".", "utc", ".", ...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
_ensure_datetime_to_string
If maybe_dttm is a datetime instance, convert to a STIX-compliant string representation. Otherwise return the value unchanged.
taxii2client/__init__.py
def _ensure_datetime_to_string(maybe_dttm): """If maybe_dttm is a datetime instance, convert to a STIX-compliant string representation. Otherwise return the value unchanged.""" if isinstance(maybe_dttm, datetime.datetime): maybe_dttm = _format_datetime(maybe_dttm) return maybe_dttm
def _ensure_datetime_to_string(maybe_dttm): """If maybe_dttm is a datetime instance, convert to a STIX-compliant string representation. Otherwise return the value unchanged.""" if isinstance(maybe_dttm, datetime.datetime): maybe_dttm = _format_datetime(maybe_dttm) return maybe_dttm
[ "If", "maybe_dttm", "is", "a", "datetime", "instance", "convert", "to", "a", "STIX", "-", "compliant", "string", "representation", ".", "Otherwise", "return", "the", "value", "unchanged", "." ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L77-L82
[ "def", "_ensure_datetime_to_string", "(", "maybe_dttm", ")", ":", "if", "isinstance", "(", "maybe_dttm", ",", "datetime", ".", "datetime", ")", ":", "maybe_dttm", "=", "_format_datetime", "(", "maybe_dttm", ")", "return", "maybe_dttm" ]
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
_filter_kwargs_to_query_params
Convert API keyword args to a mapping of URL query parameters. Except for "added_after", all keywords are mapped to match filters, i.e. to a query parameter of the form "match[<kwarg>]". "added_after" is left alone, since it's a special filter, as defined in the spec. Each value can be a single value...
taxii2client/__init__.py
def _filter_kwargs_to_query_params(filter_kwargs): """ Convert API keyword args to a mapping of URL query parameters. Except for "added_after", all keywords are mapped to match filters, i.e. to a query parameter of the form "match[<kwarg>]". "added_after" is left alone, since it's a special filter...
def _filter_kwargs_to_query_params(filter_kwargs): """ Convert API keyword args to a mapping of URL query parameters. Except for "added_after", all keywords are mapped to match filters, i.e. to a query parameter of the form "match[<kwarg>]". "added_after" is left alone, since it's a special filter...
[ "Convert", "API", "keyword", "args", "to", "a", "mapping", "of", "URL", "query", "parameters", ".", "Except", "for", "added_after", "all", "keywords", "are", "mapped", "to", "match", "filters", "i", ".", "e", ".", "to", "a", "query", "parameter", "of", "...
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L85-L134
[ "def", "_filter_kwargs_to_query_params", "(", "filter_kwargs", ")", ":", "query_params", "=", "{", "}", "for", "kwarg", ",", "arglist", "in", "six", ".", "iteritems", "(", "filter_kwargs", ")", ":", "# If user passes an empty list, None, etc, silently skip?", "if", "n...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
_to_json
Factors out some JSON parse code with error handling, to hopefully improve error messages. :param resp: A "requests" library response :return: Parsed JSON. :raises: InvalidJSONError If JSON parsing failed.
taxii2client/__init__.py
def _to_json(resp): """ Factors out some JSON parse code with error handling, to hopefully improve error messages. :param resp: A "requests" library response :return: Parsed JSON. :raises: InvalidJSONError If JSON parsing failed. """ try: return resp.json() except ValueError...
def _to_json(resp): """ Factors out some JSON parse code with error handling, to hopefully improve error messages. :param resp: A "requests" library response :return: Parsed JSON. :raises: InvalidJSONError If JSON parsing failed. """ try: return resp.json() except ValueError...
[ "Factors", "out", "some", "JSON", "parse", "code", "with", "error", "handling", "to", "hopefully", "improve", "error", "messages", "." ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L1023-L1038
[ "def", "_to_json", "(", "resp", ")", ":", "try", ":", "return", "resp", ".", "json", "(", ")", "except", "ValueError", "as", "e", ":", "# Maybe better to report the original request URL?", "six", ".", "raise_from", "(", "InvalidJSONError", "(", "\"Invalid JSON was...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
Status.refresh
Updates Status information
taxii2client/__init__.py
def refresh(self, accept=MEDIA_TYPE_TAXII_V20): """Updates Status information""" response = self.__raw = self._conn.get(self.url, headers={"Accept": accept}) self._populate_fields(**response)
def refresh(self, accept=MEDIA_TYPE_TAXII_V20): """Updates Status information""" response = self.__raw = self._conn.get(self.url, headers={"Accept": accept}) self._populate_fields(**response)
[ "Updates", "Status", "information" ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L235-L239
[ "def", "refresh", "(", "self", ",", "accept", "=", "MEDIA_TYPE_TAXII_V20", ")", ":", "response", "=", "self", ".", "__raw", "=", "self", ".", "_conn", ".", "get", "(", "self", ".", "url", ",", "headers", "=", "{", "\"Accept\"", ":", "accept", "}", ")...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
Status.wait_until_final
It will poll the URL to grab the latest status resource in a given timeout and time interval. Args: poll_interval (int): how often to poll the status service. timeout (int): how long to poll the URL until giving up. Use <= 0 to wait forever
taxii2client/__init__.py
def wait_until_final(self, poll_interval=1, timeout=60): """It will poll the URL to grab the latest status resource in a given timeout and time interval. Args: poll_interval (int): how often to poll the status service. timeout (int): how long to poll the URL until giving...
def wait_until_final(self, poll_interval=1, timeout=60): """It will poll the URL to grab the latest status resource in a given timeout and time interval. Args: poll_interval (int): how often to poll the status service. timeout (int): how long to poll the URL until giving...
[ "It", "will", "poll", "the", "URL", "to", "grab", "the", "latest", "status", "resource", "in", "a", "given", "timeout", "and", "time", "interval", "." ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L241-L257
[ "def", "wait_until_final", "(", "self", ",", "poll_interval", "=", "1", ",", "timeout", "=", "60", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "elapsed", "=", "0", "while", "(", "self", ".", "status", "!=", "\"complete\"", "and", "(", ...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
Status._validate_status
Validates Status information. Raises errors for required properties.
taxii2client/__init__.py
def _validate_status(self): """Validates Status information. Raises errors for required properties.""" if not self.id: msg = "No 'id' in Status for request '{}'" raise ValidationError(msg.format(self.url)) if not self.status: msg = "No 'status' in Sta...
def _validate_status(self): """Validates Status information. Raises errors for required properties.""" if not self.id: msg = "No 'id' in Status for request '{}'" raise ValidationError(msg.format(self.url)) if not self.status: msg = "No 'status' in Sta...
[ "Validates", "Status", "information", ".", "Raises", "errors", "for", "required", "properties", "." ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L280-L333
[ "def", "_validate_status", "(", "self", ")", ":", "if", "not", "self", ".", "id", ":", "msg", "=", "\"No 'id' in Status for request '{}'\"", "raise", "ValidationError", "(", "msg", ".", "format", "(", "self", ".", "url", ")", ")", "if", "not", "self", ".",...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
Collection._validate_collection
Validates Collection information. Raises errors for required properties.
taxii2client/__init__.py
def _validate_collection(self): """Validates Collection information. Raises errors for required properties.""" if not self._id: msg = "No 'id' in Collection for request '{}'" raise ValidationError(msg.format(self.url)) if not self._title: msg = "No 't...
def _validate_collection(self): """Validates Collection information. Raises errors for required properties.""" if not self._id: msg = "No 'id' in Collection for request '{}'" raise ValidationError(msg.format(self.url)) if not self._title: msg = "No 't...
[ "Validates", "Collection", "information", ".", "Raises", "errors", "for", "required", "properties", "." ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L455-L476
[ "def", "_validate_collection", "(", "self", ")", ":", "if", "not", "self", ".", "_id", ":", "msg", "=", "\"No 'id' in Collection for request '{}'\"", "raise", "ValidationError", "(", "msg", ".", "format", "(", "self", ".", "url", ")", ")", "if", "not", "self...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
Collection.get_objects
Implement the ``Get Objects`` endpoint (section 5.3)
taxii2client/__init__.py
def get_objects(self, accept=MEDIA_TYPE_STIX_V20, **filter_kwargs): """Implement the ``Get Objects`` endpoint (section 5.3)""" self._verify_can_read() query_params = _filter_kwargs_to_query_params(filter_kwargs) return self._conn.get(self.objects_url, headers={"Accept": accept}, ...
def get_objects(self, accept=MEDIA_TYPE_STIX_V20, **filter_kwargs): """Implement the ``Get Objects`` endpoint (section 5.3)""" self._verify_can_read() query_params = _filter_kwargs_to_query_params(filter_kwargs) return self._conn.get(self.objects_url, headers={"Accept": accept}, ...
[ "Implement", "the", "Get", "Objects", "endpoint", "(", "section", "5", ".", "3", ")" ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L499-L504
[ "def", "get_objects", "(", "self", ",", "accept", "=", "MEDIA_TYPE_STIX_V20", ",", "*", "*", "filter_kwargs", ")", ":", "self", ".", "_verify_can_read", "(", ")", "query_params", "=", "_filter_kwargs_to_query_params", "(", "filter_kwargs", ")", "return", "self", ...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
Collection.get_object
Implement the ``Get an Object`` endpoint (section 5.5)
taxii2client/__init__.py
def get_object(self, obj_id, version=None, accept=MEDIA_TYPE_STIX_V20): """Implement the ``Get an Object`` endpoint (section 5.5)""" self._verify_can_read() url = self.objects_url + str(obj_id) + "/" query_params = None if version: query_params = _filter_kwargs_to_que...
def get_object(self, obj_id, version=None, accept=MEDIA_TYPE_STIX_V20): """Implement the ``Get an Object`` endpoint (section 5.5)""" self._verify_can_read() url = self.objects_url + str(obj_id) + "/" query_params = None if version: query_params = _filter_kwargs_to_que...
[ "Implement", "the", "Get", "an", "Object", "endpoint", "(", "section", "5", ".", "5", ")" ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L506-L514
[ "def", "get_object", "(", "self", ",", "obj_id", ",", "version", "=", "None", ",", "accept", "=", "MEDIA_TYPE_STIX_V20", ")", ":", "self", ".", "_verify_can_read", "(", ")", "url", "=", "self", ".", "objects_url", "+", "str", "(", "obj_id", ")", "+", "...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
Collection.add_objects
Implement the ``Add Objects`` endpoint (section 5.4) Add objects to the collection. This may be performed either synchronously or asynchronously. To add asynchronously, set wait_for_completion to False. If False, the latter two args are unused. If the caller wishes to monitor the st...
taxii2client/__init__.py
def add_objects(self, bundle, wait_for_completion=True, poll_interval=1, timeout=60, accept=MEDIA_TYPE_TAXII_V20, content_type=MEDIA_TYPE_STIX_V20): """Implement the ``Add Objects`` endpoint (section 5.4) Add objects to the collection. This may be performed eith...
def add_objects(self, bundle, wait_for_completion=True, poll_interval=1, timeout=60, accept=MEDIA_TYPE_TAXII_V20, content_type=MEDIA_TYPE_STIX_V20): """Implement the ``Add Objects`` endpoint (section 5.4) Add objects to the collection. This may be performed eith...
[ "Implement", "the", "Add", "Objects", "endpoint", "(", "section", "5", ".", "4", ")" ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L516-L591
[ "def", "add_objects", "(", "self", ",", "bundle", ",", "wait_for_completion", "=", "True", ",", "poll_interval", "=", "1", ",", "timeout", "=", "60", ",", "accept", "=", "MEDIA_TYPE_TAXII_V20", ",", "content_type", "=", "MEDIA_TYPE_STIX_V20", ")", ":", "self",...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
Collection.get_manifest
Implement the ``Get Object Manifests`` endpoint (section 5.6).
taxii2client/__init__.py
def get_manifest(self, accept=MEDIA_TYPE_TAXII_V20, **filter_kwargs): """Implement the ``Get Object Manifests`` endpoint (section 5.6).""" self._verify_can_read() query_params = _filter_kwargs_to_query_params(filter_kwargs) return self._conn.get(self.url + "manifest/", ...
def get_manifest(self, accept=MEDIA_TYPE_TAXII_V20, **filter_kwargs): """Implement the ``Get Object Manifests`` endpoint (section 5.6).""" self._verify_can_read() query_params = _filter_kwargs_to_query_params(filter_kwargs) return self._conn.get(self.url + "manifest/", ...
[ "Implement", "the", "Get", "Object", "Manifests", "endpoint", "(", "section", "5", ".", "6", ")", "." ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L593-L599
[ "def", "get_manifest", "(", "self", ",", "accept", "=", "MEDIA_TYPE_TAXII_V20", ",", "*", "*", "filter_kwargs", ")", ":", "self", ".", "_verify_can_read", "(", ")", "query_params", "=", "_filter_kwargs_to_query_params", "(", "filter_kwargs", ")", "return", "self",...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
ApiRoot._validate_api_root
Validates API Root information. Raises errors for required properties.
taxii2client/__init__.py
def _validate_api_root(self): """Validates API Root information. Raises errors for required properties.""" if not self._title: msg = "No 'title' in API Root for request '{}'" raise ValidationError(msg.format(self.url)) if not self._versions: msg = "No...
def _validate_api_root(self): """Validates API Root information. Raises errors for required properties.""" if not self._title: msg = "No 'title' in API Root for request '{}'" raise ValidationError(msg.format(self.url)) if not self._versions: msg = "No...
[ "Validates", "API", "Root", "information", ".", "Raises", "errors", "for", "required", "properties", "." ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L681-L694
[ "def", "_validate_api_root", "(", "self", ")", ":", "if", "not", "self", ".", "_title", ":", "msg", "=", "\"No 'title' in API Root for request '{}'\"", "raise", "ValidationError", "(", "msg", ".", "format", "(", "self", ".", "url", ")", ")", "if", "not", "se...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
ApiRoot.refresh
Update the API Root's information and list of Collections
taxii2client/__init__.py
def refresh(self, accept=MEDIA_TYPE_TAXII_V20): """Update the API Root's information and list of Collections""" self.refresh_information(accept) self.refresh_collections(accept)
def refresh(self, accept=MEDIA_TYPE_TAXII_V20): """Update the API Root's information and list of Collections""" self.refresh_information(accept) self.refresh_collections(accept)
[ "Update", "the", "API", "Root", "s", "information", "and", "list", "of", "Collections" ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L708-L711
[ "def", "refresh", "(", "self", ",", "accept", "=", "MEDIA_TYPE_TAXII_V20", ")", ":", "self", ".", "refresh_information", "(", "accept", ")", "self", ".", "refresh_collections", "(", "accept", ")" ]
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
ApiRoot.refresh_information
Update the properties of this API Root. This invokes the ``Get API Root Information`` endpoint.
taxii2client/__init__.py
def refresh_information(self, accept=MEDIA_TYPE_TAXII_V20): """Update the properties of this API Root. This invokes the ``Get API Root Information`` endpoint. """ response = self.__raw = self._conn.get(self.url, headers={"Accept": accept}) ...
def refresh_information(self, accept=MEDIA_TYPE_TAXII_V20): """Update the properties of this API Root. This invokes the ``Get API Root Information`` endpoint. """ response = self.__raw = self._conn.get(self.url, headers={"Accept": accept}) ...
[ "Update", "the", "properties", "of", "this", "API", "Root", "." ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L713-L721
[ "def", "refresh_information", "(", "self", ",", "accept", "=", "MEDIA_TYPE_TAXII_V20", ")", ":", "response", "=", "self", ".", "__raw", "=", "self", ".", "_conn", ".", "get", "(", "self", ".", "url", ",", "headers", "=", "{", "\"Accept\"", ":", "accept",...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
ApiRoot.refresh_collections
Update the list of Collections contained by this API Root. This invokes the ``Get Collections`` endpoint.
taxii2client/__init__.py
def refresh_collections(self, accept=MEDIA_TYPE_TAXII_V20): """Update the list of Collections contained by this API Root. This invokes the ``Get Collections`` endpoint. """ url = self.url + "collections/" response = self._conn.get(url, headers={"Accept": accept}) self._...
def refresh_collections(self, accept=MEDIA_TYPE_TAXII_V20): """Update the list of Collections contained by this API Root. This invokes the ``Get Collections`` endpoint. """ url = self.url + "collections/" response = self._conn.get(url, headers={"Accept": accept}) self._...
[ "Update", "the", "list", "of", "Collections", "contained", "by", "this", "API", "Root", "." ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L723-L738
[ "def", "refresh_collections", "(", "self", ",", "accept", "=", "MEDIA_TYPE_TAXII_V20", ")", ":", "url", "=", "self", ".", "url", "+", "\"collections/\"", "response", "=", "self", ".", "_conn", ".", "get", "(", "url", ",", "headers", "=", "{", "\"Accept\"",...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
Server._validate_server
Validates server information. Raises errors for required properties.
taxii2client/__init__.py
def _validate_server(self): """Validates server information. Raises errors for required properties. """ if not self._title: msg = "No 'title' in Server Discovery for request '{}'" raise ValidationError(msg.format(self.url))
def _validate_server(self): """Validates server information. Raises errors for required properties. """ if not self._title: msg = "No 'title' in Server Discovery for request '{}'" raise ValidationError(msg.format(self.url))
[ "Validates", "server", "information", ".", "Raises", "errors", "for", "required", "properties", "." ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L826-L831
[ "def", "_validate_server", "(", "self", ")", ":", "if", "not", "self", ".", "_title", ":", "msg", "=", "\"No 'title' in Server Discovery for request '{}'\"", "raise", "ValidationError", "(", "msg", ".", "format", "(", "self", ".", "url", ")", ")" ]
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
Server.refresh
Update the Server information and list of API Roots
taxii2client/__init__.py
def refresh(self): """Update the Server information and list of API Roots""" response = self.__raw = self._conn.get(self.url) self._populate_fields(**response) self._loaded = True
def refresh(self): """Update the Server information and list of API Roots""" response = self.__raw = self._conn.get(self.url) self._populate_fields(**response) self._loaded = True
[ "Update", "the", "Server", "information", "and", "list", "of", "API", "Roots" ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L856-L860
[ "def", "refresh", "(", "self", ")", ":", "response", "=", "self", ".", "__raw", "=", "self", ".", "_conn", ".", "get", "(", "self", ".", "url", ")", "self", ".", "_populate_fields", "(", "*", "*", "response", ")", "self", ".", "_loaded", "=", "True...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
_HTTPConnection.valid_content_type
Check that the server is returning a valid Content-Type Args: content_type (str): ``Content-Type:`` header value accept (str): media type to include in the ``Accept:`` header.
taxii2client/__init__.py
def valid_content_type(self, content_type, accept): """Check that the server is returning a valid Content-Type Args: content_type (str): ``Content-Type:`` header value accept (str): media type to include in the ``Accept:`` header. """ accept_tokens = accept.repl...
def valid_content_type(self, content_type, accept): """Check that the server is returning a valid Content-Type Args: content_type (str): ``Content-Type:`` header value accept (str): media type to include in the ``Accept:`` header. """ accept_tokens = accept.repl...
[ "Check", "that", "the", "server", "is", "returning", "a", "valid", "Content", "-", "Type" ]
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L902-L917
[ "def", "valid_content_type", "(", "self", ",", "content_type", ",", "accept", ")", ":", "accept_tokens", "=", "accept", ".", "replace", "(", "' '", ",", "''", ")", ".", "split", "(", "';'", ")", "content_type_tokens", "=", "content_type", ".", "replace", "...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
_HTTPConnection.get
Perform an HTTP GET, using the saved requests.Session and auth info. If "Accept" isn't one of the given headers, a default TAXII mime type is used. Regardless, the response type is checked against the accept header value, and an exception is raised if they don't match. Args: ...
taxii2client/__init__.py
def get(self, url, headers=None, params=None): """Perform an HTTP GET, using the saved requests.Session and auth info. If "Accept" isn't one of the given headers, a default TAXII mime type is used. Regardless, the response type is checked against the accept header value, and an exceptio...
def get(self, url, headers=None, params=None): """Perform an HTTP GET, using the saved requests.Session and auth info. If "Accept" isn't one of the given headers, a default TAXII mime type is used. Regardless, the response type is checked against the accept header value, and an exceptio...
[ "Perform", "an", "HTTP", "GET", "using", "the", "saved", "requests", ".", "Session", "and", "auth", "info", ".", "If", "Accept", "isn", "t", "one", "of", "the", "given", "headers", "a", "default", "TAXII", "mime", "type", "is", "used", ".", "Regardless",...
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L919-L949
[ "def", "get", "(", "self", ",", "url", ",", "headers", "=", "None", ",", "params", "=", "None", ")", ":", "merged_headers", "=", "self", ".", "_merge_headers", "(", "headers", ")", "if", "\"Accept\"", "not", "in", "merged_headers", ":", "merged_headers", ...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
_HTTPConnection.post
Send a JSON POST request with the given request headers, additional URL query parameters, and the given JSON in the request body. The extra query parameters are merged with any which already exist in the URL. The 'json' and 'data' parameters may not both be given. Args: ur...
taxii2client/__init__.py
def post(self, url, headers=None, params=None, **kwargs): """Send a JSON POST request with the given request headers, additional URL query parameters, and the given JSON in the request body. The extra query parameters are merged with any which already exist in the URL. The 'json' and '...
def post(self, url, headers=None, params=None, **kwargs): """Send a JSON POST request with the given request headers, additional URL query parameters, and the given JSON in the request body. The extra query parameters are merged with any which already exist in the URL. The 'json' and '...
[ "Send", "a", "JSON", "POST", "request", "with", "the", "given", "request", "headers", "additional", "URL", "query", "parameters", "and", "the", "given", "JSON", "in", "the", "request", "body", ".", "The", "extra", "query", "parameters", "are", "merged", "wit...
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L951-L980
[ "def", "post", "(", "self", ",", "url", ",", "headers", "=", "None", ",", "params", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "kwargs", ")", ">", "1", ":", "raise", "InvalidArgumentsError", "(", "\"Too many extra args ({} > 1)\"",...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
_HTTPConnection._merge_headers
Merge headers from different sources together. Headers passed to the post/get methods have highest priority, then headers associated with the connection object itself have next priority. :param call_specific_headers: A header dict from the get/post call, or None (the default for th...
taxii2client/__init__.py
def _merge_headers(self, call_specific_headers): """ Merge headers from different sources together. Headers passed to the post/get methods have highest priority, then headers associated with the connection object itself have next priority. :param call_specific_headers: A header...
def _merge_headers(self, call_specific_headers): """ Merge headers from different sources together. Headers passed to the post/get methods have highest priority, then headers associated with the connection object itself have next priority. :param call_specific_headers: A header...
[ "Merge", "headers", "from", "different", "sources", "together", ".", "Headers", "passed", "to", "the", "post", "/", "get", "methods", "have", "highest", "priority", "then", "headers", "associated", "with", "the", "connection", "object", "itself", "have", "next",...
oasis-open/cti-taxii-client
python
https://github.com/oasis-open/cti-taxii-client/blob/b4c037fb61d8b8892af34423e2c67c81218d6f8e/taxii2client/__init__.py#L986-L1020
[ "def", "_merge_headers", "(", "self", ",", "call_specific_headers", ")", ":", "# A case-insensitive mapping is necessary here so that there is", "# predictable behavior. If a plain dict were used, you'd get keys in", "# the merged dict which differ only in case. The requests library", "# wou...
b4c037fb61d8b8892af34423e2c67c81218d6f8e
valid
total_memory
Returns the the amount of memory available for use. The memory is obtained from MemTotal entry in /proc/meminfo. Notes ===== This function is not very useful and not very portable.
sharedmem/sharedmem.py
def total_memory(): """ Returns the the amount of memory available for use. The memory is obtained from MemTotal entry in /proc/meminfo. Notes ===== This function is not very useful and not very portable. """ with file('/proc/meminfo', 'r') as f: for line ...
def total_memory(): """ Returns the the amount of memory available for use. The memory is obtained from MemTotal entry in /proc/meminfo. Notes ===== This function is not very useful and not very portable. """ with file('/proc/meminfo', 'r') as f: for line ...
[ "Returns", "the", "the", "amount", "of", "memory", "available", "for", "use", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/sharedmem.py#L186-L201
[ "def", "total_memory", "(", ")", ":", "with", "file", "(", "'/proc/meminfo'", ",", "'r'", ")", "as", "f", ":", "for", "line", "in", "f", ":", "words", "=", "line", ".", "split", "(", ")", "if", "words", "[", "0", "]", ".", "upper", "(", ")", "=...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
cpu_count
Returns the default number of slave processes to be spawned. The default value is the number of physical cpu cores seen by python. :code:`OMP_NUM_THREADS` environment variable overrides it. On PBS/torque systems if OMP_NUM_THREADS is empty, we try to use the value of :code:`PBS_NUM_PPN...
sharedmem/sharedmem.py
def cpu_count(): """ Returns the default number of slave processes to be spawned. The default value is the number of physical cpu cores seen by python. :code:`OMP_NUM_THREADS` environment variable overrides it. On PBS/torque systems if OMP_NUM_THREADS is empty, we try to use the va...
def cpu_count(): """ Returns the default number of slave processes to be spawned. The default value is the number of physical cpu cores seen by python. :code:`OMP_NUM_THREADS` environment variable overrides it. On PBS/torque systems if OMP_NUM_THREADS is empty, we try to use the va...
[ "Returns", "the", "default", "number", "of", "slave", "processes", "to", "be", "spawned", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/sharedmem.py#L203-L224
[ "def", "cpu_count", "(", ")", ":", "num", "=", "os", ".", "getenv", "(", "\"OMP_NUM_THREADS\"", ")", "if", "num", "is", "None", ":", "num", "=", "os", ".", "getenv", "(", "\"PBS_NUM_PPN\"", ")", "try", ":", "return", "int", "(", "num", ")", "except",...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
empty_like
Create a shared memory array from the shape of array.
sharedmem/sharedmem.py
def empty_like(array, dtype=None): """ Create a shared memory array from the shape of array. """ array = numpy.asarray(array) if dtype is None: dtype = array.dtype return anonymousmemmap(array.shape, dtype)
def empty_like(array, dtype=None): """ Create a shared memory array from the shape of array. """ array = numpy.asarray(array) if dtype is None: dtype = array.dtype return anonymousmemmap(array.shape, dtype)
[ "Create", "a", "shared", "memory", "array", "from", "the", "shape", "of", "array", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/sharedmem.py#L785-L791
[ "def", "empty_like", "(", "array", ",", "dtype", "=", "None", ")", ":", "array", "=", "numpy", ".", "asarray", "(", "array", ")", "if", "dtype", "is", "None", ":", "dtype", "=", "array", ".", "dtype", "return", "anonymousmemmap", "(", "array", ".", "...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
full_like
Create a shared memory array with the same shape and type as a given array, filled with `value`.
sharedmem/sharedmem.py
def full_like(array, value, dtype=None): """ Create a shared memory array with the same shape and type as a given array, filled with `value`. """ shared = empty_like(array, dtype) shared[:] = value return shared
def full_like(array, value, dtype=None): """ Create a shared memory array with the same shape and type as a given array, filled with `value`. """ shared = empty_like(array, dtype) shared[:] = value return shared
[ "Create", "a", "shared", "memory", "array", "with", "the", "same", "shape", "and", "type", "as", "a", "given", "array", "filled", "with", "value", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/sharedmem.py#L798-L803
[ "def", "full_like", "(", "array", ",", "value", ",", "dtype", "=", "None", ")", ":", "shared", "=", "empty_like", "(", "array", ",", "dtype", ")", "shared", "[", ":", "]", "=", "value", "return", "shared" ]
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
full
Create a shared memory array of given shape and type, filled with `value`.
sharedmem/sharedmem.py
def full(shape, value, dtype='f8'): """ Create a shared memory array of given shape and type, filled with `value`. """ shared = empty(shape, dtype) shared[:] = value return shared
def full(shape, value, dtype='f8'): """ Create a shared memory array of given shape and type, filled with `value`. """ shared = empty(shape, dtype) shared[:] = value return shared
[ "Create", "a", "shared", "memory", "array", "of", "given", "shape", "and", "type", "filled", "with", "value", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/sharedmem.py#L805-L810
[ "def", "full", "(", "shape", ",", "value", ",", "dtype", "=", "'f8'", ")", ":", "shared", "=", "empty", "(", "shape", ",", "dtype", ")", "shared", "[", ":", "]", "=", "value", "return", "shared" ]
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
copy
Copy an array to the shared memory. Notes ----- copy is not always necessary because the private memory is always copy-on-write. Use :code:`a = copy(a)` to immediately dereference the old 'a' on private memory
sharedmem/sharedmem.py
def copy(a): """ Copy an array to the shared memory. Notes ----- copy is not always necessary because the private memory is always copy-on-write. Use :code:`a = copy(a)` to immediately dereference the old 'a' on private memory """ shared = anonymousmemmap(a.shape, dtype=a....
def copy(a): """ Copy an array to the shared memory. Notes ----- copy is not always necessary because the private memory is always copy-on-write. Use :code:`a = copy(a)` to immediately dereference the old 'a' on private memory """ shared = anonymousmemmap(a.shape, dtype=a....
[ "Copy", "an", "array", "to", "the", "shared", "memory", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/sharedmem.py#L812-L823
[ "def", "copy", "(", "a", ")", ":", "shared", "=", "anonymousmemmap", "(", "a", ".", "shape", ",", "dtype", "=", "a", ".", "dtype", ")", "shared", "[", ":", "]", "=", "a", "[", ":", "]", "return", "shared" ]
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
ProcessGroup.get
Protected get. Get an item from Q. Will block. but if the process group has errors, raise an StopProcessGroup exception. A slave process will terminate upon StopProcessGroup. The master process shall read the error from the process group.
sharedmem/sharedmem.py
def get(self, Q): """ Protected get. Get an item from Q. Will block. but if the process group has errors, raise an StopProcessGroup exception. A slave process will terminate upon StopProcessGroup. The master process shall read the error from the process group. ...
def get(self, Q): """ Protected get. Get an item from Q. Will block. but if the process group has errors, raise an StopProcessGroup exception. A slave process will terminate upon StopProcessGroup. The master process shall read the error from the process group. ...
[ "Protected", "get", ".", "Get", "an", "item", "from", "Q", ".", "Will", "block", ".", "but", "if", "the", "process", "group", "has", "errors", "raise", "an", "StopProcessGroup", "exception", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/sharedmem.py#L404-L429
[ "def", "get", "(", "self", ",", "Q", ")", ":", "while", "self", ".", "Errors", ".", "empty", "(", ")", ":", "try", ":", "return", "Q", ".", "get", "(", "timeout", "=", "1", ")", "except", "queue", ".", "Empty", ":", "# check if the process group is d...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
background.wait
Wait and join the child process. The return value of the function call is returned. If any exception occurred it is wrapped and raised.
sharedmem/sharedmem.py
def wait(self): """ Wait and join the child process. The return value of the function call is returned. If any exception occurred it is wrapped and raised. """ e, r = self.result.get() self.slave.join() self.slave = None self.result = None ...
def wait(self): """ Wait and join the child process. The return value of the function call is returned. If any exception occurred it is wrapped and raised. """ e, r = self.result.get() self.slave.join() self.slave = None self.result = None ...
[ "Wait", "and", "join", "the", "child", "process", ".", "The", "return", "value", "of", "the", "function", "call", "is", "returned", ".", "If", "any", "exception", "occurred", "it", "is", "wrapped", "and", "raised", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/sharedmem.py#L546-L557
[ "def", "wait", "(", "self", ")", ":", "e", ",", "r", "=", "self", ".", "result", ".", "get", "(", ")", "self", ".", "slave", ".", "join", "(", ")", "self", ".", "slave", "=", "None", "self", ".", "result", "=", "None", "if", "isinstance", "(", ...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
MapReduce.map
Map-reduce with multile processes. Apply func to each item on the sequence, in parallel. As the results are collected, reduce is called on the result. The reduced result is returned as a list. Parameters ---------- func : callable ...
sharedmem/sharedmem.py
def map(self, func, sequence, reduce=None, star=False, minlength=0): """ Map-reduce with multile processes. Apply func to each item on the sequence, in parallel. As the results are collected, reduce is called on the result. The reduced result is returned as a list. ...
def map(self, func, sequence, reduce=None, star=False, minlength=0): """ Map-reduce with multile processes. Apply func to each item on the sequence, in parallel. As the results are collected, reduce is called on the result. The reduced result is returned as a list. ...
[ "Map", "-", "reduce", "with", "multile", "processes", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/sharedmem.py#L643-L782
[ "def", "map", "(", "self", ",", "func", ",", "sequence", ",", "reduce", "=", "None", ",", "star", "=", "False", ",", "minlength", "=", "0", ")", ":", "def", "realreduce", "(", "r", ")", ":", "if", "reduce", ":", "if", "isinstance", "(", "r", ",",...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
savetxt2
format of table header: # ID [type]:name(index) .... * number of items user's header is not prefixed by comment_character name of nested dtype elements are split by .
contrib/savetxt.py
def savetxt2(fname, X, delimiter=' ', newline='\n', comment_character='#', header='', save_dtype=False, fmt={}): """ format of table header: # ID [type]:name(index) .... * number of items user's header is not prefixed by comment_character name of nested dtype elements are split b...
def savetxt2(fname, X, delimiter=' ', newline='\n', comment_character='#', header='', save_dtype=False, fmt={}): """ format of table header: # ID [type]:name(index) .... * number of items user's header is not prefixed by comment_character name of nested dtype elements are split b...
[ "format", "of", "table", "header", ":" ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/contrib/savetxt.py#L14-L64
[ "def", "savetxt2", "(", "fname", ",", "X", ",", "delimiter", "=", "' '", ",", "newline", "=", "'\\n'", ",", "comment_character", "=", "'#'", ",", "header", "=", "''", ",", "save_dtype", "=", "False", ",", "fmt", "=", "{", "}", ")", ":", "prefixfmt", ...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
loadtxt2
Known issues delimiter and newline is not respected. string quotation with space is broken.
contrib/savetxt.py
def loadtxt2(fname, dtype=None, delimiter=' ', newline='\n', comment_character='#', skiplines=0): """ Known issues delimiter and newline is not respected. string quotation with space is broken. """ dtypert = [None, None, None] def preparedtype(dtype): dtypert[0] = dtype ...
def loadtxt2(fname, dtype=None, delimiter=' ', newline='\n', comment_character='#', skiplines=0): """ Known issues delimiter and newline is not respected. string quotation with space is broken. """ dtypert = [None, None, None] def preparedtype(dtype): dtypert[0] = dtype ...
[ "Known", "issues", "delimiter", "and", "newline", "is", "not", "respected", ".", "string", "quotation", "with", "space", "is", "broken", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/contrib/savetxt.py#L66-L114
[ "def", "loadtxt2", "(", "fname", ",", "dtype", "=", "None", ",", "delimiter", "=", "' '", ",", "newline", "=", "'\\n'", ",", "comment_character", "=", "'#'", ",", "skiplines", "=", "0", ")", ":", "dtypert", "=", "[", "None", ",", "None", ",", "None",...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
flatten_dtype
Unpack a structured data-type.
contrib/savetxt.py
def flatten_dtype(dtype, _next=None): """ Unpack a structured data-type. """ types = [] if _next is None: _next = [0, ''] primary = True else: primary = False prefix = _next[1] if dtype.names is None: for i in numpy.ndindex(dtype.shape): if dtype.b...
def flatten_dtype(dtype, _next=None): """ Unpack a structured data-type. """ types = [] if _next is None: _next = [0, ''] primary = True else: primary = False prefix = _next[1] if dtype.names is None: for i in numpy.ndindex(dtype.shape): if dtype.b...
[ "Unpack", "a", "structured", "data", "-", "type", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/contrib/savetxt.py#L199-L232
[ "def", "flatten_dtype", "(", "dtype", ",", "_next", "=", "None", ")", ":", "types", "=", "[", "]", "if", "_next", "is", "None", ":", "_next", "=", "[", "0", ",", "''", "]", "primary", "=", "True", "else", ":", "primary", "=", "False", "prefix", "...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
MetaOrdered
meta class for Ordered construct.
sharedmem/parallel.py
def MetaOrdered(parallel, done, turnstile): """meta class for Ordered construct.""" class Ordered: def __init__(self, iterref): if parallel.master: done[...] = 0 self.iterref = iterref parallel.barrier() @classmethod def abort(self): ...
def MetaOrdered(parallel, done, turnstile): """meta class for Ordered construct.""" class Ordered: def __init__(self, iterref): if parallel.master: done[...] = 0 self.iterref = iterref parallel.barrier() @classmethod def abort(self): ...
[ "meta", "class", "for", "Ordered", "construct", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/parallel.py#L508-L529
[ "def", "MetaOrdered", "(", "parallel", ",", "done", ",", "turnstile", ")", ":", "class", "Ordered", ":", "def", "__init__", "(", "self", ",", "iterref", ")", ":", "if", "parallel", ".", "master", ":", "done", "[", "...", "]", "=", "0", "self", ".", ...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
SlaveMonitor.kill_all
kill all slaves and reap the monitor
sharedmem/parallel.py
def kill_all(self): """kill all slaves and reap the monitor """ for pid in self.children: try: os.kill(pid, signal.SIGTRAP) except OSError: continue self.join()
def kill_all(self): """kill all slaves and reap the monitor """ for pid in self.children: try: os.kill(pid, signal.SIGTRAP) except OSError: continue self.join()
[ "kill", "all", "slaves", "and", "reap", "the", "monitor" ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/parallel.py#L171-L178
[ "def", "kill_all", "(", "self", ")", ":", "for", "pid", "in", "self", ".", "children", ":", "try", ":", "os", ".", "kill", "(", "pid", ",", "signal", ".", "SIGTRAP", ")", "except", "OSError", ":", "continue", "self", ".", "join", "(", ")" ]
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
ErrorMonitor.join
master only
sharedmem/parallel.py
def join(self): """ master only """ try: self.pipe.put('Q') self.thread.join() except: pass finally: self.thread = None
def join(self): """ master only """ try: self.pipe.put('Q') self.thread.join() except: pass finally: self.thread = None
[ "master", "only" ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/parallel.py#L218-L226
[ "def", "join", "(", "self", ")", ":", "try", ":", "self", ".", "pipe", ".", "put", "(", "'Q'", ")", "self", ".", "thread", ".", "join", "(", ")", "except", ":", "pass", "finally", ":", "self", ".", "thread", "=", "None" ]
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
ErrorMonitor.slaveraise
slave only
sharedmem/parallel.py
def slaveraise(self, type, error, traceback): """ slave only """ message = 'E' * 1 + pickle.dumps((type, ''.join(tb.format_exception(type, error, traceback)))) if self.pipe is not None: self.pipe.put(message)
def slaveraise(self, type, error, traceback): """ slave only """ message = 'E' * 1 + pickle.dumps((type, ''.join(tb.format_exception(type, error, traceback)))) if self.pipe is not None: self.pipe.put(message)
[ "slave", "only" ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/parallel.py#L228-L233
[ "def", "slaveraise", "(", "self", ",", "type", ",", "error", ",", "traceback", ")", ":", "message", "=", "'E'", "*", "1", "+", "pickle", ".", "dumps", "(", "(", "type", ",", "''", ".", "join", "(", "tb", ".", "format_exception", "(", "type", ",", ...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
Parallel.forloop
schedule can be (sch, chunk) or sch; sch is 'static', 'dynamic' or 'guided'. chunk defaults to 1 if ordered, create an ordred
sharedmem/parallel.py
def forloop(self, range, ordered=False, schedule=('static', 1)): """ schedule can be (sch, chunk) or sch; sch is 'static', 'dynamic' or 'guided'. chunk defaults to 1 if ordered, create an ordred """ if isinstance(schedule, tuple): sc...
def forloop(self, range, ordered=False, schedule=('static', 1)): """ schedule can be (sch, chunk) or sch; sch is 'static', 'dynamic' or 'guided'. chunk defaults to 1 if ordered, create an ordred """ if isinstance(schedule, tuple): sc...
[ "schedule", "can", "be", "(", "sch", "chunk", ")", "or", "sch", ";", "sch", "is", "static", "dynamic", "or", "guided", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/parallel.py#L354-L375
[ "def", "forloop", "(", "self", ",", "range", ",", "ordered", "=", "False", ",", "schedule", "=", "(", "'static'", ",", "1", ")", ")", ":", "if", "isinstance", "(", "schedule", ",", "tuple", ")", ":", "schedule", ",", "chunk", "=", "schedule", "else",...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
Barrier.abort
ensure the master exit from Barrier
sharedmem/parallel.py
def abort(self): """ ensure the master exit from Barrier """ self.mutex.release() self.turnstile.release() self.mutex.release() self.turnstile2.release()
def abort(self): """ ensure the master exit from Barrier """ self.mutex.release() self.turnstile.release() self.mutex.release() self.turnstile2.release()
[ "ensure", "the", "master", "exit", "from", "Barrier" ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/sharedmem/parallel.py#L387-L392
[ "def", "abort", "(", "self", ")", ":", "self", ".", "mutex", ".", "release", "(", ")", "self", ".", "turnstile", ".", "release", "(", ")", "self", ".", "mutex", ".", "release", "(", ")", "self", ".", "turnstile2", ".", "release", "(", ")" ]
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
MultiPartStream.read
return at most n array items, move the cursor.
contrib/multipartstream.py
def read(self, n): """ return at most n array items, move the cursor. """ while len(self.pool) < n: self.cur = self.files.next() self.pool = numpy.append(self.pool, self.fetch(self.cur), axis=0) rt = self.pool[:n] if n == len(self.poo...
def read(self, n): """ return at most n array items, move the cursor. """ while len(self.pool) < n: self.cur = self.files.next() self.pool = numpy.append(self.pool, self.fetch(self.cur), axis=0) rt = self.pool[:n] if n == len(self.poo...
[ "return", "at", "most", "n", "array", "items", "move", "the", "cursor", "." ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/contrib/multipartstream.py#L31-L44
[ "def", "read", "(", "self", ",", "n", ")", ":", "while", "len", "(", "self", ".", "pool", ")", "<", "n", ":", "self", ".", "cur", "=", "self", ".", "files", ".", "next", "(", ")", "self", ".", "pool", "=", "numpy", ".", "append", "(", "self",...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
pufunc.call
axis is the axis to chop it off. if self.altreduce is set, the results will be reduced with altreduce and returned otherwise will be saved to out, then return out.
contrib/array.py
def call(self, args, axis=0, out=None, chunksize=1024 * 1024, **kwargs): """ axis is the axis to chop it off. if self.altreduce is set, the results will be reduced with altreduce and returned otherwise will be saved to out, then return out. """ if self.altredu...
def call(self, args, axis=0, out=None, chunksize=1024 * 1024, **kwargs): """ axis is the axis to chop it off. if self.altreduce is set, the results will be reduced with altreduce and returned otherwise will be saved to out, then return out. """ if self.altredu...
[ "axis", "is", "the", "axis", "to", "chop", "it", "off", ".", "if", "self", ".", "altreduce", "is", "set", "the", "results", "will", "be", "reduced", "with", "altreduce", "and", "returned", "otherwise", "will", "be", "saved", "to", "out", "then", "return"...
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/contrib/array.py#L80-L139
[ "def", "call", "(", "self", ",", "args", ",", "axis", "=", "0", ",", "out", "=", "None", ",", "chunksize", "=", "1024", "*", "1024", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "altreduce", "is", "not", "None", ":", "ret", "=", "[", ...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
packarray.adapt
adapt source to a packarray according to the layout of template
contrib/array.py
def adapt(cls, source, template): """ adapt source to a packarray according to the layout of template """ if not isinstance(template, packarray): raise TypeError('template must be a packarray') return cls(source, template.start, template.end)
def adapt(cls, source, template): """ adapt source to a packarray according to the layout of template """ if not isinstance(template, packarray): raise TypeError('template must be a packarray') return cls(source, template.start, template.end)
[ "adapt", "source", "to", "a", "packarray", "according", "to", "the", "layout", "of", "template" ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/contrib/array.py#L201-L205
[ "def", "adapt", "(", "cls", ",", "source", ",", "template", ")", ":", "if", "not", "isinstance", "(", "template", ",", "packarray", ")", ":", "raise", "TypeError", "(", "'template must be a packarray'", ")", "return", "cls", "(", "source", ",", "template", ...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
argsort
parallel argsort, like numpy.argsort use sizeof(intp) * len(data) as scratch space use baseargsort for serial sort ind = baseargsort(data) use argmerge to merge def argmerge(data, A, B, out): ensure data[out] is sorted and out[:] = A join B TODO: shal...
contrib/sort.py
def argsort(data, out=None, chunksize=None, baseargsort=None, argmerge=None, np=None): """ parallel argsort, like numpy.argsort use sizeof(intp) * len(data) as scratch space use baseargsort for serial sort ind = baseargsort(data) use argmerge to merge def ...
def argsort(data, out=None, chunksize=None, baseargsort=None, argmerge=None, np=None): """ parallel argsort, like numpy.argsort use sizeof(intp) * len(data) as scratch space use baseargsort for serial sort ind = baseargsort(data) use argmerge to merge def ...
[ "parallel", "argsort", "like", "numpy", ".", "argsort" ]
rainwoodman/sharedmem
python
https://github.com/rainwoodman/sharedmem/blob/b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a/contrib/sort.py#L27-L104
[ "def", "argsort", "(", "data", ",", "out", "=", "None", ",", "chunksize", "=", "None", ",", "baseargsort", "=", "None", ",", "argmerge", "=", "None", ",", "np", "=", "None", ")", ":", "if", "baseargsort", "is", "None", ":", "baseargsort", "=", "lambd...
b23e59c1ed0e28f7b6c96c17a04d55c700e06e3a
valid
day_of_week
Return a random (abbreviated if `abbr`) day of week name.
forgery_py/forgery/date.py
def day_of_week(abbr=False): """Return a random (abbreviated if `abbr`) day of week name.""" if abbr: return random.choice(DAYS_ABBR) else: return random.choice(DAYS)
def day_of_week(abbr=False): """Return a random (abbreviated if `abbr`) day of week name.""" if abbr: return random.choice(DAYS_ABBR) else: return random.choice(DAYS)
[ "Return", "a", "random", "(", "abbreviated", "if", "abbr", ")", "day", "of", "week", "name", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/date.py#L55-L60
[ "def", "day_of_week", "(", "abbr", "=", "False", ")", ":", "if", "abbr", ":", "return", "random", ".", "choice", "(", "DAYS_ABBR", ")", "else", ":", "return", "random", ".", "choice", "(", "DAYS", ")" ]
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
month
Return a random (abbreviated if `abbr`) month name or month number if `numerical`.
forgery_py/forgery/date.py
def month(abbr=False, numerical=False): """Return a random (abbreviated if `abbr`) month name or month number if `numerical`. """ if numerical: return random.randint(1, 12) else: if abbr: return random.choice(MONTHS_ABBR) else: return random.choice(MON...
def month(abbr=False, numerical=False): """Return a random (abbreviated if `abbr`) month name or month number if `numerical`. """ if numerical: return random.randint(1, 12) else: if abbr: return random.choice(MONTHS_ABBR) else: return random.choice(MON...
[ "Return", "a", "random", "(", "abbreviated", "if", "abbr", ")", "month", "name", "or", "month", "number", "if", "numerical", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/date.py#L63-L73
[ "def", "month", "(", "abbr", "=", "False", ",", "numerical", "=", "False", ")", ":", "if", "numerical", ":", "return", "random", ".", "randint", "(", "1", ",", "12", ")", "else", ":", "if", "abbr", ":", "return", "random", ".", "choice", "(", "MONT...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
year
Return a random year.
forgery_py/forgery/date.py
def year(past=False, min_delta=0, max_delta=20): """Return a random year.""" return dt.date.today().year + _delta(past, min_delta, max_delta)
def year(past=False, min_delta=0, max_delta=20): """Return a random year.""" return dt.date.today().year + _delta(past, min_delta, max_delta)
[ "Return", "a", "random", "year", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/date.py#L85-L87
[ "def", "year", "(", "past", "=", "False", ",", "min_delta", "=", "0", ",", "max_delta", "=", "20", ")", ":", "return", "dt", ".", "date", ".", "today", "(", ")", ".", "year", "+", "_delta", "(", "past", ",", "min_delta", ",", "max_delta", ")" ]
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
date
Return a random `dt.date` object. Delta args are days.
forgery_py/forgery/date.py
def date(past=False, min_delta=0, max_delta=20): """Return a random `dt.date` object. Delta args are days.""" timedelta = dt.timedelta(days=_delta(past, min_delta, max_delta)) return dt.date.today() + timedelta
def date(past=False, min_delta=0, max_delta=20): """Return a random `dt.date` object. Delta args are days.""" timedelta = dt.timedelta(days=_delta(past, min_delta, max_delta)) return dt.date.today() + timedelta
[ "Return", "a", "random", "dt", ".", "date", "object", ".", "Delta", "args", "are", "days", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/date.py#L95-L98
[ "def", "date", "(", "past", "=", "False", ",", "min_delta", "=", "0", ",", "max_delta", "=", "20", ")", ":", "timedelta", "=", "dt", ".", "timedelta", "(", "days", "=", "_delta", "(", "past", ",", "min_delta", ",", "max_delta", ")", ")", "return", ...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
get_dictionary
Load a dictionary file ``dict_name`` (if it's not cached) and return its contents as an array of strings.
forgery_py/dictionaries_loader.py
def get_dictionary(dict_name): """ Load a dictionary file ``dict_name`` (if it's not cached) and return its contents as an array of strings. """ global dictionaries_cache if dict_name not in dictionaries_cache: try: dictionary_file = codecs.open( join(DICTION...
def get_dictionary(dict_name): """ Load a dictionary file ``dict_name`` (if it's not cached) and return its contents as an array of strings. """ global dictionaries_cache if dict_name not in dictionaries_cache: try: dictionary_file = codecs.open( join(DICTION...
[ "Load", "a", "dictionary", "file", "dict_name", "(", "if", "it", "s", "not", "cached", ")", "and", "return", "its", "contents", "as", "an", "array", "of", "strings", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/dictionaries_loader.py#L32-L50
[ "def", "get_dictionary", "(", "dict_name", ")", ":", "global", "dictionaries_cache", "if", "dict_name", "not", "in", "dictionaries_cache", ":", "try", ":", "dictionary_file", "=", "codecs", ".", "open", "(", "join", "(", "DICTIONARIES_PATH", ",", "dict_name", ")...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
check_digit
Return a check digit of the given credit card number. Check digit calculated using Luhn algorithm ("modulus 10") See: http://www.darkcoding.net/credit-card/luhn-formula/
forgery_py/forgery/credit_card.py
def check_digit(num): """Return a check digit of the given credit card number. Check digit calculated using Luhn algorithm ("modulus 10") See: http://www.darkcoding.net/credit-card/luhn-formula/ """ sum = 0 # drop last digit, then reverse the number digits = str(num)[:-1][::-1] for i,...
def check_digit(num): """Return a check digit of the given credit card number. Check digit calculated using Luhn algorithm ("modulus 10") See: http://www.darkcoding.net/credit-card/luhn-formula/ """ sum = 0 # drop last digit, then reverse the number digits = str(num)[:-1][::-1] for i,...
[ "Return", "a", "check", "digit", "of", "the", "given", "credit", "card", "number", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/credit_card.py#L48-L70
[ "def", "check_digit", "(", "num", ")", ":", "sum", "=", "0", "# drop last digit, then reverse the number", "digits", "=", "str", "(", "num", ")", "[", ":", "-", "1", "]", "[", ":", ":", "-", "1", "]", "for", "i", ",", "n", "in", "enumerate", "(", "...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
number
Return a random credit card number. :param type: credit card type. Defaults to a random selection. :param length: length of the credit card number. Defaults to the length for the selected card type. :param prefixes: allowed prefixes for the card number. Defaults to p...
forgery_py/forgery/credit_card.py
def number(type=None, length=None, prefixes=None): """ Return a random credit card number. :param type: credit card type. Defaults to a random selection. :param length: length of the credit card number. Defaults to the length for the selected card type. :param prefixes: allowed p...
def number(type=None, length=None, prefixes=None): """ Return a random credit card number. :param type: credit card type. Defaults to a random selection. :param length: length of the credit card number. Defaults to the length for the selected card type. :param prefixes: allowed p...
[ "Return", "a", "random", "credit", "card", "number", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/credit_card.py#L73-L107
[ "def", "number", "(", "type", "=", "None", ",", "length", "=", "None", ",", "prefixes", "=", "None", ")", ":", "# select credit card type", "if", "type", "and", "type", "in", "CARDS", ":", "card", "=", "type", "else", ":", "card", "=", "random", ".", ...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
street_number
Return a random street number.
forgery_py/forgery/address.py
def street_number(): """Return a random street number.""" length = int(random.choice(string.digits[1:6])) return ''.join(random.sample(string.digits, length))
def street_number(): """Return a random street number.""" length = int(random.choice(string.digits[1:6])) return ''.join(random.sample(string.digits, length))
[ "Return", "a", "random", "street", "number", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/address.py#L45-L48
[ "def", "street_number", "(", ")", ":", "length", "=", "int", "(", "random", ".", "choice", "(", "string", ".", "digits", "[", "1", ":", "6", "]", ")", ")", "return", "''", ".", "join", "(", "random", ".", "sample", "(", "string", ".", "digits", "...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
zip_code
Return a random ZIP code, either in `#####` or `#####-####` format.
forgery_py/forgery/address.py
def zip_code(): """Return a random ZIP code, either in `#####` or `#####-####` format.""" format = '#####' if random.random() >= 0.5: format = '#####-####' result = '' for item in format: if item == '#': result += str(random.randint(0, 9)) else: resul...
def zip_code(): """Return a random ZIP code, either in `#####` or `#####-####` format.""" format = '#####' if random.random() >= 0.5: format = '#####-####' result = '' for item in format: if item == '#': result += str(random.randint(0, 9)) else: resul...
[ "Return", "a", "random", "ZIP", "code", "either", "in", "#####", "or", "#####", "-", "####", "format", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/address.py#L90-L103
[ "def", "zip_code", "(", ")", ":", "format", "=", "'#####'", "if", "random", ".", "random", "(", ")", ">=", "0.5", ":", "format", "=", "'#####-####'", "result", "=", "''", "for", "item", "in", "format", ":", "if", "item", "==", "'#'", ":", "result", ...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
phone
Return a random phone number in `#-(###)###-####` format.
forgery_py/forgery/address.py
def phone(): """Return a random phone number in `#-(###)###-####` format.""" format = '#-(###)###-####' result = '' for item in format: if item == '#': result += str(random.randint(0, 9)) else: result += item return result
def phone(): """Return a random phone number in `#-(###)###-####` format.""" format = '#-(###)###-####' result = '' for item in format: if item == '#': result += str(random.randint(0, 9)) else: result += item return result
[ "Return", "a", "random", "phone", "number", "in", "#", "-", "(", "###", ")", "###", "-", "####", "format", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/address.py#L106-L117
[ "def", "phone", "(", ")", ":", "format", "=", "'#-(###)###-####'", "result", "=", "''", "for", "item", "in", "format", ":", "if", "item", "==", "'#'", ":", "result", "+=", "str", "(", "random", ".", "randint", "(", "0", ",", "9", ")", ")", "else", ...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
job_title
Return a random job title.
forgery_py/forgery/name.py
def job_title(): """Return a random job title.""" result = random.choice(get_dictionary('job_titles')).strip() result = result.replace('#{N}', job_title_suffix()) return result
def job_title(): """Return a random job title.""" result = random.choice(get_dictionary('job_titles')).strip() result = result.replace('#{N}', job_title_suffix()) return result
[ "Return", "a", "random", "job", "title", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/name.py#L74-L78
[ "def", "job_title", "(", ")", ":", "result", "=", "random", ".", "choice", "(", "get_dictionary", "(", "'job_titles'", ")", ")", ".", "strip", "(", ")", "result", "=", "result", ".", "replace", "(", "'#{N}'", ",", "job_title_suffix", "(", ")", ")", "re...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
body
Return a random email text.
forgery_py/forgery/email.py
def body(quantity=2, separator='\n\n', wrap_start='', wrap_end='', html=False, sentences_quantity=3, as_list=False): """Return a random email text.""" return lorem_ipsum.paragraphs(quantity=quantity, separator=separator, wrap_start=wrap_start, wrap_end=wrap_end, ...
def body(quantity=2, separator='\n\n', wrap_start='', wrap_end='', html=False, sentences_quantity=3, as_list=False): """Return a random email text.""" return lorem_ipsum.paragraphs(quantity=quantity, separator=separator, wrap_start=wrap_start, wrap_end=wrap_end, ...
[ "Return", "a", "random", "email", "text", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/email.py#L36-L43
[ "def", "body", "(", "quantity", "=", "2", ",", "separator", "=", "'\\n\\n'", ",", "wrap_start", "=", "''", ",", "wrap_end", "=", "''", ",", "html", "=", "False", ",", "sentences_quantity", "=", "3", ",", "as_list", "=", "False", ")", ":", "return", "...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
money
Return a str of decimal with two digits after a decimal mark.
forgery_py/forgery/monetary.py
def money(min=0, max=10): """Return a str of decimal with two digits after a decimal mark.""" value = random.choice(range(min * 100, max * 100)) return "%1.2f" % (float(value) / 100)
def money(min=0, max=10): """Return a str of decimal with two digits after a decimal mark.""" value = random.choice(range(min * 100, max * 100)) return "%1.2f" % (float(value) / 100)
[ "Return", "a", "str", "of", "decimal", "with", "two", "digits", "after", "a", "decimal", "mark", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/monetary.py#L33-L36
[ "def", "money", "(", "min", "=", "0", ",", "max", "=", "10", ")", ":", "value", "=", "random", ".", "choice", "(", "range", "(", "min", "*", "100", ",", "max", "*", "100", ")", ")", "return", "\"%1.2f\"", "%", "(", "float", "(", "value", ")", ...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
words
Return random words.
forgery_py/forgery/lorem_ipsum.py
def words(quantity=10, as_list=False): """Return random words.""" global _words if not _words: _words = ' '.join(get_dictionary('lorem_ipsum')).lower().\ replace('\n', '') _words = re.sub(r'\.|,|;/', '', _words) _words = _words.split(' ') result = random.sample(_wor...
def words(quantity=10, as_list=False): """Return random words.""" global _words if not _words: _words = ' '.join(get_dictionary('lorem_ipsum')).lower().\ replace('\n', '') _words = re.sub(r'\.|,|;/', '', _words) _words = _words.split(' ') result = random.sample(_wor...
[ "Return", "random", "words", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/lorem_ipsum.py#L47-L62
[ "def", "words", "(", "quantity", "=", "10", ",", "as_list", "=", "False", ")", ":", "global", "_words", "if", "not", "_words", ":", "_words", "=", "' '", ".", "join", "(", "get_dictionary", "(", "'lorem_ipsum'", ")", ")", ".", "lower", "(", ")", ".",...
e15f2e59538deb4cbfceaac314f5ea897f2d5450
valid
title
Return a random sentence to be used as e.g. an e-mail subject.
forgery_py/forgery/lorem_ipsum.py
def title(words_quantity=4): """Return a random sentence to be used as e.g. an e-mail subject.""" result = words(quantity=words_quantity) result += random.choice('?.!') return result.capitalize()
def title(words_quantity=4): """Return a random sentence to be used as e.g. an e-mail subject.""" result = words(quantity=words_quantity) result += random.choice('?.!') return result.capitalize()
[ "Return", "a", "random", "sentence", "to", "be", "used", "as", "e", ".", "g", ".", "an", "e", "-", "mail", "subject", "." ]
pilosus/ForgeryPy3
python
https://github.com/pilosus/ForgeryPy3/blob/e15f2e59538deb4cbfceaac314f5ea897f2d5450/forgery_py/forgery/lorem_ipsum.py#L65-L69
[ "def", "title", "(", "words_quantity", "=", "4", ")", ":", "result", "=", "words", "(", "quantity", "=", "words_quantity", ")", "result", "+=", "random", ".", "choice", "(", "'?.!'", ")", "return", "result", ".", "capitalize", "(", ")" ]
e15f2e59538deb4cbfceaac314f5ea897f2d5450