mirror of
https://github.com/powerline/powerline.git
synced 2025-07-29 16:55:07 +02:00
parent
1557ff2c03
commit
78e54e0c84
@ -133,6 +133,11 @@ Themes
|
|||||||
``name``
|
``name``
|
||||||
Name of the theme.
|
Name of the theme.
|
||||||
|
|
||||||
|
``default_module``
|
||||||
|
.. _config-themes-default_module:
|
||||||
|
|
||||||
|
Python module where segments will be looked by default.
|
||||||
|
|
||||||
``segments``
|
``segments``
|
||||||
A dict with a ``left`` and a ``right`` list, consisting of segment
|
A dict with a ``left`` and a ``right`` list, consisting of segment
|
||||||
dicts. Each segment has the following options:
|
dicts. Each segment has the following options:
|
||||||
@ -161,7 +166,8 @@ Themes
|
|||||||
.. _config-themes-seg-module:
|
.. _config-themes-seg-module:
|
||||||
|
|
||||||
Function module, only required for function segments. Defaults to
|
Function module, only required for function segments. Defaults to
|
||||||
``core``.
|
``powerline.ext.{extension}.segments``. Default is overriden by
|
||||||
|
:ref:`theme option <config-themes-default_module>`.
|
||||||
|
|
||||||
``name``
|
``name``
|
||||||
.. _config-themes-seg-name:
|
.. _config-themes-seg-name:
|
||||||
|
@ -30,7 +30,7 @@ class Powerline(object):
|
|||||||
# Load and initialize extension theme
|
# Load and initialize extension theme
|
||||||
theme_config = self._load_theme_config(ext, self.config_ext.get('theme', 'default'))
|
theme_config = self._load_theme_config(ext, self.config_ext.get('theme', 'default'))
|
||||||
path = [os.path.expanduser(path) for path in self.config.get('paths', [])]
|
path = [os.path.expanduser(path) for path in self.config.get('paths', [])]
|
||||||
get_segment = Segments(ext, path, colorscheme).get
|
get_segment = Segments(ext, path, colorscheme, theme_config.get('default_module')).get
|
||||||
self.get_matcher = Matchers(ext, path).get
|
self.get_matcher = Matchers(ext, path).get
|
||||||
theme_kwargs = {
|
theme_kwargs = {
|
||||||
'ext': ext,
|
'ext': ext,
|
||||||
|
@ -5,15 +5,15 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
class Segments(object):
|
class Segments(object):
|
||||||
def __init__(self, ext, path, colorscheme):
|
def __init__(self, ext, path, colorscheme, default_module=None):
|
||||||
self.ext = ext
|
self.default_module = default_module or 'powerline.ext.{0}.segments'.format(ext)
|
||||||
self.path = path
|
self.path = path
|
||||||
self.colorscheme = colorscheme
|
self.colorscheme = colorscheme
|
||||||
|
|
||||||
def get_function(self, segment):
|
def get_function(self, segment):
|
||||||
oldpath = sys.path
|
oldpath = sys.path
|
||||||
sys.path = self.path + sys.path
|
sys.path = self.path + sys.path
|
||||||
segment_module = str(segment.get('module', 'powerline.ext.{0}.segments'.format(self.ext)))
|
segment_module = str(segment.get('module', self.default_module))
|
||||||
try:
|
try:
|
||||||
return None, getattr(import_module(segment_module), segment['name']), '{0}.{1}'.format(segment_module, segment['name'])
|
return None, getattr(import_module(segment_module), segment['name']), '{0}.{1}'.format(segment_module, segment['name'])
|
||||||
finally:
|
finally:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user