id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
42,600 | googleapis/gax-python | google/gapic/longrunning/operations_client.py | OperationsClient.delete_operation | def delete_operation(self, name, options=None):
"""
Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
``google.rpc.Code.U... | python | def delete_operation(self, name, options=None):
"""
Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
``google.rpc.Code.U... | [
"def",
"delete_operation",
"(",
"self",
",",
"name",
",",
"options",
"=",
"None",
")",
":",
"# Create the request object.",
"request",
"=",
"operations_pb2",
".",
"DeleteOperationRequest",
"(",
"name",
"=",
"name",
")",
"self",
".",
"_delete_operation",
"(",
"re... | Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
``google.rpc.Code.UNIMPLEMENTED``.
Example:
>>> from google.gapic.lo... | [
"Deletes",
"a",
"long",
"-",
"running",
"operation",
".",
"This",
"method",
"indicates",
"that",
"the",
"client",
"is",
"no",
"longer",
"interested",
"in",
"the",
"operation",
"result",
".",
"It",
"does",
"not",
"cancel",
"the",
"operation",
".",
"If",
"th... | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gapic/longrunning/operations_client.py#L298-L322 |
42,601 | googleapis/gax-python | google/gax/utils/oneof.py | check_oneof | def check_oneof(**kwargs):
"""Raise ValueError if more than one keyword argument is not none.
Args:
kwargs (dict): The keyword arguments sent to the function.
Returns: None
Raises:
ValueError: If more than one entry in kwargs is not none.
"""
# Sanity check: If no keyword argu... | python | def check_oneof(**kwargs):
"""Raise ValueError if more than one keyword argument is not none.
Args:
kwargs (dict): The keyword arguments sent to the function.
Returns: None
Raises:
ValueError: If more than one entry in kwargs is not none.
"""
# Sanity check: If no keyword argu... | [
"def",
"check_oneof",
"(",
"*",
"*",
"kwargs",
")",
":",
"# Sanity check: If no keyword arguments were sent, this is fine.",
"if",
"not",
"kwargs",
":",
"return",
"None",
"not_nones",
"=",
"[",
"val",
"for",
"val",
"in",
"kwargs",
".",
"values",
"(",
")",
"if",
... | Raise ValueError if more than one keyword argument is not none.
Args:
kwargs (dict): The keyword arguments sent to the function.
Returns: None
Raises:
ValueError: If more than one entry in kwargs is not none. | [
"Raise",
"ValueError",
"if",
"more",
"than",
"one",
"keyword",
"argument",
"is",
"not",
"none",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/utils/oneof.py#L35-L54 |
42,602 | googleapis/gax-python | google/gax/api_callable.py | _bundleable | def _bundleable(desc):
"""Creates a function that transforms an API call into a bundling call.
It transform a_func from an API call that receives the requests and returns
the response into a callable that receives the same request, and
returns a :class:`bundling.Event`.
The returned Event object c... | python | def _bundleable(desc):
"""Creates a function that transforms an API call into a bundling call.
It transform a_func from an API call that receives the requests and returns
the response into a callable that receives the same request, and
returns a :class:`bundling.Event`.
The returned Event object c... | [
"def",
"_bundleable",
"(",
"desc",
")",
":",
"def",
"inner",
"(",
"a_func",
",",
"settings",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Schedules execution of a bundling task.\"\"\"",
"if",
"not",
"settings",
".",
"bundler",
":",
"return",
"a_fu... | Creates a function that transforms an API call into a bundling call.
It transform a_func from an API call that receives the requests and returns
the response into a callable that receives the same request, and
returns a :class:`bundling.Event`.
The returned Event object can be used to obtain the event... | [
"Creates",
"a",
"function",
"that",
"transforms",
"an",
"API",
"call",
"into",
"a",
"bundling",
"call",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/api_callable.py#L43-L71 |
42,603 | googleapis/gax-python | google/gax/api_callable.py | _page_streamable | def _page_streamable(page_descriptor):
"""Creates a function that yields an iterable to performs page-streaming.
Args:
page_descriptor (:class:`PageDescriptor`): indicates the structure
of page streaming to be performed.
Returns:
Callable: A function that returns an iterator.
... | python | def _page_streamable(page_descriptor):
"""Creates a function that yields an iterable to performs page-streaming.
Args:
page_descriptor (:class:`PageDescriptor`): indicates the structure
of page streaming to be performed.
Returns:
Callable: A function that returns an iterator.
... | [
"def",
"_page_streamable",
"(",
"page_descriptor",
")",
":",
"def",
"inner",
"(",
"a_func",
",",
"settings",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Actual page-streaming based on the settings.\"\"\"",
"page_iterator",
"=",
"gax",
".",
"PageIterato... | Creates a function that yields an iterable to performs page-streaming.
Args:
page_descriptor (:class:`PageDescriptor`): indicates the structure
of page streaming to be performed.
Returns:
Callable: A function that returns an iterator. | [
"Creates",
"a",
"function",
"that",
"yields",
"an",
"iterable",
"to",
"performs",
"page",
"-",
"streaming",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/api_callable.py#L74-L94 |
42,604 | googleapis/gax-python | google/gax/api_callable.py | construct_settings | def construct_settings(
service_name, client_config, config_override,
retry_names, bundle_descriptors=None, page_descriptors=None,
metrics_headers=(), kwargs=None):
"""Constructs a dictionary mapping method names to _CallSettings.
The ``client_config`` parameter is parsed from a client ... | python | def construct_settings(
service_name, client_config, config_override,
retry_names, bundle_descriptors=None, page_descriptors=None,
metrics_headers=(), kwargs=None):
"""Constructs a dictionary mapping method names to _CallSettings.
The ``client_config`` parameter is parsed from a client ... | [
"def",
"construct_settings",
"(",
"service_name",
",",
"client_config",
",",
"config_override",
",",
"retry_names",
",",
"bundle_descriptors",
"=",
"None",
",",
"page_descriptors",
"=",
"None",
",",
"metrics_headers",
"=",
"(",
")",
",",
"kwargs",
"=",
"None",
"... | Constructs a dictionary mapping method names to _CallSettings.
The ``client_config`` parameter is parsed from a client configuration JSON
file of the form:
.. code-block:: json
{
"interfaces": {
"google.fake.v1.ServiceName": {
"retry_codes": {
"idemp... | [
"Constructs",
"a",
"dictionary",
"mapping",
"method",
"names",
"to",
"_CallSettings",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/api_callable.py#L216-L360 |
42,605 | googleapis/gax-python | google/gax/api_callable.py | _catch_errors | def _catch_errors(a_func, to_catch):
"""Updates a_func to wrap exceptions with GaxError
Args:
a_func (callable): A callable.
to_catch (list[Exception]): Configures the exceptions to wrap.
Returns:
Callable: A function that will wrap certain exceptions with GaxError
"""
def ... | python | def _catch_errors(a_func, to_catch):
"""Updates a_func to wrap exceptions with GaxError
Args:
a_func (callable): A callable.
to_catch (list[Exception]): Configures the exceptions to wrap.
Returns:
Callable: A function that will wrap certain exceptions with GaxError
"""
def ... | [
"def",
"_catch_errors",
"(",
"a_func",
",",
"to_catch",
")",
":",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Wraps specified exceptions\"\"\"",
"try",
":",
"return",
"a_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")... | Updates a_func to wrap exceptions with GaxError
Args:
a_func (callable): A callable.
to_catch (list[Exception]): Configures the exceptions to wrap.
Returns:
Callable: A function that will wrap certain exceptions with GaxError | [
"Updates",
"a_func",
"to",
"wrap",
"exceptions",
"with",
"GaxError"
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/api_callable.py#L363-L382 |
42,606 | googleapis/gax-python | google/gax/api_callable.py | create_api_call | def create_api_call(func, settings):
"""Converts an rpc call into an API call governed by the settings.
In typical usage, ``func`` will be a callable used to make an rpc request.
This will mostly likely be a bound method from a request stub used to make
an rpc call.
The result is created by applyi... | python | def create_api_call(func, settings):
"""Converts an rpc call into an API call governed by the settings.
In typical usage, ``func`` will be a callable used to make an rpc request.
This will mostly likely be a bound method from a request stub used to make
an rpc call.
The result is created by applyi... | [
"def",
"create_api_call",
"(",
"func",
",",
"settings",
")",
":",
"def",
"base_caller",
"(",
"api_call",
",",
"_",
",",
"*",
"args",
")",
":",
"\"\"\"Simply call api_call and ignore settings.\"\"\"",
"return",
"api_call",
"(",
"*",
"args",
")",
"def",
"inner",
... | Converts an rpc call into an API call governed by the settings.
In typical usage, ``func`` will be a callable used to make an rpc request.
This will mostly likely be a bound method from a request stub used to make
an rpc call.
The result is created by applying a series of function decorators defined
... | [
"Converts",
"an",
"rpc",
"call",
"into",
"an",
"API",
"call",
"governed",
"by",
"the",
"settings",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/api_callable.py#L407-L464 |
42,607 | googleapis/gax-python | google/gax/utils/protobuf.py | get | def get(pb_or_dict, key, default=_SENTINEL):
"""Retrieve the given key off of the object.
If a default is specified, return it if the key is not found, otherwise
raise KeyError.
Args:
pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
object.
key (str): The ... | python | def get(pb_or_dict, key, default=_SENTINEL):
"""Retrieve the given key off of the object.
If a default is specified, return it if the key is not found, otherwise
raise KeyError.
Args:
pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
object.
key (str): The ... | [
"def",
"get",
"(",
"pb_or_dict",
",",
"key",
",",
"default",
"=",
"_SENTINEL",
")",
":",
"# We may need to get a nested key. Resolve this.",
"key",
",",
"subkey",
"=",
"_resolve_subkeys",
"(",
"key",
")",
"# Attempt to get the value from the two types of objects we know bao... | Retrieve the given key off of the object.
If a default is specified, return it if the key is not found, otherwise
raise KeyError.
Args:
pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
object.
key (str): The key to retrieve from the object in question.
... | [
"Retrieve",
"the",
"given",
"key",
"off",
"of",
"the",
"object",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/utils/protobuf.py#L42-L91 |
42,608 | googleapis/gax-python | google/gax/utils/protobuf.py | set | def set(pb_or_dict, key, value):
"""Set the given key on the object.
Args:
pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
object.
key (str): The key on the object in question.
value (Any): The value to set.
Raises:
TypeError: If pb_or_dict is... | python | def set(pb_or_dict, key, value):
"""Set the given key on the object.
Args:
pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
object.
key (str): The key on the object in question.
value (Any): The value to set.
Raises:
TypeError: If pb_or_dict is... | [
"def",
"set",
"(",
"pb_or_dict",
",",
"key",
",",
"value",
")",
":",
"# pylint: disable=redefined-builtin,too-many-branches",
"# redefined-builtin: We want 'set' to be part of the public interface.",
"# too-many-branches: This method is inherently complex.",
"# Sanity check: Is our target ... | Set the given key on the object.
Args:
pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
object.
key (str): The key on the object in question.
value (Any): The value to set.
Raises:
TypeError: If pb_or_dict is not a Message or Mapping. | [
"Set",
"the",
"given",
"key",
"on",
"the",
"object",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/utils/protobuf.py#L94-L151 |
42,609 | googleapis/gax-python | google/gax/utils/protobuf.py | setdefault | def setdefault(pb_or_dict, key, value):
"""Set the key on the object to the value if the current value is falsy.
Because protobuf Messages do not distinguish between unset values and
falsy ones particularly well, this method treats any falsy value
(e.g. 0, empty list) as a target to be overwritten, on ... | python | def setdefault(pb_or_dict, key, value):
"""Set the key on the object to the value if the current value is falsy.
Because protobuf Messages do not distinguish between unset values and
falsy ones particularly well, this method treats any falsy value
(e.g. 0, empty list) as a target to be overwritten, on ... | [
"def",
"setdefault",
"(",
"pb_or_dict",
",",
"key",
",",
"value",
")",
":",
"if",
"not",
"get",
"(",
"pb_or_dict",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"set",
"(",
"pb_or_dict",
",",
"key",
",",
"value",
")"
] | Set the key on the object to the value if the current value is falsy.
Because protobuf Messages do not distinguish between unset values and
falsy ones particularly well, this method treats any falsy value
(e.g. 0, empty list) as a target to be overwritten, on both Messages
and dictionaries.
Args:
... | [
"Set",
"the",
"key",
"on",
"the",
"object",
"to",
"the",
"value",
"if",
"the",
"current",
"value",
"is",
"falsy",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/utils/protobuf.py#L154-L172 |
42,610 | googleapis/gax-python | google/gax/utils/protobuf.py | _resolve_subkeys | def _resolve_subkeys(key, separator='.'):
"""Given a key which may actually be a nested key, return the top level
key and any nested subkeys as separate values.
Args:
key (str): A string that may or may not contain the separator.
separator (str): The namespace separator. Defaults to `.`.
... | python | def _resolve_subkeys(key, separator='.'):
"""Given a key which may actually be a nested key, return the top level
key and any nested subkeys as separate values.
Args:
key (str): A string that may or may not contain the separator.
separator (str): The namespace separator. Defaults to `.`.
... | [
"def",
"_resolve_subkeys",
"(",
"key",
",",
"separator",
"=",
"'.'",
")",
":",
"subkey",
"=",
"None",
"if",
"separator",
"in",
"key",
":",
"index",
"=",
"key",
".",
"index",
"(",
"separator",
")",
"subkey",
"=",
"key",
"[",
"index",
"+",
"1",
":",
... | Given a key which may actually be a nested key, return the top level
key and any nested subkeys as separate values.
Args:
key (str): A string that may or may not contain the separator.
separator (str): The namespace separator. Defaults to `.`.
Returns:
Tuple[str, str]: The key and ... | [
"Given",
"a",
"key",
"which",
"may",
"actually",
"be",
"a",
"nested",
"key",
"return",
"the",
"top",
"level",
"key",
"and",
"any",
"nested",
"subkeys",
"as",
"separate",
"values",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/utils/protobuf.py#L175-L191 |
42,611 | googleapis/gax-python | google/gax/__init__.py | _CallSettings.merge | def merge(self, options):
"""Returns new _CallSettings merged from this and a CallOptions object.
Note that passing if the CallOptions instance specifies a page_token,
the merged _CallSettings will have ``flatten_pages`` disabled. This
permits toggling per-resource/per-page page streami... | python | def merge(self, options):
"""Returns new _CallSettings merged from this and a CallOptions object.
Note that passing if the CallOptions instance specifies a page_token,
the merged _CallSettings will have ``flatten_pages`` disabled. This
permits toggling per-resource/per-page page streami... | [
"def",
"merge",
"(",
"self",
",",
"options",
")",
":",
"if",
"not",
"options",
":",
"return",
"_CallSettings",
"(",
"timeout",
"=",
"self",
".",
"timeout",
",",
"retry",
"=",
"self",
".",
"retry",
",",
"page_descriptor",
"=",
"self",
".",
"page_descripto... | Returns new _CallSettings merged from this and a CallOptions object.
Note that passing if the CallOptions instance specifies a page_token,
the merged _CallSettings will have ``flatten_pages`` disabled. This
permits toggling per-resource/per-page page streaming.
Args:
option... | [
"Returns",
"new",
"_CallSettings",
"merged",
"from",
"this",
"and",
"a",
"CallOptions",
"object",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/__init__.py#L112-L165 |
42,612 | googleapis/gax-python | google/gax/__init__.py | _OperationFuture.cancel | def cancel(self):
"""If last Operation's value of `done` is true, returns false;
otherwise, issues OperationsClient.cancel_operation and returns true.
"""
if self.done():
return False
self._client.cancel_operation(self._operation.name)
return True | python | def cancel(self):
"""If last Operation's value of `done` is true, returns false;
otherwise, issues OperationsClient.cancel_operation and returns true.
"""
if self.done():
return False
self._client.cancel_operation(self._operation.name)
return True | [
"def",
"cancel",
"(",
"self",
")",
":",
"if",
"self",
".",
"done",
"(",
")",
":",
"return",
"False",
"self",
".",
"_client",
".",
"cancel_operation",
"(",
"self",
".",
"_operation",
".",
"name",
")",
"return",
"True"
] | If last Operation's value of `done` is true, returns false;
otherwise, issues OperationsClient.cancel_operation and returns true. | [
"If",
"last",
"Operation",
"s",
"value",
"of",
"done",
"is",
"true",
"returns",
"false",
";",
"otherwise",
"issues",
"OperationsClient",
".",
"cancel_operation",
"and",
"returns",
"true",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/__init__.py#L574-L582 |
42,613 | googleapis/gax-python | google/gax/__init__.py | _OperationFuture.result | def result(self, timeout=None):
"""Enters polling loop on OperationsClient.get_operation, and once
Operation.done is true, then returns Operation.response if successful or
throws GaxError if not successful.
This method will wait up to timeout seconds. If the call hasn't
complete... | python | def result(self, timeout=None):
"""Enters polling loop on OperationsClient.get_operation, and once
Operation.done is true, then returns Operation.response if successful or
throws GaxError if not successful.
This method will wait up to timeout seconds. If the call hasn't
complete... | [
"def",
"result",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"# Check exceptional case: raise if no response",
"if",
"not",
"self",
".",
"_poll",
"(",
"timeout",
")",
".",
"HasField",
"(",
"'response'",
")",
":",
"raise",
"GaxError",
"(",
"self",
"."... | Enters polling loop on OperationsClient.get_operation, and once
Operation.done is true, then returns Operation.response if successful or
throws GaxError if not successful.
This method will wait up to timeout seconds. If the call hasn't
completed in timeout seconds, then a RetryError wil... | [
"Enters",
"polling",
"loop",
"on",
"OperationsClient",
".",
"get_operation",
"and",
"once",
"Operation",
".",
"done",
"is",
"true",
"then",
"returns",
"Operation",
".",
"response",
"if",
"successful",
"or",
"throws",
"GaxError",
"if",
"not",
"successful",
"."
] | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/__init__.py#L584-L599 |
42,614 | googleapis/gax-python | google/gax/__init__.py | _OperationFuture.add_done_callback | def add_done_callback(self, fn): # pylint: disable=invalid-name
"""Enters a polling loop on OperationsClient.get_operation, and once the
operation is done or cancelled, calls the function with this
_OperationFuture. Added callables are called in the order that they were
added.
"... | python | def add_done_callback(self, fn): # pylint: disable=invalid-name
"""Enters a polling loop on OperationsClient.get_operation, and once the
operation is done or cancelled, calls the function with this
_OperationFuture. Added callables are called in the order that they were
added.
"... | [
"def",
"add_done_callback",
"(",
"self",
",",
"fn",
")",
":",
"# pylint: disable=invalid-name",
"if",
"self",
".",
"_operation",
".",
"done",
":",
"_try_callback",
"(",
"self",
",",
"fn",
")",
"else",
":",
"self",
".",
"_queue",
".",
"put",
"(",
"dill",
... | Enters a polling loop on OperationsClient.get_operation, and once the
operation is done or cancelled, calls the function with this
_OperationFuture. Added callables are called in the order that they were
added. | [
"Enters",
"a",
"polling",
"loop",
"on",
"OperationsClient",
".",
"get_operation",
"and",
"once",
"the",
"operation",
"is",
"done",
"or",
"cancelled",
"calls",
"the",
"function",
"with",
"this",
"_OperationFuture",
".",
"Added",
"callables",
"are",
"called",
"in"... | 309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/__init__.py#L622-L634 |
42,615 | ambitioninc/django-query-builder | querybuilder/query.py | Join.get_sql | def get_sql(self):
"""
Generates the JOIN sql for the join tables and join condition
:rtype: str
:return: the JOIN sql for the join tables and join condition
"""
return '{0} {1} ON {2}'.format(self.join_type, self.right_table.get_sql(), self.get_condition()) | python | def get_sql(self):
"""
Generates the JOIN sql for the join tables and join condition
:rtype: str
:return: the JOIN sql for the join tables and join condition
"""
return '{0} {1} ON {2}'.format(self.join_type, self.right_table.get_sql(), self.get_condition()) | [
"def",
"get_sql",
"(",
"self",
")",
":",
"return",
"'{0} {1} ON {2}'",
".",
"format",
"(",
"self",
".",
"join_type",
",",
"self",
".",
"right_table",
".",
"get_sql",
"(",
")",
",",
"self",
".",
"get_condition",
"(",
")",
")"
] | Generates the JOIN sql for the join tables and join condition
:rtype: str
:return: the JOIN sql for the join tables and join condition | [
"Generates",
"the",
"JOIN",
"sql",
"for",
"the",
"join",
"tables",
"and",
"join",
"condition"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L94-L101 |
42,616 | ambitioninc/django-query-builder | querybuilder/query.py | Join.set_left_table | def set_left_table(self, left_table=None):
"""
Sets the left table for this join clause. If no table is specified, the first table
in the query will be used
:type left_table: str or dict or :class:`Table <querybuilder.tables.Table>` or None
:param left_table: The left table bein... | python | def set_left_table(self, left_table=None):
"""
Sets the left table for this join clause. If no table is specified, the first table
in the query will be used
:type left_table: str or dict or :class:`Table <querybuilder.tables.Table>` or None
:param left_table: The left table bein... | [
"def",
"set_left_table",
"(",
"self",
",",
"left_table",
"=",
"None",
")",
":",
"if",
"left_table",
":",
"self",
".",
"left_table",
"=",
"TableFactory",
"(",
"table",
"=",
"left_table",
",",
"owner",
"=",
"self",
".",
"owner",
",",
")",
"else",
":",
"s... | Sets the left table for this join clause. If no table is specified, the first table
in the query will be used
:type left_table: str or dict or :class:`Table <querybuilder.tables.Table>` or None
:param left_table: The left table being joined with. This can be a string of the table
na... | [
"Sets",
"the",
"left",
"table",
"for",
"this",
"join",
"clause",
".",
"If",
"no",
"table",
"is",
"specified",
"the",
"first",
"table",
"in",
"the",
"query",
"will",
"be",
"used"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L103-L119 |
42,617 | ambitioninc/django-query-builder | querybuilder/query.py | Join.get_left_table | def get_left_table(self):
"""
Returns the left table if one was specified, otherwise the first
table in the query is returned
:rtype: :class:`Table <querybuilder.tables.Table>`
:return: the left table if one was specified, otherwise the first table in the query
"""
... | python | def get_left_table(self):
"""
Returns the left table if one was specified, otherwise the first
table in the query is returned
:rtype: :class:`Table <querybuilder.tables.Table>`
:return: the left table if one was specified, otherwise the first table in the query
"""
... | [
"def",
"get_left_table",
"(",
"self",
")",
":",
"if",
"self",
".",
"left_table",
":",
"return",
"self",
".",
"left_table",
"if",
"len",
"(",
"self",
".",
"owner",
".",
"tables",
")",
":",
"return",
"self",
".",
"owner",
".",
"tables",
"[",
"0",
"]"
] | Returns the left table if one was specified, otherwise the first
table in the query is returned
:rtype: :class:`Table <querybuilder.tables.Table>`
:return: the left table if one was specified, otherwise the first table in the query | [
"Returns",
"the",
"left",
"table",
"if",
"one",
"was",
"specified",
"otherwise",
"the",
"first",
"table",
"in",
"the",
"query",
"is",
"returned"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L121-L132 |
42,618 | ambitioninc/django-query-builder | querybuilder/query.py | Join.get_all_related_objects | def get_all_related_objects(self, table):
"""
Fix for django 1.10 to replace deprecated code. Keep support for django 1.7
"""
# Django 1.7 method
if hasattr(table.model._meta, 'get_all_related_objects'):
return table.model._meta.get_all_related_objects()
else:... | python | def get_all_related_objects(self, table):
"""
Fix for django 1.10 to replace deprecated code. Keep support for django 1.7
"""
# Django 1.7 method
if hasattr(table.model._meta, 'get_all_related_objects'):
return table.model._meta.get_all_related_objects()
else:... | [
"def",
"get_all_related_objects",
"(",
"self",
",",
"table",
")",
":",
"# Django 1.7 method",
"if",
"hasattr",
"(",
"table",
".",
"model",
".",
"_meta",
",",
"'get_all_related_objects'",
")",
":",
"return",
"table",
".",
"model",
".",
"_meta",
".",
"get_all_re... | Fix for django 1.10 to replace deprecated code. Keep support for django 1.7 | [
"Fix",
"for",
"django",
"1",
".",
"10",
"to",
"replace",
"deprecated",
"code",
".",
"Keep",
"support",
"for",
"django",
"1",
".",
"7"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L134-L146 |
42,619 | ambitioninc/django-query-builder | querybuilder/query.py | Join.set_right_table | def set_right_table(self, table):
"""
Sets the right table for this join clause and try to automatically set the condition
if one isn't specified
"""
self.right_table = table
if self.left_table is None:
return
# find table prefix
if type(self.... | python | def set_right_table(self, table):
"""
Sets the right table for this join clause and try to automatically set the condition
if one isn't specified
"""
self.right_table = table
if self.left_table is None:
return
# find table prefix
if type(self.... | [
"def",
"set_right_table",
"(",
"self",
",",
"table",
")",
":",
"self",
".",
"right_table",
"=",
"table",
"if",
"self",
".",
"left_table",
"is",
"None",
":",
"return",
"# find table prefix",
"if",
"type",
"(",
"self",
".",
"left_table",
")",
"is",
"ModelTab... | Sets the right table for this join clause and try to automatically set the condition
if one isn't specified | [
"Sets",
"the",
"right",
"table",
"for",
"this",
"join",
"clause",
"and",
"try",
"to",
"automatically",
"set",
"the",
"condition",
"if",
"one",
"isn",
"t",
"specified"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L148-L182 |
42,620 | ambitioninc/django-query-builder | querybuilder/query.py | Join.get_condition | def get_condition(self):
"""
Determines the condition to be used in the condition part of the join sql.
:return: The condition for the join clause
:rtype: str or None
"""
if self.condition:
return self.condition
if type(self.right_table) is ModelTabl... | python | def get_condition(self):
"""
Determines the condition to be used in the condition part of the join sql.
:return: The condition for the join clause
:rtype: str or None
"""
if self.condition:
return self.condition
if type(self.right_table) is ModelTabl... | [
"def",
"get_condition",
"(",
"self",
")",
":",
"if",
"self",
".",
"condition",
":",
"return",
"self",
".",
"condition",
"if",
"type",
"(",
"self",
".",
"right_table",
")",
"is",
"ModelTable",
"and",
"type",
"(",
"self",
".",
"right_table",
")",
"is",
"... | Determines the condition to be used in the condition part of the join sql.
:return: The condition for the join clause
:rtype: str or None | [
"Determines",
"the",
"condition",
"to",
"be",
"used",
"in",
"the",
"condition",
"part",
"of",
"the",
"join",
"sql",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L184-L229 |
42,621 | ambitioninc/django-query-builder | querybuilder/query.py | Where.get_sql | def get_sql(self):
"""
Builds and returns the WHERE portion of the sql
:return: the WHERE portion of the sql
:rtype: str
"""
# reset arg index and args
self.arg_index = 0
self.args = {}
# build the WHERE sql portion if needed
if len(self.... | python | def get_sql(self):
"""
Builds and returns the WHERE portion of the sql
:return: the WHERE portion of the sql
:rtype: str
"""
# reset arg index and args
self.arg_index = 0
self.args = {}
# build the WHERE sql portion if needed
if len(self.... | [
"def",
"get_sql",
"(",
"self",
")",
":",
"# reset arg index and args",
"self",
".",
"arg_index",
"=",
"0",
"self",
".",
"args",
"=",
"{",
"}",
"# build the WHERE sql portion if needed",
"if",
"len",
"(",
"self",
".",
"wheres",
")",
":",
"where",
"=",
"self",... | Builds and returns the WHERE portion of the sql
:return: the WHERE portion of the sql
:rtype: str | [
"Builds",
"and",
"returns",
"the",
"WHERE",
"portion",
"of",
"the",
"sql"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L284-L299 |
42,622 | ambitioninc/django-query-builder | querybuilder/query.py | Where.get_condition_value | def get_condition_value(self, operator, value):
"""
Gets the condition value based on the operator and value
:param operator: the condition operator name
:type operator: str
:param value: the value to be formatted based on the condition operator
:type value: object
... | python | def get_condition_value(self, operator, value):
"""
Gets the condition value based on the operator and value
:param operator: the condition operator name
:type operator: str
:param value: the value to be formatted based on the condition operator
:type value: object
... | [
"def",
"get_condition_value",
"(",
"self",
",",
"operator",
",",
"value",
")",
":",
"if",
"operator",
"in",
"(",
"'contains'",
",",
"'icontains'",
")",
":",
"value",
"=",
"'%{0}%'",
".",
"format",
"(",
"value",
")",
"elif",
"operator",
"==",
"'startswith'"... | Gets the condition value based on the operator and value
:param operator: the condition operator name
:type operator: str
:param value: the value to be formatted based on the condition operator
:type value: object
:return: the comparison operator from the Where class's comparis... | [
"Gets",
"the",
"condition",
"value",
"based",
"on",
"the",
"operator",
"and",
"value"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L310-L326 |
42,623 | ambitioninc/django-query-builder | querybuilder/query.py | Where.set_arg | def set_arg(self, value):
"""
Set the query param in self.args based on the prefix and arg index
and auto increment the arg_index
:return: the string placeholder for the arg
:rtype: str
"""
named_arg = '{0}A{1}'.format(self.arg_prefix, self.arg_index)
sel... | python | def set_arg(self, value):
"""
Set the query param in self.args based on the prefix and arg index
and auto increment the arg_index
:return: the string placeholder for the arg
:rtype: str
"""
named_arg = '{0}A{1}'.format(self.arg_prefix, self.arg_index)
sel... | [
"def",
"set_arg",
"(",
"self",
",",
"value",
")",
":",
"named_arg",
"=",
"'{0}A{1}'",
".",
"format",
"(",
"self",
".",
"arg_prefix",
",",
"self",
".",
"arg_index",
")",
"self",
".",
"args",
"[",
"named_arg",
"]",
"=",
"value",
"self",
".",
"arg_index",... | Set the query param in self.args based on the prefix and arg index
and auto increment the arg_index
:return: the string placeholder for the arg
:rtype: str | [
"Set",
"the",
"query",
"param",
"in",
"self",
".",
"args",
"based",
"on",
"the",
"prefix",
"and",
"arg",
"index",
"and",
"auto",
"increment",
"the",
"arg_index"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L424-L435 |
42,624 | ambitioninc/django-query-builder | querybuilder/query.py | Sorter.get_name | def get_name(self, use_alias=True):
"""
Gets the name to reference the sorted field
:return: the name to reference the sorted field
:rtype: str
"""
if self.desc:
direction = 'DESC'
else:
direction = 'ASC'
if use_alias:
... | python | def get_name(self, use_alias=True):
"""
Gets the name to reference the sorted field
:return: the name to reference the sorted field
:rtype: str
"""
if self.desc:
direction = 'DESC'
else:
direction = 'ASC'
if use_alias:
... | [
"def",
"get_name",
"(",
"self",
",",
"use_alias",
"=",
"True",
")",
":",
"if",
"self",
".",
"desc",
":",
"direction",
"=",
"'DESC'",
"else",
":",
"direction",
"=",
"'ASC'",
"if",
"use_alias",
":",
"return",
"'{0} {1}'",
".",
"format",
"(",
"self",
".",... | Gets the name to reference the sorted field
:return: the name to reference the sorted field
:rtype: str | [
"Gets",
"the",
"name",
"to",
"reference",
"the",
"sorted",
"field"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L508-L522 |
42,625 | ambitioninc/django-query-builder | querybuilder/query.py | Limit.get_sql | def get_sql(self):
"""
Generates the sql used for the limit clause of a Query
:return: the sql for the limit clause of a Query
:rtype: str
"""
sql = ''
if self.limit and self.limit > 0:
sql += 'LIMIT {0} '.format(self.limit)
if self.offset and... | python | def get_sql(self):
"""
Generates the sql used for the limit clause of a Query
:return: the sql for the limit clause of a Query
:rtype: str
"""
sql = ''
if self.limit and self.limit > 0:
sql += 'LIMIT {0} '.format(self.limit)
if self.offset and... | [
"def",
"get_sql",
"(",
"self",
")",
":",
"sql",
"=",
"''",
"if",
"self",
".",
"limit",
"and",
"self",
".",
"limit",
">",
"0",
":",
"sql",
"+=",
"'LIMIT {0} '",
".",
"format",
"(",
"self",
".",
"limit",
")",
"if",
"self",
".",
"offset",
"and",
"se... | Generates the sql used for the limit clause of a Query
:return: the sql for the limit clause of a Query
:rtype: str | [
"Generates",
"the",
"sql",
"used",
"for",
"the",
"limit",
"clause",
"of",
"a",
"Query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L543-L555 |
42,626 | ambitioninc/django-query-builder | querybuilder/query.py | Query.init_defaults | def init_defaults(self):
"""
Sets the default values for this instance
"""
self.sql = ''
self.tables = []
self.joins = []
self._where = Where()
self.groups = []
self.sorters = []
self._limit = None
self.table_prefix = ''
sel... | python | def init_defaults(self):
"""
Sets the default values for this instance
"""
self.sql = ''
self.tables = []
self.joins = []
self._where = Where()
self.groups = []
self.sorters = []
self._limit = None
self.table_prefix = ''
sel... | [
"def",
"init_defaults",
"(",
"self",
")",
":",
"self",
".",
"sql",
"=",
"''",
"self",
".",
"tables",
"=",
"[",
"]",
"self",
".",
"joins",
"=",
"[",
"]",
"self",
".",
"_where",
"=",
"Where",
"(",
")",
"self",
".",
"groups",
"=",
"[",
"]",
"self"... | Sets the default values for this instance | [
"Sets",
"the",
"default",
"values",
"for",
"this",
"instance"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L596-L614 |
42,627 | ambitioninc/django-query-builder | querybuilder/query.py | Query.from_table | def from_table(self, table=None, fields='*', schema=None, **kwargs):
"""
Adds a ``Table`` and any optional fields to the list of tables
this query is selecting from.
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Q... | python | def from_table(self, table=None, fields='*', schema=None, **kwargs):
"""
Adds a ``Table`` and any optional fields to the list of tables
this query is selecting from.
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Q... | [
"def",
"from_table",
"(",
"self",
",",
"table",
"=",
"None",
",",
"fields",
"=",
"'*'",
",",
"schema",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# self.mark_dirty()",
"self",
".",
"tables",
".",
"append",
"(",
"TableFactory",
"(",
"table",
"=",
... | Adds a ``Table`` and any optional fields to the list of tables
this query is selecting from.
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or
:class:`ModelBase <django:django.db.models.base.ModelBase>`
... | [
"Adds",
"a",
"Table",
"and",
"any",
"optional",
"fields",
"to",
"the",
"list",
"of",
"tables",
"this",
"query",
"is",
"selecting",
"from",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L648-L683 |
42,628 | ambitioninc/django-query-builder | querybuilder/query.py | Query.insert_into | def insert_into(self, table=None, field_names=None, values=None, **kwargs):
"""
Bulk inserts a list of values into a table
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or :class:`ModelBase <django:django.db.model... | python | def insert_into(self, table=None, field_names=None, values=None, **kwargs):
"""
Bulk inserts a list of values into a table
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or :class:`ModelBase <django:django.db.model... | [
"def",
"insert_into",
"(",
"self",
",",
"table",
"=",
"None",
",",
"field_names",
"=",
"None",
",",
"values",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"table",
"=",
"TableFactory",
"(",
"table",
"=",
"table",
",",
"*",
"*",
"kwargs",
")",
"s... | Bulk inserts a list of values into a table
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or :class:`ModelBase <django:django.db.models.base.ModelBase>`
:param table: The table to select fields from. This can be a string o... | [
"Bulk",
"inserts",
"a",
"list",
"of",
"values",
"into",
"a",
"table"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L685-L715 |
42,629 | ambitioninc/django-query-builder | querybuilder/query.py | Query.update_table | def update_table(self, table=None, field_names=None, values=None, pk=None, **kwargs):
"""
Bulk updates rows in a table
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or :class:`ModelBase <django:django.db.models.ba... | python | def update_table(self, table=None, field_names=None, values=None, pk=None, **kwargs):
"""
Bulk updates rows in a table
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or :class:`ModelBase <django:django.db.models.ba... | [
"def",
"update_table",
"(",
"self",
",",
"table",
"=",
"None",
",",
"field_names",
"=",
"None",
",",
"values",
"=",
"None",
",",
"pk",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"table",
"=",
"TableFactory",
"(",
"table",
"=",
"table",
",",
"*... | Bulk updates rows in a table
:type table: str or dict or :class:`Table <querybuilder.tables.Table>`
or :class:`Query <querybuilder.query.Query>` or :class:`ModelBase <django:django.db.models.base.ModelBase>`
:param table: The table to select fields from. This can be a string of the table
... | [
"Bulk",
"updates",
"rows",
"in",
"a",
"table"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L717-L749 |
42,630 | ambitioninc/django-query-builder | querybuilder/query.py | Query.join | def join(self, right_table=None, fields=None, condition=None, join_type='JOIN',
schema=None, left_table=None, extract_fields=True, prefix_fields=False, field_prefix=None,
allow_duplicates=False):
"""
Joins a table to another table based on a condition and adds fields from the j... | python | def join(self, right_table=None, fields=None, condition=None, join_type='JOIN',
schema=None, left_table=None, extract_fields=True, prefix_fields=False, field_prefix=None,
allow_duplicates=False):
"""
Joins a table to another table based on a condition and adds fields from the j... | [
"def",
"join",
"(",
"self",
",",
"right_table",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"condition",
"=",
"None",
",",
"join_type",
"=",
"'JOIN'",
",",
"schema",
"=",
"None",
",",
"left_table",
"=",
"None",
",",
"extract_fields",
"=",
"True",
","... | Joins a table to another table based on a condition and adds fields from the joined table
to the returned fields.
:type right_table: str or dict or :class:`Table <querybuilder.tables.Table>`
:param right_table: The table being joined with. This can be a string of the table
name, a d... | [
"Joins",
"a",
"table",
"to",
"another",
"table",
"based",
"on",
"a",
"condition",
"and",
"adds",
"fields",
"from",
"the",
"joined",
"table",
"to",
"the",
"returned",
"fields",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L762-L848 |
42,631 | ambitioninc/django-query-builder | querybuilder/query.py | Query.join_left | def join_left(self, right_table=None, fields=None, condition=None, join_type='LEFT JOIN',
schema=None, left_table=None, extract_fields=True, prefix_fields=False,
field_prefix=None, allow_duplicates=False):
"""
Wrapper for ``self.join`` with a default join of 'LEFT JOI... | python | def join_left(self, right_table=None, fields=None, condition=None, join_type='LEFT JOIN',
schema=None, left_table=None, extract_fields=True, prefix_fields=False,
field_prefix=None, allow_duplicates=False):
"""
Wrapper for ``self.join`` with a default join of 'LEFT JOI... | [
"def",
"join_left",
"(",
"self",
",",
"right_table",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"condition",
"=",
"None",
",",
"join_type",
"=",
"'LEFT JOIN'",
",",
"schema",
"=",
"None",
",",
"left_table",
"=",
"None",
",",
"extract_fields",
"=",
"Tr... | Wrapper for ``self.join`` with a default join of 'LEFT JOIN'
:type right_table: str or dict or :class:`Table <querybuilder.tables.Table>`
:param right_table: The table being joined with. This can be a string of the table
name, a dict of {'alias': table}, or a ``Table`` instance
:ty... | [
"Wrapper",
"for",
"self",
".",
"join",
"with",
"a",
"default",
"join",
"of",
"LEFT",
"JOIN"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L850-L910 |
42,632 | ambitioninc/django-query-builder | querybuilder/query.py | Query.where | def where(self, q=None, where_type='AND', **kwargs):
"""
Adds a where condition as a Q object to the query's ``Where`` instance.
:type q: :class:`Q <django:django.db.models.Q>`
:param q: A django ``Q`` instance. This will be added to the query's ``Where`` object. If no
Q obj... | python | def where(self, q=None, where_type='AND', **kwargs):
"""
Adds a where condition as a Q object to the query's ``Where`` instance.
:type q: :class:`Q <django:django.db.models.Q>`
:param q: A django ``Q`` instance. This will be added to the query's ``Where`` object. If no
Q obj... | [
"def",
"where",
"(",
"self",
",",
"q",
"=",
"None",
",",
"where_type",
"=",
"'AND'",
",",
"*",
"*",
"kwargs",
")",
":",
"# self.mark_dirty()",
"if",
"q",
"is",
"not",
"None",
":",
"self",
".",
"_where",
".",
"wheres",
".",
"add",
"(",
"q",
",",
"... | Adds a where condition as a Q object to the query's ``Where`` instance.
:type q: :class:`Q <django:django.db.models.Q>`
:param q: A django ``Q`` instance. This will be added to the query's ``Where`` object. If no
Q object is passed, the kwargs will be examined for params to be added to Q ob... | [
"Adds",
"a",
"where",
"condition",
"as",
"a",
"Q",
"object",
"to",
"the",
"query",
"s",
"Where",
"instance",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L912-L935 |
42,633 | ambitioninc/django-query-builder | querybuilder/query.py | Query.group_by | def group_by(self, field=None, table=None, allow_duplicates=False):
"""
Adds a group by clause to the query by adding a ``Group`` instance to the query's
groups list
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
:param field: This can be a string of a fi... | python | def group_by(self, field=None, table=None, allow_duplicates=False):
"""
Adds a group by clause to the query by adding a ``Group`` instance to the query's
groups list
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
:param field: This can be a string of a fi... | [
"def",
"group_by",
"(",
"self",
",",
"field",
"=",
"None",
",",
"table",
"=",
"None",
",",
"allow_duplicates",
"=",
"False",
")",
":",
"new_group_item",
"=",
"Group",
"(",
"field",
"=",
"field",
",",
"table",
"=",
"table",
",",
")",
"if",
"allow_duplic... | Adds a group by clause to the query by adding a ``Group`` instance to the query's
groups list
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
:param field: This can be a string of a field name, a dict of {'alias': field}, or
a ``Field`` instance
:type... | [
"Adds",
"a",
"group",
"by",
"clause",
"to",
"the",
"query",
"by",
"adding",
"a",
"Group",
"instance",
"to",
"the",
"query",
"s",
"groups",
"list"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L937-L966 |
42,634 | ambitioninc/django-query-builder | querybuilder/query.py | Query.order_by | def order_by(self, field=None, table=None, desc=False):
"""
Adds an order by clause to the query by adding a ``Sorter`` instance to the query's
sorters list
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
:param field: This can be a string of a field name,... | python | def order_by(self, field=None, table=None, desc=False):
"""
Adds an order by clause to the query by adding a ``Sorter`` instance to the query's
sorters list
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
:param field: This can be a string of a field name,... | [
"def",
"order_by",
"(",
"self",
",",
"field",
"=",
"None",
",",
"table",
"=",
"None",
",",
"desc",
"=",
"False",
")",
":",
"self",
".",
"sorters",
".",
"append",
"(",
"Sorter",
"(",
"field",
"=",
"field",
",",
"table",
"=",
"table",
",",
"desc",
... | Adds an order by clause to the query by adding a ``Sorter`` instance to the query's
sorters list
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
:param field: This can be a string of a field name, a dict of {'alias': field}, or
a ``Field`` instance
:t... | [
"Adds",
"an",
"order",
"by",
"clause",
"to",
"the",
"query",
"by",
"adding",
"a",
"Sorter",
"instance",
"to",
"the",
"query",
"s",
"sorters",
"list"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L968-L994 |
42,635 | ambitioninc/django-query-builder | querybuilder/query.py | Query.check_name_collisions | def check_name_collisions(self):
"""
Checks if there are any tables referenced by the same identifier and updated the
auto_alias accordingly. This is called when generating the sql for a query
and should only be called internally.
"""
table_index = 0
table_names =... | python | def check_name_collisions(self):
"""
Checks if there are any tables referenced by the same identifier and updated the
auto_alias accordingly. This is called when generating the sql for a query
and should only be called internally.
"""
table_index = 0
table_names =... | [
"def",
"check_name_collisions",
"(",
"self",
")",
":",
"table_index",
"=",
"0",
"table_names",
"=",
"{",
"}",
"for",
"table",
"in",
"self",
".",
"tables",
"+",
"self",
".",
"with_tables",
":",
"table_prefix",
"=",
"'T{0}'",
".",
"format",
"(",
"table_index... | Checks if there are any tables referenced by the same identifier and updated the
auto_alias accordingly. This is called when generating the sql for a query
and should only be called internally. | [
"Checks",
"if",
"there",
"are",
"any",
"tables",
"referenced",
"by",
"the",
"same",
"identifier",
"and",
"updated",
"the",
"auto_alias",
"accordingly",
".",
"This",
"is",
"called",
"when",
"generating",
"the",
"sql",
"for",
"a",
"query",
"and",
"should",
"on... | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1033-L1055 |
42,636 | ambitioninc/django-query-builder | querybuilder/query.py | Query.get_sql | def get_sql(self, debug=False, use_cache=True):
"""
Generates the sql for this query and returns the sql as a string.
:type debug: bool
:param debug: If True, the sql will be returned in a format that is easier to read and debug.
Defaults to False
:type use_cache: b... | python | def get_sql(self, debug=False, use_cache=True):
"""
Generates the sql for this query and returns the sql as a string.
:type debug: bool
:param debug: If True, the sql will be returned in a format that is easier to read and debug.
Defaults to False
:type use_cache: b... | [
"def",
"get_sql",
"(",
"self",
",",
"debug",
"=",
"False",
",",
"use_cache",
"=",
"True",
")",
":",
"# TODO: enable caching",
"# if self.sql and use_cache and not debug:",
"# return self.sql",
"# auto alias any naming collisions",
"self",
".",
"check_name_collisions",
"... | Generates the sql for this query and returns the sql as a string.
:type debug: bool
:param debug: If True, the sql will be returned in a format that is easier to read and debug.
Defaults to False
:type use_cache: bool
:param use_cache: If True, the query will returned the c... | [
"Generates",
"the",
"sql",
"for",
"this",
"query",
"and",
"returns",
"the",
"sql",
"as",
"a",
"string",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1064-L1104 |
42,637 | ambitioninc/django-query-builder | querybuilder/query.py | Query.get_update_sql | def get_update_sql(self, rows):
"""
Returns SQL UPDATE for rows ``rows``
.. code-block:: sql
UPDATE table_name
SET
field1 = new_values.field1
field2 = new_values.field2
FROM (
VALUES
(1, 'va... | python | def get_update_sql(self, rows):
"""
Returns SQL UPDATE for rows ``rows``
.. code-block:: sql
UPDATE table_name
SET
field1 = new_values.field1
field2 = new_values.field2
FROM (
VALUES
(1, 'va... | [
"def",
"get_update_sql",
"(",
"self",
",",
"rows",
")",
":",
"field_names",
"=",
"self",
".",
"get_field_names",
"(",
")",
"pk",
"=",
"field_names",
"[",
"0",
"]",
"update_field_names",
"=",
"field_names",
"[",
"1",
":",
"]",
"num_columns",
"=",
"len",
"... | Returns SQL UPDATE for rows ``rows``
.. code-block:: sql
UPDATE table_name
SET
field1 = new_values.field1
field2 = new_values.field2
FROM (
VALUES
(1, 'value1', 'value2'),
(2, 'value1', ... | [
"Returns",
"SQL",
"UPDATE",
"for",
"rows",
"rows"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1126-L1186 |
42,638 | ambitioninc/django-query-builder | querybuilder/query.py | Query.format_sql | def format_sql(self):
"""
Builds the sql in a format that is easy for humans to read and debug
:return: The formatted sql for this query
:rtype: str
"""
# TODO: finish adding the other parts of the sql generation
sql = ''
# build SELECT
select_se... | python | def format_sql(self):
"""
Builds the sql in a format that is easy for humans to read and debug
:return: The formatted sql for this query
:rtype: str
"""
# TODO: finish adding the other parts of the sql generation
sql = ''
# build SELECT
select_se... | [
"def",
"format_sql",
"(",
"self",
")",
":",
"# TODO: finish adding the other parts of the sql generation",
"sql",
"=",
"''",
"# build SELECT",
"select_segment",
"=",
"self",
".",
"build_select_fields",
"(",
")",
"select_segment",
"=",
"select_segment",
".",
"replace",
"... | Builds the sql in a format that is easy for humans to read and debug
:return: The formatted sql for this query
:rtype: str | [
"Builds",
"the",
"sql",
"in",
"a",
"format",
"that",
"is",
"easy",
"for",
"humans",
"to",
"read",
"and",
"debug"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1267-L1307 |
42,639 | ambitioninc/django-query-builder | querybuilder/query.py | Query.build_select_fields | def build_select_fields(self):
"""
Generates the sql for the SELECT portion of the query
:return: the SELECT portion of the query
:rtype: str
"""
field_sql = []
# get the field sql for each table
for table in self.tables:
field_sql += table.g... | python | def build_select_fields(self):
"""
Generates the sql for the SELECT portion of the query
:return: the SELECT portion of the query
:rtype: str
"""
field_sql = []
# get the field sql for each table
for table in self.tables:
field_sql += table.g... | [
"def",
"build_select_fields",
"(",
"self",
")",
":",
"field_sql",
"=",
"[",
"]",
"# get the field sql for each table",
"for",
"table",
"in",
"self",
".",
"tables",
":",
"field_sql",
"+=",
"table",
".",
"get_field_sql",
"(",
")",
"# get the field sql for each join ta... | Generates the sql for the SELECT portion of the query
:return: the SELECT portion of the query
:rtype: str | [
"Generates",
"the",
"sql",
"for",
"the",
"SELECT",
"portion",
"of",
"the",
"query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1365-L1384 |
42,640 | ambitioninc/django-query-builder | querybuilder/query.py | Query.build_from_table | def build_from_table(self):
"""
Generates the sql for the FROM portion of the query
:return: the FROM portion of the query
:rtype: str
"""
table_parts = []
# get the table sql for each table
for table in self.tables:
sql = table.get_sql()
... | python | def build_from_table(self):
"""
Generates the sql for the FROM portion of the query
:return: the FROM portion of the query
:rtype: str
"""
table_parts = []
# get the table sql for each table
for table in self.tables:
sql = table.get_sql()
... | [
"def",
"build_from_table",
"(",
"self",
")",
":",
"table_parts",
"=",
"[",
"]",
"# get the table sql for each table",
"for",
"table",
"in",
"self",
".",
"tables",
":",
"sql",
"=",
"table",
".",
"get_sql",
"(",
")",
"if",
"len",
"(",
"sql",
")",
":",
"tab... | Generates the sql for the FROM portion of the query
:return: the FROM portion of the query
:rtype: str | [
"Generates",
"the",
"sql",
"for",
"the",
"FROM",
"portion",
"of",
"the",
"query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1395-L1413 |
42,641 | ambitioninc/django-query-builder | querybuilder/query.py | Query.build_joins | def build_joins(self):
"""
Generates the sql for the JOIN portion of the query
:return: the JOIN portion of the query
:rtype: str
"""
join_parts = []
# get the sql for each join object
for join_item in self.joins:
join_parts.append(join_item.... | python | def build_joins(self):
"""
Generates the sql for the JOIN portion of the query
:return: the JOIN portion of the query
:rtype: str
"""
join_parts = []
# get the sql for each join object
for join_item in self.joins:
join_parts.append(join_item.... | [
"def",
"build_joins",
"(",
"self",
")",
":",
"join_parts",
"=",
"[",
"]",
"# get the sql for each join object",
"for",
"join_item",
"in",
"self",
".",
"joins",
":",
"join_parts",
".",
"append",
"(",
"join_item",
".",
"get_sql",
"(",
")",
")",
"# if there are a... | Generates the sql for the JOIN portion of the query
:return: the JOIN portion of the query
:rtype: str | [
"Generates",
"the",
"sql",
"for",
"the",
"JOIN",
"portion",
"of",
"the",
"query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1415-L1432 |
42,642 | ambitioninc/django-query-builder | querybuilder/query.py | Query.build_groups | def build_groups(self):
"""
Generates the sql for the GROUP BY portion of the query
:return: the GROUP BY portion of the query
:rtype: str
"""
# check if there are any groupings
if len(self.groups):
groups = []
# get the group sql for eac... | python | def build_groups(self):
"""
Generates the sql for the GROUP BY portion of the query
:return: the GROUP BY portion of the query
:rtype: str
"""
# check if there are any groupings
if len(self.groups):
groups = []
# get the group sql for eac... | [
"def",
"build_groups",
"(",
"self",
")",
":",
"# check if there are any groupings",
"if",
"len",
"(",
"self",
".",
"groups",
")",
":",
"groups",
"=",
"[",
"]",
"# get the group sql for each grouping",
"for",
"group",
"in",
"self",
".",
"groups",
":",
"groups",
... | Generates the sql for the GROUP BY portion of the query
:return: the GROUP BY portion of the query
:rtype: str | [
"Generates",
"the",
"sql",
"for",
"the",
"GROUP",
"BY",
"portion",
"of",
"the",
"query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1443-L1458 |
42,643 | ambitioninc/django-query-builder | querybuilder/query.py | Query.build_order_by | def build_order_by(self, use_alias=True):
"""
Generates the sql for the ORDER BY portion of the query
:type use_alias: bool
:param use_alias: If True, the alias for the field will be used in the order by.
This is an option before query windows do not use the alias. Defaults ... | python | def build_order_by(self, use_alias=True):
"""
Generates the sql for the ORDER BY portion of the query
:type use_alias: bool
:param use_alias: If True, the alias for the field will be used in the order by.
This is an option before query windows do not use the alias. Defaults ... | [
"def",
"build_order_by",
"(",
"self",
",",
"use_alias",
"=",
"True",
")",
":",
"# check if there are any sorters",
"if",
"len",
"(",
"self",
".",
"sorters",
")",
":",
"sorters",
"=",
"[",
"]",
"# get the sql for each sorter",
"for",
"sorter",
"in",
"self",
"."... | Generates the sql for the ORDER BY portion of the query
:type use_alias: bool
:param use_alias: If True, the alias for the field will be used in the order by.
This is an option before query windows do not use the alias. Defaults to True.
:return: the ORDER BY portion of the query
... | [
"Generates",
"the",
"sql",
"for",
"the",
"ORDER",
"BY",
"portion",
"of",
"the",
"query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1460-L1479 |
42,644 | ambitioninc/django-query-builder | querybuilder/query.py | Query.find_table | def find_table(self, table):
"""
Finds a table by name or alias. The FROM tables and JOIN tables
are included in the search.
:type table: str or :class:`ModelBase <django:django.db.models.base.ModelBase>`
:param table: string of the table name or alias or a ModelBase instance
... | python | def find_table(self, table):
"""
Finds a table by name or alias. The FROM tables and JOIN tables
are included in the search.
:type table: str or :class:`ModelBase <django:django.db.models.base.ModelBase>`
:param table: string of the table name or alias or a ModelBase instance
... | [
"def",
"find_table",
"(",
"self",
",",
"table",
")",
":",
"table",
"=",
"TableFactory",
"(",
"table",
")",
"identifier",
"=",
"table",
".",
"get_identifier",
"(",
")",
"join_tables",
"=",
"[",
"join_item",
".",
"right_table",
"for",
"join_item",
"in",
"sel... | Finds a table by name or alias. The FROM tables and JOIN tables
are included in the search.
:type table: str or :class:`ModelBase <django:django.db.models.base.ModelBase>`
:param table: string of the table name or alias or a ModelBase instance
:return: The table if it is found, otherwi... | [
"Finds",
"a",
"table",
"by",
"name",
"or",
"alias",
".",
"The",
"FROM",
"tables",
"and",
"JOIN",
"tables",
"are",
"included",
"in",
"the",
"search",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1492-L1509 |
42,645 | ambitioninc/django-query-builder | querybuilder/query.py | Query.wrap | def wrap(self, alias=None):
"""
Wraps the query by selecting all fields from itself
:rtype: :class:`Query <querybuilder.query.Query>`
:return: The wrapped query
"""
field_names = self.get_field_names()
query = Query(self.connection).from_table(deepcopy(self), ali... | python | def wrap(self, alias=None):
"""
Wraps the query by selecting all fields from itself
:rtype: :class:`Query <querybuilder.query.Query>`
:return: The wrapped query
"""
field_names = self.get_field_names()
query = Query(self.connection).from_table(deepcopy(self), ali... | [
"def",
"wrap",
"(",
"self",
",",
"alias",
"=",
"None",
")",
":",
"field_names",
"=",
"self",
".",
"get_field_names",
"(",
")",
"query",
"=",
"Query",
"(",
"self",
".",
"connection",
")",
".",
"from_table",
"(",
"deepcopy",
"(",
"self",
")",
",",
"ali... | Wraps the query by selecting all fields from itself
:rtype: :class:`Query <querybuilder.query.Query>`
:return: The wrapped query | [
"Wraps",
"the",
"query",
"by",
"selecting",
"all",
"fields",
"from",
"itself"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1514-L1529 |
42,646 | ambitioninc/django-query-builder | querybuilder/query.py | Query.copy | def copy(self):
"""
Deeply copies everything in the query object except the connection object is shared
"""
connection = self.connection
del self.connection
copied_query = deepcopy(self)
copied_query.connection = connection
self.connection = connection
... | python | def copy(self):
"""
Deeply copies everything in the query object except the connection object is shared
"""
connection = self.connection
del self.connection
copied_query = deepcopy(self)
copied_query.connection = connection
self.connection = connection
... | [
"def",
"copy",
"(",
"self",
")",
":",
"connection",
"=",
"self",
".",
"connection",
"del",
"self",
".",
"connection",
"copied_query",
"=",
"deepcopy",
"(",
"self",
")",
"copied_query",
".",
"connection",
"=",
"connection",
"self",
".",
"connection",
"=",
"... | Deeply copies everything in the query object except the connection object is shared | [
"Deeply",
"copies",
"everything",
"in",
"the",
"query",
"object",
"except",
"the",
"connection",
"object",
"is",
"shared"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1531-L1540 |
42,647 | ambitioninc/django-query-builder | querybuilder/query.py | Query.get_args | def get_args(self):
"""
Gets the args for the query which will be escaped when being executed by the
db. All inner queries are inspected and their args are combined with this
query's args.
:return: all args for this query as a dict
:rtype: dict
"""
for ta... | python | def get_args(self):
"""
Gets the args for the query which will be escaped when being executed by the
db. All inner queries are inspected and their args are combined with this
query's args.
:return: all args for this query as a dict
:rtype: dict
"""
for ta... | [
"def",
"get_args",
"(",
"self",
")",
":",
"for",
"table",
"in",
"self",
".",
"tables",
"+",
"self",
".",
"with_tables",
":",
"if",
"type",
"(",
"table",
")",
"is",
"QueryTable",
":",
"self",
".",
"_where",
".",
"args",
".",
"update",
"(",
"table",
... | Gets the args for the query which will be escaped when being executed by the
db. All inner queries are inspected and their args are combined with this
query's args.
:return: all args for this query as a dict
:rtype: dict | [
"Gets",
"the",
"args",
"for",
"the",
"query",
"which",
"will",
"be",
"escaped",
"when",
"being",
"executed",
"by",
"the",
"db",
".",
"All",
"inner",
"queries",
"are",
"inspected",
"and",
"their",
"args",
"are",
"combined",
"with",
"this",
"query",
"s",
"... | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1542-L1555 |
42,648 | ambitioninc/django-query-builder | querybuilder/query.py | Query.explain | def explain(self, sql=None, sql_args=None):
"""
Runs EXPLAIN on this query
:type sql: str or None
:param sql: The sql to run EXPLAIN on. If None is specified, the query will
use ``self.get_sql()``
:type sql_args: dict or None
:param sql_args: A dictionary of... | python | def explain(self, sql=None, sql_args=None):
"""
Runs EXPLAIN on this query
:type sql: str or None
:param sql: The sql to run EXPLAIN on. If None is specified, the query will
use ``self.get_sql()``
:type sql_args: dict or None
:param sql_args: A dictionary of... | [
"def",
"explain",
"(",
"self",
",",
"sql",
"=",
"None",
",",
"sql_args",
"=",
"None",
")",
":",
"cursor",
"=",
"self",
".",
"get_cursor",
"(",
")",
"if",
"sql",
"is",
"None",
":",
"sql",
"=",
"self",
".",
"get_sql",
"(",
")",
"sql_args",
"=",
"se... | Runs EXPLAIN on this query
:type sql: str or None
:param sql: The sql to run EXPLAIN on. If None is specified, the query will
use ``self.get_sql()``
:type sql_args: dict or None
:param sql_args: A dictionary of the arguments to be escaped in the query. If None and
... | [
"Runs",
"EXPLAIN",
"on",
"this",
"query"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1557-L1581 |
42,649 | ambitioninc/django-query-builder | querybuilder/query.py | Query.select | def select(self, return_models=False, nest=False, bypass_safe_limit=False, sql=None, sql_args=None):
"""
Executes the SELECT statement and returns the rows as a list of dictionaries or a list of
model instances
:type return_models: bool
:param return_models: Set to True to retur... | python | def select(self, return_models=False, nest=False, bypass_safe_limit=False, sql=None, sql_args=None):
"""
Executes the SELECT statement and returns the rows as a list of dictionaries or a list of
model instances
:type return_models: bool
:param return_models: Set to True to retur... | [
"def",
"select",
"(",
"self",
",",
"return_models",
"=",
"False",
",",
"nest",
"=",
"False",
",",
"bypass_safe_limit",
"=",
"False",
",",
"sql",
"=",
"None",
",",
"sql_args",
"=",
"None",
")",
":",
"# Check if we need to set a safe limit",
"if",
"bypass_safe_l... | Executes the SELECT statement and returns the rows as a list of dictionaries or a list of
model instances
:type return_models: bool
:param return_models: Set to True to return a list of models instead of a list of dictionaries.
Defaults to False
:type nest: bool
:pa... | [
"Executes",
"the",
"SELECT",
"statement",
"and",
"returns",
"the",
"rows",
"as",
"a",
"list",
"of",
"dictionaries",
"or",
"a",
"list",
"of",
"model",
"instances"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1583-L1680 |
42,650 | ambitioninc/django-query-builder | querybuilder/query.py | Query.update | def update(self, rows):
"""
Updates records in the db
"""
if len(rows) == 0:
return
sql, sql_args = self.get_update_sql(rows)
# get the cursor to execute the query
cursor = self.get_cursor()
# execute the query
cursor.execute(sql, sq... | python | def update(self, rows):
"""
Updates records in the db
"""
if len(rows) == 0:
return
sql, sql_args = self.get_update_sql(rows)
# get the cursor to execute the query
cursor = self.get_cursor()
# execute the query
cursor.execute(sql, sq... | [
"def",
"update",
"(",
"self",
",",
"rows",
")",
":",
"if",
"len",
"(",
"rows",
")",
"==",
"0",
":",
"return",
"sql",
",",
"sql_args",
"=",
"self",
".",
"get_update_sql",
"(",
"rows",
")",
"# get the cursor to execute the query",
"cursor",
"=",
"self",
".... | Updates records in the db | [
"Updates",
"records",
"in",
"the",
"db"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1698-L1711 |
42,651 | ambitioninc/django-query-builder | querybuilder/query.py | Query.get_auto_field_name | def get_auto_field_name(self, model_class):
"""
If one of the unique_fields is the model's AutoField, return the field name, otherwise return None
"""
# Get auto field name (a model can only have one AutoField)
for field in model_class._meta.fields:
if isinstance(fiel... | python | def get_auto_field_name(self, model_class):
"""
If one of the unique_fields is the model's AutoField, return the field name, otherwise return None
"""
# Get auto field name (a model can only have one AutoField)
for field in model_class._meta.fields:
if isinstance(fiel... | [
"def",
"get_auto_field_name",
"(",
"self",
",",
"model_class",
")",
":",
"# Get auto field name (a model can only have one AutoField)",
"for",
"field",
"in",
"model_class",
".",
"_meta",
".",
"fields",
":",
"if",
"isinstance",
"(",
"field",
",",
"AutoField",
")",
":... | If one of the unique_fields is the model's AutoField, return the field name, otherwise return None | [
"If",
"one",
"of",
"the",
"unique_fields",
"is",
"the",
"model",
"s",
"AutoField",
"return",
"the",
"field",
"name",
"otherwise",
"return",
"None"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1713-L1722 |
42,652 | ambitioninc/django-query-builder | querybuilder/query.py | Query.upsert | def upsert(self, rows, unique_fields, update_fields, return_rows=False, return_models=False):
"""
Performs an upsert with the set of models defined in rows. If the unique field which is meant
to cause a conflict is an auto increment field, then the field should be excluded when its value is null... | python | def upsert(self, rows, unique_fields, update_fields, return_rows=False, return_models=False):
"""
Performs an upsert with the set of models defined in rows. If the unique field which is meant
to cause a conflict is an auto increment field, then the field should be excluded when its value is null... | [
"def",
"upsert",
"(",
"self",
",",
"rows",
",",
"unique_fields",
",",
"update_fields",
",",
"return_rows",
"=",
"False",
",",
"return_models",
"=",
"False",
")",
":",
"if",
"len",
"(",
"rows",
")",
"==",
"0",
":",
"return",
"ModelClass",
"=",
"self",
"... | Performs an upsert with the set of models defined in rows. If the unique field which is meant
to cause a conflict is an auto increment field, then the field should be excluded when its value is null.
In this case, an upsert will be performed followed by a bulk_create | [
"Performs",
"an",
"upsert",
"with",
"the",
"set",
"of",
"models",
"defined",
"in",
"rows",
".",
"If",
"the",
"unique",
"field",
"which",
"is",
"meant",
"to",
"cause",
"a",
"conflict",
"is",
"an",
"auto",
"increment",
"field",
"then",
"the",
"field",
"sho... | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1724-L1799 |
42,653 | ambitioninc/django-query-builder | querybuilder/query.py | Query.get_count_query | def get_count_query(self):
"""
Copies the query object and alters the field list and order by to do a more efficient count
"""
query_copy = self.copy()
if not query_copy.tables:
raise Exception('No tables specified to do a count')
for table in query_copy.tabl... | python | def get_count_query(self):
"""
Copies the query object and alters the field list and order by to do a more efficient count
"""
query_copy = self.copy()
if not query_copy.tables:
raise Exception('No tables specified to do a count')
for table in query_copy.tabl... | [
"def",
"get_count_query",
"(",
"self",
")",
":",
"query_copy",
"=",
"self",
".",
"copy",
"(",
")",
"if",
"not",
"query_copy",
".",
"tables",
":",
"raise",
"Exception",
"(",
"'No tables specified to do a count'",
")",
"for",
"table",
"in",
"query_copy",
".",
... | Copies the query object and alters the field list and order by to do a more efficient count | [
"Copies",
"the",
"query",
"object",
"and",
"alters",
"the",
"field",
"list",
"and",
"order",
"by",
"to",
"do",
"a",
"more",
"efficient",
"count"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1808-L1821 |
42,654 | ambitioninc/django-query-builder | querybuilder/query.py | Query.count | def count(self, field='*'):
"""
Returns a COUNT of the query by wrapping the query and performing a COUNT
aggregate of the specified field
:param field: the field to pass to the COUNT aggregate. Defaults to '*'
:type field: str
:return: The number of rows that the query... | python | def count(self, field='*'):
"""
Returns a COUNT of the query by wrapping the query and performing a COUNT
aggregate of the specified field
:param field: the field to pass to the COUNT aggregate. Defaults to '*'
:type field: str
:return: The number of rows that the query... | [
"def",
"count",
"(",
"self",
",",
"field",
"=",
"'*'",
")",
":",
"rows",
"=",
"self",
".",
"get_count_query",
"(",
")",
".",
"select",
"(",
"bypass_safe_limit",
"=",
"True",
")",
"return",
"list",
"(",
"rows",
"[",
"0",
"]",
".",
"values",
"(",
")"... | Returns a COUNT of the query by wrapping the query and performing a COUNT
aggregate of the specified field
:param field: the field to pass to the COUNT aggregate. Defaults to '*'
:type field: str
:return: The number of rows that the query will return
:rtype: int | [
"Returns",
"a",
"COUNT",
"of",
"the",
"query",
"by",
"wrapping",
"the",
"query",
"and",
"performing",
"a",
"COUNT",
"aggregate",
"of",
"the",
"specified",
"field"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1823-L1835 |
42,655 | ambitioninc/django-query-builder | querybuilder/query.py | Query._fetch_all_as_dict | def _fetch_all_as_dict(self, cursor):
"""
Iterates over the result set and converts each row to a dictionary
:return: A list of dictionaries where each row is a dictionary
:rtype: list of dict
"""
desc = cursor.description
return [
dict(zip([col[0] fo... | python | def _fetch_all_as_dict(self, cursor):
"""
Iterates over the result set and converts each row to a dictionary
:return: A list of dictionaries where each row is a dictionary
:rtype: list of dict
"""
desc = cursor.description
return [
dict(zip([col[0] fo... | [
"def",
"_fetch_all_as_dict",
"(",
"self",
",",
"cursor",
")",
":",
"desc",
"=",
"cursor",
".",
"description",
"return",
"[",
"dict",
"(",
"zip",
"(",
"[",
"col",
"[",
"0",
"]",
"for",
"col",
"in",
"desc",
"]",
",",
"row",
")",
")",
"for",
"row",
... | Iterates over the result set and converts each row to a dictionary
:return: A list of dictionaries where each row is a dictionary
:rtype: list of dict | [
"Iterates",
"over",
"the",
"result",
"set",
"and",
"converts",
"each",
"row",
"to",
"a",
"dictionary"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1901-L1912 |
42,656 | ambitioninc/django-query-builder | querybuilder/query.py | QueryWindow.get_sql | def get_sql(self, debug=False, use_cache=True):
"""
Generates the sql for this query window and returns the sql as a string.
:type debug: bool
:param debug: If True, the sql will be returned in a format that is easier to read and debug.
Defaults to False
:type use_c... | python | def get_sql(self, debug=False, use_cache=True):
"""
Generates the sql for this query window and returns the sql as a string.
:type debug: bool
:param debug: If True, the sql will be returned in a format that is easier to read and debug.
Defaults to False
:type use_c... | [
"def",
"get_sql",
"(",
"self",
",",
"debug",
"=",
"False",
",",
"use_cache",
"=",
"True",
")",
":",
"# TODO: implement caching and debug",
"sql",
"=",
"''",
"sql",
"+=",
"self",
".",
"build_partition_by_fields",
"(",
")",
"sql",
"+=",
"self",
".",
"build_ord... | Generates the sql for this query window and returns the sql as a string.
:type debug: bool
:param debug: If True, the sql will be returned in a format that is easier to read and debug.
Defaults to False
:type use_cache: bool
:param use_cache: If True, the query will returne... | [
"Generates",
"the",
"sql",
"for",
"this",
"query",
"window",
"and",
"returns",
"the",
"sql",
"as",
"a",
"string",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/query.py#L1941-L1965 |
42,657 | ambitioninc/django-query-builder | querybuilder/helpers.py | value_for_keypath | def value_for_keypath(dict, keypath):
"""
Returns the value of a keypath in a dictionary
if the keypath exists or None if the keypath
does not exist.
"""
if len(keypath) == 0:
return dict
keys = keypath.split('.')
value = dict
for key in keys:
if key in value:
... | python | def value_for_keypath(dict, keypath):
"""
Returns the value of a keypath in a dictionary
if the keypath exists or None if the keypath
does not exist.
"""
if len(keypath) == 0:
return dict
keys = keypath.split('.')
value = dict
for key in keys:
if key in value:
... | [
"def",
"value_for_keypath",
"(",
"dict",
",",
"keypath",
")",
":",
"if",
"len",
"(",
"keypath",
")",
"==",
"0",
":",
"return",
"dict",
"keys",
"=",
"keypath",
".",
"split",
"(",
"'.'",
")",
"value",
"=",
"dict",
"for",
"key",
"in",
"keys",
":",
"if... | Returns the value of a keypath in a dictionary
if the keypath exists or None if the keypath
does not exist. | [
"Returns",
"the",
"value",
"of",
"a",
"keypath",
"in",
"a",
"dictionary",
"if",
"the",
"keypath",
"exists",
"or",
"None",
"if",
"the",
"keypath",
"does",
"not",
"exist",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/helpers.py#L1-L19 |
42,658 | ambitioninc/django-query-builder | querybuilder/helpers.py | set_value_for_keypath | def set_value_for_keypath(item, keypath, value, create_if_needed=False, delimeter='.'):
"""
Sets the value for a keypath in a dictionary
if the keypath exists. This modifies the
original dictionary.
"""
if len(keypath) == 0:
return None
keys = keypath.split(delimeter)
if len(ke... | python | def set_value_for_keypath(item, keypath, value, create_if_needed=False, delimeter='.'):
"""
Sets the value for a keypath in a dictionary
if the keypath exists. This modifies the
original dictionary.
"""
if len(keypath) == 0:
return None
keys = keypath.split(delimeter)
if len(ke... | [
"def",
"set_value_for_keypath",
"(",
"item",
",",
"keypath",
",",
"value",
",",
"create_if_needed",
"=",
"False",
",",
"delimeter",
"=",
"'.'",
")",
":",
"if",
"len",
"(",
"keypath",
")",
"==",
"0",
":",
"return",
"None",
"keys",
"=",
"keypath",
".",
"... | Sets the value for a keypath in a dictionary
if the keypath exists. This modifies the
original dictionary. | [
"Sets",
"the",
"value",
"for",
"a",
"keypath",
"in",
"a",
"dictionary",
"if",
"the",
"keypath",
"exists",
".",
"This",
"modifies",
"the",
"original",
"dictionary",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/helpers.py#L22-L53 |
42,659 | ambitioninc/django-query-builder | querybuilder/fields.py | Field.get_alias | def get_alias(self):
"""
Gets the alias for the field or the auto_alias if one is set.
If there isn't any kind of alias, None is returned.
:return: The field alias, auto_alias, or None
:rtype: str or None
"""
alias = None
if self.alias:
alias ... | python | def get_alias(self):
"""
Gets the alias for the field or the auto_alias if one is set.
If there isn't any kind of alias, None is returned.
:return: The field alias, auto_alias, or None
:rtype: str or None
"""
alias = None
if self.alias:
alias ... | [
"def",
"get_alias",
"(",
"self",
")",
":",
"alias",
"=",
"None",
"if",
"self",
".",
"alias",
":",
"alias",
"=",
"self",
".",
"alias",
"elif",
"self",
".",
"auto_alias",
":",
"alias",
"=",
"self",
".",
"auto_alias",
"if",
"self",
".",
"table",
"and",
... | Gets the alias for the field or the auto_alias if one is set.
If there isn't any kind of alias, None is returned.
:return: The field alias, auto_alias, or None
:rtype: str or None | [
"Gets",
"the",
"alias",
"for",
"the",
"field",
"or",
"the",
"auto_alias",
"if",
"one",
"is",
"set",
".",
"If",
"there",
"isn",
"t",
"any",
"kind",
"of",
"alias",
"None",
"is",
"returned",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/fields.py#L123-L144 |
42,660 | ambitioninc/django-query-builder | querybuilder/fields.py | Field.get_select_sql | def get_select_sql(self):
"""
Gets the SELECT field portion for the field without the alias. If the field
has a table, it will be included here like table.field
:return: Gets the SELECT field portion for the field without the alias
:rtype: str
"""
if self.table:
... | python | def get_select_sql(self):
"""
Gets the SELECT field portion for the field without the alias. If the field
has a table, it will be included here like table.field
:return: Gets the SELECT field portion for the field without the alias
:rtype: str
"""
if self.table:
... | [
"def",
"get_select_sql",
"(",
"self",
")",
":",
"if",
"self",
".",
"table",
":",
"return",
"'{0}.{1}'",
".",
"format",
"(",
"self",
".",
"table",
".",
"get_identifier",
"(",
")",
",",
"self",
".",
"name",
")",
"return",
"'{0}'",
".",
"format",
"(",
"... | Gets the SELECT field portion for the field without the alias. If the field
has a table, it will be included here like table.field
:return: Gets the SELECT field portion for the field without the alias
:rtype: str | [
"Gets",
"the",
"SELECT",
"field",
"portion",
"for",
"the",
"field",
"without",
"the",
"alias",
".",
"If",
"the",
"field",
"has",
"a",
"table",
"it",
"will",
"be",
"included",
"here",
"like",
"table",
".",
"field"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/fields.py#L159-L169 |
42,661 | ambitioninc/django-query-builder | querybuilder/fields.py | MultiField.set_table | def set_table(self, table):
"""
Setter for the table of this field. Also sets the inner field's table.
"""
super(MultiField, self).set_table(table)
if self.field and self.field.table is None:
self.field.set_table(self.table) | python | def set_table(self, table):
"""
Setter for the table of this field. Also sets the inner field's table.
"""
super(MultiField, self).set_table(table)
if self.field and self.field.table is None:
self.field.set_table(self.table) | [
"def",
"set_table",
"(",
"self",
",",
"table",
")",
":",
"super",
"(",
"MultiField",
",",
"self",
")",
".",
"set_table",
"(",
"table",
")",
"if",
"self",
".",
"field",
"and",
"self",
".",
"field",
".",
"table",
"is",
"None",
":",
"self",
".",
"fiel... | Setter for the table of this field. Also sets the inner field's table. | [
"Setter",
"for",
"the",
"table",
"of",
"this",
"field",
".",
"Also",
"sets",
"the",
"inner",
"field",
"s",
"table",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/fields.py#L247-L253 |
42,662 | ambitioninc/django-query-builder | querybuilder/fields.py | DatePartField.add_to_table | def add_to_table(self, field, alias, add_group=False):
"""
Adds this field to the field's table and optionally group by it
:param field: The field to add to the table
:type field: str or :class:`Field <querybuilder.fields.Field>`
:param alias: The alias for the field
:t... | python | def add_to_table(self, field, alias, add_group=False):
"""
Adds this field to the field's table and optionally group by it
:param field: The field to add to the table
:type field: str or :class:`Field <querybuilder.fields.Field>`
:param alias: The alias for the field
:t... | [
"def",
"add_to_table",
"(",
"self",
",",
"field",
",",
"alias",
",",
"add_group",
"=",
"False",
")",
":",
"self",
".",
"table",
".",
"add_field",
"(",
"{",
"alias",
":",
"field",
"}",
")",
"if",
"add_group",
":",
"self",
".",
"table",
".",
"owner",
... | Adds this field to the field's table and optionally group by it
:param field: The field to add to the table
:type field: str or :class:`Field <querybuilder.fields.Field>`
:param alias: The alias for the field
:type alias: str
:param add_group: Whether or not the table should g... | [
"Adds",
"this",
"field",
"to",
"the",
"field",
"s",
"table",
"and",
"optionally",
"group",
"by",
"it"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/fields.py#L793-L810 |
42,663 | ambitioninc/django-query-builder | querybuilder/tables.py | Table.get_alias | def get_alias(self):
"""
Gets the alias for the table or the auto_alias if one is set.
If there isn't any kind of alias, None is returned.
:returns: The table alias, auto_alias, or None
:rtype: str or None
"""
alias = None
if self.alias:
alias... | python | def get_alias(self):
"""
Gets the alias for the table or the auto_alias if one is set.
If there isn't any kind of alias, None is returned.
:returns: The table alias, auto_alias, or None
:rtype: str or None
"""
alias = None
if self.alias:
alias... | [
"def",
"get_alias",
"(",
"self",
")",
":",
"alias",
"=",
"None",
"if",
"self",
".",
"alias",
":",
"alias",
"=",
"self",
".",
"alias",
"elif",
"self",
".",
"auto_alias",
":",
"alias",
"=",
"self",
".",
"auto_alias",
"return",
"alias"
] | Gets the alias for the table or the auto_alias if one is set.
If there isn't any kind of alias, None is returned.
:returns: The table alias, auto_alias, or None
:rtype: str or None | [
"Gets",
"the",
"alias",
"for",
"the",
"table",
"or",
"the",
"auto_alias",
"if",
"one",
"is",
"set",
".",
"If",
"there",
"isn",
"t",
"any",
"kind",
"of",
"alias",
"None",
"is",
"returned",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/tables.py#L136-L150 |
42,664 | ambitioninc/django-query-builder | querybuilder/tables.py | Table.add_field | def add_field(self, field):
"""
Adds a field to this table
:param field: This can be a string of a field name, a dict of {'alias': field}, or
a ``Field`` instance
:type field: str or dict or Field
"""
field = FieldFactory(
field,
)
... | python | def add_field(self, field):
"""
Adds a field to this table
:param field: This can be a string of a field name, a dict of {'alias': field}, or
a ``Field`` instance
:type field: str or dict or Field
"""
field = FieldFactory(
field,
)
... | [
"def",
"add_field",
"(",
"self",
",",
"field",
")",
":",
"field",
"=",
"FieldFactory",
"(",
"field",
",",
")",
"field",
".",
"set_table",
"(",
"self",
")",
"# make sure field is not already added",
"field_name",
"=",
"field",
".",
"get_name",
"(",
")",
"for"... | Adds a field to this table
:param field: This can be a string of a field name, a dict of {'alias': field}, or
a ``Field`` instance
:type field: str or dict or Field | [
"Adds",
"a",
"field",
"to",
"this",
"table"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/tables.py#L186-L211 |
42,665 | ambitioninc/django-query-builder | querybuilder/tables.py | Table.remove_field | def remove_field(self, field):
"""
Removes a field from this table
:param field: This can be a string of a field name, a dict of {'alias': field}, or
a ``Field`` instance
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
"""
new_field = F... | python | def remove_field(self, field):
"""
Removes a field from this table
:param field: This can be a string of a field name, a dict of {'alias': field}, or
a ``Field`` instance
:type field: str or dict or :class:`Field <querybuilder.fields.Field>`
"""
new_field = F... | [
"def",
"remove_field",
"(",
"self",
",",
"field",
")",
":",
"new_field",
"=",
"FieldFactory",
"(",
"field",
",",
")",
"new_field",
".",
"set_table",
"(",
"self",
")",
"new_field_identifier",
"=",
"new_field",
".",
"get_identifier",
"(",
")",
"for",
"field",
... | Removes a field from this table
:param field: This can be a string of a field name, a dict of {'alias': field}, or
a ``Field`` instance
:type field: str or dict or :class:`Field <querybuilder.fields.Field>` | [
"Removes",
"a",
"field",
"from",
"this",
"table"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/tables.py#L213-L230 |
42,666 | ambitioninc/django-query-builder | querybuilder/tables.py | Table.add_fields | def add_fields(self, fields):
"""
Adds all of the passed fields to the table's current field list
:param fields: The fields to select from ``table``. This can be
a single field, a tuple of fields, or a list of fields. Each field can be a string
or ``Field`` instance
... | python | def add_fields(self, fields):
"""
Adds all of the passed fields to the table's current field list
:param fields: The fields to select from ``table``. This can be
a single field, a tuple of fields, or a list of fields. Each field can be a string
or ``Field`` instance
... | [
"def",
"add_fields",
"(",
"self",
",",
"fields",
")",
":",
"if",
"isinstance",
"(",
"fields",
",",
"string_types",
")",
":",
"fields",
"=",
"[",
"fields",
"]",
"elif",
"type",
"(",
"fields",
")",
"is",
"tuple",
":",
"fields",
"=",
"list",
"(",
"field... | Adds all of the passed fields to the table's current field list
:param fields: The fields to select from ``table``. This can be
a single field, a tuple of fields, or a list of fields. Each field can be a string
or ``Field`` instance
:type fields: str or tuple or list of str or l... | [
"Adds",
"all",
"of",
"the",
"passed",
"fields",
"to",
"the",
"table",
"s",
"current",
"field",
"list"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/tables.py#L253-L268 |
42,667 | ambitioninc/django-query-builder | querybuilder/tables.py | Table.find_field | def find_field(self, field=None, alias=None):
"""
Finds a field by name or alias.
:param field: string of the field name or alias, dict of {'alias': field}, or a Field instance
:type field: str or dict or Field
:returns: The field if it is found, otherwise None
:rtype: ... | python | def find_field(self, field=None, alias=None):
"""
Finds a field by name or alias.
:param field: string of the field name or alias, dict of {'alias': field}, or a Field instance
:type field: str or dict or Field
:returns: The field if it is found, otherwise None
:rtype: ... | [
"def",
"find_field",
"(",
"self",
",",
"field",
"=",
"None",
",",
"alias",
"=",
"None",
")",
":",
"if",
"alias",
":",
"field",
"=",
"alias",
"field",
"=",
"FieldFactory",
"(",
"field",
",",
"table",
"=",
"self",
",",
"alias",
"=",
"alias",
")",
"id... | Finds a field by name or alias.
:param field: string of the field name or alias, dict of {'alias': field}, or a Field instance
:type field: str or dict or Field
:returns: The field if it is found, otherwise None
:rtype: :class:`Field <querybuilder.fields.Field>` or None | [
"Finds",
"a",
"field",
"by",
"name",
"or",
"alias",
"."
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/tables.py#L311-L328 |
42,668 | ambitioninc/django-query-builder | querybuilder/tables.py | SimpleTable.init_defaults | def init_defaults(self):
"""
Sets the name of the table to the passed in table value
"""
super(SimpleTable, self).init_defaults()
self.name = self.table | python | def init_defaults(self):
"""
Sets the name of the table to the passed in table value
"""
super(SimpleTable, self).init_defaults()
self.name = self.table | [
"def",
"init_defaults",
"(",
"self",
")",
":",
"super",
"(",
"SimpleTable",
",",
"self",
")",
".",
"init_defaults",
"(",
")",
"self",
".",
"name",
"=",
"self",
".",
"table"
] | Sets the name of the table to the passed in table value | [
"Sets",
"the",
"name",
"of",
"the",
"table",
"to",
"the",
"passed",
"in",
"table",
"value"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/tables.py#L336-L341 |
42,669 | ambitioninc/django-query-builder | querybuilder/tables.py | ModelTable.init_defaults | def init_defaults(self):
"""
Sets a model instance variable to the table value and sets the name to the
table name as determined from the model class
"""
super(ModelTable, self).init_defaults()
self.model = self.table
self.name = self.model._meta.db_table | python | def init_defaults(self):
"""
Sets a model instance variable to the table value and sets the name to the
table name as determined from the model class
"""
super(ModelTable, self).init_defaults()
self.model = self.table
self.name = self.model._meta.db_table | [
"def",
"init_defaults",
"(",
"self",
")",
":",
"super",
"(",
"ModelTable",
",",
"self",
")",
".",
"init_defaults",
"(",
")",
"self",
".",
"model",
"=",
"self",
".",
"table",
"self",
".",
"name",
"=",
"self",
".",
"model",
".",
"_meta",
".",
"db_table... | Sets a model instance variable to the table value and sets the name to the
table name as determined from the model class | [
"Sets",
"a",
"model",
"instance",
"variable",
"to",
"the",
"table",
"value",
"and",
"sets",
"the",
"name",
"to",
"the",
"table",
"name",
"as",
"determined",
"from",
"the",
"model",
"class"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/tables.py#L350-L357 |
42,670 | ambitioninc/django-query-builder | querybuilder/tables.py | QueryTable.init_defaults | def init_defaults(self):
"""
Sets a query instance variable to the table value
"""
super(QueryTable, self).init_defaults()
self.query = self.table
self.query.is_inner = True | python | def init_defaults(self):
"""
Sets a query instance variable to the table value
"""
super(QueryTable, self).init_defaults()
self.query = self.table
self.query.is_inner = True | [
"def",
"init_defaults",
"(",
"self",
")",
":",
"super",
"(",
"QueryTable",
",",
"self",
")",
".",
"init_defaults",
"(",
")",
"self",
".",
"query",
"=",
"self",
".",
"table",
"self",
".",
"query",
".",
"is_inner",
"=",
"True"
] | Sets a query instance variable to the table value | [
"Sets",
"a",
"query",
"instance",
"variable",
"to",
"the",
"table",
"value"
] | 113a7d845d3ddc6a45621b9880308e756f87c5bf | https://github.com/ambitioninc/django-query-builder/blob/113a7d845d3ddc6a45621b9880308e756f87c5bf/querybuilder/tables.py#L376-L382 |
42,671 | markfinger/python-nodejs | nodejs/interrogate.py | run_command | def run_command(cmd_to_run):
"""
Wrapper around subprocess that pipes the stderr and stdout from `cmd_to_run`
to temporary files. Using the temporary files gets around subprocess.PIPE's
issues with handling large buffers.
Note: this command will block the python process until `cmd_to_run` has compl... | python | def run_command(cmd_to_run):
"""
Wrapper around subprocess that pipes the stderr and stdout from `cmd_to_run`
to temporary files. Using the temporary files gets around subprocess.PIPE's
issues with handling large buffers.
Note: this command will block the python process until `cmd_to_run` has compl... | [
"def",
"run_command",
"(",
"cmd_to_run",
")",
":",
"with",
"tempfile",
".",
"TemporaryFile",
"(",
")",
"as",
"stdout_file",
",",
"tempfile",
".",
"TemporaryFile",
"(",
")",
"as",
"stderr_file",
":",
"# Run the command",
"popen",
"=",
"subprocess",
".",
"Popen"... | Wrapper around subprocess that pipes the stderr and stdout from `cmd_to_run`
to temporary files. Using the temporary files gets around subprocess.PIPE's
issues with handling large buffers.
Note: this command will block the python process until `cmd_to_run` has completed.
Returns a tuple, containing th... | [
"Wrapper",
"around",
"subprocess",
"that",
"pipes",
"the",
"stderr",
"and",
"stdout",
"from",
"cmd_to_run",
"to",
"temporary",
"files",
".",
"Using",
"the",
"temporary",
"files",
"gets",
"around",
"subprocess",
".",
"PIPE",
"s",
"issues",
"with",
"handling",
"... | 3c0c84e953b9af68cbc3f124f1802361baf006bb | https://github.com/markfinger/python-nodejs/blob/3c0c84e953b9af68cbc3f124f1802361baf006bb/nodejs/interrogate.py#L8-L34 |
42,672 | jlaine/python-netfilter | netfilter/rule.py | Extension.log | def log(self, level, prefix = ''):
"""Writes the contents of the Extension to the logging system.
"""
logging.log(level, "%sname: %s", prefix, self.__name)
logging.log(level, "%soptions: %s", prefix, self.__options) | python | def log(self, level, prefix = ''):
"""Writes the contents of the Extension to the logging system.
"""
logging.log(level, "%sname: %s", prefix, self.__name)
logging.log(level, "%soptions: %s", prefix, self.__options) | [
"def",
"log",
"(",
"self",
",",
"level",
",",
"prefix",
"=",
"''",
")",
":",
"logging",
".",
"log",
"(",
"level",
",",
"\"%sname: %s\"",
",",
"prefix",
",",
"self",
".",
"__name",
")",
"logging",
".",
"log",
"(",
"level",
",",
"\"%soptions: %s\"",
",... | Writes the contents of the Extension to the logging system. | [
"Writes",
"the",
"contents",
"of",
"the",
"Extension",
"to",
"the",
"logging",
"system",
"."
] | e4942c0f6a654a985049b629ead3dc6dcdb30145 | https://github.com/jlaine/python-netfilter/blob/e4942c0f6a654a985049b629ead3dc6dcdb30145/netfilter/rule.py#L91-L95 |
42,673 | jlaine/python-netfilter | netfilter/rule.py | Extension.specbits | def specbits(self):
"""Returns the array of arguments that would be given to
iptables for the current Extension.
"""
bits = []
for opt in sorted(self.__options):
# handle the case where this is a negated option
m = re.match(r'^! (.*)', opt)
if ... | python | def specbits(self):
"""Returns the array of arguments that would be given to
iptables for the current Extension.
"""
bits = []
for opt in sorted(self.__options):
# handle the case where this is a negated option
m = re.match(r'^! (.*)', opt)
if ... | [
"def",
"specbits",
"(",
"self",
")",
":",
"bits",
"=",
"[",
"]",
"for",
"opt",
"in",
"sorted",
"(",
"self",
".",
"__options",
")",
":",
"# handle the case where this is a negated option",
"m",
"=",
"re",
".",
"match",
"(",
"r'^! (.*)'",
",",
"opt",
")",
... | Returns the array of arguments that would be given to
iptables for the current Extension. | [
"Returns",
"the",
"array",
"of",
"arguments",
"that",
"would",
"be",
"given",
"to",
"iptables",
"for",
"the",
"current",
"Extension",
"."
] | e4942c0f6a654a985049b629ead3dc6dcdb30145 | https://github.com/jlaine/python-netfilter/blob/e4942c0f6a654a985049b629ead3dc6dcdb30145/netfilter/rule.py#L107-L125 |
42,674 | jlaine/python-netfilter | netfilter/rule.py | Rule.log | def log(self, level, prefix = ''):
"""Writes the contents of the Rule to the logging system.
"""
logging.log(level, "%sin interface: %s", prefix, self.in_interface)
logging.log(level, "%sout interface: %s", prefix, self.out_interface)
logging.log(level, "%ssource: %s", prefix, se... | python | def log(self, level, prefix = ''):
"""Writes the contents of the Rule to the logging system.
"""
logging.log(level, "%sin interface: %s", prefix, self.in_interface)
logging.log(level, "%sout interface: %s", prefix, self.out_interface)
logging.log(level, "%ssource: %s", prefix, se... | [
"def",
"log",
"(",
"self",
",",
"level",
",",
"prefix",
"=",
"''",
")",
":",
"logging",
".",
"log",
"(",
"level",
",",
"\"%sin interface: %s\"",
",",
"prefix",
",",
"self",
".",
"in_interface",
")",
"logging",
".",
"log",
"(",
"level",
",",
"\"%sout in... | Writes the contents of the Rule to the logging system. | [
"Writes",
"the",
"contents",
"of",
"the",
"Rule",
"to",
"the",
"logging",
"system",
"."
] | e4942c0f6a654a985049b629ead3dc6dcdb30145 | https://github.com/jlaine/python-netfilter/blob/e4942c0f6a654a985049b629ead3dc6dcdb30145/netfilter/rule.py#L206-L218 |
42,675 | jlaine/python-netfilter | netfilter/rule.py | Rule.specbits | def specbits(self):
"""Returns the array of arguments that would be given to
iptables for the current Rule.
"""
def host_bits(opt, optval):
# handle the case where this is a negated value
m = re.match(r'^!\s*(.*)', optval)
if m:
return ... | python | def specbits(self):
"""Returns the array of arguments that would be given to
iptables for the current Rule.
"""
def host_bits(opt, optval):
# handle the case where this is a negated value
m = re.match(r'^!\s*(.*)', optval)
if m:
return ... | [
"def",
"specbits",
"(",
"self",
")",
":",
"def",
"host_bits",
"(",
"opt",
",",
"optval",
")",
":",
"# handle the case where this is a negated value",
"m",
"=",
"re",
".",
"match",
"(",
"r'^!\\s*(.*)'",
",",
"optval",
")",
"if",
"m",
":",
"return",
"[",
"'!... | Returns the array of arguments that would be given to
iptables for the current Rule. | [
"Returns",
"the",
"array",
"of",
"arguments",
"that",
"would",
"be",
"given",
"to",
"iptables",
"for",
"the",
"current",
"Rule",
"."
] | e4942c0f6a654a985049b629ead3dc6dcdb30145 | https://github.com/jlaine/python-netfilter/blob/e4942c0f6a654a985049b629ead3dc6dcdb30145/netfilter/rule.py#L220-L252 |
42,676 | jlaine/python-netfilter | netfilter/parser.py | parse_chains | def parse_chains(data):
"""
Parse the chain definitions.
"""
chains = odict()
for line in data.splitlines(True):
m = re_chain.match(line)
if m:
policy = None
if m.group(2) != '-':
policy = m.group(2)
chains[m.group(1)] = {
... | python | def parse_chains(data):
"""
Parse the chain definitions.
"""
chains = odict()
for line in data.splitlines(True):
m = re_chain.match(line)
if m:
policy = None
if m.group(2) != '-':
policy = m.group(2)
chains[m.group(1)] = {
... | [
"def",
"parse_chains",
"(",
"data",
")",
":",
"chains",
"=",
"odict",
"(",
")",
"for",
"line",
"in",
"data",
".",
"splitlines",
"(",
"True",
")",
":",
"m",
"=",
"re_chain",
".",
"match",
"(",
"line",
")",
"if",
"m",
":",
"policy",
"=",
"None",
"i... | Parse the chain definitions. | [
"Parse",
"the",
"chain",
"definitions",
"."
] | e4942c0f6a654a985049b629ead3dc6dcdb30145 | https://github.com/jlaine/python-netfilter/blob/e4942c0f6a654a985049b629ead3dc6dcdb30145/netfilter/parser.py#L117-L133 |
42,677 | jlaine/python-netfilter | netfilter/parser.py | parse_rules | def parse_rules(data, chain):
"""
Parse the rules for the specified chain.
"""
rules = []
for line in data.splitlines(True):
m = re_rule.match(line)
if m and m.group(3) == chain:
rule = parse_rule(m.group(4))
rule.packets = int(m.group(1))
rule.byt... | python | def parse_rules(data, chain):
"""
Parse the rules for the specified chain.
"""
rules = []
for line in data.splitlines(True):
m = re_rule.match(line)
if m and m.group(3) == chain:
rule = parse_rule(m.group(4))
rule.packets = int(m.group(1))
rule.byt... | [
"def",
"parse_rules",
"(",
"data",
",",
"chain",
")",
":",
"rules",
"=",
"[",
"]",
"for",
"line",
"in",
"data",
".",
"splitlines",
"(",
"True",
")",
":",
"m",
"=",
"re_rule",
".",
"match",
"(",
"line",
")",
"if",
"m",
"and",
"m",
".",
"group",
... | Parse the rules for the specified chain. | [
"Parse",
"the",
"rules",
"for",
"the",
"specified",
"chain",
"."
] | e4942c0f6a654a985049b629ead3dc6dcdb30145 | https://github.com/jlaine/python-netfilter/blob/e4942c0f6a654a985049b629ead3dc6dcdb30145/netfilter/parser.py#L135-L147 |
42,678 | denisenkom/django-sqlserver | sqlserver/base.py | _get_new_connection | def _get_new_connection(self, conn_params):
"""Opens a connection to the database."""
self.__connection_string = conn_params.get('connection_string', '')
conn = self.Database.connect(**conn_params)
return conn | python | def _get_new_connection(self, conn_params):
"""Opens a connection to the database."""
self.__connection_string = conn_params.get('connection_string', '')
conn = self.Database.connect(**conn_params)
return conn | [
"def",
"_get_new_connection",
"(",
"self",
",",
"conn_params",
")",
":",
"self",
".",
"__connection_string",
"=",
"conn_params",
".",
"get",
"(",
"'connection_string'",
",",
"''",
")",
"conn",
"=",
"self",
".",
"Database",
".",
"connect",
"(",
"*",
"*",
"c... | Opens a connection to the database. | [
"Opens",
"a",
"connection",
"to",
"the",
"database",
"."
] | f5d5dc8637799746f1bd11bd8c479d3acd468581 | https://github.com/denisenkom/django-sqlserver/blob/f5d5dc8637799746f1bd11bd8c479d3acd468581/sqlserver/base.py#L216-L220 |
42,679 | denisenkom/django-sqlserver | sqlserver/base.py | DatabaseWrapper.get_connection_params | def get_connection_params(self):
"""Returns a dict of parameters suitable for get_new_connection."""
from django.conf import settings
settings_dict = self.settings_dict
options = settings_dict.get('OPTIONS', {})
autocommit = options.get('autocommit', False)
conn_params = ... | python | def get_connection_params(self):
"""Returns a dict of parameters suitable for get_new_connection."""
from django.conf import settings
settings_dict = self.settings_dict
options = settings_dict.get('OPTIONS', {})
autocommit = options.get('autocommit', False)
conn_params = ... | [
"def",
"get_connection_params",
"(",
"self",
")",
":",
"from",
"django",
".",
"conf",
"import",
"settings",
"settings_dict",
"=",
"self",
".",
"settings_dict",
"options",
"=",
"settings_dict",
".",
"get",
"(",
"'OPTIONS'",
",",
"{",
"}",
")",
"autocommit",
"... | Returns a dict of parameters suitable for get_new_connection. | [
"Returns",
"a",
"dict",
"of",
"parameters",
"suitable",
"for",
"get_new_connection",
"."
] | f5d5dc8637799746f1bd11bd8c479d3acd468581 | https://github.com/denisenkom/django-sqlserver/blob/f5d5dc8637799746f1bd11bd8c479d3acd468581/sqlserver/base.py#L53-L79 |
42,680 | denisenkom/django-sqlserver | sqlserver/base.py | DatabaseWrapper.create_cursor | def create_cursor(self, name=None):
"""Creates a cursor. Assumes that a connection is established."""
cursor = self.connection.cursor()
cursor.tzinfo_factory = self.tzinfo_factory
return cursor | python | def create_cursor(self, name=None):
"""Creates a cursor. Assumes that a connection is established."""
cursor = self.connection.cursor()
cursor.tzinfo_factory = self.tzinfo_factory
return cursor | [
"def",
"create_cursor",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"cursor",
"=",
"self",
".",
"connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"tzinfo_factory",
"=",
"self",
".",
"tzinfo_factory",
"return",
"cursor"
] | Creates a cursor. Assumes that a connection is established. | [
"Creates",
"a",
"cursor",
".",
"Assumes",
"that",
"a",
"connection",
"is",
"established",
"."
] | f5d5dc8637799746f1bd11bd8c479d3acd468581 | https://github.com/denisenkom/django-sqlserver/blob/f5d5dc8637799746f1bd11bd8c479d3acd468581/sqlserver/base.py#L81-L85 |
42,681 | denisenkom/django-sqlserver | sqlserver/base.py | DatabaseWrapper.__get_dbms_version | def __get_dbms_version(self, make_connection=True):
"""
Returns the 'DBMS Version' string
"""
major, minor, _, _ = self.get_server_version(make_connection=make_connection)
return '{}.{}'.format(major, minor) | python | def __get_dbms_version(self, make_connection=True):
"""
Returns the 'DBMS Version' string
"""
major, minor, _, _ = self.get_server_version(make_connection=make_connection)
return '{}.{}'.format(major, minor) | [
"def",
"__get_dbms_version",
"(",
"self",
",",
"make_connection",
"=",
"True",
")",
":",
"major",
",",
"minor",
",",
"_",
",",
"_",
"=",
"self",
".",
"get_server_version",
"(",
"make_connection",
"=",
"make_connection",
")",
"return",
"'{}.{}'",
".",
"format... | Returns the 'DBMS Version' string | [
"Returns",
"the",
"DBMS",
"Version",
"string"
] | f5d5dc8637799746f1bd11bd8c479d3acd468581 | https://github.com/denisenkom/django-sqlserver/blob/f5d5dc8637799746f1bd11bd8c479d3acd468581/sqlserver/base.py#L87-L92 |
42,682 | jlaine/python-netfilter | netfilter/firewall.py | Firewall.get_buffer | def get_buffer(self):
"""Get the change buffers."""
buffer = []
for table in self.__tables:
buffer.extend(table.get_buffer())
return buffer | python | def get_buffer(self):
"""Get the change buffers."""
buffer = []
for table in self.__tables:
buffer.extend(table.get_buffer())
return buffer | [
"def",
"get_buffer",
"(",
"self",
")",
":",
"buffer",
"=",
"[",
"]",
"for",
"table",
"in",
"self",
".",
"__tables",
":",
"buffer",
".",
"extend",
"(",
"table",
".",
"get_buffer",
"(",
")",
")",
"return",
"buffer"
] | Get the change buffers. | [
"Get",
"the",
"change",
"buffers",
"."
] | e4942c0f6a654a985049b629ead3dc6dcdb30145 | https://github.com/jlaine/python-netfilter/blob/e4942c0f6a654a985049b629ead3dc6dcdb30145/netfilter/firewall.py#L59-L64 |
42,683 | jlaine/python-netfilter | netfilter/firewall.py | Firewall.start | def start(self):
"""Start the firewall."""
self.clear()
self.setDefaultPolicy()
self.acceptIcmp()
self.acceptInput('lo') | python | def start(self):
"""Start the firewall."""
self.clear()
self.setDefaultPolicy()
self.acceptIcmp()
self.acceptInput('lo') | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"clear",
"(",
")",
"self",
".",
"setDefaultPolicy",
"(",
")",
"self",
".",
"acceptIcmp",
"(",
")",
"self",
".",
"acceptInput",
"(",
"'lo'",
")"
] | Start the firewall. | [
"Start",
"the",
"firewall",
"."
] | e4942c0f6a654a985049b629ead3dc6dcdb30145 | https://github.com/jlaine/python-netfilter/blob/e4942c0f6a654a985049b629ead3dc6dcdb30145/netfilter/firewall.py#L89-L94 |
42,684 | jlaine/python-netfilter | netfilter/table.py | Table.list_rules | def list_rules(self, chainname):
"""Returns a list of Rules in the specified chain.
"""
data = self.__run([self.__iptables_save, '-t', self.__name, '-c'])
return netfilter.parser.parse_rules(data, chainname) | python | def list_rules(self, chainname):
"""Returns a list of Rules in the specified chain.
"""
data = self.__run([self.__iptables_save, '-t', self.__name, '-c'])
return netfilter.parser.parse_rules(data, chainname) | [
"def",
"list_rules",
"(",
"self",
",",
"chainname",
")",
":",
"data",
"=",
"self",
".",
"__run",
"(",
"[",
"self",
".",
"__iptables_save",
",",
"'-t'",
",",
"self",
".",
"__name",
",",
"'-c'",
"]",
")",
"return",
"netfilter",
".",
"parser",
".",
"par... | Returns a list of Rules in the specified chain. | [
"Returns",
"a",
"list",
"of",
"Rules",
"in",
"the",
"specified",
"chain",
"."
] | e4942c0f6a654a985049b629ead3dc6dcdb30145 | https://github.com/jlaine/python-netfilter/blob/e4942c0f6a654a985049b629ead3dc6dcdb30145/netfilter/table.py#L120-L124 |
42,685 | jlaine/python-netfilter | netfilter/table.py | Table.commit | def commit(self):
"""Commits any buffered commands. This is only useful if
auto_commit is False.
"""
while len(self.__buffer) > 0:
self.__run(self.__buffer.pop(0)) | python | def commit(self):
"""Commits any buffered commands. This is only useful if
auto_commit is False.
"""
while len(self.__buffer) > 0:
self.__run(self.__buffer.pop(0)) | [
"def",
"commit",
"(",
"self",
")",
":",
"while",
"len",
"(",
"self",
".",
"__buffer",
")",
">",
"0",
":",
"self",
".",
"__run",
"(",
"self",
".",
"__buffer",
".",
"pop",
"(",
"0",
")",
")"
] | Commits any buffered commands. This is only useful if
auto_commit is False. | [
"Commits",
"any",
"buffered",
"commands",
".",
"This",
"is",
"only",
"useful",
"if",
"auto_commit",
"is",
"False",
"."
] | e4942c0f6a654a985049b629ead3dc6dcdb30145 | https://github.com/jlaine/python-netfilter/blob/e4942c0f6a654a985049b629ead3dc6dcdb30145/netfilter/table.py#L126-L131 |
42,686 | rauenzi/discordbot.py | discordbot/bot_utils/paginator.py | Pages.numbered_page | async def numbered_page(self):
"""lets you type a page number to go to"""
to_delete = []
to_delete.append(await self.bot.send_message(self.message.channel, 'What page do you want to go to?'))
msg = await self.bot.wait_for_message(author=self.author, channel=self.message.channel,
... | python | async def numbered_page(self):
"""lets you type a page number to go to"""
to_delete = []
to_delete.append(await self.bot.send_message(self.message.channel, 'What page do you want to go to?'))
msg = await self.bot.wait_for_message(author=self.author, channel=self.message.channel,
... | [
"async",
"def",
"numbered_page",
"(",
"self",
")",
":",
"to_delete",
"=",
"[",
"]",
"to_delete",
".",
"append",
"(",
"await",
"self",
".",
"bot",
".",
"send_message",
"(",
"self",
".",
"message",
".",
"channel",
",",
"'What page do you want to go to?'",
")",... | lets you type a page number to go to | [
"lets",
"you",
"type",
"a",
"page",
"number",
"to",
"go",
"to"
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/bot_utils/paginator.py#L133-L154 |
42,687 | rauenzi/discordbot.py | discordbot/bot_utils/paginator.py | Pages.show_help | async def show_help(self):
"""shows this message"""
e = discord.Embed()
messages = ['Welcome to the interactive paginator!\n']
messages.append('This interactively allows you to see pages of text by navigating with ' \
'reactions. They are as follows:\n')
... | python | async def show_help(self):
"""shows this message"""
e = discord.Embed()
messages = ['Welcome to the interactive paginator!\n']
messages.append('This interactively allows you to see pages of text by navigating with ' \
'reactions. They are as follows:\n')
... | [
"async",
"def",
"show_help",
"(",
"self",
")",
":",
"e",
"=",
"discord",
".",
"Embed",
"(",
")",
"messages",
"=",
"[",
"'Welcome to the interactive paginator!\\n'",
"]",
"messages",
".",
"append",
"(",
"'This interactively allows you to see pages of text by navigating w... | shows this message | [
"shows",
"this",
"message"
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/bot_utils/paginator.py#L156-L175 |
42,688 | rauenzi/discordbot.py | discordbot/bot_utils/paginator.py | Pages.stop_pages | async def stop_pages(self):
"""stops the interactive pagination session"""
await self.bot.delete_message(self.message)
self.paginating = False | python | async def stop_pages(self):
"""stops the interactive pagination session"""
await self.bot.delete_message(self.message)
self.paginating = False | [
"async",
"def",
"stop_pages",
"(",
"self",
")",
":",
"await",
"self",
".",
"bot",
".",
"delete_message",
"(",
"self",
".",
"message",
")",
"self",
".",
"paginating",
"=",
"False"
] | stops the interactive pagination session | [
"stops",
"the",
"interactive",
"pagination",
"session"
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/bot_utils/paginator.py#L177-L180 |
42,689 | rauenzi/discordbot.py | discordbot/bot_utils/paginator.py | Pages.paginate | async def paginate(self):
"""Actually paginate the entries and run the interactive loop if necessary."""
await self.show_page(1, first=True)
while self.paginating:
react = await self.bot.wait_for_reaction(message=self.message, check=self.react_check, timeout=120.0)
if re... | python | async def paginate(self):
"""Actually paginate the entries and run the interactive loop if necessary."""
await self.show_page(1, first=True)
while self.paginating:
react = await self.bot.wait_for_reaction(message=self.message, check=self.react_check, timeout=120.0)
if re... | [
"async",
"def",
"paginate",
"(",
"self",
")",
":",
"await",
"self",
".",
"show_page",
"(",
"1",
",",
"first",
"=",
"True",
")",
"while",
"self",
".",
"paginating",
":",
"react",
"=",
"await",
"self",
".",
"bot",
".",
"wait_for_reaction",
"(",
"message"... | Actually paginate the entries and run the interactive loop if necessary. | [
"Actually",
"paginate",
"the",
"entries",
"and",
"run",
"the",
"interactive",
"loop",
"if",
"necessary",
"."
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/bot_utils/paginator.py#L192-L212 |
42,690 | rauenzi/discordbot.py | discordbot/cogs/botadmin.py | BotAdmin._senddms | async def _senddms(self):
"""Toggles sending DMs to owner."""
data = self.bot.config.get("meta", {})
tosend = data.get('send_dms', True)
data['send_dms'] = not tosend
await self.bot.config.put('meta', data)
await self.bot.responses.toggle(message="Forwarding of DMs to own... | python | async def _senddms(self):
"""Toggles sending DMs to owner."""
data = self.bot.config.get("meta", {})
tosend = data.get('send_dms', True)
data['send_dms'] = not tosend
await self.bot.config.put('meta', data)
await self.bot.responses.toggle(message="Forwarding of DMs to own... | [
"async",
"def",
"_senddms",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"bot",
".",
"config",
".",
"get",
"(",
"\"meta\"",
",",
"{",
"}",
")",
"tosend",
"=",
"data",
".",
"get",
"(",
"'send_dms'",
",",
"True",
")",
"data",
"[",
"'send_dms'",
... | Toggles sending DMs to owner. | [
"Toggles",
"sending",
"DMs",
"to",
"owner",
"."
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/botadmin.py#L101-L107 |
42,691 | rauenzi/discordbot.py | discordbot/cogs/botadmin.py | BotAdmin._quit | async def _quit(self):
"""Quits the bot."""
await self.bot.responses.failure(message="Bot shutting down")
await self.bot.logout() | python | async def _quit(self):
"""Quits the bot."""
await self.bot.responses.failure(message="Bot shutting down")
await self.bot.logout() | [
"async",
"def",
"_quit",
"(",
"self",
")",
":",
"await",
"self",
".",
"bot",
".",
"responses",
".",
"failure",
"(",
"message",
"=",
"\"Bot shutting down\"",
")",
"await",
"self",
".",
"bot",
".",
"logout",
"(",
")"
] | Quits the bot. | [
"Quits",
"the",
"bot",
"."
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/botadmin.py#L111-L114 |
42,692 | rauenzi/discordbot.py | discordbot/cogs/botadmin.py | BotAdmin._setcolor | async def _setcolor(self, *, color : discord.Colour):
"""Sets the default color of embeds."""
data = self.bot.config.get("meta", {})
data['default_color'] = str(color)
await self.bot.config.put('meta', data)
await self.bot.responses.basic(message="The default color has been updat... | python | async def _setcolor(self, *, color : discord.Colour):
"""Sets the default color of embeds."""
data = self.bot.config.get("meta", {})
data['default_color'] = str(color)
await self.bot.config.put('meta', data)
await self.bot.responses.basic(message="The default color has been updat... | [
"async",
"def",
"_setcolor",
"(",
"self",
",",
"*",
",",
"color",
":",
"discord",
".",
"Colour",
")",
":",
"data",
"=",
"self",
".",
"bot",
".",
"config",
".",
"get",
"(",
"\"meta\"",
",",
"{",
"}",
")",
"data",
"[",
"'default_color'",
"]",
"=",
... | Sets the default color of embeds. | [
"Sets",
"the",
"default",
"color",
"of",
"embeds",
"."
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/botadmin.py#L124-L129 |
42,693 | rauenzi/discordbot.py | discordbot/cogs/botadmin.py | BotAdmin._do | async def _do(self, ctx, times: int, *, command):
"""Repeats a command a specified number of times."""
msg = copy.copy(ctx.message)
msg.content = command
for i in range(times):
await self.bot.process_commands(msg) | python | async def _do(self, ctx, times: int, *, command):
"""Repeats a command a specified number of times."""
msg = copy.copy(ctx.message)
msg.content = command
for i in range(times):
await self.bot.process_commands(msg) | [
"async",
"def",
"_do",
"(",
"self",
",",
"ctx",
",",
"times",
":",
"int",
",",
"*",
",",
"command",
")",
":",
"msg",
"=",
"copy",
".",
"copy",
"(",
"ctx",
".",
"message",
")",
"msg",
".",
"content",
"=",
"command",
"for",
"i",
"in",
"range",
"(... | Repeats a command a specified number of times. | [
"Repeats",
"a",
"command",
"a",
"specified",
"number",
"of",
"times",
"."
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/botadmin.py#L142-L147 |
42,694 | rauenzi/discordbot.py | discordbot/cogs/botadmin.py | BotAdmin.disable | async def disable(self, ctx, *, command: str):
"""Disables a command for this server.
You must have Manage Server permissions or the
Bot Admin role to use this command.
"""
command = command.lower()
if command in ('enable', 'disable'):
return await self.bot.... | python | async def disable(self, ctx, *, command: str):
"""Disables a command for this server.
You must have Manage Server permissions or the
Bot Admin role to use this command.
"""
command = command.lower()
if command in ('enable', 'disable'):
return await self.bot.... | [
"async",
"def",
"disable",
"(",
"self",
",",
"ctx",
",",
"*",
",",
"command",
":",
"str",
")",
":",
"command",
"=",
"command",
".",
"lower",
"(",
")",
"if",
"command",
"in",
"(",
"'enable'",
",",
"'disable'",
")",
":",
"return",
"await",
"self",
".... | Disables a command for this server.
You must have Manage Server permissions or the
Bot Admin role to use this command. | [
"Disables",
"a",
"command",
"for",
"this",
"server",
"."
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/botadmin.py#L151-L171 |
42,695 | rauenzi/discordbot.py | discordbot/cogs/botadmin.py | BotAdmin.enable | async def enable(self, ctx, *, command: str):
"""Enables a command for this server.
You must have Manage Server permissions or the
Bot Admin role to use this command.
"""
command = command.lower()
guild_id = ctx.message.server.id
cmds = self.config.get('commands'... | python | async def enable(self, ctx, *, command: str):
"""Enables a command for this server.
You must have Manage Server permissions or the
Bot Admin role to use this command.
"""
command = command.lower()
guild_id = ctx.message.server.id
cmds = self.config.get('commands'... | [
"async",
"def",
"enable",
"(",
"self",
",",
"ctx",
",",
"*",
",",
"command",
":",
"str",
")",
":",
"command",
"=",
"command",
".",
"lower",
"(",
")",
"guild_id",
"=",
"ctx",
".",
"message",
".",
"server",
".",
"id",
"cmds",
"=",
"self",
".",
"con... | Enables a command for this server.
You must have Manage Server permissions or the
Bot Admin role to use this command. | [
"Enables",
"a",
"command",
"for",
"this",
"server",
"."
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/botadmin.py#L175-L193 |
42,696 | rauenzi/discordbot.py | discordbot/cogs/botadmin.py | BotAdmin.ignore | async def ignore(self, ctx):
"""Handles the bot's ignore lists.
To use these commands, you must have the Bot Admin role or have
Manage Channels permissions. These commands are not allowed to be used
in a private message context.
Users with Manage Roles or Bot Admin role can sti... | python | async def ignore(self, ctx):
"""Handles the bot's ignore lists.
To use these commands, you must have the Bot Admin role or have
Manage Channels permissions. These commands are not allowed to be used
in a private message context.
Users with Manage Roles or Bot Admin role can sti... | [
"async",
"def",
"ignore",
"(",
"self",
",",
"ctx",
")",
":",
"if",
"ctx",
".",
"invoked_subcommand",
"is",
"None",
":",
"await",
"self",
".",
"bot",
".",
"say",
"(",
"'Invalid subcommand passed: {0.subcommand_passed}'",
".",
"format",
"(",
"ctx",
")",
")"
] | Handles the bot's ignore lists.
To use these commands, you must have the Bot Admin role or have
Manage Channels permissions. These commands are not allowed to be used
in a private message context.
Users with Manage Roles or Bot Admin role can still invoke the bot
in ignored cha... | [
"Handles",
"the",
"bot",
"s",
"ignore",
"lists",
"."
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/botadmin.py#L197-L208 |
42,697 | rauenzi/discordbot.py | discordbot/cogs/botadmin.py | BotAdmin.ignore_list | async def ignore_list(self, ctx):
"""Tells you what channels are currently ignored in this server."""
ignored = self.config.get('ignored', [])
channel_ids = set(c.id for c in ctx.message.server.channels)
result = []
for channel in ignored:
if channel in channel_ids:
... | python | async def ignore_list(self, ctx):
"""Tells you what channels are currently ignored in this server."""
ignored = self.config.get('ignored', [])
channel_ids = set(c.id for c in ctx.message.server.channels)
result = []
for channel in ignored:
if channel in channel_ids:
... | [
"async",
"def",
"ignore_list",
"(",
"self",
",",
"ctx",
")",
":",
"ignored",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'ignored'",
",",
"[",
"]",
")",
"channel_ids",
"=",
"set",
"(",
"c",
".",
"id",
"for",
"c",
"in",
"ctx",
".",
"message",
".... | Tells you what channels are currently ignored in this server. | [
"Tells",
"you",
"what",
"channels",
"are",
"currently",
"ignored",
"in",
"this",
"server",
"."
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/botadmin.py#L211-L224 |
42,698 | rauenzi/discordbot.py | discordbot/cogs/botadmin.py | BotAdmin.channel_cmd | async def channel_cmd(self, ctx, *, channel : discord.Channel = None):
"""Ignores a specific channel from being processed.
If no channel is specified, the current channel is ignored.
If a channel is ignored then the bot does not process commands in that
channel until it is unignored.
... | python | async def channel_cmd(self, ctx, *, channel : discord.Channel = None):
"""Ignores a specific channel from being processed.
If no channel is specified, the current channel is ignored.
If a channel is ignored then the bot does not process commands in that
channel until it is unignored.
... | [
"async",
"def",
"channel_cmd",
"(",
"self",
",",
"ctx",
",",
"*",
",",
"channel",
":",
"discord",
".",
"Channel",
"=",
"None",
")",
":",
"if",
"channel",
"is",
"None",
":",
"channel",
"=",
"ctx",
".",
"message",
".",
"channel",
"ignored",
"=",
"self"... | Ignores a specific channel from being processed.
If no channel is specified, the current channel is ignored.
If a channel is ignored then the bot does not process commands in that
channel until it is unignored. | [
"Ignores",
"a",
"specific",
"channel",
"from",
"being",
"processed",
"."
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/botadmin.py#L227-L245 |
42,699 | rauenzi/discordbot.py | discordbot/cogs/botadmin.py | BotAdmin._all | async def _all(self, ctx):
"""Ignores every channel in the server from being processed.
This works by adding every channel that the server currently has into
the ignore list. If more channels are added then they will have to be
ignored by using the ignore command.
To use this c... | python | async def _all(self, ctx):
"""Ignores every channel in the server from being processed.
This works by adding every channel that the server currently has into
the ignore list. If more channels are added then they will have to be
ignored by using the ignore command.
To use this c... | [
"async",
"def",
"_all",
"(",
"self",
",",
"ctx",
")",
":",
"ignored",
"=",
"self",
".",
"config",
".",
"get",
"(",
"'ignored'",
",",
"[",
"]",
")",
"channels",
"=",
"ctx",
".",
"message",
".",
"server",
".",
"channels",
"ignored",
".",
"extend",
"(... | Ignores every channel in the server from being processed.
This works by adding every channel that the server currently has into
the ignore list. If more channels are added then they will have to be
ignored by using the ignore command.
To use this command you must have Manage Server per... | [
"Ignores",
"every",
"channel",
"in",
"the",
"server",
"from",
"being",
"processed",
"."
] | 39bb98dae4e49487e6c6c597f85fc41c74b62bb8 | https://github.com/rauenzi/discordbot.py/blob/39bb98dae4e49487e6c6c597f85fc41c74b62bb8/discordbot/cogs/botadmin.py#L249-L264 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.