/usr/lib/python2.7/dist-packages/powerline/ipython.py is in python-powerline 2.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from powerline import Powerline
from powerline.lib.dict import mergedicts
from powerline.lib.unicode import string
class IPythonInfo(object):
def __init__(self, shell):
self._shell = shell
@property
def prompt_count(self):
return self._shell.execution_count
# HACK: ipython tries to only leave us with plain ASCII
class RewriteResult(object):
def __init__(self, prompt):
self.prompt = string(prompt)
def __str__(self):
return self.prompt
def __add__(self, s):
if type(s) is not str:
try:
s = s.encode('utf-8')
except AttributeError:
raise NotImplementedError
return RewriteResult(self.prompt + s)
class IPythonPowerline(Powerline):
def init(self, **kwargs):
super(IPythonPowerline, self).init(
'ipython',
use_daemon_threads=True,
**kwargs
)
def get_config_paths(self):
if self.config_paths:
return self.config_paths
else:
return super(IPythonPowerline, self).get_config_paths()
def get_local_themes(self, local_themes):
return dict(((type, {'config': self.load_theme_config(name)}) for type, name in local_themes.items()))
def load_main_config(self):
r = super(IPythonPowerline, self).load_main_config()
if self.config_overrides:
mergedicts(r, self.config_overrides)
return r
def load_theme_config(self, name):
r = super(IPythonPowerline, self).load_theme_config(name)
if name in self.theme_overrides:
mergedicts(r, self.theme_overrides[name])
return r
def do_setup(self, wrefs):
for wref in wrefs:
obj = wref()
if obj is not None:
setattr(obj, 'powerline', self)
|