partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
SQLQueryInfo.parse_select
get columns from select text :param text: col1, col2 :return: ALL_COLUMNS or ['col1', 'col2']
slim/base/sqlquery.py
def parse_select(cls, text: str) -> Set: """ get columns from select text :param text: col1, col2 :return: ALL_COLUMNS or ['col1', 'col2'] """ if text == '*': return ALL_COLUMNS # None means ALL selected_columns = set(filter(lambda x: x, map(str.strip...
def parse_select(cls, text: str) -> Set: """ get columns from select text :param text: col1, col2 :return: ALL_COLUMNS or ['col1', 'col2'] """ if text == '*': return ALL_COLUMNS # None means ALL selected_columns = set(filter(lambda x: x, map(str.strip...
[ "get", "columns", "from", "select", "text", ":", "param", "text", ":", "col1", "col2", ":", "return", ":", "ALL_COLUMNS", "or", "[", "col1", "col2", "]" ]
fy0/slim
python
https://github.com/fy0/slim/blob/9951a910750888dbe7dd3e98acae9c40efae0689/slim/base/sqlquery.py#L221-L232
[ "def", "parse_select", "(", "cls", ",", "text", ":", "str", ")", "->", "Set", ":", "if", "text", "==", "'*'", ":", "return", "ALL_COLUMNS", "# None means ALL", "selected_columns", "=", "set", "(", "filter", "(", "lambda", "x", ":", "x", ",", "map", "("...
9951a910750888dbe7dd3e98acae9c40efae0689
valid
SQLQueryInfo.parse_load_fk
:param data:{ <column>: role, <column2>: role, <column>: { 'role': role, 'loadfk': { ... }, }, :return: { <column>: { 'role': role, }, ... <column3>: { ...
slim/base/sqlquery.py
def parse_load_fk(cls, data: Dict[str, List[Dict[str, object]]]) -> Dict[str, List[Dict[str, object]]]: """ :param data:{ <column>: role, <column2>: role, <column>: { 'role': role, 'loadfk': { ... }, }, :return: { ...
def parse_load_fk(cls, data: Dict[str, List[Dict[str, object]]]) -> Dict[str, List[Dict[str, object]]]: """ :param data:{ <column>: role, <column2>: role, <column>: { 'role': role, 'loadfk': { ... }, }, :return: { ...
[ ":", "param", "data", ":", "{", "<column", ">", ":", "role", "<column2", ">", ":", "role", "<column", ">", ":", "{", "role", ":", "role", "loadfk", ":", "{", "...", "}", "}", ":", "return", ":", "{", "<column", ">", ":", "{", "role", ":", "role...
fy0/slim
python
https://github.com/fy0/slim/blob/9951a910750888dbe7dd3e98acae9c40efae0689/slim/base/sqlquery.py#L235-L296
[ "def", "parse_load_fk", "(", "cls", ",", "data", ":", "Dict", "[", "str", ",", "List", "[", "Dict", "[", "str", ",", "object", "]", "]", "]", ")", "->", "Dict", "[", "str", ",", "List", "[", "Dict", "[", "str", ",", "object", "]", "]", "]", "...
9951a910750888dbe7dd3e98acae9c40efae0689
valid
SQLQueryInfo.add_condition
Add a query condition and validate it. raise ParamsException if failed. self.view required :param field_name: :param op: :param value: :return: None
slim/base/sqlquery.py
def add_condition(self, field_name, op, value): """ Add a query condition and validate it. raise ParamsException if failed. self.view required :param field_name: :param op: :param value: :return: None """ if not isinstance(op, SQL_OP): ...
def add_condition(self, field_name, op, value): """ Add a query condition and validate it. raise ParamsException if failed. self.view required :param field_name: :param op: :param value: :return: None """ if not isinstance(op, SQL_OP): ...
[ "Add", "a", "query", "condition", "and", "validate", "it", ".", "raise", "ParamsException", "if", "failed", ".", "self", ".", "view", "required", ":", "param", "field_name", ":", ":", "param", "op", ":", ":", "param", "value", ":", ":", "return", ":", ...
fy0/slim
python
https://github.com/fy0/slim/blob/9951a910750888dbe7dd3e98acae9c40efae0689/slim/base/sqlquery.py#L298-L313
[ "def", "add_condition", "(", "self", ",", "field_name", ",", "op", ",", "value", ")", ":", "if", "not", "isinstance", "(", "op", ",", "SQL_OP", ")", ":", "if", "op", "not", "in", "SQL_OP", ".", "txt2op", ":", "raise", "SQLOperatorInvalid", "(", "op", ...
9951a910750888dbe7dd3e98acae9c40efae0689
valid
_packb2
Serialize a Python object into MessagePack bytes. Args: obj: a Python object Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping a custom type to a callable that packs an instance of the type into an Ext object forc...
slim/utils/umsgpack.py
def _packb2(obj, **options): """ Serialize a Python object into MessagePack bytes. Args: obj: a Python object Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping a custom type to a callable that packs an instance of the type ...
def _packb2(obj, **options): """ Serialize a Python object into MessagePack bytes. Args: obj: a Python object Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping a custom type to a callable that packs an instance of the type ...
[ "Serialize", "a", "Python", "object", "into", "MessagePack", "bytes", "." ]
fy0/slim
python
https://github.com/fy0/slim/blob/9951a910750888dbe7dd3e98acae9c40efae0689/slim/utils/umsgpack.py#L545-L575
[ "def", "_packb2", "(", "obj", ",", "*", "*", "options", ")", ":", "fp", "=", "io", ".", "BytesIO", "(", ")", "_pack2", "(", "obj", ",", "fp", ",", "*", "*", "options", ")", "return", "fp", ".", "getvalue", "(", ")" ]
9951a910750888dbe7dd3e98acae9c40efae0689
valid
_packb3
Serialize a Python object into MessagePack bytes. Args: obj: a Python object Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping a custom type to a callable that packs an instance of the type into an Ext object forc...
slim/utils/umsgpack.py
def _packb3(obj, **options): """ Serialize a Python object into MessagePack bytes. Args: obj: a Python object Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping a custom type to a callable that packs an instance of the type ...
def _packb3(obj, **options): """ Serialize a Python object into MessagePack bytes. Args: obj: a Python object Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping a custom type to a callable that packs an instance of the type ...
[ "Serialize", "a", "Python", "object", "into", "MessagePack", "bytes", "." ]
fy0/slim
python
https://github.com/fy0/slim/blob/9951a910750888dbe7dd3e98acae9c40efae0689/slim/utils/umsgpack.py#L578-L608
[ "def", "_packb3", "(", "obj", ",", "*", "*", "options", ")", ":", "fp", "=", "io", ".", "BytesIO", "(", ")", "_pack3", "(", "obj", ",", "fp", ",", "*", "*", "options", ")", "return", "fp", ".", "getvalue", "(", ")" ]
9951a910750888dbe7dd3e98acae9c40efae0689
valid
_unpackb2
Deserialize MessagePack bytes into a Python object. Args: s: a 'str' or 'bytearray' containing serialized MessagePack bytes Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping integer Ext type to a callable that unpacks an instance of ...
slim/utils/umsgpack.py
def _unpackb2(s, **options): """ Deserialize MessagePack bytes into a Python object. Args: s: a 'str' or 'bytearray' containing serialized MessagePack bytes Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping integer Ext type to a callable that...
def _unpackb2(s, **options): """ Deserialize MessagePack bytes into a Python object. Args: s: a 'str' or 'bytearray' containing serialized MessagePack bytes Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping integer Ext type to a callable that...
[ "Deserialize", "MessagePack", "bytes", "into", "a", "Python", "object", "." ]
fy0/slim
python
https://github.com/fy0/slim/blob/9951a910750888dbe7dd3e98acae9c40efae0689/slim/utils/umsgpack.py#L927-L971
[ "def", "_unpackb2", "(", "s", ",", "*", "*", "options", ")", ":", "if", "not", "isinstance", "(", "s", ",", "(", "str", ",", "bytearray", ")", ")", ":", "raise", "TypeError", "(", "\"packed data must be type 'str' or 'bytearray'\"", ")", "return", "_unpack",...
9951a910750888dbe7dd3e98acae9c40efae0689
valid
_unpackb3
Deserialize MessagePack bytes into a Python object. Args: s: a 'bytes' or 'bytearray' containing serialized MessagePack bytes Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping integer Ext type to a callable that unpacks an instance of ...
slim/utils/umsgpack.py
def _unpackb3(s, **options): """ Deserialize MessagePack bytes into a Python object. Args: s: a 'bytes' or 'bytearray' containing serialized MessagePack bytes Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping integer Ext type to a callable th...
def _unpackb3(s, **options): """ Deserialize MessagePack bytes into a Python object. Args: s: a 'bytes' or 'bytearray' containing serialized MessagePack bytes Kwargs: ext_handlers (dict): dictionary of Ext handlers, mapping integer Ext type to a callable th...
[ "Deserialize", "MessagePack", "bytes", "into", "a", "Python", "object", "." ]
fy0/slim
python
https://github.com/fy0/slim/blob/9951a910750888dbe7dd3e98acae9c40efae0689/slim/utils/umsgpack.py#L975-L1019
[ "def", "_unpackb3", "(", "s", ",", "*", "*", "options", ")", ":", "if", "not", "isinstance", "(", "s", ",", "(", "bytes", ",", "bytearray", ")", ")", ":", "raise", "TypeError", "(", "\"packed data must be type 'bytes' or 'bytearray'\"", ")", "return", "_unpa...
9951a910750888dbe7dd3e98acae9c40efae0689
valid
view_bind
将 API 绑定到 web 服务上 :param view_cls: :param app: :param cls_url: :return:
slim/base/route.py
def view_bind(app, cls_url, view_cls: Type['BaseView']): """ 将 API 绑定到 web 服务上 :param view_cls: :param app: :param cls_url: :return: """ if view_cls._no_route: return cls_url = cls_url or view_cls.__class__.__name__.lower() def add_route(name, route_info, beacon_info): f...
def view_bind(app, cls_url, view_cls: Type['BaseView']): """ 将 API 绑定到 web 服务上 :param view_cls: :param app: :param cls_url: :return: """ if view_cls._no_route: return cls_url = cls_url or view_cls.__class__.__name__.lower() def add_route(name, route_info, beacon_info): f...
[ "将", "API", "绑定到", "web", "服务上", ":", "param", "view_cls", ":", ":", "param", "app", ":", ":", "param", "cls_url", ":", ":", "return", ":" ]
fy0/slim
python
https://github.com/fy0/slim/blob/9951a910750888dbe7dd3e98acae9c40efae0689/slim/base/route.py#L55-L89
[ "def", "view_bind", "(", "app", ",", "cls_url", ",", "view_cls", ":", "Type", "[", "'BaseView'", "]", ")", ":", "if", "view_cls", ".", "_no_route", ":", "return", "cls_url", "=", "cls_url", "or", "view_cls", ".", "__class__", ".", "__name__", ".", "lower...
9951a910750888dbe7dd3e98acae9c40efae0689
valid
Route.add_static
:param prefix: URL prefix :param path: file directory :param kwargs: :return:
slim/base/route.py
def add_static(self, prefix, path, **kwargs): """ :param prefix: URL prefix :param path: file directory :param kwargs: :return: """ self.statics.append((prefix, path, kwargs),)
def add_static(self, prefix, path, **kwargs): """ :param prefix: URL prefix :param path: file directory :param kwargs: :return: """ self.statics.append((prefix, path, kwargs),)
[ ":", "param", "prefix", ":", "URL", "prefix", ":", "param", "path", ":", "file", "directory", ":", "param", "kwargs", ":", ":", "return", ":" ]
fy0/slim
python
https://github.com/fy0/slim/blob/9951a910750888dbe7dd3e98acae9c40efae0689/slim/base/route.py#L144-L151
[ "def", "add_static", "(", "self", ",", "prefix", ",", "path", ",", "*", "*", "kwargs", ")", ":", "self", ".", "statics", ".", "append", "(", "(", "prefix", ",", "path", ",", "kwargs", ")", ",", ")" ]
9951a910750888dbe7dd3e98acae9c40efae0689
valid
parse_query_by_json
['and', ['==', 't1', 'col1', val1], ['!=', 't1', 'col2', 't2', 'col2'], ['and', ['==', 't1', 'col3', val3], ['!=', 't2', 'col4', val4], ] ] :return: :param data: :return:
slim/support/asyncpg/query.py
def parse_query_by_json(data): """ ['and', ['==', 't1', 'col1', val1], ['!=', 't1', 'col2', 't2', 'col2'], ['and', ['==', 't1', 'col3', val3], ['!=', 't2', 'col4', val4], ] ] :return: :param data: :return: """ data = json.loads(da...
def parse_query_by_json(data): """ ['and', ['==', 't1', 'col1', val1], ['!=', 't1', 'col2', 't2', 'col2'], ['and', ['==', 't1', 'col3', val3], ['!=', 't2', 'col4', val4], ] ] :return: :param data: :return: """ data = json.loads(da...
[ "[", "and", "[", "==", "t1", "col1", "val1", "]", "[", "!", "=", "t1", "col2", "t2", "col2", "]", "[", "and", "[", "==", "t1", "col3", "val3", "]", "[", "!", "=", "t2", "col4", "val4", "]", "]", "]", ":", "return", ":", ":", "param", "data"...
fy0/slim
python
https://github.com/fy0/slim/blob/9951a910750888dbe7dd3e98acae9c40efae0689/slim/support/asyncpg/query.py#L518-L583
[ "def", "parse_query_by_json", "(", "data", ")", ":", "data", "=", "json", ".", "loads", "(", "data", ")", "for", "i", "in", "(", "'tables'", ",", "'columns'", ",", "'conditions'", ")", ":", "if", "i", "not", "in", "data", ":", "raise", "QueryException"...
9951a910750888dbe7dd3e98acae9c40efae0689
valid
validate
Config option name value validator decorator.
grappa/config.py
def validate(method): """ Config option name value validator decorator. """ # Name error template name_error = 'configuration option "{}" is not supported' @functools.wraps(method) def validator(self, name, *args): if name not in self.allowed_opts: raise ValueError(name_...
def validate(method): """ Config option name value validator decorator. """ # Name error template name_error = 'configuration option "{}" is not supported' @functools.wraps(method) def validator(self, name, *args): if name not in self.allowed_opts: raise ValueError(name_...
[ "Config", "option", "name", "value", "validator", "decorator", "." ]
grappa-py/grappa
python
https://github.com/grappa-py/grappa/blob/b128da8aef67501c310701c47508e7318241aa8b/grappa/config.py#L8-L20
[ "def", "validate", "(", "method", ")", ":", "# Name error template", "name_error", "=", "'configuration option \"{}\" is not supported'", "@", "functools", ".", "wraps", "(", "method", ")", "def", "validator", "(", "self", ",", "name", ",", "*", "args", ")", ":"...
b128da8aef67501c310701c47508e7318241aa8b
valid
Runner.run
Runs the current phase.
grappa/runner.py
def run(self, ctx): """ Runs the current phase. """ # Reverse engine assertion if needed if ctx.reverse: self.engine.reverse() if self.engine.empty: raise AssertionError('grappa: no assertions to run') try: # Run assertion in ...
def run(self, ctx): """ Runs the current phase. """ # Reverse engine assertion if needed if ctx.reverse: self.engine.reverse() if self.engine.empty: raise AssertionError('grappa: no assertions to run') try: # Run assertion in ...
[ "Runs", "the", "current", "phase", "." ]
grappa-py/grappa
python
https://github.com/grappa-py/grappa/blob/b128da8aef67501c310701c47508e7318241aa8b/grappa/runner.py#L49-L68
[ "def", "run", "(", "self", ",", "ctx", ")", ":", "# Reverse engine assertion if needed", "if", "ctx", ".", "reverse", ":", "self", ".", "engine", ".", "reverse", "(", ")", "if", "self", ".", "engine", ".", "empty", ":", "raise", "AssertionError", "(", "'...
b128da8aef67501c310701c47508e7318241aa8b
valid
Operator.observe
Internal decorator to trigger operator hooks before/after matcher execution.
grappa/operator.py
def observe(matcher): """ Internal decorator to trigger operator hooks before/after matcher execution. """ @functools.wraps(matcher) def observer(self, subject, *expected, **kw): # Trigger before hook, if present if hasattr(self, 'before'): ...
def observe(matcher): """ Internal decorator to trigger operator hooks before/after matcher execution. """ @functools.wraps(matcher) def observer(self, subject, *expected, **kw): # Trigger before hook, if present if hasattr(self, 'before'): ...
[ "Internal", "decorator", "to", "trigger", "operator", "hooks", "before", "/", "after", "matcher", "execution", "." ]
grappa-py/grappa
python
https://github.com/grappa-py/grappa/blob/b128da8aef67501c310701c47508e7318241aa8b/grappa/operator.py#L128-L158
[ "def", "observe", "(", "matcher", ")", ":", "@", "functools", ".", "wraps", "(", "matcher", ")", "def", "observer", "(", "self", ",", "subject", ",", "*", "expected", ",", "*", "*", "kw", ")", ":", "# Trigger before hook, if present", "if", "hasattr", "(...
b128da8aef67501c310701c47508e7318241aa8b
valid
Operator.run_matcher
Runs the operator matcher test function.
grappa/operator.py
def run_matcher(self, subject, *expected, **kw): """ Runs the operator matcher test function. """ # Update assertion expectation self.expected = expected _args = (subject,) if self.kind == OperatorTypes.MATCHER: _args += expected try: ...
def run_matcher(self, subject, *expected, **kw): """ Runs the operator matcher test function. """ # Update assertion expectation self.expected = expected _args = (subject,) if self.kind == OperatorTypes.MATCHER: _args += expected try: ...
[ "Runs", "the", "operator", "matcher", "test", "function", "." ]
grappa-py/grappa
python
https://github.com/grappa-py/grappa/blob/b128da8aef67501c310701c47508e7318241aa8b/grappa/operator.py#L168-L194
[ "def", "run_matcher", "(", "self", ",", "subject", ",", "*", "expected", ",", "*", "*", "kw", ")", ":", "# Update assertion expectation", "self", ".", "expected", "=", "expected", "_args", "=", "(", "subject", ",", ")", "if", "self", ".", "kind", "==", ...
b128da8aef67501c310701c47508e7318241aa8b
valid
Operator.run
Runs the current operator with the subject arguments to test. This method is implemented by matchers only.
grappa/operator.py
def run(self, *args, **kw): """ Runs the current operator with the subject arguments to test. This method is implemented by matchers only. """ log.debug('[operator] run "{}" with arguments: {}'.format( self.__class__.__name__, args )) if self.kind ==...
def run(self, *args, **kw): """ Runs the current operator with the subject arguments to test. This method is implemented by matchers only. """ log.debug('[operator] run "{}" with arguments: {}'.format( self.__class__.__name__, args )) if self.kind ==...
[ "Runs", "the", "current", "operator", "with", "the", "subject", "arguments", "to", "test", "." ]
grappa-py/grappa
python
https://github.com/grappa-py/grappa/blob/b128da8aef67501c310701c47508e7318241aa8b/grappa/operator.py#L196-L209
[ "def", "run", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "log", ".", "debug", "(", "'[operator] run \"{}\" with arguments: {}'", ".", "format", "(", "self", ".", "__class__", ".", "__name__", ",", "args", ")", ")", "if", "self", ".",...
b128da8aef67501c310701c47508e7318241aa8b
valid
operator
Registers a new operator function in the test engine. Arguments: *args: variadic arguments. **kw: variadic keyword arguments. Returns: function
grappa/decorators.py
def operator(name=None, operators=None, aliases=None, kind=None): """ Registers a new operator function in the test engine. Arguments: *args: variadic arguments. **kw: variadic keyword arguments. Returns: function """ def delegator(assertion, subject, expected, *args, *...
def operator(name=None, operators=None, aliases=None, kind=None): """ Registers a new operator function in the test engine. Arguments: *args: variadic arguments. **kw: variadic keyword arguments. Returns: function """ def delegator(assertion, subject, expected, *args, *...
[ "Registers", "a", "new", "operator", "function", "in", "the", "test", "engine", "." ]
grappa-py/grappa
python
https://github.com/grappa-py/grappa/blob/b128da8aef67501c310701c47508e7318241aa8b/grappa/decorators.py#L17-L47
[ "def", "operator", "(", "name", "=", "None", ",", "operators", "=", "None", ",", "aliases", "=", "None", ",", "kind", "=", "None", ")", ":", "def", "delegator", "(", "assertion", ",", "subject", ",", "expected", ",", "*", "args", ",", "*", "*", "kw...
b128da8aef67501c310701c47508e7318241aa8b
valid
attribute
Registers a new attribute only operator function in the test engine. Arguments: *args: variadic arguments. **kw: variadic keyword arguments. Returns: function
grappa/decorators.py
def attribute(*args, **kw): """ Registers a new attribute only operator function in the test engine. Arguments: *args: variadic arguments. **kw: variadic keyword arguments. Returns: function """ return operator(kind=Operator.Type.ATTRIBUTE, *args, **kw)
def attribute(*args, **kw): """ Registers a new attribute only operator function in the test engine. Arguments: *args: variadic arguments. **kw: variadic keyword arguments. Returns: function """ return operator(kind=Operator.Type.ATTRIBUTE, *args, **kw)
[ "Registers", "a", "new", "attribute", "only", "operator", "function", "in", "the", "test", "engine", "." ]
grappa-py/grappa
python
https://github.com/grappa-py/grappa/blob/b128da8aef67501c310701c47508e7318241aa8b/grappa/decorators.py#L50-L61
[ "def", "attribute", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "return", "operator", "(", "kind", "=", "Operator", ".", "Type", ".", "ATTRIBUTE", ",", "*", "args", ",", "*", "*", "kw", ")" ]
b128da8aef67501c310701c47508e7318241aa8b
valid
use
Register plugin in grappa. `plugin` argument can be a function or a object that implement `register` method, which should accept one argument: `grappa.Engine` instance. Arguments: plugin (function|module): grappa plugin object to register. Raises: ValueError: if `plugin` is not a vali...
grappa/plugin.py
def use(plugin): """ Register plugin in grappa. `plugin` argument can be a function or a object that implement `register` method, which should accept one argument: `grappa.Engine` instance. Arguments: plugin (function|module): grappa plugin object to register. Raises: ValueErr...
def use(plugin): """ Register plugin in grappa. `plugin` argument can be a function or a object that implement `register` method, which should accept one argument: `grappa.Engine` instance. Arguments: plugin (function|module): grappa plugin object to register. Raises: ValueErr...
[ "Register", "plugin", "in", "grappa", "." ]
grappa-py/grappa
python
https://github.com/grappa-py/grappa/blob/b128da8aef67501c310701c47508e7318241aa8b/grappa/plugin.py#L8-L42
[ "def", "use", "(", "plugin", ")", ":", "log", ".", "debug", "(", "'register new plugin: {}'", ".", "format", "(", "plugin", ")", ")", "if", "inspect", ".", "isfunction", "(", "plugin", ")", ":", "return", "plugin", "(", "Engine", ")", "if", "plugin", "...
b128da8aef67501c310701c47508e7318241aa8b
valid
load
Loads the built-in operators into the global test engine.
grappa/operators/__init__.py
def load(): """ Loads the built-in operators into the global test engine. """ for operator in operators: module, symbols = operator[0], operator[1:] path = 'grappa.operators.{}'.format(module) # Dynamically import modules operator = __import__(path, None, None, symbols) ...
def load(): """ Loads the built-in operators into the global test engine. """ for operator in operators: module, symbols = operator[0], operator[1:] path = 'grappa.operators.{}'.format(module) # Dynamically import modules operator = __import__(path, None, None, symbols) ...
[ "Loads", "the", "built", "-", "in", "operators", "into", "the", "global", "test", "engine", "." ]
grappa-py/grappa
python
https://github.com/grappa-py/grappa/blob/b128da8aef67501c310701c47508e7318241aa8b/grappa/operators/__init__.py#L38-L51
[ "def", "load", "(", ")", ":", "for", "operator", "in", "operators", ":", "module", ",", "symbols", "=", "operator", "[", "0", "]", ",", "operator", "[", "1", ":", "]", "path", "=", "'grappa.operators.{}'", ".", "format", "(", "module", ")", "# Dynamica...
b128da8aef67501c310701c47508e7318241aa8b
valid
register_operators
Registers one or multiple operators in the test engine.
grappa/engine.py
def register_operators(*operators): """ Registers one or multiple operators in the test engine. """ def validate(operator): if isoperator(operator): return True raise NotImplementedError('invalid operator: {}'.format(operator)) def register(operator): # Register...
def register_operators(*operators): """ Registers one or multiple operators in the test engine. """ def validate(operator): if isoperator(operator): return True raise NotImplementedError('invalid operator: {}'.format(operator)) def register(operator): # Register...
[ "Registers", "one", "or", "multiple", "operators", "in", "the", "test", "engine", "." ]
grappa-py/grappa
python
https://github.com/grappa-py/grappa/blob/b128da8aef67501c310701c47508e7318241aa8b/grappa/engine.py#L18-L43
[ "def", "register_operators", "(", "*", "operators", ")", ":", "def", "validate", "(", "operator", ")", ":", "if", "isoperator", "(", "operator", ")", ":", "return", "True", "raise", "NotImplementedError", "(", "'invalid operator: {}'", ".", "format", "(", "ope...
b128da8aef67501c310701c47508e7318241aa8b
valid
BusFinder.find_address_file
Finds the OMXPlayer DBus connection Assumes there is an alive OMXPlayer process. :return:
omxplayer/bus_finder.py
def find_address_file(self): """ Finds the OMXPlayer DBus connection Assumes there is an alive OMXPlayer process. :return: """ possible_address_files = [] while not possible_address_files: # filter is used here as glob doesn't support regexp :( ...
def find_address_file(self): """ Finds the OMXPlayer DBus connection Assumes there is an alive OMXPlayer process. :return: """ possible_address_files = [] while not possible_address_files: # filter is used here as glob doesn't support regexp :( ...
[ "Finds", "the", "OMXPlayer", "DBus", "connection", "Assumes", "there", "is", "an", "alive", "OMXPlayer", "process", ".", ":", "return", ":" ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/bus_finder.py#L24-L39
[ "def", "find_address_file", "(", "self", ")", ":", "possible_address_files", "=", "[", "]", "while", "not", "possible_address_files", ":", "# filter is used here as glob doesn't support regexp :(", "isnt_pid_file", "=", "lambda", "path", ":", "not", "path", ".", "endswi...
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.load
Loads a new source (as a file) from ``source`` (a file path or URL) by killing the current ``omxplayer`` process and forking a new one. Args: source (string): Path to the file to play or URL
omxplayer/player.py
def load(self, source, pause=False): """ Loads a new source (as a file) from ``source`` (a file path or URL) by killing the current ``omxplayer`` process and forking a new one. Args: source (string): Path to the file to play or URL """ self._source = source ...
def load(self, source, pause=False): """ Loads a new source (as a file) from ``source`` (a file path or URL) by killing the current ``omxplayer`` process and forking a new one. Args: source (string): Path to the file to play or URL """ self._source = source ...
[ "Loads", "a", "new", "source", "(", "as", "a", "file", ")", "from", "source", "(", "a", "file", "path", "or", "URL", ")", "by", "killing", "the", "current", "omxplayer", "process", "and", "forking", "a", "new", "one", "." ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L228-L240
[ "def", "load", "(", "self", ",", "source", ",", "pause", "=", "False", ")", ":", "self", ".", "_source", "=", "source", "self", ".", "_load_source", "(", "source", ")", "if", "pause", ":", "time", ".", "sleep", "(", "0.5", ")", "# Wait for the DBus int...
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.set_volume
Args: float: volume in the interval [0, 10]
omxplayer/player.py
def set_volume(self, volume): """ Args: float: volume in the interval [0, 10] """ # 0 isn't handled correctly so we have to set it to a very small value to achieve the same purpose if volume == 0: volume = 1e-10 return self._player_interface_proper...
def set_volume(self, volume): """ Args: float: volume in the interval [0, 10] """ # 0 isn't handled correctly so we have to set it to a very small value to achieve the same purpose if volume == 0: volume = 1e-10 return self._player_interface_proper...
[ "Args", ":", "float", ":", "volume", "in", "the", "interval", "[", "0", "10", "]" ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L382-L390
[ "def", "set_volume", "(", "self", ",", "volume", ")", ":", "# 0 isn't handled correctly so we have to set it to a very small value to achieve the same purpose", "if", "volume", "==", "0", ":", "volume", "=", "1e-10", "return", "self", ".", "_player_interface_property", "(",...
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.set_rate
Set the playback rate of the video as a multiple of the default playback speed Examples: >>> player.set_rate(2) # Will play twice as fast as normal speed >>> player.set_rate(0.5) # Will play half speed
omxplayer/player.py
def set_rate(self, rate): """ Set the playback rate of the video as a multiple of the default playback speed Examples: >>> player.set_rate(2) # Will play twice as fast as normal speed >>> player.set_rate(0.5) # Will play half speed """ ...
def set_rate(self, rate): """ Set the playback rate of the video as a multiple of the default playback speed Examples: >>> player.set_rate(2) # Will play twice as fast as normal speed >>> player.set_rate(0.5) # Will play half speed """ ...
[ "Set", "the", "playback", "rate", "of", "the", "video", "as", "a", "multiple", "of", "the", "default", "playback", "speed" ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L437-L448
[ "def", "set_rate", "(", "self", ",", "rate", ")", ":", "self", ".", "_rate", "=", "self", ".", "_player_interface_property", "(", "'Rate'", ",", "dbus", ".", "Double", "(", "rate", ")", ")", "return", "self", ".", "_rate" ]
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.pause
Pause playback
omxplayer/player.py
def pause(self): """ Pause playback """ self._player_interface.Pause() self._is_playing = False self.pauseEvent(self)
def pause(self): """ Pause playback """ self._player_interface.Pause() self._is_playing = False self.pauseEvent(self)
[ "Pause", "playback" ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L524-L530
[ "def", "pause", "(", "self", ")", ":", "self", ".", "_player_interface", ".", "Pause", "(", ")", "self", ".", "_is_playing", "=", "False", "self", ".", "pauseEvent", "(", "self", ")" ]
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.play_pause
Pause playback if currently playing, otherwise start playing if currently paused.
omxplayer/player.py
def play_pause(self): """ Pause playback if currently playing, otherwise start playing if currently paused. """ self._player_interface.PlayPause() self._is_playing = not self._is_playing if self._is_playing: self.playEvent(self) else: self....
def play_pause(self): """ Pause playback if currently playing, otherwise start playing if currently paused. """ self._player_interface.PlayPause() self._is_playing = not self._is_playing if self._is_playing: self.playEvent(self) else: self....
[ "Pause", "playback", "if", "currently", "playing", "otherwise", "start", "playing", "if", "currently", "paused", "." ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L533-L542
[ "def", "play_pause", "(", "self", ")", ":", "self", ".", "_player_interface", ".", "PlayPause", "(", ")", "self", ".", "_is_playing", "=", "not", "self", ".", "_is_playing", "if", "self", ".", "_is_playing", ":", "self", ".", "playEvent", "(", "self", ")...
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.seek
Seek the video by `relative_position` seconds Args: relative_position (float): The position in seconds to seek to.
omxplayer/player.py
def seek(self, relative_position): """ Seek the video by `relative_position` seconds Args: relative_position (float): The position in seconds to seek to. """ self._player_interface.Seek(Int64(1000.0 * 1000 * relative_position)) self.seekEvent(self, relative_p...
def seek(self, relative_position): """ Seek the video by `relative_position` seconds Args: relative_position (float): The position in seconds to seek to. """ self._player_interface.Seek(Int64(1000.0 * 1000 * relative_position)) self.seekEvent(self, relative_p...
[ "Seek", "the", "video", "by", "relative_position", "seconds" ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L555-L563
[ "def", "seek", "(", "self", ",", "relative_position", ")", ":", "self", ".", "_player_interface", ".", "Seek", "(", "Int64", "(", "1000.0", "*", "1000", "*", "relative_position", ")", ")", "self", ".", "seekEvent", "(", "self", ",", "relative_position", ")...
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.set_position
Set the video to playback position to `position` seconds from the start of the video Args: position (float): The position in seconds.
omxplayer/player.py
def set_position(self, position): """ Set the video to playback position to `position` seconds from the start of the video Args: position (float): The position in seconds. """ self._player_interface.SetPosition(ObjectPath("/not/used"), Int64(position * 1000.0 * 1000)...
def set_position(self, position): """ Set the video to playback position to `position` seconds from the start of the video Args: position (float): The position in seconds. """ self._player_interface.SetPosition(ObjectPath("/not/used"), Int64(position * 1000.0 * 1000)...
[ "Set", "the", "video", "to", "playback", "position", "to", "position", "seconds", "from", "the", "start", "of", "the", "video" ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L567-L575
[ "def", "set_position", "(", "self", ",", "position", ")", ":", "self", ".", "_player_interface", ".", "SetPosition", "(", "ObjectPath", "(", "\"/not/used\"", ")", ",", "Int64", "(", "position", "*", "1000.0", "*", "1000", ")", ")", "self", ".", "positionEv...
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.set_video_pos
Set the video position on the screen Args: x1 (int): Top left x coordinate (px) y1 (int): Top left y coordinate (px) x2 (int): Bottom right x coordinate (px) y2 (int): Bottom right y coordinate (px)
omxplayer/player.py
def set_video_pos(self, x1, y1, x2, y2): """ Set the video position on the screen Args: x1 (int): Top left x coordinate (px) y1 (int): Top left y coordinate (px) x2 (int): Bottom right x coordinate (px) y2 (int): Bottom right y coordinate (px) ...
def set_video_pos(self, x1, y1, x2, y2): """ Set the video position on the screen Args: x1 (int): Top left x coordinate (px) y1 (int): Top left y coordinate (px) x2 (int): Bottom right x coordinate (px) y2 (int): Bottom right y coordinate (px) ...
[ "Set", "the", "video", "position", "on", "the", "screen" ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L618-L629
[ "def", "set_video_pos", "(", "self", ",", "x1", ",", "y1", ",", "x2", ",", "y2", ")", ":", "position", "=", "\"%s %s %s %s\"", "%", "(", "str", "(", "x1", ")", ",", "str", "(", "y1", ")", ",", "str", "(", "x2", ")", ",", "str", "(", "y2", ")"...
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.video_pos
Returns: (int, int, int, int): Video spatial position (x1, y1, x2, y2) where (x1, y1) is top left, and (x2, y2) is bottom right. All values in px.
omxplayer/player.py
def video_pos(self): """ Returns: (int, int, int, int): Video spatial position (x1, y1, x2, y2) where (x1, y1) is top left, and (x2, y2) is bottom right. All values in px. """ position_string = self._player_interface.VideoPos(ObjectPath('/not...
def video_pos(self): """ Returns: (int, int, int, int): Video spatial position (x1, y1, x2, y2) where (x1, y1) is top left, and (x2, y2) is bottom right. All values in px. """ position_string = self._player_interface.VideoPos(ObjectPath('/not...
[ "Returns", ":", "(", "int", "int", "int", "int", ")", ":", "Video", "spatial", "position", "(", "x1", "y1", "x2", "y2", ")", "where", "(", "x1", "y1", ")", "is", "top", "left", "and", "(", "x2", "y2", ")", "is", "bottom", "right", ".", "All", "...
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L632-L639
[ "def", "video_pos", "(", "self", ")", ":", "position_string", "=", "self", ".", "_player_interface", ".", "VideoPos", "(", "ObjectPath", "(", "'/not/used'", ")", ")", "return", "list", "(", "map", "(", "int", ",", "position_string", ".", "split", "(", "\" ...
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.set_video_crop
Args: x1 (int): Top left x coordinate (px) y1 (int): Top left y coordinate (px) x2 (int): Bottom right x coordinate (px) y2 (int): Bottom right y coordinate (px)
omxplayer/player.py
def set_video_crop(self, x1, y1, x2, y2): """ Args: x1 (int): Top left x coordinate (px) y1 (int): Top left y coordinate (px) x2 (int): Bottom right x coordinate (px) y2 (int): Bottom right y coordinate (px) """ crop = "%s %s %s %s" % (str(...
def set_video_crop(self, x1, y1, x2, y2): """ Args: x1 (int): Top left x coordinate (px) y1 (int): Top left y coordinate (px) x2 (int): Bottom right x coordinate (px) y2 (int): Bottom right y coordinate (px) """ crop = "%s %s %s %s" % (str(...
[ "Args", ":", "x1", "(", "int", ")", ":", "Top", "left", "x", "coordinate", "(", "px", ")", "y1", "(", "int", ")", ":", "Top", "left", "y", "coordinate", "(", "px", ")", "x2", "(", "int", ")", ":", "Bottom", "right", "x", "coordinate", "(", "px"...
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L643-L652
[ "def", "set_video_crop", "(", "self", ",", "x1", ",", "y1", ",", "x2", ",", "y2", ")", ":", "crop", "=", "\"%s %s %s %s\"", "%", "(", "str", "(", "x1", ")", ",", "str", "(", "y1", ")", ",", "str", "(", "x2", ")", ",", "str", "(", "y2", ")", ...
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.is_playing
Returns: bool: Whether the player is playing
omxplayer/player.py
def is_playing(self): """ Returns: bool: Whether the player is playing """ self._is_playing = (self.playback_status() == "Playing") logger.info("Playing?: %s" % self._is_playing) return self._is_playing
def is_playing(self): """ Returns: bool: Whether the player is playing """ self._is_playing = (self.playback_status() == "Playing") logger.info("Playing?: %s" % self._is_playing) return self._is_playing
[ "Returns", ":", "bool", ":", "Whether", "the", "player", "is", "playing" ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L747-L754
[ "def", "is_playing", "(", "self", ")", ":", "self", ".", "_is_playing", "=", "(", "self", ".", "playback_status", "(", ")", "==", "\"Playing\"", ")", "logger", ".", "info", "(", "\"Playing?: %s\"", "%", "self", ".", "_is_playing", ")", "return", "self", ...
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.play_sync
Play the video and block whilst the video is playing
omxplayer/player.py
def play_sync(self): """ Play the video and block whilst the video is playing """ self.play() logger.info("Playing synchronously") try: time.sleep(0.05) logger.debug("Wait for playing to start") while self.is_playing(): ...
def play_sync(self): """ Play the video and block whilst the video is playing """ self.play() logger.info("Playing synchronously") try: time.sleep(0.05) logger.debug("Wait for playing to start") while self.is_playing(): ...
[ "Play", "the", "video", "and", "block", "whilst", "the", "video", "is", "playing" ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L758-L772
[ "def", "play_sync", "(", "self", ")", ":", "self", ".", "play", "(", ")", "logger", ".", "info", "(", "\"Playing synchronously\"", ")", "try", ":", "time", ".", "sleep", "(", "0.05", ")", "logger", ".", "debug", "(", "\"Wait for playing to start\"", ")", ...
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.play
Play the video asynchronously returning control immediately to the calling code
omxplayer/player.py
def play(self): """ Play the video asynchronously returning control immediately to the calling code """ if not self.is_playing(): self.play_pause() self._is_playing = True self.playEvent(self)
def play(self): """ Play the video asynchronously returning control immediately to the calling code """ if not self.is_playing(): self.play_pause() self._is_playing = True self.playEvent(self)
[ "Play", "the", "video", "asynchronously", "returning", "control", "immediately", "to", "the", "calling", "code" ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L776-L783
[ "def", "play", "(", "self", ")", ":", "if", "not", "self", ".", "is_playing", "(", ")", ":", "self", ".", "play_pause", "(", ")", "self", ".", "_is_playing", "=", "True", "self", ".", "playEvent", "(", "self", ")" ]
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
OMXPlayer.quit
Quit the player, blocking until the process has died
omxplayer/player.py
def quit(self): """ Quit the player, blocking until the process has died """ if self._process is None: logger.debug('Quit was called after self._process had already been released') return try: logger.debug('Quitting OMXPlayer') proc...
def quit(self): """ Quit the player, blocking until the process has died """ if self._process is None: logger.debug('Quit was called after self._process had already been released') return try: logger.debug('Quitting OMXPlayer') proc...
[ "Quit", "the", "player", "blocking", "until", "the", "process", "has", "died" ]
willprice/python-omxplayer-wrapper
python
https://github.com/willprice/python-omxplayer-wrapper/blob/f242cb391f0fd07be2d9211c13ebe72fbc628fa3/omxplayer/player.py#L831-L847
[ "def", "quit", "(", "self", ")", ":", "if", "self", ".", "_process", "is", "None", ":", "logger", ".", "debug", "(", "'Quit was called after self._process had already been released'", ")", "return", "try", ":", "logger", ".", "debug", "(", "'Quitting OMXPlayer'", ...
f242cb391f0fd07be2d9211c13ebe72fbc628fa3
valid
BlogDetailView.render_to_response
Returns a response with a template depending if the request is ajax or not and it renders with the given context.
simpleblog/views.py
def render_to_response(self, context, **response_kwargs): """ Returns a response with a template depending if the request is ajax or not and it renders with the given context. """ if self.request.is_ajax(): template = self.page_template else: temp...
def render_to_response(self, context, **response_kwargs): """ Returns a response with a template depending if the request is ajax or not and it renders with the given context. """ if self.request.is_ajax(): template = self.page_template else: temp...
[ "Returns", "a", "response", "with", "a", "template", "depending", "if", "the", "request", "is", "ajax", "or", "not", "and", "it", "renders", "with", "the", "given", "context", "." ]
drager/django-simple-blog
python
https://github.com/drager/django-simple-blog/blob/8f6575c485dc316bc908431fc8bddcae7624e050/simpleblog/views.py#L73-L87
[ "def", "render_to_response", "(", "self", ",", "context", ",", "*", "*", "response_kwargs", ")", ":", "if", "self", ".", "request", ".", "is_ajax", "(", ")", ":", "template", "=", "self", ".", "page_template", "else", ":", "template", "=", "self", ".", ...
8f6575c485dc316bc908431fc8bddcae7624e050
valid
translate_value
Given a document_field and a form_value this will translate the value to the correct result for mongo to use.
mongonaut/utils.py
def translate_value(document_field, form_value): """ Given a document_field and a form_value this will translate the value to the correct result for mongo to use. """ value = form_value if isinstance(document_field, ReferenceField): value = document_field.document_type.objects.get(id=for...
def translate_value(document_field, form_value): """ Given a document_field and a form_value this will translate the value to the correct result for mongo to use. """ value = form_value if isinstance(document_field, ReferenceField): value = document_field.document_type.objects.get(id=for...
[ "Given", "a", "document_field", "and", "a", "form_value", "this", "will", "translate", "the", "value", "to", "the", "correct", "result", "for", "mongo", "to", "use", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/utils.py#L21-L29
[ "def", "translate_value", "(", "document_field", ",", "form_value", ")", ":", "value", "=", "form_value", "if", "isinstance", "(", "document_field", ",", "ReferenceField", ")", ":", "value", "=", "document_field", ".", "document_type", ".", "objects", ".", "get"...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
trim_field_key
Returns the smallest delimited version of field_key that is an attribute on document. return (key, left_over_array)
mongonaut/utils.py
def trim_field_key(document, field_key): """ Returns the smallest delimited version of field_key that is an attribute on document. return (key, left_over_array) """ trimming = True left_over_key_values = [] current_key = field_key while trimming and current_key: if hasattr(d...
def trim_field_key(document, field_key): """ Returns the smallest delimited version of field_key that is an attribute on document. return (key, left_over_array) """ trimming = True left_over_key_values = [] current_key = field_key while trimming and current_key: if hasattr(d...
[ "Returns", "the", "smallest", "delimited", "version", "of", "field_key", "that", "is", "an", "attribute", "on", "document", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/utils.py#L32-L51
[ "def", "trim_field_key", "(", "document", ",", "field_key", ")", ":", "trimming", "=", "True", "left_over_key_values", "=", "[", "]", "current_key", "=", "field_key", "while", "trimming", "and", "current_key", ":", "if", "hasattr", "(", "document", ",", "curre...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
BaseMongoAdmin.has_edit_permission
Can edit this object
mongonaut/sites.py
def has_edit_permission(self, request): """ Can edit this object """ return request.user.is_authenticated and request.user.is_active and request.user.is_staff
def has_edit_permission(self, request): """ Can edit this object """ return request.user.is_authenticated and request.user.is_active and request.user.is_staff
[ "Can", "edit", "this", "object" ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/sites.py#L45-L47
[ "def", "has_edit_permission", "(", "self", ",", "request", ")", ":", "return", "request", ".", "user", ".", "is_authenticated", "and", "request", ".", "user", ".", "is_active", "and", "request", ".", "user", ".", "is_staff" ]
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
BaseMongoAdmin.has_add_permission
Can add this object
mongonaut/sites.py
def has_add_permission(self, request): """ Can add this object """ return request.user.is_authenticated and request.user.is_active and request.user.is_staff
def has_add_permission(self, request): """ Can add this object """ return request.user.is_authenticated and request.user.is_active and request.user.is_staff
[ "Can", "add", "this", "object" ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/sites.py#L49-L51
[ "def", "has_add_permission", "(", "self", ",", "request", ")", ":", "return", "request", ".", "user", ".", "is_authenticated", "and", "request", ".", "user", ".", "is_active", "and", "request", ".", "user", ".", "is_staff" ]
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
BaseMongoAdmin.has_delete_permission
Can delete this object
mongonaut/sites.py
def has_delete_permission(self, request): """ Can delete this object """ return request.user.is_authenticated and request.user.is_active and request.user.is_superuser
def has_delete_permission(self, request): """ Can delete this object """ return request.user.is_authenticated and request.user.is_active and request.user.is_superuser
[ "Can", "delete", "this", "object" ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/sites.py#L53-L55
[ "def", "has_delete_permission", "(", "self", ",", "request", ")", ":", "return", "request", ".", "user", ".", "is_authenticated", "and", "request", ".", "user", ".", "is_active", "and", "request", ".", "user", ".", "is_superuser" ]
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongoModelFormBaseMixin.get_form_field_dict
Takes a model dictionary representation and creates a dictionary keyed by form field. Each value is a keyed 4 tuple of: (widget, mode_field_instance, model_field_type, field_key)
mongonaut/forms/form_mixins.py
def get_form_field_dict(self, model_dict): """ Takes a model dictionary representation and creates a dictionary keyed by form field. Each value is a keyed 4 tuple of: (widget, mode_field_instance, model_field_type, field_key) """ return_dict = OrderedDict() # Wo...
def get_form_field_dict(self, model_dict): """ Takes a model dictionary representation and creates a dictionary keyed by form field. Each value is a keyed 4 tuple of: (widget, mode_field_instance, model_field_type, field_key) """ return_dict = OrderedDict() # Wo...
[ "Takes", "a", "model", "dictionary", "representation", "and", "creates", "a", "dictionary", "keyed", "by", "form", "field", ".", "Each", "value", "is", "a", "keyed", "4", "tuple", "of", ":", "(", "widget", "mode_field_instance", "model_field_type", "field_key", ...
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/form_mixins.py#L82-L108
[ "def", "get_form_field_dict", "(", "self", ",", "model_dict", ")", ":", "return_dict", "=", "OrderedDict", "(", ")", "# Workaround: mongoengine doesn't preserve form fields ordering from metaclass __new__", "if", "hasattr", "(", "self", ".", "model", ",", "'Meta'", ")", ...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongoModelFormBaseMixin.set_form_fields
Set the form fields for every key in the form_field_dict. Params: form_field_dict -- a dictionary created by get_form_field_dict parent_key -- the key for the previous key in the recursive call field_type -- used to determine what kind of field we are setting
mongonaut/forms/form_mixins.py
def set_form_fields(self, form_field_dict, parent_key=None, field_type=None): """ Set the form fields for every key in the form_field_dict. Params: form_field_dict -- a dictionary created by get_form_field_dict parent_key -- the key for the previous key in the recursive call...
def set_form_fields(self, form_field_dict, parent_key=None, field_type=None): """ Set the form fields for every key in the form_field_dict. Params: form_field_dict -- a dictionary created by get_form_field_dict parent_key -- the key for the previous key in the recursive call...
[ "Set", "the", "form", "fields", "for", "every", "key", "in", "the", "form_field_dict", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/form_mixins.py#L110-L193
[ "def", "set_form_fields", "(", "self", ",", "form_field_dict", ",", "parent_key", "=", "None", ",", "field_type", "=", "None", ")", ":", "for", "form_key", ",", "field_value", "in", "form_field_dict", ".", "items", "(", ")", ":", "form_key", "=", "make_key",...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongoModelFormBaseMixin.set_form_field
Parmams: widget -- the widget to use for displyaing the model_field model_field -- the field on the model to create a form field with field_key -- the name for the field on the form default_value -- the value to give for the field Default: Non...
mongonaut/forms/form_mixins.py
def set_form_field(self, widget, model_field, field_key, default_value): """ Parmams: widget -- the widget to use for displyaing the model_field model_field -- the field on the model to create a form field with field_key -- the name for the field on the form ...
def set_form_field(self, widget, model_field, field_key, default_value): """ Parmams: widget -- the widget to use for displyaing the model_field model_field -- the field on the model to create a form field with field_key -- the name for the field on the form ...
[ "Parmams", ":", "widget", "--", "the", "widget", "to", "use", "for", "displyaing", "the", "model_field", "model_field", "--", "the", "field", "on", "the", "model", "to", "create", "a", "form", "field", "with", "field_key", "--", "the", "name", "for", "the"...
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/form_mixins.py#L195-L239
[ "def", "set_form_field", "(", "self", ",", "widget", ",", "model_field", ",", "field_key", ",", "default_value", ")", ":", "# Empty lists cause issues on form validation", "if", "default_value", "==", "[", "]", ":", "default_value", "=", "None", "if", "widget", "a...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongoModelFormBaseMixin.get_field_value
Given field_key will return value held at self.model_instance. If model_instance has not been provided will return None.
mongonaut/forms/form_mixins.py
def get_field_value(self, field_key): """ Given field_key will return value held at self.model_instance. If model_instance has not been provided will return None. """ def get_value(document, field_key): # Short circuit the function if we do not have a document ...
def get_field_value(self, field_key): """ Given field_key will return value held at self.model_instance. If model_instance has not been provided will return None. """ def get_value(document, field_key): # Short circuit the function if we do not have a document ...
[ "Given", "field_key", "will", "return", "value", "held", "at", "self", ".", "model_instance", ".", "If", "model_instance", "has", "not", "been", "provided", "will", "return", "None", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/form_mixins.py#L241-L283
[ "def", "get_field_value", "(", "self", ",", "field_key", ")", ":", "def", "get_value", "(", "document", ",", "field_key", ")", ":", "# Short circuit the function if we do not have a document", "if", "document", "is", "None", ":", "return", "None", "current_key", ","...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
has_digit
Given a string or a list will return true if the last word or element is a digit. sep is used when a string is given to know what separates one word from another.
mongonaut/forms/form_utils.py
def has_digit(string_or_list, sep="_"): """ Given a string or a list will return true if the last word or element is a digit. sep is used when a string is given to know what separates one word from another. """ if isinstance(string_or_list, (tuple, list)): list_length = len(string_or_li...
def has_digit(string_or_list, sep="_"): """ Given a string or a list will return true if the last word or element is a digit. sep is used when a string is given to know what separates one word from another. """ if isinstance(string_or_list, (tuple, list)): list_length = len(string_or_li...
[ "Given", "a", "string", "or", "a", "list", "will", "return", "true", "if", "the", "last", "word", "or", "element", "is", "a", "digit", ".", "sep", "is", "used", "when", "a", "string", "is", "given", "to", "know", "what", "separates", "one", "word", "...
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/form_utils.py#L17-L30
[ "def", "has_digit", "(", "string_or_list", ",", "sep", "=", "\"_\"", ")", ":", "if", "isinstance", "(", "string_or_list", ",", "(", "tuple", ",", "list", ")", ")", ":", "list_length", "=", "len", "(", "string_or_list", ")", "if", "list_length", ":", "ret...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
make_key
Given any number of lists and strings will join them in order as one string separated by the sep kwarg. sep defaults to u"_". Add exclude_last_string=True as a kwarg to exclude the last item in a given string after being split by sep. Note if you only have one word in your string you can end up getti...
mongonaut/forms/form_utils.py
def make_key(*args, **kwargs): """ Given any number of lists and strings will join them in order as one string separated by the sep kwarg. sep defaults to u"_". Add exclude_last_string=True as a kwarg to exclude the last item in a given string after being split by sep. Note if you only have one w...
def make_key(*args, **kwargs): """ Given any number of lists and strings will join them in order as one string separated by the sep kwarg. sep defaults to u"_". Add exclude_last_string=True as a kwarg to exclude the last item in a given string after being split by sep. Note if you only have one w...
[ "Given", "any", "number", "of", "lists", "and", "strings", "will", "join", "them", "in", "order", "as", "one", "string", "separated", "by", "the", "sep", "kwarg", ".", "sep", "defaults", "to", "u", "_", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/form_utils.py#L33-L72
[ "def", "make_key", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "sep", "=", "kwargs", ".", "get", "(", "'sep'", ",", "u\"_\"", ")", "exclude_last_string", "=", "kwargs", ".", "get", "(", "'exclude_last_string'", ",", "False", ")", "string_array",...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongoModelForm.set_fields
Sets existing data to form fields.
mongonaut/forms/forms.py
def set_fields(self): """Sets existing data to form fields.""" # Get dictionary map of current model if self.is_initialized: self.model_map_dict = self.create_document_dictionary(self.model_instance) else: self.model_map_dict = self.create_document_dictionary(sel...
def set_fields(self): """Sets existing data to form fields.""" # Get dictionary map of current model if self.is_initialized: self.model_map_dict = self.create_document_dictionary(self.model_instance) else: self.model_map_dict = self.create_document_dictionary(sel...
[ "Sets", "existing", "data", "to", "form", "fields", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/forms.py#L35-L45
[ "def", "set_fields", "(", "self", ")", ":", "# Get dictionary map of current model", "if", "self", ".", "is_initialized", ":", "self", ".", "model_map_dict", "=", "self", ".", "create_document_dictionary", "(", "self", ".", "model_instance", ")", "else", ":", "sel...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongoModelForm.set_post_data
Need to set form data so that validation on all post data occurs and places newly entered form data on the form object.
mongonaut/forms/forms.py
def set_post_data(self): """ Need to set form data so that validation on all post data occurs and places newly entered form data on the form object. """ self.form.data = self.post_data_dict # Specifically adding list field keys to the form so they are included ...
def set_post_data(self): """ Need to set form data so that validation on all post data occurs and places newly entered form data on the form object. """ self.form.data = self.post_data_dict # Specifically adding list field keys to the form so they are included ...
[ "Need", "to", "set", "form", "data", "so", "that", "validation", "on", "all", "post", "data", "occurs", "and", "places", "newly", "entered", "form", "data", "on", "the", "form", "object", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/forms.py#L47-L65
[ "def", "set_post_data", "(", "self", ")", ":", "self", ".", "form", ".", "data", "=", "self", ".", "post_data_dict", "# Specifically adding list field keys to the form so they are included", "# in form.cleaned_data after the call to is_valid", "for", "field_key", ",", "field"...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongoModelForm.get_form
Generate the form for view.
mongonaut/forms/forms.py
def get_form(self): """ Generate the form for view. """ self.set_fields() if self.post_data_dict is not None: self.set_post_data() return self.form
def get_form(self): """ Generate the form for view. """ self.set_fields() if self.post_data_dict is not None: self.set_post_data() return self.form
[ "Generate", "the", "form", "for", "view", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/forms.py#L67-L74
[ "def", "get_form", "(", "self", ")", ":", "self", ".", "set_fields", "(", ")", "if", "self", ".", "post_data_dict", "is", "not", "None", ":", "self", ".", "set_post_data", "(", ")", "return", "self", ".", "form" ]
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongoModelForm.create_doc_dict
Generate a dictionary representation of the document. (no recursion) DO NOT CALL DIRECTLY
mongonaut/forms/forms.py
def create_doc_dict(self, document, doc_key=None, owner_document=None): """ Generate a dictionary representation of the document. (no recursion) DO NOT CALL DIRECTLY """ # Get doc field for top level documents if owner_document: doc_field = owner_document._f...
def create_doc_dict(self, document, doc_key=None, owner_document=None): """ Generate a dictionary representation of the document. (no recursion) DO NOT CALL DIRECTLY """ # Get doc field for top level documents if owner_document: doc_field = owner_document._f...
[ "Generate", "a", "dictionary", "representation", "of", "the", "document", ".", "(", "no", "recursion", ")" ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/forms.py#L76-L99
[ "def", "create_doc_dict", "(", "self", ",", "document", ",", "doc_key", "=", "None", ",", "owner_document", "=", "None", ")", ":", "# Get doc field for top level documents", "if", "owner_document", ":", "doc_field", "=", "owner_document", ".", "_fields", ".", "get...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongoModelForm.create_list_dict
Genereates a dictionary representation of the list field. Document should be the document the list_field comes from. DO NOT CALL DIRECTLY
mongonaut/forms/forms.py
def create_list_dict(self, document, list_field, doc_key): """ Genereates a dictionary representation of the list field. Document should be the document the list_field comes from. DO NOT CALL DIRECTLY """ list_dict = {"_document": document} if isinstance(list_fi...
def create_list_dict(self, document, list_field, doc_key): """ Genereates a dictionary representation of the list field. Document should be the document the list_field comes from. DO NOT CALL DIRECTLY """ list_dict = {"_document": document} if isinstance(list_fi...
[ "Genereates", "a", "dictionary", "representation", "of", "the", "list", "field", ".", "Document", "should", "be", "the", "document", "the", "list_field", "comes", "from", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/forms.py#L101-L121
[ "def", "create_list_dict", "(", "self", ",", "document", ",", "list_field", ",", "doc_key", ")", ":", "list_dict", "=", "{", "\"_document\"", ":", "document", "}", "if", "isinstance", "(", "list_field", ".", "field", ",", "EmbeddedDocumentField", ")", ":", "...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongoModelForm.create_document_dictionary
Given document generates a dictionary representation of the document. Includes the widget for each for each field in the document.
mongonaut/forms/forms.py
def create_document_dictionary(self, document, document_key=None, owner_document=None): """ Given document generates a dictionary representation of the document. Includes the widget for each for each field in the document. """ ...
def create_document_dictionary(self, document, document_key=None, owner_document=None): """ Given document generates a dictionary representation of the document. Includes the widget for each for each field in the document. """ ...
[ "Given", "document", "generates", "a", "dictionary", "representation", "of", "the", "document", ".", "Includes", "the", "widget", "for", "each", "for", "each", "field", "in", "the", "document", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/forms.py#L123-L148
[ "def", "create_document_dictionary", "(", "self", ",", "document", ",", "document_key", "=", "None", ",", "owner_document", "=", "None", ")", ":", "doc_dict", "=", "self", ".", "create_doc_dict", "(", "document", ",", "document_key", ",", "owner_document", ")", ...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
get_widget
Choose which widget to display for a field.
mongonaut/forms/widgets.py
def get_widget(model_field, disabled=False): """Choose which widget to display for a field.""" attrs = get_attrs(model_field, disabled) if hasattr(model_field, "max_length") and not model_field.max_length: return forms.Textarea(attrs=attrs) elif isinstance(model_field, DateTimeField): ...
def get_widget(model_field, disabled=False): """Choose which widget to display for a field.""" attrs = get_attrs(model_field, disabled) if hasattr(model_field, "max_length") and not model_field.max_length: return forms.Textarea(attrs=attrs) elif isinstance(model_field, DateTimeField): ...
[ "Choose", "which", "widget", "to", "display", "for", "a", "field", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/widgets.py#L22-L45
[ "def", "get_widget", "(", "model_field", ",", "disabled", "=", "False", ")", ":", "attrs", "=", "get_attrs", "(", "model_field", ",", "disabled", ")", "if", "hasattr", "(", "model_field", ",", "\"max_length\"", ")", "and", "not", "model_field", ".", "max_len...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
get_attrs
Set attributes on the display widget.
mongonaut/forms/widgets.py
def get_attrs(model_field, disabled=False): """Set attributes on the display widget.""" attrs = {} attrs['class'] = 'span6 xlarge' if disabled or isinstance(model_field, ObjectIdField): attrs['class'] += ' disabled' attrs['readonly'] = 'readonly' return attrs
def get_attrs(model_field, disabled=False): """Set attributes on the display widget.""" attrs = {} attrs['class'] = 'span6 xlarge' if disabled or isinstance(model_field, ObjectIdField): attrs['class'] += ' disabled' attrs['readonly'] = 'readonly' return attrs
[ "Set", "attributes", "on", "the", "display", "widget", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/widgets.py#L48-L55
[ "def", "get_attrs", "(", "model_field", ",", "disabled", "=", "False", ")", ":", "attrs", "=", "{", "}", "attrs", "[", "'class'", "]", "=", "'span6 xlarge'", "if", "disabled", "or", "isinstance", "(", "model_field", ",", "ObjectIdField", ")", ":", "attrs",...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
get_form_field_class
Gets the default form field for a mongoenigne field.
mongonaut/forms/widgets.py
def get_form_field_class(model_field): """Gets the default form field for a mongoenigne field.""" FIELD_MAPPING = { IntField: forms.IntegerField, StringField: forms.CharField, FloatField: forms.FloatField, BooleanField: forms.BooleanField, DateTimeField: forms.DateTimeF...
def get_form_field_class(model_field): """Gets the default form field for a mongoenigne field.""" FIELD_MAPPING = { IntField: forms.IntegerField, StringField: forms.CharField, FloatField: forms.FloatField, BooleanField: forms.BooleanField, DateTimeField: forms.DateTimeF...
[ "Gets", "the", "default", "form", "field", "for", "a", "mongoenigne", "field", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/forms/widgets.py#L58-L72
[ "def", "get_form_field_class", "(", "model_field", ")", ":", "FIELD_MAPPING", "=", "{", "IntField", ":", "forms", ".", "IntegerField", ",", "StringField", ":", "forms", ".", "CharField", ",", "FloatField", ":", "forms", ".", "FloatField", ",", "BooleanField", ...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
get_document_value
Returns the display value of a field for a particular MongoDB document.
mongonaut/templatetags/mongonaut_tags.py
def get_document_value(document, key): ''' Returns the display value of a field for a particular MongoDB document. ''' value = getattr(document, key) if isinstance(value, ObjectId): return value if isinstance(document._fields.get(key), URLField): return mark_safe("""<a href="{0}...
def get_document_value(document, key): ''' Returns the display value of a field for a particular MongoDB document. ''' value = getattr(document, key) if isinstance(value, ObjectId): return value if isinstance(document._fields.get(key), URLField): return mark_safe("""<a href="{0}...
[ "Returns", "the", "display", "value", "of", "a", "field", "for", "a", "particular", "MongoDB", "document", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/templatetags/mongonaut_tags.py#L15-L35
[ "def", "get_document_value", "(", "document", ",", "key", ")", ":", "value", "=", "getattr", "(", "document", ",", "key", ")", "if", "isinstance", "(", "value", ",", "ObjectId", ")", ":", "return", "value", "if", "isinstance", "(", "document", ".", "_fie...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
DocumentListView.get_qset
Performs filtering against the default queryset returned by mongoengine.
mongonaut/views.py
def get_qset(self, queryset, q): """Performs filtering against the default queryset returned by mongoengine. """ if self.mongoadmin.search_fields and q: params = {} for field in self.mongoadmin.search_fields: if field == 'id': ...
def get_qset(self, queryset, q): """Performs filtering against the default queryset returned by mongoengine. """ if self.mongoadmin.search_fields and q: params = {} for field in self.mongoadmin.search_fields: if field == 'id': ...
[ "Performs", "filtering", "against", "the", "default", "queryset", "returned", "by", "mongoengine", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/views.py#L55-L71
[ "def", "get_qset", "(", "self", ",", "queryset", ",", "q", ")", ":", "if", "self", ".", "mongoadmin", ".", "search_fields", "and", "q", ":", "params", "=", "{", "}", "for", "field", "in", "self", ".", "mongoadmin", ".", "search_fields", ":", "if", "f...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
DocumentListView.get_queryset
Replicates Django CBV `get_queryset()` method, but for MongoEngine.
mongonaut/views.py
def get_queryset(self): """Replicates Django CBV `get_queryset()` method, but for MongoEngine. """ if hasattr(self, "queryset") and self.queryset: return self.queryset self.set_mongonaut_base() self.set_mongoadmin() self.document = getattr(self.models, self.d...
def get_queryset(self): """Replicates Django CBV `get_queryset()` method, but for MongoEngine. """ if hasattr(self, "queryset") and self.queryset: return self.queryset self.set_mongonaut_base() self.set_mongoadmin() self.document = getattr(self.models, self.d...
[ "Replicates", "Django", "CBV", "get_queryset", "()", "method", "but", "for", "MongoEngine", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/views.py#L74-L117
[ "def", "get_queryset", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "\"queryset\"", ")", "and", "self", ".", "queryset", ":", "return", "self", ".", "queryset", "self", ".", "set_mongonaut_base", "(", ")", "self", ".", "set_mongoadmin", "(", ...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
DocumentListView.get_initial
Used during adding/editing of data.
mongonaut/views.py
def get_initial(self): """Used during adding/editing of data.""" self.query = self.get_queryset() mongo_ids = {'mongo_id': [str(x.id) for x in self.query]} return mongo_ids
def get_initial(self): """Used during adding/editing of data.""" self.query = self.get_queryset() mongo_ids = {'mongo_id': [str(x.id) for x in self.query]} return mongo_ids
[ "Used", "during", "adding", "/", "editing", "of", "data", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/views.py#L119-L123
[ "def", "get_initial", "(", "self", ")", ":", "self", ".", "query", "=", "self", ".", "get_queryset", "(", ")", "mongo_ids", "=", "{", "'mongo_id'", ":", "[", "str", "(", "x", ".", "id", ")", "for", "x", "in", "self", ".", "query", "]", "}", "retu...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
DocumentListView.get_context_data
Injects data into the context to replicate CBV ListView.
mongonaut/views.py
def get_context_data(self, **kwargs): """Injects data into the context to replicate CBV ListView.""" context = super(DocumentListView, self).get_context_data(**kwargs) context = self.set_permissions_in_context(context) if not context['has_view_permission']: return HttpRespon...
def get_context_data(self, **kwargs): """Injects data into the context to replicate CBV ListView.""" context = super(DocumentListView, self).get_context_data(**kwargs) context = self.set_permissions_in_context(context) if not context['has_view_permission']: return HttpRespon...
[ "Injects", "data", "into", "the", "context", "to", "replicate", "CBV", "ListView", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/views.py#L125-L178
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "DocumentListView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "context", "=", "self", ".", "set_permissions_in_context", ...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
DocumentListView.post
Creates new mongoengine records.
mongonaut/views.py
def post(self, request, *args, **kwargs): """Creates new mongoengine records.""" # TODO - make sure to check the rights of the poster #self.get_queryset() # TODO - write something that grabs the document class better form_class = self.get_form_class() form = self.get_form(form_cl...
def post(self, request, *args, **kwargs): """Creates new mongoengine records.""" # TODO - make sure to check the rights of the poster #self.get_queryset() # TODO - write something that grabs the document class better form_class = self.get_form_class() form = self.get_form(form_cl...
[ "Creates", "new", "mongoengine", "records", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/views.py#L180-L192
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# TODO - make sure to check the rights of the poster", "#self.get_queryset() # TODO - write something that grabs the document class better", "form_class", "=", "self", ".", "ge...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
DocumentAddFormView.get_context_data
TODO - possibly inherit this from DocumentEditFormView. This is same thing minus: self.ident = self.kwargs.get('id') self.document = self.document_type.objects.get(pk=self.ident)
mongonaut/views.py
def get_context_data(self, **kwargs): """ TODO - possibly inherit this from DocumentEditFormView. This is same thing minus: self.ident = self.kwargs.get('id') self.document = self.document_type.objects.get(pk=self.ident) """ context = super(DocumentAddFormView, self).get_...
def get_context_data(self, **kwargs): """ TODO - possibly inherit this from DocumentEditFormView. This is same thing minus: self.ident = self.kwargs.get('id') self.document = self.document_type.objects.get(pk=self.ident) """ context = super(DocumentAddFormView, self).get_...
[ "TODO", "-", "possibly", "inherit", "this", "from", "DocumentEditFormView", ".", "This", "is", "same", "thing", "minus", ":", "self", ".", "ident", "=", "self", ".", "kwargs", ".", "get", "(", "id", ")", "self", ".", "document", "=", "self", ".", "docu...
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/views.py#L290-L305
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "DocumentAddFormView", ",", "self", ")", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "self", ".", "set_mongoadmin", "(", ")", "context", "...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongonautViewMixin.get_mongoadmins
Returns a list of all mongoadmin implementations for the site
mongonaut/mixins.py
def get_mongoadmins(self): """ Returns a list of all mongoadmin implementations for the site """ apps = [] for app_name in settings.INSTALLED_APPS: mongoadmin = "{0}.mongoadmin".format(app_name) try: module = import_module(mongoadmin) except Im...
def get_mongoadmins(self): """ Returns a list of all mongoadmin implementations for the site """ apps = [] for app_name in settings.INSTALLED_APPS: mongoadmin = "{0}.mongoadmin".format(app_name) try: module = import_module(mongoadmin) except Im...
[ "Returns", "a", "list", "of", "all", "mongoadmin", "implementations", "for", "the", "site" ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/mixins.py#L67-L84
[ "def", "get_mongoadmins", "(", "self", ")", ":", "apps", "=", "[", "]", "for", "app_name", "in", "settings", ".", "INSTALLED_APPS", ":", "mongoadmin", "=", "\"{0}.mongoadmin\"", ".", "format", "(", "app_name", ")", "try", ":", "module", "=", "import_module",...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongonautViewMixin.set_mongonaut_base
Sets a number of commonly used attributes
mongonaut/mixins.py
def set_mongonaut_base(self): """ Sets a number of commonly used attributes """ if hasattr(self, "app_label"): # prevents us from calling this multiple times return None self.app_label = self.kwargs.get('app_label') self.document_name = self.kwargs.get('document_n...
def set_mongonaut_base(self): """ Sets a number of commonly used attributes """ if hasattr(self, "app_label"): # prevents us from calling this multiple times return None self.app_label = self.kwargs.get('app_label') self.document_name = self.kwargs.get('document_n...
[ "Sets", "a", "number", "of", "commonly", "used", "attributes" ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/mixins.py#L86-L99
[ "def", "set_mongonaut_base", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "\"app_label\"", ")", ":", "# prevents us from calling this multiple times", "return", "None", "self", ".", "app_label", "=", "self", ".", "kwargs", ".", "get", "(", "'app_lab...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongonautViewMixin.set_mongoadmin
Returns the MongoAdmin object for an app_label/document_name style view
mongonaut/mixins.py
def set_mongoadmin(self): """ Returns the MongoAdmin object for an app_label/document_name style view """ if hasattr(self, "mongoadmin"): return None if not hasattr(self, "document_name"): self.set_mongonaut_base() for mongoadmin in self.get_mongoadmins(...
def set_mongoadmin(self): """ Returns the MongoAdmin object for an app_label/document_name style view """ if hasattr(self, "mongoadmin"): return None if not hasattr(self, "document_name"): self.set_mongonaut_base() for mongoadmin in self.get_mongoadmins(...
[ "Returns", "the", "MongoAdmin", "object", "for", "an", "app_label", "/", "document_name", "style", "view" ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/mixins.py#L101-L117
[ "def", "set_mongoadmin", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "\"mongoadmin\"", ")", ":", "return", "None", "if", "not", "hasattr", "(", "self", ",", "\"document_name\"", ")", ":", "self", ".", "set_mongonaut_base", "(", ")", "for", ...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongonautViewMixin.set_permissions_in_context
Provides permissions for mongoadmin for use in the context
mongonaut/mixins.py
def set_permissions_in_context(self, context={}): """ Provides permissions for mongoadmin for use in the context""" context['has_view_permission'] = self.mongoadmin.has_view_permission(self.request) context['has_edit_permission'] = self.mongoadmin.has_edit_permission(self.request) conte...
def set_permissions_in_context(self, context={}): """ Provides permissions for mongoadmin for use in the context""" context['has_view_permission'] = self.mongoadmin.has_view_permission(self.request) context['has_edit_permission'] = self.mongoadmin.has_edit_permission(self.request) conte...
[ "Provides", "permissions", "for", "mongoadmin", "for", "use", "in", "the", "context" ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/mixins.py#L119-L126
[ "def", "set_permissions_in_context", "(", "self", ",", "context", "=", "{", "}", ")", ":", "context", "[", "'has_view_permission'", "]", "=", "self", ".", "mongoadmin", ".", "has_view_permission", "(", "self", ".", "request", ")", "context", "[", "'has_edit_pe...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongonautFormViewMixin.process_post_form
As long as the form is set on the view this method will validate the form and save the submitted data. Only call this if you are posting data. The given success_message will be used with the djanog messages framework if the posted data sucessfully submits.
mongonaut/mixins.py
def process_post_form(self, success_message=None): """ As long as the form is set on the view this method will validate the form and save the submitted data. Only call this if you are posting data. The given success_message will be used with the djanog messages framework if the ...
def process_post_form(self, success_message=None): """ As long as the form is set on the view this method will validate the form and save the submitted data. Only call this if you are posting data. The given success_message will be used with the djanog messages framework if the ...
[ "As", "long", "as", "the", "form", "is", "set", "on", "the", "view", "this", "method", "will", "validate", "the", "form", "and", "save", "the", "submitted", "data", ".", "Only", "call", "this", "if", "you", "are", "posting", "data", ".", "The", "given"...
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/mixins.py#L135-L173
[ "def", "process_post_form", "(", "self", ",", "success_message", "=", "None", ")", ":", "# When on initial args are given we need to set the base document.", "if", "not", "hasattr", "(", "self", ",", "'document'", ")", "or", "self", ".", "document", "is", "None", ":...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongonautFormViewMixin.process_document
Given the form_key will evaluate the document and set values correctly for the document given.
mongonaut/mixins.py
def process_document(self, document, form_key, passed_key): """ Given the form_key will evaluate the document and set values correctly for the document given. """ if passed_key is not None: current_key, remaining_key_array = trim_field_key(document, passed_key) ...
def process_document(self, document, form_key, passed_key): """ Given the form_key will evaluate the document and set values correctly for the document given. """ if passed_key is not None: current_key, remaining_key_array = trim_field_key(document, passed_key) ...
[ "Given", "the", "form_key", "will", "evaluate", "the", "document", "and", "set", "values", "correctly", "for", "the", "document", "given", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/mixins.py#L175-L206
[ "def", "process_document", "(", "self", ",", "document", ",", "form_key", ",", "passed_key", ")", ":", "if", "passed_key", "is", "not", "None", ":", "current_key", ",", "remaining_key_array", "=", "trim_field_key", "(", "document", ",", "passed_key", ")", "els...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongonautFormViewMixin.set_embedded_doc
Get the existing embedded document if it exists, else created it.
mongonaut/mixins.py
def set_embedded_doc(self, document, form_key, current_key, remaining_key): """Get the existing embedded document if it exists, else created it.""" embedded_doc = getattr(document, current_key, False) if not embedded_doc: embedded_doc = document._fields[current_key].document_type_ob...
def set_embedded_doc(self, document, form_key, current_key, remaining_key): """Get the existing embedded document if it exists, else created it.""" embedded_doc = getattr(document, current_key, False) if not embedded_doc: embedded_doc = document._fields[current_key].document_type_ob...
[ "Get", "the", "existing", "embedded", "document", "if", "it", "exists", "else", "created", "it", "." ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/mixins.py#L208-L217
[ "def", "set_embedded_doc", "(", "self", ",", "document", ",", "form_key", ",", "current_key", ",", "remaining_key", ")", ":", "embedded_doc", "=", "getattr", "(", "document", ",", "current_key", ",", "False", ")", "if", "not", "embedded_doc", ":", "embedded_do...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
MongonautFormViewMixin.set_list_field
1. Figures out what value the list ought to have 2. Sets the list
mongonaut/mixins.py
def set_list_field(self, document, form_key, current_key, remaining_key, key_array_digit): """1. Figures out what value the list ought to have 2. Sets the list """ document_field = document._fields.get(current_key) # Figure out what value the list ought to have # Non...
def set_list_field(self, document, form_key, current_key, remaining_key, key_array_digit): """1. Figures out what value the list ought to have 2. Sets the list """ document_field = document._fields.get(current_key) # Figure out what value the list ought to have # Non...
[ "1", ".", "Figures", "out", "what", "value", "the", "list", "ought", "to", "have", "2", ".", "Sets", "the", "list" ]
jazzband/django-mongonaut
python
https://github.com/jazzband/django-mongonaut/blob/5485b2e029dff8ae267a4cb39c92d0a72cb5b144/mongonaut/mixins.py#L219-L258
[ "def", "set_list_field", "(", "self", ",", "document", ",", "form_key", ",", "current_key", ",", "remaining_key", ",", "key_array_digit", ")", ":", "document_field", "=", "document", ".", "_fields", ".", "get", "(", "current_key", ")", "# Figure out what value the...
5485b2e029dff8ae267a4cb39c92d0a72cb5b144
valid
with_tz
Get the time with TZ enabled
easy_timezones/views.py
def with_tz(request): """ Get the time with TZ enabled """ dt = datetime.now() t = Template('{% load tz %}{% localtime on %}{% get_current_timezone as TIME_ZONE %}{{ TIME_ZONE }}{% endlocaltime %}') c = RequestContext(request) response = t.render(c) return HttpResponse(response)
def with_tz(request): """ Get the time with TZ enabled """ dt = datetime.now() t = Template('{% load tz %}{% localtime on %}{% get_current_timezone as TIME_ZONE %}{{ TIME_ZONE }}{% endlocaltime %}') c = RequestContext(request) response = t.render(c) return HttpResponse(response)
[ "Get", "the", "time", "with", "TZ", "enabled" ]
Miserlou/django-easy-timezones
python
https://github.com/Miserlou/django-easy-timezones/blob/a25c6312a7ecb3ebfac7b2c458b1c5be5d45a239/easy_timezones/views.py#L8-L18
[ "def", "with_tz", "(", "request", ")", ":", "dt", "=", "datetime", ".", "now", "(", ")", "t", "=", "Template", "(", "'{% load tz %}{% localtime on %}{% get_current_timezone as TIME_ZONE %}{{ TIME_ZONE }}{% endlocaltime %}'", ")", "c", "=", "RequestContext", "(", "reques...
a25c6312a7ecb3ebfac7b2c458b1c5be5d45a239
valid
without_tz
Get the time without TZ enabled
easy_timezones/views.py
def without_tz(request): """ Get the time without TZ enabled """ t = Template('{% load tz %}{% get_current_timezone as TIME_ZONE %}{{ TIME_ZONE }}') c = RequestContext(request) response = t.render(c) return HttpResponse(response)
def without_tz(request): """ Get the time without TZ enabled """ t = Template('{% load tz %}{% get_current_timezone as TIME_ZONE %}{{ TIME_ZONE }}') c = RequestContext(request) response = t.render(c) return HttpResponse(response)
[ "Get", "the", "time", "without", "TZ", "enabled" ]
Miserlou/django-easy-timezones
python
https://github.com/Miserlou/django-easy-timezones/blob/a25c6312a7ecb3ebfac7b2c458b1c5be5d45a239/easy_timezones/views.py#L20-L29
[ "def", "without_tz", "(", "request", ")", ":", "t", "=", "Template", "(", "'{% load tz %}{% get_current_timezone as TIME_ZONE %}{{ TIME_ZONE }}'", ")", "c", "=", "RequestContext", "(", "request", ")", "response", "=", "t", ".", "render", "(", "c", ")", "return", ...
a25c6312a7ecb3ebfac7b2c458b1c5be5d45a239
valid
is_valid_ip
Check Validity of an IP address
easy_timezones/utils.py
def is_valid_ip(ip_address): """ Check Validity of an IP address """ try: ip = ipaddress.ip_address(u'' + ip_address) return True except ValueError as e: return False
def is_valid_ip(ip_address): """ Check Validity of an IP address """ try: ip = ipaddress.ip_address(u'' + ip_address) return True except ValueError as e: return False
[ "Check", "Validity", "of", "an", "IP", "address" ]
Miserlou/django-easy-timezones
python
https://github.com/Miserlou/django-easy-timezones/blob/a25c6312a7ecb3ebfac7b2c458b1c5be5d45a239/easy_timezones/utils.py#L7-L14
[ "def", "is_valid_ip", "(", "ip_address", ")", ":", "try", ":", "ip", "=", "ipaddress", ".", "ip_address", "(", "u''", "+", "ip_address", ")", "return", "True", "except", "ValueError", "as", "e", ":", "return", "False" ]
a25c6312a7ecb3ebfac7b2c458b1c5be5d45a239
valid
is_local_ip
Check if IP is local
easy_timezones/utils.py
def is_local_ip(ip_address): """ Check if IP is local """ try: ip = ipaddress.ip_address(u'' + ip_address) return ip.is_loopback except ValueError as e: return None
def is_local_ip(ip_address): """ Check if IP is local """ try: ip = ipaddress.ip_address(u'' + ip_address) return ip.is_loopback except ValueError as e: return None
[ "Check", "if", "IP", "is", "local" ]
Miserlou/django-easy-timezones
python
https://github.com/Miserlou/django-easy-timezones/blob/a25c6312a7ecb3ebfac7b2c458b1c5be5d45a239/easy_timezones/utils.py#L16-L23
[ "def", "is_local_ip", "(", "ip_address", ")", ":", "try", ":", "ip", "=", "ipaddress", ".", "ip_address", "(", "u''", "+", "ip_address", ")", "return", "ip", ".", "is_loopback", "except", "ValueError", "as", "e", ":", "return", "None" ]
a25c6312a7ecb3ebfac7b2c458b1c5be5d45a239
valid
EasyTimezoneMiddleware.process_request
If we can get a valid IP from the request, look up that address in the database to get the appropriate timezone and activate it. Else, use the default.
easy_timezones/middleware.py
def process_request(self, request): """ If we can get a valid IP from the request, look up that address in the database to get the appropriate timezone and activate it. Else, use the default. """ if not request: return if not db_loaded: ...
def process_request(self, request): """ If we can get a valid IP from the request, look up that address in the database to get the appropriate timezone and activate it. Else, use the default. """ if not request: return if not db_loaded: ...
[ "If", "we", "can", "get", "a", "valid", "IP", "from", "the", "request", "look", "up", "that", "address", "in", "the", "database", "to", "get", "the", "appropriate", "timezone", "and", "activate", "it", "." ]
Miserlou/django-easy-timezones
python
https://github.com/Miserlou/django-easy-timezones/blob/a25c6312a7ecb3ebfac7b2c458b1c5be5d45a239/easy_timezones/middleware.py#L60-L99
[ "def", "process_request", "(", "self", ",", "request", ")", ":", "if", "not", "request", ":", "return", "if", "not", "db_loaded", ":", "load_db", "(", ")", "tz", "=", "request", ".", "session", ".", "get", "(", "'django_timezone'", ")", "if", "not", "t...
a25c6312a7ecb3ebfac7b2c458b1c5be5d45a239
valid
elastic_query
Public method for init the class ElasticQuery :model: SQLAlchemy model :query: valid string like a ElasticSearch :session: SQLAlchemy session *optional :enabled_fields: Fields allowed for make a query *optional
sqlalchemy_elasticquery/elastic_query.py
def elastic_query(model, query, session=None, enabled_fields=None): """ Public method for init the class ElasticQuery :model: SQLAlchemy model :query: valid string like a ElasticSearch :session: SQLAlchemy session *optional :enabled_fields: Fields allowed for make a query *optional ...
def elastic_query(model, query, session=None, enabled_fields=None): """ Public method for init the class ElasticQuery :model: SQLAlchemy model :query: valid string like a ElasticSearch :session: SQLAlchemy session *optional :enabled_fields: Fields allowed for make a query *optional ...
[ "Public", "method", "for", "init", "the", "class", "ElasticQuery", ":", "model", ":", "SQLAlchemy", "model", ":", "query", ":", "valid", "string", "like", "a", "ElasticSearch", ":", "session", ":", "SQLAlchemy", "session", "*", "optional", ":", "enabled_fields...
loverajoel/sqlalchemy-elasticquery
python
https://github.com/loverajoel/sqlalchemy-elasticquery/blob/4c99b81f59e7bb20eaeedb3adbf5126e62bbc25c/sqlalchemy_elasticquery/elastic_query.py#L40-L49
[ "def", "elastic_query", "(", "model", ",", "query", ",", "session", "=", "None", ",", "enabled_fields", "=", "None", ")", ":", "# TODO: make session to optional", "instance", "=", "ElasticQuery", "(", "model", ",", "query", ",", "session", ",", "enabled_fields",...
4c99b81f59e7bb20eaeedb3adbf5126e62bbc25c
valid
ElasticQuery.search
This is the most important method
sqlalchemy_elasticquery/elastic_query.py
def search(self): """ This is the most important method """ try: filters = json.loads(self.query) except ValueError: return False result = self.model_query if 'filter'in filters.keys(): result = self.parse_filter(filters['filter']) if ...
def search(self): """ This is the most important method """ try: filters = json.loads(self.query) except ValueError: return False result = self.model_query if 'filter'in filters.keys(): result = self.parse_filter(filters['filter']) if ...
[ "This", "is", "the", "most", "important", "method" ]
loverajoel/sqlalchemy-elasticquery
python
https://github.com/loverajoel/sqlalchemy-elasticquery/blob/4c99b81f59e7bb20eaeedb3adbf5126e62bbc25c/sqlalchemy_elasticquery/elastic_query.py#L80-L93
[ "def", "search", "(", "self", ")", ":", "try", ":", "filters", "=", "json", ".", "loads", "(", "self", ".", "query", ")", "except", "ValueError", ":", "return", "False", "result", "=", "self", ".", "model_query", "if", "'filter'", "in", "filters", ".",...
4c99b81f59e7bb20eaeedb3adbf5126e62bbc25c
valid
ElasticQuery.parse_filter
This method process the filters
sqlalchemy_elasticquery/elastic_query.py
def parse_filter(self, filters): """ This method process the filters """ for filter_type in filters: if filter_type == 'or' or filter_type == 'and': conditions = [] for field in filters[filter_type]: if self.is_field_allowed(field): ...
def parse_filter(self, filters): """ This method process the filters """ for filter_type in filters: if filter_type == 'or' or filter_type == 'and': conditions = [] for field in filters[filter_type]: if self.is_field_allowed(field): ...
[ "This", "method", "process", "the", "filters" ]
loverajoel/sqlalchemy-elasticquery
python
https://github.com/loverajoel/sqlalchemy-elasticquery/blob/4c99b81f59e7bb20eaeedb3adbf5126e62bbc25c/sqlalchemy_elasticquery/elastic_query.py#L95-L111
[ "def", "parse_filter", "(", "self", ",", "filters", ")", ":", "for", "filter_type", "in", "filters", ":", "if", "filter_type", "==", "'or'", "or", "filter_type", "==", "'and'", ":", "conditions", "=", "[", "]", "for", "field", "in", "filters", "[", "filt...
4c99b81f59e7bb20eaeedb3adbf5126e62bbc25c
valid
ElasticQuery.parse_field
Parse the operators and traduce: ES to SQLAlchemy operators
sqlalchemy_elasticquery/elastic_query.py
def parse_field(self, field, field_value): """ Parse the operators and traduce: ES to SQLAlchemy operators """ if type(field_value) is dict: # TODO: check operators and emit error operator = list(field_value)[0] if self.verify_operator(operator) is False: ...
def parse_field(self, field, field_value): """ Parse the operators and traduce: ES to SQLAlchemy operators """ if type(field_value) is dict: # TODO: check operators and emit error operator = list(field_value)[0] if self.verify_operator(operator) is False: ...
[ "Parse", "the", "operators", "and", "traduce", ":", "ES", "to", "SQLAlchemy", "operators" ]
loverajoel/sqlalchemy-elasticquery
python
https://github.com/loverajoel/sqlalchemy-elasticquery/blob/4c99b81f59e7bb20eaeedb3adbf5126e62bbc25c/sqlalchemy_elasticquery/elastic_query.py#L113-L124
[ "def", "parse_field", "(", "self", ",", "field", ",", "field_value", ")", ":", "if", "type", "(", "field_value", ")", "is", "dict", ":", "# TODO: check operators and emit error", "operator", "=", "list", "(", "field_value", ")", "[", "0", "]", "if", "self", ...
4c99b81f59e7bb20eaeedb3adbf5126e62bbc25c
valid
ElasticQuery.create_query
Mix all values and make the query
sqlalchemy_elasticquery/elastic_query.py
def create_query(self, attr): """ Mix all values and make the query """ field = attr[0] operator = attr[1] value = attr[2] model = self.model if '.' in field: field_items = field.split('.') field_name = getattr(model, field_items[0], None) ...
def create_query(self, attr): """ Mix all values and make the query """ field = attr[0] operator = attr[1] value = attr[2] model = self.model if '.' in field: field_items = field.split('.') field_name = getattr(model, field_items[0], None) ...
[ "Mix", "all", "values", "and", "make", "the", "query" ]
loverajoel/sqlalchemy-elasticquery
python
https://github.com/loverajoel/sqlalchemy-elasticquery/blob/4c99b81f59e7bb20eaeedb3adbf5126e62bbc25c/sqlalchemy_elasticquery/elastic_query.py#L143-L157
[ "def", "create_query", "(", "self", ",", "attr", ")", ":", "field", "=", "attr", "[", "0", "]", "operator", "=", "attr", "[", "1", "]", "value", "=", "attr", "[", "2", "]", "model", "=", "self", ".", "model", "if", "'.'", "in", "field", ":", "f...
4c99b81f59e7bb20eaeedb3adbf5126e62bbc25c
valid
ElasticQuery.sort
Sort
sqlalchemy_elasticquery/elastic_query.py
def sort(self, sort_list): """ Sort """ order = [] for sort in sort_list: if sort_list[sort] == "asc": order.append(asc(getattr(self.model, sort, None))) elif sort_list[sort] == "desc": order.append(desc(getattr(self.model, sort, None))) ...
def sort(self, sort_list): """ Sort """ order = [] for sort in sort_list: if sort_list[sort] == "asc": order.append(asc(getattr(self.model, sort, None))) elif sort_list[sort] == "desc": order.append(desc(getattr(self.model, sort, None))) ...
[ "Sort" ]
loverajoel/sqlalchemy-elasticquery
python
https://github.com/loverajoel/sqlalchemy-elasticquery/blob/4c99b81f59e7bb20eaeedb3adbf5126e62bbc25c/sqlalchemy_elasticquery/elastic_query.py#L159-L167
[ "def", "sort", "(", "self", ",", "sort_list", ")", ":", "order", "=", "[", "]", "for", "sort", "in", "sort_list", ":", "if", "sort_list", "[", "sort", "]", "==", "\"asc\"", ":", "order", ".", "append", "(", "asc", "(", "getattr", "(", "self", ".", ...
4c99b81f59e7bb20eaeedb3adbf5126e62bbc25c
valid
SMTP_dummy.sendmail
Remember the recipients.
mailmerge/smtp_dummy.py
def sendmail(self, msg_from, msg_to, msg): """Remember the recipients.""" SMTP_dummy.msg_from = msg_from SMTP_dummy.msg_to = msg_to SMTP_dummy.msg = msg
def sendmail(self, msg_from, msg_to, msg): """Remember the recipients.""" SMTP_dummy.msg_from = msg_from SMTP_dummy.msg_to = msg_to SMTP_dummy.msg = msg
[ "Remember", "the", "recipients", "." ]
awdeorio/mailmerge
python
https://github.com/awdeorio/mailmerge/blob/ff83f3b053ed6e182a98025873fcf3095d37b78b/mailmerge/smtp_dummy.py#L16-L20
[ "def", "sendmail", "(", "self", ",", "msg_from", ",", "msg_to", ",", "msg", ")", ":", "SMTP_dummy", ".", "msg_from", "=", "msg_from", "SMTP_dummy", ".", "msg_to", "=", "msg_to", "SMTP_dummy", ".", "msg", "=", "msg" ]
ff83f3b053ed6e182a98025873fcf3095d37b78b
valid
parsemail
Parse message headers, then remove BCC header.
mailmerge/api.py
def parsemail(raw_message): """Parse message headers, then remove BCC header.""" message = email.parser.Parser().parsestr(raw_message) # Detect encoding detected = chardet.detect(bytearray(raw_message, "utf-8")) encoding = detected["encoding"] print(">>> encoding {}".format(encoding)) for p...
def parsemail(raw_message): """Parse message headers, then remove BCC header.""" message = email.parser.Parser().parsestr(raw_message) # Detect encoding detected = chardet.detect(bytearray(raw_message, "utf-8")) encoding = detected["encoding"] print(">>> encoding {}".format(encoding)) for p...
[ "Parse", "message", "headers", "then", "remove", "BCC", "header", "." ]
awdeorio/mailmerge
python
https://github.com/awdeorio/mailmerge/blob/ff83f3b053ed6e182a98025873fcf3095d37b78b/mailmerge/api.py#L37-L59
[ "def", "parsemail", "(", "raw_message", ")", ":", "message", "=", "email", ".", "parser", ".", "Parser", "(", ")", ".", "parsestr", "(", "raw_message", ")", "# Detect encoding", "detected", "=", "chardet", ".", "detect", "(", "bytearray", "(", "raw_message",...
ff83f3b053ed6e182a98025873fcf3095d37b78b
valid
_create_boundary
Add boundary parameter to multipart message if they are not present.
mailmerge/api.py
def _create_boundary(message): """Add boundary parameter to multipart message if they are not present.""" if not message.is_multipart() or message.get_boundary() is not None: return message # HACK: Python2 lists do not natively have a `copy` method. Unfortunately, # due to a bug in the Backport ...
def _create_boundary(message): """Add boundary parameter to multipart message if they are not present.""" if not message.is_multipart() or message.get_boundary() is not None: return message # HACK: Python2 lists do not natively have a `copy` method. Unfortunately, # due to a bug in the Backport ...
[ "Add", "boundary", "parameter", "to", "multipart", "message", "if", "they", "are", "not", "present", "." ]
awdeorio/mailmerge
python
https://github.com/awdeorio/mailmerge/blob/ff83f3b053ed6e182a98025873fcf3095d37b78b/mailmerge/api.py#L62-L79
[ "def", "_create_boundary", "(", "message", ")", ":", "if", "not", "message", ".", "is_multipart", "(", ")", "or", "message", ".", "get_boundary", "(", ")", "is", "not", "None", ":", "return", "message", "# HACK: Python2 lists do not natively have a `copy` method. Un...
ff83f3b053ed6e182a98025873fcf3095d37b78b
valid
make_message_multipart
Convert a message into a multipart message.
mailmerge/api.py
def make_message_multipart(message): """Convert a message into a multipart message.""" if not message.is_multipart(): multipart_message = email.mime.multipart.MIMEMultipart('alternative') for header_key in set(message.keys()): # Preserve duplicate headers values = message...
def make_message_multipart(message): """Convert a message into a multipart message.""" if not message.is_multipart(): multipart_message = email.mime.multipart.MIMEMultipart('alternative') for header_key in set(message.keys()): # Preserve duplicate headers values = message...
[ "Convert", "a", "message", "into", "a", "multipart", "message", "." ]
awdeorio/mailmerge
python
https://github.com/awdeorio/mailmerge/blob/ff83f3b053ed6e182a98025873fcf3095d37b78b/mailmerge/api.py#L82-L96
[ "def", "make_message_multipart", "(", "message", ")", ":", "if", "not", "message", ".", "is_multipart", "(", ")", ":", "multipart_message", "=", "email", ".", "mime", ".", "multipart", ".", "MIMEMultipart", "(", "'alternative'", ")", "for", "header_key", "in",...
ff83f3b053ed6e182a98025873fcf3095d37b78b
valid
convert_markdown
Convert markdown in message text to HTML.
mailmerge/api.py
def convert_markdown(message): """Convert markdown in message text to HTML.""" assert message['Content-Type'].startswith("text/markdown") del message['Content-Type'] # Convert the text from markdown and then make the message multipart message = make_message_multipart(message) for payload_item in...
def convert_markdown(message): """Convert markdown in message text to HTML.""" assert message['Content-Type'].startswith("text/markdown") del message['Content-Type'] # Convert the text from markdown and then make the message multipart message = make_message_multipart(message) for payload_item in...
[ "Convert", "markdown", "in", "message", "text", "to", "HTML", "." ]
awdeorio/mailmerge
python
https://github.com/awdeorio/mailmerge/blob/ff83f3b053ed6e182a98025873fcf3095d37b78b/mailmerge/api.py#L99-L117
[ "def", "convert_markdown", "(", "message", ")", ":", "assert", "message", "[", "'Content-Type'", "]", ".", "startswith", "(", "\"text/markdown\"", ")", "del", "message", "[", "'Content-Type'", "]", "# Convert the text from markdown and then make the message multipart", "m...
ff83f3b053ed6e182a98025873fcf3095d37b78b
valid
addattachments
Add the attachments from the message from the commandline options.
mailmerge/api.py
def addattachments(message, template_path): """Add the attachments from the message from the commandline options.""" if 'attachment' not in message: return message, 0 message = make_message_multipart(message) attachment_filepaths = message.get_all('attachment', failobj=[]) template_parent_...
def addattachments(message, template_path): """Add the attachments from the message from the commandline options.""" if 'attachment' not in message: return message, 0 message = make_message_multipart(message) attachment_filepaths = message.get_all('attachment', failobj=[]) template_parent_...
[ "Add", "the", "attachments", "from", "the", "message", "from", "the", "commandline", "options", "." ]
awdeorio/mailmerge
python
https://github.com/awdeorio/mailmerge/blob/ff83f3b053ed6e182a98025873fcf3095d37b78b/mailmerge/api.py#L120-L154
[ "def", "addattachments", "(", "message", ",", "template_path", ")", ":", "if", "'attachment'", "not", "in", "message", ":", "return", "message", ",", "0", "message", "=", "make_message_multipart", "(", "message", ")", "attachment_filepaths", "=", "message", ".",...
ff83f3b053ed6e182a98025873fcf3095d37b78b
valid
sendmail
Send email message using Python SMTP library.
mailmerge/api.py
def sendmail(message, sender, recipients, config_filename): """Send email message using Python SMTP library.""" # Read config file from disk to get SMTP server host, port, username if not hasattr(sendmail, "host"): config = configparser.RawConfigParser() config.read(config_filename) ...
def sendmail(message, sender, recipients, config_filename): """Send email message using Python SMTP library.""" # Read config file from disk to get SMTP server host, port, username if not hasattr(sendmail, "host"): config = configparser.RawConfigParser() config.read(config_filename) ...
[ "Send", "email", "message", "using", "Python", "SMTP", "library", "." ]
awdeorio/mailmerge
python
https://github.com/awdeorio/mailmerge/blob/ff83f3b053ed6e182a98025873fcf3095d37b78b/mailmerge/api.py#L157-L206
[ "def", "sendmail", "(", "message", ",", "sender", ",", "recipients", ",", "config_filename", ")", ":", "# Read config file from disk to get SMTP server host, port, username", "if", "not", "hasattr", "(", "sendmail", ",", "\"host\"", ")", ":", "config", "=", "configpar...
ff83f3b053ed6e182a98025873fcf3095d37b78b
valid
create_sample_input_files
Create sample template email and database.
mailmerge/api.py
def create_sample_input_files(template_filename, database_filename, config_filename): """Create sample template email and database.""" print("Creating sample template email {}".format(template_filename)) if os.path.exists(template_filename): ...
def create_sample_input_files(template_filename, database_filename, config_filename): """Create sample template email and database.""" print("Creating sample template email {}".format(template_filename)) if os.path.exists(template_filename): ...
[ "Create", "sample", "template", "email", "and", "database", "." ]
awdeorio/mailmerge
python
https://github.com/awdeorio/mailmerge/blob/ff83f3b053ed6e182a98025873fcf3095d37b78b/mailmerge/api.py#L209-L278
[ "def", "create_sample_input_files", "(", "template_filename", ",", "database_filename", ",", "config_filename", ")", ":", "print", "(", "\"Creating sample template email {}\"", ".", "format", "(", "template_filename", ")", ")", "if", "os", ".", "path", ".", "exists", ...
ff83f3b053ed6e182a98025873fcf3095d37b78b
valid
main
Python API for mailmerge. mailmerge 0.1 by Andrew DeOrio <awdeorio@umich.edu>. A simple, command line mail merge tool. Render an email template for each line in a CSV database.
mailmerge/api.py
def main(sample=False, dry_run=True, limit=1, no_limit=False, database_filename=DATABASE_FILENAME_DEFAULT, template_filename=TEMPLATE_FILENAME_DEFAULT, config_filename=CONFIG_FILENAME_DEFAULT): """Python API for mailmerge. mailmerge 0.1 by Andrew DeOrio <aw...
def main(sample=False, dry_run=True, limit=1, no_limit=False, database_filename=DATABASE_FILENAME_DEFAULT, template_filename=TEMPLATE_FILENAME_DEFAULT, config_filename=CONFIG_FILENAME_DEFAULT): """Python API for mailmerge. mailmerge 0.1 by Andrew DeOrio <aw...
[ "Python", "API", "for", "mailmerge", "." ]
awdeorio/mailmerge
python
https://github.com/awdeorio/mailmerge/blob/ff83f3b053ed6e182a98025873fcf3095d37b78b/mailmerge/api.py#L281-L388
[ "def", "main", "(", "sample", "=", "False", ",", "dry_run", "=", "True", ",", "limit", "=", "1", ",", "no_limit", "=", "False", ",", "database_filename", "=", "DATABASE_FILENAME_DEFAULT", ",", "template_filename", "=", "TEMPLATE_FILENAME_DEFAULT", ",", "config_f...
ff83f3b053ed6e182a98025873fcf3095d37b78b
valid
cli
Command line interface.
mailmerge/__main__.py
def cli(sample, dry_run, limit, no_limit, database_filename, template_filename, config_filename): """Command line interface.""" # pylint: disable=too-many-arguments mailmerge.api.main( sample=sample, dry_run=dry_run, limit=limit, no_limit=no_limit, database_fi...
def cli(sample, dry_run, limit, no_limit, database_filename, template_filename, config_filename): """Command line interface.""" # pylint: disable=too-many-arguments mailmerge.api.main( sample=sample, dry_run=dry_run, limit=limit, no_limit=no_limit, database_fi...
[ "Command", "line", "interface", "." ]
awdeorio/mailmerge
python
https://github.com/awdeorio/mailmerge/blob/ff83f3b053ed6e182a98025873fcf3095d37b78b/mailmerge/__main__.py#L34-L46
[ "def", "cli", "(", "sample", ",", "dry_run", ",", "limit", ",", "no_limit", ",", "database_filename", ",", "template_filename", ",", "config_filename", ")", ":", "# pylint: disable=too-many-arguments", "mailmerge", ".", "api", ".", "main", "(", "sample", "=", "s...
ff83f3b053ed6e182a98025873fcf3095d37b78b
valid
_tailCallback
This is the "callable" version of the continuation, which sould only be accessible from the inside of the function to be continued. An attribute called "C" can be used in order to get back the public version of the continuation (for passing the continuation to another function).
tco/__init__.py
def _tailCallback(f, uid): """ This is the "callable" version of the continuation, which sould only be accessible from the inside of the function to be continued. An attribute called "C" can be used in order to get back the public version of the continuation (for passing the continuation to another ...
def _tailCallback(f, uid): """ This is the "callable" version of the continuation, which sould only be accessible from the inside of the function to be continued. An attribute called "C" can be used in order to get back the public version of the continuation (for passing the continuation to another ...
[ "This", "is", "the", "callable", "version", "of", "the", "continuation", "which", "sould", "only", "be", "accessible", "from", "the", "inside", "of", "the", "function", "to", "be", "continued", ".", "An", "attribute", "called", "C", "can", "be", "used", "i...
baruchel/tco
python
https://github.com/baruchel/tco/blob/640b525bbd91e5e787c6ebc7d19f24795aa0f9ef/tco/__init__.py#L12-L23
[ "def", "_tailCallback", "(", "f", ",", "uid", ")", ":", "def", "t", "(", "*", "args", ")", ":", "raise", "_TailCall", "(", "f", ",", "args", ",", "uid", ")", "t", ".", "C", "=", "f", "return", "t" ]
640b525bbd91e5e787c6ebc7d19f24795aa0f9ef
valid
with_continuations
A decorator for defining tail-call optimized functions. Example ------- @with_continuations() def factorial(n, k, self=None): return self(n-1, k*n) if n > 1 else k @with_continuations() def identity(x, self=None): return x @with...
tco/__init__.py
def with_continuations(**c): """ A decorator for defining tail-call optimized functions. Example ------- @with_continuations() def factorial(n, k, self=None): return self(n-1, k*n) if n > 1 else k @with_continuations() def identity(x, self=None): ...
def with_continuations(**c): """ A decorator for defining tail-call optimized functions. Example ------- @with_continuations() def factorial(n, k, self=None): return self(n-1, k*n) if n > 1 else k @with_continuations() def identity(x, self=None): ...
[ "A", "decorator", "for", "defining", "tail", "-", "call", "optimized", "functions", "." ]
baruchel/tco
python
https://github.com/baruchel/tco/blob/640b525bbd91e5e787c6ebc7d19f24795aa0f9ef/tco/__init__.py#L57-L87
[ "def", "with_continuations", "(", "*", "*", "c", ")", ":", "if", "len", "(", "c", ")", ":", "keys", ",", "k", "=", "zip", "(", "*", "c", ".", "items", "(", ")", ")", "else", ":", "keys", ",", "k", "=", "tuple", "(", "[", "]", ")", ",", "t...
640b525bbd91e5e787c6ebc7d19f24795aa0f9ef
valid
parse_int_list
Parses a string of numbers and ranges into a list of integers. Ranges are separated by dashes and inclusive of both the start and end number. Example: parse_int_list("8 9 10,11-13") == [8,9,10,11,12,13]
mhctools/cli/parsing_helpers.py
def parse_int_list(string): """ Parses a string of numbers and ranges into a list of integers. Ranges are separated by dashes and inclusive of both the start and end number. Example: parse_int_list("8 9 10,11-13") == [8,9,10,11,12,13] """ integers = [] for comma_part in string.split...
def parse_int_list(string): """ Parses a string of numbers and ranges into a list of integers. Ranges are separated by dashes and inclusive of both the start and end number. Example: parse_int_list("8 9 10,11-13") == [8,9,10,11,12,13] """ integers = [] for comma_part in string.split...
[ "Parses", "a", "string", "of", "numbers", "and", "ranges", "into", "a", "list", "of", "integers", ".", "Ranges", "are", "separated", "by", "dashes", "and", "inclusive", "of", "both", "the", "start", "and", "end", "number", "." ]
openvax/mhctools
python
https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/cli/parsing_helpers.py#L17-L37
[ "def", "parse_int_list", "(", "string", ")", ":", "integers", "=", "[", "]", "for", "comma_part", "in", "string", ".", "split", "(", "\",\"", ")", ":", "for", "substring", "in", "comma_part", ".", "split", "(", "\" \"", ")", ":", "if", "len", "(", "s...
b329b4dccd60fae41296816b8cbfe15d6ca07e67
valid
AbstractRequest.sanitize_params
Request params can be extracted from the ``**kwargs`` Arguments starting with `_` will be stripped from it, so they can be used as an argument for the request (eg. "_headers" → "headers" in the kwargs returned by this function while "headers" would be inserted into the parameters ...
peony/requests.py
def sanitize_params(method, **kwargs): """ Request params can be extracted from the ``**kwargs`` Arguments starting with `_` will be stripped from it, so they can be used as an argument for the request (eg. "_headers" → "headers" in the kwargs returned by this functi...
def sanitize_params(method, **kwargs): """ Request params can be extracted from the ``**kwargs`` Arguments starting with `_` will be stripped from it, so they can be used as an argument for the request (eg. "_headers" → "headers" in the kwargs returned by this functi...
[ "Request", "params", "can", "be", "extracted", "from", "the", "**", "kwargs" ]
odrling/peony-twitter
python
https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/requests.py#L49-L110
[ "def", "sanitize_params", "(", "method", ",", "*", "*", "kwargs", ")", ":", "# items which does not have a key starting with `_`", "items", "=", "[", "(", "key", ",", "value", ")", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", "if", "...
967f98e16e1889389540f2e6acbf7cc7a1a80203
valid
BasePeonyClient._get_base_url
create the base url for the api Parameters ---------- base_url : str format of the base_url using {api} and {version} api : str name of the api to use version : str version of the api Returns ------- str th...
peony/client.py
def _get_base_url(base_url, api, version): """ create the base url for the api Parameters ---------- base_url : str format of the base_url using {api} and {version} api : str name of the api to use version : str version of ...
def _get_base_url(base_url, api, version): """ create the base url for the api Parameters ---------- base_url : str format of the base_url using {api} and {version} api : str name of the api to use version : str version of ...
[ "create", "the", "base", "url", "for", "the", "api" ]
odrling/peony-twitter
python
https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/client.py#L187-L219
[ "def", "_get_base_url", "(", "base_url", ",", "api", ",", "version", ")", ":", "format_args", "=", "{", "}", "if", "\"{api}\"", "in", "base_url", ":", "if", "api", "==", "\"\"", ":", "base_url", "=", "base_url", ".", "replace", "(", "'{api}.'", ",", "'...
967f98e16e1889389540f2e6acbf7cc7a1a80203
valid
BasePeonyClient.request
Make requests to the REST API Parameters ---------- future : asyncio.Future Future used to return the response method : str Method to be used by the request url : str URL of the resource headers : .oauth.PeonyHeaders Custom...
peony/client.py
async def request(self, method, url, future, headers=None, session=None, encoding=None, **kwargs): """ Make requests to the REST API Parameters ---------- future : asyncio.Future ...
async def request(self, method, url, future, headers=None, session=None, encoding=None, **kwargs): """ Make requests to the REST API Parameters ---------- future : asyncio.Future ...
[ "Make", "requests", "to", "the", "REST", "API" ]
odrling/peony-twitter
python
https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/client.py#L288-L345
[ "async", "def", "request", "(", "self", ",", "method", ",", "url", ",", "future", ",", "headers", "=", "None", ",", "session", "=", "None", ",", "encoding", "=", "None", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "setup", "# prepare req...
967f98e16e1889389540f2e6acbf7cc7a1a80203
valid
BasePeonyClient.stream_request
Make requests to the Streaming API Parameters ---------- method : str Method to be used by the request url : str URL of the resource headers : dict Custom headers (doesn't overwrite `Authorization` headers) _session : aiohttp.ClientSes...
peony/client.py
def stream_request(self, method, url, headers=None, _session=None, *args, **kwargs): """ Make requests to the Streaming API Parameters ---------- method : str Method to be used by the request url : str URL of the resourc...
def stream_request(self, method, url, headers=None, _session=None, *args, **kwargs): """ Make requests to the Streaming API Parameters ---------- method : str Method to be used by the request url : str URL of the resourc...
[ "Make", "requests", "to", "the", "Streaming", "API" ]
odrling/peony-twitter
python
https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/client.py#L347-L377
[ "def", "stream_request", "(", "self", ",", "method", ",", "url", ",", "headers", "=", "None", ",", "_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "StreamResponse", "(", "method", "=", "method", ",", "url", "="...
967f98e16e1889389540f2e6acbf7cc7a1a80203
valid
BasePeonyClient.get_tasks
Get the tasks attached to the instance Returns ------- list List of tasks (:class:`asyncio.Task`)
peony/client.py
def get_tasks(self): """ Get the tasks attached to the instance Returns ------- list List of tasks (:class:`asyncio.Task`) """ tasks = self._get_tasks() tasks.extend(self._streams.get_tasks(self)) return tasks
def get_tasks(self): """ Get the tasks attached to the instance Returns ------- list List of tasks (:class:`asyncio.Task`) """ tasks = self._get_tasks() tasks.extend(self._streams.get_tasks(self)) return tasks
[ "Get", "the", "tasks", "attached", "to", "the", "instance" ]
odrling/peony-twitter
python
https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/client.py#L388-L400
[ "def", "get_tasks", "(", "self", ")", ":", "tasks", "=", "self", ".", "_get_tasks", "(", ")", "tasks", ".", "extend", "(", "self", ".", "_streams", ".", "get_tasks", "(", "self", ")", ")", "return", "tasks" ]
967f98e16e1889389540f2e6acbf7cc7a1a80203