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
klen/muffin-redis
muffin_redis.py
Plugin.publish
def publish(self, channel, message): """Publish message to channel. :returns: a coroutine """ if self.cfg.jsonpickle: message = jsonpickle.encode(message) return self.conn.publish(channel, message)
python
def publish(self, channel, message): """Publish message to channel. :returns: a coroutine """ if self.cfg.jsonpickle: message = jsonpickle.encode(message) return self.conn.publish(channel, message)
[ "def", "publish", "(", "self", ",", "channel", ",", "message", ")", ":", "if", "self", ".", "cfg", ".", "jsonpickle", ":", "message", "=", "jsonpickle", ".", "encode", "(", "message", ")", "return", "self", ".", "conn", ".", "publish", "(", "channel", ...
Publish message to channel. :returns: a coroutine
[ "Publish", "message", "to", "channel", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L126-L133
train
Publish a message to a channel.
klen/muffin-redis
muffin_redis.py
Plugin.start_subscribe
def start_subscribe(self): """Create a new Subscription context manager.""" if not self.conn: raise ValueError('Not connected') elif not self.pubsub_conn: raise ValueError('PubSub not enabled') # creates a new context manager return Subscription(self)
python
def start_subscribe(self): """Create a new Subscription context manager.""" if not self.conn: raise ValueError('Not connected') elif not self.pubsub_conn: raise ValueError('PubSub not enabled') # creates a new context manager return Subscription(self)
[ "def", "start_subscribe", "(", "self", ")", ":", "if", "not", "self", ".", "conn", ":", "raise", "ValueError", "(", "'Not connected'", ")", "elif", "not", "self", ".", "pubsub_conn", ":", "raise", "ValueError", "(", "'PubSub not enabled'", ")", "# creates a ne...
Create a new Subscription context manager.
[ "Create", "a", "new", "Subscription", "context", "manager", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L135-L143
train
Create a new Subscription context manager.
klen/muffin-redis
muffin_redis.py
Subscription._subscribe
async def _subscribe(self, channels, is_mask): """Subscribe to given channel.""" news = [] for channel in channels: key = channel, is_mask self._channels.append(key) if key in self._plugin._subscriptions: self._plugin._subscriptions[key].append...
python
async def _subscribe(self, channels, is_mask): """Subscribe to given channel.""" news = [] for channel in channels: key = channel, is_mask self._channels.append(key) if key in self._plugin._subscriptions: self._plugin._subscriptions[key].append...
[ "async", "def", "_subscribe", "(", "self", ",", "channels", ",", "is_mask", ")", ":", "news", "=", "[", "]", "for", "channel", "in", "channels", ":", "key", "=", "channel", ",", "is_mask", "self", ".", "_channels", ".", "append", "(", "key", ")", "if...
Subscribe to given channel.
[ "Subscribe", "to", "given", "channel", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L229-L241
train
Subscribe to given channels.
klen/muffin-redis
muffin_redis.py
Subscription._unsubscribe
async def _unsubscribe(self, channels, is_mask): """Unsubscribe from given channel.""" vanished = [] if channels: for channel in channels: key = channel, is_mask self._channels.remove(key) self._plugin._subscriptions[key].remove(self._q...
python
async def _unsubscribe(self, channels, is_mask): """Unsubscribe from given channel.""" vanished = [] if channels: for channel in channels: key = channel, is_mask self._channels.remove(key) self._plugin._subscriptions[key].remove(self._q...
[ "async", "def", "_unsubscribe", "(", "self", ",", "channels", ",", "is_mask", ")", ":", "vanished", "=", "[", "]", "if", "channels", ":", "for", "channel", "in", "channels", ":", "key", "=", "channel", ",", "is_mask", "self", ".", "_channels", ".", "re...
Unsubscribe from given channel.
[ "Unsubscribe", "from", "given", "channel", "." ]
b0cb8c1ba1511d501c2084def156710e75aaf781
https://github.com/klen/muffin-redis/blob/b0cb8c1ba1511d501c2084def156710e75aaf781/muffin_redis.py#L243-L262
train
Unsubscribe from given channel.
sfstpala/pcr
pcr/aes.py
AES.xor
def xor(a, b): """Bitwise xor on equal length bytearrays.""" return bytearray(i ^ j for i, j in zip(a, b))
python
def xor(a, b): """Bitwise xor on equal length bytearrays.""" return bytearray(i ^ j for i, j in zip(a, b))
[ "def", "xor", "(", "a", ",", "b", ")", ":", "return", "bytearray", "(", "i", "^", "j", "for", "i", ",", "j", "in", "zip", "(", "a", ",", "b", ")", ")" ]
Bitwise xor on equal length bytearrays.
[ "Bitwise", "xor", "on", "equal", "length", "bytearrays", "." ]
313ec17585565a0b9740f7b3f47d7a93bf37a7fc
https://github.com/sfstpala/pcr/blob/313ec17585565a0b9740f7b3f47d7a93bf37a7fc/pcr/aes.py#L110-L112
train
Bitwise xor on equal length bytearrays.
fkarb/xltable
xltable/expression.py
_to_addr
def _to_addr(worksheet, row, col, row_fixed=False, col_fixed=False): """converts a (0,0) based coordinate to an excel address""" addr = "" A = ord('A') col += 1 while col > 0: addr = chr(A + ((col - 1) % 26)) + addr col = (col - 1) // 26 prefix = ("'%s'!" % worksheet) if workshe...
python
def _to_addr(worksheet, row, col, row_fixed=False, col_fixed=False): """converts a (0,0) based coordinate to an excel address""" addr = "" A = ord('A') col += 1 while col > 0: addr = chr(A + ((col - 1) % 26)) + addr col = (col - 1) // 26 prefix = ("'%s'!" % worksheet) if workshe...
[ "def", "_to_addr", "(", "worksheet", ",", "row", ",", "col", ",", "row_fixed", "=", "False", ",", "col_fixed", "=", "False", ")", ":", "addr", "=", "\"\"", "A", "=", "ord", "(", "'A'", ")", "col", "+=", "1", "while", "col", ">", "0", ":", "addr",...
converts a (0,0) based coordinate to an excel address
[ "converts", "a", "(", "0", "0", ")", "based", "coordinate", "to", "an", "excel", "address" ]
7a592642d27ad5ee90d2aa8c26338abaa9d84bea
https://github.com/fkarb/xltable/blob/7a592642d27ad5ee90d2aa8c26338abaa9d84bea/xltable/expression.py#L358-L370
train
converts a 0 based coordinate to an excel address
fkarb/xltable
xltable/expression.py
Expression.value
def value(self): """Set a calculated value for this Expression. Used when writing formulas using XlsxWriter to give cells an initial value when the sheet is loaded without being calculated. """ try: if isinstance(self.__value, Expression): return self....
python
def value(self): """Set a calculated value for this Expression. Used when writing formulas using XlsxWriter to give cells an initial value when the sheet is loaded without being calculated. """ try: if isinstance(self.__value, Expression): return self....
[ "def", "value", "(", "self", ")", ":", "try", ":", "if", "isinstance", "(", "self", ".", "__value", ",", "Expression", ")", ":", "return", "self", ".", "__value", ".", "value", "return", "self", ".", "__value", "except", "AttributeError", ":", "return", ...
Set a calculated value for this Expression. Used when writing formulas using XlsxWriter to give cells an initial value when the sheet is loaded without being calculated.
[ "Set", "a", "calculated", "value", "for", "this", "Expression", ".", "Used", "when", "writing", "formulas", "using", "XlsxWriter", "to", "give", "cells", "an", "initial", "value", "when", "the", "sheet", "is", "loaded", "without", "being", "calculated", "." ]
7a592642d27ad5ee90d2aa8c26338abaa9d84bea
https://github.com/fkarb/xltable/blob/7a592642d27ad5ee90d2aa8c26338abaa9d84bea/xltable/expression.py#L59-L69
train
Set a calculated value for this Expression.
fkarb/xltable
xltable/expression.py
Expression.has_value
def has_value(self): """return True if value has been set""" try: if isinstance(self.__value, Expression): return self.__value.has_value return True except AttributeError: return False
python
def has_value(self): """return True if value has been set""" try: if isinstance(self.__value, Expression): return self.__value.has_value return True except AttributeError: return False
[ "def", "has_value", "(", "self", ")", ":", "try", ":", "if", "isinstance", "(", "self", ".", "__value", ",", "Expression", ")", ":", "return", "self", ".", "__value", ".", "has_value", "return", "True", "except", "AttributeError", ":", "return", "False" ]
return True if value has been set
[ "return", "True", "if", "value", "has", "been", "set" ]
7a592642d27ad5ee90d2aa8c26338abaa9d84bea
https://github.com/fkarb/xltable/blob/7a592642d27ad5ee90d2aa8c26338abaa9d84bea/xltable/expression.py#L72-L79
train
return True if value has been set
zsimic/runez
src/runez/file.py
copy
def copy(source, destination, ignore=None, adapter=None, fatal=True, logger=LOG.debug): """Copy source -> destination Args: source (str | None): Source file or folder destination (str | None): Destination file or folder ignore (callable | list | str | None): Names to be ignored ...
python
def copy(source, destination, ignore=None, adapter=None, fatal=True, logger=LOG.debug): """Copy source -> destination Args: source (str | None): Source file or folder destination (str | None): Destination file or folder ignore (callable | list | str | None): Names to be ignored ...
[ "def", "copy", "(", "source", ",", "destination", ",", "ignore", "=", "None", ",", "adapter", "=", "None", ",", "fatal", "=", "True", ",", "logger", "=", "LOG", ".", "debug", ")", ":", "return", "_file_op", "(", "source", ",", "destination", ",", "_c...
Copy source -> destination Args: source (str | None): Source file or folder destination (str | None): Destination file or folder ignore (callable | list | str | None): Names to be ignored adapter (callable | None): Optional function to call on 'source' before copy fatal (boo...
[ "Copy", "source", "-", ">", "destination" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L15-L29
train
Copy source file to destination file.
zsimic/runez
src/runez/file.py
delete
def delete(path, fatal=True, logger=LOG.debug): """ :param str|None path: Path to file or folder to delete :param bool|None fatal: Abort execution on failure if True :param callable|None logger: Logger to use :return int: 1 if effectively done, 0 if no-op, -1 on failure """ islink = path and...
python
def delete(path, fatal=True, logger=LOG.debug): """ :param str|None path: Path to file or folder to delete :param bool|None fatal: Abort execution on failure if True :param callable|None logger: Logger to use :return int: 1 if effectively done, 0 if no-op, -1 on failure """ islink = path and...
[ "def", "delete", "(", "path", ",", "fatal", "=", "True", ",", "logger", "=", "LOG", ".", "debug", ")", ":", "islink", "=", "path", "and", "os", ".", "path", ".", "islink", "(", "path", ")", "if", "not", "islink", "and", "(", "not", "path", "or", ...
:param str|None path: Path to file or folder to delete :param bool|None fatal: Abort execution on failure if True :param callable|None logger: Logger to use :return int: 1 if effectively done, 0 if no-op, -1 on failure
[ ":", "param", "str|None", "path", ":", "Path", "to", "file", "or", "folder", "to", "delete", ":", "param", "bool|None", "fatal", ":", "Abort", "execution", "on", "failure", "if", "True", ":", "param", "callable|None", "logger", ":", "Logger", "to", "use", ...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L32-L58
train
Delete a node from the tree.
zsimic/runez
src/runez/file.py
first_line
def first_line(path): """ :param str|None path: Path to file :return str|None: First line of file, if any """ try: with io.open(path, "rt", errors="ignore") as fh: return fh.readline().strip() except (IOError, TypeError): return None
python
def first_line(path): """ :param str|None path: Path to file :return str|None: First line of file, if any """ try: with io.open(path, "rt", errors="ignore") as fh: return fh.readline().strip() except (IOError, TypeError): return None
[ "def", "first_line", "(", "path", ")", ":", "try", ":", "with", "io", ".", "open", "(", "path", ",", "\"rt\"", ",", "errors", "=", "\"ignore\"", ")", "as", "fh", ":", "return", "fh", ".", "readline", "(", ")", ".", "strip", "(", ")", "except", "(...
:param str|None path: Path to file :return str|None: First line of file, if any
[ ":", "param", "str|None", "path", ":", "Path", "to", "file", ":", "return", "str|None", ":", "First", "line", "of", "file", "if", "any" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L61-L71
train
Returns first line of file
zsimic/runez
src/runez/file.py
get_conf
def get_conf(path, fatal=True, keep_empty=False, default=None): """ :param str|list|None path: Path to file, or lines to parse :param bool|None fatal: Abort execution on failure if True :param bool keep_empty: If True, keep definitions with empty values :param dict|list|None default: Object to retur...
python
def get_conf(path, fatal=True, keep_empty=False, default=None): """ :param str|list|None path: Path to file, or lines to parse :param bool|None fatal: Abort execution on failure if True :param bool keep_empty: If True, keep definitions with empty values :param dict|list|None default: Object to retur...
[ "def", "get_conf", "(", "path", ",", "fatal", "=", "True", ",", "keep_empty", "=", "False", ",", "default", "=", "None", ")", ":", "if", "not", "path", ":", "return", "default", "lines", "=", "path", "if", "isinstance", "(", "path", ",", "list", ")",...
:param str|list|None path: Path to file, or lines to parse :param bool|None fatal: Abort execution on failure if True :param bool keep_empty: If True, keep definitions with empty values :param dict|list|None default: Object to return if conf couldn't be read :return dict: Dict of section -> key -> value
[ ":", "param", "str|list|None", "path", ":", "Path", "to", "file", "or", "lines", "to", "parse", ":", "param", "bool|None", "fatal", ":", "Abort", "execution", "on", "failure", "if", "True", ":", "param", "bool", "keep_empty", ":", "If", "True", "keep", "...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L74-L121
train
Read the configuration file at the specified path.
zsimic/runez
src/runez/file.py
get_lines
def get_lines(path, max_size=TEXT_THRESHOLD_SIZE, fatal=True, default=None): """ :param str|None path: Path of text file to return lines from :param int|None max_size: Return contents only for files smaller than 'max_size' bytes :param bool|None fatal: Abort execution on failure if True :param list|...
python
def get_lines(path, max_size=TEXT_THRESHOLD_SIZE, fatal=True, default=None): """ :param str|None path: Path of text file to return lines from :param int|None max_size: Return contents only for files smaller than 'max_size' bytes :param bool|None fatal: Abort execution on failure if True :param list|...
[ "def", "get_lines", "(", "path", ",", "max_size", "=", "TEXT_THRESHOLD_SIZE", ",", "fatal", "=", "True", ",", "default", "=", "None", ")", ":", "if", "not", "path", "or", "not", "os", ".", "path", ".", "isfile", "(", "path", ")", "or", "(", "max_size...
:param str|None path: Path of text file to return lines from :param int|None max_size: Return contents only for files smaller than 'max_size' bytes :param bool|None fatal: Abort execution on failure if True :param list|None default: Object to return if lines couldn't be read :return list|None: Lines fro...
[ ":", "param", "str|None", "path", ":", "Path", "of", "text", "file", "to", "return", "lines", "from", ":", "param", "int|None", "max_size", ":", "Return", "contents", "only", "for", "files", "smaller", "than", "max_size", "bytes", ":", "param", "bool|None", ...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L124-L141
train
Reads lines from a file.
zsimic/runez
src/runez/file.py
move
def move(source, destination, adapter=None, fatal=True, logger=LOG.debug): """ Move source -> destination :param str|None source: Source file or folder :param str|None destination: Destination file or folder :param callable adapter: Optional function to call on 'source' before copy :param bool|...
python
def move(source, destination, adapter=None, fatal=True, logger=LOG.debug): """ Move source -> destination :param str|None source: Source file or folder :param str|None destination: Destination file or folder :param callable adapter: Optional function to call on 'source' before copy :param bool|...
[ "def", "move", "(", "source", ",", "destination", ",", "adapter", "=", "None", ",", "fatal", "=", "True", ",", "logger", "=", "LOG", ".", "debug", ")", ":", "return", "_file_op", "(", "source", ",", "destination", ",", "_move", ",", "adapter", ",", "...
Move source -> destination :param str|None source: Source file or folder :param str|None destination: Destination file or folder :param callable adapter: Optional function to call on 'source' before copy :param bool|None fatal: Abort execution on failure if True :param callable|None logger: Logger ...
[ "Move", "source", "-", ">", "destination" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L144-L155
train
Move source to destination
zsimic/runez
src/runez/file.py
symlink
def symlink(source, destination, adapter=None, must_exist=True, fatal=True, logger=LOG.debug): """ Symlink source <- destination :param str|None source: Source file or folder :param str|None destination: Destination file or folder :param callable adapter: Optional function to call on 'source' befor...
python
def symlink(source, destination, adapter=None, must_exist=True, fatal=True, logger=LOG.debug): """ Symlink source <- destination :param str|None source: Source file or folder :param str|None destination: Destination file or folder :param callable adapter: Optional function to call on 'source' befor...
[ "def", "symlink", "(", "source", ",", "destination", ",", "adapter", "=", "None", ",", "must_exist", "=", "True", ",", "fatal", "=", "True", ",", "logger", "=", "LOG", ".", "debug", ")", ":", "return", "_file_op", "(", "source", ",", "destination", ","...
Symlink source <- destination :param str|None source: Source file or folder :param str|None destination: Destination file or folder :param callable adapter: Optional function to call on 'source' before copy :param bool must_exist: If True, verify that source does indeed exist :param bool|None fatal...
[ "Symlink", "source", "<", "-", "destination" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L158-L170
train
Symlink source to destination.
zsimic/runez
src/runez/file.py
touch
def touch(path, fatal=True, logger=None): """ :param str|None path: Path to file to touch :param bool|None fatal: Abort execution on failure if True :param callable|None logger: Logger to use """ return write(path, "", fatal=fatal, logger=logger)
python
def touch(path, fatal=True, logger=None): """ :param str|None path: Path to file to touch :param bool|None fatal: Abort execution on failure if True :param callable|None logger: Logger to use """ return write(path, "", fatal=fatal, logger=logger)
[ "def", "touch", "(", "path", ",", "fatal", "=", "True", ",", "logger", "=", "None", ")", ":", "return", "write", "(", "path", ",", "\"\"", ",", "fatal", "=", "fatal", ",", "logger", "=", "logger", ")" ]
:param str|None path: Path to file to touch :param bool|None fatal: Abort execution on failure if True :param callable|None logger: Logger to use
[ ":", "param", "str|None", "path", ":", "Path", "to", "file", "to", "touch", ":", "param", "bool|None", "fatal", ":", "Abort", "execution", "on", "failure", "if", "True", ":", "param", "callable|None", "logger", ":", "Logger", "to", "use" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L173-L179
train
Create a new file in the current working directory.
zsimic/runez
src/runez/file.py
write
def write(path, contents, fatal=True, logger=None): """ :param str|None path: Path to file :param str|None contents: Contents to write :param bool|None fatal: Abort execution on failure if True :param callable|None logger: Logger to use :return int: 1 if effectively done, 0 if no-op, -1 on failu...
python
def write(path, contents, fatal=True, logger=None): """ :param str|None path: Path to file :param str|None contents: Contents to write :param bool|None fatal: Abort execution on failure if True :param callable|None logger: Logger to use :return int: 1 if effectively done, 0 if no-op, -1 on failu...
[ "def", "write", "(", "path", ",", "contents", ",", "fatal", "=", "True", ",", "logger", "=", "None", ")", ":", "if", "not", "path", ":", "return", "0", "if", "is_dryrun", "(", ")", ":", "action", "=", "\"write %s bytes to\"", "%", "len", "(", "conten...
:param str|None path: Path to file :param str|None contents: Contents to write :param bool|None fatal: Abort execution on failure if True :param callable|None logger: Logger to use :return int: 1 if effectively done, 0 if no-op, -1 on failure
[ ":", "param", "str|None", "path", ":", "Path", "to", "file", ":", "param", "str|None", "contents", ":", "Contents", "to", "write", ":", "param", "bool|None", "fatal", ":", "Abort", "execution", "on", "failure", "if", "True", ":", "param", "callable|None", ...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L182-L211
train
Writes the contents of the contents to the file at the specified path.
zsimic/runez
src/runez/file.py
_copy
def _copy(source, destination, ignore=None): """Effective copy""" if os.path.isdir(source): shutil.copytree(source, destination, symlinks=True, ignore=ignore) else: shutil.copy(source, destination) shutil.copystat(source, destination)
python
def _copy(source, destination, ignore=None): """Effective copy""" if os.path.isdir(source): shutil.copytree(source, destination, symlinks=True, ignore=ignore) else: shutil.copy(source, destination) shutil.copystat(source, destination)
[ "def", "_copy", "(", "source", ",", "destination", ",", "ignore", "=", "None", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "source", ")", ":", "shutil", ".", "copytree", "(", "source", ",", "destination", ",", "symlinks", "=", "True", ",", ...
Effective copy
[ "Effective", "copy" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L214-L221
train
Effective copy
zsimic/runez
src/runez/file.py
_file_op
def _file_op(source, destination, func, adapter, fatal, logger, must_exist=True, ignore=None): """Call func(source, destination) Args: source (str | None): Source file or folder destination (str | None): Destination file or folder func (callable): Implementation function adapter...
python
def _file_op(source, destination, func, adapter, fatal, logger, must_exist=True, ignore=None): """Call func(source, destination) Args: source (str | None): Source file or folder destination (str | None): Destination file or folder func (callable): Implementation function adapter...
[ "def", "_file_op", "(", "source", ",", "destination", ",", "func", ",", "adapter", ",", "fatal", ",", "logger", ",", "must_exist", "=", "True", ",", "ignore", "=", "None", ")", ":", "if", "not", "source", "or", "not", "destination", "or", "source", "==...
Call func(source, destination) Args: source (str | None): Source file or folder destination (str | None): Destination file or folder func (callable): Implementation function adapter (callable | None): Optional function to call on 'source' before copy fatal (bool | None): Abo...
[ "Call", "func", "(", "source", "destination", ")" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/file.py#L234-L292
train
Internal function to call a function on source and destination files.
ehansis/ozelot
examples/leonardo/leonardo/extracols/pipeline.py
LoadArtists.run
def run(self): """Load all artists into the database """ df = ArtistsInputData().load() # rename columns df.rename(columns={'artistLabel': 'name', 'year_of_birth': 'extra_1', 'genderLabel': 'extra_2'}, inpl...
python
def run(self): """Load all artists into the database """ df = ArtistsInputData().load() # rename columns df.rename(columns={'artistLabel': 'name', 'year_of_birth': 'extra_1', 'genderLabel': 'extra_2'}, inpl...
[ "def", "run", "(", "self", ")", ":", "df", "=", "ArtistsInputData", "(", ")", ".", "load", "(", ")", "# rename columns", "df", ".", "rename", "(", "columns", "=", "{", "'artistLabel'", ":", "'name'", ",", "'year_of_birth'", ":", "'extra_1'", ",", "'gende...
Load all artists into the database
[ "Load", "all", "artists", "into", "the", "database" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/examples/leonardo/leonardo/extracols/pipeline.py#L37-L71
train
Load all artists into the database and store them in the database
redhat-cip/python-dciclient
dciclient/v1/shell_commands/topic.py
list
def list(context, sort, limit, where, verbose): """list(context, sort, limit. where. verbose) List all topics. >>> dcictl topic-list :param string sort: Field to apply sort :param integer limit: Max number of rows to return :param string where: An optional filter criteria :param boolean v...
python
def list(context, sort, limit, where, verbose): """list(context, sort, limit. where. verbose) List all topics. >>> dcictl topic-list :param string sort: Field to apply sort :param integer limit: Max number of rows to return :param string where: An optional filter criteria :param boolean v...
[ "def", "list", "(", "context", ",", "sort", ",", "limit", ",", "where", ",", "verbose", ")", ":", "topics", "=", "topic", ".", "list", "(", "context", ",", "sort", "=", "sort", ",", "limit", "=", "limit", ",", "where", "=", "where", ")", "utils", ...
list(context, sort, limit. where. verbose) List all topics. >>> dcictl topic-list :param string sort: Field to apply sort :param integer limit: Max number of rows to return :param string where: An optional filter criteria :param boolean verbose: Display verbose output
[ "list", "(", "context", "sort", "limit", ".", "where", ".", "verbose", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/topic.py#L34-L47
train
List all topics in the
redhat-cip/python-dciclient
dciclient/v1/shell_commands/topic.py
create
def create(context, name, component_types, active, product_id, data): """create(context, name, component_types, active, product_id, data) Create a topic. >>> dcictl topic-create [OPTIONS] :param string name: Name of the topic [required] :param string component_types: list of component types separ...
python
def create(context, name, component_types, active, product_id, data): """create(context, name, component_types, active, product_id, data) Create a topic. >>> dcictl topic-create [OPTIONS] :param string name: Name of the topic [required] :param string component_types: list of component types separ...
[ "def", "create", "(", "context", ",", "name", ",", "component_types", ",", "active", ",", "product_id", ",", "data", ")", ":", "if", "component_types", ":", "component_types", "=", "component_types", ".", "split", "(", "','", ")", "state", "=", "utils", "....
create(context, name, component_types, active, product_id, data) Create a topic. >>> dcictl topic-create [OPTIONS] :param string name: Name of the topic [required] :param string component_types: list of component types separated by commas :param boolean active: Set the topic in the (in)active sta...
[ "create", "(", "context", "name", "component_types", "active", "product_id", "data", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/topic.py#L57-L76
train
Create a topic.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/topic.py
update
def update(context, id, etag, name, component_types, label, next_topic_id, active, product_id, data): """update(context, id, etag, name, label, next_topic_id, active, product_id, data) Update a Topic. >>> dcictl topic-update [OPTIONS] :param string id: ID of the Topic [requir...
python
def update(context, id, etag, name, component_types, label, next_topic_id, active, product_id, data): """update(context, id, etag, name, label, next_topic_id, active, product_id, data) Update a Topic. >>> dcictl topic-update [OPTIONS] :param string id: ID of the Topic [requir...
[ "def", "update", "(", "context", ",", "id", ",", "etag", ",", "name", ",", "component_types", ",", "label", ",", "next_topic_id", ",", "active", ",", "product_id", ",", "data", ")", ":", "if", "component_types", ":", "component_types", "=", "component_types"...
update(context, id, etag, name, label, next_topic_id, active, product_id, data) Update a Topic. >>> dcictl topic-update [OPTIONS] :param string id: ID of the Topic [required] :param string etag: Entity tag of the Topic resource [required] :param string name: Name of the Topic :p...
[ "update", "(", "context", "id", "etag", "name", "label", "next_topic_id", "active", "product_id", "data", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/topic.py#L90-L118
train
Update a specific topic in a specific node
redhat-cip/python-dciclient
dciclient/v1/shell_commands/topic.py
attach_team
def attach_team(context, id, team_id): """attach_team(context, id, team_id) Attach a team to a topic. >>> dcictl topic-attach-team [OPTIONS] :param string id: ID of the topic to attach to [required] :param string team_id: ID of the team to attach to this topic [required] """ team_id = tea...
python
def attach_team(context, id, team_id): """attach_team(context, id, team_id) Attach a team to a topic. >>> dcictl topic-attach-team [OPTIONS] :param string id: ID of the topic to attach to [required] :param string team_id: ID of the team to attach to this topic [required] """ team_id = tea...
[ "def", "attach_team", "(", "context", ",", "id", ",", "team_id", ")", ":", "team_id", "=", "team_id", "or", "identity", ".", "my_team_id", "(", "context", ")", "result", "=", "topic", ".", "attach_team", "(", "context", ",", "id", "=", "id", ",", "team...
attach_team(context, id, team_id) Attach a team to a topic. >>> dcictl topic-attach-team [OPTIONS] :param string id: ID of the topic to attach to [required] :param string team_id: ID of the team to attach to this topic [required]
[ "attach_team", "(", "context", "id", "team_id", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/topic.py#L160-L172
train
Attach a team to a topic
redhat-cip/python-dciclient
dciclient/v1/shell_commands/topic.py
unattach_team
def unattach_team(context, id, team_id): """unattach_team(context, id, team_id) Unattach a team from a topic. >>> dcictl topic-unattach-team [OPTIONS] :param string id: ID of the topic to unattach from [required] :param string team_id: ID of team to unattach from this topic, default is th...
python
def unattach_team(context, id, team_id): """unattach_team(context, id, team_id) Unattach a team from a topic. >>> dcictl topic-unattach-team [OPTIONS] :param string id: ID of the topic to unattach from [required] :param string team_id: ID of team to unattach from this topic, default is th...
[ "def", "unattach_team", "(", "context", ",", "id", ",", "team_id", ")", ":", "team_id", "=", "team_id", "or", "identity", ".", "my_team_id", "(", "context", ")", "result", "=", "topic", ".", "unattach_team", "(", "context", ",", "id", "=", "id", ",", "...
unattach_team(context, id, team_id) Unattach a team from a topic. >>> dcictl topic-unattach-team [OPTIONS] :param string id: ID of the topic to unattach from [required] :param string team_id: ID of team to unattach from this topic, default is the current user team [optional]
[ "unattach_team", "(", "context", "id", "team_id", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/topic.py#L179-L195
train
Unattach a team from a topic
redhat-cip/python-dciclient
dciclient/v1/shell_commands/topic.py
list_attached_team
def list_attached_team(context, id, sort, limit, where, verbose): """list_attached_team(context, id, sort, limit. where. verbose) List teams attached to a topic. >>> dcictl topic-list-team :param string id: ID of the topic to list teams for [required] :param string sort: Field to apply sort :...
python
def list_attached_team(context, id, sort, limit, where, verbose): """list_attached_team(context, id, sort, limit. where. verbose) List teams attached to a topic. >>> dcictl topic-list-team :param string id: ID of the topic to list teams for [required] :param string sort: Field to apply sort :...
[ "def", "list_attached_team", "(", "context", ",", "id", ",", "sort", ",", "limit", ",", "where", ",", "verbose", ")", ":", "result", "=", "topic", ".", "list_teams", "(", "context", ",", "id", "=", "id", ",", "sort", "=", "sort", ",", "limit", "=", ...
list_attached_team(context, id, sort, limit. where. verbose) List teams attached to a topic. >>> dcictl topic-list-team :param string id: ID of the topic to list teams for [required] :param string sort: Field to apply sort :param integer limit: Max number of rows to return :param string where...
[ "list_attached_team", "(", "context", "id", "sort", "limit", ".", "where", ".", "verbose", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/topic.py#L207-L222
train
List the teams attached to a topic.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/purge.py
purge
def purge(context, resource, force): """purge(context, resource, force) Purge soft-deleted resources. >>> dcictl purge --resource remotecis """ resources = ['components', 'topics', 'tests', 'teams', 'feeders', 'remotecis', 'jobs', 'files', 'users', 'products'] l_resources = ...
python
def purge(context, resource, force): """purge(context, resource, force) Purge soft-deleted resources. >>> dcictl purge --resource remotecis """ resources = ['components', 'topics', 'tests', 'teams', 'feeders', 'remotecis', 'jobs', 'files', 'users', 'products'] l_resources = ...
[ "def", "purge", "(", "context", ",", "resource", ",", "force", ")", ":", "resources", "=", "[", "'components'", ",", "'topics'", ",", "'tests'", ",", "'teams'", ",", "'feeders'", ",", "'remotecis'", ",", "'jobs'", ",", "'files'", ",", "'users'", ",", "'p...
purge(context, resource, force) Purge soft-deleted resources. >>> dcictl purge --resource remotecis
[ "purge", "(", "context", "resource", "force", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/purge.py#L29-L87
train
Purge soft - deleted resources.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/analytic.py
create
def create(context, job_id, name, type, url, data): """create(context, job_id, name, type, url, data) Create an analytic. >>> dcictl analytic-create [OPTIONS] :param string job-id: The job on which to attach the analytic :param string name: Name of the analytic [required] :param string type: ...
python
def create(context, job_id, name, type, url, data): """create(context, job_id, name, type, url, data) Create an analytic. >>> dcictl analytic-create [OPTIONS] :param string job-id: The job on which to attach the analytic :param string name: Name of the analytic [required] :param string type: ...
[ "def", "create", "(", "context", ",", "job_id", ",", "name", ",", "type", ",", "url", ",", "data", ")", ":", "result", "=", "analytic", ".", "create", "(", "context", ",", "job_id", "=", "job_id", ",", "name", "=", "name", ",", "type", "=", "type",...
create(context, job_id, name, type, url, data) Create an analytic. >>> dcictl analytic-create [OPTIONS] :param string job-id: The job on which to attach the analytic :param string name: Name of the analytic [required] :param string type: Type of the analytic [required] :param string url: Url ...
[ "create", "(", "context", "job_id", "name", "type", "url", "data", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/analytic.py#L32-L48
train
Create an analytic. analytic.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/analytic.py
list
def list(context, job_id): """list(context, job_id) List all analytics of a job. >>> dcictl analytic-list [OPTIONS] :param string job-id: The job on which to attach the analytic """ result = analytic.list(context, job_id=job_id) utils.format_output(result, context.format)
python
def list(context, job_id): """list(context, job_id) List all analytics of a job. >>> dcictl analytic-list [OPTIONS] :param string job-id: The job on which to attach the analytic """ result = analytic.list(context, job_id=job_id) utils.format_output(result, context.format)
[ "def", "list", "(", "context", ",", "job_id", ")", ":", "result", "=", "analytic", ".", "list", "(", "context", ",", "job_id", "=", "job_id", ")", "utils", ".", "format_output", "(", "result", ",", "context", ".", "format", ")" ]
list(context, job_id) List all analytics of a job. >>> dcictl analytic-list [OPTIONS] :param string job-id: The job on which to attach the analytic
[ "list", "(", "context", "job_id", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/analytic.py#L54-L65
train
List all analytics of a job.
redhat-cip/python-dciclient
dciclient/v1/shell_commands/analytic.py
update
def update(context, id, job_id, name, type, url, data): """update(context, id, export_control, active) Update an analytic >>> dcictl analytic-update [OPTIONS] :param string job-id: The job on which to attach the analytic :param string name: Name of the analytic [required] :param string type: ...
python
def update(context, id, job_id, name, type, url, data): """update(context, id, export_control, active) Update an analytic >>> dcictl analytic-update [OPTIONS] :param string job-id: The job on which to attach the analytic :param string name: Name of the analytic [required] :param string type: ...
[ "def", "update", "(", "context", ",", "id", ",", "job_id", ",", "name", ",", "type", ",", "url", ",", "data", ")", ":", "analytic_info", "=", "analytic", ".", "get", "(", "context", ",", "id", "=", "id", ",", "job_id", "=", "job_id", ")", "etag", ...
update(context, id, export_control, active) Update an analytic >>> dcictl analytic-update [OPTIONS] :param string job-id: The job on which to attach the analytic :param string name: Name of the analytic [required] :param string type: Type of the analytic [required] :param string url: Url of t...
[ "update", "(", "context", "id", "export_control", "active", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/analytic.py#L76-L97
train
Update an analytic node
redhat-cip/python-dciclient
dciclient/v1/shell_commands/analytic.py
show
def show(context, id, job_id): """show(context, id, job_id) Show an analytic. >>> dcictl analytic-show [OPTIONS] id :param string id: The id of the analytic :param string job-id: The job on which to show the analytic """ result = analytic.get(context, id, job_id=job_id) utils.format_...
python
def show(context, id, job_id): """show(context, id, job_id) Show an analytic. >>> dcictl analytic-show [OPTIONS] id :param string id: The id of the analytic :param string job-id: The job on which to show the analytic """ result = analytic.get(context, id, job_id=job_id) utils.format_...
[ "def", "show", "(", "context", ",", "id", ",", "job_id", ")", ":", "result", "=", "analytic", ".", "get", "(", "context", ",", "id", ",", "job_id", "=", "job_id", ")", "utils", ".", "format_output", "(", "result", ",", "context", ".", "format", ")" ]
show(context, id, job_id) Show an analytic. >>> dcictl analytic-show [OPTIONS] id :param string id: The id of the analytic :param string job-id: The job on which to show the analytic
[ "show", "(", "context", "id", "job_id", ")" ]
a4aa5899062802bbe4c30a075d8447f8d222d214
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/analytic.py#L104-L116
train
Show an analytic.
mojaie/chorus
chorus/util/text.py
substitute
def substitute(dict_, source): """ Perform re.sub with the patterns in the given dict Args: dict_: {pattern: repl} source: str """ d_esc = (re.escape(k) for k in dict_.keys()) pattern = re.compile('|'.join(d_esc)) return pattern.sub(lambda x: dict_[x.group()], source)
python
def substitute(dict_, source): """ Perform re.sub with the patterns in the given dict Args: dict_: {pattern: repl} source: str """ d_esc = (re.escape(k) for k in dict_.keys()) pattern = re.compile('|'.join(d_esc)) return pattern.sub(lambda x: dict_[x.group()], source)
[ "def", "substitute", "(", "dict_", ",", "source", ")", ":", "d_esc", "=", "(", "re", ".", "escape", "(", "k", ")", "for", "k", "in", "dict_", ".", "keys", "(", ")", ")", "pattern", "=", "re", ".", "compile", "(", "'|'", ".", "join", "(", "d_esc...
Perform re.sub with the patterns in the given dict Args: dict_: {pattern: repl} source: str
[ "Perform", "re", ".", "sub", "with", "the", "patterns", "in", "the", "given", "dict", "Args", ":", "dict_", ":", "{", "pattern", ":", "repl", "}", "source", ":", "str" ]
fc7fe23a0272554c67671645ab07830b315eeb1b
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/util/text.py#L10-L18
train
Perform re. sub with the patterns in the given dict
jslang/responsys
responsys/types.py
InteractType.soap_attribute
def soap_attribute(self, name, value): """ Marks an attribute as being a part of the data defined by the soap datatype""" setattr(self, name, value) self._attributes.add(name)
python
def soap_attribute(self, name, value): """ Marks an attribute as being a part of the data defined by the soap datatype""" setattr(self, name, value) self._attributes.add(name)
[ "def", "soap_attribute", "(", "self", ",", "name", ",", "value", ")", ":", "setattr", "(", "self", ",", "name", ",", "value", ")", "self", ".", "_attributes", ".", "add", "(", "name", ")" ]
Marks an attribute as being a part of the data defined by the soap datatype
[ "Marks", "an", "attribute", "as", "being", "a", "part", "of", "the", "data", "defined", "by", "the", "soap", "datatype" ]
9b355a444c0c75dff41064502c1e2b76dfd5cb93
https://github.com/jslang/responsys/blob/9b355a444c0c75dff41064502c1e2b76dfd5cb93/responsys/types.py#L32-L35
train
Mark an attribute as being part of the data defined by the soap datatype
jslang/responsys
responsys/types.py
InteractType.get_soap_object
def get_soap_object(self, client): """ Create and return a soap service type defined for this instance """ def to_soap_attribute(attr): words = attr.split('_') words = words[:1] + [word.capitalize() for word in words[1:]] return ''.join(words) soap_object = c...
python
def get_soap_object(self, client): """ Create and return a soap service type defined for this instance """ def to_soap_attribute(attr): words = attr.split('_') words = words[:1] + [word.capitalize() for word in words[1:]] return ''.join(words) soap_object = c...
[ "def", "get_soap_object", "(", "self", ",", "client", ")", ":", "def", "to_soap_attribute", "(", "attr", ")", ":", "words", "=", "attr", ".", "split", "(", "'_'", ")", "words", "=", "words", "[", ":", "1", "]", "+", "[", "word", ".", "capitalize", ...
Create and return a soap service type defined for this instance
[ "Create", "and", "return", "a", "soap", "service", "type", "defined", "for", "this", "instance" ]
9b355a444c0c75dff41064502c1e2b76dfd5cb93
https://github.com/jslang/responsys/blob/9b355a444c0c75dff41064502c1e2b76dfd5cb93/responsys/types.py#L37-L49
train
Create and return a soap service type defined for this instance
jslang/responsys
responsys/types.py
RecordData.get_soap_object
def get_soap_object(self, client): """ Override default get_soap_object behavior to account for child Record types """ record_data = super().get_soap_object(client) record_data.records = [Record(r).get_soap_object(client) for r in record_data.records] return record_data
python
def get_soap_object(self, client): """ Override default get_soap_object behavior to account for child Record types """ record_data = super().get_soap_object(client) record_data.records = [Record(r).get_soap_object(client) for r in record_data.records] return record_data
[ "def", "get_soap_object", "(", "self", ",", "client", ")", ":", "record_data", "=", "super", "(", ")", ".", "get_soap_object", "(", "client", ")", "record_data", ".", "records", "=", "[", "Record", "(", "r", ")", ".", "get_soap_object", "(", "client", ")...
Override default get_soap_object behavior to account for child Record types
[ "Override", "default", "get_soap_object", "behavior", "to", "account", "for", "child", "Record", "types" ]
9b355a444c0c75dff41064502c1e2b76dfd5cb93
https://github.com/jslang/responsys/blob/9b355a444c0c75dff41064502c1e2b76dfd5cb93/responsys/types.py#L158-L162
train
Override default get_soap_object behavior to account for child Record types
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.retransmit
def retransmit(self, data): """Processes messages that have been delivered from the listener. Args: data (dict): A dictionary containing the uuid, euuid, and message response. E.g. {"cuuid": x, "euuid": y, "response": z}. Returns: None """ # If...
python
def retransmit(self, data): """Processes messages that have been delivered from the listener. Args: data (dict): A dictionary containing the uuid, euuid, and message response. E.g. {"cuuid": x, "euuid": y, "response": z}. Returns: None """ # If...
[ "def", "retransmit", "(", "self", ",", "data", ")", ":", "# If that shit is still in self.event_uuids, then that means we STILL", "# haven't gotten a response from the client. Then we resend that shit", "# and WAIT", "if", "data", "[", "\"euuid\"", "]", "in", "self", ".", "even...
Processes messages that have been delivered from the listener. Args: data (dict): A dictionary containing the uuid, euuid, and message response. E.g. {"cuuid": x, "euuid": y, "response": z}. Returns: None
[ "Processes", "messages", "that", "have", "been", "delivered", "from", "the", "listener", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L161-L208
train
Processes messages that have been delivered from the listener and retransmits them to the client.
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.handle_message
def handle_message(self, msg, host): """Processes messages that have been delivered from the listener. Args: msg (string): The raw packet data delivered from the listener. This data will be unserialized and then processed based on the packet's method. host (t...
python
def handle_message(self, msg, host): """Processes messages that have been delivered from the listener. Args: msg (string): The raw packet data delivered from the listener. This data will be unserialized and then processed based on the packet's method. host (t...
[ "def", "handle_message", "(", "self", ",", "msg", ",", "host", ")", ":", "response", "=", "None", "# Unserialize the packet, and decrypt if the host has encryption enabled", "if", "host", "in", "self", ".", "encrypted_hosts", ":", "msg_data", "=", "unserialize_data", ...
Processes messages that have been delivered from the listener. Args: msg (string): The raw packet data delivered from the listener. This data will be unserialized and then processed based on the packet's method. host (tuple): The (address, host) tuple of the source m...
[ "Processes", "messages", "that", "have", "been", "delivered", "from", "the", "listener", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L211-L269
train
Handles a single message from the listener.
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.handle_message_registered
def handle_message_registered(self, msg_data, host): """Processes messages that have been delivered by a registered client. Args: msg (string): The raw packet data delivered from the listener. This data will be unserialized and then processed based on the packet's meth...
python
def handle_message_registered(self, msg_data, host): """Processes messages that have been delivered by a registered client. Args: msg (string): The raw packet data delivered from the listener. This data will be unserialized and then processed based on the packet's meth...
[ "def", "handle_message_registered", "(", "self", ",", "msg_data", ",", "host", ")", ":", "response", "=", "None", "if", "msg_data", "[", "\"method\"", "]", "==", "\"EVENT\"", ":", "logger", ".", "debug", "(", "\"<%s> <euuid:%s> Event message \"", "\"received\"", ...
Processes messages that have been delivered by a registered client. Args: msg (string): The raw packet data delivered from the listener. This data will be unserialized and then processed based on the packet's method. host (tuple): The (address, host) tuple of the sou...
[ "Processes", "messages", "that", "have", "been", "delivered", "by", "a", "registered", "client", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L272-L318
train
Processes a message that has been delivered by a registered client.
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.autodiscover
def autodiscover(self, message): """This function simply returns the server version number as a response to the client. Args: message (dict): A dictionary of the autodiscover message from the client. Returns: A JSON string of the "OHAI Client" server res...
python
def autodiscover(self, message): """This function simply returns the server version number as a response to the client. Args: message (dict): A dictionary of the autodiscover message from the client. Returns: A JSON string of the "OHAI Client" server res...
[ "def", "autodiscover", "(", "self", ",", "message", ")", ":", "# Check to see if the client's version is the same as our own.", "if", "message", "[", "\"version\"", "]", "in", "self", ".", "allowed_versions", ":", "logger", ".", "debug", "(", "\"<%s> Client version matc...
This function simply returns the server version number as a response to the client. Args: message (dict): A dictionary of the autodiscover message from the client. Returns: A JSON string of the "OHAI Client" server response with the server's version nu...
[ "This", "function", "simply", "returns", "the", "server", "version", "number", "as", "a", "response", "to", "the", "client", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L321-L356
train
This function returns the server s version number as a response to the client.
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.register
def register(self, message, host): """This function will register a particular client in the server's registry dictionary. Any clients that are registered will be able to send and recieve events to and from the server. Args: message (dict): The client message from the...
python
def register(self, message, host): """This function will register a particular client in the server's registry dictionary. Any clients that are registered will be able to send and recieve events to and from the server. Args: message (dict): The client message from the...
[ "def", "register", "(", "self", ",", "message", ",", "host", ")", ":", "# Get the client generated cuuid from the register message", "cuuid", "=", "message", "[", "\"cuuid\"", "]", "# Check to see if we've hit the maximum number of registrations", "# If we've reached the maximum ...
This function will register a particular client in the server's registry dictionary. Any clients that are registered will be able to send and recieve events to and from the server. Args: message (dict): The client message from the client who wants to register. ...
[ "This", "function", "will", "register", "a", "particular", "client", "in", "the", "server", "s", "registry", "dictionary", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L359-L429
train
This function will register a particular client in the server s registry dictionary.
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.is_registered
def is_registered(self, cuuid, host): """This function will check to see if a given host with client uuid is currently registered. Args: cuuid (string): The client uuid that wishes to register. host (tuple): The (address, port) tuple of the client that is registe...
python
def is_registered(self, cuuid, host): """This function will check to see if a given host with client uuid is currently registered. Args: cuuid (string): The client uuid that wishes to register. host (tuple): The (address, port) tuple of the client that is registe...
[ "def", "is_registered", "(", "self", ",", "cuuid", ",", "host", ")", ":", "# Check to see if the host with the client uuid exists in the registry", "# table.", "if", "(", "cuuid", "in", "self", ".", "registry", ")", "and", "(", "self", ".", "registry", "[", "cuuid...
This function will check to see if a given host with client uuid is currently registered. Args: cuuid (string): The client uuid that wishes to register. host (tuple): The (address, port) tuple of the client that is registering. Returns: Will return Tru...
[ "This", "function", "will", "check", "to", "see", "if", "a", "given", "host", "with", "client", "uuid", "is", "currently", "registered", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L432-L451
train
This function will check to see if a given host with client uuid is currently registered.
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.event
def event(self, cuuid, host, euuid, event_data, timestamp, priority): """This function will process event packets and send them to legal checks. Args: cuuid (string): The client uuid that the event came from. host (tuple): The (address, port) tuple of the client. e...
python
def event(self, cuuid, host, euuid, event_data, timestamp, priority): """This function will process event packets and send them to legal checks. Args: cuuid (string): The client uuid that the event came from. host (tuple): The (address, port) tuple of the client. e...
[ "def", "event", "(", "self", ",", "cuuid", ",", "host", ",", "euuid", ",", "event_data", ",", "timestamp", ",", "priority", ")", ":", "# Set the initial response to none", "response", "=", "None", "# If the host we're sending to is using encryption, get their key to", "...
This function will process event packets and send them to legal checks. Args: cuuid (string): The client uuid that the event came from. host (tuple): The (address, port) tuple of the client. euuid (string): The event uuid of the specific event. event_data (any): ...
[ "This", "function", "will", "process", "event", "packets", "and", "send", "them", "to", "legal", "checks", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L454-L555
train
This function will process the event packets and send them to the appropriate handler.
ShadowBlip/Neteria
neteria/server.py
NeteriaServer.notify
def notify(self, cuuid, event_data): """This function will send a NOTIFY event to a registered client. NOTIFY messages are nearly identical to EVENT messages, except that NOTIFY messages are always sent from server -> client. EVENT messages are always sent from client -> server. In addi...
python
def notify(self, cuuid, event_data): """This function will send a NOTIFY event to a registered client. NOTIFY messages are nearly identical to EVENT messages, except that NOTIFY messages are always sent from server -> client. EVENT messages are always sent from client -> server. In addi...
[ "def", "notify", "(", "self", ",", "cuuid", ",", "event_data", ")", ":", "# Generate an event uuid for the notify event", "euuid", "=", "str", "(", "uuid", ".", "uuid1", "(", ")", ")", "# If the client uses encryption, get their key to encrypt", "if", "\"encryption\"", ...
This function will send a NOTIFY event to a registered client. NOTIFY messages are nearly identical to EVENT messages, except that NOTIFY messages are always sent from server -> client. EVENT messages are always sent from client -> server. In addition to this difference, NOTIFY messages...
[ "This", "function", "will", "send", "a", "NOTIFY", "event", "to", "a", "registered", "client", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/server.py#L558-L630
train
This function sends a NOTIFY event to a registered client.
untwisted/untwisted
untwisted/wrappers.py
once
def once(dispatcher, event, handle, *args): """ Used to do a mapping like event -> handle but handle is called just once upon event. """ def shell(dispatcher, *args): try: handle(dispatcher, *args) except Exception as e: raise e finally: d...
python
def once(dispatcher, event, handle, *args): """ Used to do a mapping like event -> handle but handle is called just once upon event. """ def shell(dispatcher, *args): try: handle(dispatcher, *args) except Exception as e: raise e finally: d...
[ "def", "once", "(", "dispatcher", ",", "event", ",", "handle", ",", "*", "args", ")", ":", "def", "shell", "(", "dispatcher", ",", "*", "args", ")", ":", "try", ":", "handle", "(", "dispatcher", ",", "*", "args", ")", "except", "Exception", "as", "...
Used to do a mapping like event -> handle but handle is called just once upon event.
[ "Used", "to", "do", "a", "mapping", "like", "event", "-", ">", "handle", "but", "handle", "is", "called", "just", "once", "upon", "event", "." ]
8a8d9c8a8d0f3452d5de67cd760297bb5759f637
https://github.com/untwisted/untwisted/blob/8a8d9c8a8d0f3452d5de67cd760297bb5759f637/untwisted/wrappers.py#L7-L20
train
Used to do a mapping like event - > handle
untwisted/untwisted
untwisted/core.py
Gear.mainloop
def mainloop(self): """ This is the reactor mainloop. It is intented to be called when a reactor is installed. from untwisted.network import * # It processes forever. core.gear.mainloop() """ while True: # It calls repeteadl...
python
def mainloop(self): """ This is the reactor mainloop. It is intented to be called when a reactor is installed. from untwisted.network import * # It processes forever. core.gear.mainloop() """ while True: # It calls repeteadl...
[ "def", "mainloop", "(", "self", ")", ":", "while", "True", ":", "# It calls repeteadly the reactor", "# update method.", "try", ":", "self", ".", "update", "(", ")", "except", "Kill", ":", "# It breaks the loop", "# silently.", "# people implementing reactors from other...
This is the reactor mainloop. It is intented to be called when a reactor is installed. from untwisted.network import * # It processes forever. core.gear.mainloop()
[ "This", "is", "the", "reactor", "mainloop", ".", "It", "is", "intented", "to", "be", "called", "when", "a", "reactor", "is", "installed", "." ]
8a8d9c8a8d0f3452d5de67cd760297bb5759f637
https://github.com/untwisted/untwisted/blob/8a8d9c8a8d0f3452d5de67cd760297bb5759f637/untwisted/core.py#L41-L68
train
Main loop for the reactor.
thorgate/django-esteid
esteid/digidocservice/service.py
DigiDocService.start_session
def start_session(self, b_hold_session, sig_doc_xml=None, datafile=None): """Start a DigidocService session :return: True if session was started and session code was stored in I{session_code} """ response = self.__invoke('StartSession', { 'bHoldSession': b_hold_session, ...
python
def start_session(self, b_hold_session, sig_doc_xml=None, datafile=None): """Start a DigidocService session :return: True if session was started and session code was stored in I{session_code} """ response = self.__invoke('StartSession', { 'bHoldSession': b_hold_session, ...
[ "def", "start_session", "(", "self", ",", "b_hold_session", ",", "sig_doc_xml", "=", "None", ",", "datafile", "=", "None", ")", ":", "response", "=", "self", ".", "__invoke", "(", "'StartSession'", ",", "{", "'bHoldSession'", ":", "b_hold_session", ",", "'Si...
Start a DigidocService session :return: True if session was started and session code was stored in I{session_code}
[ "Start", "a", "DigidocService", "session" ]
407ae513e357fedea0e3e42198df8eb9d9ff0646
https://github.com/thorgate/django-esteid/blob/407ae513e357fedea0e3e42198df8eb9d9ff0646/esteid/digidocservice/service.py#L153-L179
train
Start a DigidocService session
thorgate/django-esteid
esteid/digidocservice/service.py
DigiDocService.mobile_sign
def mobile_sign(self, id_code, country, phone_nr, language=None, signing_profile='LT_TM'): """ This can be used to add a signature to existing data files WARNING: Must have at least one datafile in the session """ if not (self.container and isinstance(self.container, PreviouslyCrea...
python
def mobile_sign(self, id_code, country, phone_nr, language=None, signing_profile='LT_TM'): """ This can be used to add a signature to existing data files WARNING: Must have at least one datafile in the session """ if not (self.container and isinstance(self.container, PreviouslyCrea...
[ "def", "mobile_sign", "(", "self", ",", "id_code", ",", "country", ",", "phone_nr", ",", "language", "=", "None", ",", "signing_profile", "=", "'LT_TM'", ")", ":", "if", "not", "(", "self", ".", "container", "and", "isinstance", "(", "self", ".", "contai...
This can be used to add a signature to existing data files WARNING: Must have at least one datafile in the session
[ "This", "can", "be", "used", "to", "add", "a", "signature", "to", "existing", "data", "files" ]
407ae513e357fedea0e3e42198df8eb9d9ff0646
https://github.com/thorgate/django-esteid/blob/407ae513e357fedea0e3e42198df8eb9d9ff0646/esteid/digidocservice/service.py#L299-L334
train
This method is used to add a signature to existing data files in the session.
sfstpala/pcr
pcr/maths.py
check_candidate
def check_candidate(a, d, n, s): """Part of the Miller-Rabin primality test in is_prime().""" if pow(a, d, n) == 1: return False for i in range(s): if pow(a, 2 ** i * d, n) == n - 1: return False return True
python
def check_candidate(a, d, n, s): """Part of the Miller-Rabin primality test in is_prime().""" if pow(a, d, n) == 1: return False for i in range(s): if pow(a, 2 ** i * d, n) == n - 1: return False return True
[ "def", "check_candidate", "(", "a", ",", "d", ",", "n", ",", "s", ")", ":", "if", "pow", "(", "a", ",", "d", ",", "n", ")", "==", "1", ":", "return", "False", "for", "i", "in", "range", "(", "s", ")", ":", "if", "pow", "(", "a", ",", "2",...
Part of the Miller-Rabin primality test in is_prime().
[ "Part", "of", "the", "Miller", "-", "Rabin", "primality", "test", "in", "is_prime", "()", "." ]
313ec17585565a0b9740f7b3f47d7a93bf37a7fc
https://github.com/sfstpala/pcr/blob/313ec17585565a0b9740f7b3f47d7a93bf37a7fc/pcr/maths.py#L24-L31
train
Part of the Miller - Rabin primality test in is_prime ().
sfstpala/pcr
pcr/maths.py
is_prime
def is_prime(n, k=64): """ Test whether n is prime probabilisticly. This uses the Miller-Rabin primality test. If n is composite, then this test will declare it to be probably prime with a probability of at most 4**-k. To be on the safe side, a value of k=64 for integers up to 3072 bits is...
python
def is_prime(n, k=64): """ Test whether n is prime probabilisticly. This uses the Miller-Rabin primality test. If n is composite, then this test will declare it to be probably prime with a probability of at most 4**-k. To be on the safe side, a value of k=64 for integers up to 3072 bits is...
[ "def", "is_prime", "(", "n", ",", "k", "=", "64", ")", ":", "if", "n", "==", "2", ":", "return", "True", "if", "n", "<", "2", "or", "n", "%", "2", "==", "0", ":", "return", "False", "for", "i", "in", "range", "(", "3", ",", "2048", ")", "...
Test whether n is prime probabilisticly. This uses the Miller-Rabin primality test. If n is composite, then this test will declare it to be probably prime with a probability of at most 4**-k. To be on the safe side, a value of k=64 for integers up to 3072 bits is recommended (error probability = 2...
[ "Test", "whether", "n", "is", "prime", "probabilisticly", "." ]
313ec17585565a0b9740f7b3f47d7a93bf37a7fc
https://github.com/sfstpala/pcr/blob/313ec17585565a0b9740f7b3f47d7a93bf37a7fc/pcr/maths.py#L34-L71
train
Test whether n is prime probabilisticly.
sfstpala/pcr
pcr/maths.py
get_prime
def get_prime(bits, k=64): """ Return a random prime up to a certain length. This function uses random.SystemRandom. """ if bits % 8 != 0 or bits == 0: raise ValueError("bits must be >= 0 and divisible by 8") while True: n = int.from_bytes(os.urandom(bits // 8), "big") ...
python
def get_prime(bits, k=64): """ Return a random prime up to a certain length. This function uses random.SystemRandom. """ if bits % 8 != 0 or bits == 0: raise ValueError("bits must be >= 0 and divisible by 8") while True: n = int.from_bytes(os.urandom(bits // 8), "big") ...
[ "def", "get_prime", "(", "bits", ",", "k", "=", "64", ")", ":", "if", "bits", "%", "8", "!=", "0", "or", "bits", "==", "0", ":", "raise", "ValueError", "(", "\"bits must be >= 0 and divisible by 8\"", ")", "while", "True", ":", "n", "=", "int", ".", ...
Return a random prime up to a certain length. This function uses random.SystemRandom.
[ "Return", "a", "random", "prime", "up", "to", "a", "certain", "length", "." ]
313ec17585565a0b9740f7b3f47d7a93bf37a7fc
https://github.com/sfstpala/pcr/blob/313ec17585565a0b9740f7b3f47d7a93bf37a7fc/pcr/maths.py#L74-L86
train
Return a random prime up to a certain length.
sfstpala/pcr
pcr/maths.py
mult_inv
def mult_inv(a, b): """ Calculate the multiplicative inverse a**-1 % b. This function works for n >= 5 where n is prime. """ # in addition to the normal setup, we also remember b last_b, x, last_x, y, last_y = b, 0, 1, 1, 0 while b != 0: q = a // b a, b = b, a % b x,...
python
def mult_inv(a, b): """ Calculate the multiplicative inverse a**-1 % b. This function works for n >= 5 where n is prime. """ # in addition to the normal setup, we also remember b last_b, x, last_x, y, last_y = b, 0, 1, 1, 0 while b != 0: q = a // b a, b = b, a % b x,...
[ "def", "mult_inv", "(", "a", ",", "b", ")", ":", "# in addition to the normal setup, we also remember b", "last_b", ",", "x", ",", "last_x", ",", "y", ",", "last_y", "=", "b", ",", "0", ",", "1", ",", "1", ",", "0", "while", "b", "!=", "0", ":", "q",...
Calculate the multiplicative inverse a**-1 % b. This function works for n >= 5 where n is prime.
[ "Calculate", "the", "multiplicative", "inverse", "a", "**", "-", "1", "%", "b", "." ]
313ec17585565a0b9740f7b3f47d7a93bf37a7fc
https://github.com/sfstpala/pcr/blob/313ec17585565a0b9740f7b3f47d7a93bf37a7fc/pcr/maths.py#L100-L116
train
Calculate the multiplicative inverse of a and b.
sfstpala/pcr
pcr/maths.py
make_rsa_keys
def make_rsa_keys(bits=2048, e=65537, k=64): """ Create RSA key pair. Returns n, e, d, where (n, e) is the public key and (n, e, d) is the private key (and k is the number of rounds used in the Miller-Rabin primality test). """ p, q = None, None while p == q: p, q = get_pri...
python
def make_rsa_keys(bits=2048, e=65537, k=64): """ Create RSA key pair. Returns n, e, d, where (n, e) is the public key and (n, e, d) is the private key (and k is the number of rounds used in the Miller-Rabin primality test). """ p, q = None, None while p == q: p, q = get_pri...
[ "def", "make_rsa_keys", "(", "bits", "=", "2048", ",", "e", "=", "65537", ",", "k", "=", "64", ")", ":", "p", ",", "q", "=", "None", ",", "None", "while", "p", "==", "q", ":", "p", ",", "q", "=", "get_prime", "(", "bits", "//", "2", ")", ",...
Create RSA key pair. Returns n, e, d, where (n, e) is the public key and (n, e, d) is the private key (and k is the number of rounds used in the Miller-Rabin primality test).
[ "Create", "RSA", "key", "pair", "." ]
313ec17585565a0b9740f7b3f47d7a93bf37a7fc
https://github.com/sfstpala/pcr/blob/313ec17585565a0b9740f7b3f47d7a93bf37a7fc/pcr/maths.py#L119-L135
train
Create RSA key pair.
brutus/wdiffhtml
wdiffhtml/cli.py
parse_commandline
def parse_commandline(argv): """ Returns the arguments parsed from *argv* as a namespace. """ ap = ArgumentParser( prog='wdiffhtml', description=DESCRIPTION, epilog=EPILOG, ) ap.add_argument( '--version', action='version', version='wdiffhtml v{}'.format(version), help="shows version and...
python
def parse_commandline(argv): """ Returns the arguments parsed from *argv* as a namespace. """ ap = ArgumentParser( prog='wdiffhtml', description=DESCRIPTION, epilog=EPILOG, ) ap.add_argument( '--version', action='version', version='wdiffhtml v{}'.format(version), help="shows version and...
[ "def", "parse_commandline", "(", "argv", ")", ":", "ap", "=", "ArgumentParser", "(", "prog", "=", "'wdiffhtml'", ",", "description", "=", "DESCRIPTION", ",", "epilog", "=", "EPILOG", ",", ")", "ap", ".", "add_argument", "(", "'--version'", ",", "action", "...
Returns the arguments parsed from *argv* as a namespace.
[ "Returns", "the", "arguments", "parsed", "from", "*", "argv", "*", "as", "a", "namespace", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/wdiffhtml/cli.py#L55-L144
train
Parse the command line arguments and return them as a namespace.
brutus/wdiffhtml
wdiffhtml/cli.py
get_context
def get_context(args): """ Returns a context from the namespace *args* (command line arguments). """ context = {} if args.revision: context['version'] = args.revision if args.datestamp: context['timestamp'] = "{:%Y-%m-%d}".format(datetime.utcnow()) if args.timestamp: context['timestamp'] = "{...
python
def get_context(args): """ Returns a context from the namespace *args* (command line arguments). """ context = {} if args.revision: context['version'] = args.revision if args.datestamp: context['timestamp'] = "{:%Y-%m-%d}".format(datetime.utcnow()) if args.timestamp: context['timestamp'] = "{...
[ "def", "get_context", "(", "args", ")", ":", "context", "=", "{", "}", "if", "args", ".", "revision", ":", "context", "[", "'version'", "]", "=", "args", ".", "revision", "if", "args", ".", "datestamp", ":", "context", "[", "'timestamp'", "]", "=", "...
Returns a context from the namespace *args* (command line arguments).
[ "Returns", "a", "context", "from", "the", "namespace", "*", "args", "*", "(", "command", "line", "arguments", ")", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/wdiffhtml/cli.py#L147-L165
train
Returns a context from the namespace args.
brutus/wdiffhtml
wdiffhtml/cli.py
run_cli
def run_cli(argv=None): """ Calls :func:`wdiff` and prints the results to STDERR. Parses the options for :meth:`wdiff` with :func:`parse_commandline`. If *argv* is supplied, it is used as command line, else the actual one is used. Return Codes ------------ 0: okay 1: error with arguments 2: `wdiff`...
python
def run_cli(argv=None): """ Calls :func:`wdiff` and prints the results to STDERR. Parses the options for :meth:`wdiff` with :func:`parse_commandline`. If *argv* is supplied, it is used as command line, else the actual one is used. Return Codes ------------ 0: okay 1: error with arguments 2: `wdiff`...
[ "def", "run_cli", "(", "argv", "=", "None", ")", ":", "args", "=", "parse_commandline", "(", "argv", ")", "try", ":", "context", "=", "get_context", "(", "args", ")", "settings", "=", "Settings", "(", "args", ".", "org_file", ",", "args", ".", "new_fil...
Calls :func:`wdiff` and prints the results to STDERR. Parses the options for :meth:`wdiff` with :func:`parse_commandline`. If *argv* is supplied, it is used as command line, else the actual one is used. Return Codes ------------ 0: okay 1: error with arguments 2: `wdiff` not found 3: error running `w...
[ "Calls", ":", "func", ":", "wdiff", "and", "prints", "the", "results", "to", "STDERR", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/wdiffhtml/cli.py#L168-L201
train
A wrapper for wdiff.
bluekeyes/sphinx-javalink
javalink/__init__.py
setup
def setup(app): """Register the extension with Sphinx. Args: app: The Sphinx application. """ for name, (default, rebuild, _) in ref.CONFIG_VALUES.iteritems(): app.add_config_value(name, default, rebuild) app.add_directive('javaimport', ref.JavarefImportDirective) app.add_role...
python
def setup(app): """Register the extension with Sphinx. Args: app: The Sphinx application. """ for name, (default, rebuild, _) in ref.CONFIG_VALUES.iteritems(): app.add_config_value(name, default, rebuild) app.add_directive('javaimport', ref.JavarefImportDirective) app.add_role...
[ "def", "setup", "(", "app", ")", ":", "for", "name", ",", "(", "default", ",", "rebuild", ",", "_", ")", "in", "ref", ".", "CONFIG_VALUES", ".", "iteritems", "(", ")", ":", "app", ".", "add_config_value", "(", "name", ",", "default", ",", "rebuild", ...
Register the extension with Sphinx. Args: app: The Sphinx application.
[ "Register", "the", "extension", "with", "Sphinx", "." ]
490e37506efa53e95ad88a665e347536e75b6254
https://github.com/bluekeyes/sphinx-javalink/blob/490e37506efa53e95ad88a665e347536e75b6254/javalink/__init__.py#L9-L25
train
Register the extension with Sphinx.
bluekeyes/sphinx-javalink
javalink/__init__.py
validate_env
def validate_env(app): """Purge expired values from the environment. When certain configuration values change, related values in the environment must be cleared. While Sphinx can rebuild documents on configuration changes, it does not notify extensions when this happens. Instead, cache relevant val...
python
def validate_env(app): """Purge expired values from the environment. When certain configuration values change, related values in the environment must be cleared. While Sphinx can rebuild documents on configuration changes, it does not notify extensions when this happens. Instead, cache relevant val...
[ "def", "validate_env", "(", "app", ")", ":", "if", "not", "hasattr", "(", "app", ".", "env", ",", "'javalink_config_cache'", ")", ":", "app", ".", "env", ".", "javalink_config_cache", "=", "{", "}", "for", "conf_attr", ",", "(", "_", ",", "_", ",", "...
Purge expired values from the environment. When certain configuration values change, related values in the environment must be cleared. While Sphinx can rebuild documents on configuration changes, it does not notify extensions when this happens. Instead, cache relevant values in the environment in orde...
[ "Purge", "expired", "values", "from", "the", "environment", "." ]
490e37506efa53e95ad88a665e347536e75b6254
https://github.com/bluekeyes/sphinx-javalink/blob/490e37506efa53e95ad88a665e347536e75b6254/javalink/__init__.py#L32-L58
train
Purge expired values from the environment.
bluekeyes/sphinx-javalink
javalink/__init__.py
find_rt_jar
def find_rt_jar(javahome=None): """Find the path to the Java standard library jar. The jar is expected to exist at the path 'jre/lib/rt.jar' inside a standard Java installation directory. The directory is found using the following procedure: 1. If the javehome argument is provided, use the value a...
python
def find_rt_jar(javahome=None): """Find the path to the Java standard library jar. The jar is expected to exist at the path 'jre/lib/rt.jar' inside a standard Java installation directory. The directory is found using the following procedure: 1. If the javehome argument is provided, use the value a...
[ "def", "find_rt_jar", "(", "javahome", "=", "None", ")", ":", "if", "not", "javahome", ":", "if", "'JAVA_HOME'", "in", "os", ".", "environ", ":", "javahome", "=", "os", ".", "environ", "[", "'JAVA_HOME'", "]", "elif", "sys", ".", "platform", "==", "'da...
Find the path to the Java standard library jar. The jar is expected to exist at the path 'jre/lib/rt.jar' inside a standard Java installation directory. The directory is found using the following procedure: 1. If the javehome argument is provided, use the value as the directory. 2. If the J...
[ "Find", "the", "path", "to", "the", "Java", "standard", "library", "jar", "." ]
490e37506efa53e95ad88a665e347536e75b6254
https://github.com/bluekeyes/sphinx-javalink/blob/490e37506efa53e95ad88a665e347536e75b6254/javalink/__init__.py#L61-L95
train
Find the path to the Java standard library jar.
blue-yonder/cee_syslog_handler
cee_syslog_handler/__init__.py
RegexFilter.filter
def filter(self, record): """ Returns True if the record shall be logged. False otherwise. https://github.com/python/cpython/blob/2.7/Lib/logging/__init__.py#L607 """ found = self._pattern.search(record.getMessage()) return not found
python
def filter(self, record): """ Returns True if the record shall be logged. False otherwise. https://github.com/python/cpython/blob/2.7/Lib/logging/__init__.py#L607 """ found = self._pattern.search(record.getMessage()) return not found
[ "def", "filter", "(", "self", ",", "record", ")", ":", "found", "=", "self", ".", "_pattern", ".", "search", "(", "record", ".", "getMessage", "(", ")", ")", "return", "not", "found" ]
Returns True if the record shall be logged. False otherwise. https://github.com/python/cpython/blob/2.7/Lib/logging/__init__.py#L607
[ "Returns", "True", "if", "the", "record", "shall", "be", "logged", ".", "False", "otherwise", "." ]
c6006b59d38d4d8dabfc1301c689c71f35e3b8b8
https://github.com/blue-yonder/cee_syslog_handler/blob/c6006b59d38d4d8dabfc1301c689c71f35e3b8b8/cee_syslog_handler/__init__.py#L266-L273
train
Returns True if the record shall be logged False otherwise.
brutus/wdiffhtml
setup.py
get_meta
def get_meta(path=None): """ Returns a tuple of `__version__` and `__doc__` form the modul. If *path* is set, it is temporarily added to `sys.path`. """ if path: sys.path.insert(1, path) from wdiffhtml import __version__, __doc__ if path: del(sys.path[0]) return __version__, __doc__
python
def get_meta(path=None): """ Returns a tuple of `__version__` and `__doc__` form the modul. If *path* is set, it is temporarily added to `sys.path`. """ if path: sys.path.insert(1, path) from wdiffhtml import __version__, __doc__ if path: del(sys.path[0]) return __version__, __doc__
[ "def", "get_meta", "(", "path", "=", "None", ")", ":", "if", "path", ":", "sys", ".", "path", ".", "insert", "(", "1", ",", "path", ")", "from", "wdiffhtml", "import", "__version__", ",", "__doc__", "if", "path", ":", "del", "(", "sys", ".", "path"...
Returns a tuple of `__version__` and `__doc__` form the modul. If *path* is set, it is temporarily added to `sys.path`.
[ "Returns", "a", "tuple", "of", "__version__", "and", "__doc__", "form", "the", "modul", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/setup.py#L22-L34
train
Returns a tuple of the version and documentation of the modul.
zsimic/runez
src/runez/convert.py
flattened
def flattened(value, split=None): """ Args: value: Possibly nested arguments (sequence of lists, nested lists) split (int | str | unicode | (str | unicode, int) | None): How to split values: - None: simply flatten, no further processing - one char string: split() on speci...
python
def flattened(value, split=None): """ Args: value: Possibly nested arguments (sequence of lists, nested lists) split (int | str | unicode | (str | unicode, int) | None): How to split values: - None: simply flatten, no further processing - one char string: split() on speci...
[ "def", "flattened", "(", "value", ",", "split", "=", "None", ")", ":", "result", "=", "[", "]", "separator", "=", "None", "mode", "=", "0", "if", "isinstance", "(", "split", ",", "tuple", ")", ":", "separator", ",", "mode", "=", "split", "elif", "i...
Args: value: Possibly nested arguments (sequence of lists, nested lists) split (int | str | unicode | (str | unicode, int) | None): How to split values: - None: simply flatten, no further processing - one char string: split() on specified char - SANITIZED: discard all...
[ "Args", ":", "value", ":", "Possibly", "nested", "arguments", "(", "sequence", "of", "lists", "nested", "lists", ")", "split", "(", "int", "|", "str", "|", "unicode", "|", "(", "str", "|", "unicode", "int", ")", "|", "None", ")", ":", "How", "to", ...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L20-L44
train
Returns a list of items in the specified order from the specified value.
zsimic/runez
src/runez/convert.py
formatted
def formatted(text, *args, **kwargs): """ Args: text (str | unicode): Text to format *args: Objects to extract values from (as attributes) **kwargs: Optional values provided as named args Returns: (str): Attributes from this class are expanded if mentioned """ if not...
python
def formatted(text, *args, **kwargs): """ Args: text (str | unicode): Text to format *args: Objects to extract values from (as attributes) **kwargs: Optional values provided as named args Returns: (str): Attributes from this class are expanded if mentioned """ if not...
[ "def", "formatted", "(", "text", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "text", "or", "\"{\"", "not", "in", "text", ":", "return", "text", "strict", "=", "kwargs", ".", "pop", "(", "\"strict\"", ",", "True", ")", "max_dep...
Args: text (str | unicode): Text to format *args: Objects to extract values from (as attributes) **kwargs: Optional values provided as named args Returns: (str): Attributes from this class are expanded if mentioned
[ "Args", ":", "text", "(", "str", "|", "unicode", ")", ":", "Text", "to", "format", "*", "args", ":", "Objects", "to", "extract", "values", "from", "(", "as", "attributes", ")", "**", "kwargs", ":", "Optional", "values", "provided", "as", "named", "args...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L47-L79
train
Returns the text formatted with the specified attributes.
zsimic/runez
src/runez/convert.py
quoted
def quoted(text): """ Args: text (str | unicode | None): Text to optionally quote Returns: (str): Quoted if 'text' contains spaces """ if text and " " in text: sep = "'" if '"' in text else '"' return "%s%s%s" % (sep, text, sep) return text
python
def quoted(text): """ Args: text (str | unicode | None): Text to optionally quote Returns: (str): Quoted if 'text' contains spaces """ if text and " " in text: sep = "'" if '"' in text else '"' return "%s%s%s" % (sep, text, sep) return text
[ "def", "quoted", "(", "text", ")", ":", "if", "text", "and", "\" \"", "in", "text", ":", "sep", "=", "\"'\"", "if", "'\"'", "in", "text", "else", "'\"'", "return", "\"%s%s%s\"", "%", "(", "sep", ",", "text", ",", "sep", ")", "return", "text" ]
Args: text (str | unicode | None): Text to optionally quote Returns: (str): Quoted if 'text' contains spaces
[ "Args", ":", "text", "(", "str", "|", "unicode", "|", "None", ")", ":", "Text", "to", "optionally", "quote" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L82-L93
train
Quote the given text if it contains spaces.
zsimic/runez
src/runez/convert.py
represented_args
def represented_args(args, separator=" "): """ Args: args (list | tuple | None): Arguments to represent separator (str | unicode): Separator to use Returns: (str): Quoted as needed textual representation """ result = [] if args: for text in args: resu...
python
def represented_args(args, separator=" "): """ Args: args (list | tuple | None): Arguments to represent separator (str | unicode): Separator to use Returns: (str): Quoted as needed textual representation """ result = [] if args: for text in args: resu...
[ "def", "represented_args", "(", "args", ",", "separator", "=", "\" \"", ")", ":", "result", "=", "[", "]", "if", "args", ":", "for", "text", "in", "args", ":", "result", ".", "append", "(", "quoted", "(", "short", "(", "text", ")", ")", ")", "retur...
Args: args (list | tuple | None): Arguments to represent separator (str | unicode): Separator to use Returns: (str): Quoted as needed textual representation
[ "Args", ":", "args", "(", "list", "|", "tuple", "|", "None", ")", ":", "Arguments", "to", "represent", "separator", "(", "str", "|", "unicode", ")", ":", "Separator", "to", "use" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L96-L109
train
Returns a textual representation of the arguments.
zsimic/runez
src/runez/convert.py
resolved_path
def resolved_path(path, base=None): """ Args: path (str | unicode | None): Path to resolve base (str | unicode | None): Base path to use to resolve relative paths (default: current working dir) Returns: (str): Absolute path """ if not path or path.startswith(SYMBOLIC_TMP): ...
python
def resolved_path(path, base=None): """ Args: path (str | unicode | None): Path to resolve base (str | unicode | None): Base path to use to resolve relative paths (default: current working dir) Returns: (str): Absolute path """ if not path or path.startswith(SYMBOLIC_TMP): ...
[ "def", "resolved_path", "(", "path", ",", "base", "=", "None", ")", ":", "if", "not", "path", "or", "path", ".", "startswith", "(", "SYMBOLIC_TMP", ")", ":", "return", "path", "path", "=", "os", ".", "path", ".", "expanduser", "(", "path", ")", "if",...
Args: path (str | unicode | None): Path to resolve base (str | unicode | None): Base path to use to resolve relative paths (default: current working dir) Returns: (str): Absolute path
[ "Args", ":", "path", "(", "str", "|", "unicode", "|", "None", ")", ":", "Path", "to", "resolve", "base", "(", "str", "|", "unicode", "|", "None", ")", ":", "Base", "path", "to", "use", "to", "resolve", "relative", "paths", "(", "default", ":", "cur...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L112-L128
train
Resolves the path to a base directory and returns the absolute path.
zsimic/runez
src/runez/convert.py
shortened
def shortened(text, size=120): """ Args: text (str | unicode): Text to shorten size (int): Max chars Returns: (str): Leading part of 'text' with at most 'size' chars """ if text: text = text.strip() if len(text) > size: return "%s..." % text[:size...
python
def shortened(text, size=120): """ Args: text (str | unicode): Text to shorten size (int): Max chars Returns: (str): Leading part of 'text' with at most 'size' chars """ if text: text = text.strip() if len(text) > size: return "%s..." % text[:size...
[ "def", "shortened", "(", "text", ",", "size", "=", "120", ")", ":", "if", "text", ":", "text", "=", "text", ".", "strip", "(", ")", "if", "len", "(", "text", ")", ">", "size", ":", "return", "\"%s...\"", "%", "text", "[", ":", "size", "-", "3",...
Args: text (str | unicode): Text to shorten size (int): Max chars Returns: (str): Leading part of 'text' with at most 'size' chars
[ "Args", ":", "text", "(", "str", "|", "unicode", ")", ":", "Text", "to", "shorten", "size", "(", "int", ")", ":", "Max", "chars" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L135-L148
train
Shorten text to at most size chars.
zsimic/runez
src/runez/convert.py
_flatten
def _flatten(result, value, separator, mode): """ Args: result (list): Will hold all flattened values value: Possibly nested arguments (sequence of lists, nested lists) separator (str | unicode | None): Split values with `separator` if specified mode (int): Describes how keep fla...
python
def _flatten(result, value, separator, mode): """ Args: result (list): Will hold all flattened values value: Possibly nested arguments (sequence of lists, nested lists) separator (str | unicode | None): Split values with `separator` if specified mode (int): Describes how keep fla...
[ "def", "_flatten", "(", "result", ",", "value", ",", "separator", ",", "mode", ")", ":", "if", "value", "is", "None", "or", "value", "is", "UNSET", ":", "if", "mode", "&", "SHELL", ":", "# Convenience: allow to filter out [\"--switch\", None] easily", "if", "r...
Args: result (list): Will hold all flattened values value: Possibly nested arguments (sequence of lists, nested lists) separator (str | unicode | None): Split values with `separator` if specified mode (int): Describes how keep flattenened values Returns: list: 'value' flatte...
[ "Args", ":", "result", "(", "list", ")", ":", "Will", "hold", "all", "flattened", "values", "value", ":", "Possibly", "nested", "arguments", "(", "sequence", "of", "lists", "nested", "lists", ")", "separator", "(", "str", "|", "unicode", "|", "None", ")"...
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L227-L259
train
Flatten the list of items in the key - value pair into a single item.
zsimic/runez
src/runez/convert.py
_get_value
def _get_value(obj, key): """Get a value for 'key' from 'obj', if possible""" if isinstance(obj, (list, tuple)): for item in obj: v = _find_value(key, item) if v is not None: return v return None if isinstance(obj, dict): return obj.get(key) ...
python
def _get_value(obj, key): """Get a value for 'key' from 'obj', if possible""" if isinstance(obj, (list, tuple)): for item in obj: v = _find_value(key, item) if v is not None: return v return None if isinstance(obj, dict): return obj.get(key) ...
[ "def", "_get_value", "(", "obj", ",", "key", ")", ":", "if", "isinstance", "(", "obj", ",", "(", "list", ",", "tuple", ")", ")", ":", "for", "item", "in", "obj", ":", "v", "=", "_find_value", "(", "key", ",", "item", ")", "if", "v", "is", "not"...
Get a value for 'key' from 'obj', if possible
[ "Get", "a", "value", "for", "key", "from", "obj", "if", "possible" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L262-L273
train
Get a value for key from obj
zsimic/runez
src/runez/convert.py
_find_value
def _find_value(key, *args): """Find a value for 'key' in any of the objects given as 'args'""" for arg in args: v = _get_value(arg, key) if v is not None: return v
python
def _find_value(key, *args): """Find a value for 'key' in any of the objects given as 'args'""" for arg in args: v = _get_value(arg, key) if v is not None: return v
[ "def", "_find_value", "(", "key", ",", "*", "args", ")", ":", "for", "arg", "in", "args", ":", "v", "=", "_get_value", "(", "arg", ",", "key", ")", "if", "v", "is", "not", "None", ":", "return", "v" ]
Find a value for 'key' in any of the objects given as 'args
[ "Find", "a", "value", "for", "key", "in", "any", "of", "the", "objects", "given", "as", "args" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L276-L281
train
Find a value for key in any of the objects given as args.
zsimic/runez
src/runez/convert.py
Anchored.set
def set(cls, *anchors): """ Args: *anchors (str | unicode | list): Optional paths to use as anchors for short() """ cls.paths = sorted(flattened(anchors, split=SANITIZED | UNIQUE), reverse=True)
python
def set(cls, *anchors): """ Args: *anchors (str | unicode | list): Optional paths to use as anchors for short() """ cls.paths = sorted(flattened(anchors, split=SANITIZED | UNIQUE), reverse=True)
[ "def", "set", "(", "cls", ",", "*", "anchors", ")", ":", "cls", ".", "paths", "=", "sorted", "(", "flattened", "(", "anchors", ",", "split", "=", "SANITIZED", "|", "UNIQUE", ")", ",", "reverse", "=", "True", ")" ]
Args: *anchors (str | unicode | list): Optional paths to use as anchors for short()
[ "Args", ":", "*", "anchors", "(", "str", "|", "unicode", "|", "list", ")", ":", "Optional", "paths", "to", "use", "as", "anchors", "for", "short", "()" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L170-L175
train
Sets the base class s paths to use as anchors for short (
zsimic/runez
src/runez/convert.py
Anchored.pop
def pop(cls, anchors): """ Args: anchors (str | unicode | list): Optional paths to use as anchors for short() """ for anchor in flattened(anchors, split=SANITIZED | UNIQUE): if anchor in cls.paths: cls.paths.remove(anchor)
python
def pop(cls, anchors): """ Args: anchors (str | unicode | list): Optional paths to use as anchors for short() """ for anchor in flattened(anchors, split=SANITIZED | UNIQUE): if anchor in cls.paths: cls.paths.remove(anchor)
[ "def", "pop", "(", "cls", ",", "anchors", ")", ":", "for", "anchor", "in", "flattened", "(", "anchors", ",", "split", "=", "SANITIZED", "|", "UNIQUE", ")", ":", "if", "anchor", "in", "cls", ".", "paths", ":", "cls", ".", "paths", ".", "remove", "("...
Args: anchors (str | unicode | list): Optional paths to use as anchors for short()
[ "Args", ":", "anchors", "(", "str", "|", "unicode", "|", "list", ")", ":", "Optional", "paths", "to", "use", "as", "anchors", "for", "short", "()" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L186-L193
train
Removes an anchor from the set of anchors.
zsimic/runez
src/runez/convert.py
Anchored.short
def short(cls, path): """ Example: short("examined /Users/joe/foo") => "examined ~/foo" Args: path: Path to represent in its short form Returns: (str): Short form, using '~' if applicable """ if not path: return path ...
python
def short(cls, path): """ Example: short("examined /Users/joe/foo") => "examined ~/foo" Args: path: Path to represent in its short form Returns: (str): Short form, using '~' if applicable """ if not path: return path ...
[ "def", "short", "(", "cls", ",", "path", ")", ":", "if", "not", "path", ":", "return", "path", "path", "=", "str", "(", "path", ")", "if", "cls", ".", "paths", ":", "for", "p", "in", "cls", ".", "paths", ":", "if", "p", ":", "path", "=", "pat...
Example: short("examined /Users/joe/foo") => "examined ~/foo" Args: path: Path to represent in its short form Returns: (str): Short form, using '~' if applicable
[ "Example", ":", "short", "(", "examined", "/", "Users", "/", "joe", "/", "foo", ")", "=", ">", "examined", "~", "/", "foo" ]
14363b719a1aae1528859a501a22d075ce0abfcc
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/convert.py#L196-L217
train
Returns the short form of a path.
abantos/bolt
bolt/_btutils.py
add_search_path
def add_search_path(*path_tokens): """ Adds a new search path from where modules can be loaded. This function is provided for test applications to add locations to the search path, so any required functionality can be loaded. It helps keeping the step implementation modules simple by placing the b...
python
def add_search_path(*path_tokens): """ Adds a new search path from where modules can be loaded. This function is provided for test applications to add locations to the search path, so any required functionality can be loaded. It helps keeping the step implementation modules simple by placing the b...
[ "def", "add_search_path", "(", "*", "path_tokens", ")", ":", "full_path", "=", "os", ".", "path", ".", "join", "(", "*", "path_tokens", ")", "if", "full_path", "not", "in", "sys", ".", "path", ":", "sys", ".", "path", ".", "insert", "(", "0", ",", ...
Adds a new search path from where modules can be loaded. This function is provided for test applications to add locations to the search path, so any required functionality can be loaded. It helps keeping the step implementation modules simple by placing the bulk of the implementation in separate utili...
[ "Adds", "a", "new", "search", "path", "from", "where", "modules", "can", "be", "loaded", ".", "This", "function", "is", "provided", "for", "test", "applications", "to", "add", "locations", "to", "the", "search", "path", "so", "any", "required", "functionalit...
8b6a911d4a7b1a6e870748a523c9b2b91997c773
https://github.com/abantos/bolt/blob/8b6a911d4a7b1a6e870748a523c9b2b91997c773/bolt/_btutils.py#L8-L22
train
Adds a new search path from where modules can be loaded.
abantos/bolt
bolt/_btutils.py
load_script
def load_script(filename): """ Loads a python script as a module. This function is provided to allow applications to load a Python module by its file name. :param string filename: Name of the python file to be loaded as a module. :return: A |Python|_ module loaded from the specifi...
python
def load_script(filename): """ Loads a python script as a module. This function is provided to allow applications to load a Python module by its file name. :param string filename: Name of the python file to be loaded as a module. :return: A |Python|_ module loaded from the specifi...
[ "def", "load_script", "(", "filename", ")", ":", "path", ",", "module_name", ",", "ext", "=", "_extract_script_components", "(", "filename", ")", "add_search_path", "(", "path", ")", "return", "_load_module", "(", "module_name", ")" ]
Loads a python script as a module. This function is provided to allow applications to load a Python module by its file name. :param string filename: Name of the python file to be loaded as a module. :return: A |Python|_ module loaded from the specified file.
[ "Loads", "a", "python", "script", "as", "a", "module", "." ]
8b6a911d4a7b1a6e870748a523c9b2b91997c773
https://github.com/abantos/bolt/blob/8b6a911d4a7b1a6e870748a523c9b2b91997c773/bolt/_btutils.py#L26-L40
train
Loads a python script as a module.
potash/drain
drain/util.py
parse_dates
def parse_dates(df, inplace=True, *args, **kwargs): """ Parse all datetime.date and datetime.datetime columns """ if not inplace: df = df.copy() for c in df.columns: i = df[c].first_valid_index() if i is not None and type(df[c].ix[i]) in (date, datetime): df[c] =...
python
def parse_dates(df, inplace=True, *args, **kwargs): """ Parse all datetime.date and datetime.datetime columns """ if not inplace: df = df.copy() for c in df.columns: i = df[c].first_valid_index() if i is not None and type(df[c].ix[i]) in (date, datetime): df[c] =...
[ "def", "parse_dates", "(", "df", ",", "inplace", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "inplace", ":", "df", "=", "df", ".", "copy", "(", ")", "for", "c", "in", "df", ".", "columns", ":", "i", "=", "df...
Parse all datetime.date and datetime.datetime columns
[ "Parse", "all", "datetime", ".", "date", "and", "datetime", ".", "datetime", "columns" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L45-L58
train
Parse all datetime. date and datetime. datetime columns
potash/drain
drain/util.py
get_subdirs
def get_subdirs(directory): """ Returns: a list of subdirectories of the given directory """ return [os.path.join(directory, name) for name in os.listdir(directory) if os.path.isdir(os.path.join(directory, name))]
python
def get_subdirs(directory): """ Returns: a list of subdirectories of the given directory """ return [os.path.join(directory, name) for name in os.listdir(directory) if os.path.isdir(os.path.join(directory, name))]
[ "def", "get_subdirs", "(", "directory", ")", ":", "return", "[", "os", ".", "path", ".", "join", "(", "directory", ",", "name", ")", "for", "name", "in", "os", ".", "listdir", "(", "directory", ")", "if", "os", ".", "path", ".", "isdir", "(", "os",...
Returns: a list of subdirectories of the given directory
[ "Returns", ":", "a", "list", "of", "subdirectories", "of", "the", "given", "directory" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L66-L72
train
Returns a list of subdirectories of the given directory
potash/drain
drain/util.py
to_float
def to_float(*args): """ cast numpy arrays to float32 if there's more than one, return an array """ floats = [np.array(a, dtype=np.float32) for a in args] return floats[0] if len(floats) == 1 else floats
python
def to_float(*args): """ cast numpy arrays to float32 if there's more than one, return an array """ floats = [np.array(a, dtype=np.float32) for a in args] return floats[0] if len(floats) == 1 else floats
[ "def", "to_float", "(", "*", "args", ")", ":", "floats", "=", "[", "np", ".", "array", "(", "a", ",", "dtype", "=", "np", ".", "float32", ")", "for", "a", "in", "args", "]", "return", "floats", "[", "0", "]", "if", "len", "(", "floats", ")", ...
cast numpy arrays to float32 if there's more than one, return an array
[ "cast", "numpy", "arrays", "to", "float32", "if", "there", "s", "more", "than", "one", "return", "an", "array" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L83-L89
train
cast numpy arrays to float32
potash/drain
drain/util.py
get_attr
def get_attr(name): """ get a class or function by name """ i = name.rfind('.') cls = str(name[i+1:]) module = str(name[:i]) mod = __import__(module, fromlist=[cls]) return getattr(mod, cls)
python
def get_attr(name): """ get a class or function by name """ i = name.rfind('.') cls = str(name[i+1:]) module = str(name[:i]) mod = __import__(module, fromlist=[cls]) return getattr(mod, cls)
[ "def", "get_attr", "(", "name", ")", ":", "i", "=", "name", ".", "rfind", "(", "'.'", ")", "cls", "=", "str", "(", "name", "[", "i", "+", "1", ":", "]", ")", "module", "=", "str", "(", "name", "[", ":", "i", "]", ")", "mod", "=", "__import_...
get a class or function by name
[ "get", "a", "class", "or", "function", "by", "name" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L131-L140
train
get a class or function by name
potash/drain
drain/util.py
mode
def mode(series): """ pandas mode is "empty if nothing has 2+ occurrences." this method always returns something: nan if the series is empty/nan), breaking ties arbitrarily """ if series.notnull().sum() == 0: return np.nan else: return series.value_counts().idxmax()
python
def mode(series): """ pandas mode is "empty if nothing has 2+ occurrences." this method always returns something: nan if the series is empty/nan), breaking ties arbitrarily """ if series.notnull().sum() == 0: return np.nan else: return series.value_counts().idxmax()
[ "def", "mode", "(", "series", ")", ":", "if", "series", ".", "notnull", "(", ")", ".", "sum", "(", ")", "==", "0", ":", "return", "np", ".", "nan", "else", ":", "return", "series", ".", "value_counts", "(", ")", ".", "idxmax", "(", ")" ]
pandas mode is "empty if nothing has 2+ occurrences." this method always returns something: nan if the series is empty/nan), breaking ties arbitrarily
[ "pandas", "mode", "is", "empty", "if", "nothing", "has", "2", "+", "occurrences", ".", "this", "method", "always", "returns", "something", ":", "nan", "if", "the", "series", "is", "empty", "/", "nan", ")", "breaking", "ties", "arbitrarily" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L163-L172
train
pandas mode is empty if nothing has 2 + occurrences.
potash/drain
drain/util.py
list_expand
def list_expand(d, prefix=None): """ Recursively expand dictionaries into lists e.g. list_expand({1:{2:[3,4]}, 5:[6]}) == [(1,2,3), (1,2,4), (5,6)] """ if prefix is None: prefix = tuple() for k in d: if isinstance(d, dict): for i in list_expand(d[k], prefix=tuple(chai...
python
def list_expand(d, prefix=None): """ Recursively expand dictionaries into lists e.g. list_expand({1:{2:[3,4]}, 5:[6]}) == [(1,2,3), (1,2,4), (5,6)] """ if prefix is None: prefix = tuple() for k in d: if isinstance(d, dict): for i in list_expand(d[k], prefix=tuple(chai...
[ "def", "list_expand", "(", "d", ",", "prefix", "=", "None", ")", ":", "if", "prefix", "is", "None", ":", "prefix", "=", "tuple", "(", ")", "for", "k", "in", "d", ":", "if", "isinstance", "(", "d", ",", "dict", ")", ":", "for", "i", "in", "list_...
Recursively expand dictionaries into lists e.g. list_expand({1:{2:[3,4]}, 5:[6]}) == [(1,2,3), (1,2,4), (5,6)]
[ "Recursively", "expand", "dictionaries", "into", "lists", "e", ".", "g", ".", "list_expand", "(", "{", "1", ":", "{", "2", ":", "[", "3", "4", "]", "}", "5", ":", "[", "6", "]", "}", ")", "==", "[", "(", "1", "2", "3", ")", "(", "1", "2", ...
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L228-L240
train
Recursively expands a dictionary into lists of lists.
potash/drain
drain/util.py
dict_expand
def dict_expand(d, prefix=None): """ Recursively expand subdictionaries returning dictionary dict_expand({1:{2:3}, 4:5}) = {(1,2):3, 4:5} """ result = {} for k, v in d.items(): if isinstance(v, dict): result.update(dict_expand(v, prefix=k)) else: result[k]...
python
def dict_expand(d, prefix=None): """ Recursively expand subdictionaries returning dictionary dict_expand({1:{2:3}, 4:5}) = {(1,2):3, 4:5} """ result = {} for k, v in d.items(): if isinstance(v, dict): result.update(dict_expand(v, prefix=k)) else: result[k]...
[ "def", "dict_expand", "(", "d", ",", "prefix", "=", "None", ")", ":", "result", "=", "{", "}", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "result", ".", "update", "(", "d...
Recursively expand subdictionaries returning dictionary dict_expand({1:{2:3}, 4:5}) = {(1,2):3, 4:5}
[ "Recursively", "expand", "subdictionaries", "returning", "dictionary", "dict_expand", "(", "{", "1", ":", "{", "2", ":", "3", "}", "4", ":", "5", "}", ")", "=", "{", "(", "1", "2", ")", ":", "3", "4", ":", "5", "}" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L243-L258
train
Recursively expand subdictionaries returning dictionary
potash/drain
drain/util.py
dict_diff
def dict_diff(dicts): """ Subset dictionaries to keys which map to multiple values """ diff_keys = set() for k in union(set(d.keys()) for d in dicts): values = [] for d in dicts: if k not in d: diff_keys.add(k) break else: ...
python
def dict_diff(dicts): """ Subset dictionaries to keys which map to multiple values """ diff_keys = set() for k in union(set(d.keys()) for d in dicts): values = [] for d in dicts: if k not in d: diff_keys.add(k) break else: ...
[ "def", "dict_diff", "(", "dicts", ")", ":", "diff_keys", "=", "set", "(", ")", "for", "k", "in", "union", "(", "set", "(", "d", ".", "keys", "(", ")", ")", "for", "d", "in", "dicts", ")", ":", "values", "=", "[", "]", "for", "d", "in", "dicts...
Subset dictionaries to keys which map to multiple values
[ "Subset", "dictionaries", "to", "keys", "which", "map", "to", "multiple", "values" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L273-L291
train
Returns a list of dicts which are not in the list of dicts.
potash/drain
drain/util.py
dict_product
def dict_product(*d, **kwargs): """ cartesian product of dict whose values are lists Args: d: dictionary to take product of. multiple dictionaries will first be merged by dict_merge kwargs: additional kwargs for convenience Returns: a list of dictionaries with the same...
python
def dict_product(*d, **kwargs): """ cartesian product of dict whose values are lists Args: d: dictionary to take product of. multiple dictionaries will first be merged by dict_merge kwargs: additional kwargs for convenience Returns: a list of dictionaries with the same...
[ "def", "dict_product", "(", "*", "d", ",", "*", "*", "kwargs", ")", ":", "d", "=", "dict", "(", "dict_merge", "(", "*", "d", ")", ",", "*", "*", "kwargs", ")", "holdout", "=", "{", "k", ":", "d", "[", "k", "]", "for", "k", "in", "d", "if", ...
cartesian product of dict whose values are lists Args: d: dictionary to take product of. multiple dictionaries will first be merged by dict_merge kwargs: additional kwargs for convenience Returns: a list of dictionaries with the same keys as d and kwargs
[ "cartesian", "product", "of", "dict", "whose", "values", "are", "lists", "Args", ":", "d", ":", "dictionary", "to", "take", "product", "of", ".", "multiple", "dictionaries", "will", "first", "be", "merged", "by", "dict_merge", "kwargs", ":", "additional", "k...
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L309-L333
train
Returns a list of dicts with the same keys as d and kwargs as kwargs
potash/drain
drain/util.py
dict_update_union
def dict_update_union(d1, d2): """ update a set-valued dictionary when key exists, union sets """ for k in d2: if k in d1: d1[k].update(d2[k]) else: d1[k] = d2[k]
python
def dict_update_union(d1, d2): """ update a set-valued dictionary when key exists, union sets """ for k in d2: if k in d1: d1[k].update(d2[k]) else: d1[k] = d2[k]
[ "def", "dict_update_union", "(", "d1", ",", "d2", ")", ":", "for", "k", "in", "d2", ":", "if", "k", "in", "d1", ":", "d1", "[", "k", "]", ".", "update", "(", "d2", "[", "k", "]", ")", "else", ":", "d1", "[", "k", "]", "=", "d2", "[", "k",...
update a set-valued dictionary when key exists, union sets
[ "update", "a", "set", "-", "valued", "dictionary", "when", "key", "exists", "union", "sets" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L350-L359
train
update a set - valued dictionary d1 when key exists union sets
potash/drain
drain/util.py
indent
def indent(s, n_spaces=2, initial=True): """ Indent all new lines Args: n_spaces: number of spaces to use for indentation initial: whether or not to start with an indent """ i = ' '*n_spaces t = s.replace('\n', '\n%s' % i) if initial: t = i + t return t
python
def indent(s, n_spaces=2, initial=True): """ Indent all new lines Args: n_spaces: number of spaces to use for indentation initial: whether or not to start with an indent """ i = ' '*n_spaces t = s.replace('\n', '\n%s' % i) if initial: t = i + t return t
[ "def", "indent", "(", "s", ",", "n_spaces", "=", "2", ",", "initial", "=", "True", ")", ":", "i", "=", "' '", "*", "n_spaces", "t", "=", "s", ".", "replace", "(", "'\\n'", ",", "'\\n%s'", "%", "i", ")", "if", "initial", ":", "t", "=", "i", "+...
Indent all new lines Args: n_spaces: number of spaces to use for indentation initial: whether or not to start with an indent
[ "Indent", "all", "new", "lines", "Args", ":", "n_spaces", ":", "number", "of", "spaces", "to", "use", "for", "indentation", "initial", ":", "whether", "or", "not", "to", "start", "with", "an", "indent" ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L502-L513
train
Indent all new lines in a string
potash/drain
drain/util.py
is_instance_collection
def is_instance_collection(c, cls): """ Args: c: any object cls: a class or a list/tuple of classes Returns: True if c is a non-empty collection of objects, each of which is an instance of one of the specified classes. """ if not (hasattr(c, '__iter__') and len(c) > 0): ...
python
def is_instance_collection(c, cls): """ Args: c: any object cls: a class or a list/tuple of classes Returns: True if c is a non-empty collection of objects, each of which is an instance of one of the specified classes. """ if not (hasattr(c, '__iter__') and len(c) > 0): ...
[ "def", "is_instance_collection", "(", "c", ",", "cls", ")", ":", "if", "not", "(", "hasattr", "(", "c", ",", "'__iter__'", ")", "and", "len", "(", "c", ")", ">", "0", ")", ":", "# make sure it's iterable and not empty", "return", "False", "cls", "=", "ma...
Args: c: any object cls: a class or a list/tuple of classes Returns: True if c is a non-empty collection of objects, each of which is an instance of one of the specified classes.
[ "Args", ":", "c", ":", "any", "object", "cls", ":", "a", "class", "or", "a", "list", "/", "tuple", "of", "classes", "Returns", ":", "True", "if", "c", "is", "a", "non", "-", "empty", "collection", "of", "objects", "each", "of", "which", "is", "an",...
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L516-L538
train
Checks if a collection of objects is an instance of one of the specified classes.
potash/drain
drain/util.py
PgSQLDatabase.to_sql
def to_sql(self, frame, name, if_exists='fail', index=True, index_label=None, schema=None, chunksize=None, dtype=None, pk=None, prefixes=None, raise_on_error=True): """ Write records stored in a DataFrame to a SQL database. Parameters ---------- fra...
python
def to_sql(self, frame, name, if_exists='fail', index=True, index_label=None, schema=None, chunksize=None, dtype=None, pk=None, prefixes=None, raise_on_error=True): """ Write records stored in a DataFrame to a SQL database. Parameters ---------- fra...
[ "def", "to_sql", "(", "self", ",", "frame", ",", "name", ",", "if_exists", "=", "'fail'", ",", "index", "=", "True", ",", "index_label", "=", "None", ",", "schema", "=", "None", ",", "chunksize", "=", "None", ",", "dtype", "=", "None", ",", "pk", "...
Write records stored in a DataFrame to a SQL database. Parameters ---------- frame : DataFrame name : string Name of SQL table if_exists : {'fail', 'replace', 'append'}, default 'fail' - fail: If table exists, do nothing. - replace: If table e...
[ "Write", "records", "stored", "in", "a", "DataFrame", "to", "a", "SQL", "database", "." ]
ddd62081cb9317beb5d21f86c8b4bb196ca3d222
https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/util.py#L405-L476
train
Write records stored in a DataFrame to a SQL database.
sonic182/libsasscompiler
libsasscompiler/__init__.py
LibSassCompiler.compile_file
def compile_file(self, infile, outfile, outdated=False, force=False): """Process sass file.""" myfile = codecs.open(outfile, 'w', 'utf-8') if settings.DEBUG: myfile.write(sass.compile(filename=infile)) else: myfile.write(sass.compile(filename=infile, ...
python
def compile_file(self, infile, outfile, outdated=False, force=False): """Process sass file.""" myfile = codecs.open(outfile, 'w', 'utf-8') if settings.DEBUG: myfile.write(sass.compile(filename=infile)) else: myfile.write(sass.compile(filename=infile, ...
[ "def", "compile_file", "(", "self", ",", "infile", ",", "outfile", ",", "outdated", "=", "False", ",", "force", "=", "False", ")", ":", "myfile", "=", "codecs", ".", "open", "(", "outfile", ",", "'w'", ",", "'utf-8'", ")", "if", "settings", ".", "DEB...
Process sass file.
[ "Process", "sass", "file", "." ]
067c2324bbed9d22966fe63d87e5b3687510bc26
https://github.com/sonic182/libsasscompiler/blob/067c2324bbed9d22966fe63d87e5b3687510bc26/libsasscompiler/__init__.py#L22-L31
train
Process sass file.
ehansis/ozelot
ozelot/etl/targets.py
ORMTarget.from_task
def from_task(cls, task): """Create a new target representing a task and its parameters Args: task: Task instance to create target for; the task class has to inherit from :class:`ozelot.tasks.TaskBase`. Returns: ozelot.tasks.ORMTarget: a new target insta...
python
def from_task(cls, task): """Create a new target representing a task and its parameters Args: task: Task instance to create target for; the task class has to inherit from :class:`ozelot.tasks.TaskBase`. Returns: ozelot.tasks.ORMTarget: a new target insta...
[ "def", "from_task", "(", "cls", ",", "task", ")", ":", "target", "=", "cls", "(", "name", "=", "task", ".", "get_name", "(", ")", ",", "params", "=", "task", ".", "get_param_string", "(", ")", ")", "return", "target" ]
Create a new target representing a task and its parameters Args: task: Task instance to create target for; the task class has to inherit from :class:`ozelot.tasks.TaskBase`. Returns: ozelot.tasks.ORMTarget: a new target instance
[ "Create", "a", "new", "target", "representing", "a", "task", "and", "its", "parameters" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/targets.py#L21-L34
train
Create a new target representing a task and its parameters
ehansis/ozelot
ozelot/etl/targets.py
ORMTarget._base_query
def _base_query(self, session): """Base query for a target. Args: session: database session to query in """ return session.query(ORMTargetMarker) \ .filter(ORMTargetMarker.name == self.name) \ .filter(ORMTargetMarker.params == self.params)
python
def _base_query(self, session): """Base query for a target. Args: session: database session to query in """ return session.query(ORMTargetMarker) \ .filter(ORMTargetMarker.name == self.name) \ .filter(ORMTargetMarker.params == self.params)
[ "def", "_base_query", "(", "self", ",", "session", ")", ":", "return", "session", ".", "query", "(", "ORMTargetMarker", ")", ".", "filter", "(", "ORMTargetMarker", ".", "name", "==", "self", ".", "name", ")", ".", "filter", "(", "ORMTargetMarker", ".", "...
Base query for a target. Args: session: database session to query in
[ "Base", "query", "for", "a", "target", "." ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/targets.py#L36-L44
train
Base query for a target.
ehansis/ozelot
ozelot/etl/targets.py
ORMTarget.exists
def exists(self): """Check if a target exists This function is called by :mod:`luigi` to check if a task output exists. By default, :mod:`luigi` considers a task as complete if all it targets (outputs) exist. Returns: bool: ``True`` if target exists, ``False`` otherwise ...
python
def exists(self): """Check if a target exists This function is called by :mod:`luigi` to check if a task output exists. By default, :mod:`luigi` considers a task as complete if all it targets (outputs) exist. Returns: bool: ``True`` if target exists, ``False`` otherwise ...
[ "def", "exists", "(", "self", ")", ":", "# get DB connection", "session", "=", "client", ".", "get_client", "(", ")", ".", "create_session", "(", ")", "# query for target existence", "ret", "=", "self", ".", "_base_query", "(", "session", ")", ".", "count", ...
Check if a target exists This function is called by :mod:`luigi` to check if a task output exists. By default, :mod:`luigi` considers a task as complete if all it targets (outputs) exist. Returns: bool: ``True`` if target exists, ``False`` otherwise
[ "Check", "if", "a", "target", "exists" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/targets.py#L46-L63
train
Check if a target exists in the database.
ehansis/ozelot
ozelot/etl/targets.py
ORMTarget.create
def create(self): """Create an instance of the current target in the database If a target with the current name and params already exists, no second instance is created. """ session = client.get_client().create_session() if not self._base_query(session).count() > 0: ...
python
def create(self): """Create an instance of the current target in the database If a target with the current name and params already exists, no second instance is created. """ session = client.get_client().create_session() if not self._base_query(session).count() > 0: ...
[ "def", "create", "(", "self", ")", ":", "session", "=", "client", ".", "get_client", "(", ")", ".", "create_session", "(", ")", "if", "not", "self", ".", "_base_query", "(", "session", ")", ".", "count", "(", ")", ">", "0", ":", "# store a new target i...
Create an instance of the current target in the database If a target with the current name and params already exists, no second instance is created.
[ "Create", "an", "instance", "of", "the", "current", "target", "in", "the", "database" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/targets.py#L65-L79
train
Create an instance of the current target in the database
ehansis/ozelot
ozelot/etl/targets.py
ORMTarget.remove
def remove(self): """Remove a target Raises a ``RuntimeError`` if the target does not exist. """ session = client.get_client().create_session() if not self._base_query(session).count() > 0: session.close() raise RuntimeError("Target does not exist, name=...
python
def remove(self): """Remove a target Raises a ``RuntimeError`` if the target does not exist. """ session = client.get_client().create_session() if not self._base_query(session).count() > 0: session.close() raise RuntimeError("Target does not exist, name=...
[ "def", "remove", "(", "self", ")", ":", "session", "=", "client", ".", "get_client", "(", ")", ".", "create_session", "(", ")", "if", "not", "self", ".", "_base_query", "(", "session", ")", ".", "count", "(", ")", ">", "0", ":", "session", ".", "cl...
Remove a target Raises a ``RuntimeError`` if the target does not exist.
[ "Remove", "a", "target" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/targets.py#L81-L97
train
Removes a target from the database. Raises a RuntimeError if the target does not exist.
dchaplinsky/translit-ua
translitua/translit.py
add_uppercase
def add_uppercase(table): """ Extend the table with uppercase options >>> print("а" in add_uppercase({"а": "a"})) True >>> print(add_uppercase({"а": "a"})["а"] == "a") True >>> print("А" in add_uppercase({"а": "a"})) True >>> print(add_uppercase({"а": "a"})["А"] == "A") True ...
python
def add_uppercase(table): """ Extend the table with uppercase options >>> print("а" in add_uppercase({"а": "a"})) True >>> print(add_uppercase({"а": "a"})["а"] == "a") True >>> print("А" in add_uppercase({"а": "a"})) True >>> print(add_uppercase({"а": "a"})["А"] == "A") True ...
[ "def", "add_uppercase", "(", "table", ")", ":", "orig", "=", "table", ".", "copy", "(", ")", "orig", ".", "update", "(", "dict", "(", "(", "k", ".", "capitalize", "(", ")", ",", "v", ".", "capitalize", "(", ")", ")", "for", "k", ",", "v", "in",...
Extend the table with uppercase options >>> print("а" in add_uppercase({"а": "a"})) True >>> print(add_uppercase({"а": "a"})["а"] == "a") True >>> print("А" in add_uppercase({"а": "a"})) True >>> print(add_uppercase({"а": "a"})["А"] == "A") True >>> print(len(add_uppercase({"а": "a"...
[ "Extend", "the", "table", "with", "uppercase", "options" ]
14e634492c7ce937d77436772fa32d2de5707a9b
https://github.com/dchaplinsky/translit-ua/blob/14e634492c7ce937d77436772fa32d2de5707a9b/translitua/translit.py#L12-L35
train
Extend the table with uppercase options
dchaplinsky/translit-ua
translitua/translit.py
convert_table
def convert_table(table): """ >>> print(1072 in convert_table({"а": "a"})) True >>> print(1073 in convert_table({"а": "a"})) False >>> print(convert_table({"а": "a"})[1072] == "a") True >>> print(len(convert_table({"а": "a"}).keys()) == 1) True """ return dict((ord(k), v) fo...
python
def convert_table(table): """ >>> print(1072 in convert_table({"а": "a"})) True >>> print(1073 in convert_table({"а": "a"})) False >>> print(convert_table({"а": "a"})[1072] == "a") True >>> print(len(convert_table({"а": "a"}).keys()) == 1) True """ return dict((ord(k), v) fo...
[ "def", "convert_table", "(", "table", ")", ":", "return", "dict", "(", "(", "ord", "(", "k", ")", ",", "v", ")", "for", "k", ",", "v", "in", "table", ".", "items", "(", ")", ")" ]
>>> print(1072 in convert_table({"а": "a"})) True >>> print(1073 in convert_table({"а": "a"})) False >>> print(convert_table({"а": "a"})[1072] == "a") True >>> print(len(convert_table({"а": "a"}).keys()) == 1) True
[ ">>>", "print", "(", "1072", "in", "convert_table", "(", "{", "а", ":", "a", "}", "))", "True", ">>>", "print", "(", "1073", "in", "convert_table", "(", "{", "а", ":", "a", "}", "))", "False", ">>>", "print", "(", "convert_table", "(", "{", "а", ...
14e634492c7ce937d77436772fa32d2de5707a9b
https://github.com/dchaplinsky/translit-ua/blob/14e634492c7ce937d77436772fa32d2de5707a9b/translitua/translit.py#L38-L50
train
Convert a table to a sequence of alphabetical characters.
dchaplinsky/translit-ua
translitua/translit.py
translit
def translit(src, table=UkrainianKMU, preserve_case=True): u""" Transliterates given unicode `src` text to transliterated variant according to a given transliteration table. Official ukrainian transliteration is used by default :param src: string to transliterate :type src: str :param table: tr...
python
def translit(src, table=UkrainianKMU, preserve_case=True): u""" Transliterates given unicode `src` text to transliterated variant according to a given transliteration table. Official ukrainian transliteration is used by default :param src: string to transliterate :type src: str :param table: tr...
[ "def", "translit", "(", "src", ",", "table", "=", "UkrainianKMU", ",", "preserve_case", "=", "True", ")", ":", "src", "=", "text_type", "(", "src", ")", "src_is_upper", "=", "src", ".", "isupper", "(", ")", "if", "hasattr", "(", "table", ",", "\"DELETE...
u""" Transliterates given unicode `src` text to transliterated variant according to a given transliteration table. Official ukrainian transliteration is used by default :param src: string to transliterate :type src: str :param table: transliteration table :type table: transliteration table obje...
[ "u", "Transliterates", "given", "unicode", "src", "text", "to", "transliterated", "variant", "according", "to", "a", "given", "transliteration", "table", ".", "Official", "ukrainian", "transliteration", "is", "used", "by", "default" ]
14e634492c7ce937d77436772fa32d2de5707a9b
https://github.com/dchaplinsky/translit-ua/blob/14e634492c7ce937d77436772fa32d2de5707a9b/translitua/translit.py#L1043-L1156
train
u Transliterates given unicode src text to transliterated variant according to a given transliteration table.
ehansis/ozelot
examples/leonardo/leonardo/kvstore/pipeline.py
EntityCreatorMixin.store
def store(self, df, attribute_columns): """Store entities and their attributes Args: df (pandas.DataFrame): data to store (storing appends 'id' and 'type' columns!) attribute_columns (list(str)): list of column labels that define attributes """ # ID start values...
python
def store(self, df, attribute_columns): """Store entities and their attributes Args: df (pandas.DataFrame): data to store (storing appends 'id' and 'type' columns!) attribute_columns (list(str)): list of column labels that define attributes """ # ID start values...
[ "def", "store", "(", "self", ",", "df", ",", "attribute_columns", ")", ":", "# ID start values depend on currently stored entities/attributes!", "entity_id_start", "=", "models", ".", "Entity", ".", "get_max_id", "(", "self", ".", "session", ")", "+", "1", "attribut...
Store entities and their attributes Args: df (pandas.DataFrame): data to store (storing appends 'id' and 'type' columns!) attribute_columns (list(str)): list of column labels that define attributes
[ "Store", "entities", "and", "their", "attributes" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/examples/leonardo/leonardo/kvstore/pipeline.py#L49-L86
train
Store entities and attributes in the database.
ehansis/ozelot
examples/leonardo/leonardo/kvstore/pipeline.py
LoadArtists.run
def run(self): """Load all artists into the database """ df = ArtistsInputData().load() # rename columns df.rename(columns={'artistLabel': 'name', 'genderLabel': 'gender'}, inplace=True) # attribute columns that exist in the...
python
def run(self): """Load all artists into the database """ df = ArtistsInputData().load() # rename columns df.rename(columns={'artistLabel': 'name', 'genderLabel': 'gender'}, inplace=True) # attribute columns that exist in the...
[ "def", "run", "(", "self", ")", ":", "df", "=", "ArtistsInputData", "(", ")", ".", "load", "(", ")", "# rename columns", "df", ".", "rename", "(", "columns", "=", "{", "'artistLabel'", ":", "'name'", ",", "'genderLabel'", ":", "'gender'", "}", ",", "in...
Load all artists into the database
[ "Load", "all", "artists", "into", "the", "database" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/examples/leonardo/leonardo/kvstore/pipeline.py#L97-L118
train
Load all artists into the database and store them into the database
ehansis/ozelot
examples/leonardo/leonardo/kvstore/pipeline.py
LoadPaintings.run
def run(self): """Load all paintings into the database """ df = PaintingsInputData().load() # rename columns df.rename(columns={'paintingLabel': 'name'}, inplace=True) # get artist IDs, map via artist wiki ID artists = models.Entity.query_with_attributes('artis...
python
def run(self): """Load all paintings into the database """ df = PaintingsInputData().load() # rename columns df.rename(columns={'paintingLabel': 'name'}, inplace=True) # get artist IDs, map via artist wiki ID artists = models.Entity.query_with_attributes('artis...
[ "def", "run", "(", "self", ")", ":", "df", "=", "PaintingsInputData", "(", ")", ".", "load", "(", ")", "# rename columns", "df", ".", "rename", "(", "columns", "=", "{", "'paintingLabel'", ":", "'name'", "}", ",", "inplace", "=", "True", ")", "# get ar...
Load all paintings into the database
[ "Load", "all", "paintings", "into", "the", "database" ]
948675e02eb6fca940450f5cb814f53e97159e5b
https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/examples/leonardo/leonardo/kvstore/pipeline.py#L149-L168
train
Load all paintings into the database and store them in the database
ShadowBlip/Neteria
neteria/core.py
serialize_data
def serialize_data(data, compression=False, encryption=False, public_key=None): """Serializes normal Python datatypes into plaintext using json. You may also choose to enable compression and encryption when serializing data to send over the network. Enabling one or both of these options will incur addi...
python
def serialize_data(data, compression=False, encryption=False, public_key=None): """Serializes normal Python datatypes into plaintext using json. You may also choose to enable compression and encryption when serializing data to send over the network. Enabling one or both of these options will incur addi...
[ "def", "serialize_data", "(", "data", ",", "compression", "=", "False", ",", "encryption", "=", "False", ",", "public_key", "=", "None", ")", ":", "message", "=", "json", ".", "dumps", "(", "data", ")", "if", "compression", ":", "message", "=", "zlib", ...
Serializes normal Python datatypes into plaintext using json. You may also choose to enable compression and encryption when serializing data to send over the network. Enabling one or both of these options will incur additional overhead. Args: data (dict): The data to convert into plain text usin...
[ "Serializes", "normal", "Python", "datatypes", "into", "plaintext", "using", "json", "." ]
1a8c976eb2beeca0a5a272a34ac58b2c114495a4
https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/core.py#L44-L76
train
Serializes normal Python datatypes into plaintext using json.