text
stringlengths
81
112k
Convert a Structure specification to a numpy structured dtype. def struct_to_dtype(struct): """Convert a Structure specification to a numpy structured dtype.""" # str() around name necessary because protobuf gives unicode names, but dtype doesn't # support them on Python 2 fields = [(str(var.name), dat...
Unpack an NCStream Variable into information we can use. def unpack_variable(var): """Unpack an NCStream Variable into information we can use.""" # If we actually get a structure instance, handle turning that into a variable if var.dataType == stream.STRUCTURE: return None, struct_to_dtype(var), 'S...
Unpack an embedded attribute into a python or numpy object. def unpack_attribute(att): """Unpack an embedded attribute into a python or numpy object.""" if att.unsigned: log.warning('Unsupported unsigned attribute!') # TDS 5.0 now has a dataType attribute that takes precedence if att.len == 0:...
Read a variable-length integer. Parameters ---------- file_obj : file-like object The file to read from. Returns ------- int the variable-length value read def read_var_int(file_obj): """Read a variable-length integer. Parameters ---------- file_obj : file-lik...
Retrieve data from CDMRemote for one or more variables. def fetch_data(self, **var): """Retrieve data from CDMRemote for one or more variables.""" varstr = ','.join(name + self._convert_indices(ind) for name, ind in var.items()) query = self.query().add_query_parameter...
Generate a new query for CDMRemote. This handles turning on compression if necessary. Returns ------- HTTPQuery The created query. def query(self): """Generate a new query for CDMRemote. This handles turning on compression if necessary. Returns ...
检查 access token 是否有效. def check_token(func): """检查 access token 是否有效.""" @wraps(func) def wrapper(*args, **kwargs): response = func(*args, **kwargs) if response.status_code == 401: raise InvalidToken('Access token invalid or no longer valid') else: return res...
上传单个文件(<2G). | 百度PCS服务目前支持最大2G的单个文件上传。 | 如需支持超大文件(>2G)的断点续传,请参考下面的“分片文件上传”方法。 :param remote_path: 网盘中文件的保存路径(包含文件名)。 必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:...
分片上传—文件分片及上传. 百度 PCS 服务支持每次直接上传最大2G的单个文件。 如需支持上传超大文件(>2G),则可以通过组合调用分片文件上传的 ``upload_tmpfile`` 方法和 ``upload_superfile`` 方法实现: 1. 首先,将超大文件分割为2G以内的单文件,并调用 ``upload_tmpfile`` 将分片文件依次上传; 2. 其次,调用 ``upload_superfile`` ,完成分片文件的重组。 除此之外,如果应用中需要支持断点续传的功能, 也可...
分片上传—合并分片文件. 与分片文件上传的 ``upload_tmpfile`` 方法配合使用, 可实现超大文件(>2G)上传,同时也可用于断点续传的场景。 :param remote_path: 网盘中文件的保存路径(包含文件名)。 必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符...
为当前用户创建一个目录. :param remote_path: 网盘中目录的路径,必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` 或空白字符,空...
获取单个文件或目录的元信息. :param remote_path: 网盘中文件/目录的路径,必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` 或空...
获取目录下的文件列表. :param remote_path: 网盘中目录的路径,必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` 或空白字符,空白...
移动单个文件或目录. :param from_path: 源文件/目录在网盘中的路径(包括文件名)。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` 或空白字符,空白字符包括: ...
批量移动文件或目录. :param path_list: 源文件地址和目标文件地址对列表: >>> path_list = [ ... ('/apps/test_sdk/test.txt', # 源文件 ... '/apps/test_sdk/testmkdir/b.txt' # 目标文件 ... ), ... ('/apps/test...
拷贝文件或目录. :param from_path: 源文件/目录在网盘中的路径(包括文件名)。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` 或空白字符,空白字符包括: ...
删除单个文件或目录. .. warning:: * 文件/目录删除后默认临时存放在回收站内,删除文件或目录的临时存放 不占用用户的空间配额; * 存放有效期为10天,10天内可还原回原路径下,10天后则永久删除。 :param remote_path: 网盘中文件/目录的路径,路径必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; ...
批量删除文件或目录. .. warning:: * 文件/目录删除后默认临时存放在回收站内,删除文件或目录的临时存放 不占用用户的空间配额; * 存放有效期为10天,10天内可还原回原路径下,10天后则永久删除。 :param path_list: 网盘中文件/目录的路径列表,路径必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; ...
按文件名搜索文件(不支持查找目录). :param remote_path: 需要检索的目录路径,路径必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` ...
获取指定图片文件的缩略图. :param remote_path: 源图片的路径,路径必须以 /apps/ 开头。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` 或空白字符,...
文件增量更新操作查询接口. 本接口有数秒延迟,但保证返回结果为最终一致. :param cursor: 用于标记更新断点。 * 首次调用cursor=null; * 非首次调用,使用最后一次调用diff接口的返回结果 中的cursor。 :type cursor: str :return: Response 对象 def diff(self, cursor='null', **kwargs): """文件增量...
对视频文件进行转码,实现实时观看视频功能. 可下载支持 HLS/M3U8 的 `媒体云播放器 SDK <HLSSDK_>`__ 配合使用. .. _HLSSDK: http://developer.baidu.com/wiki/index.php?title=docs/cplat/media/sdk :param remote_path: 需要下载的视频文件路径,以/开头的绝对路径, 需含源文件的文件名。 .. warning:: ...
以视频、音频、图片及文档四种类型的视图获取所创建应用程序下的 文件列表. :param file_type: 类型分为video、audio、image及doc四种。 :param start: 返回条目控制起始值,缺省值为0。 :param limit: 返回条目控制长度,缺省为1000,可配置。 :param filter_path: 需要过滤的前缀路径,如:/apps/album .. warning:: * 路径长度限制为1...
为当前用户下载一个流式文件.其参数和返回结果与下载单个文件的相同. :param remote_path: 需要下载的文件路径,以/开头的绝对路径,含文件名。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` ...
秒传一个文件. .. warning:: * 被秒传文件必须大于256KB(即 256*1024 B)。 * 校验段为文件的前256KB,秒传接口需要提供校验段的MD5。 (非强一致接口,上传后请等待1秒后再读取) :param remote_path: 上传文件的全路径名。 .. warning:: * 路径长度限制为1000; * 径中不能包...
添加离线下载任务,实现单个文件离线下载. :param source_url: 源文件的URL。 :param remote_path: 下载后的文件保存路径。 .. warning:: * 路径长度限制为1000; * 径中不能包含以下字符:``\\\\ ? | " > < : *``; * 文件名或路径名开头结尾不能是 ``.`` ...
根据任务ID号,查询离线下载任务信息及进度信息。 :param task_ids: 要查询的任务ID列表 :type task_ids: list or tuple :param operate_type: * 0:查任务信息 * 1:查进度信息,默认为1 :param expires: 请求失效时间,如果有,则会校验。 :type expires: int :return: Response 对象 def query_do...
查询离线下载任务ID列表及任务信息. :param need_task_info: 是否需要返回任务信息: * 0:不需要 * 1:需要,默认为1 :param start: 查询任务起始位置,默认为0。 :param limit: 设定返回任务数量,默认为10。 :param asc: * 0:降序,默认值 * 1:升序 :param create_...
取消离线下载任务. :param task_id: 要取消的任务ID号。 :type task_id: str :param expires: 请求失效时间,如果有,则会校验。 :type expires: int :return: Response 对象 def cancel_download_task(self, task_id, expires=None, **kwargs): """取消离线下载任务. :param task_id: 要取消的任务ID号。 :type task_id: str ...
获取回收站中的文件及目录列表. :param start: 返回条目的起始值,缺省值为0 :param limit: 返回条目的长度,缺省值为1000 :return: Response 对象 def list_recycle_bin(self, start=0, limit=1000, **kwargs): """获取回收站中的文件及目录列表. :param start: 返回条目的起始值,缺省值为0 :param limit: 返回条目的长度,缺省值为1000 :return: Response 对象 ...
还原单个文件或目录(非强一致接口,调用后请sleep 1秒读取). :param fs_id: 所还原的文件或目录在PCS的临时唯一标识ID。 :type fs_id: str :return: Response 对象 def restore_recycle_bin(self, fs_id, **kwargs): """还原单个文件或目录(非强一致接口,调用后请sleep 1秒读取). :param fs_id: 所还原的文件或目录在PCS的临时唯一标识ID。 :type fs_id: str :return: Re...
批量还原文件或目录(非强一致接口,调用后请sleep1秒 ). :param fs_ids: 所还原的文件或目录在 PCS 的临时唯一标识 ID 的列表。 :type fs_ids: list or tuple :return: Response 对象 def multi_restore_recycle_bin(self, fs_ids, **kwargs): """批量还原文件或目录(非强一致接口,调用后请sleep1秒 ). :param fs_ids: 所还原的文件或目录在 PCS 的临时唯一标识 ID 的列表。 :type ...
使用 Refresh Token 刷新以获得新的 Access Token. :param refresh_token: 用于刷新 Access Token 用的 Refresh Token; :param client_id: 应用的 API Key; :param client_secret: 应用的 Secret Key; :param scope: 以空格分隔的权限列表,若不传递此参数,代表请求的数据访问 操作权限与上次获取 Access Token 时一致。通过 Refresh Token 刷新 Access Toke...
Login to verisure app api Login before calling any read or write commands def login(self): """ Login to verisure app api Login before calling any read or write commands """ if os.path.exists(self._cookieFileName): with open(self._cookieFileName, 'r') as cookieFile...
Get information about installations def _get_installations(self): """ Get information about installations """ response = None for base_url in urls.BASE_URLS: urls.BASE_URL = base_url try: response = requests.get( urls.get_installations...
Get overview for installation def get_overview(self): """ Get overview for installation """ response = None try: response = requests.get( urls.overview(self._giid), headers={ 'Accept': 'application/json, text/javascript, */*; q=0.0...
Turn on or off smartplug Args: device_label (str): Smartplug device label state (boolean): new status, 'True' or 'False' def set_smartplug_state(self, device_label, state): """ Turn on or off smartplug Args: device_label (str): Smartplug device label ...
Get recent events Args: filters (string set): 'ARM', 'DISARM', 'FIRE', 'INTRUSION', 'TECHNICAL', 'SOS', 'WARNING', 'LOCK', 'UNLOCK' pagesize (int): Number of events to display offset (int): Skip pagesize * o...
Get climate history Args: device_label: device label of climate device def get_climate(self, device_label): """ Get climate history Args: device_label: device label of climate device """ response = None try: response = requests.get( ...
Lock or unlock Args: code (str): Lock code device_label (str): device label of lock state (str): 'lock' or 'unlock' def set_lock_state(self, code, device_label, state): """ Lock or unlock Args: code (str): Lock code device_label (str...
Get lock state transaction status Args: transaction_id: Transaction ID received from set_lock_state def get_lock_state_transaction(self, transaction_id): """ Get lock state transaction status Args: transaction_id: Transaction ID received from set_lock_state """...
Get lock configuration Args: device_label (str): device label of lock def get_lock_config(self, device_label): """ Get lock configuration Args: device_label (str): device label of lock """ response = None try: response = requests.get...
Set lock configuration Args: device_label (str): device label of lock volume (str): 'SILENCE', 'LOW' or 'HIGH' voice_level (str): 'ESSENTIAL' or 'NORMAL' auto_lock_enabled (boolean): auto lock enabled def set_lock_config(self, device_label, volume=None, voice_le...
Capture smartcam image Args: device_label (str): device label of camera def capture_image(self, device_label): """ Capture smartcam image Args: device_label (str): device label of camera """ response = None try: response = requests.p...
Get smartcam image series Args: number_of_imageseries (int): number of image series to get offset (int): skip offset amount of image series def get_camera_imageseries(self, number_of_imageseries=10, offset=0): """ Get smartcam image series Args: number_of_i...
Download image taken by a smartcam Args: device_label (str): device label of camera image_id (str): image id from image series file_name (str): path to file def download_image(self, device_label, image_id, file_name): """ Download image taken by a smartcam ...
Logout and remove vid def logout(self): """ Logout and remove vid """ response = None try: response = requests.delete( urls.login(), headers={ 'Cookie': 'vid={}'.format(self._vid)}) except requests.exceptions.RequestExcepti...
Set heatpump mode Args: mode (str): 'HEAT', 'COOL', 'FAN' or 'AUTO' def set_heat_pump_mode(self, device_label, mode): """ Set heatpump mode Args: mode (str): 'HEAT', 'COOL', 'FAN' or 'AUTO' """ response = None try: response = requests....
Set heatpump mode Args: feature: 'QUIET', 'ECONAVI', or 'POWERFUL' def set_heat_pump_feature(self, device_label, feature): """ Set heatpump mode Args: feature: 'QUIET', 'ECONAVI', or 'POWERFUL' """ response = None try: response = reque...
Print the result of a verisure request def print_result(overview, *names): """ Print the result of a verisure request """ if names: for name in names: toprint = overview for part in name.split('/'): toprint = toprint[part] print(json.dumps(toprint, in...
Start verisure command line def main(): """ Start verisure command line """ parser = argparse.ArgumentParser( description='Read or change status of verisure devices') parser.add_argument( 'username', help='MyPages username') parser.add_argument( 'password', help=...
Shortcut to retrieving the ContentType id of the model. def type_id(self): """ Shortcut to retrieving the ContentType id of the model. """ try: return ContentType.objects.get_for_model(self.model, for_concrete_model=False).id except DatabaseError as e: ra...
.. versionadded:: 0.9 Return the default cache key which is used to store a rendered item. By default, this function generates the cache key using :func:`get_output_cache_base_key`. def get_output_cache_key(self, placeholder_name, instance): """ .. versionadded:: 0.9 Re...
.. versionadded:: 0.9 Return the possible cache keys for a rendered item. This method should be overwritten when implementing a function :func:`set_cached_output` method or when implementing a :func:`get_output_cache_key` function. By default, this function generates the cac...
.. versionadded:: 0.9 Return the cached output for a rendered item, or ``None`` if no output is cached. This method can be overwritten to implement custom caching mechanisms. By default, this function generates the cache key using :func:`get_output_cache_key` and retrieves t...
.. versionadded:: 0.9 Store the cached output for a rendered item. This method can be overwritten to implement custom caching mechanisms. By default, this function generates the cache key using :func:`~fluent_contents.cache.get_rendering_cache_key` and stores the results in ...
The rendering/view function that displays a plugin model instance. :param instance: An instance of the ``model`` the plugin uses. :param request: The Django :class:`~django.http.HttpRequest` class containing the request parameters. :param kwargs: An optional slot for any new parameters. ...
Render a custom template with the :class:`~PluginContext` as context instance. def render_to_string(self, request, template, context, content_instance=None): """ Render a custom template with the :class:`~PluginContext` as context instance. """ if not content_instance: conte...
Add a :class:`~django.forms.Media` class to the current request. This will be rendered by the ``render_plugin_media`` template tag. def register_frontend_media(request, media): """ Add a :class:`~django.forms.Media` class to the current request. This will be rendered by the ``render_plugin_media`` temp...
Return a cache key for the content item output. .. seealso:: The :func:`ContentItem.clear_cache() <fluent_contents.models.ContentItem.clear_cache>` function can be used to remove the cache keys of a retrieved object. def get_rendering_cache_key(placeholder_name, contentitem): """ Return a...
Return a cache key for an existing placeholder object. This key is used to cache the entire output of a placeholder. def get_placeholder_cache_key(placeholder, language_code): """ Return a cache key for an existing placeholder object. This key is used to cache the entire output of a placeholder. ...
Return a cache key for a placeholder. This key is used to cache the entire output of a placeholder. def get_placeholder_cache_key_for_parent(parent_object, placeholder_name, language_code): """ Return a cache key for a placeholder. This key is used to cache the entire output of a placeholder. """...
See if there are items that point to a removed model. def remove_stale_items(self, stale_cts): """ See if there are items that point to a removed model. """ stale_ct_ids = list(stale_cts.keys()) items = (ContentItem.objects .non_polymorphic() # very important, ...
See if there are items that no longer point to an existing parent. def remove_unreferenced_items(self, stale_cts): """ See if there are items that no longer point to an existing parent. """ stale_ct_ids = list(stale_cts.keys()) parent_types = (ContentItem.objects.order_by() ...
Gives all elements from self._initial having a slot value that is not already in self.get_queryset() def __initial_minus_queryset(self): """ Gives all elements from self._initial having a slot value that is not already in self.get_queryset() """ queryset = self.get_query...
Validate and return the Placeholder object that the template variable points to. def _get_placeholder_arg(arg_name, placeholder): """ Validate and return the Placeholder object that the template variable points to. """ if placeholder is None: raise RuntimeWarning(u"placeholder object is None") ...
Extract the local or external URLs from a Media object. def _split_js(media, domain): """ Extract the local or external URLs from a Media object. """ # Read internal property without creating new Media instance. if not media._js: return ImmutableMedia.empty_instance needs_local = domai...
Extract the local or external URLs from a Media object. def _split_css(media, domain): """ Extract the local or external URLs from a Media object. """ # Read internal property without creating new Media instance. if not media._css: return ImmutableMedia.empty_instance needs_local = dom...
Parse the node syntax: .. code-block:: html+django {% page_placeholder parentobj slotname title="test" role="m" %} def parse(cls, parser, token): """ Parse the node syntax: .. code-block:: html+django {% page_placeholder parentobj slotname title="test" role="...
Return the string literal that is used in the template. The title is used in the admin screens. def get_title(self): """ Return the string literal that is used in the template. The title is used in the admin screens. """ try: return extract_literal(self.meta_...
See if a template FilterExpression holds a literal value. :type templatevar: django.template.FilterExpression :rtype: bool|None def extract_literal(templatevar): """ See if a template FilterExpression holds a literal value. :type templatevar: django.template.FilterExpression :rtype: bool|None...
See if a template FilterExpression holds a literal boolean value. :type templatevar: django.template.FilterExpression :rtype: bool|None def extract_literal_bool(templatevar): """ See if a template FilterExpression holds a literal boolean value. :type templatevar: django.template.FilterExpression ...
Create a new MarkupPlugin class that represents the plugin type. def _create_markup_plugin(language, model): """ Create a new MarkupPlugin class that represents the plugin type. """ form = type("{0}MarkupItemForm".format(language.capitalize()), (MarkupItemForm,), { 'default_language': language,...
Return lookup arguments for the generic ``parent_type`` / ``parent_id`` fields. :param parent_object: The parent object. :type parent_object: :class:`~django.db.models.Model` def get_parent_lookup_kwargs(parent_object): """ Return lookup arguments for the generic ``parent_type`` / ``parent_id`` fields...
.. versionadded:: 1.0 Get the currently active languages of an parent object. Note: if there is no content at the page, the language won't be returned. def get_parent_active_language_choices(parent_object, exclude_current=False): """ .. versionadded:: 1.0 Get the currently active languages of an...
Return a placeholder by key. def get_by_slot(self, parent_object, slot): """ Return a placeholder by key. """ placeholder = self.parent(parent_object).get(slot=slot) placeholder.parent = parent_object # fill the reverse cache return placeholder
Create a placeholder with the given parameters def create_for_object(self, parent_object, slot, role='m', title=None): """ Create a placeholder with the given parameters """ from .db import Placeholder parent_attrs = get_parent_lookup_kwargs(parent_object) obj = self.cre...
.. versionadded:: 1.0 Only return translated objects which of the given languages. When no language codes are given, only the currently active language is returned. def translated(self, *language_codes): """ .. versionadded:: 1.0 Only return translated objects which of the gi...
Return all content items which are associated with a given parent object. def parent(self, parent_object, limit_parent_language=True): """ Return all content items which are associated with a given parent object. """ lookup = get_parent_lookup_kwargs(parent_object) # Filter the...
.. versionadded: 1.0.2 Move the entire queryset to a new object. Returns a queryset with the newly created objects. def move_to_placeholder(self, placeholder, sort_order=None): """ .. versionadded: 1.0.2 Move the entire queryset to a new object. Returns a queryset with the newly creat...
.. versionadded: 1.0 Copy the entire queryset to a new object. Returns a queryset with the newly created objects. def copy_to_placeholder(self, placeholder, sort_order=None): """ .. versionadded: 1.0 Copy the entire queryset to a new object. Returns a queryset with the newly created o...
Return all content items which are associated with a given parent object. def parent(self, parent_object, limit_parent_language=True): """ Return all content items which are associated with a given parent object. """ return self.all().parent(parent_object, limit_parent_language)
Create a Content Item with the given parameters If the language_code is not provided, the language code of the parent will be used. This may perform an additional database query, unless the :class:`~fluent_contents.models.managers.PlaceholderManager` methods were used to construct the object, ...
Return the data of the placeholder fields. def get_placeholder_data(self, request, obj=None): """ Return the data of the placeholder fields. """ # Return all placeholder fields in the model. if not hasattr(self.model, '_meta_placeholder_fields'): return [] d...
Return which plugins are allowed by the placeholder fields. def get_all_allowed_plugins(self): """ Return which plugins are allowed by the placeholder fields. """ # Get all allowed plugins of the various placeholders together. if not hasattr(self.model, '_meta_placeholder_fields...
Create a new MarkupItem model that saves itself in a single language. def _create_markup_model(fixed_language): """ Create a new MarkupItem model that saves itself in a single language. """ title = backend.LANGUAGE_NAMES.get(fixed_language) or fixed_language objects = MarkupLanguageManager(fixed_l...
Returns a :class:`PlaceholderFormField` instance for this database Field. def formfield(self, **kwargs): """ Returns a :class:`PlaceholderFormField` instance for this database Field. """ defaults = { 'label': capfirst(self.verbose_name), 'help_text': self.help_te...
Internal Django method to associate the field with the Model; it assigns the descriptor. def contribute_to_class(self, cls, name, **kwargs): """ Internal Django method to associate the field with the Model; it assigns the descriptor. """ super(PlaceholderField, self).contribute_to_class...
Get the set of plugins that this field may display. def plugins(self): """ Get the set of plugins that this field may display. """ from fluent_contents import extensions if self._plugins is None: return extensions.plugin_pool.get_plugins() else: t...
Internal Django method, used to return the placeholder ID when exporting the model instance. def value_from_object(self, obj): """ Internal Django method, used to return the placeholder ID when exporting the model instance. """ try: # not using self.attname, access the descr...
Read the cached output - only when search needs it. def can_use_cached_output(self, contentitem): """ Read the cached output - only when search needs it. """ return contentitem.plugin.search_output and not contentitem.plugin.search_fields \ and super(SearchRenderingPipe, self...
Render the item - but render as search text instead. def render_item(self, contentitem): """ Render the item - but render as search text instead. """ plugin = contentitem.plugin if not plugin.search_output and not plugin.search_fields: # Only render items when the it...
Dynamically generate genuine django inlines for all registered content item types. When the `plugins` parameter is ``None``, all plugin inlines are returned. def get_content_item_inlines(plugins=None, base=BaseContentItemInline): """ Dynamically generate genuine django inlines for all registered content it...
Get the list of OEmbed providers. def get_oembed_providers(): """ Get the list of OEmbed providers. """ global _provider_list, _provider_lock if _provider_list is not None: return _provider_list # Allow only one thread to build the list, or make request to embed.ly. _provider_lock....
Construct the provider registry, using the app settings. def _build_provider_list(): """ Construct the provider registry, using the app settings. """ registry = None if appsettings.FLUENT_OEMBED_SOURCE == 'basic': registry = bootstrap_basic() elif appsettings.FLUENT_OEMBED_SOURCE == 'em...
Fetch the OEmbed object, return the response as dictionary. def get_oembed_data(url, max_width=None, max_height=None, **params): """ Fetch the OEmbed object, return the response as dictionary. """ if max_width: params['maxwidth'] = max_width if max_height: params['maxheight'] = max_height reg...
Return all plugins, grouped by category. The structure is a {"Categorynane": [list of plugin classes]} def group_plugins_into_categories(plugins): """ Return all plugins, grouped by category. The structure is a {"Categorynane": [list of plugin classes]} """ if not plugins: return {} ...
Return a tuple of plugin model choices, suitable for a select field. Each tuple is a ("TypeName", "Title") value. def plugin_categories_to_choices(categories): """ Return a tuple of plugin model choices, suitable for a select field. Each tuple is a ("TypeName", "Title") value. """ choices = [] ...
Optimized version of django.forms.Media.__add__() that doesn't create new objects. def add_media(dest, media): """ Optimized version of django.forms.Media.__add__() that doesn't create new objects. """ if django.VERSION >= (2, 2): dest._css_lists += media._css_lists dest._js_lists += me...
Returns a Request instance populated with cms specific attributes. def get_dummy_request(language=None): """ Returns a Request instance populated with cms specific attributes. """ if settings.ALLOWED_HOSTS and settings.ALLOWED_HOSTS != "*": host = settings.ALLOWED_HOSTS[0] else: ho...