"""
The definition of the ITheme interface.
"""
#
# Copyright Qualcomm Technologies Inc, 2019.
# All Rights Reserved
#
# Thirdparty imports
from zope.interface import Interface
# Zope interface bends the rules slightly, so ignore these pylint warnings:
# pylint: disable=no-self-argument,inherit-non-class,no-method-argument
[docs]class ITheme(Interface):
"""This interface is used to abstract away how and from where theme
information is loaded.
This interface is an adapter interface, and expects to be found by
adapting an IApplicationOptions and an IPersistState
instances. This allows ITheme implementations to choose from either the
persisted state or from the command line options which theme to
use.
Typical usage to get the real implementation of an ITheme interface
will be done something like this::
from zope.component import getMultiAdapter
theme = getMultiAdapter((getUtility(IApplicationOptions),
getUtility(IPersistState)), ITheme)
"""
def get_stylesheet(area):
"""Return a string which is the theme information for a particular
area. The areas available are not defined by this
interface.
Implementation objects might, for example, implement this by
looking for a file with the area name in particular folder.
:return: A string of (usually) CSS-formatted data, or the
empty string if no data is found for the specified area.
"""
def stylesheet_location(area):
"""Return a string defining the location of a CSS file derived from
the area name. This method will be used from WebView-based
content, and therefore a path relative to the content itself
needs to be returned. The caller needs to determine whether
this file actually exists. The implementation of this object
will simply apply the rules for its theming strategy for where
its CSS files ought to be.
:return: A string to the relative path of a CSS file.
"""
def get_xml(name: str) -> str:
"""Some parts of the user interface are rendered using HTML
markup. This method fetches markup for a particlarly named
part of the user interface. This interface definition does not
enumerate what these names are.
The returned XML can contain Kajiki markup so that parts of
the XML can be replaced with context data.
:return: The XML-compliant HTML markup.
"""