text stringlengths 81 112k |
|---|
:returns:
A list containing a :obj:`Gtk.TreePath` for each selected row
and a :obj:`Gtk.TreeModel` or :obj:`None`.
:rtype: (:obj:`Gtk.TreeModel`, [:obj:`Gtk.TreePath`])
{{ docs }}
def get_selected_rows(self):
"""
:returns:
A list containing a :obj:`... |
Set the value of the child model
def set_value(self, iter, column, value):
"""Set the value of the child model"""
# Delegate to child model
iter = self.convert_iter_to_child_iter(iter)
self.get_model().set_value(iter, column, value) |
Returns the module or raises ForeignError
def get_foreign_module(namespace):
"""Returns the module or raises ForeignError"""
if namespace not in _MODULES:
try:
module = importlib.import_module("." + namespace, __package__)
except ImportError:
module = None
_MODU... |
Returns a ForeignStruct implementation or raises ForeignError
def get_foreign_struct(namespace, name):
"""Returns a ForeignStruct implementation or raises ForeignError"""
get_foreign_module(namespace)
try:
return ForeignStruct.get(namespace, name)
except KeyError:
raise ForeignError("... |
Raises ImportError if the specified foreign module isn't supported or
the needed dependencies aren't installed.
e.g.: check_foreign('cairo', 'Context')
def require_foreign(namespace, symbol=None):
"""Raises ImportError if the specified foreign module isn't supported or
the needed dependencies aren't i... |
io_add_watch(channel, priority, condition, func, *user_data) -> event_source_id
def io_add_watch(*args, **kwargs):
"""io_add_watch(channel, priority, condition, func, *user_data) -> event_source_id"""
channel, priority, condition, func, user_data = _io_add_watch_get_args(*args, **kwargs)
return GLib.io_add... |
child_watch_add(priority, pid, function, *data)
def child_watch_add(*args, **kwargs):
"""child_watch_add(priority, pid, function, *data)"""
priority, pid, function, data = _child_watch_add_get_args(*args, **kwargs)
return GLib.child_watch_add(priority, pid, function, *data) |
Create a GVariant object from given format and argument list.
This method recursively calls itself for complex structures (arrays,
dictionaries, boxed).
Return a tuple (variant, rest_format, rest_args) with the generated
GVariant, the remainder of the format string, and the remainder o... |
Handle the case where the outermost type of format is a tuple.
def _create_tuple(self, format, args):
"""Handle the case where the outermost type of format is a tuple."""
format = format[1:] # eat the '('
if args is None:
# empty value: we need to call _create() to parse the subty... |
Handle the case where the outermost type of format is a dict.
def _create_dict(self, format, args):
"""Handle the case where the outermost type of format is a dict."""
builder = None
if args is None or not args[0]:
# empty value: we need to call _create() to parse the subtype,
... |
Handle the case where the outermost type of format is an array.
def _create_array(self, format, args):
"""Handle the case where the outermost type of format is an array."""
builder = None
if args is None or not args[0]:
# empty value: we need to call _create() to parse the subtype,... |
Decompose a GVariant into a native Python object.
def unpack(self):
"""Decompose a GVariant into a native Python object."""
LEAF_ACCESSORS = {
'b': self.get_boolean,
'y': self.get_byte,
'n': self.get_int16,
'q': self.get_uint16,
'i': self.get... |
Return a list of the element signatures of the topmost signature tuple.
If the signature is not a tuple, it returns one element with the entire
signature. If the signature is an empty tuple, the result is [].
This is useful for e. g. iterating over method parameters which are
passed as... |
Maps a GITypeInfo() to a ctypes type.
The ctypes types have to be different in the case of return values
since ctypes does 'auto unboxing' in some cases which gives
us no chance to free memory if there is a ownership transfer.
def typeinfo_to_ctypes(info, return_value=False):
"""Maps a GITypeInfo() to... |
Returns a pointer containing the value.
This only works for int32/uint32/utf-8..
def pack_pointer(self, name):
"""Returns a pointer containing the value.
This only works for int32/uint32/utf-8..
"""
return self.parse("""
raise $_.TypeError('Can\\'t convert %(type_name)s to po... |
Takes bytes and returns a GITypelib, or raises GIError
def new_from_memory(cls, data):
"""Takes bytes and returns a GITypelib, or raises GIError"""
size = len(data)
copy = g_memdup(data, size)
ptr = cast(copy, POINTER(guint8))
try:
with gerror(GIError) as error:
... |
Get the subtype class for a pointer
def _get_type(cls, ptr):
"""Get the subtype class for a pointer"""
# fall back to the base class if unknown
return cls.__types.get(lib.g_base_info_get_type(ptr), cls) |
Add a method to the target class
def add_method(info, target_cls, virtual=False, dont_replace=False):
"""Add a method to the target class"""
# escape before prefixing, like pygobject
name = escape_identifier(info.name)
if virtual:
name = "do_" + name
attr = VirtualMethodAttribute(info,... |
Creates a GInterface class
def InterfaceAttribute(iface_info):
"""Creates a GInterface class"""
# Create a new class
cls = type(iface_info.name, (InterfaceBase,), dict(_Interface.__dict__))
cls.__module__ = iface_info.namespace
# GType
cls.__gtype__ = PGType(iface_info.g_type)
# Properti... |
Create a new class for a gtype not in the gir.
The caller is responsible for caching etc.
def new_class_from_gtype(gtype):
"""Create a new class for a gtype not in the gir.
The caller is responsible for caching etc.
"""
if gtype.is_a(PGType.from_name("GObject")):
parent = gtype.parent.pyty... |
Creates a GObject class.
It inherits from the base class and all interfaces it implements.
def ObjectAttribute(obj_info):
"""Creates a GObject class.
It inherits from the base class and all interfaces it implements.
"""
if obj_info.name == "Object" and obj_info.namespace == "GObject":
cl... |
Get a hopefully cache constructor
def _generate_constructor(cls, names):
"""Get a hopefully cache constructor"""
cache = cls._constructors
if names in cache:
return cache[names]
elif len(cache) > 3:
cache.clear()
func = generate_constructor(cls, names)
... |
set_property(property_name: str, value: object)
Set property *property_name* to *value*.
def set_property(self, name, value):
"""set_property(property_name: str, value: object)
Set property *property_name* to *value*.
"""
if not hasattr(self.props, name):
raise Ty... |
get_property(property_name: str) -> object
Retrieves a property value.
def get_property(self, name):
"""get_property(property_name: str) -> object
Retrieves a property value.
"""
if not hasattr(self.props, name):
raise TypeError("Unknown property: %r" % name)
... |
connect(detailed_signal: str, handler: function, *args) -> handler_id: int
The connect() method adds a function or method (handler) to the end
of the list of signal handlers for the named detailed_signal but
before the default class signal handler. An optional set of
parameters may be s... |
connect_after(detailed_signal: str, handler: function, *args) -> handler_id: int
The connect_after() method is similar to the connect() method
except that the handler is added to the signal handler list after
the default class signal handler. Otherwise the details of handler
definition ... |
Make the Python instance take ownership of the GIBaseInfo. i.e.
unref if the python instance gets gc'ed.
def _take_ownership(self):
"""Make the Python instance take ownership of the GIBaseInfo. i.e.
unref if the python instance gets gc'ed.
"""
if self:
ptr = cast(se... |
Casts a GIBaseInfo instance to the right sub type.
The original GIBaseInfo can't have ownership.
Will take ownership.
def _cast(cls, base_info, take_ownership=True):
"""Casts a GIBaseInfo instance to the right sub type.
The original GIBaseInfo can't have ownership.
Will take o... |
Decodes the return value of it isn't None
def decode_return(codec="ascii"):
"""Decodes the return value of it isn't None"""
def outer(f):
def wrap(*args, **kwargs):
res = f(*args, **kwargs)
if res is not None:
return res.decode(codec)
return res
... |
Takes a library name and calls find_library in case loading fails,
since some girs don't include the real .so name.
Raises OSError like LoadLibrary if loading fails.
e.g. javascriptcoregtk-3.0 should be libjavascriptcoregtk-3.0.so on unix
def load_ctypes_library(name):
"""Takes a library name and cal... |
Escape partial C identifiers so they can be used as
attributes/arguments
def escape_identifier(text, reg=KWD_RE):
"""Escape partial C identifiers so they can be used as
attributes/arguments"""
# see http://docs.python.org/reference/lexical_analysis.html#identifiers
if not text:
return "_"
... |
Cache the return value of a function without arguments
def cache_return(func):
"""Cache the return value of a function without arguments"""
_cache = []
def wrap():
if not _cache:
_cache.append(func())
return _cache[0]
return wrap |
Might return a struct
def lookup_name_fast(self, name):
"""Might return a struct"""
if name in self.__names:
return self.__names[name]
count = self.__get_count_cached()
lo = 0
hi = count
while lo < hi:
mid = (lo + hi) // 2
if self.__... |
Returns a struct if one exists
def lookup_name_slow(self, name):
"""Returns a struct if one exists"""
for index in xrange(self.__get_count_cached()):
if self.__get_name_cached(index) == name:
return self.__get_info_cached(index) |
Returns a struct if one exists
def lookup_name(self, name):
"""Returns a struct if one exists"""
try:
info = self._get_by_name(self._source, name)
except NotImplementedError:
pass
else:
if info:
return info
return
... |
Creates a new class similar to namedtuple.
Pass a list of field names or None for no field name.
>>> x = ResultTuple._new_type([None, "bar"])
>>> x((1, 3))
ResultTuple(1, bar=3)
def _new_type(cls, args):
"""Creates a new class similar to namedtuple.
Pass a list of fie... |
Returns a list of signal names for the given type
:param type\\_:
:type type\\_: :obj:`GObject.GType`
:returns: A list of signal names
:rtype: :obj:`list`
def signal_list_names(type_):
"""Returns a list of signal names for the given type
:param type\\_:
:type type\\_: :obj:`GObject.GType`... |
Blocks the signal handler from being invoked until
handler_unblock() is called.
:param GObject.Object obj:
Object instance to block handlers for.
:param int handler_id:
Id of signal to block.
:returns:
A context manager which optionally can be used to
automatically unblo... |
Parse a detailed signal name into (signal_id, detail).
:param str detailed_signal:
Signal name which can include detail.
For example: "notify:prop_name"
:returns:
Tuple of (signal_id, detail)
:raises ValueError:
If the given signal is unknown.
def signal_parse_name(detailed... |
cached: Return a new instance
internal: return a shared instance that's not the ctypes cached one
def find_library(name, cached=True, internal=True):
"""
cached: Return a new instance
internal: return a shared instance that's not the ctypes cached one
"""
# a new one
if not cac... |
Track an object which needs destruction when it is garbage collected.
def track(cls, obj, ptr):
"""
Track an object which needs destruction when it is garbage collected.
"""
cls._objects.add(cls(obj, ptr)) |
Convert a D-BUS return variant into an appropriate return value
def _unpack_result(klass, result):
'''Convert a D-BUS return variant into an appropriate return value'''
result = result.unpack()
# to be compatible with standard Python behaviour, unbox
# single-element tuples and return... |
:param type: a Python GObject instance or type that the signal is associated with
:type type: :obj:`GObject.Object`
:returns: a list of :obj:`GObject.ParamSpec`
:rtype: [:obj:`GObject.ParamSpec`]
Takes a GObject/GInterface subclass or a GType and returns a list of
GParamSpecs for all properties of... |
Loads overrides for an introspection module.
Either returns the same module again in case there are no overrides or a
proxy module including overrides. Doesn't cache the result.
def load_overrides(introspection_module):
"""Loads overrides for an introspection module.
Either returns the same module ag... |
Takes a override class or function and assigns it dunder arguments
form the overidden one.
def override(klass):
"""Takes a override class or function and assigns it dunder arguments
form the overidden one.
"""
namespace = klass.__module__.rsplit(".", 1)[-1]
mod_name = const.PREFIX[-1] + "." + ... |
Mark a function deprecated so calling it issues a warning
def deprecated(function, instead):
"""Mark a function deprecated so calling it issues a warning"""
# skip for classes, breaks doc generation
if not isinstance(function, types.FunctionType):
return function
@wraps(function)
def wrap... |
Marks a module level attribute as deprecated. Accessing it will emit
a PyGIDeprecationWarning warning.
e.g. for ``deprecated_attr("GObject", "STATUS_FOO", "GLib.Status.FOO")``
accessing GObject.STATUS_FOO will emit:
"GObject.STATUS_FOO is deprecated; use GLib.Status.FOO instead"
:param str na... |
Wrapper for deprecating GObject based __init__ methods which specify
defaults already available or non-standard defaults.
:param callable super_init_func:
Initializer to wrap.
:param list arg_names:
Ordered argument name list.
:param list ignore:
List of argument names to ignore... |
Translate method's return value for stripping off success flag.
There are a lot of methods which return a "success" boolean and have
several out arguments. Translate such a method to return the out arguments
on success and None on failure.
def strip_boolean_result(method, exc_type=None, exc_str=None, fail... |
Raises ImportError
def get_introspection_module(namespace):
"""Raises ImportError"""
if namespace in _introspection_modules:
return _introspection_modules[namespace]
from . import get_required_version
repository = GIRepository()
version = get_required_version(namespace)
try:
... |
Returns a ReturnValue instance for param type 'index
def get_param_type(self, index):
"""Returns a ReturnValue instance for param type 'index'"""
assert index in (0, 1)
type_info = self.type.get_param_type(index)
type_cls = get_return_class(type_info)
instance = type_cls(None,... |
Parse a piece of text and substitude $var by either unique
variable names or by the given kwargs mapping. Use $$ to escape $.
Returns a CodeBlock and the resulting variable mapping.
parse("$foo = $foo + $bar", bar="1")
("t1 = t1 + 1", {'foo': 't1', 'bar': '1'})
def parse_code(code, var_factory, **kwa... |
Parse code and include non string/codeblock kwargs as
dependencies.
int/long will be inlined.
Returns a CodeBlock and the resulting variable mapping.
def parse_with_objects(code, var, **kwargs):
"""Parse code and include non string/codeblock kwargs as
dependencies.
int/long will be inlined.
... |
Request a name, might return the name or a similar one if already
used or reserved
def request_name(self, name):
"""Request a name, might return the name or a similar one if already
used or reserved
"""
while name in self._blacklist:
name += "_"
self._blackl... |
Add a code dependency so it gets inserted into globals
def add_dependency(self, name, obj):
"""Add a code dependency so it gets inserted into globals"""
if name in self._deps:
if self._deps[name] is obj:
return
raise ValueError(
"There exists a d... |
Append this block to another one, passing all dependencies
def write_into(self, block, level=0):
"""Append this block to another one, passing all dependencies"""
for line, l in self._lines:
block.write_line(line, level + l)
for name, obj in _compat.iteritems(self._deps):
... |
Append multiple new lines
def write_lines(self, lines, level=0):
"""Append multiple new lines"""
for line in lines:
self.write_line(line, level) |
Execute the python code and returns the global dict.
kwargs can contain extra dependencies that get only used
at compile time.
def compile(self, **kwargs):
"""Execute the python code and returns the global dict.
kwargs can contain extra dependencies that get only used
at compile... |
Print the code block to stdout.
Does syntax highlighting if possible.
def pprint(self, file_=sys.stdout):
"""Print the code block to stdout.
Does syntax highlighting if possible.
"""
code = []
if self._deps:
code.append("# dependencies:")
for k, v in... |
Class decorator
def register(cls, namespace, name):
"""Class decorator"""
def func(kind):
cls._FOREIGN[(namespace, name)] = kind()
return kind
return func |
If may_be_null returns nullable or if NULL can be passed in.
This can still be wrong if the specific typelib is older than the linked
libgirepository.
https://bugzilla.gnome.org/show_bug.cgi?id=660879#c47
def may_be_null_is_nullable():
"""If may_be_null returns nullable or if NULL can be passed in.
... |
Gives a name for a type that is suitable for a docstring.
int -> "int"
Gtk.Window -> "Gtk.Window"
[int] -> "[int]"
{int: Gtk.Button} -> "{int: Gtk.Button}"
def get_type_name(type_):
"""Gives a name for a type that is suitable for a docstring.
int -> "int"
Gtk.Window -> "Gtk.Window"
[i... |
Create a docstring in the form:
name(in_name: type) -> (ret_type, out_name: type)
def build_docstring(func_name, args, ret, throws, signal_owner_type=None):
"""Create a docstring in the form:
name(in_name: type) -> (ret_type, out_name: type)
"""
out_args = []
if ret and not ret.ignore:... |
Creates a Python callable for a GIFunctionInfo instance
def generate_function(info, method=False):
"""Creates a Python callable for a GIFunctionInfo instance"""
assert isinstance(info, GIFunctionInfo)
arg_infos = list(info.get_args())
arg_types = [a.get_type() for a in arg_infos]
return_type = in... |
Takes a GICallableInfo and generates a dummy callback function which
just raises but has a correct docstring. They are mainly accessible for
documentation, so the API reference can reference a real thing.
func_name can be different than info.name because vfuncs, for example,
get prefixed with 'do_' whe... |
Returns a new shiny class for the given enum type
def _create_enum_class(ffi, type_name, prefix, flags=False):
"""Returns a new shiny class for the given enum type"""
class _template(int):
_map = {}
@property
def value(self):
return int(self)
def __str__(self):
... |
Converts some common enum expressions to constants
def _fixup_cdef_enums(string, reg=re.compile(r"=\s*(\d+)\s*<<\s*(\d+)")):
"""Converts some common enum expressions to constants"""
def repl_shift(match):
shift_by = int(match.group(2))
value = int(match.group(1))
int_value = ctypes.c_i... |
Takes a glist, copies the values casted to type_ in to a list
and frees all items and the list.
def unpack_glist(g, type_, transfer_full=True):
"""Takes a glist, copies the values casted to type_ in to a list
and frees all items and the list.
"""
values = []
item = g
while item:
pt... |
Takes a null terminated array, copies the values into a list
and frees each value and the list.
def unpack_nullterm_array(array):
"""Takes a null terminated array, copies the values into a list
and frees each value and the list.
"""
addrs = cast(array, POINTER(ctypes.c_void_p))
l = []
i = ... |
Set a version for the namespace to be loaded.
This needs to be called before importing the namespace or any
namespace that depends on it.
def require_version(namespace, version):
"""Set a version for the namespace to be loaded.
This needs to be called before importing the namespace or any
namespace... |
A context manager which tries to give helpful warnings
about missing gi.require_version() which could potentially
break code if only an older version than expected is installed
or a new version gets introduced.
::
with _check_require_version("Gtk", stacklevel):
load_namespace_and_o... |
Returns the stacklevel value for warnings.warn() for when the warning
gets emitted by an imported module, but the warning should point at the
code doing the import.
Pass import_hook=True if the warning gets generated by an import hook
(warn() gets called in load_module(), see PEP302)
def get_import_st... |
Takes a glist ptr, copies the values casted to type_ in to a list
and frees all items and the list.
If an item is returned all yielded before are invalid.
def unpack_glist(glist_ptr, cffi_type, transfer_full=True):
"""Takes a glist ptr, copies the values casted to type_ in to a list
and frees all item... |
Converts a zero terminated array to a list and frees each element
and the list itself.
If an item is returned all yielded before are invalid.
def unpack_zeroterm_array(ptr):
"""Converts a zero terminated array to a list and frees each element
and the list itself.
If an item is returned all yielde... |
Creates a new struct class.
def StructureAttribute(struct_info):
"""Creates a new struct class."""
# Copy the template and add the gtype
cls_dict = dict(_Structure.__dict__)
cls = type(struct_info.name, _Structure.__bases__, cls_dict)
cls.__module__ = struct_info.namespace
cls.__gtype__ = PGTy... |
Creates a GError exception and takes ownership if own is True
def _from_gerror(cls, error, own=True):
"""Creates a GError exception and takes ownership if own is True"""
if not own:
error = error.copy()
self = cls()
self._error = error
return self |
Takes a version string or tuple and raises ValueError in case
the passed version is newer than the current version of pgi.
Keep in mind that the pgi version is different from the pygobject one.
def check_version(version):
"""Takes a version string or tuple and raises ValueError in case
the passed vers... |
Call before the first gi import to redirect gi imports to pgi
def install_as_gi():
"""Call before the first gi import to redirect gi imports to pgi"""
import sys
# check if gi has already been replaces
if "gi.repository" in const.PREFIX:
return
# make sure gi isn't loaded first
for m... |
Adds specified panel class to model class.
:param model: the model class.
:param panel_cls: the panel class.
:param heading: the panel heading.
:param index: the index position to insert at.
def add_panel_to_edit_handler(model, panel_cls, heading, index=None):
"""
Adds specified panel class to... |
Returns context dictionary for view.
:rtype: dict.
def get_context_data(self, **kwargs):
"""
Returns context dictionary for view.
:rtype: dict.
"""
#noinspection PyUnresolvedReferences
query_str = self.request.GET.get('q', None)
queryset ... |
Returns ordering value for list.
:rtype: str.
def get_ordering(self):
"""
Returns ordering value for list.
:rtype: str.
"""
#noinspection PyUnresolvedReferences
ordering = self.request.GET.get('ordering', None)
if ordering not in ['title', '-created_at... |
Returns queryset instance.
:rtype: django.db.models.query.QuerySet.
def get_queryset(self):
"""
Returns queryset instance.
:rtype: django.db.models.query.QuerySet.
"""
queryset = super(IndexView, self).get_queryset()
search_form = self.get_search_form()
... |
Returns search form instance.
:rtype: django.forms.ModelForm.
def get_search_form(self):
"""
Returns search form instance.
:rtype: django.forms.ModelForm.
"""
#noinspection PyUnresolvedReferences
if 'q' in self.request.GET:
#noinspection PyUnresolve... |
Returns a list of template names for the view.
:rtype: list.
def get_template_names(self):
"""
Returns a list of template names for the view.
:rtype: list.
"""
#noinspection PyUnresolvedReferences
if self.request.is_ajax():
template_name = '/results... |
Returns tuple containing paginator instance, page instance,
object list, and whether there are other pages.
:param queryset: the queryset instance to paginate.
:param page_size: the number of instances per page.
:rtype: tuple.
def paginate_queryset(self, queryset, page_size):
"... |
Processes an invalid form submittal.
:param form: the form instance.
:rtype: django.http.HttpResponse.
def form_invalid(self, form):
"""
Processes an invalid form submittal.
:param form: the form instance.
:rtype: django.http.HttpResponse.
"""
meta = ge... |
Processes a valid form submittal.
:param form: the form instance.
:rtype: django.http.HttpResponse.
def form_valid(self, form):
"""
Processes a valid form submittal.
:param form: the form instance.
:rtype: django.http.HttpResponse.
"""
#noinspection PyA... |
Returns redirect URL for valid form submittal.
:rtype: str.
def get_success_url(self):
"""
Returns redirect URL for valid form submittal.
:rtype: str.
"""
if self.success_url:
url = force_text(self.success_url)
else:
url = reverse('{0}:i... |
Processes deletion of the specified instance.
:param request: the request instance.
:rtype: django.http.HttpResponse.
def delete(self, request, *args, **kwargs):
"""
Processes deletion of the specified instance.
:param request: the request instance.
:rtype: django.http... |
Returns chunks of n length of iterable
If len(iterable) % n != 0, then the last chunk will have length
less than n.
Example:
>>> chunked([1, 2, 3, 4, 5], 2)
[(1, 2), (3, 4), (5,)]
def chunked(iterable, n):
"""Returns chunks of n length of iterable
If len(iterable) % n != 0, then the la... |
Return explanation in an easier to read format
Easier to read for me, at least.
def format_explanation(explanation, indent=' ', indent_level=0):
"""Return explanation in an easier to read format
Easier to read for me, at least.
"""
if not explanation:
return ''
# Note: This is prob... |
Return a elasticsearch Elasticsearch object using settings
from ``settings.py``.
:arg overrides: Allows you to override defaults to create the
ElasticSearch object. You can override any of the arguments
isted in :py:func:`elasticutils.get_es`.
For example, if you wanted to create an Elasti... |
Wrap a callable and return None if ES_DISABLED is False.
This also adds an additional `es` argument to the callable
giving you an ElasticSearch instance to use.
def es_required(fun):
"""Wrap a callable and return None if ES_DISABLED is False.
This also adds an additional `es` argument to the callable... |
Returns the elasticsearch Elasticsearch object to use.
This uses the django get_es builder by default which takes
into account settings in ``settings.py``.
def get_es(self, default_builder=get_es):
"""Returns the elasticsearch Elasticsearch object to use.
This uses the django get_es b... |
Returns the list of indexes to act on based on ES_INDEXES setting
def get_indexes(self, default_indexes=None):
"""Returns the list of indexes to act on based on ES_INDEXES setting
"""
doctype = self.type.get_mapping_type_name()
indexes = (settings.ES_INDEXES.get(doctype) or
... |
Returns the doctypes (or mapping type names) to use.
def get_doctypes(self, default_doctypes=None):
"""Returns the doctypes (or mapping type names) to use."""
doctypes = self.type.get_mapping_type_name()
if isinstance(doctypes, six.string_types):
doctypes = [doctypes]
return... |
Gets the index for this model.
The index for this model is specified in `settings.ES_INDEXES`
which is a dict of mapping type -> index name.
By default, this uses `.get_mapping_type()` to determine the
mapping and returns the value in `settings.ES_INDEXES` for that
or ``setting... |
Returns the queryset of ids of all things to be indexed.
Defaults to::
cls.get_model().objects.order_by('id').values_list(
'id', flat=True)
:returns: iterable of ids of objects to be indexed
def get_indexable(cls):
"""Returns the queryset of ids of all things to b... |
Create an elasticsearch `Elasticsearch` object and return it.
This will aggressively re-use `Elasticsearch` objects with the
following rules:
1. if you pass the same argument values to `get_es()`, then it
will return the same `Elasticsearch` object
2. if you pass different argument values to `g... |
Returns facet counts as dict.
Given the `items()` on the raw dictionary from Elasticsearch this processes
it and returns the counts keyed on the facet name provided in the original
query.
def _facet_counts(items):
"""Returns facet counts as dict.
Given the `items()` on the raw dictionary from Ela... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.