repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
mbunse/socket_client_server
socket_client_server/socket_client_server.py
Sock_Server.quit
def quit(self): """ Quit socket server """ logging.info("quiting sock server") if self.__quit is not None: self.__quit.set() self.join() return
python
def quit(self): """ Quit socket server """ logging.info("quiting sock server") if self.__quit is not None: self.__quit.set() self.join() return
[ "def", "quit", "(", "self", ")", ":", "logging", ".", "info", "(", "\"quiting sock server\"", ")", "if", "self", ".", "__quit", "is", "not", "None", ":", "self", ".", "__quit", ".", "set", "(", ")", "self", ".", "join", "(", ")", "return" ]
Quit socket server
[ "Quit", "socket", "server" ]
8e884925cf887d386554c1859f626d8f01bd0036
https://github.com/mbunse/socket_client_server/blob/8e884925cf887d386554c1859f626d8f01bd0036/socket_client_server/socket_client_server.py#L146-L154
train
Quit the server and join it.
mbunse/socket_client_server
socket_client_server/socket_client_server.py
Sock_Server.run
def run(self): """ Loop for server. Executed via `Sock_Server.start()`. """ # Bind the socket to the port logging.info("Server starts socket on {addr}".format(addr=self.server_address)) # Create a UDS socket if six.PY2: sock = socket.socket(...
python
def run(self): """ Loop for server. Executed via `Sock_Server.start()`. """ # Bind the socket to the port logging.info("Server starts socket on {addr}".format(addr=self.server_address)) # Create a UDS socket if six.PY2: sock = socket.socket(...
[ "def", "run", "(", "self", ")", ":", "# Bind the socket to the port\r", "logging", ".", "info", "(", "\"Server starts socket on {addr}\"", ".", "format", "(", "addr", "=", "self", ".", "server_address", ")", ")", "# Create a UDS socket\r", "if", "six", ".", "PY2",...
Loop for server. Executed via `Sock_Server.start()`.
[ "Loop", "for", "server", ".", "Executed", "via", "Sock_Server", ".", "start", "()", "." ]
8e884925cf887d386554c1859f626d8f01bd0036
https://github.com/mbunse/socket_client_server/blob/8e884925cf887d386554c1859f626d8f01bd0036/socket_client_server/socket_client_server.py#L182-L202
train
Loop for server. Executed via Sock_Server. start.
kurtbrose/faststat
faststat/format.py
si_round
def si_round(val): ''' round to a "scientific notation" tuple of (factor, exponent) such that 1 < factor < 1000, and factor * 10 ** exponent == val ''' if val < 0: neg = True val = -val elif val == 0: return 0, 0 else: neg = False exp = math.log(val) / mat...
python
def si_round(val): ''' round to a "scientific notation" tuple of (factor, exponent) such that 1 < factor < 1000, and factor * 10 ** exponent == val ''' if val < 0: neg = True val = -val elif val == 0: return 0, 0 else: neg = False exp = math.log(val) / mat...
[ "def", "si_round", "(", "val", ")", ":", "if", "val", "<", "0", ":", "neg", "=", "True", "val", "=", "-", "val", "elif", "val", "==", "0", ":", "return", "0", ",", "0", "else", ":", "neg", "=", "False", "exp", "=", "math", ".", "log", "(", ...
round to a "scientific notation" tuple of (factor, exponent) such that 1 < factor < 1000, and factor * 10 ** exponent == val
[ "round", "to", "a", "scientific", "notation", "tuple", "of", "(", "factor", "exponent", ")", "such", "that", "1", "<", "factor", "<", "1000", "and", "factor", "*", "10", "**", "exponent", "==", "val" ]
5060c0e10acaafd4a48de3f16869bfccc1deb44a
https://github.com/kurtbrose/faststat/blob/5060c0e10acaafd4a48de3f16869bfccc1deb44a/faststat/format.py#L23-L43
train
round to a scientific notation tuple of factor and exponent
glormph/msstitch
src/app/actions/peptable/psmtopeptable.py
get_quantcols
def get_quantcols(pattern, oldheader, coltype): """Searches for quantification columns using pattern and header list. Calls reader function to do regexp. Returns a single column for precursor quant.""" if pattern is None: return False if coltype == 'precur': return reader.get_cols_in_...
python
def get_quantcols(pattern, oldheader, coltype): """Searches for quantification columns using pattern and header list. Calls reader function to do regexp. Returns a single column for precursor quant.""" if pattern is None: return False if coltype == 'precur': return reader.get_cols_in_...
[ "def", "get_quantcols", "(", "pattern", ",", "oldheader", ",", "coltype", ")", ":", "if", "pattern", "is", "None", ":", "return", "False", "if", "coltype", "==", "'precur'", ":", "return", "reader", ".", "get_cols_in_file", "(", "pattern", ",", "oldheader", ...
Searches for quantification columns using pattern and header list. Calls reader function to do regexp. Returns a single column for precursor quant.
[ "Searches", "for", "quantification", "columns", "using", "pattern", "and", "header", "list", ".", "Calls", "reader", "function", "to", "do", "regexp", ".", "Returns", "a", "single", "column", "for", "precursor", "quant", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/peptable/psmtopeptable.py#L10-L17
train
Searches for quantification columns using pattern and header list. Returns a single column for precursor quant.
glormph/msstitch
src/app/actions/peptable/psmtopeptable.py
get_peptide_quant
def get_peptide_quant(quantdata, quanttype): """Parses lists of quantdata and returns maxvalue from them. Strips NA""" parsefnx = {'precur': max} quantfloats = [] for q in quantdata: try: quantfloats.append(float(q)) except(TypeError, ValueError): pass if not ...
python
def get_peptide_quant(quantdata, quanttype): """Parses lists of quantdata and returns maxvalue from them. Strips NA""" parsefnx = {'precur': max} quantfloats = [] for q in quantdata: try: quantfloats.append(float(q)) except(TypeError, ValueError): pass if not ...
[ "def", "get_peptide_quant", "(", "quantdata", ",", "quanttype", ")", ":", "parsefnx", "=", "{", "'precur'", ":", "max", "}", "quantfloats", "=", "[", "]", "for", "q", "in", "quantdata", ":", "try", ":", "quantfloats", ".", "append", "(", "float", "(", ...
Parses lists of quantdata and returns maxvalue from them. Strips NA
[ "Parses", "lists", "of", "quantdata", "and", "returns", "maxvalue", "from", "them", ".", "Strips", "NA" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/peptable/psmtopeptable.py#L50-L61
train
Parses a list of quantdata and returns maxvalue from them. Strips NA
neithere/monk
monk/compat.py
safe_str
def safe_str(value): """ Returns: * a `str` instance (bytes) in Python 2.x, or * a `str` instance (Unicode) in Python 3.x. """ if sys.version_info < (3,0) and isinstance(value, unicode): return value.encode('utf-8') else: return str(value)
python
def safe_str(value): """ Returns: * a `str` instance (bytes) in Python 2.x, or * a `str` instance (Unicode) in Python 3.x. """ if sys.version_info < (3,0) and isinstance(value, unicode): return value.encode('utf-8') else: return str(value)
[ "def", "safe_str", "(", "value", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", "0", ")", "and", "isinstance", "(", "value", ",", "unicode", ")", ":", "return", "value", ".", "encode", "(", "'utf-8'", ")", "else", ":", "return", "s...
Returns: * a `str` instance (bytes) in Python 2.x, or * a `str` instance (Unicode) in Python 3.x.
[ "Returns", ":" ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/compat.py#L50-L60
train
Returns a string representation of the given value.
neithere/monk
monk/compat.py
safe_unicode
def safe_unicode(value): """ Returns: * a `unicode` instance in Python 2.x, or * a `str` instance in Python 3.x. """ if sys.version_info < (3,0): if isinstance(value, str): return value.decode('utf-8') else: return unicode(value) else: return str...
python
def safe_unicode(value): """ Returns: * a `unicode` instance in Python 2.x, or * a `str` instance in Python 3.x. """ if sys.version_info < (3,0): if isinstance(value, str): return value.decode('utf-8') else: return unicode(value) else: return str...
[ "def", "safe_unicode", "(", "value", ")", ":", "if", "sys", ".", "version_info", "<", "(", "3", ",", "0", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "return", "value", ".", "decode", "(", "'utf-8'", ")", "else", ":", "return"...
Returns: * a `unicode` instance in Python 2.x, or * a `str` instance in Python 3.x.
[ "Returns", ":" ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/compat.py#L63-L76
train
Returns a unicode instance in Python 2. x or str in Python 3. x.
Erotemic/utool
utool/util_csv.py
read_csv
def read_csv(fpath): """ reads csv in unicode """ import csv import utool as ut #csvfile = open(fpath, 'rb') with open(fpath, 'rb') as csvfile: row_iter = csv.reader(csvfile, delimiter=str(','), quotechar=str('|')) row_list = [ut.lmap(ut.ensure_unicode, row) for row in row_iter] ...
python
def read_csv(fpath): """ reads csv in unicode """ import csv import utool as ut #csvfile = open(fpath, 'rb') with open(fpath, 'rb') as csvfile: row_iter = csv.reader(csvfile, delimiter=str(','), quotechar=str('|')) row_list = [ut.lmap(ut.ensure_unicode, row) for row in row_iter] ...
[ "def", "read_csv", "(", "fpath", ")", ":", "import", "csv", "import", "utool", "as", "ut", "#csvfile = open(fpath, 'rb')", "with", "open", "(", "fpath", ",", "'rb'", ")", "as", "csvfile", ":", "row_iter", "=", "csv", ".", "reader", "(", "csvfile", ",", "...
reads csv in unicode
[ "reads", "csv", "in", "unicode" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_csv.py#L151-L159
train
reads csv in unicode
Erotemic/utool
utool/util_csv.py
make_csv_table
def make_csv_table(column_list=[], column_lbls=None, header='', column_type=None, row_lbls=None, transpose=False, precision=2, use_lbl_width=True, comma_repl='<com>', raw=False, new=False, standardize=False): """ Creates a csv table with aligned columns ...
python
def make_csv_table(column_list=[], column_lbls=None, header='', column_type=None, row_lbls=None, transpose=False, precision=2, use_lbl_width=True, comma_repl='<com>', raw=False, new=False, standardize=False): """ Creates a csv table with aligned columns ...
[ "def", "make_csv_table", "(", "column_list", "=", "[", "]", ",", "column_lbls", "=", "None", ",", "header", "=", "''", ",", "column_type", "=", "None", ",", "row_lbls", "=", "None", ",", "transpose", "=", "False", ",", "precision", "=", "2", ",", "use_...
Creates a csv table with aligned columns make_csv_table Args: column_list (list): column_lbls (None): header (str): column_type (None): row_lbls (None): transpose (bool): Returns: str: csv_text Example: >>> # ENABLE_DOCTEST >>> ...
[ "Creates", "a", "csv", "table", "with", "aligned", "columns" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_csv.py#L183-L366
train
Function creates a csv table with aligned columns
Erotemic/utool
utool/_internal/meta_util_dbg.py
get_caller_name
def get_caller_name(N=0, strict=True): """ Standalone version of get_caller_name """ if isinstance(N, (list, tuple)): name_list = [] for N_ in N: try: name_list.append(get_caller_name(N_)) except AssertionError: name_list.append('X') ...
python
def get_caller_name(N=0, strict=True): """ Standalone version of get_caller_name """ if isinstance(N, (list, tuple)): name_list = [] for N_ in N: try: name_list.append(get_caller_name(N_)) except AssertionError: name_list.append('X') ...
[ "def", "get_caller_name", "(", "N", "=", "0", ",", "strict", "=", "True", ")", ":", "if", "isinstance", "(", "N", ",", "(", "list", ",", "tuple", ")", ")", ":", "name_list", "=", "[", "]", "for", "N_", "in", "N", ":", "try", ":", "name_list", "...
Standalone version of get_caller_name
[ "Standalone", "version", "of", "get_caller_name" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/meta_util_dbg.py#L27-L47
train
Standalone version of get_caller_name
quikmile/trellio
trellio/registry.py
registry_dump_handle
async def registry_dump_handle(request): ''' only read :param request: :return: ''' registry = registry_dump_handle.registry response_dict = {} repo = registry._repository response_dict['registered_services'] = repo._registered_services response_dict['uptimes'] = repo._uptimes ...
python
async def registry_dump_handle(request): ''' only read :param request: :return: ''' registry = registry_dump_handle.registry response_dict = {} repo = registry._repository response_dict['registered_services'] = repo._registered_services response_dict['uptimes'] = repo._uptimes ...
[ "async", "def", "registry_dump_handle", "(", "request", ")", ":", "registry", "=", "registry_dump_handle", ".", "registry", "response_dict", "=", "{", "}", "repo", "=", "registry", ".", "_repository", "response_dict", "[", "'registered_services'", "]", "=", "repo"...
only read :param request: :return:
[ "only", "read", ":", "param", "request", ":", ":", "return", ":" ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/registry.py#L398-L410
train
This function is used to dump the registry content.
quikmile/trellio
trellio/registry.py
Registry._handle_ping
def _handle_ping(self, packet, protocol): """ Responds to pings from registry_client only if the node_ids present in the ping payload are registered :param packet: The 'ping' packet received :param protocol: The protocol on which the pong should be sent """ if 'payload' in packe...
python
def _handle_ping(self, packet, protocol): """ Responds to pings from registry_client only if the node_ids present in the ping payload are registered :param packet: The 'ping' packet received :param protocol: The protocol on which the pong should be sent """ if 'payload' in packe...
[ "def", "_handle_ping", "(", "self", ",", "packet", ",", "protocol", ")", ":", "if", "'payload'", "in", "packet", ":", "is_valid_node", "=", "True", "node_ids", "=", "list", "(", "packet", "[", "'payload'", "]", ".", "values", "(", ")", ")", "for", "nod...
Responds to pings from registry_client only if the node_ids present in the ping payload are registered :param packet: The 'ping' packet received :param protocol: The protocol on which the pong should be sent
[ "Responds", "to", "pings", "from", "registry_client", "only", "if", "the", "node_ids", "present", "in", "the", "ping", "payload", "are", "registered" ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/registry.py#L379-L395
train
Handles a ping packet from registry_client only if the node_ids present in the ping payload are registered and the pong should be sent.
glormph/msstitch
src/app/drivers/pycolator/splitmerge.py
SplitDriver.set_features
def set_features(self, filter_type): """Calls splitter to split percolator output into target/decoy elements. Writes two new xml files with features. Currently only psms and peptides. Proteins not here, since one cannot do protein inference before having merged and remapped multi...
python
def set_features(self, filter_type): """Calls splitter to split percolator output into target/decoy elements. Writes two new xml files with features. Currently only psms and peptides. Proteins not here, since one cannot do protein inference before having merged and remapped multi...
[ "def", "set_features", "(", "self", ",", "filter_type", ")", ":", "elements_to_split", "=", "{", "'psm'", ":", "self", ".", "allpsms", ",", "'peptide'", ":", "self", ".", "allpeps", "}", "self", ".", "features", "=", "self", ".", "splitfunc", "(", "eleme...
Calls splitter to split percolator output into target/decoy elements. Writes two new xml files with features. Currently only psms and peptides. Proteins not here, since one cannot do protein inference before having merged and remapped multifraction data anyway.
[ "Calls", "splitter", "to", "split", "percolator", "output", "into", "target", "/", "decoy", "elements", ".", "Writes", "two", "new", "xml", "files", "with", "features", ".", "Currently", "only", "psms", "and", "peptides", ".", "Proteins", "not", "here", "sin...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/pycolator/splitmerge.py#L25-L33
train
Calls splitter to split percolator output into target and decoy elements.
glormph/msstitch
src/app/drivers/pycolator/splitmerge.py
MergeDriver.set_features
def set_features(self): """"Merge all psms and peptides""" allpsms_str = readers.generate_psms_multiple_fractions_strings( self.mergefiles, self.ns) allpeps = preparation.merge_peptides(self.mergefiles, self.ns) self.features = {'psm': allpsms_str, 'peptide': allpeps}
python
def set_features(self): """"Merge all psms and peptides""" allpsms_str = readers.generate_psms_multiple_fractions_strings( self.mergefiles, self.ns) allpeps = preparation.merge_peptides(self.mergefiles, self.ns) self.features = {'psm': allpsms_str, 'peptide': allpeps}
[ "def", "set_features", "(", "self", ")", ":", "allpsms_str", "=", "readers", ".", "generate_psms_multiple_fractions_strings", "(", "self", ".", "mergefiles", ",", "self", ".", "ns", ")", "allpeps", "=", "preparation", ".", "merge_peptides", "(", "self", ".", "...
Merge all psms and peptides
[ "Merge", "all", "psms", "and", "peptides" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/pycolator/splitmerge.py#L94-L99
train
Merge all psms and peptides
Erotemic/utool
utool/util_git.py
git_sequence_editor_squash
def git_sequence_editor_squash(fpath): r""" squashes wip messages CommandLine: python -m utool.util_git --exec-git_sequence_editor_squash Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> import utool as ut >>> from utool.util_git import * # NOQA >>> fpat...
python
def git_sequence_editor_squash(fpath): r""" squashes wip messages CommandLine: python -m utool.util_git --exec-git_sequence_editor_squash Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> import utool as ut >>> from utool.util_git import * # NOQA >>> fpat...
[ "def", "git_sequence_editor_squash", "(", "fpath", ")", ":", "# print(sys.argv)", "import", "utool", "as", "ut", "text", "=", "ut", ".", "read_from", "(", "fpath", ")", "# print('fpath = %r' % (fpath,))", "print", "(", "text", ")", "# Doesnt work because of fixed witd...
r""" squashes wip messages CommandLine: python -m utool.util_git --exec-git_sequence_editor_squash Example: >>> # DISABLE_DOCTEST >>> # SCRIPT >>> import utool as ut >>> from utool.util_git import * # NOQA >>> fpath = ut.get_argval('--fpath', str, default=N...
[ "r", "squashes", "wip", "messages" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_git.py#L876-L1016
train
r git - sequence - editor squashes all non - interactive commits with same message
Erotemic/utool
utool/util_git.py
std_build_command
def std_build_command(repo='.'): """ DEPRICATE My standard build script names. Calls mingw_build.bat on windows and unix_build.sh on unix """ import utool as ut print('+**** stdbuild *******') print('repo = %r' % (repo,)) if sys.platform.startswith('win32'): # vtool --rebui...
python
def std_build_command(repo='.'): """ DEPRICATE My standard build script names. Calls mingw_build.bat on windows and unix_build.sh on unix """ import utool as ut print('+**** stdbuild *******') print('repo = %r' % (repo,)) if sys.platform.startswith('win32'): # vtool --rebui...
[ "def", "std_build_command", "(", "repo", "=", "'.'", ")", ":", "import", "utool", "as", "ut", "print", "(", "'+**** stdbuild *******'", ")", "print", "(", "'repo = %r'", "%", "(", "repo", ",", ")", ")", "if", "sys", ".", "platform", ".", "startswith", "(...
DEPRICATE My standard build script names. Calls mingw_build.bat on windows and unix_build.sh on unix
[ "DEPRICATE", "My", "standard", "build", "script", "names", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_git.py#L1019-L1047
train
This function is used to build a standard build script.
Thermondo/django-heroku-connect
heroku_connect/management/commands/import_mappings.py
Command.wait_for_import
def wait_for_import(self, connection_id, wait_interval): """ Wait until connection state is no longer ``IMPORT_CONFIGURATION``. Args: connection_id (str): Heroku Connect connection to monitor. wait_interval (int): How frequently to poll in seconds. Raises: ...
python
def wait_for_import(self, connection_id, wait_interval): """ Wait until connection state is no longer ``IMPORT_CONFIGURATION``. Args: connection_id (str): Heroku Connect connection to monitor. wait_interval (int): How frequently to poll in seconds. Raises: ...
[ "def", "wait_for_import", "(", "self", ",", "connection_id", ",", "wait_interval", ")", ":", "self", ".", "stdout", ".", "write", "(", "self", ".", "style", ".", "NOTICE", "(", "'Waiting for import'", ")", ",", "ending", "=", "''", ")", "state", "=", "ut...
Wait until connection state is no longer ``IMPORT_CONFIGURATION``. Args: connection_id (str): Heroku Connect connection to monitor. wait_interval (int): How frequently to poll in seconds. Raises: CommandError: If fetch connection information fails.
[ "Wait", "until", "connection", "state", "is", "no", "longer", "IMPORT_CONFIGURATION", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/management/commands/import_mappings.py#L76-L100
train
Wait until the Heroku Connect connection is no longer in the IMPORT_CONFIGURATION state.
ThreatResponse/aws_ir_plugins
aws_ir_plugins/disableaccess_key.py
Plugin.setup
def setup(self): """Method runs the plugin""" if self.dry_run is not True: self.client = self._get_client() self._disable_access_key()
python
def setup(self): """Method runs the plugin""" if self.dry_run is not True: self.client = self._get_client() self._disable_access_key()
[ "def", "setup", "(", "self", ")", ":", "if", "self", ".", "dry_run", "is", "not", "True", ":", "self", ".", "client", "=", "self", ".", "_get_client", "(", ")", "self", ".", "_disable_access_key", "(", ")" ]
Method runs the plugin
[ "Method", "runs", "the", "plugin" ]
b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73
https://github.com/ThreatResponse/aws_ir_plugins/blob/b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73/aws_ir_plugins/disableaccess_key.py#L29-L33
train
Method runs the plugin
ThreatResponse/aws_ir_plugins
aws_ir_plugins/disableaccess_key.py
Plugin.validate
def validate(self): """Returns whether this plugin does what it claims to have done""" try: response = self.client.get_access_key_last_used( AccessKeyId=self.access_key_id ) username = response['UserName'] access_keys = self.client.list_ac...
python
def validate(self): """Returns whether this plugin does what it claims to have done""" try: response = self.client.get_access_key_last_used( AccessKeyId=self.access_key_id ) username = response['UserName'] access_keys = self.client.list_ac...
[ "def", "validate", "(", "self", ")", ":", "try", ":", "response", "=", "self", ".", "client", ".", "get_access_key_last_used", "(", "AccessKeyId", "=", "self", ".", "access_key_id", ")", "username", "=", "response", "[", "'UserName'", "]", "access_keys", "="...
Returns whether this plugin does what it claims to have done
[ "Returns", "whether", "this", "plugin", "does", "what", "it", "claims", "to", "have", "done" ]
b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73
https://github.com/ThreatResponse/aws_ir_plugins/blob/b5128ef5cbd91fc0b5d55615f1c14cb036ae7c73/aws_ir_plugins/disableaccess_key.py#L35-L61
train
Returns whether this plugin does what it claims to have done
Erotemic/utool
utool/_internal/py2_syntax_funcs.py
ignores_exc_tb
def ignores_exc_tb(*args, **kwargs): """ PYTHON 2 ONLY VERSION -- needs to be in its own file for syntactic reasons ignore_exc_tb decorates a function and remove both itself and the function from any exception traceback that occurs. This is useful to decorate other trivial decorators which are...
python
def ignores_exc_tb(*args, **kwargs): """ PYTHON 2 ONLY VERSION -- needs to be in its own file for syntactic reasons ignore_exc_tb decorates a function and remove both itself and the function from any exception traceback that occurs. This is useful to decorate other trivial decorators which are...
[ "def", "ignores_exc_tb", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "outer_wrapper", "=", "kwargs", ".", "get", "(", "'outer_wrapper'", ",", "True", ")", "def", "ignores_exc_tb_closure", "(", "func", ")", ":", "if", "not", "IGNORE_TRACEBACK", ":"...
PYTHON 2 ONLY VERSION -- needs to be in its own file for syntactic reasons ignore_exc_tb decorates a function and remove both itself and the function from any exception traceback that occurs. This is useful to decorate other trivial decorators which are polluting your stacktrace. if IGNORE_TRACEB...
[ "PYTHON", "2", "ONLY", "VERSION", "--", "needs", "to", "be", "in", "its", "own", "file", "for", "syntactic", "reasons" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/py2_syntax_funcs.py#L10-L61
train
This function is used to decorate a function that ignores any exception traceback that occurs in the current thread.
glormph/msstitch
src/app/actions/prottable/create_empty.py
generate_master_proteins
def generate_master_proteins(psms, protcol): """Fed with a psms generator, this returns the master proteins present in the PSM table. PSMs with multiple master proteins are excluded.""" master_proteins = {} if not protcol: protcol = mzidtsvdata.HEADER_MASTER_PROT for psm in psms: pro...
python
def generate_master_proteins(psms, protcol): """Fed with a psms generator, this returns the master proteins present in the PSM table. PSMs with multiple master proteins are excluded.""" master_proteins = {} if not protcol: protcol = mzidtsvdata.HEADER_MASTER_PROT for psm in psms: pro...
[ "def", "generate_master_proteins", "(", "psms", ",", "protcol", ")", ":", "master_proteins", "=", "{", "}", "if", "not", "protcol", ":", "protcol", "=", "mzidtsvdata", ".", "HEADER_MASTER_PROT", "for", "psm", "in", "psms", ":", "protacc", "=", "psm", "[", ...
Fed with a psms generator, this returns the master proteins present in the PSM table. PSMs with multiple master proteins are excluded.
[ "Fed", "with", "a", "psms", "generator", "this", "returns", "the", "master", "proteins", "present", "in", "the", "PSM", "table", ".", "PSMs", "with", "multiple", "master", "proteins", "are", "excluded", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/create_empty.py#L5-L21
train
Fed with a psms generator this returns the master proteins present in the PSM table.
glormph/msstitch
src/app/drivers/pycolator/base.py
PycolatorDriver.prepare_percolator_output
def prepare_percolator_output(self, fn): """Returns namespace and static xml from percolator output file""" ns = xml.get_namespace(fn) static = readers.get_percolator_static_xml(fn, ns) return ns, static
python
def prepare_percolator_output(self, fn): """Returns namespace and static xml from percolator output file""" ns = xml.get_namespace(fn) static = readers.get_percolator_static_xml(fn, ns) return ns, static
[ "def", "prepare_percolator_output", "(", "self", ",", "fn", ")", ":", "ns", "=", "xml", ".", "get_namespace", "(", "fn", ")", "static", "=", "readers", ".", "get_percolator_static_xml", "(", "fn", ",", "ns", ")", "return", "ns", ",", "static" ]
Returns namespace and static xml from percolator output file
[ "Returns", "namespace", "and", "static", "xml", "from", "percolator", "output", "file" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/pycolator/base.py#L13-L17
train
Returns namespace and static xml from percolator output file
rhazdon/django-sonic-screwdriver
django_sonic_screwdriver/git/decorators.py
git_available
def git_available(func): """ Check, if a git repository exists in the given folder. """ def inner(*args): os.chdir(APISettings.GIT_DIR) if call(['git', 'rev-parse']) == 0: return func(*args) Shell.fail('There is no git repository!') return exit(1) retur...
python
def git_available(func): """ Check, if a git repository exists in the given folder. """ def inner(*args): os.chdir(APISettings.GIT_DIR) if call(['git', 'rev-parse']) == 0: return func(*args) Shell.fail('There is no git repository!') return exit(1) retur...
[ "def", "git_available", "(", "func", ")", ":", "def", "inner", "(", "*", "args", ")", ":", "os", ".", "chdir", "(", "APISettings", ".", "GIT_DIR", ")", "if", "call", "(", "[", "'git'", ",", "'rev-parse'", "]", ")", "==", "0", ":", "return", "func",...
Check, if a git repository exists in the given folder.
[ "Check", "if", "a", "git", "repository", "exists", "in", "the", "given", "folder", "." ]
89e885e8c1322fc5c3e0f79b03a55acdc6e63972
https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/git/decorators.py#L8-L21
train
Check if a git repository exists in the given folder.
YuriyGuts/pygoose
pygoose/kg/gpu.py
_cuda_get_gpu_spec_string
def _cuda_get_gpu_spec_string(gpu_ids=None): """ Build a GPU id string to be used for CUDA_VISIBLE_DEVICES. """ if gpu_ids is None: return '' if isinstance(gpu_ids, list): return ','.join(str(gpu_id) for gpu_id in gpu_ids) if isinstance(gpu_ids, int): return str(gpu_id...
python
def _cuda_get_gpu_spec_string(gpu_ids=None): """ Build a GPU id string to be used for CUDA_VISIBLE_DEVICES. """ if gpu_ids is None: return '' if isinstance(gpu_ids, list): return ','.join(str(gpu_id) for gpu_id in gpu_ids) if isinstance(gpu_ids, int): return str(gpu_id...
[ "def", "_cuda_get_gpu_spec_string", "(", "gpu_ids", "=", "None", ")", ":", "if", "gpu_ids", "is", "None", ":", "return", "''", "if", "isinstance", "(", "gpu_ids", ",", "list", ")", ":", "return", "','", ".", "join", "(", "str", "(", "gpu_id", ")", "for...
Build a GPU id string to be used for CUDA_VISIBLE_DEVICES.
[ "Build", "a", "GPU", "id", "string", "to", "be", "used", "for", "CUDA_VISIBLE_DEVICES", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/gpu.py#L4-L18
train
Build a GPU id string to be used for CUDA_VISIBLE_DEVICES.
chriso/gauged
gauged/bridge.py
SharedLibrary.prototype
def prototype(self, name, argtypes, restype=None): """Define argument / return types for the specified C function""" function = self.function(name) function.argtypes = argtypes if restype: function.restype = restype
python
def prototype(self, name, argtypes, restype=None): """Define argument / return types for the specified C function""" function = self.function(name) function.argtypes = argtypes if restype: function.restype = restype
[ "def", "prototype", "(", "self", ",", "name", ",", "argtypes", ",", "restype", "=", "None", ")", ":", "function", "=", "self", ".", "function", "(", "name", ")", "function", ".", "argtypes", "=", "argtypes", "if", "restype", ":", "function", ".", "rest...
Define argument / return types for the specified C function
[ "Define", "argument", "/", "return", "types", "for", "the", "specified", "C", "function" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/bridge.py#L31-L36
train
Define argument and return types for the specified C function name
dsoprea/NsqSpinner
nsq/identify.py
Identify.heartbeat_interval
def heartbeat_interval(self, heartbeat_interval_ms): """heartbeat_interval (nsqd 0.2.19+) milliseconds between heartbeats. Valid range: 1000 <= heartbeat_interval <= configured_max (-1 disables heartbeats) --max-heartbeat-interval (nsqd flag) controls the max Defaults to --cl...
python
def heartbeat_interval(self, heartbeat_interval_ms): """heartbeat_interval (nsqd 0.2.19+) milliseconds between heartbeats. Valid range: 1000 <= heartbeat_interval <= configured_max (-1 disables heartbeats) --max-heartbeat-interval (nsqd flag) controls the max Defaults to --cl...
[ "def", "heartbeat_interval", "(", "self", ",", "heartbeat_interval_ms", ")", ":", "assert", "issubclass", "(", "heartbeat_interval_ms", ".", "__class__", ",", "int", ")", "return", "self", ".", "__push", "(", "'heartbeat_interval'", ",", "heartbeat_interval_ms", ")"...
heartbeat_interval (nsqd 0.2.19+) milliseconds between heartbeats. Valid range: 1000 <= heartbeat_interval <= configured_max (-1 disables heartbeats) --max-heartbeat-interval (nsqd flag) controls the max Defaults to --client-timeout / 2
[ "heartbeat_interval", "(", "nsqd", "0", ".", "2", ".", "19", "+", ")", "milliseconds", "between", "heartbeats", "." ]
972237b8ddce737983bfed001fde52e5236be695
https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/identify.py#L103-L116
train
Set the heartbeat interval in milliseconds between heartbeats.
dsoprea/NsqSpinner
nsq/identify.py
Identify.output_buffer_size
def output_buffer_size(self, output_buffer_size_b): """output_buffer_size (nsqd 0.2.21+) the size in bytes of the buffer nsqd will use when writing to this client. Valid range: 64 <= output_buffer_size <= configured_max (-1 disables output buffering) --max-output-buffer-size ...
python
def output_buffer_size(self, output_buffer_size_b): """output_buffer_size (nsqd 0.2.21+) the size in bytes of the buffer nsqd will use when writing to this client. Valid range: 64 <= output_buffer_size <= configured_max (-1 disables output buffering) --max-output-buffer-size ...
[ "def", "output_buffer_size", "(", "self", ",", "output_buffer_size_b", ")", ":", "assert", "issubclass", "(", "output_buffer_size_b", ".", "__class__", ",", "int", ")", "return", "self", ".", "__push", "(", "'output_buffer_size'", ",", "output_buffer_size_b", ")" ]
output_buffer_size (nsqd 0.2.21+) the size in bytes of the buffer nsqd will use when writing to this client. Valid range: 64 <= output_buffer_size <= configured_max (-1 disables output buffering) --max-output-buffer-size (nsqd flag) controls the max Defaults to 16kb
[ "output_buffer_size", "(", "nsqd", "0", ".", "2", ".", "21", "+", ")", "the", "size", "in", "bytes", "of", "the", "buffer", "nsqd", "will", "use", "when", "writing", "to", "this", "client", "." ]
972237b8ddce737983bfed001fde52e5236be695
https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/identify.py#L118-L132
train
Set the output_buffer_size of the current entry
dsoprea/NsqSpinner
nsq/identify.py
Identify.deflate_level
def deflate_level(self, deflate_level): """deflate_level (nsqd 0.2.23+) configure the deflate compression level for this connection. --max-deflate-level (nsqd flag) configures the maximum allowed value Valid range: 1 <= deflate_level <= configured_max Higher values mean bette...
python
def deflate_level(self, deflate_level): """deflate_level (nsqd 0.2.23+) configure the deflate compression level for this connection. --max-deflate-level (nsqd flag) configures the maximum allowed value Valid range: 1 <= deflate_level <= configured_max Higher values mean bette...
[ "def", "deflate_level", "(", "self", ",", "deflate_level", ")", ":", "assert", "issubclass", "(", "deflate_level", ".", "__class__", ",", "int", ")", "return", "self", ".", "__push", "(", "'deflate_level'", ",", "deflate_level", ")" ]
deflate_level (nsqd 0.2.23+) configure the deflate compression level for this connection. --max-deflate-level (nsqd flag) configures the maximum allowed value Valid range: 1 <= deflate_level <= configured_max Higher values mean better compression but more CPU usage for nsqd.
[ "deflate_level", "(", "nsqd", "0", ".", "2", ".", "23", "+", ")", "configure", "the", "deflate", "compression", "level", "for", "this", "connection", "." ]
972237b8ddce737983bfed001fde52e5236be695
https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/identify.py#L197-L210
train
set the deflate level for this connection
dsoprea/NsqSpinner
nsq/identify.py
Identify.sample_rate
def sample_rate(self, sample_rate): """sample_rate (nsqd 0.2.25+) sample messages delivered over this connection. Valid range: 0 <= sample_rate <= 99 (0 disables sampling) Defaults to 0 """ assert issubclass(sample_rate.__class__, int) return self.__push('sam...
python
def sample_rate(self, sample_rate): """sample_rate (nsqd 0.2.25+) sample messages delivered over this connection. Valid range: 0 <= sample_rate <= 99 (0 disables sampling) Defaults to 0 """ assert issubclass(sample_rate.__class__, int) return self.__push('sam...
[ "def", "sample_rate", "(", "self", ",", "sample_rate", ")", ":", "assert", "issubclass", "(", "sample_rate", ".", "__class__", ",", "int", ")", "return", "self", ".", "__push", "(", "'sample_rate'", ",", "sample_rate", ")" ]
sample_rate (nsqd 0.2.25+) sample messages delivered over this connection. Valid range: 0 <= sample_rate <= 99 (0 disables sampling) Defaults to 0
[ "sample_rate", "(", "nsqd", "0", ".", "2", ".", "25", "+", ")", "sample", "messages", "delivered", "over", "this", "connection", "." ]
972237b8ddce737983bfed001fde52e5236be695
https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/identify.py#L212-L223
train
Set the sample rate of the current session.
dsoprea/NsqSpinner
nsq/identify.py
Identify.msg_timeout
def msg_timeout(self, msg_timeout_ms): """msg_timeout (nsqd 0.2.28+) configure the server-side message timeout for messages delivered to this client. """ assert issubclass(msg_timeout_ms.__class__, int) return self.__push('msg_timeout', msg_timeout_ms)
python
def msg_timeout(self, msg_timeout_ms): """msg_timeout (nsqd 0.2.28+) configure the server-side message timeout for messages delivered to this client. """ assert issubclass(msg_timeout_ms.__class__, int) return self.__push('msg_timeout', msg_timeout_ms)
[ "def", "msg_timeout", "(", "self", ",", "msg_timeout_ms", ")", ":", "assert", "issubclass", "(", "msg_timeout_ms", ".", "__class__", ",", "int", ")", "return", "self", ".", "__push", "(", "'msg_timeout'", ",", "msg_timeout_ms", ")" ]
msg_timeout (nsqd 0.2.28+) configure the server-side message timeout for messages delivered to this client.
[ "msg_timeout", "(", "nsqd", "0", ".", "2", ".", "28", "+", ")", "configure", "the", "server", "-", "side", "message", "timeout", "for", "messages", "delivered", "to", "this", "client", "." ]
972237b8ddce737983bfed001fde52e5236be695
https://github.com/dsoprea/NsqSpinner/blob/972237b8ddce737983bfed001fde52e5236be695/nsq/identify.py#L234-L241
train
set the server - side message timeout for messages delivered to this client
glormph/msstitch
src/app/drivers/mzidtsv/quant.py
TSVQuantDriver.get_psms
def get_psms(self): """Creates iterator to write to new tsv. Contains input tsv lines plus quant data for these.""" self.header, isob_header = prep.get_full_and_isobaric_headers( self.oldheader, self.lookup, self.isobaric, self.precursor) self.psms = prep.generate_psms_quante...
python
def get_psms(self): """Creates iterator to write to new tsv. Contains input tsv lines plus quant data for these.""" self.header, isob_header = prep.get_full_and_isobaric_headers( self.oldheader, self.lookup, self.isobaric, self.precursor) self.psms = prep.generate_psms_quante...
[ "def", "get_psms", "(", "self", ")", ":", "self", ".", "header", ",", "isob_header", "=", "prep", ".", "get_full_and_isobaric_headers", "(", "self", ".", "oldheader", ",", "self", ".", "lookup", ",", "self", ".", "isobaric", ",", "self", ".", "precursor", ...
Creates iterator to write to new tsv. Contains input tsv lines plus quant data for these.
[ "Creates", "iterator", "to", "write", "to", "new", "tsv", ".", "Contains", "input", "tsv", "lines", "plus", "quant", "data", "for", "these", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/mzidtsv/quant.py#L20-L27
train
Creates iterator to write to new tsv. Contains input tsv lines plus quant data for these.
moluwole/Bast
bast/controller.py
Controller.write_error
def write_error(self, status_code, **kwargs): """ Handle Exceptions from the server. Formats the HTML into readable form """ reason = self._reason if self.settings.get("serve_traceback") and "exc_info" in kwargs: error = [] for line in traceback.format_ex...
python
def write_error(self, status_code, **kwargs): """ Handle Exceptions from the server. Formats the HTML into readable form """ reason = self._reason if self.settings.get("serve_traceback") and "exc_info" in kwargs: error = [] for line in traceback.format_ex...
[ "def", "write_error", "(", "self", ",", "status_code", ",", "*", "*", "kwargs", ")", ":", "reason", "=", "self", ".", "_reason", "if", "self", ".", "settings", ".", "get", "(", "\"serve_traceback\"", ")", "and", "\"exc_info\"", "in", "kwargs", ":", "erro...
Handle Exceptions from the server. Formats the HTML into readable form
[ "Handle", "Exceptions", "from", "the", "server", ".", "Formats", "the", "HTML", "into", "readable", "form" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L37-L51
train
Handles exceptions from the server and writes the error to the output stream.
moluwole/Bast
bast/controller.py
Controller.view
def view(self, template_name, kwargs=None): """ Used to render template to view Sample usage +++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): self.view('index...
python
def view(self, template_name, kwargs=None): """ Used to render template to view Sample usage +++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): self.view('index...
[ "def", "view", "(", "self", ",", "template_name", ",", "kwargs", "=", "None", ")", ":", "if", "kwargs", "is", "None", ":", "kwargs", "=", "dict", "(", ")", "self", ".", "add_", "(", "'session'", ",", "self", ".", "session", ")", "content", "=", "se...
Used to render template to view Sample usage +++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): self.view('index.html')
[ "Used", "to", "render", "template", "to", "view" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L53-L73
train
Render a template to view the current object
moluwole/Bast
bast/controller.py
Controller.initialize
def initialize(self, method, middleware, request_type): """ Overridden initialize method from Tornado. Assigns the controller method and middleware attached to the route being executed to global variables to be used """ self.method = method self.middleware = middleware ...
python
def initialize(self, method, middleware, request_type): """ Overridden initialize method from Tornado. Assigns the controller method and middleware attached to the route being executed to global variables to be used """ self.method = method self.middleware = middleware ...
[ "def", "initialize", "(", "self", ",", "method", ",", "middleware", ",", "request_type", ")", ":", "self", ".", "method", "=", "method", "self", ".", "middleware", "=", "middleware", "self", ".", "request_type", "=", "request_type" ]
Overridden initialize method from Tornado. Assigns the controller method and middleware attached to the route being executed to global variables to be used
[ "Overridden", "initialize", "method", "from", "Tornado", ".", "Assigns", "the", "controller", "method", "and", "middleware", "attached", "to", "the", "route", "being", "executed", "to", "global", "variables", "to", "be", "used" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L98-L105
train
Override initialize method from Tornado.
moluwole/Bast
bast/controller.py
Controller.only
def only(self, arguments): """ returns the key, value pair of the arguments passed as a dict object Sample Usage ++++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): ...
python
def only(self, arguments): """ returns the key, value pair of the arguments passed as a dict object Sample Usage ++++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): ...
[ "def", "only", "(", "self", ",", "arguments", ")", ":", "data", "=", "{", "}", "if", "not", "isinstance", "(", "arguments", ",", "list", ")", ":", "arguments", "=", "list", "(", "arguments", ")", "for", "i", "in", "arguments", ":", "data", "[", "i"...
returns the key, value pair of the arguments passed as a dict object Sample Usage ++++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): data = self.only(['username']) Re...
[ "returns", "the", "key", "value", "pair", "of", "the", "arguments", "passed", "as", "a", "dict", "object" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L107-L129
train
Returns the key value pair of the arguments passed as a dict object
moluwole/Bast
bast/controller.py
Controller.all
def all(self): """ Returns all the arguments passed with the request Sample Usage ++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): data = self.all() R...
python
def all(self): """ Returns all the arguments passed with the request Sample Usage ++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): data = self.all() R...
[ "def", "all", "(", "self", ")", ":", "data", "=", "{", "}", "args", "=", "self", ".", "request", ".", "arguments", "for", "key", ",", "value", "in", "args", ".", "items", "(", ")", ":", "data", "[", "key", "]", "=", "self", ".", "get_argument", ...
Returns all the arguments passed with the request Sample Usage ++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): data = self.all() Returns a dictionary of all the requ...
[ "Returns", "all", "the", "arguments", "passed", "with", "the", "request" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L131-L153
train
Returns all the arguments passed with the request Sample Usage Usage ++++++++++++++
moluwole/Bast
bast/controller.py
Controller.except_
def except_(self, arguments): """ returns the arguments passed to the route except that set by user Sample Usage ++++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): ...
python
def except_(self, arguments): """ returns the arguments passed to the route except that set by user Sample Usage ++++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): ...
[ "def", "except_", "(", "self", ",", "arguments", ")", ":", "if", "not", "isinstance", "(", "arguments", ",", "list", ")", ":", "arguments", "=", "list", "(", "arguments", ")", "args", "=", "self", ".", "request", ".", "arguments", "data", "=", "{", "...
returns the arguments passed to the route except that set by user Sample Usage ++++++++++++++ .. code:: python from bast import Controller class MyController(Controller): def index(self): data = self.except_(['arg_name']) Re...
[ "returns", "the", "arguments", "passed", "to", "the", "route", "except", "that", "set", "by", "user" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L155-L180
train
Returns the arguments passed to the route except that set by user
moluwole/Bast
bast/controller.py
Controller.json
def json(self, data): """ Encodes the dictionary being passed to JSON and sets the Header to application/json """ self.write(json_.encode(data)) self.set_header('Content-type', 'application/json')
python
def json(self, data): """ Encodes the dictionary being passed to JSON and sets the Header to application/json """ self.write(json_.encode(data)) self.set_header('Content-type', 'application/json')
[ "def", "json", "(", "self", ",", "data", ")", ":", "self", ".", "write", "(", "json_", ".", "encode", "(", "data", ")", ")", "self", ".", "set_header", "(", "'Content-type'", ",", "'application/json'", ")" ]
Encodes the dictionary being passed to JSON and sets the Header to application/json
[ "Encodes", "the", "dictionary", "being", "passed", "to", "JSON", "and", "sets", "the", "Header", "to", "application", "/", "json" ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L182-L187
train
Writes the dictionary to the response and sets the Content - Type to application / json
moluwole/Bast
bast/controller.py
Controller.get_argument
def get_argument(self, name, default=None, strip=True): """ Returns the value of the argument with the given name. If default is not provided, returns ``None`` If the argument appears in the url more than once, we return the last value. The returned value is always unicode ...
python
def get_argument(self, name, default=None, strip=True): """ Returns the value of the argument with the given name. If default is not provided, returns ``None`` If the argument appears in the url more than once, we return the last value. The returned value is always unicode ...
[ "def", "get_argument", "(", "self", ",", "name", ",", "default", "=", "None", ",", "strip", "=", "True", ")", ":", "return", "self", ".", "_get_argument", "(", "name", ",", "default", ",", "self", ".", "request", ".", "arguments", ",", "strip", ")", ...
Returns the value of the argument with the given name. If default is not provided, returns ``None`` If the argument appears in the url more than once, we return the last value. The returned value is always unicode
[ "Returns", "the", "value", "of", "the", "argument", "with", "the", "given", "name", "." ]
eecf55ae72e6f24af7c101549be0422cd2c1c95a
https://github.com/moluwole/Bast/blob/eecf55ae72e6f24af7c101549be0422cd2c1c95a/bast/controller.py#L245-L255
train
Returns the value of the given name. If default is provided it returns the last value. If strip is True the value is stripped from the argument.
neithere/monk
monk/mongo.py
MongoBoundDictMixin.find
def find(cls, db, *args, **kwargs): """ Returns a :class:`MongoResultSet` object. Example:: items = Item.find(db, {'title': u'Hello'}) .. note:: The arguments are those of pymongo collection's `find` method. A frequent error is to pass query key/valu...
python
def find(cls, db, *args, **kwargs): """ Returns a :class:`MongoResultSet` object. Example:: items = Item.find(db, {'title': u'Hello'}) .. note:: The arguments are those of pymongo collection's `find` method. A frequent error is to pass query key/valu...
[ "def", "find", "(", "cls", ",", "db", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cls", ".", "_ensure_indexes", "(", "db", ")", "docs", "=", "db", "[", "cls", ".", "collection", "]", ".", "find", "(", "*", "args", ",", "*", "*", "kw...
Returns a :class:`MongoResultSet` object. Example:: items = Item.find(db, {'title': u'Hello'}) .. note:: The arguments are those of pymongo collection's `find` method. A frequent error is to pass query key/value pairs as keyword arguments. This is **wrong...
[ "Returns", "a", ":", "class", ":", "MongoResultSet", "object", "." ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/mongo.py#L165-L183
train
Returns a list of items in the specified database.
neithere/monk
monk/mongo.py
MongoBoundDictMixin.get_one
def get_one(cls, db, *args, **kwargs): """ Returns an object that corresponds to given query or ``None``. Example:: item = Item.get_one(db, {'title': u'Hello'}) """ data = db[cls.collection].find_one(*args, **kwargs) if data: return cls.wrap_inc...
python
def get_one(cls, db, *args, **kwargs): """ Returns an object that corresponds to given query or ``None``. Example:: item = Item.get_one(db, {'title': u'Hello'}) """ data = db[cls.collection].find_one(*args, **kwargs) if data: return cls.wrap_inc...
[ "def", "get_one", "(", "cls", ",", "db", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "data", "=", "db", "[", "cls", ".", "collection", "]", ".", "find_one", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "data", ":", "return", ...
Returns an object that corresponds to given query or ``None``. Example:: item = Item.get_one(db, {'title': u'Hello'})
[ "Returns", "an", "object", "that", "corresponds", "to", "given", "query", "or", "None", "." ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/mongo.py#L186-L199
train
Returns an object that corresponds to given query or None.
neithere/monk
monk/mongo.py
MongoBoundDictMixin.save
def save(self, db): """ Saves the object to given database. Usage:: item = Item(title=u'Hello') item.save(db) Collection name is taken from :attr:`MongoBoundDictMixin.collection`. """ assert self.collection self._ensure_indexes(db) # XX...
python
def save(self, db): """ Saves the object to given database. Usage:: item = Item(title=u'Hello') item.save(db) Collection name is taken from :attr:`MongoBoundDictMixin.collection`. """ assert self.collection self._ensure_indexes(db) # XX...
[ "def", "save", "(", "self", ",", "db", ")", ":", "assert", "self", ".", "collection", "self", ".", "_ensure_indexes", "(", "db", ")", "# XXX self.structure belongs to StructuredDictMixin !!", "outgoing", "=", "dict", "(", "dict_to_db", "(", "self", ",", "self", ...
Saves the object to given database. Usage:: item = Item(title=u'Hello') item.save(db) Collection name is taken from :attr:`MongoBoundDictMixin.collection`.
[ "Saves", "the", "object", "to", "given", "database", ".", "Usage", "::" ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/mongo.py#L201-L224
train
Saves the object to given database.
neithere/monk
monk/mongo.py
MongoBoundDictMixin.get_id
def get_id(self): """ Returns object id or ``None``. """ import warnings warnings.warn('{0}.get_id() is deprecated, ' 'use {0}.id instead'.format(type(self).__name__), DeprecationWarning) return self.get('_id')
python
def get_id(self): """ Returns object id or ``None``. """ import warnings warnings.warn('{0}.get_id() is deprecated, ' 'use {0}.id instead'.format(type(self).__name__), DeprecationWarning) return self.get('_id')
[ "def", "get_id", "(", "self", ")", ":", "import", "warnings", "warnings", ".", "warn", "(", "'{0}.get_id() is deprecated, '", "'use {0}.id instead'", ".", "format", "(", "type", "(", "self", ")", ".", "__name__", ")", ",", "DeprecationWarning", ")", "return", ...
Returns object id or ``None``.
[ "Returns", "object", "id", "or", "None", "." ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/mongo.py#L232-L239
train
Returns object id or None.
neithere/monk
monk/mongo.py
MongoBoundDictMixin.get_ref
def get_ref(self): """ Returns a `DBRef` for this object or ``None``. """ _id = self.id if _id is None: return None else: return DBRef(self.collection, _id)
python
def get_ref(self): """ Returns a `DBRef` for this object or ``None``. """ _id = self.id if _id is None: return None else: return DBRef(self.collection, _id)
[ "def", "get_ref", "(", "self", ")", ":", "_id", "=", "self", ".", "id", "if", "_id", "is", "None", ":", "return", "None", "else", ":", "return", "DBRef", "(", "self", ".", "collection", ",", "_id", ")" ]
Returns a `DBRef` for this object or ``None``.
[ "Returns", "a", "DBRef", "for", "this", "object", "or", "None", "." ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/mongo.py#L241-L248
train
Returns a DBRef object for this object or None.
neithere/monk
monk/mongo.py
MongoBoundDictMixin.remove
def remove(self, db): """ Removes the object from given database. Usage:: item = Item.get_one(db) item.remove(db) Collection name is taken from :attr:`MongoBoundDictMixin.collection`. """ assert self.collection assert self.id db[self.col...
python
def remove(self, db): """ Removes the object from given database. Usage:: item = Item.get_one(db) item.remove(db) Collection name is taken from :attr:`MongoBoundDictMixin.collection`. """ assert self.collection assert self.id db[self.col...
[ "def", "remove", "(", "self", ",", "db", ")", ":", "assert", "self", ".", "collection", "assert", "self", ".", "id", "db", "[", "self", ".", "collection", "]", ".", "remove", "(", "self", ".", "id", ")" ]
Removes the object from given database. Usage:: item = Item.get_one(db) item.remove(db) Collection name is taken from :attr:`MongoBoundDictMixin.collection`.
[ "Removes", "the", "object", "from", "given", "database", ".", "Usage", "::" ]
4b2ee5152b081ac288ce8568422a027b5e7d2b1c
https://github.com/neithere/monk/blob/4b2ee5152b081ac288ce8568422a027b5e7d2b1c/monk/mongo.py#L250-L262
train
Removes the object from given database.
quikmile/trellio
trellio/utils/log.py
logx
def logx(supress_args=[], supress_all_args=False, supress_result=False, logger=logging.getLogger(), debug_level=logging.DEBUG): """ logs parameters and result takes arguments supress_args - list of parameter names to supress supress_all_args - boolean to supress all arguments ...
python
def logx(supress_args=[], supress_all_args=False, supress_result=False, logger=logging.getLogger(), debug_level=logging.DEBUG): """ logs parameters and result takes arguments supress_args - list of parameter names to supress supress_all_args - boolean to supress all arguments ...
[ "def", "logx", "(", "supress_args", "=", "[", "]", ",", "supress_all_args", "=", "False", ",", "supress_result", "=", "False", ",", "logger", "=", "logging", ".", "getLogger", "(", ")", ",", "debug_level", "=", "logging", ".", "DEBUG", ")", ":", "def", ...
logs parameters and result takes arguments supress_args - list of parameter names to supress supress_all_args - boolean to supress all arguments supress_result - boolean to supress result receiver - custom logging function which takes a string as input; defaults to logging on stdout
[ "logs", "parameters", "and", "result", "takes", "arguments", "supress_args", "-", "list", "of", "parameter", "names", "to", "supress", "supress_all_args", "-", "boolean", "to", "supress", "all", "arguments", "supress_result", "-", "boolean", "to", "supress", "resu...
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/utils/log.py#L180-L220
train
A function decorator that logs parameters and result of a function
quikmile/trellio
trellio/utils/log.py
CustomTimeLoggingFormatter.formatTime
def formatTime(self, record, datefmt=None): # noqa """ Overrides formatTime method to use datetime module instead of time module to display time in microseconds. Time module by default does not resolve time to microseconds. """ if datefmt: s = datetime.dateti...
python
def formatTime(self, record, datefmt=None): # noqa """ Overrides formatTime method to use datetime module instead of time module to display time in microseconds. Time module by default does not resolve time to microseconds. """ if datefmt: s = datetime.dateti...
[ "def", "formatTime", "(", "self", ",", "record", ",", "datefmt", "=", "None", ")", ":", "# noqa", "if", "datefmt", ":", "s", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "datefmt", ")", "else", ":", "t", "=", "datet...
Overrides formatTime method to use datetime module instead of time module to display time in microseconds. Time module by default does not resolve time to microseconds.
[ "Overrides", "formatTime", "method", "to", "use", "datetime", "module", "instead", "of", "time", "module", "to", "display", "time", "in", "microseconds", ".", "Time", "module", "by", "default", "does", "not", "resolve", "time", "to", "microseconds", "." ]
e8b050077562acf32805fcbb9c0c162248a23c62
https://github.com/quikmile/trellio/blob/e8b050077562acf32805fcbb9c0c162248a23c62/trellio/utils/log.py#L21-L32
train
Formats the time of the record in the specified datefmt.
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogQuerySet.related_to
def related_to(self, instance): """Filter for all log objects of the same connected model as the given instance.""" return self.filter(table_name=instance.table_name, record_id=instance.record_id)
python
def related_to(self, instance): """Filter for all log objects of the same connected model as the given instance.""" return self.filter(table_name=instance.table_name, record_id=instance.record_id)
[ "def", "related_to", "(", "self", ",", "instance", ")", ":", "return", "self", ".", "filter", "(", "table_name", "=", "instance", ".", "table_name", ",", "record_id", "=", "instance", ".", "record_id", ")" ]
Filter for all log objects of the same connected model as the given instance.
[ "Filter", "for", "all", "log", "objects", "of", "the", "same", "connected", "model", "as", "the", "given", "instance", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L18-L20
train
Filter for all log objects of the same connected model as the given instance.
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogAbstract.capture_insert_from_model
def capture_insert_from_model(cls, table_name, record_id, *, exclude_fields=()): """ Create a fresh insert record from the current model state in the database. For read-write connected models, this will lead to the attempted creation of a corresponding object in Salesforce. Arg...
python
def capture_insert_from_model(cls, table_name, record_id, *, exclude_fields=()): """ Create a fresh insert record from the current model state in the database. For read-write connected models, this will lead to the attempted creation of a corresponding object in Salesforce. Arg...
[ "def", "capture_insert_from_model", "(", "cls", ",", "table_name", ",", "record_id", ",", "*", ",", "exclude_fields", "=", "(", ")", ")", ":", "exclude_cols", "=", "(", ")", "if", "exclude_fields", ":", "model_cls", "=", "get_connected_model_for_table_name", "("...
Create a fresh insert record from the current model state in the database. For read-write connected models, this will lead to the attempted creation of a corresponding object in Salesforce. Args: table_name (str): The name of the table backing the connected model (without schema) ...
[ "Create", "a", "fresh", "insert", "record", "from", "the", "current", "model", "state", "in", "the", "database", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L130-L170
train
Create a fresh insert record from the current model state in the database.
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogAbstract.capture_update_from_model
def capture_update_from_model(cls, table_name, record_id, *, update_fields=()): """ Create a fresh update record from the current model state in the database. For read-write connected models, this will lead to the attempted update of the values of a corresponding object in Salesforce. ...
python
def capture_update_from_model(cls, table_name, record_id, *, update_fields=()): """ Create a fresh update record from the current model state in the database. For read-write connected models, this will lead to the attempted update of the values of a corresponding object in Salesforce. ...
[ "def", "capture_update_from_model", "(", "cls", ",", "table_name", ",", "record_id", ",", "*", ",", "update_fields", "=", "(", ")", ")", ":", "include_cols", "=", "(", ")", "if", "update_fields", ":", "model_cls", "=", "get_connected_model_for_table_name", "(", ...
Create a fresh update record from the current model state in the database. For read-write connected models, this will lead to the attempted update of the values of a corresponding object in Salesforce. Args: table_name (str): The name of the table backing the connected model (witho...
[ "Create", "a", "fresh", "update", "record", "from", "the", "current", "model", "state", "in", "the", "database", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L173-L212
train
Create a fresh update record from the current model state in the database.
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogAbstract.get_model
def get_model(self): """ Fetch the instance of the connected model referenced by this log record. Returns: The connected instance, or ``None`` if it does not exists. """ model_cls = get_connected_model_for_table_name(self.table_name) return model_cls._defaul...
python
def get_model(self): """ Fetch the instance of the connected model referenced by this log record. Returns: The connected instance, or ``None`` if it does not exists. """ model_cls = get_connected_model_for_table_name(self.table_name) return model_cls._defaul...
[ "def", "get_model", "(", "self", ")", ":", "model_cls", "=", "get_connected_model_for_table_name", "(", "self", ".", "table_name", ")", "return", "model_cls", ".", "_default_manager", ".", "filter", "(", "id", "=", "self", ".", "record_id", ")", ".", "first", ...
Fetch the instance of the connected model referenced by this log record. Returns: The connected instance, or ``None`` if it does not exists.
[ "Fetch", "the", "instance", "of", "the", "connected", "model", "referenced", "by", "this", "log", "record", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L223-L232
train
Fetch the instance of the connected model referenced by this log record.
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogAbstract.related
def related(self, *, exclude_self=False): """ Get a QuerySet for all trigger log objects for the same connected model. Args: exclude_self (bool): Whether to exclude this log object from the result list """ manager = type(self)._default_manager queryset = mana...
python
def related(self, *, exclude_self=False): """ Get a QuerySet for all trigger log objects for the same connected model. Args: exclude_self (bool): Whether to exclude this log object from the result list """ manager = type(self)._default_manager queryset = mana...
[ "def", "related", "(", "self", ",", "*", ",", "exclude_self", "=", "False", ")", ":", "manager", "=", "type", "(", "self", ")", ".", "_default_manager", "queryset", "=", "manager", ".", "related_to", "(", "self", ")", "if", "exclude_self", ":", "queryset...
Get a QuerySet for all trigger log objects for the same connected model. Args: exclude_self (bool): Whether to exclude this log object from the result list
[ "Get", "a", "QuerySet", "for", "all", "trigger", "log", "objects", "for", "the", "same", "connected", "model", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L234-L245
train
Returns a QuerySet for all trigger log objects for the same connected model.
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogAbstract.capture_insert
def capture_insert(self, *, exclude_fields=()): """Apply :meth:`.TriggerLogAbstract.capture_insert_from_model` for this log.""" return self.capture_insert_from_model(self.table_name, self.record_id, exclude_fields=exclude_fields)
python
def capture_insert(self, *, exclude_fields=()): """Apply :meth:`.TriggerLogAbstract.capture_insert_from_model` for this log.""" return self.capture_insert_from_model(self.table_name, self.record_id, exclude_fields=exclude_fields)
[ "def", "capture_insert", "(", "self", ",", "*", ",", "exclude_fields", "=", "(", ")", ")", ":", "return", "self", ".", "capture_insert_from_model", "(", "self", ".", "table_name", ",", "self", ".", "record_id", ",", "exclude_fields", "=", "exclude_fields", "...
Apply :meth:`.TriggerLogAbstract.capture_insert_from_model` for this log.
[ "Apply", ":", "meth", ":", ".", "TriggerLogAbstract", ".", "capture_insert_from_model", "for", "this", "log", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L247-L250
train
Apply : meth :. TriggerLogAbstract. capture_insert_from_model for this log.
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogAbstract.capture_update
def capture_update(self, *, update_fields=()): """Apply :meth:`.TriggerLogAbstract.capture_insert_from_model` for this log.""" return self.capture_update_from_model(self.table_name, self.record_id, update_fields=update_fields)
python
def capture_update(self, *, update_fields=()): """Apply :meth:`.TriggerLogAbstract.capture_insert_from_model` for this log.""" return self.capture_update_from_model(self.table_name, self.record_id, update_fields=update_fields)
[ "def", "capture_update", "(", "self", ",", "*", ",", "update_fields", "=", "(", ")", ")", ":", "return", "self", ".", "capture_update_from_model", "(", "self", ".", "table_name", ",", "self", ".", "record_id", ",", "update_fields", "=", "update_fields", ")" ...
Apply :meth:`.TriggerLogAbstract.capture_insert_from_model` for this log.
[ "Apply", ":", "meth", ":", ".", "TriggerLogAbstract", ".", "capture_insert_from_model", "for", "this", "log", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L252-L255
train
Apply : meth :. TriggerLogAbstract. capture_update_from_model for this log.
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogAbstract._fieldnames_to_colnames
def _fieldnames_to_colnames(model_cls, fieldnames): """Get the names of columns referenced by the given model fields.""" get_field = model_cls._meta.get_field fields = map(get_field, fieldnames) return {f.column for f in fields}
python
def _fieldnames_to_colnames(model_cls, fieldnames): """Get the names of columns referenced by the given model fields.""" get_field = model_cls._meta.get_field fields = map(get_field, fieldnames) return {f.column for f in fields}
[ "def", "_fieldnames_to_colnames", "(", "model_cls", ",", "fieldnames", ")", ":", "get_field", "=", "model_cls", ".", "_meta", ".", "get_field", "fields", "=", "map", "(", "get_field", ",", "fieldnames", ")", "return", "{", "f", ".", "column", "for", "f", "...
Get the names of columns referenced by the given model fields.
[ "Get", "the", "names", "of", "columns", "referenced", "by", "the", "given", "model", "fields", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L258-L262
train
Get the names of columns referenced by the given model fields.
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogArchive.redo
def redo(self): """ Re-sync the change recorded in this trigger log. Creates a ``NEW`` live trigger log from the data in this archived trigger log and sets the state of this archived instance to ``REQUEUED``. .. seealso:: :meth:`.TriggerLog.redo` Returns: T...
python
def redo(self): """ Re-sync the change recorded in this trigger log. Creates a ``NEW`` live trigger log from the data in this archived trigger log and sets the state of this archived instance to ``REQUEUED``. .. seealso:: :meth:`.TriggerLog.redo` Returns: T...
[ "def", "redo", "(", "self", ")", ":", "trigger_log", "=", "self", ".", "_to_live_trigger_log", "(", "state", "=", "TRIGGER_LOG_STATE", "[", "'NEW'", "]", ")", "trigger_log", ".", "save", "(", "force_insert", "=", "True", ")", "# make sure we get a fresh row", ...
Re-sync the change recorded in this trigger log. Creates a ``NEW`` live trigger log from the data in this archived trigger log and sets the state of this archived instance to ``REQUEUED``. .. seealso:: :meth:`.TriggerLog.redo` Returns: The :class:`.TriggerLog` instance tha...
[ "Re", "-", "sync", "the", "change", "recorded", "in", "this", "trigger", "log", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L308-L325
train
Redo the change recorded in this archived trigger log.
Thermondo/django-heroku-connect
heroku_connect/models.py
TriggerLogArchive._to_live_trigger_log
def _to_live_trigger_log(self, **kwargs): """ Make a new, non-archived :class:`.TriggerLog` instance with duplicate data. Args: **kwargs: Set as attributes of the new instance, overriding what would otherwise be copied from ``self``. Returns: The...
python
def _to_live_trigger_log(self, **kwargs): """ Make a new, non-archived :class:`.TriggerLog` instance with duplicate data. Args: **kwargs: Set as attributes of the new instance, overriding what would otherwise be copied from ``self``. Returns: The...
[ "def", "_to_live_trigger_log", "(", "self", ",", "*", "*", "kwargs", ")", ":", "field_names", "=", "(", "field", ".", "name", "for", "field", "in", "TriggerLogAbstract", ".", "_meta", ".", "get_fields", "(", ")", ")", "attributes", "=", "{", "name", ":",...
Make a new, non-archived :class:`.TriggerLog` instance with duplicate data. Args: **kwargs: Set as attributes of the new instance, overriding what would otherwise be copied from ``self``. Returns: The new (unpersisted) :class:`TriggerLog` instance.
[ "Make", "a", "new", "non", "-", "archived", ":", "class", ":", ".", "TriggerLog", "instance", "with", "duplicate", "data", "." ]
f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5
https://github.com/Thermondo/django-heroku-connect/blob/f390e0fbf256ee79b30bb88f9a8c9576c6c8d9b5/heroku_connect/models.py#L327-L343
train
Make a new non - archived trigger log with duplicate data.
glormph/msstitch
src/app/actions/prottable/isoquant.py
add_isoquant_data
def add_isoquant_data(proteins, quantproteins, quantacc, quantfields): """Runs through a protein table and adds quant data from ANOTHER protein table that contains that data.""" for protein in base_add_isoquant_data(proteins, quantproteins, prottabledata.HEADER_PROT...
python
def add_isoquant_data(proteins, quantproteins, quantacc, quantfields): """Runs through a protein table and adds quant data from ANOTHER protein table that contains that data.""" for protein in base_add_isoquant_data(proteins, quantproteins, prottabledata.HEADER_PROT...
[ "def", "add_isoquant_data", "(", "proteins", ",", "quantproteins", ",", "quantacc", ",", "quantfields", ")", ":", "for", "protein", "in", "base_add_isoquant_data", "(", "proteins", ",", "quantproteins", ",", "prottabledata", ".", "HEADER_PROTEIN", ",", "quantacc", ...
Runs through a protein table and adds quant data from ANOTHER protein table that contains that data.
[ "Runs", "through", "a", "protein", "table", "and", "adds", "quant", "data", "from", "ANOTHER", "protein", "table", "that", "contains", "that", "data", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/isoquant.py#L15-L21
train
Runs through a protein table and adds quant data from ANOTHER protein table that contains that data.
glormph/msstitch
src/app/actions/peptable/isoquant.py
add_isoquant_data
def add_isoquant_data(peptides, quantpeptides, quantacc, quantfields): """Runs through a peptide table and adds quant data from ANOTHER peptide table that contains that data.""" for peptide in base_add_isoquant_data(peptides, quantpeptides, peptabledata.HEADER_PEP...
python
def add_isoquant_data(peptides, quantpeptides, quantacc, quantfields): """Runs through a peptide table and adds quant data from ANOTHER peptide table that contains that data.""" for peptide in base_add_isoquant_data(peptides, quantpeptides, peptabledata.HEADER_PEP...
[ "def", "add_isoquant_data", "(", "peptides", ",", "quantpeptides", ",", "quantacc", ",", "quantfields", ")", ":", "for", "peptide", "in", "base_add_isoquant_data", "(", "peptides", ",", "quantpeptides", ",", "peptabledata", ".", "HEADER_PEPTIDE", ",", "quantacc", ...
Runs through a peptide table and adds quant data from ANOTHER peptide table that contains that data.
[ "Runs", "through", "a", "peptide", "table", "and", "adds", "quant", "data", "from", "ANOTHER", "peptide", "table", "that", "contains", "that", "data", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/peptable/isoquant.py#L5-L11
train
Runs through a peptide table and adds quant data from ANOTHER peptide table that contains that data.
chriso/gauged
gauged/results/time_series.py
TimeSeries.map
def map(self, fn): """Run a map function across all y points in the series""" return TimeSeries([(x, fn(y)) for x, y in self.points])
python
def map(self, fn): """Run a map function across all y points in the series""" return TimeSeries([(x, fn(y)) for x, y in self.points])
[ "def", "map", "(", "self", ",", "fn", ")", ":", "return", "TimeSeries", "(", "[", "(", "x", ",", "fn", "(", "y", ")", ")", "for", "x", ",", "y", "in", "self", ".", "points", "]", ")" ]
Run a map function across all y points in the series
[ "Run", "a", "map", "function", "across", "all", "y", "points", "in", "the", "series" ]
cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976
https://github.com/chriso/gauged/blob/cda3bba2f3e92ce2fb4aa92132dcc0e689bf7976/gauged/results/time_series.py#L43-L45
train
Run a map function across all y points in the series
glormph/msstitch
src/app/actions/prottable/merge.py
build_proteintable
def build_proteintable(pqdb, headerfields, mergecutoff, isobaric=False, precursor=False, probability=False, fdr=False, pep=False, genecentric=False): """Fetches proteins and quants from joined lookup table, loops through them and when all of a protein's quants have ...
python
def build_proteintable(pqdb, headerfields, mergecutoff, isobaric=False, precursor=False, probability=False, fdr=False, pep=False, genecentric=False): """Fetches proteins and quants from joined lookup table, loops through them and when all of a protein's quants have ...
[ "def", "build_proteintable", "(", "pqdb", ",", "headerfields", ",", "mergecutoff", ",", "isobaric", "=", "False", ",", "precursor", "=", "False", ",", "probability", "=", "False", ",", "fdr", "=", "False", ",", "pep", "=", "False", ",", "genecentric", "=",...
Fetches proteins and quants from joined lookup table, loops through them and when all of a protein's quants have been collected, yields the protein quant information.
[ "Fetches", "proteins", "and", "quants", "from", "joined", "lookup", "table", "loops", "through", "them", "and", "when", "all", "of", "a", "protein", "s", "quants", "have", "been", "collected", "yields", "the", "protein", "quant", "information", "." ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/prottable/merge.py#L9-L60
train
Builds a protein table from a joined lookup table.
glormph/msstitch
src/app/drivers/prottable/merge.py
BuildProteinTableDriver.set_feature_generator
def set_feature_generator(self): """Generates proteins with quant from the lookup table""" self.features = preparation.build_proteintable(self.lookup, self.headerfields, self.mergecutoff, ...
python
def set_feature_generator(self): """Generates proteins with quant from the lookup table""" self.features = preparation.build_proteintable(self.lookup, self.headerfields, self.mergecutoff, ...
[ "def", "set_feature_generator", "(", "self", ")", ":", "self", ".", "features", "=", "preparation", ".", "build_proteintable", "(", "self", ".", "lookup", ",", "self", ".", "headerfields", ",", "self", ".", "mergecutoff", ",", "self", ".", "isobaric", ",", ...
Generates proteins with quant from the lookup table
[ "Generates", "proteins", "with", "quant", "from", "the", "lookup", "table" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/prottable/merge.py#L35-L44
train
Generates proteins with quant from the lookup table
glormph/msstitch
src/app/actions/mzidtsv/proteingrouping.py
count_protein_group_hits
def count_protein_group_hits(lineproteins, groups): """Takes a list of protein accessions and a list of protein groups content from DB. Counts for each group in list how many proteins are found in lineproteins. Returns list of str amounts. """ hits = [] for group in groups: hits.append(0...
python
def count_protein_group_hits(lineproteins, groups): """Takes a list of protein accessions and a list of protein groups content from DB. Counts for each group in list how many proteins are found in lineproteins. Returns list of str amounts. """ hits = [] for group in groups: hits.append(0...
[ "def", "count_protein_group_hits", "(", "lineproteins", ",", "groups", ")", ":", "hits", "=", "[", "]", "for", "group", "in", "groups", ":", "hits", ".", "append", "(", "0", ")", "for", "protein", "in", "lineproteins", ":", "if", "protein", "in", "group"...
Takes a list of protein accessions and a list of protein groups content from DB. Counts for each group in list how many proteins are found in lineproteins. Returns list of str amounts.
[ "Takes", "a", "list", "of", "protein", "accessions", "and", "a", "list", "of", "protein", "groups", "content", "from", "DB", ".", "Counts", "for", "each", "group", "in", "list", "how", "many", "proteins", "are", "found", "in", "lineproteins", ".", "Returns...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/actions/mzidtsv/proteingrouping.py#L57-L68
train
Takes a list of protein accessions and a list of protein groups content from DB. Returns a list of str amounts.
glormph/msstitch
src/app/lookups/sqlite/prottable.py
GeneTableAssocIDsDB.get_proteins_psms_for_map
def get_proteins_psms_for_map(self): """Gets gene-PSM combinations from DB and filters out uniques on the fly. Filtering is done since PSM are stored per protein, not per gene, so there may be a lot of *plicates""" fields = ['p.assoc_id', 'sets.set_name', 'pep.sequence'...
python
def get_proteins_psms_for_map(self): """Gets gene-PSM combinations from DB and filters out uniques on the fly. Filtering is done since PSM are stored per protein, not per gene, so there may be a lot of *plicates""" fields = ['p.assoc_id', 'sets.set_name', 'pep.sequence'...
[ "def", "get_proteins_psms_for_map", "(", "self", ")", ":", "fields", "=", "[", "'p.assoc_id'", ",", "'sets.set_name'", ",", "'pep.sequence'", ",", "'psm.psm_id'", "]", "firstjoin", "=", "(", "'protein_psm'", ",", "'pp'", ",", "'protein_acc'", ")", "genetable", "...
Gets gene-PSM combinations from DB and filters out uniques on the fly. Filtering is done since PSM are stored per protein, not per gene, so there may be a lot of *plicates
[ "Gets", "gene", "-", "PSM", "combinations", "from", "DB", "and", "filters", "out", "uniques", "on", "the", "fly", ".", "Filtering", "is", "done", "since", "PSM", "are", "stored", "per", "protein", "not", "per", "gene", "so", "there", "may", "be", "a", ...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/lookups/sqlite/prottable.py#L125-L133
train
Gets the gene - PSM combinations from the DB and filters out any PSM combinations that are not unique for the given protein.
Erotemic/utool
utool/util_logging.py
get_logging_dir
def get_logging_dir(appname='default'): """ The default log dir is in the system resource directory But the utool global cache allows for the user to override where the logs for a specific app should be stored. Returns: log_dir_realpath (str): real path to logging directory """ from...
python
def get_logging_dir(appname='default'): """ The default log dir is in the system resource directory But the utool global cache allows for the user to override where the logs for a specific app should be stored. Returns: log_dir_realpath (str): real path to logging directory """ from...
[ "def", "get_logging_dir", "(", "appname", "=", "'default'", ")", ":", "from", "utool", ".", "_internal", "import", "meta_util_cache", "from", "utool", ".", "_internal", "import", "meta_util_cplat", "from", "utool", "import", "util_cache", "if", "appname", "is", ...
The default log dir is in the system resource directory But the utool global cache allows for the user to override where the logs for a specific app should be stored. Returns: log_dir_realpath (str): real path to logging directory
[ "The", "default", "log", "dir", "is", "in", "the", "system", "resource", "directory", "But", "the", "utool", "global", "cache", "allows", "for", "the", "user", "to", "override", "where", "the", "logs", "for", "a", "specific", "app", "should", "be", "stored...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_logging.py#L186-L208
train
Get the logging directory for a specific app
Erotemic/utool
utool/util_logging.py
get_log_fpath
def get_log_fpath(num='next', appname=None, log_dir=None): """ Returns: log_fpath (str): path to log file """ if log_dir is None: log_dir = get_logging_dir(appname=appname) if not exists(log_dir): os.makedirs(log_dir) if appname is not None: log_fname = appname + ...
python
def get_log_fpath(num='next', appname=None, log_dir=None): """ Returns: log_fpath (str): path to log file """ if log_dir is None: log_dir = get_logging_dir(appname=appname) if not exists(log_dir): os.makedirs(log_dir) if appname is not None: log_fname = appname + ...
[ "def", "get_log_fpath", "(", "num", "=", "'next'", ",", "appname", "=", "None", ",", "log_dir", "=", "None", ")", ":", "if", "log_dir", "is", "None", ":", "log_dir", "=", "get_logging_dir", "(", "appname", "=", "appname", ")", "if", "not", "exists", "(...
Returns: log_fpath (str): path to log file
[ "Returns", ":", "log_fpath", "(", "str", ")", ":", "path", "to", "log", "file" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_logging.py#L251-L273
train
Returns the path to the log file for the current page.
Erotemic/utool
utool/util_logging.py
add_logging_handler
def add_logging_handler(handler, format_='file'): """ mostly for util_logging internals """ global __UTOOL_ROOT_LOGGER__ if __UTOOL_ROOT_LOGGER__ is None: builtins.print('[WARNING] logger not started, cannot add handler') return # create formatter and add it to the handlers #...
python
def add_logging_handler(handler, format_='file'): """ mostly for util_logging internals """ global __UTOOL_ROOT_LOGGER__ if __UTOOL_ROOT_LOGGER__ is None: builtins.print('[WARNING] logger not started, cannot add handler') return # create formatter and add it to the handlers #...
[ "def", "add_logging_handler", "(", "handler", ",", "format_", "=", "'file'", ")", ":", "global", "__UTOOL_ROOT_LOGGER__", "if", "__UTOOL_ROOT_LOGGER__", "is", "None", ":", "builtins", ".", "print", "(", "'[WARNING] logger not started, cannot add handler'", ")", "return"...
mostly for util_logging internals
[ "mostly", "for", "util_logging", "internals" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_logging.py#L280-L302
train
Add a logging handler to the internal log list.
Erotemic/utool
utool/util_logging.py
start_logging
def start_logging(log_fpath=None, mode='a', appname='default', log_dir=None): r""" Overwrites utool print functions to use a logger CommandLine: python -m utool.util_logging --test-start_logging:0 python -m utool.util_logging --test-start_logging:1 Example0: >>> # DISABLE_DOCTE...
python
def start_logging(log_fpath=None, mode='a', appname='default', log_dir=None): r""" Overwrites utool print functions to use a logger CommandLine: python -m utool.util_logging --test-start_logging:0 python -m utool.util_logging --test-start_logging:1 Example0: >>> # DISABLE_DOCTE...
[ "def", "start_logging", "(", "log_fpath", "=", "None", ",", "mode", "=", "'a'", ",", "appname", "=", "'default'", ",", "log_dir", "=", "None", ")", ":", "global", "__UTOOL_ROOT_LOGGER__", "global", "__UTOOL_PRINT__", "global", "__UTOOL_WRITE__", "global", "__UTO...
r""" Overwrites utool print functions to use a logger CommandLine: python -m utool.util_logging --test-start_logging:0 python -m utool.util_logging --test-start_logging:1 Example0: >>> # DISABLE_DOCTEST >>> import sys >>> sys.argv.append('--verb-logging') >>...
[ "r", "Overwrites", "utool", "print", "functions", "to", "use", "a", "logger" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_logging.py#L375-L520
train
r Starts logging on the given log file.
Erotemic/utool
utool/util_logging.py
stop_logging
def stop_logging(): """ Restores utool print functions to python defaults """ global __UTOOL_ROOT_LOGGER__ global __UTOOL_PRINT__ global __UTOOL_WRITE__ global __UTOOL_FLUSH__ if __UTOOL_ROOT_LOGGER__ is not None: # Flush remaining buffer if VERBOSE or LOGGING_VERBOSE: ...
python
def stop_logging(): """ Restores utool print functions to python defaults """ global __UTOOL_ROOT_LOGGER__ global __UTOOL_PRINT__ global __UTOOL_WRITE__ global __UTOOL_FLUSH__ if __UTOOL_ROOT_LOGGER__ is not None: # Flush remaining buffer if VERBOSE or LOGGING_VERBOSE: ...
[ "def", "stop_logging", "(", ")", ":", "global", "__UTOOL_ROOT_LOGGER__", "global", "__UTOOL_PRINT__", "global", "__UTOOL_WRITE__", "global", "__UTOOL_FLUSH__", "if", "__UTOOL_ROOT_LOGGER__", "is", "not", "None", ":", "# Flush remaining buffer", "if", "VERBOSE", "or", "L...
Restores utool print functions to python defaults
[ "Restores", "utool", "print", "functions", "to", "python", "defaults" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_logging.py#L523-L543
train
Restores utool print functions to python defaults
Erotemic/utool
utool/util_logging.py
CustomStreamHandler.flush
def flush(self): """ Flushes the stream. """ self.acquire() try: if self.stream and hasattr(self.stream, "flush"): self.stream.flush() finally: self.release()
python
def flush(self): """ Flushes the stream. """ self.acquire() try: if self.stream and hasattr(self.stream, "flush"): self.stream.flush() finally: self.release()
[ "def", "flush", "(", "self", ")", ":", "self", ".", "acquire", "(", ")", "try", ":", "if", "self", ".", "stream", "and", "hasattr", "(", "self", ".", "stream", ",", "\"flush\"", ")", ":", "self", ".", "stream", ".", "flush", "(", ")", "finally", ...
Flushes the stream.
[ "Flushes", "the", "stream", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_logging.py#L322-L331
train
Flushes the stream.
Erotemic/utool
utool/util_logging.py
CustomStreamHandler.emit
def emit(self, record): """ Emit a record. If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended t...
python
def emit(self, record): """ Emit a record. If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended t...
[ "def", "emit", "(", "self", ",", "record", ")", ":", "try", ":", "msg", "=", "self", ".", "format", "(", "record", ")", "stream", "=", "self", ".", "stream", "fs", "=", "\"%s%s\"", "if", "six", ".", "PY3", "or", "not", "logging", ".", "_unicode", ...
Emit a record. If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ...
[ "Emit", "a", "record", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_logging.py#L333-L372
train
Emits a record to the output stream.
Erotemic/utool
utool/util_list.py
replace_nones
def replace_nones(list_, repl=-1): r""" Recursively removes Nones in all lists and sublists and replaces them with the repl variable Args: list_ (list): repl (obj): replacement value Returns: list CommandLine: python -m utool.util_list --test-replace_nones ...
python
def replace_nones(list_, repl=-1): r""" Recursively removes Nones in all lists and sublists and replaces them with the repl variable Args: list_ (list): repl (obj): replacement value Returns: list CommandLine: python -m utool.util_list --test-replace_nones ...
[ "def", "replace_nones", "(", "list_", ",", "repl", "=", "-", "1", ")", ":", "repl_list", "=", "[", "repl", "if", "item", "is", "None", "else", "(", "replace_nones", "(", "item", ",", "repl", ")", "if", "isinstance", "(", "item", ",", "list", ")", "...
r""" Recursively removes Nones in all lists and sublists and replaces them with the repl variable Args: list_ (list): repl (obj): replacement value Returns: list CommandLine: python -m utool.util_list --test-replace_nones Example: >>> # ENABLE_DOCTEST ...
[ "r", "Recursively", "removes", "Nones", "in", "all", "lists", "and", "sublists", "and", "replaces", "them", "with", "the", "repl", "variable" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L78-L113
train
r Recursively removes Nones in all lists and sublists and replaces them with AttributeNames
Erotemic/utool
utool/util_list.py
recursive_replace
def recursive_replace(list_, target, repl=-1): r""" Recursively removes target in all lists and sublists and replaces them with the repl variable """ repl_list = [ recursive_replace(item, target, repl) if isinstance(item, (list, np.ndarray)) else (repl if item == target else item) ...
python
def recursive_replace(list_, target, repl=-1): r""" Recursively removes target in all lists and sublists and replaces them with the repl variable """ repl_list = [ recursive_replace(item, target, repl) if isinstance(item, (list, np.ndarray)) else (repl if item == target else item) ...
[ "def", "recursive_replace", "(", "list_", ",", "target", ",", "repl", "=", "-", "1", ")", ":", "repl_list", "=", "[", "recursive_replace", "(", "item", ",", "target", ",", "repl", ")", "if", "isinstance", "(", "item", ",", "(", "list", ",", "np", "."...
r""" Recursively removes target in all lists and sublists and replaces them with the repl variable
[ "r", "Recursively", "removes", "target", "in", "all", "lists", "and", "sublists", "and", "replaces", "them", "with", "the", "repl", "variable" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L116-L126
train
r Recursively removes target in all lists and sublists and replaces them with repl variable.
Erotemic/utool
utool/util_list.py
ensure_list_size
def ensure_list_size(list_, size_): """ Allocates more space if needbe. Ensures len(``list_``) == ``size_``. Args: list_ (list): ``list`` to extend size_ (int): amount to exent by """ lendiff = (size_) - len(list_) if lendiff > 0: extension = [None for _ in range(lendif...
python
def ensure_list_size(list_, size_): """ Allocates more space if needbe. Ensures len(``list_``) == ``size_``. Args: list_ (list): ``list`` to extend size_ (int): amount to exent by """ lendiff = (size_) - len(list_) if lendiff > 0: extension = [None for _ in range(lendif...
[ "def", "ensure_list_size", "(", "list_", ",", "size_", ")", ":", "lendiff", "=", "(", "size_", ")", "-", "len", "(", "list_", ")", "if", "lendiff", ">", "0", ":", "extension", "=", "[", "None", "for", "_", "in", "range", "(", "lendiff", ")", "]", ...
Allocates more space if needbe. Ensures len(``list_``) == ``size_``. Args: list_ (list): ``list`` to extend size_ (int): amount to exent by
[ "Allocates", "more", "space", "if", "needbe", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L150-L162
train
Allocates more space if needbe.
Erotemic/utool
utool/util_list.py
safe_listget
def safe_listget(list_, index, default='?'): """ depricate """ if index >= len(list_): return default ret = list_[index] if ret is None: return default return ret
python
def safe_listget(list_, index, default='?'): """ depricate """ if index >= len(list_): return default ret = list_[index] if ret is None: return default return ret
[ "def", "safe_listget", "(", "list_", ",", "index", ",", "default", "=", "'?'", ")", ":", "if", "index", ">=", "len", "(", "list_", ")", ":", "return", "default", "ret", "=", "list_", "[", "index", "]", "if", "ret", "is", "None", ":", "return", "def...
depricate
[ "depricate" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L246-L253
train
depricate listget
Erotemic/utool
utool/util_list.py
listclip
def listclip(list_, num, fromback=False): r""" DEPRICATE: use slices instead Args: list_ (list): num (int): Returns: sublist: CommandLine: python -m utool.util_list --test-listclip Example1: >>> # ENABLE_DOCTEST >>> import utool as ut >...
python
def listclip(list_, num, fromback=False): r""" DEPRICATE: use slices instead Args: list_ (list): num (int): Returns: sublist: CommandLine: python -m utool.util_list --test-listclip Example1: >>> # ENABLE_DOCTEST >>> import utool as ut >...
[ "def", "listclip", "(", "list_", ",", "num", ",", "fromback", "=", "False", ")", ":", "if", "num", "is", "None", ":", "num_", "=", "len", "(", "list_", ")", "else", ":", "num_", "=", "min", "(", "len", "(", "list_", ")", ",", "num", ")", "if", ...
r""" DEPRICATE: use slices instead Args: list_ (list): num (int): Returns: sublist: CommandLine: python -m utool.util_list --test-listclip Example1: >>> # ENABLE_DOCTEST >>> import utool as ut >>> # build test data >>> list_ = [1, 2...
[ "r", "DEPRICATE", ":", "use", "slices", "instead" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L256-L309
train
r Clip the elements of a list into a new list
Erotemic/utool
utool/util_list.py
find_list_indexes
def find_list_indexes(list_, items): """ Args: list_ (list): list of items to be searched items (list): list of items to find Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> list_ = ['a', 'b', 'c'] >>> items = ['d', 'c', 'b', 'f'] ...
python
def find_list_indexes(list_, items): """ Args: list_ (list): list of items to be searched items (list): list of items to find Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> list_ = ['a', 'b', 'c'] >>> items = ['d', 'c', 'b', 'f'] ...
[ "def", "find_list_indexes", "(", "list_", ",", "items", ")", ":", "index_lookup", "=", "make_index_lookup", "(", "list_", ")", "index_list", "=", "[", "index_lookup", ".", "get", "(", "item", ")", "for", "item", "in", "items", "]", "# index_list = [listfind(li...
Args: list_ (list): list of items to be searched items (list): list of items to find Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> list_ = ['a', 'b', 'c'] >>> items = ['d', 'c', 'b', 'f'] >>> index_list = find_list_indexes(list_,...
[ "Args", ":", "list_", "(", "list", ")", ":", "list", "of", "items", "to", "be", "searched", "items", "(", "list", ")", ":", "list", "of", "items", "to", "find" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L312-L331
train
This function will find the list of indexes in the order of the items in the list
Erotemic/utool
utool/util_list.py
search_list
def search_list(text_list, pattern, flags=0): """ CommandLine: python -m utool.util_list --test-search_list Example: >>> # ENABLE_DOCTEST >>> import utool as ut >>> text_list = ['ham', 'jam', 'eggs', 'spam'] >>> pattern = '.am' >>> flags = 0 >>> (vali...
python
def search_list(text_list, pattern, flags=0): """ CommandLine: python -m utool.util_list --test-search_list Example: >>> # ENABLE_DOCTEST >>> import utool as ut >>> text_list = ['ham', 'jam', 'eggs', 'spam'] >>> pattern = '.am' >>> flags = 0 >>> (vali...
[ "def", "search_list", "(", "text_list", ",", "pattern", ",", "flags", "=", "0", ")", ":", "import", "re", "import", "utool", "as", "ut", "match_list", "=", "[", "re", ".", "search", "(", "pattern", ",", "text", ",", "flags", "=", "flags", ")", "for",...
CommandLine: python -m utool.util_list --test-search_list Example: >>> # ENABLE_DOCTEST >>> import utool as ut >>> text_list = ['ham', 'jam', 'eggs', 'spam'] >>> pattern = '.am' >>> flags = 0 >>> (valid_index_list, valid_match_list) = ut.search_list(text_list...
[ "CommandLine", ":", "python", "-", "m", "utool", ".", "util_list", "--", "test", "-", "search_list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L361-L382
train
A simple wrapper for search_list that returns a list of valid index and match lists
Erotemic/utool
utool/util_list.py
multi_replace
def multi_replace(instr, search_list=[], repl_list=None): """ Does a string replace with a list of search and replacements TODO: rename """ repl_list = [''] * len(search_list) if repl_list is None else repl_list for ser, repl in zip(search_list, repl_list): instr = instr.replace(ser, re...
python
def multi_replace(instr, search_list=[], repl_list=None): """ Does a string replace with a list of search and replacements TODO: rename """ repl_list = [''] * len(search_list) if repl_list is None else repl_list for ser, repl in zip(search_list, repl_list): instr = instr.replace(ser, re...
[ "def", "multi_replace", "(", "instr", ",", "search_list", "=", "[", "]", ",", "repl_list", "=", "None", ")", ":", "repl_list", "=", "[", "''", "]", "*", "len", "(", "search_list", ")", "if", "repl_list", "is", "None", "else", "repl_list", "for", "ser",...
Does a string replace with a list of search and replacements TODO: rename
[ "Does", "a", "string", "replace", "with", "a", "list", "of", "search", "and", "replacements" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L387-L396
train
Does a string replace with a list of search and replacements
Erotemic/utool
utool/util_list.py
invertible_flatten1
def invertible_flatten1(unflat_list): r""" Flattens `unflat_list` but remember how to reconstruct the `unflat_list` Returns `flat_list` and the `reverse_list` with indexes into the `flat_list` Args: unflat_list (list): list of nested lists that we will flatten. Returns: tuple :...
python
def invertible_flatten1(unflat_list): r""" Flattens `unflat_list` but remember how to reconstruct the `unflat_list` Returns `flat_list` and the `reverse_list` with indexes into the `flat_list` Args: unflat_list (list): list of nested lists that we will flatten. Returns: tuple :...
[ "def", "invertible_flatten1", "(", "unflat_list", ")", ":", "nextnum", "=", "functools", ".", "partial", "(", "six", ".", "next", ",", "itertools", ".", "count", "(", "0", ")", ")", "# Build an unflat list of flat indexes", "reverse_list", "=", "[", "[", "next...
r""" Flattens `unflat_list` but remember how to reconstruct the `unflat_list` Returns `flat_list` and the `reverse_list` with indexes into the `flat_list` Args: unflat_list (list): list of nested lists that we will flatten. Returns: tuple : (flat_list, reverse_list) CommandLin...
[ "r", "Flattens", "unflat_list", "but", "remember", "how", "to", "reconstruct", "the", "unflat_list", "Returns", "flat_list", "and", "the", "reverse_list", "with", "indexes", "into", "the", "flat_list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L423-L454
train
r Flattens unflat_list but remember how to reconstruct the unflat_list
Erotemic/utool
utool/util_list.py
unflatten1
def unflatten1(flat_list, reverse_list): """ Rebuilds unflat list from invertible_flatten1 Args: flat_list (list): the flattened list reverse_list (list): the list which undoes flattenting Returns: unflat_list2: original nested list SeeAlso: invertible_flatten1 ...
python
def unflatten1(flat_list, reverse_list): """ Rebuilds unflat list from invertible_flatten1 Args: flat_list (list): the flattened list reverse_list (list): the list which undoes flattenting Returns: unflat_list2: original nested list SeeAlso: invertible_flatten1 ...
[ "def", "unflatten1", "(", "flat_list", ",", "reverse_list", ")", ":", "unflat_list2", "=", "[", "[", "flat_list", "[", "index", "]", "for", "index", "in", "tup", "]", "for", "tup", "in", "reverse_list", "]", "return", "unflat_list2" ]
Rebuilds unflat list from invertible_flatten1 Args: flat_list (list): the flattened list reverse_list (list): the list which undoes flattenting Returns: unflat_list2: original nested list SeeAlso: invertible_flatten1 invertible_flatten2 unflatten2
[ "Rebuilds", "unflat", "list", "from", "invertible_flatten1" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L457-L476
train
Rebuilds unflat list from invertible_flatten1 COOKIEList
Erotemic/utool
utool/util_list.py
total_flatten
def total_flatten(unflat_list): """ unflat_list = [1, 2, [3, 4], [5, [9]]] Args: unflat_list (list): Returns: list: flat_list CommandLine: python -m utool.util_list --exec-total_flatten --show Example: >>> # DISABLE_DOCTEST >>> from utool.util_list impo...
python
def total_flatten(unflat_list): """ unflat_list = [1, 2, [3, 4], [5, [9]]] Args: unflat_list (list): Returns: list: flat_list CommandLine: python -m utool.util_list --exec-total_flatten --show Example: >>> # DISABLE_DOCTEST >>> from utool.util_list impo...
[ "def", "total_flatten", "(", "unflat_list", ")", ":", "import", "utool", "as", "ut", "next_list", "=", "unflat_list", "scalar_flags", "=", "[", "not", "ut", ".", "isiterable", "(", "item", ")", "for", "item", "in", "next_list", "]", "while", "not", "all", ...
unflat_list = [1, 2, [3, 4], [5, [9]]] Args: unflat_list (list): Returns: list: flat_list CommandLine: python -m utool.util_list --exec-total_flatten --show Example: >>> # DISABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> import utool as ut ...
[ "unflat_list", "=", "[", "1", "2", "[", "3", "4", "]", "[", "5", "[", "9", "]]]", "Args", ":", "unflat_list", "(", "list", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L490-L520
train
This function will flatten a list of unflatenized items into a single item
Erotemic/utool
utool/util_list.py
invertible_total_flatten
def invertible_total_flatten(unflat_list): r""" Args: unflat_list (list): Returns: tuple: (flat_list, invert_levels) CommandLine: python -m utool.util_list --exec-invertible_total_flatten --show Example: >>> # DISABLE_DOCTEST >>> from utool.util_list import...
python
def invertible_total_flatten(unflat_list): r""" Args: unflat_list (list): Returns: tuple: (flat_list, invert_levels) CommandLine: python -m utool.util_list --exec-invertible_total_flatten --show Example: >>> # DISABLE_DOCTEST >>> from utool.util_list import...
[ "def", "invertible_total_flatten", "(", "unflat_list", ")", ":", "import", "utool", "as", "ut", "next_list", "=", "unflat_list", "scalar_flags", "=", "[", "not", "ut", ".", "isiterable", "(", "item", ")", "for", "item", "in", "next_list", "]", "invert_stack", ...
r""" Args: unflat_list (list): Returns: tuple: (flat_list, invert_levels) CommandLine: python -m utool.util_list --exec-invertible_total_flatten --show Example: >>> # DISABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> import utool as ut ...
[ "r", "Args", ":", "unflat_list", "(", "list", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L523-L567
train
r Inverts a list of unflatized items into a single item and returns a tuple of the unflattened items and the order of the elements in the list.
Erotemic/utool
utool/util_list.py
invertible_flatten2
def invertible_flatten2(unflat_list): """ An alternative to invertible_flatten1 which uses cumsum Flattens ``list`` but remember how to reconstruct the unflat ``list`` Returns flat ``list`` and the unflat ``list`` with indexes into the flat ``list`` Args: unflat_list (list): Retur...
python
def invertible_flatten2(unflat_list): """ An alternative to invertible_flatten1 which uses cumsum Flattens ``list`` but remember how to reconstruct the unflat ``list`` Returns flat ``list`` and the unflat ``list`` with indexes into the flat ``list`` Args: unflat_list (list): Retur...
[ "def", "invertible_flatten2", "(", "unflat_list", ")", ":", "sublen_list", "=", "list", "(", "map", "(", "len", ",", "unflat_list", ")", ")", "if", "not", "util_type", ".", "HAVE_NUMPY", ":", "cumlen_list", "=", "np", ".", "cumsum", "(", "sublen_list", ")"...
An alternative to invertible_flatten1 which uses cumsum Flattens ``list`` but remember how to reconstruct the unflat ``list`` Returns flat ``list`` and the unflat ``list`` with indexes into the flat ``list`` Args: unflat_list (list): Returns: tuple: flat_list, cumlen_list See...
[ "An", "alternative", "to", "invertible_flatten1", "which", "uses", "cumsum" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L594-L665
train
Invertible flatten a list of unflat lists and return a flat list of unflat lists
Erotemic/utool
utool/util_list.py
invertible_flatten2_numpy
def invertible_flatten2_numpy(unflat_arrs, axis=0): """ more numpy version TODO: move to vtool Args: unflat_arrs (list): list of ndarrays Returns: tuple: (flat_list, cumlen_list) CommandLine: python -m utool.util_list --test-invertible_flatten2_numpy Example: ...
python
def invertible_flatten2_numpy(unflat_arrs, axis=0): """ more numpy version TODO: move to vtool Args: unflat_arrs (list): list of ndarrays Returns: tuple: (flat_list, cumlen_list) CommandLine: python -m utool.util_list --test-invertible_flatten2_numpy Example: ...
[ "def", "invertible_flatten2_numpy", "(", "unflat_arrs", ",", "axis", "=", "0", ")", ":", "cumlen_list", "=", "np", ".", "cumsum", "(", "[", "arr", ".", "shape", "[", "axis", "]", "for", "arr", "in", "unflat_arrs", "]", ")", "flat_list", "=", "np", ".",...
more numpy version TODO: move to vtool Args: unflat_arrs (list): list of ndarrays Returns: tuple: (flat_list, cumlen_list) CommandLine: python -m utool.util_list --test-invertible_flatten2_numpy Example: >>> # ENABLE_DOCTET >>> from utool.util_list impor...
[ "more", "numpy", "version" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L668-L693
train
invertible_flatten2_numpy - flatten a list of ndarrays
Erotemic/utool
utool/util_list.py
unflatten2
def unflatten2(flat_list, cumlen_list): """ Rebuilds unflat list from invertible_flatten1 Args: flat_list (list): the flattened list cumlen_list (list): the list which undoes flattenting Returns: unflat_list2: original nested list SeeAlso: invertible_flatten1 i...
python
def unflatten2(flat_list, cumlen_list): """ Rebuilds unflat list from invertible_flatten1 Args: flat_list (list): the flattened list cumlen_list (list): the list which undoes flattenting Returns: unflat_list2: original nested list SeeAlso: invertible_flatten1 i...
[ "def", "unflatten2", "(", "flat_list", ",", "cumlen_list", ")", ":", "unflat_list2", "=", "[", "flat_list", "[", "low", ":", "high", "]", "for", "low", ",", "high", "in", "zip", "(", "itertools", ".", "chain", "(", "[", "0", "]", ",", "cumlen_list", ...
Rebuilds unflat list from invertible_flatten1 Args: flat_list (list): the flattened list cumlen_list (list): the list which undoes flattenting Returns: unflat_list2: original nested list SeeAlso: invertible_flatten1 invertible_flatten2 unflatten2 Examp...
[ "Rebuilds", "unflat", "list", "from", "invertible_flatten1" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L696-L725
train
Rebuilds unflat list from invertible_flatten1
Erotemic/utool
utool/util_list.py
unflat_unique_rowid_map
def unflat_unique_rowid_map(func, unflat_rowids, **kwargs): """ performs only one call to the underlying func with unique rowids the func must be some lookup function TODO: move this to a better place. CommandLine: python -m utool.util_list --test-unflat_unique_rowid_map:0 python -...
python
def unflat_unique_rowid_map(func, unflat_rowids, **kwargs): """ performs only one call to the underlying func with unique rowids the func must be some lookup function TODO: move this to a better place. CommandLine: python -m utool.util_list --test-unflat_unique_rowid_map:0 python -...
[ "def", "unflat_unique_rowid_map", "(", "func", ",", "unflat_rowids", ",", "*", "*", "kwargs", ")", ":", "import", "utool", "as", "ut", "# First flatten the list, and remember the original dimensions", "flat_rowids", ",", "reverse_list", "=", "ut", ".", "invertible_flatt...
performs only one call to the underlying func with unique rowids the func must be some lookup function TODO: move this to a better place. CommandLine: python -m utool.util_list --test-unflat_unique_rowid_map:0 python -m utool.util_list --test-unflat_unique_rowid_map:1 Example0: ...
[ "performs", "only", "one", "call", "to", "the", "underlying", "func", "with", "unique", "rowids", "the", "func", "must", "be", "some", "lookup", "function" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L728-L796
train
This function is used to unflat the unique rowids of a tree structure.
Erotemic/utool
utool/util_list.py
safe_slice
def safe_slice(list_, *args): """ safe_slice(list_, [start], stop, [end], [step]) Slices list and truncates if out of bounds """ if len(args) == 3: start = args[0] stop = args[1] step = args[2] else: step = 1 if len(args) == 2: start = args[0...
python
def safe_slice(list_, *args): """ safe_slice(list_, [start], stop, [end], [step]) Slices list and truncates if out of bounds """ if len(args) == 3: start = args[0] stop = args[1] step = args[2] else: step = 1 if len(args) == 2: start = args[0...
[ "def", "safe_slice", "(", "list_", ",", "*", "args", ")", ":", "if", "len", "(", "args", ")", "==", "3", ":", "start", "=", "args", "[", "0", "]", "stop", "=", "args", "[", "1", "]", "step", "=", "args", "[", "2", "]", "else", ":", "step", ...
safe_slice(list_, [start], stop, [end], [step]) Slices list and truncates if out of bounds
[ "safe_slice", "(", "list_", "[", "start", "]", "stop", "[", "end", "]", "[", "step", "]", ")", "Slices", "list", "and", "truncates", "if", "out", "of", "bounds" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L807-L826
train
Slice list and truncates if out of bounds
Erotemic/utool
utool/util_list.py
allsame
def allsame(list_, strict=True): """ checks to see if list is equal everywhere Args: list_ (list): Returns: True if all items in the list are equal """ if len(list_) == 0: return True first_item = list_[0] return list_all_eq_to(list_, first_item, strict)
python
def allsame(list_, strict=True): """ checks to see if list is equal everywhere Args: list_ (list): Returns: True if all items in the list are equal """ if len(list_) == 0: return True first_item = list_[0] return list_all_eq_to(list_, first_item, strict)
[ "def", "allsame", "(", "list_", ",", "strict", "=", "True", ")", ":", "if", "len", "(", "list_", ")", "==", "0", ":", "return", "True", "first_item", "=", "list_", "[", "0", "]", "return", "list_all_eq_to", "(", "list_", ",", "first_item", ",", "stri...
checks to see if list is equal everywhere Args: list_ (list): Returns: True if all items in the list are equal
[ "checks", "to", "see", "if", "list", "is", "equal", "everywhere" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L832-L845
train
checks to see if list is equal everywhere
Erotemic/utool
utool/util_list.py
list_all_eq_to
def list_all_eq_to(list_, val, strict=True): """ checks to see if list is equal everywhere to a value Args: list_ (list): val : value to check against Returns: True if all items in the list are equal to val """ if util_type.HAVE_NUMPY and isinstance(val, np.ndarray): ...
python
def list_all_eq_to(list_, val, strict=True): """ checks to see if list is equal everywhere to a value Args: list_ (list): val : value to check against Returns: True if all items in the list are equal to val """ if util_type.HAVE_NUMPY and isinstance(val, np.ndarray): ...
[ "def", "list_all_eq_to", "(", "list_", ",", "val", ",", "strict", "=", "True", ")", ":", "if", "util_type", ".", "HAVE_NUMPY", "and", "isinstance", "(", "val", ",", "np", ".", "ndarray", ")", ":", "return", "all", "(", "[", "np", ".", "all", "(", "...
checks to see if list is equal everywhere to a value Args: list_ (list): val : value to check against Returns: True if all items in the list are equal to val
[ "checks", "to", "see", "if", "list", "is", "equal", "everywhere", "to", "a", "value" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L848-L874
train
checks to see if all items in the list are equal to a value
Erotemic/utool
utool/util_list.py
compress
def compress(item_list, flag_list): """ like np.compress but for lists Returns items in item list where the corresponding item in flag list is True Args: item_list (list): list of items to mask flag_list (list): list of booleans used as a mask Returns: list : filtered_...
python
def compress(item_list, flag_list): """ like np.compress but for lists Returns items in item list where the corresponding item in flag list is True Args: item_list (list): list of items to mask flag_list (list): list of booleans used as a mask Returns: list : filtered_...
[ "def", "compress", "(", "item_list", ",", "flag_list", ")", ":", "assert", "len", "(", "item_list", ")", "==", "len", "(", "flag_list", ")", ",", "(", "'lists should correspond. len(item_list)=%r len(flag_list)=%r'", "%", "(", "len", "(", "item_list", ")", ",", ...
like np.compress but for lists Returns items in item list where the corresponding item in flag list is True Args: item_list (list): list of items to mask flag_list (list): list of booleans used as a mask Returns: list : filtered_items - masked items
[ "like", "np", ".", "compress", "but", "for", "lists" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L898-L916
train
Like np. compress but for lists
Erotemic/utool
utool/util_list.py
ziptake
def ziptake(items_list, indexes_list): """ SeeAlso: vt.ziptake """ return [take(list_, index_list) for list_, index_list in zip(items_list, indexes_list)]
python
def ziptake(items_list, indexes_list): """ SeeAlso: vt.ziptake """ return [take(list_, index_list) for list_, index_list in zip(items_list, indexes_list)]
[ "def", "ziptake", "(", "items_list", ",", "indexes_list", ")", ":", "return", "[", "take", "(", "list_", ",", "index_list", ")", "for", "list_", ",", "index_list", "in", "zip", "(", "items_list", ",", "indexes_list", ")", "]" ]
SeeAlso: vt.ziptake
[ "SeeAlso", ":", "vt", ".", "ziptake" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L923-L929
train
Takes a list of items and returns a list of items with the given indexes.
Erotemic/utool
utool/util_list.py
zipcompress
def zipcompress(items_list, flags_list): """ SeeAlso: vt.zipcompress """ return [compress(list_, flags) for list_, flags in zip(items_list, flags_list)]
python
def zipcompress(items_list, flags_list): """ SeeAlso: vt.zipcompress """ return [compress(list_, flags) for list_, flags in zip(items_list, flags_list)]
[ "def", "zipcompress", "(", "items_list", ",", "flags_list", ")", ":", "return", "[", "compress", "(", "list_", ",", "flags", ")", "for", "list_", ",", "flags", "in", "zip", "(", "items_list", ",", "flags_list", ")", "]" ]
SeeAlso: vt.zipcompress
[ "SeeAlso", ":", "vt", ".", "zipcompress" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L932-L938
train
zipcompress items_list and flags_list
Erotemic/utool
utool/util_list.py
filterfalse_items
def filterfalse_items(item_list, flag_list): """ Returns items in item list where the corresponding item in flag list is true Args: item_list (list): list of items flag_list (list): list of truthy values Returns: filtered_items : items where the corresponding flag was truthy ...
python
def filterfalse_items(item_list, flag_list): """ Returns items in item list where the corresponding item in flag list is true Args: item_list (list): list of items flag_list (list): list of truthy values Returns: filtered_items : items where the corresponding flag was truthy ...
[ "def", "filterfalse_items", "(", "item_list", ",", "flag_list", ")", ":", "assert", "len", "(", "item_list", ")", "==", "len", "(", "flag_list", ")", "filtered_items", "=", "list", "(", "util_iter", ".", "ifilterfalse_items", "(", "item_list", ",", "flag_list"...
Returns items in item list where the corresponding item in flag list is true Args: item_list (list): list of items flag_list (list): list of truthy values Returns: filtered_items : items where the corresponding flag was truthy SeeAlso: util_iter.ifilterfalse_items
[ "Returns", "items", "in", "item", "list", "where", "the", "corresponding", "item", "in", "flag", "list", "is", "true" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L966-L982
train
Returns items in item list where the corresponding item in flag_list is true
Erotemic/utool
utool/util_list.py
isect
def isect(list1, list2): r""" returns list1 elements that are also in list2. preserves order of list1 intersect_ordered Args: list1 (list): list2 (list): Returns: list: new_list Example: >>> # DISABLE_DOCTEST >>> from utool.util_list import * # NOQA ...
python
def isect(list1, list2): r""" returns list1 elements that are also in list2. preserves order of list1 intersect_ordered Args: list1 (list): list2 (list): Returns: list: new_list Example: >>> # DISABLE_DOCTEST >>> from utool.util_list import * # NOQA ...
[ "def", "isect", "(", "list1", ",", "list2", ")", ":", "set2", "=", "set", "(", "list2", ")", "return", "[", "item", "for", "item", "in", "list1", "if", "item", "in", "set2", "]" ]
r""" returns list1 elements that are also in list2. preserves order of list1 intersect_ordered Args: list1 (list): list2 (list): Returns: list: new_list Example: >>> # DISABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> list1 = ['featweig...
[ "r", "returns", "list1", "elements", "that", "are", "also", "in", "list2", ".", "preserves", "order", "of", "list1" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1001-L1088
train
r Returns list1 elements that are also in list2. preserves order of list1 intersect_ordered
Erotemic/utool
utool/util_list.py
union
def union(*lists, **kwargs): """ Ignore: %timeit len(reduce(set.union, map(set, x))) %timeit len(ut.union(*x)) %timeit len(ut.unique(ut.flatten(ut.lmap(np.unique, x)))) %timeit len(ut.unique(ut.flatten(x))) %timeit len(ut.union(*x)) %timeit len(ut.list_union(*x)) ...
python
def union(*lists, **kwargs): """ Ignore: %timeit len(reduce(set.union, map(set, x))) %timeit len(ut.union(*x)) %timeit len(ut.unique(ut.flatten(ut.lmap(np.unique, x)))) %timeit len(ut.unique(ut.flatten(x))) %timeit len(ut.union(*x)) %timeit len(ut.list_union(*x)) ...
[ "def", "union", "(", "*", "lists", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'ordered'", ",", "True", ")", ":", "return", "union_ordered", "(", "*", "lists", ")", "else", ":", "return", "list_union", "(", "*", "lists", ")...
Ignore: %timeit len(reduce(set.union, map(set, x))) %timeit len(ut.union(*x)) %timeit len(ut.unique(ut.flatten(ut.lmap(np.unique, x)))) %timeit len(ut.unique(ut.flatten(x))) %timeit len(ut.union(*x)) %timeit len(ut.list_union(*x)) %timeit len(set.union(*[set(list_...
[ "Ignore", ":", "%timeit", "len", "(", "reduce", "(", "set", ".", "union", "map", "(", "set", "x", ")))", "%timeit", "len", "(", "ut", ".", "union", "(", "*", "x", "))", "%timeit", "len", "(", "ut", ".", "unique", "(", "ut", ".", "flatten", "(", ...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1095-L1110
train
Return the union of lists.
Erotemic/utool
utool/util_list.py
is_subset_of_any
def is_subset_of_any(set_, other_sets): """ returns True if set_ is a subset of any set in other_sets Args: set_ (set): other_sets (list of sets): Returns: bool: flag CommandLine: python -m utool.util_list --test-is_subset_of_any Example: >>> # ENABLE_...
python
def is_subset_of_any(set_, other_sets): """ returns True if set_ is a subset of any set in other_sets Args: set_ (set): other_sets (list of sets): Returns: bool: flag CommandLine: python -m utool.util_list --test-is_subset_of_any Example: >>> # ENABLE_...
[ "def", "is_subset_of_any", "(", "set_", ",", "other_sets", ")", ":", "set_", "=", "set", "(", "set_", ")", "other_sets", "=", "map", "(", "set", ",", "other_sets", ")", "return", "any", "(", "[", "set_", ".", "issubset", "(", "other_set", ")", "for", ...
returns True if set_ is a subset of any set in other_sets Args: set_ (set): other_sets (list of sets): Returns: bool: flag CommandLine: python -m utool.util_list --test-is_subset_of_any Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * #...
[ "returns", "True", "if", "set_", "is", "a", "subset", "of", "any", "set", "in", "other_sets" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1157-L1197
train
Tests if set_ is a subset of any set in other_sets
Erotemic/utool
utool/util_list.py
priority_sort
def priority_sort(list_, priority): r""" Args: list_ (list): priority (list): desired order of items Returns: list: reordered_list CommandLine: python -m utool.util_list --test-priority_argsort Example: >>> # ENABLE_DOCTEST >>> from utool.util_list ...
python
def priority_sort(list_, priority): r""" Args: list_ (list): priority (list): desired order of items Returns: list: reordered_list CommandLine: python -m utool.util_list --test-priority_argsort Example: >>> # ENABLE_DOCTEST >>> from utool.util_list ...
[ "def", "priority_sort", "(", "list_", ",", "priority", ")", ":", "# remove requested priority items not in the list", "priority_", "=", "setintersect_ordered", "(", "priority", ",", "list_", ")", "reordered_list", "=", "unique_ordered", "(", "priority_", "+", "list_", ...
r""" Args: list_ (list): priority (list): desired order of items Returns: list: reordered_list CommandLine: python -m utool.util_list --test-priority_argsort Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> list_ = [2,...
[ "r", "Args", ":", "list_", "(", "list", ")", ":", "priority", "(", "list", ")", ":", "desired", "order", "of", "items" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1200-L1225
train
r Sorts the items in a list by a given priority list
Erotemic/utool
utool/util_list.py
priority_argsort
def priority_argsort(list_, priority): r""" Args: list_ (list): priority (list): desired order of items Returns: list: reordered_index_list Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> import utool as ut >>> list_ =...
python
def priority_argsort(list_, priority): r""" Args: list_ (list): priority (list): desired order of items Returns: list: reordered_index_list Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> import utool as ut >>> list_ =...
[ "def", "priority_argsort", "(", "list_", ",", "priority", ")", ":", "reordered_list", "=", "priority_sort", "(", "list_", ",", "priority", ")", "# FIXME: inefficient", "sortx", "=", "[", "list_", ".", "index", "(", "item", ")", "for", "item", "in", "reordere...
r""" Args: list_ (list): priority (list): desired order of items Returns: list: reordered_index_list Example: >>> # ENABLE_DOCTEST >>> from utool.util_list import * # NOQA >>> import utool as ut >>> list_ = [2, 4, 6, 8, 10] >>> priority = [8...
[ "r", "Args", ":", "list_", "(", "list", ")", ":", "priority", "(", "list", ")", ":", "desired", "order", "of", "items" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1228-L1253
train
r Sorts the items in a list by a given priority list
Erotemic/utool
utool/util_list.py
flag_unique_items
def flag_unique_items(list_): """ Returns a list of flags corresponding to the first time an item is seen Args: list_ (list): list of items Returns: flag_list Timing: import random import utool as ut def random_items(n, m): rng = random.Random(...
python
def flag_unique_items(list_): """ Returns a list of flags corresponding to the first time an item is seen Args: list_ (list): list of items Returns: flag_list Timing: import random import utool as ut def random_items(n, m): rng = random.Random(...
[ "def", "flag_unique_items", "(", "list_", ")", ":", "len_", "=", "len", "(", "list_", ")", "item_to_index", "=", "dict", "(", "zip", "(", "reversed", "(", "list_", ")", ",", "reversed", "(", "range", "(", "len_", ")", ")", ")", ")", "flag_list", "=",...
Returns a list of flags corresponding to the first time an item is seen Args: list_ (list): list of items Returns: flag_list Timing: import random import utool as ut def random_items(n, m): rng = random.Random(0) return [rng.randint(0, n) f...
[ "Returns", "a", "list", "of", "flags", "corresponding", "to", "the", "first", "time", "an", "item", "is", "seen" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L1256-L1326
train
Returns a list of flags corresponding to the first time an item is seen