Package: python3-yaql
Version: 0.2.3-2
Severity: grave
Tags: patch
Justification: renders package unusable

yaql (python 3 package) fails to launch or import because uses python 2 syntax.

2to3 seams to fix the issue.


-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'testing-updates'), (500, 'stable-
updates'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.1.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=es_UY.UTF-8, LC_CTYPE=es_UY.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages python3-yaql depends on:
ii  dpkg         1.18.2
ii  python3-ply  3.4-5
ii  python3.4    3.4.3-7
pn  python3:any  <none>

python3-yaql recommends no packages.

python3-yaql suggests no packages.
--- yaql/__init__.py	(original)
+++ yaql/__init__.py	(refactored)
@@ -12,8 +12,8 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import parser
-import context
+from . import parser
+from . import context
 from yaql.functions import builtin, extended
 
 __versioninfo__ = (0, 2, 3)
--- yaql/context.py	(original)
+++ yaql/context.py	(refactored)
@@ -14,7 +14,7 @@
 
 from functools import wraps
 import inspect
-from exceptions import NoArgumentFound
+from .exceptions import NoArgumentFound
 
 
 class Context():
--- yaql/exceptions.py	(original)
+++ yaql/exceptions.py	(refactored)
@@ -20,9 +20,9 @@
 
 class NoFunctionRegisteredException(YaqlException):
     def __init__(self, func_name, arg_num=None):
-        self.func_name = func_name
+        self.__name__ = func_name
         self.arg_num = arg_num
-        msg = "No function called '{0}' is registered".format(self.func_name)
+        msg = "No function called '{0}' is registered".format(self.__name__)
         if self.arg_num:
             msg += " which has {0} arguments".format(self.arg_num)
         super(NoFunctionRegisteredException, self).__init__(msg)
--- yaql/expressions.py	(original)
+++ yaql/expressions.py	(refactored)
@@ -13,8 +13,8 @@
 #    under the License.
 
 import types
-from context import *
-from exceptions import YaqlExecutionException, NoFunctionRegisteredException
+from .context import *
+from .exceptions import YaqlExecutionException, NoFunctionRegisteredException
 import yaql
 
 
@@ -87,7 +87,7 @@
                         fs = self._try_invoke(
                             resolvers,
                             [self.function_name, this], context) or []
-                        if not isinstance(fs, types.ListType):
+                        if not isinstance(fs, list):
                             fs = [fs]
                     except YaqlExecutionException:
                         fs = []
@@ -223,7 +223,7 @@
             ok = True
             if arg_type:
                 ok = ok and isinstance(arg_val, arg_type)
-                if type(arg_val) == types.BooleanType:
+                if type(arg_val) == bool:
                     ok = ok and type(arg_val) == arg_type
             if custom_validator:
                 ok = ok and custom_validator(arg_val)
--- yaql/parser.py	(original)
+++ yaql/parser.py	(refactored)
@@ -14,9 +14,9 @@
 
 import types
 import ply.yacc as yacc
-import expressions
-import exceptions
-import lexer
+from . import expressions
+from . import exceptions
+from . import lexer
 import tempfile
 
 
@@ -96,7 +96,7 @@
     """
     func : value '.' FUNC arg ')'
     """
-    if isinstance(p[4], types.ListType):
+    if isinstance(p[4], list):
         arg = p[4]
     else:
         arg = [p[4]]
@@ -114,7 +114,7 @@
     """
     func : FUNC arg ')'
     """
-    if isinstance(p[2], types.ListType):
+    if isinstance(p[2], list):
         arg = p[2]
     else:
         arg = [p[2]]
@@ -126,11 +126,11 @@
     arg : arg ',' arg
     """
     val_list = []
-    if isinstance(p[1], types.ListType):
+    if isinstance(p[1], list):
         val_list += p[1]
     else:
         val_list.append(p[1])
-    if isinstance(p[3], types.ListType):
+    if isinstance(p[3], list):
         val_list += p[3]
     else:
         val_list.append(p[3])
--- yaql/utils.py	(original)
+++ yaql/utils.py	(refactored)
@@ -18,9 +18,9 @@
 
 def limit(generator, limit=MAX_GENERATOR_ITEMS):
     res = []
-    for i in xrange(limit):
+    for i in range(limit):
         try:
-            res.append(generator.next())
+            res.append(next(generator))
         except StopIteration:
             return res
     raise YaqlSequenceException(limit)
--- yaql/cli/cli_functions.py	(original)
+++ yaql/cli/cli_functions.py	(refactored)
@@ -31,7 +31,7 @@
 @ContextAware()
 def main(context):
     print("Yet Another Query Language - command-line query tool")
-    print("Version {0}".format(version))
+    print(("Version {0}".format(version)))
     print("Copyright (c) 2013 Mirantis, Inc")
     print("")
     if not context.get_data():
@@ -44,7 +44,7 @@
     comm = True
     while comm != 'exit':
         try:
-            comm = raw_input(PROMPT)
+            comm = input(PROMPT)
         except EOFError:
             return
         if not comm:
@@ -52,7 +52,7 @@
         if comm[0] == '@':
             funcName, args = parse_service_command(comm)
             if funcName not in SERVICE_FUNCTIONS:
-                print("Unknown command " + funcName)
+                print(("Unknown command " + funcName))
             else:
                 SERVICE_FUNCTIONS[funcName](args, context)
             continue
@@ -62,17 +62,17 @@
             if ex.position:
                 pointer_string = (" " * (ex.position + len(PROMPT))) + '^'
                 print(pointer_string)
-            print(ex.message)
+            print((ex.message))
             continue
         try:
             res = expr.evaluate(context=Context(context))
             if isinstance(res, types.GeneratorType):
                 res = limit(res)
-            print(json.dumps(res, indent=4))
+            print((json.dumps(res, indent=4)))
         except Exception as ex:
             print("Execution exception:")
             if hasattr(ex, 'message'):
-                print(ex.message)
+                print((ex.message))
             else:
                 print("Unknown")
 
@@ -81,17 +81,17 @@
     try:
         json_str = open(os.path.expanduser(data_file)).read()
     except IOError as e:
-        print("Unable to read data file '{0}': {1}".format(data_file,
-                                                           e.strerror))
+        print(("Unable to read data file '{0}': {1}".format(data_file,
+                                                           e.strerror)))
         return
     try:
         decoder = JSONDecoder()
         data = decoder.decode(json_str)
     except Exception as e:
-        print("Unable to parse data: " + e.message)
+        print(("Unable to parse data: " + e.message))
         return
     context.set_data(data)
-    print("Data from file '{0}' loaded into context".format(data_file))
+    print(("Data from file '{0}' loaded into context".format(data_file)))
 
 
 
--- yaql/cli/run.py	(original)
+++ yaql/cli/run.py	(refactored)
@@ -30,7 +30,7 @@
             decoder = JSONDecoder()
             data = decoder.decode(json_str)
         except:
-            print("Unable to load data from "+options.data)
+            print(("Unable to load data from "+options.data))
             return
     else:
         data = None
--- yaql/functions/builtin.py	(original)
+++ yaql/functions/builtin.py	(refactored)
@@ -21,7 +21,7 @@
 
 
 def _get_att_or_key(item, value):
-    if isinstance(item, types.DictionaryType):
+    if isinstance(item, dict):
         return item.get(value)
     return getattr(item, value)
 
@@ -35,20 +35,20 @@
 
 
 @EvalArg('self', arg_type=collections.Iterable,
-         custom_validator=lambda v: not isinstance(v, types.DictionaryType)
-         and not isinstance(v, types.StringTypes))
+         custom_validator=lambda v: not isinstance(v, dict)
+         and not isinstance(v, str))
 def collection_attribution(self, att_name):
     for item in self:
         val = _get_att_or_key(item, att_name())
         if isinstance(val, collections.Iterable) and \
-                not isinstance(val, types.StringTypes):
+                not isinstance(val, str):
             for v in val:
                 yield v
         else:
             yield val
 
 
-@EvalArg('self', arg_type=types.DictionaryType)
+@EvalArg('self', arg_type=dict)
 def dict_attribution(self, arg_name):
     return self.get(arg_name())
 
@@ -63,7 +63,7 @@
 
 # Collection filtering
 
-@EvalArg("index", types.IntType)
+@EvalArg("index", int)
 def get_by_index(this, index):
     this = this()
     if isinstance(this, types.GeneratorType):
@@ -72,11 +72,11 @@
 
 
 @EvalArg("self", arg_type=collections.Iterable,
-         custom_validator=lambda v: not isinstance(v, types.StringTypes))
+         custom_validator=lambda v: not isinstance(v, str))
 def filter_by_predicate(self, predicate):
     for item in self:
         r = predicate(item)
-        if not isinstance(r, types.BooleanType):
+        if not isinstance(r, bool):
             raise YaqlExecutionException()
         if r is True:
             yield item
@@ -132,19 +132,19 @@
 
 # Boolean operations
 
-@EvalArg('a', arg_type=types.BooleanType)
-@EvalArg('b', arg_type=types.BooleanType)
+@EvalArg('a', arg_type=bool)
+@EvalArg('b', arg_type=bool)
 def _and(a, b):
     return a and b
 
 
-@EvalArg('a', arg_type=types.BooleanType)
-@EvalArg('b', arg_type=types.BooleanType)
+@EvalArg('a', arg_type=bool)
+@EvalArg('b', arg_type=bool)
 def _or(a, b):
     return a or b
 
 
-@EvalArg('self', arg_type=types.BooleanType)
+@EvalArg('self', arg_type=bool)
 def _not(self):
     return not self
 
@@ -186,7 +186,7 @@
 
 @EvalArg('value')
 def to_bool(value):
-    if isinstance(value, types.StringTypes):
+    if isinstance(value, str):
         if value.lower() == 'false':
             return False
     return bool(value)
--- yaql/functions/extended.py	(original)
+++ yaql/functions/extended.py	(refactored)
@@ -38,7 +38,7 @@
 
 
 def _range_limited(start, end):
-    for i in xrange(int(start()), int(end())):
+    for i in range(int(start()), int(end())):
         yield i
 
 
@@ -66,7 +66,7 @@
 
 
 @ContextAware()
-@EvalArg('levels', types.IntType)
+@EvalArg('levels', int)
 def parent(context, levels, func):
     con = context
     traversed = 0
@@ -113,7 +113,7 @@
     self = self()
     for cond in conditions:
         res = cond(self)
-        if not isinstance(res, types.TupleType):
+        if not isinstance(res, tuple):
             raise YaqlExecutionException("Switch must have tuple parameters")
         if len(res) != 2:
             raise YaqlExecutionException("Switch tuples must be of size 2")

Reply via email to