Skip to content

Commit

Permalink
added full unicode string type inside booleano.
Browse files Browse the repository at this point in the history
  • Loading branch information
darius BERNARD committed May 4, 2017
1 parent fef5d1c commit f2a6970
Show file tree
Hide file tree
Showing 23 changed files with 44 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/booleano/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

# Namespace package here! See:
# http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
from __future__ import unicode_literals
try: #pragma: no cover
__import__('pkg_resources').declare_namespace(__name__)
except ImportError: #pragma: no cover
Expand Down
1 change: 1 addition & 0 deletions src/booleano/operations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using the classes provided by this package.
"""
from __future__ import unicode_literals
import six

from booleano.exc import InvalidOperationError
Expand Down
2 changes: 2 additions & 0 deletions src/booleano/operations/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
evaluable ones).
"""
from __future__ import unicode_literals

from booleano.exc import ConversionError
from booleano.operations import (And, BelongsTo, Equal, GreaterEqual,
GreaterThan, IsSubset, LessEqual, LessThan,
Expand Down
2 changes: 2 additions & 0 deletions src/booleano/operations/operands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
Booleano operands.
"""
from __future__ import unicode_literals
import six


from booleano.operations import OPERATIONS, OperationNode
from booleano.exc import InvalidOperationError, BadOperandError

Expand Down
1 change: 1 addition & 0 deletions src/booleano/operations/operands/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
**Python classes and Booleano classes are two different things!**
"""
from __future__ import unicode_literals
from collections import OrderedDict

import six
Expand Down
3 changes: 2 additions & 1 deletion src/booleano/operations/operands/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Constant operands.
"""
from __future__ import unicode_literals
import six

from booleano.exc import InvalidOperationError
Expand Down Expand Up @@ -157,7 +158,7 @@ def __str__(self):

def __repr__(self):
"""Return the representation for this constant string."""
return '<String "%s">' % self.constant_value.encode("utf-8")
return '<String "%s">' % self.constant_value


@six.python_2_unicode_compatible
Expand Down
5 changes: 3 additions & 2 deletions src/booleano/operations/operands/placeholders.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
parser won't verify its existence.
"""
from __future__ import unicode_literals
import six

from booleano.exc import BadCallError, InvalidOperationError
Expand Down Expand Up @@ -120,7 +121,7 @@ def __str__(self):

def __repr__(self):
"""Return the representation for this placeholder variable."""
msg = '<Placeholder variable "%s"' % self.name.encode("utf-8")
msg = '<Placeholder variable "%s"' % self.name
if self.namespace_parts:
ns = self._namespace_to_ascii()
msg = '%s at namespace="%s"' % (msg, ns)
Expand Down Expand Up @@ -183,7 +184,7 @@ def __repr__(self):
"""Return the representation for this placeholder function."""
args = [repr(arg) for arg in self.arguments]
args = ", ".join(args)
func_name = self.name.encode("utf-8")
func_name = self.name
msg = '<Placeholder function call "%s"(%s)' % (func_name, args)
if self.namespace_parts:
ns = self._namespace_to_ascii()
Expand Down
1 change: 1 addition & 0 deletions src/booleano/operations/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Built-in operators.
"""
from __future__ import unicode_literals
import six


Expand Down
1 change: 1 addition & 0 deletions src/booleano/parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"""

from __future__ import unicode_literals
from logging import getLogger

from booleano.parser.parsers import EvaluableParser, ConvertibleParser
Expand Down
1 change: 1 addition & 0 deletions src/booleano/parser/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Adaptive grammar definition and handling.
"""
from __future__ import unicode_literals

from booleano.exc import GrammarError

Expand Down
1 change: 1 addition & 0 deletions src/booleano/parser/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"""

from __future__ import unicode_literals
import re

import six
Expand Down
1 change: 1 addition & 0 deletions src/booleano/parser/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Booleano scope handling.
"""
from __future__ import unicode_literals

from logging import getLogger

Expand Down
2 changes: 2 additions & 0 deletions src/booleano/parser/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
Semi-automatic utilities to test Booleano grammars and parsers.
"""
from __future__ import unicode_literals

from nose.tools import eq_, ok_, raises
from pyparsing import ParseException

Expand Down
1 change: 1 addition & 0 deletions src/booleano/parser/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
SQL "WHERE" clauses) using so-called parse tree converters.
"""
from __future__ import unicode_literals
import six

__all__ = ("EvaluableParseTree", "ConvertibleParseTree")
Expand Down
12 changes: 11 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@
"""

from __future__ import unicode_literals
import six

if six.PY2: # pragma: nocover
import sys
reload(sys)
sys.setdefaultencoding("utf-8")


import logging
from collections import OrderedDict

import six


from booleano.operations.converters import BaseConverter
from booleano.operations import (Not, And, Or, Xor, Equal, NotEqual, LessThan,
Expand Down Expand Up @@ -224,6 +233,7 @@ def __init__(self, *args, **kwargs):
logging.Handler.__init__(self, *args, **kwargs)

def emit(self, record):
print("received message %s %s"% (record.levelname, record.getMessage()))
self.messages[record.levelname.lower()].append(record.getMessage())

def reset(self):
Expand Down
2 changes: 2 additions & 0 deletions tests/operations/test_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
Tests for the parse tree converters.
"""
from __future__ import unicode_literals

from nose.tools import eq_, assert_raises, raises

from booleano.operations.converters import BaseConverter
Expand Down
1 change: 1 addition & 0 deletions tests/operations/test_operands.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Tests for unbounded operands.
"""
from __future__ import unicode_literals

from nose.tools import eq_, ok_, assert_false, assert_raises, raises
import six
Expand Down
1 change: 1 addition & 0 deletions tests/operations/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Tests for the operators.
"""
from __future__ import unicode_literals

from nose.tools import eq_, ok_, assert_false, assert_raises, raises
import six
Expand Down
1 change: 1 addition & 0 deletions tests/parsing/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Test suite for the grammar configurations.
"""
from __future__ import unicode_literals

from nose.tools import eq_, ok_, assert_raises

Expand Down
7 changes: 5 additions & 2 deletions tests/parsing/test_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Tests for the parsing managers.
"""
from __future__ import unicode_literals

from nose.tools import eq_, ok_, assert_false, assert_raises

Expand Down Expand Up @@ -115,7 +116,9 @@ def test_parsing_with_undefined_grammar_but_available_translations(self):
LessEqual(PedestriansCrossingRoad(), Number(3)))
eq_(parse_tree, expected_tree)
# Checking the log:
info = "Generated parser for unknown grammar 'es'"
info = "Generated parser for unknown grammar u'es'"
print(log_handler.handler.messages)

ok_(info in log_handler.handler.messages['info'])
log_handler.undo()

Expand All @@ -135,7 +138,7 @@ def test_parsing_with_undefined_grammar_and_no_translated_bindings(self):
LessEqual(PedestriansCrossingRoad(), Number(3)))
eq_(parse_tree, expected_tree)
# Checking the log:
info = "Generated parser for unknown grammar 'fr'"
info = "Generated parser for unknown grammar u'fr'"
ok_(info in log_handler.handler.messages['info'])
log_handler.undo()

Expand Down
1 change: 1 addition & 0 deletions tests/parsing/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Test suite for the built-in parser implementation.
"""
from __future__ import unicode_literals

from nose.tools import eq_, assert_raises
import six
Expand Down
1 change: 1 addition & 0 deletions tests/parsing/test_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Scope handling tests.
"""
from __future__ import unicode_literals

from nose.tools import eq_, ok_, assert_false, assert_raises, raises
import six
Expand Down
1 change: 1 addition & 0 deletions tests/parsing/test_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Tests for the parse trees.
"""
from __future__ import unicode_literals

from nose.tools import eq_, ok_, assert_false, assert_raises, raises
import six
Expand Down

0 comments on commit f2a6970

Please sign in to comment.