Some Python-3 compatibility fixes

This commit is contained in:
Sascha Peilicke
2013-07-19 11:53:00 +02:00
parent a54d892887
commit d668b9dafe
8 changed files with 21 additions and 12 deletions

View File

@@ -2,7 +2,7 @@ language: python
python:
- "2.6"
- "2.7"
#- "3.3"
- "3.3"
# command to install dependencies
install: "pip install -r requirements.txt --use-mirrors"
# command to run tests

View File

@@ -62,7 +62,7 @@ class Color():
return self.rgba(*args)
elif len(args) == 3:
try:
return self._rgbatohex(map(int, args))
return self._rgbatohex(list(map(int, args)))
except ValueError:
if all((a for a in args
if a[-1] == '%'
@@ -80,7 +80,7 @@ class Color():
"""
if len(args) == 4:
try:
return self._rgbatohex(map(int, args))
return self._rgbatohex(list(map(int, args)))
except ValueError:
if all((a for a in args
if a[-1] == '%'

View File

@@ -84,7 +84,7 @@ class LessLexer:
def __init__(self):
self.build(reflags=re.UNICODE | re.IGNORECASE)
self.last = None
self.next = None
self.next_ = None
self.pretok = True
def t_css_filter(self, t):
@@ -256,9 +256,9 @@ class LessLexer:
2. Strips out whitespace from nonsignificant locations
to ease parsing.
"""
if self.next:
t = self.next
self.next = None
if self.next_:
t = self.next_
self.next_ = None
return t
while True:
t = self.lexer.token()
@@ -270,7 +270,7 @@ class LessLexer:
continue
self.pretok = False
if t.type == '}' and self.last and self.last.type not in '{;}':
self.next = t
self.next_ = t
tok = lex.LexToken()
tok.type = ';'
tok.value = ';'

View File

@@ -1,4 +1,3 @@
from __future__ import print_function
# -*- coding: utf8 -*-
"""
.. module:: lesscpy.lessc.parser
@@ -12,9 +11,13 @@ from __future__ import print_function
See LICENSE for details.
.. moduleauthor:: Johann T. Mariusson <jtm@robot.is>
"""
from __future__ import print_function
import os
import sys
import ply.yacc
from . import lexer
from . import utility
from .scope import Scope

View File

@@ -7,6 +7,9 @@
See LICENSE for details.
.. moduleauthor:: Johann T. Mariusson <jtm@robot.is>
"""
from __future__ import print_function
import collections
import re

View File

@@ -56,7 +56,7 @@ class Mixin(Node):
raises:
SyntaxError
"""
arguments = zip(args, [' '] * len(args)) if args and args[0] else None
arguments = list(zip(args, [' '] * len(args))) if args and args[0] else None
zl = itertools.zip_longest if sys.version_info[
0] == 3 else itertools.izip_longest
if self.args:

View File

@@ -1,4 +1,3 @@
from __future__ import print_function
# -*- coding: utf8 -*-
"""
.. module:: lesscpy.scripts.compiler
@@ -10,11 +9,15 @@ from __future__ import print_function
See LICENSE for details
.. moduleauthor:: Johann T. Mariusson <jtm@robot.is>
"""
from __future__ import print_function
import os
import sys
import glob
import copy
import argparse
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
from lesscpy.lessc import parser
from lesscpy.lessc import lexer

View File

@@ -1,5 +1,5 @@
[tox]
envlist = py26,py27,pep8
envlist = py26,py27,py33,pep8
[testenv]
deps = -r{toxinidir}/requirements.txt