mirror of
https://github.com/powerline/powerline.git
synced 2025-04-08 19:25:04 +02:00
Unify imports
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 .
This commit is contained in:
parent
545bd6b52f
commit
06211cbe63
@ -67,6 +67,65 @@ Programming style
|
||||
documentation and commit messages.
|
||||
* It is allowed to have too long lines. It is advised though to avoid lines
|
||||
wider then a hundred of characters.
|
||||
* Imports have the following structure:
|
||||
|
||||
1. Shebang and modeline in a form
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
. Modeline is required, shebang is not. If shebang is present file must end
|
||||
with
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Actual script here
|
||||
|
||||
2. Module docstring.
|
||||
3. ``__future__`` import exactly in a form
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
(powerline.shell is the only exception due to problems with argparse). It
|
||||
is not separated by newline with shebang and modeline, but is with
|
||||
docstring.
|
||||
4. Standard python library imports in a form ``import X``.
|
||||
5. Standard python library imports in a form ``from X import Y``.
|
||||
6. Third-party (non-python and non-powerline) library imports in a form
|
||||
``import X``.
|
||||
7. Third-party library imports in a form ``from X import Y``.
|
||||
8. Powerline non-test imports in a form ``from powerline.X import Y``.
|
||||
9. Powerline test imports in a form ``import tests.vim as vim_module``.
|
||||
10. Powerline test imports in a form ``from tests.X import Y``.
|
||||
|
||||
Each entry is separated by newline from another entry. Any entry except for
|
||||
the first and third ones is optional. Example with all entries:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
#!/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
|
||||
|
||||
Submitting changes
|
||||
==================
|
||||
|
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
|
@ -1,8 +1,10 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(os.getcwd()))))
|
||||
sys.path.insert(0, os.path.abspath(os.getcwd()))
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from sphinx.ext import autodoc
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from inspect import formatargspec
|
||||
|
||||
from sphinx.ext import autodoc
|
||||
|
||||
from powerline.lint.inspect import getconfigargspec
|
||||
from powerline.segments import Segment
|
||||
|
||||
try:
|
||||
from __builtin__ import unicode
|
||||
except ImportError:
|
||||
unicode = lambda s, enc: s # NOQA
|
||||
from powerline.lib.unicode import unicode
|
||||
|
||||
|
||||
def formatvalue(val):
|
||||
|
@ -1,6 +1,6 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
|
@ -1,11 +1,14 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
|
||||
from time import sleep
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
from powerline import Powerline
|
||||
import sys
|
||||
from time import sleep
|
||||
from powerline.lib.monotonic import monotonic
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
powerline = Powerline('wm', renderer_module='pango_markup')
|
||||
powerline.update_renderer()
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import absolute_import, unicode_literals, print_function
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
import re
|
||||
|
@ -1,15 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import print_function
|
||||
|
||||
from powerline import Powerline
|
||||
from powerline.lib.monotonic import monotonic
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
import time
|
||||
import i3
|
||||
|
||||
from threading import Lock
|
||||
|
||||
import i3
|
||||
|
||||
from powerline import Powerline
|
||||
from powerline.lib.monotonic import monotonic
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
name = 'wm'
|
||||
|
@ -1,12 +1,13 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from weakref import ref
|
||||
|
||||
from powerline.ipython import IPythonPowerline, RewriteResult
|
||||
|
||||
from IPython.core.prompts import PromptManager
|
||||
from IPython.core.magic import Magics, magics_class, line_magic
|
||||
|
||||
from powerline.ipython import IPythonPowerline, RewriteResult
|
||||
|
||||
|
||||
@magics_class
|
||||
class PowerlineMagics(Magics):
|
||||
|
@ -1,16 +1,17 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import re
|
||||
|
||||
from weakref import ref
|
||||
|
||||
from powerline.ipython import IPythonPowerline, RewriteResult
|
||||
from powerline.lib.unicode import string
|
||||
|
||||
from IPython.Prompts import BasePrompt
|
||||
from IPython.ipapi import get as get_ipython
|
||||
from IPython.ipapi import TryNext
|
||||
|
||||
from powerline.ipython import IPythonPowerline, RewriteResult
|
||||
from powerline.lib.unicode import string
|
||||
|
||||
|
||||
class IPythonInfo(object):
|
||||
def __init__(self, cache):
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from libqtile import bar
|
||||
from libqtile.widget import base
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import absolute_import, unicode_literals, division, print_function
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import re
|
||||
import os
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
import codecs
|
||||
@ -8,6 +9,10 @@ try:
|
||||
except ImportError:
|
||||
vim = {}
|
||||
|
||||
if not hasattr(vim, 'bindeval'):
|
||||
import json
|
||||
|
||||
|
||||
if hasattr(vim, 'bindeval'):
|
||||
def vim_get_func(f, rettype=None):
|
||||
'''Return a vim function binding.'''
|
||||
@ -19,8 +24,6 @@ if hasattr(vim, 'bindeval'):
|
||||
except vim.error:
|
||||
return None
|
||||
else:
|
||||
import json
|
||||
|
||||
class VimFunc(object):
|
||||
'''Evaluate a vim function using vim.eval().
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import absolute_import, unicode_literals, division, print_function
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import atexit
|
||||
|
||||
import zsh
|
||||
|
||||
from weakref import WeakValueDictionary, ref
|
||||
|
||||
import zsh
|
||||
|
||||
from powerline.shell import ShellPowerline
|
||||
from powerline.lib import parsedotval
|
||||
from powerline.lib.unicode import unicode
|
||||
|
@ -1,10 +1,9 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from copy import copy
|
||||
try:
|
||||
from __builtin__ import unicode
|
||||
except ImportError:
|
||||
unicode = str
|
||||
|
||||
from powerline.lib.unicode import unicode
|
||||
|
||||
|
||||
DEFAULT_MODE_KEY = None
|
||||
|
@ -1,8 +1,9 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from __future__ import absolute_import, unicode_literals, print_function
|
||||
import os
|
||||
|
||||
|
||||
POWERLINE_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
BINDINGS_DIRECTORY = os.path.join(POWERLINE_ROOT, 'powerline', 'bindings')
|
||||
TMUX_CONFIG_DIRECTORY = os.path.join(BINDINGS_DIRECTORY, 'tmux')
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline import Powerline
|
||||
from powerline.lib import mergedicts
|
||||
|
@ -1,7 +1,10 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from functools import wraps
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import json
|
||||
|
||||
from functools import wraps
|
||||
|
||||
|
||||
REMOVE_THIS_KEY = object()
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from powerline.lib.threaded import MultiRunnedThread
|
||||
from powerline.lib.watcher import create_file_watcher
|
||||
from copy import deepcopy
|
||||
|
||||
from threading import Event, Lock
|
||||
from collections import defaultdict
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import json
|
||||
import codecs
|
||||
|
||||
from copy import deepcopy
|
||||
from threading import Event, Lock
|
||||
from collections import defaultdict
|
||||
|
||||
from powerline.lib.threaded import MultiRunnedThread
|
||||
from powerline.lib.watcher import create_file_watcher
|
||||
|
||||
|
||||
def open_file(path):
|
||||
return codecs.open(path, encoding='utf-8')
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import gc
|
||||
import sys
|
||||
|
@ -1,6 +1,9 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from math import log
|
||||
|
||||
|
||||
unit_list = tuple(zip(['', 'k', 'M', 'G', 'T', 'P'], [0, 0, 1, 2, 2, 2]))
|
||||
|
||||
|
||||
|
@ -1,8 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
import os
|
||||
@ -13,6 +10,10 @@ import struct
|
||||
from ctypes.util import find_library
|
||||
|
||||
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
|
||||
class INotifyError(Exception):
|
||||
pass
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from functools import wraps
|
||||
|
||||
from powerline.lib.monotonic import monotonic
|
||||
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import division, absolute_import
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
try:
|
||||
try:
|
||||
@ -13,11 +12,9 @@ try:
|
||||
from time import CLOCK_MONOTONIC as CLOCK_ID # NOQA
|
||||
|
||||
monotonic = lambda: clock_gettime(CLOCK_ID)
|
||||
|
||||
except ImportError:
|
||||
# >=python-3.3
|
||||
from time import monotonic # NOQA
|
||||
|
||||
except ImportError:
|
||||
import ctypes
|
||||
import sys
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from __future__ import absolute_import, unicode_literals, division, print_function
|
||||
import sys
|
||||
import os
|
||||
|
||||
from subprocess import Popen, PIPE
|
||||
from locale import getlocale, getdefaultlocale, LC_MESSAGES
|
||||
from functools import partial
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
if sys.platform.startswith('win32'):
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from threading import Thread, Lock, Event
|
||||
from types import MethodType
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from locale import getpreferredencoding
|
||||
|
||||
@ -10,6 +10,12 @@ except ImportError:
|
||||
unicode = str # NOQA
|
||||
|
||||
|
||||
try:
|
||||
from __builtin__ import unichr
|
||||
except ImportError:
|
||||
unichr = chr
|
||||
|
||||
|
||||
def u(s):
|
||||
'''Return unicode instance assuming UTF-8 encoded string.
|
||||
'''
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
try:
|
||||
from urllib.error import HTTPError
|
||||
|
@ -1,8 +1,9 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import absolute_import
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
import errno
|
||||
|
||||
from threading import Lock
|
||||
from collections import defaultdict
|
||||
|
||||
@ -226,7 +227,7 @@ def guess(path, create_watcher):
|
||||
continue
|
||||
try:
|
||||
if vcs not in globals():
|
||||
globals()[vcs] = getattr(__import__('powerline.lib.vcs', fromlist=[vcs]), vcs)
|
||||
globals()[vcs] = getattr(__import__(str('powerline.lib.vcs'), fromlist=[str(vcs)]), str(vcs))
|
||||
return globals()[vcs].Repository(directory, create_watcher)
|
||||
except:
|
||||
pass
|
||||
|
@ -1,9 +1,10 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import absolute_import, unicode_literals, division, print_function
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
|
||||
from io import StringIO
|
||||
|
||||
from bzrlib import (workingtree, status, library_state, trace, ui)
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import (unicode_literals, absolute_import, print_function)
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import absolute_import
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
|
||||
@ -11,8 +11,7 @@ from powerline.lib.inotify import INotifyError
|
||||
|
||||
|
||||
def create_file_watcher(pl, watcher_type='auto', expire_time=10):
|
||||
'''
|
||||
Create an object that can watch for changes to specified files
|
||||
'''Create an object that can watch for changes to specified files
|
||||
|
||||
Use ``.__call__()`` method of the returned object to start watching the file
|
||||
or check whether file has changed since last call.
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import errno
|
||||
import os
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, absolute_import, print_function)
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, absolute_import, print_function)
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.lib.path import realpath
|
||||
import os
|
||||
|
||||
from collections import defaultdict
|
||||
from threading import RLock
|
||||
from functools import partial
|
||||
from threading import Thread
|
||||
|
||||
import os
|
||||
from powerline.lib.path import realpath
|
||||
|
||||
|
||||
class UvNotFound(NotImplementedError):
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import itertools
|
||||
import sys
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import absolute_import
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from inspect import ArgSpec, getargspec
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
__version__ = '3.10'
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
|
||||
from .loader import Loader
|
||||
from powerline.lint.markedjson.loader import Loader
|
||||
|
||||
|
||||
def load(stream, Loader=Loader):
|
||||
|
@ -1,8 +1,12 @@
|
||||
__all__ = ['Composer', 'ComposerError']
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from .error import MarkedError
|
||||
from .events import * # NOQA
|
||||
from .nodes import * # NOQA
|
||||
from powerline.lint.markedjson import nodes
|
||||
from powerline.lint.markedjson import events
|
||||
from powerline.lint.markedjson.error import MarkedError
|
||||
|
||||
|
||||
__all__ = ['Composer', 'ComposerError']
|
||||
|
||||
|
||||
class ComposerError(MarkedError):
|
||||
@ -15,15 +19,15 @@ class Composer:
|
||||
|
||||
def check_node(self):
|
||||
# Drop the STREAM-START event.
|
||||
if self.check_event(StreamStartEvent):
|
||||
if self.check_event(events.StreamStartEvent):
|
||||
self.get_event()
|
||||
|
||||
# If there are more documents available?
|
||||
return not self.check_event(StreamEndEvent)
|
||||
return not self.check_event(events.StreamEndEvent)
|
||||
|
||||
def get_node(self):
|
||||
# Get the root node of the next document.
|
||||
if not self.check_event(StreamEndEvent):
|
||||
if not self.check_event(events.StreamEndEvent):
|
||||
return self.compose_document()
|
||||
|
||||
def get_single_node(self):
|
||||
@ -32,11 +36,11 @@ class Composer:
|
||||
|
||||
# Compose a document if the stream is not empty.
|
||||
document = None
|
||||
if not self.check_event(StreamEndEvent):
|
||||
if not self.check_event(events.StreamEndEvent):
|
||||
document = self.compose_document()
|
||||
|
||||
# Ensure that the stream contains no more documents.
|
||||
if not self.check_event(StreamEndEvent):
|
||||
if not self.check_event(events.StreamEndEvent):
|
||||
event = self.get_event()
|
||||
raise ComposerError(
|
||||
"expected a single document in the stream",
|
||||
@ -64,11 +68,11 @@ class Composer:
|
||||
|
||||
def compose_node(self, parent, index):
|
||||
self.descend_resolver(parent, index)
|
||||
if self.check_event(ScalarEvent):
|
||||
if self.check_event(events.ScalarEvent):
|
||||
node = self.compose_scalar_node()
|
||||
elif self.check_event(SequenceStartEvent):
|
||||
elif self.check_event(events.SequenceStartEvent):
|
||||
node = self.compose_sequence_node()
|
||||
elif self.check_event(MappingStartEvent):
|
||||
elif self.check_event(events.MappingStartEvent):
|
||||
node = self.compose_mapping_node()
|
||||
self.ascend_resolver()
|
||||
return node
|
||||
@ -77,18 +81,18 @@ class Composer:
|
||||
event = self.get_event()
|
||||
tag = event.tag
|
||||
if tag is None or tag == '!':
|
||||
tag = self.resolve(ScalarNode, event.value, event.implicit, event.start_mark)
|
||||
node = ScalarNode(tag, event.value, event.start_mark, event.end_mark, style=event.style)
|
||||
tag = self.resolve(nodes.ScalarNode, event.value, event.implicit, event.start_mark)
|
||||
node = nodes.ScalarNode(tag, event.value, event.start_mark, event.end_mark, style=event.style)
|
||||
return node
|
||||
|
||||
def compose_sequence_node(self):
|
||||
start_event = self.get_event()
|
||||
tag = start_event.tag
|
||||
if tag is None or tag == '!':
|
||||
tag = self.resolve(SequenceNode, None, start_event.implicit)
|
||||
node = SequenceNode(tag, [], start_event.start_mark, None, flow_style=start_event.flow_style)
|
||||
tag = self.resolve(nodes.SequenceNode, None, start_event.implicit)
|
||||
node = nodes.SequenceNode(tag, [], start_event.start_mark, None, flow_style=start_event.flow_style)
|
||||
index = 0
|
||||
while not self.check_event(SequenceEndEvent):
|
||||
while not self.check_event(events.SequenceEndEvent):
|
||||
node.value.append(self.compose_node(node, index))
|
||||
index += 1
|
||||
end_event = self.get_event()
|
||||
@ -99,9 +103,9 @@ class Composer:
|
||||
start_event = self.get_event()
|
||||
tag = start_event.tag
|
||||
if tag is None or tag == '!':
|
||||
tag = self.resolve(MappingNode, None, start_event.implicit)
|
||||
node = MappingNode(tag, [], start_event.start_mark, None, flow_style=start_event.flow_style)
|
||||
while not self.check_event(MappingEndEvent):
|
||||
tag = self.resolve(nodes.MappingNode, None, start_event.implicit)
|
||||
node = nodes.MappingNode(tag, [], start_event.start_mark, None, flow_style=start_event.flow_style)
|
||||
while not self.check_event(events.MappingEndEvent):
|
||||
# key_event = self.peek_event()
|
||||
item_key = self.compose_node(node, None)
|
||||
# if item_key in node.value:
|
||||
|
@ -1,19 +1,16 @@
|
||||
__all__ = ['BaseConstructor', 'Constructor', 'ConstructorError']
|
||||
|
||||
from .error import MarkedError
|
||||
from .nodes import * # NOQA
|
||||
from .markedvalue import gen_marked_value
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import collections
|
||||
import types
|
||||
|
||||
from functools import wraps
|
||||
|
||||
from powerline.lint.markedjson.error import MarkedError
|
||||
|
||||
try:
|
||||
from __builtin__ import unicode
|
||||
except ImportError:
|
||||
unicode = str # NOQA
|
||||
from powerline.lint.markedjson import nodes
|
||||
from powerline.lint.markedjson.markedvalue import gen_marked_value
|
||||
from powerline.lib.unicode import unicode
|
||||
|
||||
|
||||
def marked(func):
|
||||
@ -94,7 +91,7 @@ class BaseConstructor:
|
||||
|
||||
@marked
|
||||
def construct_scalar(self, node):
|
||||
if not isinstance(node, ScalarNode):
|
||||
if not isinstance(node, nodes.ScalarNode):
|
||||
raise ConstructorError(
|
||||
None, None,
|
||||
"expected a scalar node, but found %s" % node.id,
|
||||
@ -103,7 +100,7 @@ class BaseConstructor:
|
||||
return node.value
|
||||
|
||||
def construct_sequence(self, node, deep=False):
|
||||
if not isinstance(node, SequenceNode):
|
||||
if not isinstance(node, nodes.SequenceNode):
|
||||
raise ConstructorError(
|
||||
None, None,
|
||||
"expected a sequence node, but found %s" % node.id,
|
||||
@ -116,7 +113,7 @@ class BaseConstructor:
|
||||
|
||||
@marked
|
||||
def construct_mapping(self, node, deep=False):
|
||||
if not isinstance(node, MappingNode):
|
||||
if not isinstance(node, nodes.MappingNode):
|
||||
raise ConstructorError(
|
||||
None, None,
|
||||
"expected a mapping node, but found %s" % node.id,
|
||||
@ -156,7 +153,7 @@ class BaseConstructor:
|
||||
|
||||
class Constructor(BaseConstructor):
|
||||
def construct_scalar(self, node):
|
||||
if isinstance(node, MappingNode):
|
||||
if isinstance(node, nodes.MappingNode):
|
||||
for key_node, value_node in node.value:
|
||||
if key_node.tag == 'tag:yaml.org,2002:value':
|
||||
return self.construct_scalar(value_node)
|
||||
@ -169,13 +166,13 @@ class Constructor(BaseConstructor):
|
||||
key_node, value_node = node.value[index]
|
||||
if key_node.tag == 'tag:yaml.org,2002:merge':
|
||||
del node.value[index]
|
||||
if isinstance(value_node, MappingNode):
|
||||
if isinstance(value_node, nodes.MappingNode):
|
||||
self.flatten_mapping(value_node)
|
||||
merge.extend(value_node.value)
|
||||
elif isinstance(value_node, SequenceNode):
|
||||
elif isinstance(value_node, nodes.SequenceNode):
|
||||
submerge = []
|
||||
for subnode in value_node.value:
|
||||
if not isinstance(subnode, MappingNode):
|
||||
if not isinstance(subnode, nodes.MappingNode):
|
||||
raise ConstructorError(
|
||||
"while constructing a mapping",
|
||||
node.start_mark,
|
||||
@ -203,7 +200,7 @@ class Constructor(BaseConstructor):
|
||||
node.value = merge + node.value
|
||||
|
||||
def construct_mapping(self, node, deep=False):
|
||||
if isinstance(node, MappingNode):
|
||||
if isinstance(node, nodes.MappingNode):
|
||||
self.flatten_mapping(node)
|
||||
return BaseConstructor.construct_mapping(self, node, deep=deep)
|
||||
|
||||
|
@ -1,13 +1,10 @@
|
||||
__all__ = ['Mark', 'MarkedError', 'echoerr', 'NON_PRINTABLE']
|
||||
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
try:
|
||||
from __builtin__ import unichr
|
||||
except ImportError:
|
||||
unichr = chr # NOQA
|
||||
from powerline.lib.unicode import unichr
|
||||
|
||||
|
||||
NON_PRINTABLE = re.compile('[^\t\n\x20-\x7E' + unichr(0x85) + (unichr(0xA0) + '-' + unichr(0xD7FF)) + (unichr(0xE000) + '-' + unichr(0xFFFD)) + ']')
|
||||
|
@ -1,6 +1,8 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
|
||||
# Abstract classes.
|
||||
|
||||
|
||||
class Event(object):
|
||||
def __init__(self, start_mark=None, end_mark=None):
|
||||
self.start_mark = start_mark
|
||||
@ -38,8 +40,6 @@ class CollectionEndEvent(Event):
|
||||
|
||||
|
||||
# Implementations.
|
||||
|
||||
|
||||
class StreamStartEvent(Event):
|
||||
def __init__(self, start_mark=None, end_mark=None, encoding=None):
|
||||
self.start_mark = start_mark
|
||||
|
@ -1,12 +1,13 @@
|
||||
__all__ = ['Loader']
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from .reader import Reader
|
||||
from .scanner import Scanner
|
||||
from .parser import Parser
|
||||
from .composer import Composer
|
||||
from .constructor import Constructor
|
||||
from .resolver import Resolver
|
||||
from .error import echoerr
|
||||
from powerline.lint.markedjson.reader import Reader
|
||||
from powerline.lint.markedjson.scanner import Scanner
|
||||
from powerline.lint.markedjson.parser import Parser
|
||||
from powerline.lint.markedjson.composer import Composer
|
||||
from powerline.lint.markedjson.constructor import Constructor
|
||||
from powerline.lint.markedjson.resolver import Resolver
|
||||
from powerline.lint.markedjson.error import echoerr
|
||||
|
||||
|
||||
class Loader(Reader, Scanner, Parser, Composer, Constructor, Resolver):
|
||||
|
@ -1,10 +1,7 @@
|
||||
__all__ = ['gen_marked_value', 'MarkedValue']
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
|
||||
try:
|
||||
from __builtin__ import unicode
|
||||
except ImportError:
|
||||
unicode = str
|
||||
from powerline.lib.unicode import unicode
|
||||
|
||||
|
||||
def gen_new(cls):
|
||||
|
@ -1,3 +1,7 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
|
||||
class Node(object):
|
||||
def __init__(self, tag, value, start_mark, end_mark):
|
||||
self.tag = tag
|
||||
|
@ -1,8 +1,9 @@
|
||||
__all__ = ['Parser', 'ParserError']
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from .error import MarkedError
|
||||
from .tokens import * # NOQA
|
||||
from .events import * # NOQA
|
||||
from powerline.lint.markedjson.error import MarkedError
|
||||
from powerline.lint.markedjson import tokens
|
||||
from powerline.lint.markedjson import events
|
||||
|
||||
|
||||
class ParserError(MarkedError):
|
||||
@ -58,7 +59,7 @@ class Parser:
|
||||
def parse_stream_start(self):
|
||||
# Parse the stream start.
|
||||
token = self.get_token()
|
||||
event = StreamStartEvent(token.start_mark, token.end_mark, encoding=token.encoding)
|
||||
event = events.StreamStartEvent(token.start_mark, token.end_mark, encoding=token.encoding)
|
||||
|
||||
# Prepare the next state.
|
||||
self.state = self.parse_implicit_document_start
|
||||
@ -67,10 +68,10 @@ class Parser:
|
||||
|
||||
def parse_implicit_document_start(self):
|
||||
# Parse an implicit document.
|
||||
if not self.check_token(StreamEndToken):
|
||||
if not self.check_token(tokens.StreamEndToken):
|
||||
token = self.peek_token()
|
||||
start_mark = end_mark = token.start_mark
|
||||
event = DocumentStartEvent(start_mark, end_mark, explicit=False)
|
||||
event = events.DocumentStartEvent(start_mark, end_mark, explicit=False)
|
||||
|
||||
# Prepare the next state.
|
||||
self.states.append(self.parse_document_end)
|
||||
@ -83,17 +84,17 @@ class Parser:
|
||||
|
||||
def parse_document_start(self):
|
||||
# Parse an explicit document.
|
||||
if not self.check_token(StreamEndToken):
|
||||
if not self.check_token(tokens.StreamEndToken):
|
||||
token = self.peek_token()
|
||||
self.echoerr(
|
||||
None, None,
|
||||
("expected '<stream end>', but found %r" % token.id), token.start_mark
|
||||
)
|
||||
return StreamEndEvent(token.start_mark, token.end_mark)
|
||||
return events.StreamEndEvent(token.start_mark, token.end_mark)
|
||||
else:
|
||||
# Parse the end of the stream.
|
||||
token = self.get_token()
|
||||
event = StreamEndEvent(token.start_mark, token.end_mark)
|
||||
event = events.StreamEndEvent(token.start_mark, token.end_mark)
|
||||
assert not self.states
|
||||
assert not self.marks
|
||||
self.state = None
|
||||
@ -104,7 +105,7 @@ class Parser:
|
||||
token = self.peek_token()
|
||||
start_mark = end_mark = token.start_mark
|
||||
explicit = False
|
||||
event = DocumentEndEvent(start_mark, end_mark, explicit=explicit)
|
||||
event = events.DocumentEndEvent(start_mark, end_mark, explicit=explicit)
|
||||
|
||||
# Prepare the next state.
|
||||
self.state = self.parse_document_start
|
||||
@ -120,22 +121,22 @@ class Parser:
|
||||
start_mark = end_mark = self.peek_token().start_mark
|
||||
event = None
|
||||
implicit = True
|
||||
if self.check_token(ScalarToken):
|
||||
if self.check_token(tokens.ScalarToken):
|
||||
token = self.get_token()
|
||||
end_mark = token.end_mark
|
||||
if token.plain:
|
||||
implicit = (True, False)
|
||||
else:
|
||||
implicit = (False, True)
|
||||
event = ScalarEvent(implicit, token.value, start_mark, end_mark, style=token.style)
|
||||
event = events.ScalarEvent(implicit, token.value, start_mark, end_mark, style=token.style)
|
||||
self.state = self.states.pop()
|
||||
elif self.check_token(FlowSequenceStartToken):
|
||||
elif self.check_token(tokens.FlowSequenceStartToken):
|
||||
end_mark = self.peek_token().end_mark
|
||||
event = SequenceStartEvent(implicit, start_mark, end_mark, flow_style=True)
|
||||
event = events.SequenceStartEvent(implicit, start_mark, end_mark, flow_style=True)
|
||||
self.state = self.parse_flow_sequence_first_entry
|
||||
elif self.check_token(FlowMappingStartToken):
|
||||
elif self.check_token(tokens.FlowMappingStartToken):
|
||||
end_mark = self.peek_token().end_mark
|
||||
event = MappingStartEvent(implicit, start_mark, end_mark, flow_style=True)
|
||||
event = events.MappingStartEvent(implicit, start_mark, end_mark, flow_style=True)
|
||||
self.state = self.parse_flow_mapping_first_key
|
||||
else:
|
||||
token = self.peek_token()
|
||||
@ -152,11 +153,11 @@ class Parser:
|
||||
return self.parse_flow_sequence_entry(first=True)
|
||||
|
||||
def parse_flow_sequence_entry(self, first=False):
|
||||
if not self.check_token(FlowSequenceEndToken):
|
||||
if not self.check_token(tokens.FlowSequenceEndToken):
|
||||
if not first:
|
||||
if self.check_token(FlowEntryToken):
|
||||
if self.check_token(tokens.FlowEntryToken):
|
||||
self.get_token()
|
||||
if self.check_token(FlowSequenceEndToken):
|
||||
if self.check_token(tokens.FlowSequenceEndToken):
|
||||
token = self.peek_token()
|
||||
self.echoerr(
|
||||
"While parsing a flow sequence", self.marks[-1],
|
||||
@ -169,11 +170,11 @@ class Parser:
|
||||
("expected ',' or ']', but got %r" % token.id), token.start_mark
|
||||
)
|
||||
|
||||
if not self.check_token(FlowSequenceEndToken):
|
||||
if not self.check_token(tokens.FlowSequenceEndToken):
|
||||
self.states.append(self.parse_flow_sequence_entry)
|
||||
return self.parse_node()
|
||||
token = self.get_token()
|
||||
event = SequenceEndEvent(token.start_mark, token.end_mark)
|
||||
event = events.SequenceEndEvent(token.start_mark, token.end_mark)
|
||||
self.state = self.states.pop()
|
||||
self.marks.pop()
|
||||
return event
|
||||
@ -181,7 +182,7 @@ class Parser:
|
||||
def parse_flow_sequence_entry_mapping_end(self):
|
||||
self.state = self.parse_flow_sequence_entry
|
||||
token = self.peek_token()
|
||||
return MappingEndEvent(token.start_mark, token.start_mark)
|
||||
return events.MappingEndEvent(token.start_mark, token.start_mark)
|
||||
|
||||
def parse_flow_mapping_first_key(self):
|
||||
token = self.get_token()
|
||||
@ -189,11 +190,11 @@ class Parser:
|
||||
return self.parse_flow_mapping_key(first=True)
|
||||
|
||||
def parse_flow_mapping_key(self, first=False):
|
||||
if not self.check_token(FlowMappingEndToken):
|
||||
if not self.check_token(tokens.FlowMappingEndToken):
|
||||
if not first:
|
||||
if self.check_token(FlowEntryToken):
|
||||
if self.check_token(tokens.FlowEntryToken):
|
||||
self.get_token()
|
||||
if self.check_token(FlowMappingEndToken):
|
||||
if self.check_token(tokens.FlowMappingEndToken):
|
||||
token = self.peek_token()
|
||||
self.echoerr(
|
||||
"While parsing a flow mapping", self.marks[-1],
|
||||
@ -205,9 +206,9 @@ class Parser:
|
||||
"while parsing a flow mapping", self.marks[-1],
|
||||
("expected ',' or '}', but got %r" % token.id), token.start_mark
|
||||
)
|
||||
if self.check_token(KeyToken):
|
||||
if self.check_token(tokens.KeyToken):
|
||||
token = self.get_token()
|
||||
if not self.check_token(ValueToken, FlowEntryToken, FlowMappingEndToken):
|
||||
if not self.check_token(tokens.ValueToken, tokens.FlowEntryToken, tokens.FlowMappingEndToken):
|
||||
self.states.append(self.parse_flow_mapping_value)
|
||||
return self.parse_node()
|
||||
else:
|
||||
@ -216,12 +217,12 @@ class Parser:
|
||||
"while parsing a flow mapping", self.marks[-1],
|
||||
("expected value, but got %r" % token.id), token.start_mark
|
||||
)
|
||||
elif not self.check_token(FlowMappingEndToken):
|
||||
elif not self.check_token(tokens.FlowMappingEndToken):
|
||||
token = self.peek_token()
|
||||
expect_key = self.check_token(ValueToken, FlowEntryToken)
|
||||
expect_key = self.check_token(tokens.ValueToken, tokens.FlowEntryToken)
|
||||
if not expect_key:
|
||||
self.get_token()
|
||||
expect_key = self.check_token(ValueToken)
|
||||
expect_key = self.check_token(tokens.ValueToken)
|
||||
|
||||
if expect_key:
|
||||
raise ParserError(
|
||||
@ -235,15 +236,15 @@ class Parser:
|
||||
("expected ':', but got %r" % token.id), token.start_mark
|
||||
)
|
||||
token = self.get_token()
|
||||
event = MappingEndEvent(token.start_mark, token.end_mark)
|
||||
event = events.MappingEndEvent(token.start_mark, token.end_mark)
|
||||
self.state = self.states.pop()
|
||||
self.marks.pop()
|
||||
return event
|
||||
|
||||
def parse_flow_mapping_value(self):
|
||||
if self.check_token(ValueToken):
|
||||
if self.check_token(tokens.ValueToken):
|
||||
token = self.get_token()
|
||||
if not self.check_token(FlowEntryToken, FlowMappingEndToken):
|
||||
if not self.check_token(tokens.FlowEntryToken, tokens.FlowMappingEndToken):
|
||||
self.states.append(self.parse_flow_mapping_key)
|
||||
return self.parse_node()
|
||||
|
||||
|
@ -1,16 +1,14 @@
|
||||
# This module contains abstractions for the input stream. You don't have to
|
||||
# looks further, there are no pretty code.
|
||||
|
||||
__all__ = ['Reader', 'ReaderError']
|
||||
|
||||
from .error import MarkedError, Mark, NON_PRINTABLE
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import codecs
|
||||
|
||||
try:
|
||||
from __builtin__ import unicode
|
||||
except ImportError:
|
||||
unicode = str # NOQA
|
||||
from powerline.lint.markedjson.error import MarkedError, Mark, NON_PRINTABLE
|
||||
from powerline.lib.unicode import unicode
|
||||
|
||||
|
||||
# This module contains abstractions for the input stream. You don't have to
|
||||
# looks further, there are no pretty code.
|
||||
|
||||
|
||||
class ReaderError(MarkedError):
|
||||
|
@ -1,10 +1,11 @@
|
||||
__all__ = ['BaseResolver', 'Resolver']
|
||||
|
||||
from .error import MarkedError
|
||||
from .nodes import * # NOQA
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import re
|
||||
|
||||
from powerline.lint.markedjson.error import MarkedError
|
||||
from powerline.lint.markedjson import nodes
|
||||
|
||||
|
||||
class ResolverError(MarkedError):
|
||||
pass
|
||||
@ -73,7 +74,7 @@ class BaseResolver:
|
||||
and current_index is None):
|
||||
return
|
||||
if isinstance(index_check, str):
|
||||
if not (isinstance(current_index, ScalarNode) and index_check == current_index.value):
|
||||
if not (isinstance(current_index, nodes.ScalarNode) and index_check == current_index.value):
|
||||
return
|
||||
elif isinstance(index_check, int) and not isinstance(index_check, bool):
|
||||
if index_check != current_index:
|
||||
@ -81,7 +82,7 @@ class BaseResolver:
|
||||
return True
|
||||
|
||||
def resolve(self, kind, value, implicit, mark=None):
|
||||
if kind is ScalarNode and implicit[0]:
|
||||
if kind is nodes.ScalarNode and implicit[0]:
|
||||
if value == '':
|
||||
resolvers = self.yaml_implicit_resolvers.get('', [])
|
||||
else:
|
||||
@ -97,11 +98,11 @@ class BaseResolver:
|
||||
mark
|
||||
)
|
||||
return self.DEFAULT_SCALAR_TAG
|
||||
if kind is ScalarNode:
|
||||
if kind is nodes.ScalarNode:
|
||||
return self.DEFAULT_SCALAR_TAG
|
||||
elif kind is SequenceNode:
|
||||
elif kind is nodes.SequenceNode:
|
||||
return self.DEFAULT_SEQUENCE_TAG
|
||||
elif kind is MappingNode:
|
||||
elif kind is nodes.MappingNode:
|
||||
return self.DEFAULT_MAPPING_TAG
|
||||
|
||||
|
||||
|
@ -1,3 +1,11 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.lint.markedjson.error import MarkedError
|
||||
from powerline.lint.markedjson import tokens
|
||||
from powerline.lib.unicode import unicode
|
||||
|
||||
|
||||
# Scanner produces tokens of the following types:
|
||||
# STREAM-START
|
||||
# STREAM-END
|
||||
@ -14,22 +22,11 @@
|
||||
#
|
||||
# Read comments in the Scanner code for more details.
|
||||
|
||||
__all__ = ['Scanner', 'ScannerError']
|
||||
|
||||
from .error import MarkedError
|
||||
from .tokens import * # NOQA
|
||||
|
||||
|
||||
class ScannerError(MarkedError):
|
||||
pass
|
||||
|
||||
|
||||
try:
|
||||
from __builtin__ import unicode
|
||||
except ImportError:
|
||||
unicode = str # NOQA
|
||||
|
||||
|
||||
class SimpleKey:
|
||||
# See below simple keys treatment.
|
||||
def __init__(self, token_number, index, line, column, mark):
|
||||
@ -241,8 +238,7 @@ class Scanner:
|
||||
mark = self.get_mark()
|
||||
|
||||
# Add STREAM-START.
|
||||
self.tokens.append(StreamStartToken(mark, mark,
|
||||
encoding=self.encoding))
|
||||
self.tokens.append(tokens.StreamStartToken(mark, mark, encoding=self.encoding))
|
||||
|
||||
def fetch_stream_end(self):
|
||||
# Reset simple keys.
|
||||
@ -254,19 +250,18 @@ class Scanner:
|
||||
mark = self.get_mark()
|
||||
|
||||
# Add STREAM-END.
|
||||
self.tokens.append(StreamEndToken(mark, mark))
|
||||
self.tokens.append(tokens.StreamEndToken(mark, mark))
|
||||
|
||||
# The steam is finished.
|
||||
self.done = True
|
||||
|
||||
def fetch_flow_sequence_start(self):
|
||||
self.fetch_flow_collection_start(FlowSequenceStartToken)
|
||||
self.fetch_flow_collection_start(tokens.FlowSequenceStartToken)
|
||||
|
||||
def fetch_flow_mapping_start(self):
|
||||
self.fetch_flow_collection_start(FlowMappingStartToken)
|
||||
self.fetch_flow_collection_start(tokens.FlowMappingStartToken)
|
||||
|
||||
def fetch_flow_collection_start(self, TokenClass):
|
||||
|
||||
# '[' and '{' may start a simple key.
|
||||
self.save_possible_simple_key()
|
||||
|
||||
@ -283,13 +278,12 @@ class Scanner:
|
||||
self.tokens.append(TokenClass(start_mark, end_mark))
|
||||
|
||||
def fetch_flow_sequence_end(self):
|
||||
self.fetch_flow_collection_end(FlowSequenceEndToken)
|
||||
self.fetch_flow_collection_end(tokens.FlowSequenceEndToken)
|
||||
|
||||
def fetch_flow_mapping_end(self):
|
||||
self.fetch_flow_collection_end(FlowMappingEndToken)
|
||||
self.fetch_flow_collection_end(tokens.FlowMappingEndToken)
|
||||
|
||||
def fetch_flow_collection_end(self, TokenClass):
|
||||
|
||||
# Reset possible simple key on the current level.
|
||||
self.remove_possible_simple_key()
|
||||
|
||||
@ -312,7 +306,7 @@ class Scanner:
|
||||
# Add KEY.
|
||||
key = self.possible_simple_keys[self.flow_level]
|
||||
del self.possible_simple_keys[self.flow_level]
|
||||
self.tokens.insert(key.token_number - self.tokens_taken, KeyToken(key.mark, key.mark))
|
||||
self.tokens.insert(key.token_number - self.tokens_taken, tokens.KeyToken(key.mark, key.mark))
|
||||
|
||||
# There cannot be two simple keys one after another.
|
||||
self.allow_simple_key = False
|
||||
@ -321,10 +315,9 @@ class Scanner:
|
||||
start_mark = self.get_mark()
|
||||
self.forward()
|
||||
end_mark = self.get_mark()
|
||||
self.tokens.append(ValueToken(start_mark, end_mark))
|
||||
self.tokens.append(tokens.ValueToken(start_mark, end_mark))
|
||||
|
||||
def fetch_flow_entry(self):
|
||||
|
||||
# Simple keys are allowed after ','.
|
||||
self.allow_simple_key = True
|
||||
|
||||
@ -335,7 +328,7 @@ class Scanner:
|
||||
start_mark = self.get_mark()
|
||||
self.forward()
|
||||
end_mark = self.get_mark()
|
||||
self.tokens.append(FlowEntryToken(start_mark, end_mark))
|
||||
self.tokens.append(tokens.FlowEntryToken(start_mark, end_mark))
|
||||
|
||||
def fetch_double(self):
|
||||
# A flow scalar could be a simple key.
|
||||
@ -385,7 +378,7 @@ class Scanner:
|
||||
chunks.extend(self.scan_flow_scalar_non_spaces(start_mark))
|
||||
self.forward()
|
||||
end_mark = self.get_mark()
|
||||
return ScalarToken(unicode().join(chunks), False, start_mark, end_mark, '"')
|
||||
return tokens.ScalarToken(unicode().join(chunks), False, start_mark, end_mark, '"')
|
||||
|
||||
ESCAPE_REPLACEMENTS = {
|
||||
'b': '\x08',
|
||||
@ -480,4 +473,4 @@ class Scanner:
|
||||
chunks.append(self.prefix(length))
|
||||
self.forward(length)
|
||||
end_mark = self.get_mark()
|
||||
return ScalarToken(''.join(chunks), True, start_mark, end_mark)
|
||||
return tokens.ScalarToken(''.join(chunks), True, start_mark, end_mark)
|
||||
|
@ -1,3 +1,7 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
|
||||
class Token(object):
|
||||
def __init__(self, start_mark, end_mark):
|
||||
self.start_mark = start_mark
|
||||
|
@ -1,15 +1,14 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from __future__ import unicode_literals, absolute_import, division
|
||||
from powerline.theme import requires_segment_info
|
||||
from powerline.bindings.vim import (current_tabpage, list_tabpages, vim_getbufoption)
|
||||
|
||||
try:
|
||||
import vim
|
||||
except ImportError:
|
||||
vim = {} # NOQA
|
||||
|
||||
from powerline.theme import requires_segment_info
|
||||
from powerline.bindings.vim import (current_tabpage, list_tabpages, vim_getbufoption)
|
||||
|
||||
|
||||
def tabpage_updated_segment_info(segment_info, tabpage, mode):
|
||||
segment_info = segment_info.copy()
|
||||
|
@ -1,2 +1,6 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
from pkgutil import extend_path
|
||||
|
||||
|
||||
__path__ = extend_path(__path__, __name__)
|
||||
|
@ -1,8 +1,8 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
|
||||
from powerline.bindings.vim import vim_getbufoption
|
||||
|
||||
|
||||
|
@ -1,2 +1,6 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
from pkgutil import extend_path
|
||||
|
||||
|
||||
__path__ = extend_path(__path__, __name__)
|
||||
|
@ -1,22 +1,28 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
|
||||
try:
|
||||
import vim
|
||||
|
||||
vim.command('''function! Powerline_plugin_ctrlp_main(...)
|
||||
except ImportError:
|
||||
vim = object() # NOQA
|
||||
else:
|
||||
vim.command('''
|
||||
function! Powerline_plugin_ctrlp_main(...)
|
||||
let b:powerline_ctrlp_type = 'main'
|
||||
let b:powerline_ctrlp_args = a:000
|
||||
endfunction''')
|
||||
|
||||
vim.command('''function! Powerline_plugin_ctrlp_prog(...)
|
||||
vim.command('''
|
||||
function! Powerline_plugin_ctrlp_prog(...)
|
||||
let b:powerline_ctrlp_type = 'prog'
|
||||
let b:powerline_ctrlp_args = a:000
|
||||
endfunction''')
|
||||
|
||||
vim.command('''let g:ctrlp_status_func = { 'main': 'Powerline_plugin_ctrlp_main', 'prog': 'Powerline_plugin_ctrlp_prog' }''')
|
||||
except ImportError:
|
||||
vim = object() # NOQA
|
||||
vim.command('''
|
||||
let g:ctrlp_status_func = {'main': 'Powerline_plugin_ctrlp_main', 'prog': 'Powerline_plugin_ctrlp_prog'}
|
||||
''')
|
||||
|
||||
|
||||
def ctrlp(matcher_info):
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
import re
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
|
||||
@ -6,16 +7,10 @@ from unicodedata import east_asian_width, combining
|
||||
from itertools import chain
|
||||
|
||||
from powerline.theme import Theme
|
||||
from powerline.lib.unicode import unichr
|
||||
|
||||
try:
|
||||
NBSP = unicode(' ', 'utf-8')
|
||||
except NameError:
|
||||
NBSP = ' '
|
||||
|
||||
try:
|
||||
from __builtin__ import unichr as chr
|
||||
except ImportError:
|
||||
pass
|
||||
NBSP = ' '
|
||||
|
||||
|
||||
def construct_returned_value(rendered_highlighted, segments, width, output_raw, output_width):
|
||||
@ -80,7 +75,7 @@ class Renderer(object):
|
||||
See documentation of ``unicode.translate`` for details.
|
||||
'''
|
||||
|
||||
np_character_translations = dict(((i, '^' + chr(i + 0x40)) for i in range(0x20)))
|
||||
np_character_translations = dict(((i, '^' + unichr(i + 0x40)) for i in range(0x20)))
|
||||
'''Non-printable character translations
|
||||
|
||||
These are used to transform characters in range 0x00—0x1F into ``^@``,
|
||||
|
@ -1,7 +1,9 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import json
|
||||
|
||||
from powerline.renderer import Renderer
|
||||
import json
|
||||
|
||||
|
||||
class I3barRenderer(Renderer):
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.renderers.shell import ShellRenderer
|
||||
from powerline.theme import Theme
|
||||
|
@ -1,10 +1,11 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from xml.sax.saxutils import escape as _escape
|
||||
|
||||
from powerline.renderer import Renderer
|
||||
from powerline.colorscheme import ATTR_BOLD, ATTR_ITALIC, ATTR_UNDERLINE
|
||||
|
||||
from xml.sax.saxutils import escape as _escape
|
||||
|
||||
|
||||
class PangoMarkupRenderer(Renderer):
|
||||
'''Powerline Pango markup segment renderer.'''
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import absolute_import, unicode_literals, division, print_function
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.renderer import Renderer
|
||||
from powerline.theme import Theme
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.renderers.shell import ShellRenderer
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.renderers.shell import ShellRenderer
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.renderers.shell.zsh import ZshPromptRenderer
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.renderers.shell import ShellRenderer
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.renderer import Renderer
|
||||
from powerline.colorscheme import ATTR_BOLD, ATTR_ITALIC, ATTR_UNDERLINE
|
||||
|
@ -1,20 +1,15 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
import sys
|
||||
|
||||
import vim
|
||||
|
||||
from powerline.bindings.vim import vim_get_func, vim_getoption, environ, current_tabpage
|
||||
from powerline.renderer import Renderer
|
||||
from powerline.colorscheme import ATTR_BOLD, ATTR_ITALIC, ATTR_UNDERLINE
|
||||
from powerline.theme import Theme
|
||||
|
||||
import vim
|
||||
import sys
|
||||
|
||||
|
||||
try:
|
||||
from __builtin__ import unichr as chr
|
||||
except ImportError:
|
||||
pass
|
||||
from powerline.lib.unicode import unichr
|
||||
|
||||
|
||||
vim_mode = vim_get_func('mode', rettype=str)
|
||||
@ -23,8 +18,8 @@ if int(vim.eval('v:version')) >= 702:
|
||||
vim_mode = lambda: _vim_mode(1)
|
||||
|
||||
mode_translations = {
|
||||
chr(ord('V') - 0x40): '^V',
|
||||
chr(ord('S') - 0x40): '^S',
|
||||
unichr(ord('V') - 0x40): '^V',
|
||||
unichr(ord('S') - 0x40): '^S',
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import absolute_import, unicode_literals, division, print_function
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.lib.watcher import create_file_watcher
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import absolute_import
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import unicode_literals, absolute_import, division
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
import sys
|
||||
@ -9,6 +8,7 @@ import socket
|
||||
|
||||
from datetime import datetime
|
||||
from multiprocessing import cpu_count as _cpu_count
|
||||
from collections import namedtuple
|
||||
|
||||
from powerline.lib import add_divider_highlight_group
|
||||
from powerline.lib.shell import asrun, run_cmd
|
||||
@ -20,7 +20,6 @@ from powerline.lib.humanize_bytes import humanize_bytes
|
||||
from powerline.lib.unicode import u
|
||||
from powerline.theme import requires_segment_info, requires_filesystem_watcher
|
||||
from powerline.segments import Segment, with_docstring
|
||||
from collections import namedtuple
|
||||
|
||||
|
||||
cpu_count = None
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import i3
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.theme import requires_segment_info
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.theme import requires_segment_info
|
||||
from powerline.segments import with_docstring
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import absolute_import, unicode_literals, division, print_function
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.bindings.tmux import get_tmux_output
|
||||
|
||||
|
@ -1,17 +1,16 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import unicode_literals, absolute_import, division
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
try:
|
||||
import vim
|
||||
except ImportError:
|
||||
vim = {} # NOQA
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
from powerline.bindings.vim import (vim_get_func, getbufvar, vim_getbufoption,
|
||||
buffer_name, vim_getwinvar,
|
||||
register_buffer_cache, current_tabpage,
|
||||
|
@ -1,2 +1,6 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
from pkgutil import extend_path
|
||||
|
||||
|
||||
__path__ = extend_path(__path__, __name__)
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
try:
|
||||
import vim
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
try:
|
||||
import vim
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
try:
|
||||
import vim
|
||||
|
@ -1,4 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
try:
|
||||
import vim
|
||||
|
@ -1,4 +1,6 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
# WARNING: using unicode_literals causes errors in argparse
|
||||
from __future__ import (division, absolute_import, print_function)
|
||||
|
||||
from powerline import Powerline
|
||||
from powerline.lib import mergedicts, parsedotval
|
||||
|
@ -1,9 +1,10 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import division
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import itertools
|
||||
|
||||
from powerline.segment import gen_segment_getter, process_segment
|
||||
from powerline.lib.unicode import u
|
||||
import itertools
|
||||
|
||||
|
||||
def requires_segment_info(func):
|
||||
|
@ -1,6 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
'''Script used to obtain powerline configuration'''
|
||||
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import argparse
|
||||
|
||||
try:
|
||||
|
@ -6,6 +6,7 @@ import socket
|
||||
import os
|
||||
import errno
|
||||
import sys
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from select import select
|
||||
from signal import signal, SIGTERM
|
||||
|
@ -1,10 +1,15 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
'''Powerline configuration checker.'''
|
||||
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import argparse
|
||||
from powerline.lint import check
|
||||
import sys
|
||||
|
||||
from powerline.lint import check
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('-p', '--config_path', action='append', metavar='PATH')
|
||||
|
@ -1,6 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
'''Powerline prompt and statusline script.'''
|
||||
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
4
setup.py
4
setup.py
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
@ -8,6 +9,7 @@ import logging
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
|
||||
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
try:
|
||||
README = open(os.path.join(CURRENT_DIR, 'README.rst'), 'rb').read().decode('utf-8')
|
||||
|
@ -1,5 +1,8 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info < (2, 7):
|
||||
from unittest2 import TestCase, main # NOQA
|
||||
from unittest2.case import SkipTest # NOQA
|
||||
|
@ -1,4 +1,6 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import imp
|
||||
import sys
|
||||
|
||||
|
@ -1,13 +1,18 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
|
||||
from threading import Lock
|
||||
from powerline.renderer import Renderer
|
||||
from powerline.lib.config import ConfigLoader
|
||||
from powerline import Powerline
|
||||
from tests.lib import Args, replace_attr
|
||||
from copy import deepcopy
|
||||
from time import sleep
|
||||
from functools import wraps
|
||||
import os
|
||||
|
||||
from powerline.renderer import Renderer
|
||||
from powerline.lib.config import ConfigLoader
|
||||
from powerline import Powerline
|
||||
|
||||
from tests.lib import Args, replace_attr
|
||||
|
||||
|
||||
class TestHelpers(object):
|
||||
|
@ -1,5 +1,5 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import unicode_literals, absolute_import, division
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
import os
|
||||
import json
|
||||
|
@ -1,5 +1,4 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from tests import vim
|
||||
|
||||
|
||||
|
@ -2,15 +2,19 @@
|
||||
|
||||
'''Tests for shell.py parser'''
|
||||
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline.shell import get_argparser, finish_args
|
||||
from tests import TestCase
|
||||
from tests.lib import replace_attr
|
||||
import sys
|
||||
|
||||
if sys.version_info < (3,):
|
||||
from io import BytesIO as StrIO
|
||||
else:
|
||||
from io import StringIO as StrIO # NOQA
|
||||
from io import StringIO as StrIO
|
||||
|
||||
from powerline.shell import get_argparser, finish_args
|
||||
|
||||
from tests import TestCase
|
||||
from tests.lib import replace_attr
|
||||
|
||||
|
||||
class TestParser(TestCase):
|
||||
|
@ -1,15 +1,18 @@
|
||||
# vim:fileencoding=utf-8:noet
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
from powerline import Powerline
|
||||
from tests import TestCase
|
||||
from tests.lib.config_mock import select_renderer
|
||||
from shutil import rmtree
|
||||
import os
|
||||
import json
|
||||
from powerline.lib import mergedicts_copy as mdc
|
||||
|
||||
from subprocess import check_call
|
||||
from operator import add
|
||||
from shutil import rmtree
|
||||
|
||||
from powerline.lib import mergedicts_copy as mdc
|
||||
from powerline import Powerline
|
||||
|
||||
from tests import TestCase
|
||||
from tests.lib.config_mock import select_renderer
|
||||
|
||||
|
||||
CONFIG_DIR = 'tests/config'
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user