Add support for python-2.6

This commit is contained in:
ZyX 2013-03-03 15:47:54 +04:00 committed by Kim Silkebækken
parent 9fd63021f0
commit 47cfde0ecc
11 changed files with 20 additions and 19 deletions

View File

@ -21,7 +21,7 @@ follow the installation guide below:
Plugin installation
===================
1. Install Python 3.2+ or Python 2.7.
1. Install Python 3.2+ or Python 2.6+.
2. Install Powerline using the following command::
pip install --user git+git://github.com/Lokaltog/powerline

View File

@ -29,9 +29,8 @@ Python package
Vim installation
----------------
Any terminal vim version with Python 3.3 or Python 2.7 support should work,
but if you're using MacVim you need to install it using the following
command::
Any terminal vim version with Python 3.2+ or Python 2.6+ support should work,
but if you're using MacVim you need to install it using the following command::
brew install macvim --env-std --override-system-vim

View File

@ -1 +1 @@
EBUILD powerline-9999.ebuild 3428 SHA256 56a885903451b133dfd3ff3567613bd04d63242a2a3f6aace3d22eded39f2dcd SHA512 3861c0bd9170ea4d6c28d3a57a63f15ee6c710c4636c41ae4272259a6ddfd0f4a865f851d176115edf95eb335a14cb01fd6c8b8e9bb6b8b393b1025461e53c5c WHIRLPOOL 853fd571b9436ce19a08c4a0bd35c35f6cdb66eeacb4649d1eb235cef2fa47025499cd2d08558913ef2fec09cb21dc62d6c6b2b8f3a252aa8628cd0c181b1523
EBUILD powerline-9999.ebuild 3436 SHA256 9a09866972c18adb5bc3b9394ae8ec98e305aef27e7558803dd89f499829fa48 SHA512 620363137d24ca57457d97fabb95108e515aec2ce986d7dc6abb4b5c68ef2866e55a4024005efc91f7f84fcac58b79c9445af93e3bfff3d1c12aba462c8e8a61 WHIRLPOOL 227ab590e91c97fbe9b720c882d422ee7c05d0637c174cde48f4cd1f683653f14e67914abdb9ba03406d5090d6a56a96e546c501fb1b10961ddaa4005c04b686

View File

@ -3,7 +3,7 @@
# $Header: /var/cvsroot/gentoo-x86/dev-python/setuptools/setuptools-9999.ebuild,v 1.1 2013/01/11 09:59:31 mgorny Exp $
EAPI="5"
PYTHON_COMPAT=( python{2_7,3_3} )
PYTHON_COMPAT=( python{2_6,2_7,3_2,3_3} )
#if LIVE
EGIT_REPO_URI="https://github.com/Lokaltog/${PN}"

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
import importlib
from __future__ import absolute_import
import json
import os
import sys
@ -63,7 +63,7 @@ class Powerline(object):
renderer_module_import = 'powerline.renderers.{0}'.format(renderer_module_name)
renderer_class_name = '{0}Renderer'.format(underscore_to_camelcase(renderer_module_name))
try:
Renderer = getattr(importlib.import_module(renderer_module_import), renderer_class_name)
Renderer = getattr(__import__(renderer_module_import, fromlist=[renderer_class_name]), renderer_class_name)
except ImportError as e:
sys.stderr.write('Error while importing renderer module: {0}\n'.format(e))
sys.exit(1)

View File

@ -10,7 +10,7 @@ function! s:CriticalError(message)
endfunction
if ! has('python') && ! has('python3')
call s:CriticalError('You need vim compiled with Python 2.7 or 3.3+ support
call s:CriticalError('You need vim compiled with Python 2.6+ or 3.2+ support
\ for Powerline to work. Please consult the documentation for more details.')
finish
endif
@ -33,7 +33,7 @@ catch
if !exists('s:launched')
call s:CriticalError('An error occured while importing the Powerline package.
\ This could be caused by an invalid sys.path setting, or by an incompatible
\ Python version (Powerline requires Python 2.7 or 3.3+ to work). Please consult
\ Python version (Powerline requires Python 2.6+ or 3.2+ to work). Please consult
\ the troubleshooting section in the documentation for possible solutions.')
finish
endif

View File

@ -1,4 +1,4 @@
import importlib
from __future__ import absolute_import
import os
from powerline.lib.memoize import memoize
@ -24,7 +24,7 @@ def guess(path):
if check(os.path.join(directory, vcs_dir)):
try:
if vcs not in globals():
globals()[vcs] = importlib.import_module('powerline.lib.vcs.' + vcs)
globals()[vcs] = getattr(__import__('powerline.lib.vcs', fromlist=[vcs]), vcs)
return globals()[vcs].Repository(directory)
except:
pass

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from importlib import import_module
from __future__ import absolute_import
import sys
@ -13,7 +13,7 @@ def gen_matcher_getter(ext, import_paths):
oldpath = sys.path
sys.path = import_paths + sys.path
try:
return getattr(import_module(match_module), match_function)
return getattr(__import__(match_module, fromlist=[match_function]), match_function)
finally:
sys.path = oldpath
return get

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from importlib import import_module
from __future__ import absolute_import
import sys
@ -25,7 +25,7 @@ def get_function(data, segment):
sys.path = data['path'] + sys.path
segment_module = str(segment.get('module', data['default_module']))
try:
return None, getattr(import_module(segment_module), segment['name']), segment_module
return None, getattr(__import__(segment_module, fromlist=[segment['name']]), segment['name']), segment_module
finally:
sys.path = oldpath

View File

@ -564,9 +564,9 @@ class NowPlayingSegment(object):
if not now_playing_str:
return
ignore_levels = ('tag', 'set',)
now_playing = {token[0] if token[0] not in ignore_levels else token[1]:
' '.join(token[1:]) if token[0] not in ignore_levels else
' '.join(token[2:]) for token in [line.split(' ') for line in now_playing_str.split('\n')[:-1]]}
now_playing = dict(((token[0] if token[0] not in ignore_levels else token[1],
(' '.join(token[1:]) if token[0] not in ignore_levels else
' '.join(token[2:]))) for token in [line.split(' ') for line in now_playing_str.split('\n')[:-1]]))
state = self._convert_state(now_playing.get('status'))
return {
'state': state,

View File

@ -198,6 +198,8 @@ def file_size(segment_info, suffix='B', si_prefix=False):
:return: file size or None if the file isn't saved or if the size is too big to fit in a number
'''
file_name = segment_info['buffer'].name
if not file_name:
return None
try:
file_size = os.stat(file_name).st_size
except: