mirror of
https://github.com/powerline/powerline.git
synced 2025-07-27 07:44:36 +02:00
Get rid of double quotes where possible
This commits replaces them either with Unicode quotes (“”) or single equivalents.
This commit is contained in:
parent
77b0695caf
commit
ca83c461d9
@ -33,7 +33,7 @@ def read_to_log(pl, client):
|
|||||||
while True:
|
while True:
|
||||||
start_time = monotonic()
|
start_time = monotonic()
|
||||||
s = powerline.render(side='right')
|
s = powerline.render(side='right')
|
||||||
request = "powerline_widget:set_markup('" + s.replace('\\', '\\\\').replace("'", "\\'") + "')\n"
|
request = 'powerline_widget:set_markup(\'' + s.replace('\\', '\\\\').replace('\'', '\\\'') + '\')\n'
|
||||||
client = Popen(['awesome-client'], shell=False, stdout=PIPE, stderr=PIPE, stdin=PIPE)
|
client = Popen(['awesome-client'], shell=False, stdout=PIPE, stderr=PIPE, stdin=PIPE)
|
||||||
client.stdin.write(request.encode('utf-8'))
|
client.stdin.write(request.encode('utf-8'))
|
||||||
client.stdin.close()
|
client.stdin.close()
|
||||||
|
@ -31,7 +31,7 @@ _powerline_init_tmux_support() {
|
|||||||
# TMUX variable may be unset to create new tmux session inside this one
|
# TMUX variable may be unset to create new tmux session inside this one
|
||||||
_POWERLINE_TMUX="$TMUX"
|
_POWERLINE_TMUX="$TMUX"
|
||||||
|
|
||||||
trap "_powerline_tmux_set_columns" WINCH
|
trap '_powerline_tmux_set_columns' WINCH
|
||||||
_powerline_tmux_set_columns
|
_powerline_tmux_set_columns
|
||||||
|
|
||||||
test "x$PROMPT_COMMAND" != "x${PROMPT_COMMAND/_powerline_tmux_set_pwd}" ||
|
test "x$PROMPT_COMMAND" != "x${PROMPT_COMMAND/_powerline_tmux_set_pwd}" ||
|
||||||
|
@ -8,7 +8,7 @@ from powerline import Powerline as PowerlineCore
|
|||||||
|
|
||||||
|
|
||||||
class Powerline(base._TextBox):
|
class Powerline(base._TextBox):
|
||||||
def __init__(self, timeout=2, text=" ", width=bar.CALCULATED, **config):
|
def __init__(self, timeout=2, text=' ', width=bar.CALCULATED, **config):
|
||||||
base._TextBox.__init__(self, text, width, **config)
|
base._TextBox.__init__(self, text, width, **config)
|
||||||
self.timeout_add(timeout, self.update)
|
self.timeout_add(timeout, self.update)
|
||||||
self.powerline = PowerlineCore(ext='wm', renderer_module='pango_markup')
|
self.powerline = PowerlineCore(ext='wm', renderer_module='pango_markup')
|
||||||
|
@ -61,24 +61,24 @@ function s:rcmd(s)
|
|||||||
endfunction
|
endfunction
|
||||||
try
|
try
|
||||||
let s:can_replace_pyeval = !exists('g:powerline_pyeval')
|
let s:can_replace_pyeval = !exists('g:powerline_pyeval')
|
||||||
call s:rcmd("try:")
|
call s:rcmd('try:')
|
||||||
call s:rcmd(" powerline_appended_path = None")
|
call s:rcmd(' powerline_appended_path = None')
|
||||||
call s:rcmd(" try:")
|
call s:rcmd(' try:')
|
||||||
call s:rcmd(" ".s:import_cmd."")
|
call s:rcmd(' '.s:import_cmd.'')
|
||||||
call s:rcmd(" except ImportError:")
|
call s:rcmd(' except ImportError:')
|
||||||
call s:rcmd(" import sys, vim")
|
call s:rcmd(' import sys, vim')
|
||||||
call s:rcmd(" powerline_appended_path = vim.eval('expand(\"<sfile>:h:h:h:h:h\")')")
|
call s:rcmd(' powerline_appended_path = vim.eval("expand(\"<sfile>:h:h:h:h:h\")")')
|
||||||
call s:rcmd(" sys.path.append(powerline_appended_path)")
|
call s:rcmd(' sys.path.append(powerline_appended_path)')
|
||||||
call s:rcmd(" ".s:import_cmd."")
|
call s:rcmd(' '.s:import_cmd.'')
|
||||||
call s:rcmd(" import vim")
|
call s:rcmd(' import vim')
|
||||||
call s:rcmd(" powerline_instance = VimPowerline()")
|
call s:rcmd(' powerline_instance = VimPowerline()')
|
||||||
call s:rcmd(" powerline_instance.setup(pyeval=vim.eval('s:pyeval'), pycmd=vim.eval('s:pycmd'), can_replace_pyeval=int(vim.eval('s:can_replace_pyeval')))")
|
call s:rcmd(' powerline_instance.setup(pyeval=vim.eval("s:pyeval"), pycmd=vim.eval("s:pycmd"), can_replace_pyeval=int(vim.eval("s:can_replace_pyeval")))')
|
||||||
call s:rcmd(" del VimPowerline")
|
call s:rcmd(' del VimPowerline')
|
||||||
call s:rcmd(" del powerline_instance")
|
call s:rcmd(' del powerline_instance')
|
||||||
call s:rcmd("except Exception:")
|
call s:rcmd('except Exception:')
|
||||||
call s:rcmd(" import traceback, sys")
|
call s:rcmd(' import traceback, sys')
|
||||||
call s:rcmd(" traceback.print_exc(file=sys.stdout)")
|
call s:rcmd(' traceback.print_exc(file=sys.stdout)')
|
||||||
call s:rcmd(" raise")
|
call s:rcmd(' raise')
|
||||||
execute s:pycmd s:pystr
|
execute s:pycmd s:pystr
|
||||||
unlet s:pystr
|
unlet s:pystr
|
||||||
let s:launched = 1
|
let s:launched = 1
|
||||||
@ -99,61 +99,61 @@ finally
|
|||||||
echomsg 'should set g:powerline_pycmd to "py3" to make it load correctly.'
|
echomsg 'should set g:powerline_pycmd to "py3" to make it load correctly.'
|
||||||
endif
|
endif
|
||||||
echohl None
|
echohl None
|
||||||
call s:rcmd("def powerline_troubleshoot():")
|
call s:rcmd('def powerline_troubleshoot():')
|
||||||
call s:rcmd(" import sys")
|
call s:rcmd(' import sys')
|
||||||
call s:rcmd(" import vim")
|
call s:rcmd(' import vim')
|
||||||
call s:rcmd(" if sys.version_info < (2, 6):")
|
call s:rcmd(' if sys.version_info < (2, 6):')
|
||||||
call s:rcmd(" print('Too old python version: ' + sys.version + ' (first supported is 2.6)')")
|
call s:rcmd(' print("Too old python version: " + sys.version + " (first supported is 2.6)")')
|
||||||
call s:rcmd(" elif sys.version_info[0] == 3 and sys.version_info[1] < 2:")
|
call s:rcmd(' elif sys.version_info[0] == 3 and sys.version_info[1] < 2:')
|
||||||
call s:rcmd(" print('Too old python 3 version: ' + sys.version + ' (first supported is 3.2)')")
|
call s:rcmd(' print("Too old python 3 version: " + sys.version + " (first supported is 3.2)")')
|
||||||
call s:rcmd(" try:")
|
call s:rcmd(' try:')
|
||||||
call s:rcmd(" import powerline")
|
call s:rcmd(' import powerline')
|
||||||
call s:rcmd(" except ImportError:")
|
call s:rcmd(' except ImportError:')
|
||||||
call s:rcmd(" print('Unable to import powerline, is it installed?')")
|
call s:rcmd(' print("Unable to import powerline, is it installed?")')
|
||||||
call s:rcmd(" else:")
|
call s:rcmd(' else:')
|
||||||
call s:rcmd(" if not vim.eval('expand(\"<sfile>\")').startswith('/usr/'):")
|
call s:rcmd(' if not vim.eval(''expand("<sfile>")'').startswith("/usr/"):')
|
||||||
call s:rcmd(" import os")
|
call s:rcmd(' import os')
|
||||||
call s:rcmd(" powerline_dir = os.path.realpath(os.path.normpath(powerline.__file__))")
|
call s:rcmd(' powerline_dir = os.path.realpath(os.path.normpath(powerline.__file__))')
|
||||||
call s:rcmd(" powerline_dir = os.path.dirname(powerline.__file__)")
|
call s:rcmd(' powerline_dir = os.path.dirname(powerline.__file__)')
|
||||||
call s:rcmd(" this_dir = os.path.realpath(os.path.normpath(vim.eval('expand(\"<sfile>:p\")')))")
|
call s:rcmd(' this_dir = os.path.realpath(os.path.normpath(vim.eval(''expand("<sfile>:p")'')))')
|
||||||
call s:rcmd(" this_dir = os.path.dirname(this_dir)") " powerline/bindings/vim/plugin
|
call s:rcmd(' this_dir = os.path.dirname(this_dir)') " powerline/bindings/vim/plugin
|
||||||
call s:rcmd(" this_dir = os.path.dirname(this_dir)") " powerline/bindings/vim
|
call s:rcmd(' this_dir = os.path.dirname(this_dir)') " powerline/bindings/vim
|
||||||
call s:rcmd(" this_dir = os.path.dirname(this_dir)") " powerline/bindings
|
call s:rcmd(' this_dir = os.path.dirname(this_dir)') " powerline/bindings
|
||||||
call s:rcmd(" this_dir = os.path.dirname(this_dir)") " powerline
|
call s:rcmd(' this_dir = os.path.dirname(this_dir)') " powerline
|
||||||
call s:rcmd(" if os.path.basename(this_dir) != 'powerline':")
|
call s:rcmd(' if os.path.basename(this_dir) != "powerline":')
|
||||||
call s:rcmd(" print('Check your installation:')")
|
call s:rcmd(' print("Check your installation:")')
|
||||||
call s:rcmd(" print('this script is not in powerline[/bindings/vim/plugin] directory,')")
|
call s:rcmd(' print("this script is not in powerline[/bindings/vim/plugin] directory,")')
|
||||||
call s:rcmd(" print('neither it is installed system-wide')")
|
call s:rcmd(' print("neither it is installed system-wide")')
|
||||||
call s:rcmd(" real_powerline_dir = os.path.realpath(powerline_dir)")
|
call s:rcmd(' real_powerline_dir = os.path.realpath(powerline_dir)')
|
||||||
call s:rcmd(" real_this_dir = os.path.realpath(this_dir)")
|
call s:rcmd(' real_this_dir = os.path.realpath(this_dir)')
|
||||||
call s:rcmd(" this_dir_par = os.path.dirname(real_this_dir)")
|
call s:rcmd(' this_dir_par = os.path.dirname(real_this_dir)')
|
||||||
call s:rcmd(" powerline_appended_path = globals().get('powerline_appended_path')")
|
call s:rcmd(' powerline_appended_path = globals().get("powerline_appended_path")')
|
||||||
call s:rcmd(" if powerline_appended_path is not None and this_dir_par != powerline_appended_path:")
|
call s:rcmd(' if powerline_appended_path is not None and this_dir_par != powerline_appended_path:')
|
||||||
call s:rcmd(" print('Check your installation: this script is symlinked somewhere')")
|
call s:rcmd(' print("Check your installation: this script is symlinked somewhere")')
|
||||||
call s:rcmd(" print('where powerline is not present: {0!r} != {1!r}.'.format(")
|
call s:rcmd(' print("where powerline is not present: {0!r} != {1!r}.".format(')
|
||||||
call s:rcmd(" real_this_dir, powerline_appended_path))")
|
call s:rcmd(' real_this_dir, powerline_appended_path))')
|
||||||
call s:rcmd(" elif real_powerline_dir != real_this_dir:")
|
call s:rcmd(' elif real_powerline_dir != real_this_dir:')
|
||||||
call s:rcmd(" print('It appears that you have two powerline versions installed:')")
|
call s:rcmd(' print("It appears that you have two powerline versions installed:")')
|
||||||
call s:rcmd(" print('one in ' + real_powerline_dir + ', other in ' + real_this_dir + '.')")
|
call s:rcmd(' print("one in " + real_powerline_dir + ", other in " + real_this_dir + ".")')
|
||||||
call s:rcmd(" print('You should remove one of this. Check out troubleshooting section,')")
|
call s:rcmd(' print("You should remove one of this. Check out troubleshooting section,")')
|
||||||
call s:rcmd(" print('it contains some information about the alternatives.')")
|
call s:rcmd(' print("it contains some information about the alternatives.")')
|
||||||
call s:rcmd(" try:")
|
call s:rcmd(' try:')
|
||||||
call s:rcmd(" from powerline.lint import check")
|
call s:rcmd(' from powerline.lint import check')
|
||||||
call s:rcmd(" except ImportError:")
|
call s:rcmd(' except ImportError:')
|
||||||
call s:rcmd(" print('Failed to import powerline.lint.check, cannot run powerline-lint')")
|
call s:rcmd(' print("Failed to import powerline.lint.check, cannot run powerline-lint")')
|
||||||
call s:rcmd(" else:")
|
call s:rcmd(' else:')
|
||||||
call s:rcmd(" try:")
|
call s:rcmd(' try:')
|
||||||
call s:rcmd(" paths = powerline_instance.get_config_paths()")
|
call s:rcmd(' paths = powerline_instance.get_config_paths()')
|
||||||
call s:rcmd(" except NameError:")
|
call s:rcmd(' except NameError:')
|
||||||
call s:rcmd(" pass")
|
call s:rcmd(' pass')
|
||||||
call s:rcmd(" else:")
|
call s:rcmd(' else:')
|
||||||
call s:rcmd(" from powerline.lint.markedjson.error import echoerr")
|
call s:rcmd(' from powerline.lint.markedjson.error import echoerr')
|
||||||
call s:rcmd(" ee = lambda *args, **kwargs: echoerr(*args, stream=sys.stdout, **kwargs)")
|
call s:rcmd(' ee = lambda *args, **kwargs: echoerr(*args, stream=sys.stdout, **kwargs)')
|
||||||
call s:rcmd(" check(paths=paths, echoerr=ee, require_ext='vim')")
|
call s:rcmd(' check(paths=paths, echoerr=ee, require_ext="vim")')
|
||||||
call s:rcmd("try:")
|
call s:rcmd('try:')
|
||||||
call s:rcmd(" powerline_troubleshoot()")
|
call s:rcmd(' powerline_troubleshoot()')
|
||||||
call s:rcmd("finally:")
|
call s:rcmd('finally:')
|
||||||
call s:rcmd(" del powerline_troubleshoot")
|
call s:rcmd(' del powerline_troubleshoot')
|
||||||
execute s:pycmd s:pystr
|
execute s:pycmd s:pystr
|
||||||
unlet s:pystr
|
unlet s:pystr
|
||||||
unlet s:pycmd
|
unlet s:pycmd
|
||||||
|
@ -36,7 +36,7 @@ _powerline_init_tmux_support() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
chpwd_functions+=( _powerline_tmux_set_pwd )
|
chpwd_functions+=( _powerline_tmux_set_pwd )
|
||||||
trap "_powerline_tmux_set_columns" SIGWINCH
|
trap '_powerline_tmux_set_columns' SIGWINCH
|
||||||
_powerline_tmux_set_columns
|
_powerline_tmux_set_columns
|
||||||
_powerline_tmux_set_pwd
|
_powerline_tmux_set_pwd
|
||||||
fi
|
fi
|
||||||
@ -111,7 +111,7 @@ _powerline_setup_prompt() {
|
|||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
|
|
||||||
for f in "${precmd_functions[@]}"; do
|
for f in "${precmd_functions[@]}"; do
|
||||||
if [[ "$f" = "_powerline_set_jobnum" ]]; then
|
if [[ "$f" = '_powerline_set_jobnum' ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -24,25 +24,25 @@ def print_cycles(objects, outstream=sys.stdout, show_progress=False):
|
|||||||
'''
|
'''
|
||||||
def print_path(path):
|
def print_path(path):
|
||||||
for i, step in enumerate(path):
|
for i, step in enumerate(path):
|
||||||
# next "wraps around"
|
# next “wraps around”
|
||||||
next = path[(i + 1) % len(path)]
|
next = path[(i + 1) % len(path)]
|
||||||
|
|
||||||
outstream.write(" %s -- " % str(type(step)))
|
outstream.write(' %s -- ' % str(type(step)))
|
||||||
written = False
|
written = False
|
||||||
if isinstance(step, dict):
|
if isinstance(step, dict):
|
||||||
for key, val in step.items():
|
for key, val in step.items():
|
||||||
if val is next:
|
if val is next:
|
||||||
outstream.write("[%s]" % repr(key))
|
outstream.write('[%s]' % repr(key))
|
||||||
written = True
|
written = True
|
||||||
break
|
break
|
||||||
if key is next:
|
if key is next:
|
||||||
outstream.write("[key] = %s" % repr(val))
|
outstream.write('[key] = %s' % repr(val))
|
||||||
written = True
|
written = True
|
||||||
break
|
break
|
||||||
elif isinstance(step, (list, tuple)):
|
elif isinstance(step, (list, tuple)):
|
||||||
for i, item in enumerate(step):
|
for i, item in enumerate(step):
|
||||||
if item is next:
|
if item is next:
|
||||||
outstream.write("[%d]" % i)
|
outstream.write('[%d]' % i)
|
||||||
written = True
|
written = True
|
||||||
elif getattr(type(step), '__getattribute__', None) in (object.__getattribute__, type.__getattribute__):
|
elif getattr(type(step), '__getattribute__', None) in (object.__getattribute__, type.__getattribute__):
|
||||||
for attr in chain(dir(step), getattr(step, '__dict__', ())):
|
for attr in chain(dir(step), getattr(step, '__dict__', ())):
|
||||||
@ -55,12 +55,12 @@ def print_cycles(objects, outstream=sys.stdout, show_progress=False):
|
|||||||
break
|
break
|
||||||
if not written:
|
if not written:
|
||||||
outstream.write(repr(step))
|
outstream.write(repr(step))
|
||||||
outstream.write(" ->\n")
|
outstream.write(' ->\n')
|
||||||
outstream.write("\n")
|
outstream.write('\n')
|
||||||
|
|
||||||
def recurse(obj, start, all, current_path):
|
def recurse(obj, start, all, current_path):
|
||||||
if show_progress:
|
if show_progress:
|
||||||
outstream.write("%d\r" % len(all))
|
outstream.write('%d\r' % len(all))
|
||||||
|
|
||||||
all[id(obj)] = None
|
all[id(obj)] = None
|
||||||
|
|
||||||
|
@ -41,27 +41,27 @@ def load_inotify():
|
|||||||
if not name:
|
if not name:
|
||||||
raise INotifyError('Cannot find C library')
|
raise INotifyError('Cannot find C library')
|
||||||
libc = ctypes.CDLL(name, use_errno=True)
|
libc = ctypes.CDLL(name, use_errno=True)
|
||||||
for function in ("inotify_add_watch", "inotify_init1", "inotify_rm_watch"):
|
for function in ('inotify_add_watch', 'inotify_init1', 'inotify_rm_watch'):
|
||||||
if not hasattr(libc, function):
|
if not hasattr(libc, function):
|
||||||
raise INotifyError('libc is too old')
|
raise INotifyError('libc is too old')
|
||||||
# inotify_init1()
|
# inotify_init1()
|
||||||
prototype = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, use_errno=True)
|
prototype = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, use_errno=True)
|
||||||
init1 = prototype(('inotify_init1', libc), ((1, "flags", 0),))
|
init1 = prototype(('inotify_init1', libc), ((1, 'flags', 0),))
|
||||||
|
|
||||||
# inotify_add_watch()
|
# inotify_add_watch()
|
||||||
prototype = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_char_p, ctypes.c_uint32, use_errno=True)
|
prototype = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_char_p, ctypes.c_uint32, use_errno=True)
|
||||||
add_watch = prototype(('inotify_add_watch', libc), (
|
add_watch = prototype(('inotify_add_watch', libc), (
|
||||||
(1, "fd"), (1, "pathname"), (1, "mask")))
|
(1, 'fd'), (1, 'pathname'), (1, 'mask')))
|
||||||
|
|
||||||
# inotify_rm_watch()
|
# inotify_rm_watch()
|
||||||
prototype = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_int, use_errno=True)
|
prototype = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_int, ctypes.c_int, use_errno=True)
|
||||||
rm_watch = prototype(('inotify_rm_watch', libc), (
|
rm_watch = prototype(('inotify_rm_watch', libc), (
|
||||||
(1, "fd"), (1, "wd")))
|
(1, 'fd'), (1, 'wd')))
|
||||||
|
|
||||||
# read()
|
# read()
|
||||||
prototype = ctypes.CFUNCTYPE(ctypes.c_ssize_t, ctypes.c_int, ctypes.c_void_p, ctypes.c_size_t, use_errno=True)
|
prototype = ctypes.CFUNCTYPE(ctypes.c_ssize_t, ctypes.c_int, ctypes.c_void_p, ctypes.c_size_t, use_errno=True)
|
||||||
read = prototype(('read', libc), (
|
read = prototype(('read', libc), (
|
||||||
(1, "fd"), (1, "buf"), (1, "count")))
|
(1, 'fd'), (1, 'buf'), (1, 'count')))
|
||||||
_inotify = (init1, add_watch, rm_watch, read)
|
_inotify = (init1, add_watch, rm_watch, read)
|
||||||
return _inotify
|
return _inotify
|
||||||
|
|
||||||
|
@ -66,15 +66,14 @@ except ImportError:
|
|||||||
# shutil.which was added in python-3.3. Here is what was added:
|
# shutil.which was added in python-3.3. Here is what was added:
|
||||||
# Lib/shutil.py, commit 5abe28a9c8fe701ba19b1db5190863384e96c798
|
# Lib/shutil.py, commit 5abe28a9c8fe701ba19b1db5190863384e96c798
|
||||||
def which(cmd, mode=os.F_OK | os.X_OK, path=None):
|
def which(cmd, mode=os.F_OK | os.X_OK, path=None):
|
||||||
"""Given a command, mode, and a PATH string, return the path which
|
'''Given a command, mode, and a PATH string, return the path which
|
||||||
conforms to the given mode on the PATH, or None if there is no such
|
conforms to the given mode on the PATH, or None if there is no such
|
||||||
file.
|
file.
|
||||||
|
|
||||||
`mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
|
``mode`` defaults to os.F_OK | os.X_OK. ``path`` defaults to the result
|
||||||
of os.environ.get("PATH"), or can be overridden with a custom search
|
of ``os.environ.get('PATH')``, or can be overridden with a custom search
|
||||||
path.
|
path.
|
||||||
|
'''
|
||||||
"""
|
|
||||||
# Check that a given file can be accessed with the correct mode.
|
# Check that a given file can be accessed with the correct mode.
|
||||||
# Additionally check that `file` is not a directory, as on Windows
|
# Additionally check that `file` is not a directory, as on Windows
|
||||||
# directories pass the os.access check.
|
# directories pass the os.access check.
|
||||||
@ -94,20 +93,20 @@ except ImportError:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if path is None:
|
if path is None:
|
||||||
path = os.environ.get("PATH", os.defpath)
|
path = os.environ.get('PATH', os.defpath)
|
||||||
if not path:
|
if not path:
|
||||||
return None
|
return None
|
||||||
path = path.split(os.pathsep)
|
path = path.split(os.pathsep)
|
||||||
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == 'win32':
|
||||||
# The current directory takes precedence on Windows.
|
# The current directory takes precedence on Windows.
|
||||||
if os.curdir not in path:
|
if os.curdir not in path:
|
||||||
path.insert(0, os.curdir)
|
path.insert(0, os.curdir)
|
||||||
|
|
||||||
# PATHEXT is necessary to check on Windows.
|
# PATHEXT is necessary to check on Windows.
|
||||||
pathext = os.environ.get("PATHEXT", "").split(os.pathsep)
|
pathext = os.environ.get('PATHEXT', '').split(os.pathsep)
|
||||||
# See if the given file matches any of the expected path extensions.
|
# See if the given file matches any of the expected path extensions.
|
||||||
# This will allow us to short circuit when given "python.exe".
|
# This will allow us to short circuit when given 'python.exe'.
|
||||||
# If it does match, only test that one, otherwise we have to try
|
# If it does match, only test that one, otherwise we have to try
|
||||||
# others.
|
# others.
|
||||||
if any(cmd.lower().endswith(ext.lower()) for ext in pathext):
|
if any(cmd.lower().endswith(ext.lower()) for ext in pathext):
|
||||||
|
@ -252,7 +252,7 @@ def debug():
|
|||||||
'''Test run guess(), repo.branch() and repo.status()
|
'''Test run guess(), repo.branch() and repo.status()
|
||||||
|
|
||||||
To use::
|
To use::
|
||||||
python -c "from powerline.lib.vcs import debug; debug()" some_file_to_watch.
|
python -c 'from powerline.lib.vcs import debug; debug()' some_file_to_watch.
|
||||||
'''
|
'''
|
||||||
import sys
|
import sys
|
||||||
dest = sys.argv[-1]
|
dest = sys.argv[-1]
|
||||||
|
@ -50,8 +50,8 @@ class Repository(object):
|
|||||||
|
|
||||||
Without file argument: returns status of the repository:
|
Without file argument: returns status of the repository:
|
||||||
|
|
||||||
:"D?": dirty (tracked modified files: added, removed, deleted, modified),
|
:'D?': dirty (tracked modified files: added, removed, deleted, modified),
|
||||||
:"?U": untracked-dirty (added, but not tracked files)
|
:'?U': untracked-dirty (added, but not tracked files)
|
||||||
:None: clean (status is empty)
|
:None: clean (status is empty)
|
||||||
|
|
||||||
With file argument: returns status of this file: The status codes are
|
With file argument: returns status of this file: The status codes are
|
||||||
|
@ -64,7 +64,7 @@ class GitRepository(object):
|
|||||||
:None: repository clean
|
:None: repository clean
|
||||||
|
|
||||||
With file argument: returns status of this file. Output is
|
With file argument: returns status of this file. Output is
|
||||||
equivalent to the first two columns of "git status --porcelain"
|
equivalent to the first two columns of ``git status --porcelain``
|
||||||
(except for merge statuses as they are not supported by libgit2).
|
(except for merge statuses as they are not supported by libgit2).
|
||||||
'''
|
'''
|
||||||
if path:
|
if path:
|
||||||
|
@ -41,13 +41,13 @@ class Repository(object):
|
|||||||
|
|
||||||
Without file argument: returns status of the repository:
|
Without file argument: returns status of the repository:
|
||||||
|
|
||||||
:"D?": dirty (tracked modified files: added, removed, deleted, modified),
|
:'D?': dirty (tracked modified files: added, removed, deleted, modified),
|
||||||
:"?U": untracked-dirty (added, but not tracked files)
|
:'?U': untracked-dirty (added, but not tracked files)
|
||||||
:None: clean (status is empty)
|
:None: clean (status is empty)
|
||||||
|
|
||||||
With file argument: returns status of this file: "M"odified, "A"dded,
|
With file argument: returns status of this file: `M`odified, `A`dded,
|
||||||
"R"emoved, "D"eleted (removed from filesystem, but still tracked),
|
`R`emoved, `D`eleted (removed from filesystem, but still tracked),
|
||||||
"U"nknown, "I"gnored, (None)Clean.
|
`U`nknown, `I`gnored, (None)Clean.
|
||||||
'''
|
'''
|
||||||
if path:
|
if path:
|
||||||
return get_file_status(
|
return get_file_status(
|
||||||
|
@ -75,7 +75,7 @@ def check_matcher_func(ext, match_name, data, context, echoerr):
|
|||||||
|
|
||||||
if not callable(func):
|
if not callable(func):
|
||||||
echoerr(context='Error while loading matcher functions',
|
echoerr(context='Error while loading matcher functions',
|
||||||
problem='loaded "function" {0} is not callable'.format(match_function),
|
problem='loaded “function” {0} is not callable'.format(match_function),
|
||||||
problem_mark=match_name.mark)
|
problem_mark=match_name.mark)
|
||||||
return True, False, True
|
return True, False, True
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ def import_function(function_type, name, data, context, echoerr, module):
|
|||||||
if not callable(func):
|
if not callable(func):
|
||||||
echoerr(context='Error while checking segments (key {key})'.format(key=context.key),
|
echoerr(context='Error while checking segments (key {key})'.format(key=context.key),
|
||||||
context_mark=name.mark,
|
context_mark=name.mark,
|
||||||
problem='imported "function" {0} from module {1} is not callable'.format(name, module),
|
problem='imported “function” {0} from module {1} is not callable'.format(name, module),
|
||||||
problem_mark=module.mark)
|
problem_mark=module.mark)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -5,10 +5,12 @@ from powerline.lint.markedjson.loader import Loader
|
|||||||
|
|
||||||
|
|
||||||
def load(stream, Loader=Loader):
|
def load(stream, Loader=Loader):
|
||||||
"""
|
'''Parse JSON value and produce the corresponding Python object
|
||||||
Parse the first YAML document in a stream
|
|
||||||
and produce the corresponding Python object.
|
:return:
|
||||||
"""
|
(hadproblem, object) where first argument is true if there were errors
|
||||||
|
during loading JSON stream and second is the corresponding JSON object.
|
||||||
|
'''
|
||||||
loader = Loader(stream)
|
loader = Loader(stream)
|
||||||
try:
|
try:
|
||||||
r = loader.get_single_data()
|
r = loader.get_single_data()
|
||||||
|
@ -43,9 +43,9 @@ class Composer:
|
|||||||
if not self.check_event(events.StreamEndEvent):
|
if not self.check_event(events.StreamEndEvent):
|
||||||
event = self.get_event()
|
event = self.get_event()
|
||||||
raise ComposerError(
|
raise ComposerError(
|
||||||
"expected a single document in the stream",
|
'expected a single document in the stream',
|
||||||
document.start_mark,
|
document.start_mark,
|
||||||
"but found another document",
|
'but found another document',
|
||||||
event.start_mark
|
event.start_mark
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -109,8 +109,8 @@ class Composer:
|
|||||||
# key_event = self.peek_event()
|
# key_event = self.peek_event()
|
||||||
item_key = self.compose_node(node, None)
|
item_key = self.compose_node(node, None)
|
||||||
# if item_key in node.value:
|
# if item_key in node.value:
|
||||||
# raise ComposerError("while composing a mapping", start_event.start_mark,
|
# raise ComposerError('while composing a mapping', start_event.start_mark,
|
||||||
# "found duplicate key", key_event.start_mark)
|
# 'found duplicate key', key_event.start_mark)
|
||||||
item_value = self.compose_node(node, item_key)
|
item_value = self.compose_node(node, item_key)
|
||||||
# node.value[item_key] = item_value
|
# node.value[item_key] = item_value
|
||||||
node.value.append((item_key, item_value))
|
node.value.append((item_key, item_value))
|
||||||
|
@ -94,7 +94,7 @@ class BaseConstructor:
|
|||||||
if not isinstance(node, nodes.ScalarNode):
|
if not isinstance(node, nodes.ScalarNode):
|
||||||
raise ConstructorError(
|
raise ConstructorError(
|
||||||
None, None,
|
None, None,
|
||||||
"expected a scalar node, but found %s" % node.id,
|
'expected a scalar node, but found %s' % node.id,
|
||||||
node.start_mark
|
node.start_mark
|
||||||
)
|
)
|
||||||
return node.value
|
return node.value
|
||||||
@ -103,7 +103,7 @@ class BaseConstructor:
|
|||||||
if not isinstance(node, nodes.SequenceNode):
|
if not isinstance(node, nodes.SequenceNode):
|
||||||
raise ConstructorError(
|
raise ConstructorError(
|
||||||
None, None,
|
None, None,
|
||||||
"expected a sequence node, but found %s" % node.id,
|
'expected a sequence node, but found %s' % node.id,
|
||||||
node.start_mark
|
node.start_mark
|
||||||
)
|
)
|
||||||
return [
|
return [
|
||||||
|
@ -57,10 +57,10 @@ class Mark:
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
snippet = self.get_snippet()
|
snippet = self.get_snippet()
|
||||||
where = (" in \"%s\", line %d, column %d" % (
|
where = (' in "%s", line %d, column %d' % (
|
||||||
self.name, self.line + 1, self.column + 1))
|
self.name, self.line + 1, self.column + 1))
|
||||||
if snippet is not None:
|
if snippet is not None:
|
||||||
where += ":\n" + snippet
|
where += ':\n' + snippet
|
||||||
if type(where) is str:
|
if type(where) is str:
|
||||||
return where
|
return where
|
||||||
else:
|
else:
|
||||||
|
@ -88,7 +88,7 @@ class Parser:
|
|||||||
token = self.peek_token()
|
token = self.peek_token()
|
||||||
self.echoerr(
|
self.echoerr(
|
||||||
None, None,
|
None, None,
|
||||||
("expected '<stream end>', but found %r" % token.id), token.start_mark
|
('expected \'<stream end>\', but found %r' % token.id), token.start_mark
|
||||||
)
|
)
|
||||||
return events.StreamEndEvent(token.start_mark, token.end_mark)
|
return events.StreamEndEvent(token.start_mark, token.end_mark)
|
||||||
else:
|
else:
|
||||||
@ -141,8 +141,8 @@ class Parser:
|
|||||||
else:
|
else:
|
||||||
token = self.peek_token()
|
token = self.peek_token()
|
||||||
raise ParserError(
|
raise ParserError(
|
||||||
"while parsing a flow node", start_mark,
|
'while parsing a flow node', start_mark,
|
||||||
"expected the node content, but found %r" % token.id,
|
'expected the node content, but found %r' % token.id,
|
||||||
token.start_mark
|
token.start_mark
|
||||||
)
|
)
|
||||||
return event
|
return event
|
||||||
@ -160,14 +160,14 @@ class Parser:
|
|||||||
if self.check_token(tokens.FlowSequenceEndToken):
|
if self.check_token(tokens.FlowSequenceEndToken):
|
||||||
token = self.peek_token()
|
token = self.peek_token()
|
||||||
self.echoerr(
|
self.echoerr(
|
||||||
"While parsing a flow sequence", self.marks[-1],
|
'While parsing a flow sequence', self.marks[-1],
|
||||||
("expected sequence value, but got %r" % token.id), token.start_mark
|
('expected sequence value, but got %r' % token.id), token.start_mark
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
token = self.peek_token()
|
token = self.peek_token()
|
||||||
raise ParserError(
|
raise ParserError(
|
||||||
"while parsing a flow sequence", self.marks[-1],
|
'while parsing a flow sequence', self.marks[-1],
|
||||||
("expected ',' or ']', but got %r" % token.id), token.start_mark
|
('expected \',\' or \']\', but got %r' % token.id), token.start_mark
|
||||||
)
|
)
|
||||||
|
|
||||||
if not self.check_token(tokens.FlowSequenceEndToken):
|
if not self.check_token(tokens.FlowSequenceEndToken):
|
||||||
@ -197,14 +197,14 @@ class Parser:
|
|||||||
if self.check_token(tokens.FlowMappingEndToken):
|
if self.check_token(tokens.FlowMappingEndToken):
|
||||||
token = self.peek_token()
|
token = self.peek_token()
|
||||||
self.echoerr(
|
self.echoerr(
|
||||||
"While parsing a flow mapping", self.marks[-1],
|
'While parsing a flow mapping', self.marks[-1],
|
||||||
("expected mapping key, but got %r" % token.id), token.start_mark
|
('expected mapping key, but got %r' % token.id), token.start_mark
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
token = self.peek_token()
|
token = self.peek_token()
|
||||||
raise ParserError(
|
raise ParserError(
|
||||||
"while parsing a flow mapping", self.marks[-1],
|
'while parsing a flow mapping', self.marks[-1],
|
||||||
("expected ',' or '}', but got %r" % token.id), token.start_mark
|
('expected \',\' or \'}\', but got %r' % token.id), token.start_mark
|
||||||
)
|
)
|
||||||
if self.check_token(tokens.KeyToken):
|
if self.check_token(tokens.KeyToken):
|
||||||
token = self.get_token()
|
token = self.get_token()
|
||||||
@ -214,8 +214,8 @@ class Parser:
|
|||||||
else:
|
else:
|
||||||
token = self.peek_token()
|
token = self.peek_token()
|
||||||
raise ParserError(
|
raise ParserError(
|
||||||
"while parsing a flow mapping", self.marks[-1],
|
'while parsing a flow mapping', self.marks[-1],
|
||||||
("expected value, but got %r" % token.id), token.start_mark
|
('expected value, but got %r' % token.id), token.start_mark
|
||||||
)
|
)
|
||||||
elif not self.check_token(tokens.FlowMappingEndToken):
|
elif not self.check_token(tokens.FlowMappingEndToken):
|
||||||
token = self.peek_token()
|
token = self.peek_token()
|
||||||
@ -226,14 +226,14 @@ class Parser:
|
|||||||
|
|
||||||
if expect_key:
|
if expect_key:
|
||||||
raise ParserError(
|
raise ParserError(
|
||||||
"while parsing a flow mapping", self.marks[-1],
|
'while parsing a flow mapping', self.marks[-1],
|
||||||
("expected string key, but got %r" % token.id), token.start_mark
|
('expected string key, but got %r' % token.id), token.start_mark
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
token = self.peek_token()
|
token = self.peek_token()
|
||||||
raise ParserError(
|
raise ParserError(
|
||||||
"while parsing a flow mapping", self.marks[-1],
|
'while parsing a flow mapping', self.marks[-1],
|
||||||
("expected ':', but got %r" % token.id), token.start_mark
|
('expected \':\', but got %r' % token.id), token.start_mark
|
||||||
)
|
)
|
||||||
token = self.get_token()
|
token = self.get_token()
|
||||||
event = events.MappingEndEvent(token.start_mark, token.end_mark)
|
event = events.MappingEndEvent(token.start_mark, token.end_mark)
|
||||||
@ -250,6 +250,6 @@ class Parser:
|
|||||||
|
|
||||||
token = self.peek_token()
|
token = self.peek_token()
|
||||||
raise ParserError(
|
raise ParserError(
|
||||||
"while parsing a flow mapping", self.marks[-1],
|
'while parsing a flow mapping', self.marks[-1],
|
||||||
("expected mapping value, but got %r" % token.id), token.start_mark
|
('expected mapping value, but got %r' % token.id), token.start_mark
|
||||||
)
|
)
|
||||||
|
@ -39,7 +39,7 @@ class SimpleKey:
|
|||||||
|
|
||||||
class Scanner:
|
class Scanner:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initialize the scanner."""
|
'''Initialize the scanner.'''
|
||||||
# It is assumed that Scanner and Reader will have a common descendant.
|
# It is assumed that Scanner and Reader will have a common descendant.
|
||||||
# Reader do the dirty work of checking for BOM and converting the
|
# Reader do the dirty work of checking for BOM and converting the
|
||||||
# input data to Unicode. It also adds NUL to the end.
|
# input data to Unicode. It also adds NUL to the end.
|
||||||
@ -168,7 +168,7 @@ class Scanner:
|
|||||||
return self.fetch_value()
|
return self.fetch_value()
|
||||||
|
|
||||||
# Is it a double quoted scalar?
|
# Is it a double quoted scalar?
|
||||||
if ch == '\"':
|
if ch == '"':
|
||||||
return self.fetch_double()
|
return self.fetch_double()
|
||||||
|
|
||||||
# It must be a plain scalar then.
|
# It must be a plain scalar then.
|
||||||
@ -177,8 +177,8 @@ class Scanner:
|
|||||||
|
|
||||||
# No? It’s an error. Let’s produce a nice error message.
|
# No? It’s an error. Let’s produce a nice error message.
|
||||||
raise ScannerError(
|
raise ScannerError(
|
||||||
"while scanning for the next token", None,
|
'while scanning for the next token', None,
|
||||||
"found character %r that cannot start any token" % ch,
|
'found character %r that cannot start any token' % ch,
|
||||||
self.get_mark()
|
self.get_mark()
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -386,7 +386,7 @@ class Scanner:
|
|||||||
'n': '\x0A',
|
'n': '\x0A',
|
||||||
'f': '\x0C',
|
'f': '\x0C',
|
||||||
'r': '\x0D',
|
'r': '\x0D',
|
||||||
'\"': '\"',
|
'"': '\"',
|
||||||
'\\': '\\',
|
'\\': '\\',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,8 +417,8 @@ class Scanner:
|
|||||||
for k in range(length):
|
for k in range(length):
|
||||||
if self.peek(k) not in '0123456789ABCDEFabcdef':
|
if self.peek(k) not in '0123456789ABCDEFabcdef':
|
||||||
raise ScannerError(
|
raise ScannerError(
|
||||||
"while scanning a double-quoted scalar", start_mark,
|
'while scanning a double-quoted scalar', start_mark,
|
||||||
"expected escape sequence of %d hexdecimal numbers, but found %r" % (
|
'expected escape sequence of %d hexdecimal numbers, but found %r' % (
|
||||||
length, self.peek(k)),
|
length, self.peek(k)),
|
||||||
self.get_mark()
|
self.get_mark()
|
||||||
)
|
)
|
||||||
@ -427,8 +427,8 @@ class Scanner:
|
|||||||
self.forward(length)
|
self.forward(length)
|
||||||
else:
|
else:
|
||||||
raise ScannerError(
|
raise ScannerError(
|
||||||
"while scanning a double-quoted scalar", start_mark,
|
'while scanning a double-quoted scalar', start_mark,
|
||||||
("found unknown escape character %r" % ch), self.get_mark()
|
('found unknown escape character %r' % ch), self.get_mark()
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return chunks
|
return chunks
|
||||||
@ -444,13 +444,13 @@ class Scanner:
|
|||||||
ch = self.peek()
|
ch = self.peek()
|
||||||
if ch == '\0':
|
if ch == '\0':
|
||||||
raise ScannerError(
|
raise ScannerError(
|
||||||
"while scanning a quoted scalar", start_mark,
|
'while scanning a quoted scalar', start_mark,
|
||||||
"found unexpected end of stream", self.get_mark()
|
'found unexpected end of stream', self.get_mark()
|
||||||
)
|
)
|
||||||
elif ch == '\n':
|
elif ch == '\n':
|
||||||
raise ScannerError(
|
raise ScannerError(
|
||||||
"while scanning a quoted scalar", start_mark,
|
'while scanning a quoted scalar', start_mark,
|
||||||
"found unexpected line end", self.get_mark()
|
'found unexpected line end', self.get_mark()
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
chunks.append(whitespaces)
|
chunks.append(whitespaces)
|
||||||
|
@ -382,7 +382,7 @@ class Spec(object):
|
|||||||
:param function msg_func:
|
:param function msg_func:
|
||||||
Function that should accept checked value and return message that
|
Function that should accept checked value and return message that
|
||||||
describes the problem with this value. Default value will emit
|
describes the problem with this value. Default value will emit
|
||||||
something like “length of ["foo", "bar"] is not greater then 10”.
|
something like “length of ['foo', 'bar'] is not greater then 10”.
|
||||||
|
|
||||||
:return: self.
|
:return: self.
|
||||||
'''
|
'''
|
||||||
@ -560,7 +560,7 @@ class Spec(object):
|
|||||||
:param function msg_func:
|
:param function msg_func:
|
||||||
Function that should accept checked value and return message that
|
Function that should accept checked value and return message that
|
||||||
describes the problem with this value. Default value will emit
|
describes the problem with this value. Default value will emit
|
||||||
something like “"xyz" must be one of {"abc", "def", "ghi"}”.
|
something like “"xyz" must be one of {'abc', 'def', 'ghi'}”.
|
||||||
|
|
||||||
:return: self.
|
:return: self.
|
||||||
'''
|
'''
|
||||||
|
@ -19,19 +19,19 @@ class I3barRenderer(Renderer):
|
|||||||
|
|
||||||
def hl(self, contents, fg=None, bg=None, attr=None):
|
def hl(self, contents, fg=None, bg=None, attr=None):
|
||||||
segment = {
|
segment = {
|
||||||
"full_text": contents,
|
'full_text': contents,
|
||||||
"separator": False,
|
'separator': False,
|
||||||
"separator_block_width": 0, # no seperators
|
'separator_block_width': 0, # no seperators
|
||||||
}
|
}
|
||||||
|
|
||||||
if fg is not None:
|
if fg is not None:
|
||||||
if fg is not False and fg[1] is not False:
|
if fg is not False and fg[1] is not False:
|
||||||
segment['color'] = "#{0:06x}".format(fg[1])
|
segment['color'] = '#{0:06x}'.format(fg[1])
|
||||||
if bg is not None:
|
if bg is not None:
|
||||||
if bg is not False and bg[1] is not False:
|
if bg is not False and bg[1] is not False:
|
||||||
segment['background_color'] = "#{0:06x}".format(bg[1])
|
segment['background_color'] = '#{0:06x}'.format(bg[1])
|
||||||
# i3bar "pseudo json" requires one line at a time
|
# i3bar “pseudo json” requires one line at a time
|
||||||
return json.dumps(segment) + ",\n"
|
return json.dumps(segment) + ',\n'
|
||||||
|
|
||||||
|
|
||||||
renderer = I3barRenderer
|
renderer = I3barRenderer
|
||||||
|
@ -101,7 +101,7 @@ class CwdSegment(Segment):
|
|||||||
# user most probably deleted the directory
|
# user most probably deleted the directory
|
||||||
# this happens when removing files from Mercurial repos for example
|
# this happens when removing files from Mercurial repos for example
|
||||||
pl.warn('Current directory not found')
|
pl.warn('Current directory not found')
|
||||||
return "[not found]"
|
return '[not found]'
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
if shorten_home:
|
if shorten_home:
|
||||||
|
@ -133,8 +133,8 @@ def visual_range(pl, segment_info, CTRL_V_text='{rows} x {vcols}', v_text_onelin
|
|||||||
vcols Number of virtual columns in the selection
|
vcols Number of virtual columns in the selection
|
||||||
========= =============================================================
|
========= =============================================================
|
||||||
'''
|
'''
|
||||||
sline, scol, soff = [int(v) for v in vim_funcs['getpos']("v")[1:]]
|
sline, scol, soff = [int(v) for v in vim_funcs['getpos']('v')[1:]]
|
||||||
eline, ecol, eoff = [int(v) for v in vim_funcs['getpos'](".")[1:]]
|
eline, ecol, eoff = [int(v) for v in vim_funcs['getpos']('.')[1:]]
|
||||||
svcol = vim_funcs['virtcol']([sline, scol, soff])
|
svcol = vim_funcs['virtcol']([sline, scol, soff])
|
||||||
evcol = vim_funcs['virtcol']([eline, ecol, eoff])
|
evcol = vim_funcs['virtcol']([eline, ecol, eoff])
|
||||||
rows = abs(eline - sline) + 1
|
rows = abs(eline - sline) + 1
|
||||||
|
@ -148,7 +148,7 @@ class VimPowerline(Powerline):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if (
|
if (
|
||||||
bool(int(vim.eval("has('gui_running') && argc() == 0")))
|
bool(int(vim.eval('has(\'gui_running\') && argc() == 0')))
|
||||||
and not vim.current.buffer.name
|
and not vim.current.buffer.name
|
||||||
and len(vim.windows) == 1
|
and len(vim.windows) == 1
|
||||||
):
|
):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user