id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
240,300
ironfroggy/django-better-cache
bettercache/objects.py
CacheModel.get
def get(cls, **kwargs): """Get a copy of the type from the cache and reconstruct it.""" data = cls._get(**kwargs) if data is None: new = cls() new.from_miss(**kwargs) return new return cls.deserialize(data)
python
def get(cls, **kwargs): """Get a copy of the type from the cache and reconstruct it.""" data = cls._get(**kwargs) if data is None: new = cls() new.from_miss(**kwargs) return new return cls.deserialize(data)
[ "def", "get", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "data", "=", "cls", ".", "_get", "(", "*", "*", "kwargs", ")", "if", "data", "is", "None", ":", "new", "=", "cls", "(", ")", "new", ".", "from_miss", "(", "*", "*", "kwargs", ")", ...
Get a copy of the type from the cache and reconstruct it.
[ "Get", "a", "copy", "of", "the", "type", "from", "the", "cache", "and", "reconstruct", "it", "." ]
5350e8c646cef1c1ca74eab176f856ddd9eaf5c3
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/objects.py#L144-L152
240,301
ironfroggy/django-better-cache
bettercache/objects.py
CacheModel.get_or_create
def get_or_create(cls, **kwargs): """Get a copy of the type from the cache, or create a new one.""" data = cls._get(**kwargs) if data is None: return cls(**kwargs), True return cls.deserialize(data), False
python
def get_or_create(cls, **kwargs): """Get a copy of the type from the cache, or create a new one.""" data = cls._get(**kwargs) if data is None: return cls(**kwargs), True return cls.deserialize(data), False
[ "def", "get_or_create", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "data", "=", "cls", ".", "_get", "(", "*", "*", "kwargs", ")", "if", "data", "is", "None", ":", "return", "cls", "(", "*", "*", "kwargs", ")", ",", "True", "return", "cls", ...
Get a copy of the type from the cache, or create a new one.
[ "Get", "a", "copy", "of", "the", "type", "from", "the", "cache", "or", "create", "a", "new", "one", "." ]
5350e8c646cef1c1ca74eab176f856ddd9eaf5c3
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/objects.py#L155-L161
240,302
ironfroggy/django-better-cache
bettercache/objects.py
CacheModel.from_miss
def from_miss(self, **kwargs): """Called to initialize an instance when it is not found in the cache. For example, if your CacheModel should pull data from the database to populate the cache, ... def from_miss(self, username): user = User.objects.get(us...
python
def from_miss(self, **kwargs): """Called to initialize an instance when it is not found in the cache. For example, if your CacheModel should pull data from the database to populate the cache, ... def from_miss(self, username): user = User.objects.get(us...
[ "def", "from_miss", "(", "self", ",", "*", "*", "kwargs", ")", ":", "raise", "type", "(", "self", ")", ".", "Missing", "(", "type", "(", "self", ")", "(", "*", "*", "kwargs", ")", ".", "key", "(", ")", ")" ]
Called to initialize an instance when it is not found in the cache. For example, if your CacheModel should pull data from the database to populate the cache, ... def from_miss(self, username): user = User.objects.get(username=username) self.emai...
[ "Called", "to", "initialize", "an", "instance", "when", "it", "is", "not", "found", "in", "the", "cache", "." ]
5350e8c646cef1c1ca74eab176f856ddd9eaf5c3
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/objects.py#L163-L177
240,303
ironfroggy/django-better-cache
bettercache/objects.py
CacheModel.delete
def delete(self): """Deleting any existing copy of this object from the cache.""" key = self._key(self._all_keys()) _cache.delete(key)
python
def delete(self): """Deleting any existing copy of this object from the cache.""" key = self._key(self._all_keys()) _cache.delete(key)
[ "def", "delete", "(", "self", ")", ":", "key", "=", "self", ".", "_key", "(", "self", ".", "_all_keys", "(", ")", ")", "_cache", ".", "delete", "(", "key", ")" ]
Deleting any existing copy of this object from the cache.
[ "Deleting", "any", "existing", "copy", "of", "this", "object", "from", "the", "cache", "." ]
5350e8c646cef1c1ca74eab176f856ddd9eaf5c3
https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/objects.py#L179-L183
240,304
diffeo/yakonfig
yakonfig/merge.py
overlay_config
def overlay_config(base, overlay): '''Overlay one configuration over another. This overlays `overlay` on top of `base` as follows: * If either isn't a dictionary, returns `overlay`. * Any key in `base` not present in `overlay` is present in the result with its original value. * Any key in `o...
python
def overlay_config(base, overlay): '''Overlay one configuration over another. This overlays `overlay` on top of `base` as follows: * If either isn't a dictionary, returns `overlay`. * Any key in `base` not present in `overlay` is present in the result with its original value. * Any key in `o...
[ "def", "overlay_config", "(", "base", ",", "overlay", ")", ":", "if", "not", "isinstance", "(", "base", ",", "collections", ".", "Mapping", ")", ":", "return", "overlay", "if", "not", "isinstance", "(", "overlay", ",", "collections", ".", "Mapping", ")", ...
Overlay one configuration over another. This overlays `overlay` on top of `base` as follows: * If either isn't a dictionary, returns `overlay`. * Any key in `base` not present in `overlay` is present in the result with its original value. * Any key in `overlay` with value :const:`None` is not pr...
[ "Overlay", "one", "configuration", "over", "another", "." ]
412e195da29b4f4fc7b72967c192714a6f5eaeb5
https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/merge.py#L20-L64
240,305
diffeo/yakonfig
yakonfig/merge.py
diff_config
def diff_config(base, target): '''Find the differences between two configurations. This finds a delta configuration from `base` to `target`, such that calling :func:`overlay_config` with `base` and the result of this function yields `target`. This works as follows: * If both are identical (of any...
python
def diff_config(base, target): '''Find the differences between two configurations. This finds a delta configuration from `base` to `target`, such that calling :func:`overlay_config` with `base` and the result of this function yields `target`. This works as follows: * If both are identical (of any...
[ "def", "diff_config", "(", "base", ",", "target", ")", ":", "if", "not", "isinstance", "(", "base", ",", "collections", ".", "Mapping", ")", ":", "if", "base", "==", "target", ":", "return", "{", "}", "return", "target", "if", "not", "isinstance", "(",...
Find the differences between two configurations. This finds a delta configuration from `base` to `target`, such that calling :func:`overlay_config` with `base` and the result of this function yields `target`. This works as follows: * If both are identical (of any type), returns an empty dictionary. ...
[ "Find", "the", "differences", "between", "two", "configurations", "." ]
412e195da29b4f4fc7b72967c192714a6f5eaeb5
https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/merge.py#L67-L110
240,306
harlowja/constructs
constructs/tree.py
pformat
def pformat(tree): """Recursively formats a tree into a nice string representation. Example Input: yahoo = tt.Tree(tt.Node("CEO")) yahoo.root.add(tt.Node("Infra")) yahoo.root[0].add(tt.Node("Boss")) yahoo.root[0][0].add(tt.Node("Me")) yahoo.root.add(tt.Node("Mobile")) yahoo.root.a...
python
def pformat(tree): """Recursively formats a tree into a nice string representation. Example Input: yahoo = tt.Tree(tt.Node("CEO")) yahoo.root.add(tt.Node("Infra")) yahoo.root[0].add(tt.Node("Boss")) yahoo.root[0][0].add(tt.Node("Me")) yahoo.root.add(tt.Node("Mobile")) yahoo.root.a...
[ "def", "pformat", "(", "tree", ")", ":", "if", "tree", ".", "empty", "(", ")", ":", "return", "''", "buf", "=", "six", ".", "StringIO", "(", ")", "for", "line", "in", "_pformat", "(", "tree", ".", "root", ",", "0", ")", ":", "buf", ".", "write"...
Recursively formats a tree into a nice string representation. Example Input: yahoo = tt.Tree(tt.Node("CEO")) yahoo.root.add(tt.Node("Infra")) yahoo.root[0].add(tt.Node("Boss")) yahoo.root[0][0].add(tt.Node("Me")) yahoo.root.add(tt.Node("Mobile")) yahoo.root.add(tt.Node("Mail")) E...
[ "Recursively", "formats", "a", "tree", "into", "a", "nice", "string", "representation", "." ]
53f20a8422bbd56294d5c0161081cb5875511fab
https://github.com/harlowja/constructs/blob/53f20a8422bbd56294d5c0161081cb5875511fab/constructs/tree.py#L172-L196
240,307
harlowja/constructs
constructs/tree.py
Node.path_iter
def path_iter(self, include_self=True): """Yields back the path from this node to the root node.""" if include_self: node = self else: node = self.parent while node is not None: yield node node = node.parent
python
def path_iter(self, include_self=True): """Yields back the path from this node to the root node.""" if include_self: node = self else: node = self.parent while node is not None: yield node node = node.parent
[ "def", "path_iter", "(", "self", ",", "include_self", "=", "True", ")", ":", "if", "include_self", ":", "node", "=", "self", "else", ":", "node", "=", "self", ".", "parent", "while", "node", "is", "not", "None", ":", "yield", "node", "node", "=", "no...
Yields back the path from this node to the root node.
[ "Yields", "back", "the", "path", "from", "this", "node", "to", "the", "root", "node", "." ]
53f20a8422bbd56294d5c0161081cb5875511fab
https://github.com/harlowja/constructs/blob/53f20a8422bbd56294d5c0161081cb5875511fab/constructs/tree.py#L101-L109
240,308
harlowja/constructs
constructs/tree.py
Node.child_count
def child_count(self, only_direct=True): """Returns how many children this node has, either only the direct children of this node or inclusive of all children nodes of this node. """ if not only_direct: count = 0 for _node in self.dfs_iter(): count...
python
def child_count(self, only_direct=True): """Returns how many children this node has, either only the direct children of this node or inclusive of all children nodes of this node. """ if not only_direct: count = 0 for _node in self.dfs_iter(): count...
[ "def", "child_count", "(", "self", ",", "only_direct", "=", "True", ")", ":", "if", "not", "only_direct", ":", "count", "=", "0", "for", "_node", "in", "self", ".", "dfs_iter", "(", ")", ":", "count", "+=", "1", "return", "count", "return", "len", "(...
Returns how many children this node has, either only the direct children of this node or inclusive of all children nodes of this node.
[ "Returns", "how", "many", "children", "this", "node", "has", "either", "only", "the", "direct", "children", "of", "this", "node", "or", "inclusive", "of", "all", "children", "nodes", "of", "this", "node", "." ]
53f20a8422bbd56294d5c0161081cb5875511fab
https://github.com/harlowja/constructs/blob/53f20a8422bbd56294d5c0161081cb5875511fab/constructs/tree.py#L119-L128
240,309
harlowja/constructs
constructs/tree.py
Node.index
def index(self, item): """Finds the child index of a given item, searchs in added order.""" index_at = None for (i, child) in enumerate(self._children): if child.item == item: index_at = i break if index_at is None: raise ValueError...
python
def index(self, item): """Finds the child index of a given item, searchs in added order.""" index_at = None for (i, child) in enumerate(self._children): if child.item == item: index_at = i break if index_at is None: raise ValueError...
[ "def", "index", "(", "self", ",", "item", ")", ":", "index_at", "=", "None", "for", "(", "i", ",", "child", ")", "in", "enumerate", "(", "self", ".", "_children", ")", ":", "if", "child", ".", "item", "==", "item", ":", "index_at", "=", "i", "bre...
Finds the child index of a given item, searchs in added order.
[ "Finds", "the", "child", "index", "of", "a", "given", "item", "searchs", "in", "added", "order", "." ]
53f20a8422bbd56294d5c0161081cb5875511fab
https://github.com/harlowja/constructs/blob/53f20a8422bbd56294d5c0161081cb5875511fab/constructs/tree.py#L135-L144
240,310
mgk/thingamon
thingamon/thing.py
Thing.publish_state
def publish_state(self, state): """Publish thing state to AWS IoT. Args: state (dict): object state. Must be JSON serializable (i.e., not have circular references). """ message = json.dumps({'state': {'reported': state}}) self.client.publish(self.topi...
python
def publish_state(self, state): """Publish thing state to AWS IoT. Args: state (dict): object state. Must be JSON serializable (i.e., not have circular references). """ message = json.dumps({'state': {'reported': state}}) self.client.publish(self.topi...
[ "def", "publish_state", "(", "self", ",", "state", ")", ":", "message", "=", "json", ".", "dumps", "(", "{", "'state'", ":", "{", "'reported'", ":", "state", "}", "}", ")", "self", ".", "client", ".", "publish", "(", "self", ".", "topic", ",", "mes...
Publish thing state to AWS IoT. Args: state (dict): object state. Must be JSON serializable (i.e., not have circular references).
[ "Publish", "thing", "state", "to", "AWS", "IoT", "." ]
3f7d68dc2131c347473af15cd5f7d4b669407c6b
https://github.com/mgk/thingamon/blob/3f7d68dc2131c347473af15cd5f7d4b669407c6b/thingamon/thing.py#L28-L37
240,311
CitrineInformatics/dftparse
dftparse/vasp/eigenval_parser.py
_is_kpoint
def _is_kpoint(line): """Is this line the start of a new k-point block""" # Try to parse the k-point; false otherwise toks = line.split() # k-point header lines have 4 tokens if len(toks) != 4: return False try: # K-points are centered at the origin xs = [float(x) for x ...
python
def _is_kpoint(line): """Is this line the start of a new k-point block""" # Try to parse the k-point; false otherwise toks = line.split() # k-point header lines have 4 tokens if len(toks) != 4: return False try: # K-points are centered at the origin xs = [float(x) for x ...
[ "def", "_is_kpoint", "(", "line", ")", ":", "# Try to parse the k-point; false otherwise", "toks", "=", "line", ".", "split", "(", ")", "# k-point header lines have 4 tokens", "if", "len", "(", "toks", ")", "!=", "4", ":", "return", "False", "try", ":", "# K-poi...
Is this line the start of a new k-point block
[ "Is", "this", "line", "the", "start", "of", "a", "new", "k", "-", "point", "block" ]
53a1bf19945cf1c195d6af9beccb3d1b7f4a4c1d
https://github.com/CitrineInformatics/dftparse/blob/53a1bf19945cf1c195d6af9beccb3d1b7f4a4c1d/dftparse/vasp/eigenval_parser.py#L4-L19
240,312
CitrineInformatics/dftparse
dftparse/vasp/eigenval_parser.py
_parse_kpoint
def _parse_kpoint(line, lines): """Parse the k-point and then continue to iterate over the band energies and occupations""" toks = line.split() kpoint = [float(x) for x in toks[:3]] weight = float(toks[-1]) newline = next(lines) bands_up = [] occ_up = [] bands_down = [] occ_down = [...
python
def _parse_kpoint(line, lines): """Parse the k-point and then continue to iterate over the band energies and occupations""" toks = line.split() kpoint = [float(x) for x in toks[:3]] weight = float(toks[-1]) newline = next(lines) bands_up = [] occ_up = [] bands_down = [] occ_down = [...
[ "def", "_parse_kpoint", "(", "line", ",", "lines", ")", ":", "toks", "=", "line", ".", "split", "(", ")", "kpoint", "=", "[", "float", "(", "x", ")", "for", "x", "in", "toks", "[", ":", "3", "]", "]", "weight", "=", "float", "(", "toks", "[", ...
Parse the k-point and then continue to iterate over the band energies and occupations
[ "Parse", "the", "k", "-", "point", "and", "then", "continue", "to", "iterate", "over", "the", "band", "energies", "and", "occupations" ]
53a1bf19945cf1c195d6af9beccb3d1b7f4a4c1d
https://github.com/CitrineInformatics/dftparse/blob/53a1bf19945cf1c195d6af9beccb3d1b7f4a4c1d/dftparse/vasp/eigenval_parser.py#L22-L71
240,313
Celeo/Pycord
pycord/__init__.py
WebSocketEvent.parse
def parse(cls, op): """Gets the enum for the op code Args: op: value of the op code (will be casted to int) Returns: The enum that matches the op code """ for event in cls: if event.value == int(op): return event retur...
python
def parse(cls, op): """Gets the enum for the op code Args: op: value of the op code (will be casted to int) Returns: The enum that matches the op code """ for event in cls: if event.value == int(op): return event retur...
[ "def", "parse", "(", "cls", ",", "op", ")", ":", "for", "event", "in", "cls", ":", "if", "event", ".", "value", "==", "int", "(", "op", ")", ":", "return", "event", "return", "None" ]
Gets the enum for the op code Args: op: value of the op code (will be casted to int) Returns: The enum that matches the op code
[ "Gets", "the", "enum", "for", "the", "op", "code" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L45-L57
240,314
Celeo/Pycord
pycord/__init__.py
WebSocketKeepAlive.run
def run(self): """Runs the thread This method handles sending the heartbeat to the Discord websocket server, so the connection can remain open and the bot remain online for those commands that require it to be. Args: None """ while self.should_run: ...
python
def run(self): """Runs the thread This method handles sending the heartbeat to the Discord websocket server, so the connection can remain open and the bot remain online for those commands that require it to be. Args: None """ while self.should_run: ...
[ "def", "run", "(", "self", ")", ":", "while", "self", ".", "should_run", ":", "try", ":", "self", ".", "logger", ".", "debug", "(", "'Sending heartbeat, seq '", "+", "last_sequence", ")", "self", ".", "ws", ".", "send", "(", "json", ".", "dumps", "(", ...
Runs the thread This method handles sending the heartbeat to the Discord websocket server, so the connection can remain open and the bot remain online for those commands that require it to be. Args: None
[ "Runs", "the", "thread" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L87-L109
240,315
Celeo/Pycord
pycord/__init__.py
Pycord._setup_logger
def _setup_logger(self, logging_level: int, log_to_console: bool): """Sets up the internal logger Args: logging_level: what logging level to use log_to_console: whether or not to log to the console """ self.logger = logging.getLogger('discord') self.logge...
python
def _setup_logger(self, logging_level: int, log_to_console: bool): """Sets up the internal logger Args: logging_level: what logging level to use log_to_console: whether or not to log to the console """ self.logger = logging.getLogger('discord') self.logge...
[ "def", "_setup_logger", "(", "self", ",", "logging_level", ":", "int", ",", "log_to_console", ":", "bool", ")", ":", "self", ".", "logger", "=", "logging", ".", "getLogger", "(", "'discord'", ")", "self", ".", "logger", ".", "handlers", "=", "[", "]", ...
Sets up the internal logger Args: logging_level: what logging level to use log_to_console: whether or not to log to the console
[ "Sets", "up", "the", "internal", "logger" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L181-L200
240,316
Celeo/Pycord
pycord/__init__.py
Pycord._query
def _query(self, path: str, method: str, data: Dict[str, Any]=None, expected_status: int = 200) \ -> Union[List[Dict[str, Any]], Dict[str, Any], None]: """Make an HTTP request Args: path: the URI path (not including the base url, start with the first uri segment,...
python
def _query(self, path: str, method: str, data: Dict[str, Any]=None, expected_status: int = 200) \ -> Union[List[Dict[str, Any]], Dict[str, Any], None]: """Make an HTTP request Args: path: the URI path (not including the base url, start with the first uri segment,...
[ "def", "_query", "(", "self", ",", "path", ":", "str", ",", "method", ":", "str", ",", "data", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "expected_status", ":", "int", "=", "200", ")", "->", "Union", "[", "List", "[", "Dict", ...
Make an HTTP request Args: path: the URI path (not including the base url, start with the first uri segment, like 'users/...') method: the HTTP method to use (GET, POST, PATCH, ...) data: the data to send as JSON data expected_status: expected HTT...
[ "Make", "an", "HTTP", "request" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L221-L252
240,317
Celeo/Pycord
pycord/__init__.py
Pycord._ws_on_message
def _ws_on_message(self, ws: websocket.WebSocketApp, raw: Union[str, bytes]): """Callback for receiving messages from the websocket connection This method receives ALL events from the websocket connection, some of which are used for the initial authentication flow, some of which are used for ma...
python
def _ws_on_message(self, ws: websocket.WebSocketApp, raw: Union[str, bytes]): """Callback for receiving messages from the websocket connection This method receives ALL events from the websocket connection, some of which are used for the initial authentication flow, some of which are used for ma...
[ "def", "_ws_on_message", "(", "self", ",", "ws", ":", "websocket", ".", "WebSocketApp", ",", "raw", ":", "Union", "[", "str", ",", "bytes", "]", ")", ":", "if", "isinstance", "(", "raw", ",", "bytes", ")", ":", "decoded", "=", "zlib", ".", "decompres...
Callback for receiving messages from the websocket connection This method receives ALL events from the websocket connection, some of which are used for the initial authentication flow, some of which are used for maintaining the connection, some of which are for notifying this client of user sta...
[ "Callback", "for", "receiving", "messages", "from", "the", "websocket", "connection" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L269-L317
240,318
Celeo/Pycord
pycord/__init__.py
Pycord._ws_on_error
def _ws_on_error(self, ws: websocket.WebSocketApp, error: Exception): """Callback for receiving errors from the websocket connection Args: ws: websocket connection error: exception raised """ self.logger.error(f'Got error from websocket connection: {str(error)}')
python
def _ws_on_error(self, ws: websocket.WebSocketApp, error: Exception): """Callback for receiving errors from the websocket connection Args: ws: websocket connection error: exception raised """ self.logger.error(f'Got error from websocket connection: {str(error)}')
[ "def", "_ws_on_error", "(", "self", ",", "ws", ":", "websocket", ".", "WebSocketApp", ",", "error", ":", "Exception", ")", ":", "self", ".", "logger", ".", "error", "(", "f'Got error from websocket connection: {str(error)}'", ")" ]
Callback for receiving errors from the websocket connection Args: ws: websocket connection error: exception raised
[ "Callback", "for", "receiving", "errors", "from", "the", "websocket", "connection" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L319-L326
240,319
Celeo/Pycord
pycord/__init__.py
Pycord._ws_on_close
def _ws_on_close(self, ws: websocket.WebSocketApp): """Callback for closing the websocket connection Args: ws: websocket connection (now closed) """ self.connected = False self.logger.error('Websocket closed') self._reconnect_websocket()
python
def _ws_on_close(self, ws: websocket.WebSocketApp): """Callback for closing the websocket connection Args: ws: websocket connection (now closed) """ self.connected = False self.logger.error('Websocket closed') self._reconnect_websocket()
[ "def", "_ws_on_close", "(", "self", ",", "ws", ":", "websocket", ".", "WebSocketApp", ")", ":", "self", ".", "connected", "=", "False", "self", ".", "logger", ".", "error", "(", "'Websocket closed'", ")", "self", ".", "_reconnect_websocket", "(", ")" ]
Callback for closing the websocket connection Args: ws: websocket connection (now closed)
[ "Callback", "for", "closing", "the", "websocket", "connection" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L328-L336
240,320
Celeo/Pycord
pycord/__init__.py
Pycord._ws_on_open
def _ws_on_open(self, ws: websocket.WebSocketApp): """Callback for sending the initial authentication data This "payload" contains the required data to authenticate this websocket client as a suitable bot connection to the Discord websocket. Args: ws: websocket connection ...
python
def _ws_on_open(self, ws: websocket.WebSocketApp): """Callback for sending the initial authentication data This "payload" contains the required data to authenticate this websocket client as a suitable bot connection to the Discord websocket. Args: ws: websocket connection ...
[ "def", "_ws_on_open", "(", "self", ",", "ws", ":", "websocket", ".", "WebSocketApp", ")", ":", "payload", "=", "{", "'op'", ":", "WebSocketEvent", ".", "IDENTIFY", ".", "value", ",", "'d'", ":", "{", "'token'", ":", "self", ".", "token", ",", "'propert...
Callback for sending the initial authentication data This "payload" contains the required data to authenticate this websocket client as a suitable bot connection to the Discord websocket. Args: ws: websocket connection
[ "Callback", "for", "sending", "the", "initial", "authentication", "data" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L338-L364
240,321
Celeo/Pycord
pycord/__init__.py
Pycord.connect_to_websocket
def connect_to_websocket(self): """Call this method to make the connection to the Discord websocket This method is not blocking, so you'll probably want to call it after initializating your Pycord object, and then move on with your code. When you want to block on just maintaining the we...
python
def connect_to_websocket(self): """Call this method to make the connection to the Discord websocket This method is not blocking, so you'll probably want to call it after initializating your Pycord object, and then move on with your code. When you want to block on just maintaining the we...
[ "def", "connect_to_websocket", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "'Making websocket connection'", ")", "try", ":", "if", "hasattr", "(", "self", ",", "'_ws'", ")", ":", "self", ".", "_ws", ".", "close", "(", ")", "except", ...
Call this method to make the connection to the Discord websocket This method is not blocking, so you'll probably want to call it after initializating your Pycord object, and then move on with your code. When you want to block on just maintaining the websocket connection, then call ``kee...
[ "Call", "this", "method", "to", "make", "the", "connection", "to", "the", "Discord", "websocket" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L374-L399
240,322
Celeo/Pycord
pycord/__init__.py
Pycord.disconnect_from_websocket
def disconnect_from_websocket(self): """Disconnects from the websocket Args: None """ self.logger.warning('Disconnecting from websocket') self.logger.info('Stopping keep alive thread') self._ws_keep_alive.stop() self._ws_keep_alive.join() self...
python
def disconnect_from_websocket(self): """Disconnects from the websocket Args: None """ self.logger.warning('Disconnecting from websocket') self.logger.info('Stopping keep alive thread') self._ws_keep_alive.stop() self._ws_keep_alive.join() self...
[ "def", "disconnect_from_websocket", "(", "self", ")", ":", "self", ".", "logger", ".", "warning", "(", "'Disconnecting from websocket'", ")", "self", ".", "logger", ".", "info", "(", "'Stopping keep alive thread'", ")", "self", ".", "_ws_keep_alive", ".", "stop", ...
Disconnects from the websocket Args: None
[ "Disconnects", "from", "the", "websocket" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L424-L440
240,323
Celeo/Pycord
pycord/__init__.py
Pycord.set_status
def set_status(self, name: str = None): """Updates the bot's status This is used to get the game that the bot is "playing" or to clear it. If you want to set a game, pass a name; if you want to clear it, either call this method without the optional ``name`` parameter or explicitly ...
python
def set_status(self, name: str = None): """Updates the bot's status This is used to get the game that the bot is "playing" or to clear it. If you want to set a game, pass a name; if you want to clear it, either call this method without the optional ``name`` parameter or explicitly ...
[ "def", "set_status", "(", "self", ",", "name", ":", "str", "=", "None", ")", ":", "game", "=", "None", "if", "name", ":", "game", "=", "{", "'name'", ":", "name", "}", "payload", "=", "{", "'op'", ":", "WebSocketEvent", ".", "STATUS_UPDATE", ".", "...
Updates the bot's status This is used to get the game that the bot is "playing" or to clear it. If you want to set a game, pass a name; if you want to clear it, either call this method without the optional ``name`` parameter or explicitly pass ``None``. Args: name: ...
[ "Updates", "the", "bot", "s", "status" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L442-L469
240,324
Celeo/Pycord
pycord/__init__.py
Pycord.get_guild_info
def get_guild_info(self, id: str) -> Dict[str, Any]: """Get a guild's information by its id Args: id: snowflake id of the guild Returns: Dictionary data for the guild API object Example: { "id": "41771983423143937", ...
python
def get_guild_info(self, id: str) -> Dict[str, Any]: """Get a guild's information by its id Args: id: snowflake id of the guild Returns: Dictionary data for the guild API object Example: { "id": "41771983423143937", ...
[ "def", "get_guild_info", "(", "self", ",", "id", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "self", ".", "_query", "(", "f'guilds/{id}'", ",", "'GET'", ")" ]
Get a guild's information by its id Args: id: snowflake id of the guild Returns: Dictionary data for the guild API object Example: { "id": "41771983423143937", "name": "Discord Developers", ...
[ "Get", "a", "guild", "s", "information", "by", "its", "id" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L549-L577
240,325
Celeo/Pycord
pycord/__init__.py
Pycord.get_channels_in
def get_channels_in(self, guild_id: str) -> List[Dict[str, Any]]: """Get a list of channels in the guild Args: guild_id: id of the guild to fetch channels from Returns: List of dictionary objects of channels in the guild. Note the different types of channels...
python
def get_channels_in(self, guild_id: str) -> List[Dict[str, Any]]: """Get a list of channels in the guild Args: guild_id: id of the guild to fetch channels from Returns: List of dictionary objects of channels in the guild. Note the different types of channels...
[ "def", "get_channels_in", "(", "self", ",", "guild_id", ":", "str", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "return", "self", ".", "_query", "(", "f'guilds/{guild_id}/channels'", ",", "'GET'", ")" ]
Get a list of channels in the guild Args: guild_id: id of the guild to fetch channels from Returns: List of dictionary objects of channels in the guild. Note the different types of channels: text, voice, DM, group DM. https://discordapp.com/developers/d...
[ "Get", "a", "list", "of", "channels", "in", "the", "guild" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L579-L628
240,326
Celeo/Pycord
pycord/__init__.py
Pycord.get_channel_info
def get_channel_info(self, id: str) -> Dict[str, Any]: """Get a chanel's information by its id Args: id: snowflake id of the chanel Returns: Dictionary data for the chanel API object Example: { "id": "41771983423143937", ...
python
def get_channel_info(self, id: str) -> Dict[str, Any]: """Get a chanel's information by its id Args: id: snowflake id of the chanel Returns: Dictionary data for the chanel API object Example: { "id": "41771983423143937", ...
[ "def", "get_channel_info", "(", "self", ",", "id", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "self", ".", "_query", "(", "f'channels/{id}'", ",", "'GET'", ")" ]
Get a chanel's information by its id Args: id: snowflake id of the chanel Returns: Dictionary data for the chanel API object Example: { "id": "41771983423143937", "guild_id": "41771983423143937", ...
[ "Get", "a", "chanel", "s", "information", "by", "its", "id" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L630-L651
240,327
Celeo/Pycord
pycord/__init__.py
Pycord.get_guild_members
def get_guild_members(self, guild_id: int) -> List[Dict[str, Any]]: """Get a list of members in the guild Args: guild_id: snowflake id of the guild Returns: List of dictionary objects of users in the guild. Example: [ { ...
python
def get_guild_members(self, guild_id: int) -> List[Dict[str, Any]]: """Get a list of members in the guild Args: guild_id: snowflake id of the guild Returns: List of dictionary objects of users in the guild. Example: [ { ...
[ "def", "get_guild_members", "(", "self", ",", "guild_id", ":", "int", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "return", "self", ".", "_query", "(", "f'guilds/{guild_id}/members'", ",", "'GET'", ")" ]
Get a list of members in the guild Args: guild_id: snowflake id of the guild Returns: List of dictionary objects of users in the guild. Example: [ { "id": "41771983423143937", "name...
[ "Get", "a", "list", "of", "members", "in", "the", "guild" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L653-L700
240,328
Celeo/Pycord
pycord/__init__.py
Pycord.get_guild_member_by_id
def get_guild_member_by_id(self, guild_id: int, member_id: int) -> Dict[str, Any]: """Get a guild member by their id Args: guild_id: snowflake id of the guild member_id: snowflake id of the member Returns: Dictionary data for the guild member. E...
python
def get_guild_member_by_id(self, guild_id: int, member_id: int) -> Dict[str, Any]: """Get a guild member by their id Args: guild_id: snowflake id of the guild member_id: snowflake id of the member Returns: Dictionary data for the guild member. E...
[ "def", "get_guild_member_by_id", "(", "self", ",", "guild_id", ":", "int", ",", "member_id", ":", "int", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "self", ".", "_query", "(", "f'guilds/{guild_id}/members/{member_id}'", ",", "'GET'", ")" ...
Get a guild member by their id Args: guild_id: snowflake id of the guild member_id: snowflake id of the member Returns: Dictionary data for the guild member. Example: { "id": "41771983423143937", "...
[ "Get", "a", "guild", "member", "by", "their", "id" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L702-L735
240,329
Celeo/Pycord
pycord/__init__.py
Pycord.get_all_guild_roles
def get_all_guild_roles(self, guild_id: int) -> List[Dict[str, Any]]: """Gets all the roles for the specified guild Args: guild_id: snowflake id of the guild Returns: List of dictionary objects of roles in the guild. Example: [ ...
python
def get_all_guild_roles(self, guild_id: int) -> List[Dict[str, Any]]: """Gets all the roles for the specified guild Args: guild_id: snowflake id of the guild Returns: List of dictionary objects of roles in the guild. Example: [ ...
[ "def", "get_all_guild_roles", "(", "self", ",", "guild_id", ":", "int", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "return", "self", ".", "_query", "(", "f'guilds/{guild_id}/roles'", ",", "'GET'", ")" ]
Gets all the roles for the specified guild Args: guild_id: snowflake id of the guild Returns: List of dictionary objects of roles in the guild. Example: [ { "id": "41771983423143936", ...
[ "Gets", "all", "the", "roles", "for", "the", "specified", "guild" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L737-L780
240,330
Celeo/Pycord
pycord/__init__.py
Pycord.set_member_roles
def set_member_roles(self, guild_id: int, member_id: int, roles: List[int]): """Set the member's roles This method takes a list of **role ids** that you want the user to have. This method will **overwrite** all of the user's current roles with the roles in the passed list of roles. ...
python
def set_member_roles(self, guild_id: int, member_id: int, roles: List[int]): """Set the member's roles This method takes a list of **role ids** that you want the user to have. This method will **overwrite** all of the user's current roles with the roles in the passed list of roles. ...
[ "def", "set_member_roles", "(", "self", ",", "guild_id", ":", "int", ",", "member_id", ":", "int", ",", "roles", ":", "List", "[", "int", "]", ")", ":", "self", ".", "_query", "(", "f'guilds/{guild_id}/members/{member_id}'", ",", "'PATCH'", ",", "{", "'rol...
Set the member's roles This method takes a list of **role ids** that you want the user to have. This method will **overwrite** all of the user's current roles with the roles in the passed list of roles. When calling this method, be sure that the list of roles that you're setting ...
[ "Set", "the", "member", "s", "roles" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L782-L799
240,331
Celeo/Pycord
pycord/__init__.py
Pycord.command
def command(self, name: str) -> Callable: """Decorator to wrap methods to register them as commands The argument to this method is the command that you want to trigger your callback. If you want users to send "!hello bob" and your method "command_hello" to get called when someone does, ...
python
def command(self, name: str) -> Callable: """Decorator to wrap methods to register them as commands The argument to this method is the command that you want to trigger your callback. If you want users to send "!hello bob" and your method "command_hello" to get called when someone does, ...
[ "def", "command", "(", "self", ",", "name", ":", "str", ")", "->", "Callable", ":", "def", "inner", "(", "f", ":", "Callable", ")", ":", "self", ".", "_commands", ".", "append", "(", "(", "name", ",", "f", ")", ")", "return", "inner" ]
Decorator to wrap methods to register them as commands The argument to this method is the command that you want to trigger your callback. If you want users to send "!hello bob" and your method "command_hello" to get called when someone does, then your setup will look like: @pycord....
[ "Decorator", "to", "wrap", "methods", "to", "register", "them", "as", "commands" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L865-L915
240,332
Celeo/Pycord
pycord/__init__.py
Pycord.register_command
def register_command(self, name: str, f: Callable): """Registers an existing callable object as a command callback This method can be used instead of the ``@command`` decorator. Both do the same thing, but this method is useful for registering callbacks for methods defined before or out...
python
def register_command(self, name: str, f: Callable): """Registers an existing callable object as a command callback This method can be used instead of the ``@command`` decorator. Both do the same thing, but this method is useful for registering callbacks for methods defined before or out...
[ "def", "register_command", "(", "self", ",", "name", ":", "str", ",", "f", ":", "Callable", ")", ":", "self", ".", "_commands", ".", "append", "(", "(", "name", ",", "f", ")", ")" ]
Registers an existing callable object as a command callback This method can be used instead of the ``@command`` decorator. Both do the same thing, but this method is useful for registering callbacks for methods defined before or outside the scope of your bot object, allowing you to defi...
[ "Registers", "an", "existing", "callable", "object", "as", "a", "command", "callback" ]
15c38e39b508c89c35f7f6d7009fe8e9f161a94e
https://github.com/Celeo/Pycord/blob/15c38e39b508c89c35f7f6d7009fe8e9f161a94e/pycord/__init__.py#L917-L942
240,333
GMadorell/abris
abris_transform/parsing/csv_parsing.py
prepare_csv_to_dataframe
def prepare_csv_to_dataframe(data_file, config, use_target=True): """ Parses the given data file following the data model of the given configuration. @return: pandas DataFrame """ names, dtypes = [], [] model = config.get_data_model() for feature in model: assert feature.get_name() n...
python
def prepare_csv_to_dataframe(data_file, config, use_target=True): """ Parses the given data file following the data model of the given configuration. @return: pandas DataFrame """ names, dtypes = [], [] model = config.get_data_model() for feature in model: assert feature.get_name() n...
[ "def", "prepare_csv_to_dataframe", "(", "data_file", ",", "config", ",", "use_target", "=", "True", ")", ":", "names", ",", "dtypes", "=", "[", "]", ",", "[", "]", "model", "=", "config", ".", "get_data_model", "(", ")", "for", "feature", "in", "model", ...
Parses the given data file following the data model of the given configuration. @return: pandas DataFrame
[ "Parses", "the", "given", "data", "file", "following", "the", "data", "model", "of", "the", "given", "configuration", "." ]
0d8ab7ec506835a45fae6935d129f5d7e6937bb2
https://github.com/GMadorell/abris/blob/0d8ab7ec506835a45fae6935d129f5d7e6937bb2/abris_transform/parsing/csv_parsing.py#L4-L20
240,334
sunlightlabs/django-locksmith
locksmith/hub/models.py
Key.mark_for_update
def mark_for_update(self): ''' Note that a change has been made so all Statuses need update ''' self.pub_statuses.exclude(status=UNPUBLISHED).update(status=NEEDS_UPDATE) push_key.delay(self)
python
def mark_for_update(self): ''' Note that a change has been made so all Statuses need update ''' self.pub_statuses.exclude(status=UNPUBLISHED).update(status=NEEDS_UPDATE) push_key.delay(self)
[ "def", "mark_for_update", "(", "self", ")", ":", "self", ".", "pub_statuses", ".", "exclude", "(", "status", "=", "UNPUBLISHED", ")", ".", "update", "(", "status", "=", "NEEDS_UPDATE", ")", "push_key", ".", "delay", "(", "self", ")" ]
Note that a change has been made so all Statuses need update
[ "Note", "that", "a", "change", "has", "been", "made", "so", "all", "Statuses", "need", "update" ]
eef5b7c25404560aaad50b6e622594f89239b74b
https://github.com/sunlightlabs/django-locksmith/blob/eef5b7c25404560aaad50b6e622594f89239b74b/locksmith/hub/models.py#L82-L87
240,335
drongo-framework/drongo
drongo/response.py
Response.set_cookie
def set_cookie(self, key, value, domain=None, path='/', secure=False, httponly=True): """Set a cookie. Args: key (:obj:`str`): Cookie name value (:obj:`str`): Cookie value domain (:obj:`str`): Cookie domain path (:obj:`str`): Cookie val...
python
def set_cookie(self, key, value, domain=None, path='/', secure=False, httponly=True): """Set a cookie. Args: key (:obj:`str`): Cookie name value (:obj:`str`): Cookie value domain (:obj:`str`): Cookie domain path (:obj:`str`): Cookie val...
[ "def", "set_cookie", "(", "self", ",", "key", ",", "value", ",", "domain", "=", "None", ",", "path", "=", "'/'", ",", "secure", "=", "False", ",", "httponly", "=", "True", ")", ":", "self", ".", "_cookies", "[", "key", "]", "=", "value", "if", "d...
Set a cookie. Args: key (:obj:`str`): Cookie name value (:obj:`str`): Cookie value domain (:obj:`str`): Cookie domain path (:obj:`str`): Cookie value secure (:obj:`bool`): True if secure, False otherwise httponly (:obj:`bool`): True if it'...
[ "Set", "a", "cookie", "." ]
487edb370ae329f370bcf3b433ed3f28ba4c1d8c
https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/response.py#L51-L72
240,336
drongo-framework/drongo
drongo/response.py
Response.set_content
def set_content(self, content, content_length=None): """Set content for the response. Args: content (:obj:`str` or :obj:`iterable`): Response content. Can be either unicode or raw bytes. When returning large content, an iterable (or a generator) can be used t...
python
def set_content(self, content, content_length=None): """Set content for the response. Args: content (:obj:`str` or :obj:`iterable`): Response content. Can be either unicode or raw bytes. When returning large content, an iterable (or a generator) can be used t...
[ "def", "set_content", "(", "self", ",", "content", ",", "content_length", "=", "None", ")", ":", "if", "content_length", "is", "not", "None", ":", "self", ".", "_content_length", "=", "content_length", "self", ".", "_content", "=", "content" ]
Set content for the response. Args: content (:obj:`str` or :obj:`iterable`): Response content. Can be either unicode or raw bytes. When returning large content, an iterable (or a generator) can be used to avoid loading entire content into the memory. ...
[ "Set", "content", "for", "the", "response", "." ]
487edb370ae329f370bcf3b433ed3f28ba4c1d8c
https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/response.py#L74-L88
240,337
drongo-framework/drongo
drongo/response.py
Response.bake
def bake(self, start_response): """Bakes the response and returns the content. Args: start_response (:obj:`callable`): Callback method that accepts status code and a list of tuples (pairs) containing headers' key and value respectively. """ if...
python
def bake(self, start_response): """Bakes the response and returns the content. Args: start_response (:obj:`callable`): Callback method that accepts status code and a list of tuples (pairs) containing headers' key and value respectively. """ if...
[ "def", "bake", "(", "self", ",", "start_response", ")", ":", "if", "isinstance", "(", "self", ".", "_content", ",", "six", ".", "text_type", ")", ":", "self", ".", "_content", "=", "self", ".", "_content", ".", "encode", "(", "'utf8'", ")", "if", "se...
Bakes the response and returns the content. Args: start_response (:obj:`callable`): Callback method that accepts status code and a list of tuples (pairs) containing headers' key and value respectively.
[ "Bakes", "the", "response", "and", "returns", "the", "content", "." ]
487edb370ae329f370bcf3b433ed3f28ba4c1d8c
https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/response.py#L90-L117
240,338
drongo-framework/drongo
drongo/response.py
Response.set_redirect
def set_redirect(self, url, status=HttpStatusCodes.HTTP_303): """Helper method to set a redirect response. Args: url (:obj:`str`): URL to redirect to status (:obj:`str`, optional): Status code of the response """ self.set_status(status) self.set_content('...
python
def set_redirect(self, url, status=HttpStatusCodes.HTTP_303): """Helper method to set a redirect response. Args: url (:obj:`str`): URL to redirect to status (:obj:`str`, optional): Status code of the response """ self.set_status(status) self.set_content('...
[ "def", "set_redirect", "(", "self", ",", "url", ",", "status", "=", "HttpStatusCodes", ".", "HTTP_303", ")", ":", "self", ".", "set_status", "(", "status", ")", "self", ".", "set_content", "(", "''", ")", "self", ".", "set_header", "(", "HttpResponseHeader...
Helper method to set a redirect response. Args: url (:obj:`str`): URL to redirect to status (:obj:`str`, optional): Status code of the response
[ "Helper", "method", "to", "set", "a", "redirect", "response", "." ]
487edb370ae329f370bcf3b433ed3f28ba4c1d8c
https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/response.py#L120-L129
240,339
drongo-framework/drongo
drongo/response.py
Response.set_json
def set_json(self, obj, status=HttpStatusCodes.HTTP_200): """Helper method to set a JSON response. Args: obj (:obj:`object`): JSON serializable object status (:obj:`str`, optional): Status code of the response """ obj = json.dumps(obj, sort_keys=True, default=lam...
python
def set_json(self, obj, status=HttpStatusCodes.HTTP_200): """Helper method to set a JSON response. Args: obj (:obj:`object`): JSON serializable object status (:obj:`str`, optional): Status code of the response """ obj = json.dumps(obj, sort_keys=True, default=lam...
[ "def", "set_json", "(", "self", ",", "obj", ",", "status", "=", "HttpStatusCodes", ".", "HTTP_200", ")", ":", "obj", "=", "json", ".", "dumps", "(", "obj", ",", "sort_keys", "=", "True", ",", "default", "=", "lambda", "x", ":", "str", "(", "x", ")"...
Helper method to set a JSON response. Args: obj (:obj:`object`): JSON serializable object status (:obj:`str`, optional): Status code of the response
[ "Helper", "method", "to", "set", "a", "JSON", "response", "." ]
487edb370ae329f370bcf3b433ed3f28ba4c1d8c
https://github.com/drongo-framework/drongo/blob/487edb370ae329f370bcf3b433ed3f28ba4c1d8c/drongo/response.py#L131-L141
240,340
Huong-nt/flask-rak
flask_rak/core.py
find_rak
def find_rak(): """ Find our instance of Rak, navigating Local's and possible blueprints. """ if hasattr(current_app, 'rak'): return getattr(current_app, 'rak') else: if hasattr(current_app, 'blueprints'): blueprints = getattr(current_app, 'blueprints') for bl...
python
def find_rak(): """ Find our instance of Rak, navigating Local's and possible blueprints. """ if hasattr(current_app, 'rak'): return getattr(current_app, 'rak') else: if hasattr(current_app, 'blueprints'): blueprints = getattr(current_app, 'blueprints') for bl...
[ "def", "find_rak", "(", ")", ":", "if", "hasattr", "(", "current_app", ",", "'rak'", ")", ":", "return", "getattr", "(", "current_app", ",", "'rak'", ")", "else", ":", "if", "hasattr", "(", "current_app", ",", "'blueprints'", ")", ":", "blueprints", "=",...
Find our instance of Rak, navigating Local's and possible blueprints.
[ "Find", "our", "instance", "of", "Rak", "navigating", "Local", "s", "and", "possible", "blueprints", "." ]
ffe16b0fc3d49e83c1d220c445ce14632219f69d
https://github.com/Huong-nt/flask-rak/blob/ffe16b0fc3d49e83c1d220c445ce14632219f69d/flask_rak/core.py#L29-L40
240,341
Huong-nt/flask-rak
flask_rak/core.py
RAK.intent
def intent(self, intent_name): """Decorator routes an Rogo IntentRequest. Functions decorated as an intent are registered as the view function for the Intent's URL, and provide the backend responses to give your Skill its functionality. @ask.intent('WeatherIntent') def weather(ci...
python
def intent(self, intent_name): """Decorator routes an Rogo IntentRequest. Functions decorated as an intent are registered as the view function for the Intent's URL, and provide the backend responses to give your Skill its functionality. @ask.intent('WeatherIntent') def weather(ci...
[ "def", "intent", "(", "self", ",", "intent_name", ")", ":", "def", "decorator", "(", "f", ")", ":", "self", ".", "_intent_view_funcs", "[", "intent_name", "]", "=", "f", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*"...
Decorator routes an Rogo IntentRequest. Functions decorated as an intent are registered as the view function for the Intent's URL, and provide the backend responses to give your Skill its functionality. @ask.intent('WeatherIntent') def weather(city): return statement('I predi...
[ "Decorator", "routes", "an", "Rogo", "IntentRequest", ".", "Functions", "decorated", "as", "an", "intent", "are", "registered", "as", "the", "view", "function", "for", "the", "Intent", "s", "URL", "and", "provide", "the", "backend", "responses", "to", "give", ...
ffe16b0fc3d49e83c1d220c445ce14632219f69d
https://github.com/Huong-nt/flask-rak/blob/ffe16b0fc3d49e83c1d220c445ce14632219f69d/flask_rak/core.py#L155-L172
240,342
emin63/eyap
eyap/core/comments.py
SingleComment.make_anchor_id
def make_anchor_id(self): """Return string to use as URL anchor for this comment. """ result = re.sub( '[^a-zA-Z0-9_]', '_', self.user + '_' + self.timestamp) return result
python
def make_anchor_id(self): """Return string to use as URL anchor for this comment. """ result = re.sub( '[^a-zA-Z0-9_]', '_', self.user + '_' + self.timestamp) return result
[ "def", "make_anchor_id", "(", "self", ")", ":", "result", "=", "re", ".", "sub", "(", "'[^a-zA-Z0-9_]'", ",", "'_'", ",", "self", ".", "user", "+", "'_'", "+", "self", ".", "timestamp", ")", "return", "result" ]
Return string to use as URL anchor for this comment.
[ "Return", "string", "to", "use", "as", "URL", "anchor", "for", "this", "comment", "." ]
a610761973b478ca0e864e970be05ce29d5994a5
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/comments.py#L60-L65
240,343
emin63/eyap
eyap/core/comments.py
SingleComment.make_url
def make_url(self, my_request, anchor_id=None): """Make URL to this comment. :arg my_request: The request object where this comment is seen from. :arg anchor_id=None: Optional anchor id. If None, we use self.make_anchor_id() ~-~-~-~-~-~-~-~-~-~-~-~-...
python
def make_url(self, my_request, anchor_id=None): """Make URL to this comment. :arg my_request: The request object where this comment is seen from. :arg anchor_id=None: Optional anchor id. If None, we use self.make_anchor_id() ~-~-~-~-~-~-~-~-~-~-~-~-...
[ "def", "make_url", "(", "self", ",", "my_request", ",", "anchor_id", "=", "None", ")", ":", "if", "anchor_id", "is", "None", ":", "anchor_id", "=", "self", ".", "make_anchor_id", "(", ")", "result", "=", "'{}?{}#{}'", ".", "format", "(", "my_request", "....
Make URL to this comment. :arg my_request: The request object where this comment is seen from. :arg anchor_id=None: Optional anchor id. If None, we use self.make_anchor_id() ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- :returns: Str...
[ "Make", "URL", "to", "this", "comment", "." ]
a610761973b478ca0e864e970be05ce29d5994a5
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/comments.py#L67-L90
240,344
emin63/eyap
eyap/core/comments.py
SingleComment.to_dict
def to_dict(self): """Return description of self in dict format. This is useful for serializing to something like json later. """ jdict = { 'user': self.user, 'summary': self.summary, 'body': self.body, 'markup': self.markup, '...
python
def to_dict(self): """Return description of self in dict format. This is useful for serializing to something like json later. """ jdict = { 'user': self.user, 'summary': self.summary, 'body': self.body, 'markup': self.markup, '...
[ "def", "to_dict", "(", "self", ")", ":", "jdict", "=", "{", "'user'", ":", "self", ".", "user", ",", "'summary'", ":", "self", ".", "summary", ",", "'body'", ":", "self", ".", "body", ",", "'markup'", ":", "self", ".", "markup", ",", "'url'", ":", ...
Return description of self in dict format. This is useful for serializing to something like json later.
[ "Return", "description", "of", "self", "in", "dict", "format", "." ]
a610761973b478ca0e864e970be05ce29d5994a5
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/comments.py#L92-L105
240,345
emin63/eyap
eyap/core/comments.py
SingleComment.set_display_mode
def set_display_mode(self, mytz, fmt): """Set the display mode for self. :arg mytz: A pytz.timezone object. :arg fmt: A format string for strftime. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- PURPOSE: Modifies self.display_timestamp to first p...
python
def set_display_mode(self, mytz, fmt): """Set the display mode for self. :arg mytz: A pytz.timezone object. :arg fmt: A format string for strftime. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- PURPOSE: Modifies self.display_timestamp to first p...
[ "def", "set_display_mode", "(", "self", ",", "mytz", ",", "fmt", ")", ":", "my_stamp", "=", "dateutil", ".", "parser", ".", "parse", "(", "self", ".", "timestamp", ")", "tz_stamp", "=", "my_stamp", ".", "astimezone", "(", "mytz", ")", "if", "my_stamp", ...
Set the display mode for self. :arg mytz: A pytz.timezone object. :arg fmt: A format string for strftime. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- PURPOSE: Modifies self.display_timestamp to first parse self.timestamp and th...
[ "Set", "the", "display", "mode", "for", "self", "." ]
a610761973b478ca0e864e970be05ce29d5994a5
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/comments.py#L107-L124
240,346
emin63/eyap
eyap/core/comments.py
CommentThread.get_comment_section
def get_comment_section(self, force_reload=False, reverse=False): """Get CommentSection instance representing all comments for thread. :arg force_reload=False: Whether to force reloading comments directly or allow using what is cached ...
python
def get_comment_section(self, force_reload=False, reverse=False): """Get CommentSection instance representing all comments for thread. :arg force_reload=False: Whether to force reloading comments directly or allow using what is cached ...
[ "def", "get_comment_section", "(", "self", ",", "force_reload", "=", "False", ",", "reverse", "=", "False", ")", ":", "if", "self", ".", "content", "is", "not", "None", "and", "not", "force_reload", ":", "return", "self", ".", "content", "if", "self", "....
Get CommentSection instance representing all comments for thread. :arg force_reload=False: Whether to force reloading comments directly or allow using what is cached in self.content if possible. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-...
[ "Get", "CommentSection", "instance", "representing", "all", "comments", "for", "thread", "." ]
a610761973b478ca0e864e970be05ce29d5994a5
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/comments.py#L318-L340
240,347
emin63/eyap
eyap/core/comments.py
CommentThread.validate_attachment_location
def validate_attachment_location(self, location): """Validate a proposed attachment location. :arg location: String representing location to put attachment. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- PURPOSE: Raises an exception if attachment location is bad. ...
python
def validate_attachment_location(self, location): """Validate a proposed attachment location. :arg location: String representing location to put attachment. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- PURPOSE: Raises an exception if attachment location is bad. ...
[ "def", "validate_attachment_location", "(", "self", ",", "location", ")", ":", "if", "not", "re", ".", "compile", "(", "self", ".", "valid_attachment_loc_re", ")", ".", "match", "(", "location", ")", ":", "raise", "ValueError", "(", "'Bad chars in attachment loc...
Validate a proposed attachment location. :arg location: String representing location to put attachment. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- PURPOSE: Raises an exception if attachment location is bad. By default, this just forces reasonable character...
[ "Validate", "a", "proposed", "attachment", "location", "." ]
a610761973b478ca0e864e970be05ce29d5994a5
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/comments.py#L342-L357
240,348
emin63/eyap
eyap/core/comments.py
FileCommentThread.lookup_thread_id
def lookup_thread_id(self): "Lookup the thread id as path to comment file." path = os.path.join(self.realm, self.topic + '.csv') return path
python
def lookup_thread_id(self): "Lookup the thread id as path to comment file." path = os.path.join(self.realm, self.topic + '.csv') return path
[ "def", "lookup_thread_id", "(", "self", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "realm", ",", "self", ".", "topic", "+", "'.csv'", ")", "return", "path" ]
Lookup the thread id as path to comment file.
[ "Lookup", "the", "thread", "id", "as", "path", "to", "comment", "file", "." ]
a610761973b478ca0e864e970be05ce29d5994a5
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/comments.py#L398-L402
240,349
emin63/eyap
eyap/core/comments.py
FileCommentThread.lookup_comments
def lookup_comments(self, reverse=False): "Implement as required by parent to lookup comments in file system." comments = [] if self.thread_id is None: self.thread_id = self.lookup_thread_id() path = self.thread_id with open(self.thread_id, 'r', newline='') as fdesc:...
python
def lookup_comments(self, reverse=False): "Implement as required by parent to lookup comments in file system." comments = [] if self.thread_id is None: self.thread_id = self.lookup_thread_id() path = self.thread_id with open(self.thread_id, 'r', newline='') as fdesc:...
[ "def", "lookup_comments", "(", "self", ",", "reverse", "=", "False", ")", ":", "comments", "=", "[", "]", "if", "self", ".", "thread_id", "is", "None", ":", "self", ".", "thread_id", "=", "self", ".", "lookup_thread_id", "(", ")", "path", "=", "self", ...
Implement as required by parent to lookup comments in file system.
[ "Implement", "as", "required", "by", "parent", "to", "lookup", "comments", "in", "file", "system", "." ]
a610761973b478ca0e864e970be05ce29d5994a5
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/comments.py#L404-L425
240,350
emin63/eyap
eyap/core/comments.py
FileCommentThread.create_thread
def create_thread(self, body): """Implement create_thread as required by parent. This basically just calls add_comment with allow_create=True and then builds a response object to indicate everything is fine. """ self.add_comment(body, allow_create=True) the_response = Re...
python
def create_thread(self, body): """Implement create_thread as required by parent. This basically just calls add_comment with allow_create=True and then builds a response object to indicate everything is fine. """ self.add_comment(body, allow_create=True) the_response = Re...
[ "def", "create_thread", "(", "self", ",", "body", ")", ":", "self", ".", "add_comment", "(", "body", ",", "allow_create", "=", "True", ")", "the_response", "=", "Response", "(", ")", "the_response", ".", "code", "=", "\"OK\"", "the_response", ".", "status_...
Implement create_thread as required by parent. This basically just calls add_comment with allow_create=True and then builds a response object to indicate everything is fine.
[ "Implement", "create_thread", "as", "required", "by", "parent", "." ]
a610761973b478ca0e864e970be05ce29d5994a5
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/comments.py#L427-L436
240,351
emin63/eyap
eyap/core/comments.py
FileCommentThread.add_comment
def add_comment(self, body, allow_create=False, allow_hashes=False, summary=None): "Implement as required by parent to store comment in CSV file." if allow_hashes: raise ValueError('allow_hashes not implemented for %s yet' % ( self.__class__.__name__)) ...
python
def add_comment(self, body, allow_create=False, allow_hashes=False, summary=None): "Implement as required by parent to store comment in CSV file." if allow_hashes: raise ValueError('allow_hashes not implemented for %s yet' % ( self.__class__.__name__)) ...
[ "def", "add_comment", "(", "self", ",", "body", ",", "allow_create", "=", "False", ",", "allow_hashes", "=", "False", ",", "summary", "=", "None", ")", ":", "if", "allow_hashes", ":", "raise", "ValueError", "(", "'allow_hashes not implemented for %s yet'", "%", ...
Implement as required by parent to store comment in CSV file.
[ "Implement", "as", "required", "by", "parent", "to", "store", "comment", "in", "CSV", "file", "." ]
a610761973b478ca0e864e970be05ce29d5994a5
https://github.com/emin63/eyap/blob/a610761973b478ca0e864e970be05ce29d5994a5/eyap/core/comments.py#L438-L456
240,352
wushuyi/wsy_captcha
wsy_captcha/bezier.py
pascal_row
def pascal_row(n): """ Returns n-th row of Pascal's triangle """ result = [1] x, numerator = 1, n for denominator in range(1, n // 2 + 1): x *= numerator x /= denominator result.append(x) numerator -= 1 if n & 1 == 0: result.extend(reversed(result[:-1])) ...
python
def pascal_row(n): """ Returns n-th row of Pascal's triangle """ result = [1] x, numerator = 1, n for denominator in range(1, n // 2 + 1): x *= numerator x /= denominator result.append(x) numerator -= 1 if n & 1 == 0: result.extend(reversed(result[:-1])) ...
[ "def", "pascal_row", "(", "n", ")", ":", "result", "=", "[", "1", "]", "x", ",", "numerator", "=", "1", ",", "n", "for", "denominator", "in", "range", "(", "1", ",", "n", "//", "2", "+", "1", ")", ":", "x", "*=", "numerator", "x", "/=", "deno...
Returns n-th row of Pascal's triangle
[ "Returns", "n", "-", "th", "row", "of", "Pascal", "s", "triangle" ]
eeb8fd8b8d37c3550903a83339109e064da45d89
https://github.com/wushuyi/wsy_captcha/blob/eeb8fd8b8d37c3550903a83339109e064da45d89/wsy_captcha/bezier.py#L11-L25
240,353
edelbluth/blackred
src/blackred/blackred.py
create_salt
def create_salt(length: int=128) -> bytes: """ Create a new salt :param int length: How many bytes should the salt be long? :return: The salt :rtype: bytes """ return b''.join(bytes([SystemRandom().randint(0, 255)]) for _ in range(length))
python
def create_salt(length: int=128) -> bytes: """ Create a new salt :param int length: How many bytes should the salt be long? :return: The salt :rtype: bytes """ return b''.join(bytes([SystemRandom().randint(0, 255)]) for _ in range(length))
[ "def", "create_salt", "(", "length", ":", "int", "=", "128", ")", "->", "bytes", ":", "return", "b''", ".", "join", "(", "bytes", "(", "[", "SystemRandom", "(", ")", ".", "randint", "(", "0", ",", "255", ")", "]", ")", "for", "_", "in", "range", ...
Create a new salt :param int length: How many bytes should the salt be long? :return: The salt :rtype: bytes
[ "Create", "a", "new", "salt" ]
57a655e4d4eca60ce16e7b338079355049a87b49
https://github.com/edelbluth/blackred/blob/57a655e4d4eca60ce16e7b338079355049a87b49/src/blackred/blackred.py#L28-L36
240,354
edelbluth/blackred
src/blackred/blackred.py
BlackRed.__get_connection
def __get_connection(self) -> redis.Redis: """ Get a Redis connection :return: Redis connection instance :rtype: redis.Redis """ if self.__redis_use_socket: r = redis.from_url( 'unix://{:s}?db={:d}'.format( self.__redis_ho...
python
def __get_connection(self) -> redis.Redis: """ Get a Redis connection :return: Redis connection instance :rtype: redis.Redis """ if self.__redis_use_socket: r = redis.from_url( 'unix://{:s}?db={:d}'.format( self.__redis_ho...
[ "def", "__get_connection", "(", "self", ")", "->", "redis", ".", "Redis", ":", "if", "self", ".", "__redis_use_socket", ":", "r", "=", "redis", ".", "from_url", "(", "'unix://{:s}?db={:d}'", ".", "format", "(", "self", ".", "__redis_host", ",", "self", "."...
Get a Redis connection :return: Redis connection instance :rtype: redis.Redis
[ "Get", "a", "Redis", "connection" ]
57a655e4d4eca60ce16e7b338079355049a87b49
https://github.com/edelbluth/blackred/blob/57a655e4d4eca60ce16e7b338079355049a87b49/src/blackred/blackred.py#L208-L234
240,355
edelbluth/blackred
src/blackred/blackred.py
BlackRed._encode_item
def _encode_item(self, item: str) -> str: """ If anonymization is on, an item gets salted and hashed here. :param str item: :return: Hashed item, if anonymization is on; the unmodified item otherwise :rtype: str """ assert item is not None if not self.__r...
python
def _encode_item(self, item: str) -> str: """ If anonymization is on, an item gets salted and hashed here. :param str item: :return: Hashed item, if anonymization is on; the unmodified item otherwise :rtype: str """ assert item is not None if not self.__r...
[ "def", "_encode_item", "(", "self", ",", "item", ":", "str", ")", "->", "str", ":", "assert", "item", "is", "not", "None", "if", "not", "self", ".", "__redis_conf", "[", "'anonymization'", "]", ":", "return", "item", "connection", "=", "self", ".", "__...
If anonymization is on, an item gets salted and hashed here. :param str item: :return: Hashed item, if anonymization is on; the unmodified item otherwise :rtype: str
[ "If", "anonymization", "is", "on", "an", "item", "gets", "salted", "and", "hashed", "here", "." ]
57a655e4d4eca60ce16e7b338079355049a87b49
https://github.com/edelbluth/blackred/blob/57a655e4d4eca60ce16e7b338079355049a87b49/src/blackred/blackred.py#L245-L262
240,356
edelbluth/blackred
src/blackred/blackred.py
BlackRed.__get_ttl
def __get_ttl(self, item: str) -> int: """ Get the amount of time a specific item will remain in the database. :param str item: The item to get the TTL for :return: Time in seconds. Returns None for a non-existing element. :rtype: int """ connection = self.__get_...
python
def __get_ttl(self, item: str) -> int: """ Get the amount of time a specific item will remain in the database. :param str item: The item to get the TTL for :return: Time in seconds. Returns None for a non-existing element. :rtype: int """ connection = self.__get_...
[ "def", "__get_ttl", "(", "self", ",", "item", ":", "str", ")", "->", "int", ":", "connection", "=", "self", ".", "__get_connection", "(", ")", "ttl", "=", "connection", ".", "ttl", "(", "item", ")", "BlackRed", ".", "__release_connection", "(", "connecti...
Get the amount of time a specific item will remain in the database. :param str item: The item to get the TTL for :return: Time in seconds. Returns None for a non-existing element. :rtype: int
[ "Get", "the", "amount", "of", "time", "a", "specific", "item", "will", "remain", "in", "the", "database", "." ]
57a655e4d4eca60ce16e7b338079355049a87b49
https://github.com/edelbluth/blackred/blob/57a655e4d4eca60ce16e7b338079355049a87b49/src/blackred/blackred.py#L264-L275
240,357
edelbluth/blackred
src/blackred/blackred.py
BlackRed.get_watchlist_ttl
def get_watchlist_ttl(self, item: str) -> int: """ Get the amount of time a specific item will remain on the watchlist. :param str item: The item to get the TTL for on the watchlist :return: Time in seconds. Returns None for a non-existing element :rtype: int """ ...
python
def get_watchlist_ttl(self, item: str) -> int: """ Get the amount of time a specific item will remain on the watchlist. :param str item: The item to get the TTL for on the watchlist :return: Time in seconds. Returns None for a non-existing element :rtype: int """ ...
[ "def", "get_watchlist_ttl", "(", "self", ",", "item", ":", "str", ")", "->", "int", ":", "assert", "item", "is", "not", "None", "item", "=", "self", ".", "_encode_item", "(", "item", ")", "return", "self", ".", "__get_ttl", "(", "self", ".", "__redis_c...
Get the amount of time a specific item will remain on the watchlist. :param str item: The item to get the TTL for on the watchlist :return: Time in seconds. Returns None for a non-existing element :rtype: int
[ "Get", "the", "amount", "of", "time", "a", "specific", "item", "will", "remain", "on", "the", "watchlist", "." ]
57a655e4d4eca60ce16e7b338079355049a87b49
https://github.com/edelbluth/blackred/blob/57a655e4d4eca60ce16e7b338079355049a87b49/src/blackred/blackred.py#L289-L299
240,358
edelbluth/blackred
src/blackred/blackred.py
BlackRed.is_not_blocked
def is_not_blocked(self, item: str) -> bool: """ Check if an item is _not_ already on the blacklist :param str item: The item to check :return: True, when the item is _not_ on the blacklist :rtype: bool """ assert item is not None item = self._encode_item...
python
def is_not_blocked(self, item: str) -> bool: """ Check if an item is _not_ already on the blacklist :param str item: The item to check :return: True, when the item is _not_ on the blacklist :rtype: bool """ assert item is not None item = self._encode_item...
[ "def", "is_not_blocked", "(", "self", ",", "item", ":", "str", ")", "->", "bool", ":", "assert", "item", "is", "not", "None", "item", "=", "self", ".", "_encode_item", "(", "item", ")", "connection", "=", "self", ".", "__get_connection", "(", ")", "key...
Check if an item is _not_ already on the blacklist :param str item: The item to check :return: True, when the item is _not_ on the blacklist :rtype: bool
[ "Check", "if", "an", "item", "is", "_not_", "already", "on", "the", "blacklist" ]
57a655e4d4eca60ce16e7b338079355049a87b49
https://github.com/edelbluth/blackred/blob/57a655e4d4eca60ce16e7b338079355049a87b49/src/blackred/blackred.py#L301-L320
240,359
edelbluth/blackred
src/blackred/blackred.py
BlackRed.log_fail
def log_fail(self, item: str) -> None: """ Log a failed action for an item. If the fail count for this item reaches the threshold, the item is moved to the blacklist. :param str item: The item to log """ assert item is not None item = self._encode_item(item) ...
python
def log_fail(self, item: str) -> None: """ Log a failed action for an item. If the fail count for this item reaches the threshold, the item is moved to the blacklist. :param str item: The item to log """ assert item is not None item = self._encode_item(item) ...
[ "def", "log_fail", "(", "self", ",", "item", ":", "str", ")", "->", "None", ":", "assert", "item", "is", "not", "None", "item", "=", "self", ".", "_encode_item", "(", "item", ")", "if", "self", ".", "is_blocked", "(", "item", ")", ":", "return", "c...
Log a failed action for an item. If the fail count for this item reaches the threshold, the item is moved to the blacklist. :param str item: The item to log
[ "Log", "a", "failed", "action", "for", "an", "item", ".", "If", "the", "fail", "count", "for", "this", "item", "reaches", "the", "threshold", "the", "item", "is", "moved", "to", "the", "blacklist", "." ]
57a655e4d4eca60ce16e7b338079355049a87b49
https://github.com/edelbluth/blackred/blob/57a655e4d4eca60ce16e7b338079355049a87b49/src/blackred/blackred.py#L332-L358
240,360
kblin/aio-standalone
aiostandalone/app.py
StandaloneApplication.start_task
def start_task(self, func): """Start up a task""" task = self.loop.create_task(func(self)) self._started_tasks.append(task) def done_callback(done_task): self._started_tasks.remove(done_task) task.add_done_callback(done_callback) return task
python
def start_task(self, func): """Start up a task""" task = self.loop.create_task(func(self)) self._started_tasks.append(task) def done_callback(done_task): self._started_tasks.remove(done_task) task.add_done_callback(done_callback) return task
[ "def", "start_task", "(", "self", ",", "func", ")", ":", "task", "=", "self", ".", "loop", ".", "create_task", "(", "func", "(", "self", ")", ")", "self", ".", "_started_tasks", ".", "append", "(", "task", ")", "def", "done_callback", "(", "done_task",...
Start up a task
[ "Start", "up", "a", "task" ]
21f7212ee23e7c2dff679fbf3e9c8d9acf77b568
https://github.com/kblin/aio-standalone/blob/21f7212ee23e7c2dff679fbf3e9c8d9acf77b568/aiostandalone/app.py#L77-L86
240,361
kblin/aio-standalone
aiostandalone/app.py
StandaloneApplication.run
def run(self, loop=None): """Actually run the application :param loop: Custom event loop or None for default """ if loop is None: loop = asyncio.get_event_loop() self.loop = loop loop.run_until_complete(self.startup()) for func in self.tasks: ...
python
def run(self, loop=None): """Actually run the application :param loop: Custom event loop or None for default """ if loop is None: loop = asyncio.get_event_loop() self.loop = loop loop.run_until_complete(self.startup()) for func in self.tasks: ...
[ "def", "run", "(", "self", ",", "loop", "=", "None", ")", ":", "if", "loop", "is", "None", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "self", ".", "loop", "=", "loop", "loop", ".", "run_until_complete", "(", "self", ".", "startup",...
Actually run the application :param loop: Custom event loop or None for default
[ "Actually", "run", "the", "application" ]
21f7212ee23e7c2dff679fbf3e9c8d9acf77b568
https://github.com/kblin/aio-standalone/blob/21f7212ee23e7c2dff679fbf3e9c8d9acf77b568/aiostandalone/app.py#L88-L123
240,362
jonathansick/paperweight
paperweight/gitio.py
read_git_blob
def read_git_blob(commit_ref, path, repo_dir='.'): """Get text from a git blob. Parameters ---------- commit_ref : str Any SHA or git tag that can resolve into a commit in the git repository. path : str Path to the document in the git repository, relative to the root ...
python
def read_git_blob(commit_ref, path, repo_dir='.'): """Get text from a git blob. Parameters ---------- commit_ref : str Any SHA or git tag that can resolve into a commit in the git repository. path : str Path to the document in the git repository, relative to the root ...
[ "def", "read_git_blob", "(", "commit_ref", ",", "path", ",", "repo_dir", "=", "'.'", ")", ":", "repo", "=", "git", ".", "Repo", "(", "repo_dir", ")", "tree", "=", "repo", ".", "tree", "(", "commit_ref", ")", "dirname", ",", "fname", "=", "os", ".", ...
Get text from a git blob. Parameters ---------- commit_ref : str Any SHA or git tag that can resolve into a commit in the git repository. path : str Path to the document in the git repository, relative to the root of the repository. repo_dir : str Path from c...
[ "Get", "text", "from", "a", "git", "blob", "." ]
803535b939a56d375967cefecd5fdca81323041e
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/gitio.py#L14-L42
240,363
jonathansick/paperweight
paperweight/gitio.py
_read_blob_in_tree
def _read_blob_in_tree(tree, components): """Recursively open trees to ultimately read a blob""" if len(components) == 1: # Tree is direct parent of blob return _read_blob(tree, components[0]) else: # Still trees to open dirname = components.pop(0) for t in tree.trave...
python
def _read_blob_in_tree(tree, components): """Recursively open trees to ultimately read a blob""" if len(components) == 1: # Tree is direct parent of blob return _read_blob(tree, components[0]) else: # Still trees to open dirname = components.pop(0) for t in tree.trave...
[ "def", "_read_blob_in_tree", "(", "tree", ",", "components", ")", ":", "if", "len", "(", "components", ")", "==", "1", ":", "# Tree is direct parent of blob", "return", "_read_blob", "(", "tree", ",", "components", "[", "0", "]", ")", "else", ":", "# Still t...
Recursively open trees to ultimately read a blob
[ "Recursively", "open", "trees", "to", "ultimately", "read", "a", "blob" ]
803535b939a56d375967cefecd5fdca81323041e
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/gitio.py#L45-L55
240,364
jonathansick/paperweight
paperweight/gitio.py
absolute_git_root_dir
def absolute_git_root_dir(fpath=""): """Absolute path to the git root directory containing a given file or directory. """ if len(fpath) == 0: dirname_str = os.getcwd() else: dirname_str = os.path.dirname(fpath) dirname_str = os.path.abspath(dirname_str) dirnames = dirname_str...
python
def absolute_git_root_dir(fpath=""): """Absolute path to the git root directory containing a given file or directory. """ if len(fpath) == 0: dirname_str = os.getcwd() else: dirname_str = os.path.dirname(fpath) dirname_str = os.path.abspath(dirname_str) dirnames = dirname_str...
[ "def", "absolute_git_root_dir", "(", "fpath", "=", "\"\"", ")", ":", "if", "len", "(", "fpath", ")", "==", "0", ":", "dirname_str", "=", "os", ".", "getcwd", "(", ")", "else", ":", "dirname_str", "=", "os", ".", "path", ".", "dirname", "(", "fpath", ...
Absolute path to the git root directory containing a given file or directory.
[ "Absolute", "path", "to", "the", "git", "root", "directory", "containing", "a", "given", "file", "or", "directory", "." ]
803535b939a56d375967cefecd5fdca81323041e
https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/gitio.py#L67-L84
240,365
DallasMorningNews/django-datafreezer
datafreezer/forms.py
DatasetUploadForm.clean
def clean(self): """Verifies that beginning date is before ending date.""" cleaned_data = super(DatasetUploadForm, self).clean() date_begin = self.cleaned_data.get('date_begin') date_end = self.cleaned_data.get('date_end') if date_end < date_begin: msg = u'End date sh...
python
def clean(self): """Verifies that beginning date is before ending date.""" cleaned_data = super(DatasetUploadForm, self).clean() date_begin = self.cleaned_data.get('date_begin') date_end = self.cleaned_data.get('date_end') if date_end < date_begin: msg = u'End date sh...
[ "def", "clean", "(", "self", ")", ":", "cleaned_data", "=", "super", "(", "DatasetUploadForm", ",", "self", ")", ".", "clean", "(", ")", "date_begin", "=", "self", ".", "cleaned_data", ".", "get", "(", "'date_begin'", ")", "date_end", "=", "self", ".", ...
Verifies that beginning date is before ending date.
[ "Verifies", "that", "beginning", "date", "is", "before", "ending", "date", "." ]
982dcf2015c80a280f1a093e32977cb71d4ea7aa
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/forms.py#L131-L140
240,366
Bystroushaak/kwargs_obj
src/kwargs_obj/kwargs_obj.py
KwargsObj._kwargs_to_attributes
def _kwargs_to_attributes(self, kwargs): """ Put keys from `kwargs` to `self`, if the keys are already there. """ for key, val in kwargs.iteritems(): if key not in self.__dict__: raise ValueError( "Can't set %s parameter - it is not defined...
python
def _kwargs_to_attributes(self, kwargs): """ Put keys from `kwargs` to `self`, if the keys are already there. """ for key, val in kwargs.iteritems(): if key not in self.__dict__: raise ValueError( "Can't set %s parameter - it is not defined...
[ "def", "_kwargs_to_attributes", "(", "self", ",", "kwargs", ")", ":", "for", "key", ",", "val", "in", "kwargs", ".", "iteritems", "(", ")", ":", "if", "key", "not", "in", "self", ".", "__dict__", ":", "raise", "ValueError", "(", "\"Can't set %s parameter -...
Put keys from `kwargs` to `self`, if the keys are already there.
[ "Put", "keys", "from", "kwargs", "to", "self", "if", "the", "keys", "are", "already", "there", "." ]
67b571706f1dcbdacf465a34cd6a42b58cbd6449
https://github.com/Bystroushaak/kwargs_obj/blob/67b571706f1dcbdacf465a34cd6a42b58cbd6449/src/kwargs_obj/kwargs_obj.py#L27-L37
240,367
baverman/supplement
supplement/remote.py
Environment.assist
def assist(self, project_path, source, position, filename): """Return completion match and list of completion proposals :param project_path: absolute project path :param source: unicode or byte string code source :param position: character or byte cursor position :param filename...
python
def assist(self, project_path, source, position, filename): """Return completion match and list of completion proposals :param project_path: absolute project path :param source: unicode or byte string code source :param position: character or byte cursor position :param filename...
[ "def", "assist", "(", "self", ",", "project_path", ",", "source", ",", "position", ",", "filename", ")", ":", "return", "self", ".", "_call", "(", "'assist'", ",", "project_path", ",", "source", ",", "position", ",", "filename", ")" ]
Return completion match and list of completion proposals :param project_path: absolute project path :param source: unicode or byte string code source :param position: character or byte cursor position :param filename: absolute path of file with source code :returns: tuple (compl...
[ "Return", "completion", "match", "and", "list", "of", "completion", "proposals" ]
955002fe5a5749c9f0d89002f0006ec4fcd35bc9
https://github.com/baverman/supplement/blob/955002fe5a5749c9f0d89002f0006ec4fcd35bc9/supplement/remote.py#L114-L123
240,368
baverman/supplement
supplement/remote.py
Environment.get_location
def get_location(self, project_path, source, position, filename): """Return line number and file path where name under cursor is defined If line is None location wasn't finded. If file path is None, defenition is located in the same source. :param project_path: absolute project path ...
python
def get_location(self, project_path, source, position, filename): """Return line number and file path where name under cursor is defined If line is None location wasn't finded. If file path is None, defenition is located in the same source. :param project_path: absolute project path ...
[ "def", "get_location", "(", "self", ",", "project_path", ",", "source", ",", "position", ",", "filename", ")", ":", "return", "self", ".", "_call", "(", "'get_location'", ",", "project_path", ",", "source", ",", "position", ",", "filename", ")" ]
Return line number and file path where name under cursor is defined If line is None location wasn't finded. If file path is None, defenition is located in the same source. :param project_path: absolute project path :param source: unicode or byte string code source :param positi...
[ "Return", "line", "number", "and", "file", "path", "where", "name", "under", "cursor", "is", "defined" ]
955002fe5a5749c9f0d89002f0006ec4fcd35bc9
https://github.com/baverman/supplement/blob/955002fe5a5749c9f0d89002f0006ec4fcd35bc9/supplement/remote.py#L125-L137
240,369
baverman/supplement
supplement/remote.py
Environment.get_docstring
def get_docstring(self, project_path, source, position, filename): """Return signature and docstring for current cursor call context Some examples of call context:: func(| func(arg| func(arg,| func(arg, func2(| # call context is func2 Signature ...
python
def get_docstring(self, project_path, source, position, filename): """Return signature and docstring for current cursor call context Some examples of call context:: func(| func(arg| func(arg,| func(arg, func2(| # call context is func2 Signature ...
[ "def", "get_docstring", "(", "self", ",", "project_path", ",", "source", ",", "position", ",", "filename", ")", ":", "return", "self", ".", "_call", "(", "'get_docstring'", ",", "project_path", ",", "source", ",", "position", ",", "filename", ")" ]
Return signature and docstring for current cursor call context Some examples of call context:: func(| func(arg| func(arg,| func(arg, func2(| # call context is func2 Signature and docstring can be None :param project_path: absolute project path ...
[ "Return", "signature", "and", "docstring", "for", "current", "cursor", "call", "context" ]
955002fe5a5749c9f0d89002f0006ec4fcd35bc9
https://github.com/baverman/supplement/blob/955002fe5a5749c9f0d89002f0006ec4fcd35bc9/supplement/remote.py#L139-L158
240,370
baverman/supplement
supplement/remote.py
Environment.get_scope
def get_scope(self, project_path, source, lineno, filename, continous=True): """ Return scope name at cursor position For example:: class Foo: def foo(self): pass | def bar(self): pass ...
python
def get_scope(self, project_path, source, lineno, filename, continous=True): """ Return scope name at cursor position For example:: class Foo: def foo(self): pass | def bar(self): pass ...
[ "def", "get_scope", "(", "self", ",", "project_path", ",", "source", ",", "lineno", ",", "filename", ",", "continous", "=", "True", ")", ":", "return", "self", ".", "_call", "(", "'get_scope'", ",", "project_path", ",", "source", ",", "lineno", ",", "fil...
Return scope name at cursor position For example:: class Foo: def foo(self): pass | def bar(self): pass get_scope return Foo.foo if continuous is True and Foo otherwise. :param project_pat...
[ "Return", "scope", "name", "at", "cursor", "position" ]
955002fe5a5749c9f0d89002f0006ec4fcd35bc9
https://github.com/baverman/supplement/blob/955002fe5a5749c9f0d89002f0006ec4fcd35bc9/supplement/remote.py#L168-L189
240,371
andreycizov/python-xrpc
xrpc/runtime.py
_masquerade
def _masquerade(origin: str, orig: ServiceDefn, new: ServiceDefn, **map: str) -> str: """build an origin URL such that the orig has all of the mappings to new defined by map""" origin: ParseResult = urlparse(origin) prev_maps = {} if origin.query: prev_maps = {k: v for k, v in parse_qsl(origi...
python
def _masquerade(origin: str, orig: ServiceDefn, new: ServiceDefn, **map: str) -> str: """build an origin URL such that the orig has all of the mappings to new defined by map""" origin: ParseResult = urlparse(origin) prev_maps = {} if origin.query: prev_maps = {k: v for k, v in parse_qsl(origi...
[ "def", "_masquerade", "(", "origin", ":", "str", ",", "orig", ":", "ServiceDefn", ",", "new", ":", "ServiceDefn", ",", "*", "*", "map", ":", "str", ")", "->", "str", ":", "origin", ":", "ParseResult", "=", "urlparse", "(", "origin", ")", "prev_maps", ...
build an origin URL such that the orig has all of the mappings to new defined by map
[ "build", "an", "origin", "URL", "such", "that", "the", "orig", "has", "all", "of", "the", "mappings", "to", "new", "defined", "by", "map" ]
4f916383cda7de3272962f3ba07a64f7ec451098
https://github.com/andreycizov/python-xrpc/blob/4f916383cda7de3272962f3ba07a64f7ec451098/xrpc/runtime.py#L134-L164
240,372
andreycizov/python-xrpc
xrpc/runtime.py
masquerade
def masquerade(origin: str, orig: Type[TA], new: Type[TB], **map: str) -> str: """Make ``orig`` appear as new""" return _masquerade(origin, cache_get(orig), cache_get(new), **map)
python
def masquerade(origin: str, orig: Type[TA], new: Type[TB], **map: str) -> str: """Make ``orig`` appear as new""" return _masquerade(origin, cache_get(orig), cache_get(new), **map)
[ "def", "masquerade", "(", "origin", ":", "str", ",", "orig", ":", "Type", "[", "TA", "]", ",", "new", ":", "Type", "[", "TB", "]", ",", "*", "*", "map", ":", "str", ")", "->", "str", ":", "return", "_masquerade", "(", "origin", ",", "cache_get", ...
Make ``orig`` appear as new
[ "Make", "orig", "appear", "as", "new" ]
4f916383cda7de3272962f3ba07a64f7ec451098
https://github.com/andreycizov/python-xrpc/blob/4f916383cda7de3272962f3ba07a64f7ec451098/xrpc/runtime.py#L167-L170
240,373
SOBotics/pyRedunda
pyRedunda/Redunda.py
Redunda.sendStatusPing
def sendStatusPing(self): """ Sends a status ping to Redunda with the instance key specified while constructing the object. """ data = parse.urlencode({"key": self.key, "version": self.version}).encode() req = request.Request("https://redunda.sobotics.org/status.json", data) ...
python
def sendStatusPing(self): """ Sends a status ping to Redunda with the instance key specified while constructing the object. """ data = parse.urlencode({"key": self.key, "version": self.version}).encode() req = request.Request("https://redunda.sobotics.org/status.json", data) ...
[ "def", "sendStatusPing", "(", "self", ")", ":", "data", "=", "parse", ".", "urlencode", "(", "{", "\"key\"", ":", "self", ".", "key", ",", "\"version\"", ":", "self", ".", "version", "}", ")", ".", "encode", "(", ")", "req", "=", "request", ".", "R...
Sends a status ping to Redunda with the instance key specified while constructing the object.
[ "Sends", "a", "status", "ping", "to", "Redunda", "with", "the", "instance", "key", "specified", "while", "constructing", "the", "object", "." ]
4bd190dc908861c5fac4c9b60cf79eeb0e5c76ab
https://github.com/SOBotics/pyRedunda/blob/4bd190dc908861c5fac4c9b60cf79eeb0e5c76ab/pyRedunda/Redunda.py#L36-L49
240,374
SOBotics/pyRedunda
pyRedunda/Redunda.py
Redunda.uploadFile
def uploadFile(self, filename, ispickle=False, athome=False): """ Uploads a single file to Redunda. :param str filename: The name of the file to upload :param bool ispickle: Optional variable to be set to True is the file is a pickle; default is False. :returns: returns nothing ...
python
def uploadFile(self, filename, ispickle=False, athome=False): """ Uploads a single file to Redunda. :param str filename: The name of the file to upload :param bool ispickle: Optional variable to be set to True is the file is a pickle; default is False. :returns: returns nothing ...
[ "def", "uploadFile", "(", "self", ",", "filename", ",", "ispickle", "=", "False", ",", "athome", "=", "False", ")", ":", "print", "(", "\"Uploading file {} to Redunda.\"", ".", "format", "(", "filename", ")", ")", "_", ",", "tail", "=", "os", ".", "path"...
Uploads a single file to Redunda. :param str filename: The name of the file to upload :param bool ispickle: Optional variable to be set to True is the file is a pickle; default is False. :returns: returns nothing
[ "Uploads", "a", "single", "file", "to", "Redunda", "." ]
4bd190dc908861c5fac4c9b60cf79eeb0e5c76ab
https://github.com/SOBotics/pyRedunda/blob/4bd190dc908861c5fac4c9b60cf79eeb0e5c76ab/pyRedunda/Redunda.py#L51-L96
240,375
SOBotics/pyRedunda
pyRedunda/Redunda.py
Redunda.downloadFile
def downloadFile(self, filename, ispickle=False, athome=False): """ Downloads a single file from Redunda. :param str filename: The name of the file you want to download :param bool ispickle: Optional variable which tells if the file to be downloaded is a pickle; default is False. ...
python
def downloadFile(self, filename, ispickle=False, athome=False): """ Downloads a single file from Redunda. :param str filename: The name of the file you want to download :param bool ispickle: Optional variable which tells if the file to be downloaded is a pickle; default is False. ...
[ "def", "downloadFile", "(", "self", ",", "filename", ",", "ispickle", "=", "False", ",", "athome", "=", "False", ")", ":", "print", "(", "\"Downloading file {} from Redunda.\"", ".", "format", "(", "filename", ")", ")", "_", ",", "tail", "=", "os", ".", ...
Downloads a single file from Redunda. :param str filename: The name of the file you want to download :param bool ispickle: Optional variable which tells if the file to be downloaded is a pickle; default is False. :returns: returns nothing
[ "Downloads", "a", "single", "file", "from", "Redunda", "." ]
4bd190dc908861c5fac4c9b60cf79eeb0e5c76ab
https://github.com/SOBotics/pyRedunda/blob/4bd190dc908861c5fac4c9b60cf79eeb0e5c76ab/pyRedunda/Redunda.py#L98-L139
240,376
SOBotics/pyRedunda
pyRedunda/Redunda.py
Redunda.uploadFiles
def uploadFiles(self): """ Uploads all the files in 'filesToSync' """ for each_file in self.filesToSync: self.uploadFile(each_file["name"], each_file["ispickle"], each_file["at_home"])
python
def uploadFiles(self): """ Uploads all the files in 'filesToSync' """ for each_file in self.filesToSync: self.uploadFile(each_file["name"], each_file["ispickle"], each_file["at_home"])
[ "def", "uploadFiles", "(", "self", ")", ":", "for", "each_file", "in", "self", ".", "filesToSync", ":", "self", ".", "uploadFile", "(", "each_file", "[", "\"name\"", "]", ",", "each_file", "[", "\"ispickle\"", "]", ",", "each_file", "[", "\"at_home\"", "]"...
Uploads all the files in 'filesToSync'
[ "Uploads", "all", "the", "files", "in", "filesToSync" ]
4bd190dc908861c5fac4c9b60cf79eeb0e5c76ab
https://github.com/SOBotics/pyRedunda/blob/4bd190dc908861c5fac4c9b60cf79eeb0e5c76ab/pyRedunda/Redunda.py#L141-L146
240,377
SOBotics/pyRedunda
pyRedunda/Redunda.py
Redunda.downloadFiles
def downloadFiles(self): """ Downloads all the files in 'filesToSync' """ for each_file in self.filesToSync: self.downloadFile(each_file["name"], each_file["ispickle"], each_file["at_home"])
python
def downloadFiles(self): """ Downloads all the files in 'filesToSync' """ for each_file in self.filesToSync: self.downloadFile(each_file["name"], each_file["ispickle"], each_file["at_home"])
[ "def", "downloadFiles", "(", "self", ")", ":", "for", "each_file", "in", "self", ".", "filesToSync", ":", "self", ".", "downloadFile", "(", "each_file", "[", "\"name\"", "]", ",", "each_file", "[", "\"ispickle\"", "]", ",", "each_file", "[", "\"at_home\"", ...
Downloads all the files in 'filesToSync'
[ "Downloads", "all", "the", "files", "in", "filesToSync" ]
4bd190dc908861c5fac4c9b60cf79eeb0e5c76ab
https://github.com/SOBotics/pyRedunda/blob/4bd190dc908861c5fac4c9b60cf79eeb0e5c76ab/pyRedunda/Redunda.py#L148-L153
240,378
SOBotics/pyRedunda
pyRedunda/Redunda.py
Redunda.getEvents
def getEvents(self): """ Gets all events from Redunda and returns them. :returns: Returns a dictionary of the events which were fetched. """ url = "https://redunda.sobotics.org/events.json" data = parse.urlencode({"key": self.key}).encode() req = request.Reques...
python
def getEvents(self): """ Gets all events from Redunda and returns them. :returns: Returns a dictionary of the events which were fetched. """ url = "https://redunda.sobotics.org/events.json" data = parse.urlencode({"key": self.key}).encode() req = request.Reques...
[ "def", "getEvents", "(", "self", ")", ":", "url", "=", "\"https://redunda.sobotics.org/events.json\"", "data", "=", "parse", ".", "urlencode", "(", "{", "\"key\"", ":", "self", ".", "key", "}", ")", ".", "encode", "(", ")", "req", "=", "request", ".", "R...
Gets all events from Redunda and returns them. :returns: Returns a dictionary of the events which were fetched.
[ "Gets", "all", "events", "from", "Redunda", "and", "returns", "them", "." ]
4bd190dc908861c5fac4c9b60cf79eeb0e5c76ab
https://github.com/SOBotics/pyRedunda/blob/4bd190dc908861c5fac4c9b60cf79eeb0e5c76ab/pyRedunda/Redunda.py#L155-L169
240,379
asphalt-framework/asphalt-memcached
asphalt/memcached/component.py
MemcachedComponent.configure_client
def configure_client(cls, host: str = 'localhost', port: int = 11211, **client_args): """ Configure a Memcached client. :param host: host name or ip address to connect to :param port: port number to connect to :param client_args: extra keyword arguments passed to :class:`aiomcac...
python
def configure_client(cls, host: str = 'localhost', port: int = 11211, **client_args): """ Configure a Memcached client. :param host: host name or ip address to connect to :param port: port number to connect to :param client_args: extra keyword arguments passed to :class:`aiomcac...
[ "def", "configure_client", "(", "cls", ",", "host", ":", "str", "=", "'localhost'", ",", "port", ":", "int", "=", "11211", ",", "*", "*", "client_args", ")", ":", "assert", "check_argument_types", "(", ")", "client", "=", "Client", "(", "host", ",", "p...
Configure a Memcached client. :param host: host name or ip address to connect to :param port: port number to connect to :param client_args: extra keyword arguments passed to :class:`aiomcache.Client`
[ "Configure", "a", "Memcached", "client", "." ]
48739fbc1f492c2ccfbe9ed0d8c8d8eda740bc0b
https://github.com/asphalt-framework/asphalt-memcached/blob/48739fbc1f492c2ccfbe9ed0d8c8d8eda740bc0b/asphalt/memcached/component.py#L44-L55
240,380
ThreshingFloor/libtf
libtf/logparsers/tf_auth_log.py
TFAuthLog._extract_features
def _extract_features(self): """ Extracts and sets the feature data from the log file necessary for a reduction """ for parsed_line in self.parsed_lines: # If it's ssh, we can handle it if parsed_line.get('program') == 'sshd': result = self._parse...
python
def _extract_features(self): """ Extracts and sets the feature data from the log file necessary for a reduction """ for parsed_line in self.parsed_lines: # If it's ssh, we can handle it if parsed_line.get('program') == 'sshd': result = self._parse...
[ "def", "_extract_features", "(", "self", ")", ":", "for", "parsed_line", "in", "self", ".", "parsed_lines", ":", "# If it's ssh, we can handle it", "if", "parsed_line", ".", "get", "(", "'program'", ")", "==", "'sshd'", ":", "result", "=", "self", ".", "_parse...
Extracts and sets the feature data from the log file necessary for a reduction
[ "Extracts", "and", "sets", "the", "feature", "data", "from", "the", "log", "file", "necessary", "for", "a", "reduction" ]
f1a8710f750639c9b9e2a468ece0d2923bf8c3df
https://github.com/ThreshingFloor/libtf/blob/f1a8710f750639c9b9e2a468ece0d2923bf8c3df/libtf/logparsers/tf_auth_log.py#L64-L85
240,381
ThreshingFloor/libtf
libtf/logparsers/tf_auth_log.py
TFAuthLog._analyze
def _analyze(self): """ Decide which lines should be filtered out """ pids = [] for ip in self.filter['ips']: if ip in self.ips_to_pids: for pid in self.ips_to_pids[ip]: pids.append(pid) for line in self.parsed_lines: ...
python
def _analyze(self): """ Decide which lines should be filtered out """ pids = [] for ip in self.filter['ips']: if ip in self.ips_to_pids: for pid in self.ips_to_pids[ip]: pids.append(pid) for line in self.parsed_lines: ...
[ "def", "_analyze", "(", "self", ")", ":", "pids", "=", "[", "]", "for", "ip", "in", "self", ".", "filter", "[", "'ips'", "]", ":", "if", "ip", "in", "self", ".", "ips_to_pids", ":", "for", "pid", "in", "self", ".", "ips_to_pids", "[", "ip", "]", ...
Decide which lines should be filtered out
[ "Decide", "which", "lines", "should", "be", "filtered", "out" ]
f1a8710f750639c9b9e2a468ece0d2923bf8c3df
https://github.com/ThreshingFloor/libtf/blob/f1a8710f750639c9b9e2a468ece0d2923bf8c3df/libtf/logparsers/tf_auth_log.py#L109-L124
240,382
ThreshingFloor/libtf
libtf/logparsers/tf_auth_log.py
TFAuthLog._to_epoch
def _to_epoch(self, ts): """ Adds a year to the syslog timestamp because syslog doesn't use years :param ts: The timestamp to add a year to :return: Date/time string that includes a year """ year = self.year tmpts = "%s %s" % (ts, str(self.year)) new_tim...
python
def _to_epoch(self, ts): """ Adds a year to the syslog timestamp because syslog doesn't use years :param ts: The timestamp to add a year to :return: Date/time string that includes a year """ year = self.year tmpts = "%s %s" % (ts, str(self.year)) new_tim...
[ "def", "_to_epoch", "(", "self", ",", "ts", ")", ":", "year", "=", "self", ".", "year", "tmpts", "=", "\"%s %s\"", "%", "(", "ts", ",", "str", "(", "self", ".", "year", ")", ")", "new_time", "=", "int", "(", "calendar", ".", "timegm", "(", "time"...
Adds a year to the syslog timestamp because syslog doesn't use years :param ts: The timestamp to add a year to :return: Date/time string that includes a year
[ "Adds", "a", "year", "to", "the", "syslog", "timestamp", "because", "syslog", "doesn", "t", "use", "years" ]
f1a8710f750639c9b9e2a468ece0d2923bf8c3df
https://github.com/ThreshingFloor/libtf/blob/f1a8710f750639c9b9e2a468ece0d2923bf8c3df/libtf/logparsers/tf_auth_log.py#L126-L144
240,383
ThreshingFloor/libtf
libtf/logparsers/tf_auth_log.py
TFAuthLog._parse_auth_message
def _parse_auth_message(self, auth_message): """ Parse a message to see if we have ip addresses or users that we care about :param auth_message: The auth message to parse :return: Result """ result = {} has_matched = False for regex in REGEXES_INVALID_U...
python
def _parse_auth_message(self, auth_message): """ Parse a message to see if we have ip addresses or users that we care about :param auth_message: The auth message to parse :return: Result """ result = {} has_matched = False for regex in REGEXES_INVALID_U...
[ "def", "_parse_auth_message", "(", "self", ",", "auth_message", ")", ":", "result", "=", "{", "}", "has_matched", "=", "False", "for", "regex", "in", "REGEXES_INVALID_USER", ":", "# Check for the invalid user/ip messages", "m", "=", "re", ".", "search", "(", "re...
Parse a message to see if we have ip addresses or users that we care about :param auth_message: The auth message to parse :return: Result
[ "Parse", "a", "message", "to", "see", "if", "we", "have", "ip", "addresses", "or", "users", "that", "we", "care", "about" ]
f1a8710f750639c9b9e2a468ece0d2923bf8c3df
https://github.com/ThreshingFloor/libtf/blob/f1a8710f750639c9b9e2a468ece0d2923bf8c3df/libtf/logparsers/tf_auth_log.py#L146-L189
240,384
guyingbo/iofree
iofree/__init__.py
read_until
def read_until(data: bytes, *, return_tail: bool = True, from_=None) -> bytes: """ read until some bytes appear """ return (yield (Traps._read_until, data, return_tail, from_))
python
def read_until(data: bytes, *, return_tail: bool = True, from_=None) -> bytes: """ read until some bytes appear """ return (yield (Traps._read_until, data, return_tail, from_))
[ "def", "read_until", "(", "data", ":", "bytes", ",", "*", ",", "return_tail", ":", "bool", "=", "True", ",", "from_", "=", "None", ")", "->", "bytes", ":", "return", "(", "yield", "(", "Traps", ".", "_read_until", ",", "data", ",", "return_tail", ","...
read until some bytes appear
[ "read", "until", "some", "bytes", "appear" ]
9a14250c276f88c784d164f60fb22fbc1e7a3243
https://github.com/guyingbo/iofree/blob/9a14250c276f88c784d164f60fb22fbc1e7a3243/iofree/__init__.py#L214-L218
240,385
guyingbo/iofree
iofree/__init__.py
read_int
def read_int(nbytes: int, *, byteorder: str = "big", from_=None) -> int: """ read some bytes as integer """ return (yield (Traps._read_int, nbytes, byteorder, from_))
python
def read_int(nbytes: int, *, byteorder: str = "big", from_=None) -> int: """ read some bytes as integer """ return (yield (Traps._read_int, nbytes, byteorder, from_))
[ "def", "read_int", "(", "nbytes", ":", "int", ",", "*", ",", "byteorder", ":", "str", "=", "\"big\"", ",", "from_", "=", "None", ")", "->", "int", ":", "return", "(", "yield", "(", "Traps", ".", "_read_int", ",", "nbytes", ",", "byteorder", ",", "f...
read some bytes as integer
[ "read", "some", "bytes", "as", "integer" ]
9a14250c276f88c784d164f60fb22fbc1e7a3243
https://github.com/guyingbo/iofree/blob/9a14250c276f88c784d164f60fb22fbc1e7a3243/iofree/__init__.py#L228-L232
240,386
guyingbo/iofree
iofree/__init__.py
Parser.send
def send(self, data: bytes = b""): """ send data for parsing """ self.input.extend(data) self._process()
python
def send(self, data: bytes = b""): """ send data for parsing """ self.input.extend(data) self._process()
[ "def", "send", "(", "self", ",", "data", ":", "bytes", "=", "b\"\"", ")", ":", "self", ".", "input", ".", "extend", "(", "data", ")", "self", ".", "_process", "(", ")" ]
send data for parsing
[ "send", "data", "for", "parsing" ]
9a14250c276f88c784d164f60fb22fbc1e7a3243
https://github.com/guyingbo/iofree/blob/9a14250c276f88c784d164f60fb22fbc1e7a3243/iofree/__init__.py#L44-L49
240,387
ryanjdillon/pylleo
pylleo/utils_bokeh.py
create_bokeh_server
def create_bokeh_server(io_loop, files, argvs, host, port): '''Start bokeh server with applications paths''' from bokeh.server.server import Server from bokeh.command.util import build_single_handler_applications # Turn file paths into bokeh apps apps = build_single_handler_applications(files, argv...
python
def create_bokeh_server(io_loop, files, argvs, host, port): '''Start bokeh server with applications paths''' from bokeh.server.server import Server from bokeh.command.util import build_single_handler_applications # Turn file paths into bokeh apps apps = build_single_handler_applications(files, argv...
[ "def", "create_bokeh_server", "(", "io_loop", ",", "files", ",", "argvs", ",", "host", ",", "port", ")", ":", "from", "bokeh", ".", "server", ".", "server", "import", "Server", "from", "bokeh", ".", "command", ".", "util", "import", "build_single_handler_app...
Start bokeh server with applications paths
[ "Start", "bokeh", "server", "with", "applications", "paths" ]
b9b999fef19eaeccce4f207ab1b6198287c1bfec
https://github.com/ryanjdillon/pylleo/blob/b9b999fef19eaeccce4f207ab1b6198287c1bfec/pylleo/utils_bokeh.py#L2-L26
240,388
FlorianLudwig/rueckenwind
rw/routing.py
_generate_request_handler_proxy
def _generate_request_handler_proxy(handler_class, handler_args, name): """When a tornado.web.RequestHandler gets mounted we create a launcher function""" @scope.inject def request_handler_wrapper(app, handler, **kwargs): handler = handler_class(app, handler.request, **handler_args) handler...
python
def _generate_request_handler_proxy(handler_class, handler_args, name): """When a tornado.web.RequestHandler gets mounted we create a launcher function""" @scope.inject def request_handler_wrapper(app, handler, **kwargs): handler = handler_class(app, handler.request, **handler_args) handler...
[ "def", "_generate_request_handler_proxy", "(", "handler_class", ",", "handler_args", ",", "name", ")", ":", "@", "scope", ".", "inject", "def", "request_handler_wrapper", "(", "app", ",", "handler", ",", "*", "*", "kwargs", ")", ":", "handler", "=", "handler_c...
When a tornado.web.RequestHandler gets mounted we create a launcher function
[ "When", "a", "tornado", ".", "web", ".", "RequestHandler", "gets", "mounted", "we", "create", "a", "launcher", "function" ]
47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea
https://github.com/FlorianLudwig/rueckenwind/blob/47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea/rw/routing.py#L178-L189
240,389
FlorianLudwig/rueckenwind
rw/routing.py
RoutingTable.setup
def setup(self): """setup routing table""" # get all routes from submodules for prefix, routes in self.sub_rt: routes.prefix = self.prefix + prefix routes.setup() fn_name_prefixes = {} for fn_key, fn in routes.fn_namespace.items(): ...
python
def setup(self): """setup routing table""" # get all routes from submodules for prefix, routes in self.sub_rt: routes.prefix = self.prefix + prefix routes.setup() fn_name_prefixes = {} for fn_key, fn in routes.fn_namespace.items(): ...
[ "def", "setup", "(", "self", ")", ":", "# get all routes from submodules", "for", "prefix", ",", "routes", "in", "self", ".", "sub_rt", ":", "routes", ".", "prefix", "=", "self", ".", "prefix", "+", "prefix", "routes", ".", "setup", "(", ")", "fn_name_pref...
setup routing table
[ "setup", "routing", "table" ]
47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea
https://github.com/FlorianLudwig/rueckenwind/blob/47fec7af05ea10b3cf6d59b9f7bf4d12c02dddea/rw/routing.py#L202-L229
240,390
TkTech/pytextql
setup.py
get_version
def get_version(): """ Loads the current module version from version.py and returns it. :returns: module version identifier. :rtype: str """ local_results = {} version_file_path = os.path.join('pytextql', 'version.py') # This is compatible with py3k which removed execfile. with...
python
def get_version(): """ Loads the current module version from version.py and returns it. :returns: module version identifier. :rtype: str """ local_results = {} version_file_path = os.path.join('pytextql', 'version.py') # This is compatible with py3k which removed execfile. with...
[ "def", "get_version", "(", ")", ":", "local_results", "=", "{", "}", "version_file_path", "=", "os", ".", "path", ".", "join", "(", "'pytextql'", ",", "'version.py'", ")", "# This is compatible with py3k which removed execfile.", "with", "open", "(", "version_file_p...
Loads the current module version from version.py and returns it. :returns: module version identifier. :rtype: str
[ "Loads", "the", "current", "module", "version", "from", "version", ".", "py", "and", "returns", "it", "." ]
e054a7a4df7262deaca49bdbf748c00acf011b51
https://github.com/TkTech/pytextql/blob/e054a7a4df7262deaca49bdbf748c00acf011b51/setup.py#L7-L25
240,391
thomasbiddle/Kippt-for-Python
kippt/clips.py
Clip.update
def update(self, **args): """ Updates a Clip. Parameters: - args Dictionary of other fields Accepted fields can be found here: https://github.com/kippt/api-documentation/blob/master/objects/clip.md """ # JSONify our data. data = json.dumps(args) ...
python
def update(self, **args): """ Updates a Clip. Parameters: - args Dictionary of other fields Accepted fields can be found here: https://github.com/kippt/api-documentation/blob/master/objects/clip.md """ # JSONify our data. data = json.dumps(args) ...
[ "def", "update", "(", "self", ",", "*", "*", "args", ")", ":", "# JSONify our data.", "data", "=", "json", ".", "dumps", "(", "args", ")", "r", "=", "requests", ".", "put", "(", "\"https://kippt.com/api/clips/%s\"", "%", "(", "self", ".", "id", ")", ",...
Updates a Clip. Parameters: - args Dictionary of other fields Accepted fields can be found here: https://github.com/kippt/api-documentation/blob/master/objects/clip.md
[ "Updates", "a", "Clip", "." ]
dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267
https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/clips.py#L150-L165
240,392
thomasbiddle/Kippt-for-Python
kippt/clips.py
Clip.like
def like(self): """ Like a clip. """ r = requests.post( "https://kippt.com/api/clips/%s/likes" % (self.id), headers=self.kippt.header ) return (r.json())
python
def like(self): """ Like a clip. """ r = requests.post( "https://kippt.com/api/clips/%s/likes" % (self.id), headers=self.kippt.header ) return (r.json())
[ "def", "like", "(", "self", ")", ":", "r", "=", "requests", ".", "post", "(", "\"https://kippt.com/api/clips/%s/likes\"", "%", "(", "self", ".", "id", ")", ",", "headers", "=", "self", ".", "kippt", ".", "header", ")", "return", "(", "r", ".", "json", ...
Like a clip.
[ "Like", "a", "clip", "." ]
dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267
https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/clips.py#L167-L175
240,393
thomasbiddle/Kippt-for-Python
kippt/clips.py
Clip.comment
def comment(self, body): """ Comment on a clip. Parameters: - body (Required) """ # Merge our url as a parameter and JSONify it. data = json.dumps({'body': body}) r = requests.post( "https://kippt.com/api/clips/%s/comments" (self.id), head...
python
def comment(self, body): """ Comment on a clip. Parameters: - body (Required) """ # Merge our url as a parameter and JSONify it. data = json.dumps({'body': body}) r = requests.post( "https://kippt.com/api/clips/%s/comments" (self.id), head...
[ "def", "comment", "(", "self", ",", "body", ")", ":", "# Merge our url as a parameter and JSONify it.", "data", "=", "json", ".", "dumps", "(", "{", "'body'", ":", "body", "}", ")", "r", "=", "requests", ".", "post", "(", "\"https://kippt.com/api/clips/%s/commen...
Comment on a clip. Parameters: - body (Required)
[ "Comment", "on", "a", "clip", "." ]
dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267
https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/clips.py#L187-L200
240,394
thomasbiddle/Kippt-for-Python
kippt/clips.py
Clip.unlike
def unlike(self): """ Unlike a clip. """ r = requests.delete( "https://kippt.com/api/clips/%s/likes" % (self.id), headers=self.kippt.header) return (r.json())
python
def unlike(self): """ Unlike a clip. """ r = requests.delete( "https://kippt.com/api/clips/%s/likes" % (self.id), headers=self.kippt.header) return (r.json())
[ "def", "unlike", "(", "self", ")", ":", "r", "=", "requests", ".", "delete", "(", "\"https://kippt.com/api/clips/%s/likes\"", "%", "(", "self", ".", "id", ")", ",", "headers", "=", "self", ".", "kippt", ".", "header", ")", "return", "(", "r", ".", "jso...
Unlike a clip.
[ "Unlike", "a", "clip", "." ]
dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267
https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/clips.py#L223-L230
240,395
jayclassless/basicserial
src/basicserial/__init__.py
to_json
def to_json(value, pretty=False): """ Serializes the given value to JSON. :param value: the value to serialize :param pretty: whether or not to format the output in a more human-readable way; if not specified, defaults to ``False`` :type pretty: bool :rtype: str """ opt...
python
def to_json(value, pretty=False): """ Serializes the given value to JSON. :param value: the value to serialize :param pretty: whether or not to format the output in a more human-readable way; if not specified, defaults to ``False`` :type pretty: bool :rtype: str """ opt...
[ "def", "to_json", "(", "value", ",", "pretty", "=", "False", ")", ":", "options", "=", "{", "'sort_keys'", ":", "False", ",", "'cls'", ":", "BasicJSONEncoder", ",", "}", "if", "pretty", ":", "options", "[", "'indent'", "]", "=", "2", "options", "[", ...
Serializes the given value to JSON. :param value: the value to serialize :param pretty: whether or not to format the output in a more human-readable way; if not specified, defaults to ``False`` :type pretty: bool :rtype: str
[ "Serializes", "the", "given", "value", "to", "JSON", "." ]
da779edd955ba1009d14fae4e5926e29ad112b9d
https://github.com/jayclassless/basicserial/blob/da779edd955ba1009d14fae4e5926e29ad112b9d/src/basicserial/__init__.py#L80-L100
240,396
jayclassless/basicserial
src/basicserial/__init__.py
from_json
def from_json(value, native_datetimes=True): """ Deserializes the given value from JSON. :param value: the value to deserialize :type value: str :param native_datetimes: whether or not strings that look like dates/times should be automatically cast to the native objects, or left as ...
python
def from_json(value, native_datetimes=True): """ Deserializes the given value from JSON. :param value: the value to deserialize :type value: str :param native_datetimes: whether or not strings that look like dates/times should be automatically cast to the native objects, or left as ...
[ "def", "from_json", "(", "value", ",", "native_datetimes", "=", "True", ")", ":", "hook", "=", "BasicJsonDecoder", "(", "native_datetimes", "=", "native_datetimes", ")", "result", "=", "json", ".", "loads", "(", "value", ",", "object_hook", "=", "hook", ")",...
Deserializes the given value from JSON. :param value: the value to deserialize :type value: str :param native_datetimes: whether or not strings that look like dates/times should be automatically cast to the native objects, or left as strings; if not specified, defaults to ``True`` ...
[ "Deserializes", "the", "given", "value", "from", "JSON", "." ]
da779edd955ba1009d14fae4e5926e29ad112b9d
https://github.com/jayclassless/basicserial/blob/da779edd955ba1009d14fae4e5926e29ad112b9d/src/basicserial/__init__.py#L173-L190
240,397
jayclassless/basicserial
src/basicserial/__init__.py
to_yaml
def to_yaml(value, pretty=False): """ Serializes the given value to YAML. :param value: the value to serialize :param pretty: whether or not to format the output in a more human-readable way; if not specified, defaults to ``False`` :type pretty: bool :rtype: str """ if ...
python
def to_yaml(value, pretty=False): """ Serializes the given value to YAML. :param value: the value to serialize :param pretty: whether or not to format the output in a more human-readable way; if not specified, defaults to ``False`` :type pretty: bool :rtype: str """ if ...
[ "def", "to_yaml", "(", "value", ",", "pretty", "=", "False", ")", ":", "if", "not", "yaml", ":", "raise", "NotImplementedError", "(", "'No supported YAML library available'", ")", "options", "=", "{", "'Dumper'", ":", "BasicYamlDumper", ",", "'allow_unicode'", "...
Serializes the given value to YAML. :param value: the value to serialize :param pretty: whether or not to format the output in a more human-readable way; if not specified, defaults to ``False`` :type pretty: bool :rtype: str
[ "Serializes", "the", "given", "value", "to", "YAML", "." ]
da779edd955ba1009d14fae4e5926e29ad112b9d
https://github.com/jayclassless/basicserial/blob/da779edd955ba1009d14fae4e5926e29ad112b9d/src/basicserial/__init__.py#L244-L265
240,398
jayclassless/basicserial
src/basicserial/__init__.py
from_yaml
def from_yaml(value, native_datetimes=True): """ Deserializes the given value from YAML. :param value: the value to deserialize :type value: str :param native_datetimes: whether or not strings that look like dates/times should be automatically cast to the native objects, or left as ...
python
def from_yaml(value, native_datetimes=True): """ Deserializes the given value from YAML. :param value: the value to deserialize :type value: str :param native_datetimes: whether or not strings that look like dates/times should be automatically cast to the native objects, or left as ...
[ "def", "from_yaml", "(", "value", ",", "native_datetimes", "=", "True", ")", ":", "if", "not", "yaml", ":", "raise", "NotImplementedError", "(", "'No supported YAML library available'", ")", "if", "native_datetimes", ":", "loader", "=", "NativeDatesYamlLoader", "els...
Deserializes the given value from YAML. :param value: the value to deserialize :type value: str :param native_datetimes: whether or not strings that look like dates/times should be automatically cast to the native objects, or left as strings; if not specified, defaults to ``True`` ...
[ "Deserializes", "the", "given", "value", "from", "YAML", "." ]
da779edd955ba1009d14fae4e5926e29ad112b9d
https://github.com/jayclassless/basicserial/blob/da779edd955ba1009d14fae4e5926e29ad112b9d/src/basicserial/__init__.py#L302-L323
240,399
jayclassless/basicserial
src/basicserial/__init__.py
to_toml
def to_toml(value, pretty=False): # noqa: unused-argument """ Serializes the given value to TOML. :param value: the value to serialize :param pretty: this argument is ignored, as no TOML libraries support this type of operation :type pretty: bool :rtype: str """ if not...
python
def to_toml(value, pretty=False): # noqa: unused-argument """ Serializes the given value to TOML. :param value: the value to serialize :param pretty: this argument is ignored, as no TOML libraries support this type of operation :type pretty: bool :rtype: str """ if not...
[ "def", "to_toml", "(", "value", ",", "pretty", "=", "False", ")", ":", "# noqa: unused-argument", "if", "not", "toml", ":", "raise", "NotImplementedError", "(", "'No supported TOML library available'", ")", "return", "toml", ".", "dumps", "(", "make_toml_friendly", ...
Serializes the given value to TOML. :param value: the value to serialize :param pretty: this argument is ignored, as no TOML libraries support this type of operation :type pretty: bool :rtype: str
[ "Serializes", "the", "given", "value", "to", "TOML", "." ]
da779edd955ba1009d14fae4e5926e29ad112b9d
https://github.com/jayclassless/basicserial/blob/da779edd955ba1009d14fae4e5926e29ad112b9d/src/basicserial/__init__.py#L354-L369