Ejemplo n.º 1
0
	def __init__(self,
				ext,
				theme_config,
				common_config,
				pl,
				top_theme_config=None,
				run_once=False,
				shutdown_event=None):
		self.dividers = theme_config.get('dividers', common_config['dividers'])
		self.spaces = theme_config.get('spaces', common_config['spaces'])
		self.segments = {
			'left': [],
			'right': [],
		}
		self.EMPTY_SEGMENT = {
			'contents': None,
			'highlight': {'fg': False, 'bg': False, 'attr': 0}
		}
		self.pl = pl
		theme_configs = [theme_config]
		if top_theme_config:
			theme_configs.append(top_theme_config)
		get_segment = gen_segment_getter(pl, ext, common_config['paths'], theme_configs, theme_config.get('default_module'))
		for side in ['left', 'right']:
			for segment in theme_config['segments'].get(side, []):
				segment = get_segment(segment, side)
				if not run_once:
					if segment['startup']:
						try:
							segment['startup'](pl, shutdown_event)
						except Exception as e:
							pl.error('Exception during {0} startup: {1}', segment['name'], str(e))
							continue
				self.segments[side].append(segment)
Ejemplo n.º 2
0
	def __init__(self,
	             ext,
	             theme_config,
	             common_config,
	             pl,
	             get_module_attr,
	             top_theme,
	             colorscheme,
	             main_theme_config=None,
	             run_once=False,
	             shutdown_event=None):
		self.colorscheme = colorscheme
		self.dividers = theme_config['dividers']
		self.dividers = dict((
			(key, dict((k, u(v))
			for k, v in val.items()))
			for key, val in self.dividers.items()
		))
		try:
			self.cursor_space_multiplier = 1 - (theme_config['cursor_space'] / 100)
		except KeyError:
			self.cursor_space_multiplier = None
		self.cursor_columns = theme_config.get('cursor_columns')
		self.spaces = theme_config['spaces']
		self.outer_padding = int(theme_config.get('outer_padding', 1))
		self.segments = []
		self.EMPTY_SEGMENT = {
			'contents': None,
			'highlight': {'fg': False, 'bg': False, 'attrs': 0}
		}
		self.pl = pl
		theme_configs = [theme_config]
		if main_theme_config:
			theme_configs.append(main_theme_config)
		get_segment = gen_segment_getter(
			pl,
			ext,
			common_config,
			theme_configs,
			theme_config.get('default_module'),
			get_module_attr,
			top_theme
		)
		for segdict in itertools.chain((theme_config['segments'],),
		                               theme_config['segments'].get('above', ())):
			self.segments.append(new_empty_segment_line())
			for side in ['left', 'right']:
				for segment in segdict.get(side, []):
					segment = get_segment(segment, side)
					if segment:
						if not run_once:
							if segment['startup']:
								try:
									segment['startup'](pl, shutdown_event)
								except Exception as e:
									pl.error('Exception during {0} startup: {1}', segment['name'], str(e))
									continue
						self.segments[-1][side].append(segment)
Ejemplo n.º 3
0
	def __init__(self,
	             ext,
	             theme_config,
	             common_config,
	             pl,
	             get_module_attr,
	             top_theme,
	             colorscheme,
	             main_theme_config=None,
	             run_once=False,
	             shutdown_event=None):
		self.colorscheme = colorscheme
		self.dividers = theme_config['dividers']
		self.dividers = dict((
			(key, dict((k, u(v))
			for k, v in val.items()))
			for key, val in self.dividers.items()
		))
		try:
			self.cursor_space_multiplier = 1 - (theme_config['cursor_space'] / 100)
		except KeyError:
			self.cursor_space_multiplier = None
		self.cursor_columns = theme_config.get('cursor_columns')
		self.spaces = theme_config['spaces']
		self.segments = []
		self.EMPTY_SEGMENT = {
			'contents': None,
			'highlight': {'fg': False, 'bg': False, 'attr': 0}
		}
		self.pl = pl
		theme_configs = [theme_config]
		if main_theme_config:
			theme_configs.append(main_theme_config)
		get_segment = gen_segment_getter(
			pl,
			ext,
			common_config,
			theme_configs,
			theme_config.get('default_module'),
			get_module_attr,
			top_theme
		)
		for segdict in itertools.chain((theme_config['segments'],),
		                               theme_config['segments'].get('above', ())):
			self.segments.append(new_empty_segment_line())
			for side in ['left', 'right']:
				for segment in segdict.get(side, []):
					segment = get_segment(segment, side)
					if segment:
						if not run_once:
							if segment['startup']:
								try:
									segment['startup'](pl, shutdown_event)
								except Exception as e:
									pl.error('Exception during {0} startup: {1}', segment['name'], str(e))
									continue
						self.segments[-1][side].append(segment)
Ejemplo n.º 4
0
 def __init__(self,
              ext,
              theme_config,
              common_config,
              pl,
              top_theme_config=None,
              run_once=False,
              shutdown_event=None):
     self.dividers = theme_config.get('dividers', common_config['dividers'])
     self.spaces = theme_config.get('spaces', common_config['spaces'])
     self.segments = {
         'left': [],
         'right': [],
     }
     self.EMPTY_SEGMENT = {
         'contents': None,
         'highlight': {
             'fg': False,
             'bg': False,
             'attr': 0
         }
     }
     self.pl = pl
     theme_configs = [theme_config]
     if top_theme_config:
         theme_configs.append(top_theme_config)
     get_segment = gen_segment_getter(pl, ext, common_config['paths'],
                                      theme_configs,
                                      theme_config.get('default_module'))
     for side in ['left', 'right']:
         for segment in theme_config['segments'].get(side, []):
             segment = get_segment(segment, side)
             if not run_once:
                 if segment['startup']:
                     try:
                         segment['startup'](pl, shutdown_event)
                     except Exception as e:
                         pl.error('Exception during {0} startup: {1}',
                                  segment['name'], str(e))
                         continue
             self.segments[side].append(segment)