According to the `sys.path` documentation “As initialized upon program startup,
the first item of this list, path[0], is the directory containing the script
that was used to invoke the Python interpreter.” Since client is named
`powerline.py` it tries to use the client itself as powerline module and
obviously fails to import `lib` submodule.
Now imports follow the following structure:
1. __future__ line: exactly one line allowed:
from __future__ import (unicode_literals, division, absolute_import, print_function)
(powerline.shell is the only exception due to problems with argparse).
2. Standard python library imports in a form `import X`.
3. Standard python library imports in a form `from X import Y`.
4. and 5. 2. and 3. for third-party (non-python and non-powerline imports).
6. 3. for powerline non-test imports.
7. and 8. 2. and 3. for powerline testing module imports.
Each list entry is separated by exactly one newline from another import. If
there is module docstring it goes between `# vim:` comment and `__future__`
import. So the structure containing all items is the following:
#!/usr/bin/env python
# vim:fileencoding=utf-8:noet
'''Powerline super module'''
import sys
from argparse import ArgumentParser
import psutil
from colormath.color_diff import delta_e_cie2000
from powerline.lib.unicode import u
import tests.vim as vim_module
from tests import TestCase
.
Assuming ascii was expected to be used when LANG=C it did not work in any case:
in this case preferred encoding is “ANSI_X3.4-1968”. Same for
`sys.getfilesystemencoding()`.
It took 2/3 of do_render call according to profiler. New variant takes only 1/6.
WARNING: This commit will break all powerline installations with running daemon
because it changes communication protocol. You must kill and restart all your
powerline daemons for powerline to function properly.
Highlight @kovidgoyal
Note: this shell script is still faster then client/powerline.py. `time` reports
0.00, 0.01, 0.02÷0.03 for powerline, powerline.sh and powerline.py
respectively (run with `./client/powerline* tmux right`).
Note: does not work in busybox as env there does not support -0 argument.
Requires sed, id (for dash as $UID is not available there), env, printf
and socat. Is not currently handled by setup.py.
Minor changes have been applied:
- Removed copyright info and GPL 3 license since Powerline is MIT (needs
confirmation from kovidgoyal before merge)
- The `powerline-client` script is renamed to `powerline`, and calls the
daemon or `powerline-render` (the previous `powerline`) to render
a statusline
- Minor coding style corrections to match the rest of the project
- Python 3 support is removed for now due to setuptools failing with
binary scripts
Todo:
- Automatically attempt to launch powerline-daemon the first time
powerline is run if the daemon isn't already running?
- pip install -e fails with binary files (it appears that pip recodes
the powerline binary to ASCII, the compiled powerline script must be
copied manually to ~/.local/bin after pip install -e has been run)