[Python-modules-commits] [fparser] 03/06: Add python3 patch
Alastair McKinstry
mckinstry at moszumanska.debian.org
Wed Jul 26 09:33:11 UTC 2017
This is an automated email from the git hooks/post-receive script.
mckinstry pushed a commit to branch debian/master
in repository fparser.
commit a4b70b68617a9567b31e81b0c6118db5b748b040
Author: Alastair McKinstry <mckinstry at debian.org>
Date: Tue Jul 25 21:28:45 2017 +0100
Add python3 patch
---
debian/changelog | 1 +
debian/patches/python3.patch | 5952 ++++++++++++++++++++++++++++++++++++++++++
debian/patches/series | 1 +
3 files changed, 5954 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 092cf85..de3f366 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ fparser (0.0.5-2) UNRELEASED; urgency=medium
* Add link to Git rep to debian/control
* Change Arch from any to all
+ * Add python3 patch
-- Alastair McKinstry <mckinstry at debian.org> Tue, 25 Jul 2017 16:12:52 +0100
diff --git a/debian/patches/python3.patch b/debian/patches/python3.patch
new file mode 100644
index 0000000..4681667
--- /dev/null
+++ b/debian/patches/python3.patch
@@ -0,0 +1,5952 @@
+Description: Python3 support (Make code py2,py3 agnostic)
+Author: Alastair McKinstry <mckinstry at debian.org>
+Last-Updated: 2017-07-24
+Forwarded: no
+
+Index: fparser-0.0.5/src/fparser/api.py
+===================================================================
+--- fparser-0.0.5.orig/src/fparser/api.py
++++ fparser-0.0.5/src/fparser/api.py
+@@ -72,13 +72,13 @@ Module content
+
+ __autodoc__ = ['get_reader', 'parse', 'walk']
+
+-import Fortran2003
++from . import Fortran2003
+ # import all Statement classes:
+-from base_classes import EndStatement, classes
+-from block_statements import *
++from .base_classes import EndStatement, classes
++from .block_statements import *
+
+ # CHAR_BIT is used to convert object bit sizes to byte sizes
+-from utils import CHAR_BIT
++from .utils import CHAR_BIT
+
+ def get_reader(input, isfree=None, isstrict=None, include_dirs = None, source_only = None,
+ ignore_comments = True):
+@@ -115,7 +115,7 @@ def get_reader(input, isfree=None, isstr
+ """
+ import os
+ import re
+- from readfortran import FortranFileReader, FortranStringReader
++ from .readfortran import FortranFileReader, FortranStringReader
+ if os.path.isfile(input):
+ name,ext = os.path.splitext(input)
+ if ext.lower() in ['.c']:
+@@ -135,7 +135,7 @@ def get_reader(input, isfree=None, isstr
+ elif isinstance(input, str):
+ reader = FortranStringReader(input, include_dirs = include_dirs, source_only = source_only)
+ else:
+- raise TypeError,'Expected string or filename input but got %s' % (type(input))
++ raise TypeError('Expected string or filename input but got %s' % (type(input)))
+ if isfree is None: isfree = reader.isfree
+ if isstrict is None: isstrict = reader.isstrict
+ reader.set_mode(isfree, isstrict)
+@@ -213,7 +213,7 @@ def parse(input, isfree=None, isstrict=N
+ --------
+ get_reader
+ """
+- from parsefortran import FortranParser
++ from .parsefortran import FortranParser
+ reader = get_reader(input, isfree, isstrict, include_dirs, source_only)
+ parser = FortranParser(reader, ignore_comments = ignore_comments)
+ parser.parse()
+Index: fparser-0.0.5/src/fparser/base_classes.py
+===================================================================
+--- fparser-0.0.5.orig/src/fparser/base_classes.py
++++ fparser-0.0.5/src/fparser/base_classes.py
+@@ -73,10 +73,11 @@ import re
+ import sys
+ import copy
+ import logging
+-from readfortran import Line, Comment
++from .readfortran import Line, Comment
+ from numpy.distutils.misc_util import yellow_text, red_text
+-from utils import split_comma, specs_split_comma, is_int_literal_constant
+-from utils import classes
++from .utils import split_comma, specs_split_comma, is_int_literal_constant
++from .utils import classes
++from functools import reduce
+
+ logger = logging.getLogger('fparser')
+
+@@ -91,7 +92,7 @@ class AttributeHolder(object):
+ def __init__(self, **kws):
+ self._attributes = {}
+ self._readonly = []
+- for k,v in kws.items():
++ for k,v in list(kws.items()):
+ self._attributes[k] = v
+ if callable(v):
+ self._readonly.append(k)
+@@ -99,10 +100,10 @@ class AttributeHolder(object):
+
+ def __getattr__(self, name):
+ if name not in self._attributes:
+- raise AttributeError,'%s instance has no attribute %r, '\
++ raise AttributeError('%s instance has no attribute %r, '\
+ 'expected attributes: %s' \
+ % (self.__class__.__name__,name,
+- ','.join(self._attributes.keys()))
++ ','.join(list(self._attributes.keys()))))
+ value = self._attributes[name]
+ if callable(value):
+ value = value()
+@@ -114,16 +115,16 @@ class AttributeHolder(object):
+ self.__dict__[name] = value
+ return
+ if name in self._readonly:
+- raise AttributeError,'%s instance attribute %r is readonly' \
+- % (self.__class__.__name__, name)
++ raise AttributeError('%s instance attribute %r is readonly' \
++ % (self.__class__.__name__, name))
+ if name not in self._attributes:
+- raise AttributeError,'%s instance has no attribute %r, '\
++ raise AttributeError('%s instance has no attribute %r, '\
+ 'expected attributes: %s' \
+- % (self.__class__.__name__,name,','.join(self._attributes.keys()))
++ % (self.__class__.__name__,name,','.join(list(self._attributes.keys()))))
+ self._attributes[name] = value
+
+ def isempty(self):
+- for k in self._attributes.keys():
++ for k in list(self._attributes.keys()):
+ v = getattr(self,k)
+ if v: return False
+ return True
+@@ -134,20 +135,20 @@ class AttributeHolder(object):
+ if depth==0: return tab + self.__class__.__name__
+ l = [self.__class__.__name__+':']
+ ttab = tab + ' '
+- for k in self._attributes.keys():
++ for k in list(self._attributes.keys()):
+ v = getattr(self,k)
+ if v:
+ if isinstance(v,list):
+ l.append(ttab + '%s=<%s-list>' % (k,len(v)))
+ elif isinstance(v,dict):
+- l.append(ttab + '%s=<dict with keys %s>' % (k,v.keys()))
++ l.append(ttab + '%s=<dict with keys %s>' % (k,list(v.keys())))
+ else:
+ l.append(ttab + '%s=<%s>' % (k,type(v)))
+ return '\n'.join(l)
+
+ def todict(self):
+ d = {}
+- for k in self._attributes.keys():
++ for k in list(self._attributes.keys()):
+ v = getattr(self, k)
+ d[k] = v
+ return d
+@@ -158,7 +159,7 @@ def get_base_classes(cls):
+ bases += get_base_classes(c)
+ return bases + cls.__bases__ + (cls,)
+
+-class Variable(object):
++class Variable(object, metaclass=classes):
+ """
+ Variable instance has attributes:
+ name
+@@ -168,8 +169,6 @@ class Variable(object):
+ intent
+ parent - Statement instances defining the variable
+ """
+-
+- __metaclass__ = classes
+
+ def __init__(self, parent, name):
+ self.parent = parent
+@@ -227,7 +226,7 @@ class Variable(object):
+ return self.typedecl
+
+ def add_parent(self, parent):
+- if id(parent) not in map(id, self.parents):
++ if id(parent) not in list(map(id, self.parents)):
+ self.parents.append(parent)
+ self.parent = parent
+ return
+@@ -361,26 +360,26 @@ class Variable(object):
+ lattr = attr.lower()
+ uattr = attr.upper()
+ if lattr.startswith('dimension'):
+- assert self.dimension is None, `self.dimension,attr`
++ assert self.dimension is None, repr((self.dimension,attr))
+ l = attr[9:].lstrip()
+- assert l[0]+l[-1]=='()',`l`
++ assert l[0]+l[-1]=='()',repr(l)
+ self.set_dimension(split_comma(l[1:-1].strip(), self.parent.item))
+ continue
+ if lattr.startswith('intent'):
+ l = attr[6:].lstrip()
+- assert l[0]+l[-1]=='()',`l`
++ assert l[0]+l[-1]=='()',repr(l)
+ self.set_intent(specs_split_comma(l[1:-1].strip(),
+ self.parent.item, upper=True))
+ continue
+ if lattr.startswith('bind'):
+ l = attr[4:].lstrip()
+- assert l[0]+l[-1]=='()',`l`
++ assert l[0]+l[-1]=='()',repr(l)
+ self.bind = specs_split_comma(l[1:-1].strip(), self.parent.item,
+ upper = True)
+ continue
+ if lattr.startswith('check'):
+ l = attr[5:].lstrip()
+- assert l[0]+l[-1]=='()',`l`
++ assert l[0]+l[-1]=='()',repr(l)
+ self.check.extend(split_comma(l[1:-1].strip(), self.parent.item))
+ continue
+ if uattr not in attributes:
+@@ -483,18 +482,17 @@ class Variable(object):
+ def info(self, message):
+ return self.parent.info(message)
+
+-class ProgramBlock(object):
++class ProgramBlock(object, metaclass=classes):
+
+- __metaclass__ = classes
++ pass
+
+-class Statement(object):
++class Statement(object, metaclass=classes):
+ """
+ Statement instance has attributes:
+ parent - Parent BeginStatement or FortranParser instance
+ item - Line instance containing the statement line
+ isvalid - boolean, when False, the Statement instance will be ignored
+ """
+- __metaclass__ = classes
+
+ modes = ['free','fix','f77','pyf']
+ _repr_attr_names = []
+@@ -746,7 +744,7 @@ class BeginStatement(Statement):
+ # TODO: FIX ME, Comment content is a string
+ self.content.append(classes.Comment(self, item))
+ else:
+- raise NotImplementedError(`item`)
++ raise NotImplementedError(repr(item))
+ item = self.get_item()
+
+ if not end_flag:
+--- fparser-0.0.5.orig/src/fparser/Fortran2003.py
++++ fparser-0.0.5/src/fparser/Fortran2003.py
+@@ -69,11 +69,12 @@
+ # Original author: Pearu Peterson <pearu at cens.ioc.ee>
+ # First version created: Oct 2006
+
++from __future__ import print_function
+ import re
+ import logging
+-from splitline import string_replace_map
+-import pattern_tools as pattern
+-from readfortran import FortranReaderBase
++from .splitline import string_replace_map
++from . import pattern_tools as pattern
++from .readfortran import FortranReaderBase
+
+ logger = logging.getLogger("fparser")
+
+@@ -92,7 +93,7 @@ def show_result(func):
+ def new_func(cls, string, **kws):
+ r = func(cls, string, **kws)
+ if r is not None and isinstance(r, StmtBase):
+- print '%s(%r) -> %r' % (cls.__name__, string, str(r))
++ print ('%s(%r) -> %r' % (cls.__name__, string, str(r)))
+ return r
+ return new_func
+
+@@ -140,11 +141,11 @@ class Base(object):
+ # restore readers content when no match is found.
+ try:
+ result = cls.match(string)
+- except NoMatchError, msg:
++ except NoMatchError as msg:
+ if str(msg)=='%s: %r' % (cls.__name__, string): # avoid recursion 1.
+ raise
+
+- #print '__new__:result:',cls.__name__,`string,result`
++ #print '__new__:result:',cls.__name__,repr(string,result)
+ if isinstance(result, tuple):
+ obj = object.__new__(cls)
+ obj.string = string
+@@ -160,17 +161,17 @@ class Base(object):
+ #print '%s:%s: %r' % (cls.__name__,subcls.__name__,string)
+ try:
+ obj = subcls(string, parent_cls = parent_cls)
+- except NoMatchError, msg:
++ except NoMatchError as msg:
+ obj = None
+ if obj is not None:
+ return obj
+
+ else:
+- raise AssertionError,`result`
++ raise AssertionError(repr(result))
+ errmsg = '%s: %r' % (cls.__name__, string)
+ #if isinstance(string, FortranReaderBase) and string.fifo_item:
+ # errmsg += ' while reaching %s' % (string.fifo_item[-1])
+- raise NoMatchError, errmsg
++ raise NoMatchError(errmsg)
+
+ ## def restore_reader(self):
+ ## self._item.reader.put_item(self._item)
+@@ -224,7 +225,7 @@ content : tuple
+ enable_select_type_construct_hook = False,
+ enable_case_construct_hook = False
+ ):
+- assert isinstance(reader,FortranReaderBase),`reader`
++ assert isinstance(reader,FortranReaderBase),repr(reader)
+ content = []
+ if startcls is not None:
+ try:
+@@ -1870,7 +1871,7 @@ class Component_Decl(Base): # R442
+ if newline.startswith('='):
+ init = Component_Initialization(newline)
+ else:
+- assert newline=='',`newline`
++ assert newline=='',repr(newline)
+ return name, array_spec, char_length, init
+ match = staticmethod(match)
+ def tostr(self):
+@@ -2465,7 +2466,7 @@ class Entity_Decl(Base): # R504
+ elif newline:
+ return
+ else:
+- assert newline=='',`newline, string`
++ assert newline=='',repr(newline, string)
+ return name, array_spec, char_length, init
+ match = staticmethod(match)
+ def tostr(self):
+@@ -3188,7 +3189,7 @@ items : (Namelist_Group_Name, Namelist_G
+ parts = line.split('/')
+ items = []
+ fst = parts.pop(0)
+- assert not fst,`fst, parts`
++ assert not fst,repr((fst, parts))
+ while len(parts)>=2:
+ name,lst = parts[:2]
+ del parts[:2]
+@@ -3197,7 +3198,7 @@ items : (Namelist_Group_Name, Namelist_G
+ if lst.endswith(','):
+ lst = lst[:-1].rstrip()
+ items.append((Namelist_Group_Name(name),Namelist_Group_Object_List(lst)))
+- assert not parts,`parts`
++ assert not parts,repr(parts)
+ return tuple(items)
+
+ def tostr(self):
+@@ -3551,7 +3552,7 @@ class Allocate_Stmt(StmtBase): # R623
+ opts = None
+ if i!=-1:
+ j = line[:i].rfind(',')
+- assert j!=-1,`i,j,line`
++ assert j!=-1,repr((i,j,line))
+ opts = Alloc_Opt_List(repmap(line[j+1:].lstrip()))
+ line = line[:j].rstrip()
+ return spec, Allocation_List(repmap(line)), opts
+@@ -3694,7 +3695,7 @@ class Deallocate_Stmt(StmtBase): # R635
+ opts = None
+ if i!=-1:
+ j = line[:i].rfind(',')
+- assert j!=-1,`i,j,line`
++ assert j!=-1,repr((i,j,line))
+ opts = Dealloc_Opt_List(repmap(line[j+1:].lstrip()))
+ line = line[:j].rstrip()
+ return Allocate_Object_List(repmap(line)), opts
+@@ -3782,7 +3783,7 @@ class Defined_Op(STRINGBase): # R703, 72
+ subclass_names = []
+ def match(string):
+ if pattern.non_defined_binary_op.match(string):
+- raise NoMatchError,'%s: %r' % (Defined_Unary_Op.__name__, string)
++ raise NoMatchError('%s: %r' % (Defined_Unary_Op.__name__, string))
+ return STRINGBase.match(pattern.abs_defined_op, string)
+ match = staticmethod(match)
+
+@@ -4034,13 +4035,13 @@ class Pointer_Assignment_Stmt(StmtBase):
+ l = repmap(lhs[i+1:-1].strip())
+ try:
+ return Data_Pointer_Object(o), Bounds_Spec_List(l), Data_Target(rhs)
+- except NoMatchError, msg:
++ except NoMatchError as msg:
+ return Data_Pointer_Object(o), Bounds_Remapping_List(l), Data_Target(rhs)
+ else:
+ lhs = repmap(lhs)
+ try:
+ return Data_Pointer_Object(lhs), None, Data_Target(rhs)
+- except NoMatchError, msg:
++ except NoMatchError as msg:
+ return Proc_Pointer_Object(lhs), None, Proc_Target(rhs)
+
+ def tostr(self):
+@@ -4351,7 +4352,7 @@ class Forall_Triplet_Spec(Base): # R755
+ if i==-1: return
+ n = Index_Name(repmap(line[:i].rstrip()))
+ line = line[i+1:].lstrip()
+- s = map(lambda s: repmap(s.strip()), line.split(':'))
++ s = [repmap(s.strip()) for s in line.split(':')]
+ if len(s)==2:
+ return n, Subscript(s[0]), Subscript(s[1]), None
+ if len(s)==3:
+@@ -5016,7 +5017,7 @@ class Loop_Control(Base): # R830
+ var,rhs = line.split('=')
+ rhs = [s.strip() for s in rhs.lstrip().split(',')]
+ if not 2<=len(rhs)<=3: return
+- return Variable(repmap(var.rstrip())),map(Scalar_Int_Expr, map(repmap,rhs))
++ return Variable(repmap(var.rstrip())),list(map(Scalar_Int_Expr, list(map(repmap,rhs))))
+ match = staticmethod(match)
+ def tostr(self):
+ if len(self.items)==1: return ', WHILE (%s)' % (self.items[0])
+@@ -5444,11 +5445,11 @@ items : (Io_Control_Spec_List, Format, I
+
+ def tostr(self):
+ if self.items[0] is not None:
+- assert self.items[1] is None,`self.items`
++ assert self.items[1] is None,repr(self.items)
+ if self.items[2] is None:
+ return 'READ(%s)' % (self.items[0])
+ return 'READ(%s) %s' % (self.items[0], self.items[2])
+- assert self.items[1] is not None, `self.items`
++ assert self.items[1] is not None, repr(self.items)
+ if self.items[2] is None:
+ return 'READ %s' % (self.items[1])
+ return 'READ %s, %s' % (self.items[1], self.items[2])
+@@ -5745,7 +5746,7 @@ items : (File_Unit_Number, Position_Spec
+
+ def tostr(self):
+ if self.items[0] is not None:
+- assert self.items[1] is None, `self.items`
++ assert self.items[1] is None, repr(self.items)
+ return 'BACKSPACE %s' % (self.items[0])
+ return 'BACKSPACE(%s)' % (self.items[1])
+
+@@ -5773,7 +5774,7 @@ items : (File_Unit_Number, Position_Spec
+
+ def tostr(self):
+ if self.items[0] is not None:
+- assert self.items[1] is None, `self.items`
++ assert self.items[1] is None, repr(self.items)
+ return 'ENDFILE %s' % (self.items[0])
+ return 'ENDFILE(%s)' % (self.items[1])
+
+@@ -5801,7 +5802,7 @@ items : (File_Unit_Number, Position_Spec
+
+ def tostr(self):
+ if self.items[0] is not None:
+- assert self.items[1] is None, `self.items`
++ assert self.items[1] is None, repr(self.items)
+ return 'REWIND %s' % (self.items[0])
+ return 'REWIND(%s)' % (self.items[1])
+
+@@ -5853,7 +5854,7 @@ items : (File_Unit_Number, Position_Spec
+
+ def tostr(self):
+ if self.items[0] is not None:
+- assert self.items[1] is None, `self.items`
++ assert self.items[1] is None, repr(self.items)
+ return 'FLUSH %s' % (self.items[0])
+ return 'FLUSH(%s)' % (self.items[1])
+
+@@ -5915,7 +5916,7 @@ items : (Inquire_Spec_List, Scalar_Int_V
+
+ def tostr(self):
+ if self.items[0] is None:
+- assert None not in self.items[1:],`self.items`
++ assert None not in self.items[1:],repr(self.items)
+ return 'INQUIRE(IOLENGTH=%s) %s' % (self.items[1:])
+ return 'INQUIRE(%s)' % (self.items[0])
+
+@@ -6191,7 +6192,7 @@ class Data_Edit_Desc_C1002(Base):
+ if self.items[3] is None:
+ return '%s%s.%s' % (c, self.items[1], self.items[2])
+ return '%s%s.%sE%s' % (c, self.items[1], self.items[2], self.items[3])
+- raise NotImpletenetedError,`c`
++ raise NotImpletenetedError(repr(c))
+
+ class Data_Edit_Desc(Base): # R1005
+ """
+@@ -6265,7 +6266,7 @@ class Data_Edit_Desc(Base): # R1005
+ return '%s%s' % (c, self.items[1])
+ else:
+ return '%s%s(%s)' % (c, self.items[1], self.items[2])
+- raise NotImpletenetedError,`c`
++ raise NotImpletenetedError(repr(c))
+
+ class W(Base): # R1006
+ """
+@@ -7460,29 +7461,29 @@ for clsname in _names:
+ _names.append(n)
+ n = n[:-5]
+ #print 'Generating %s_List' % (n)
+- exec '''\
++ exec('''\
+ class %s_List(SequenceBase):
+ subclass_names = [\'%s\']
+ use_names = []
+ def match(string): return SequenceBase.match(r\',\', %s, string)
+ match = staticmethod(match)
+-''' % (n, n, n)
++''' % (n, n, n))
+ elif n.endswith('_Name'):
+ _names.append(n)
+ n = n[:-5]
+ #print 'Generating %s_Name' % (n)
+- exec '''\
++ exec ('''\
+ class %s_Name(Base):
+ subclass_names = [\'Name\']
+-''' % (n)
++''' % (n))
+ elif n.startswith('Scalar_'):
+ _names.append(n)
+ n = n[7:]
+ #print 'Generating Scalar_%s' % (n)
+- exec '''\
++ exec ('''\
+ class Scalar_%s(Base):
+ subclass_names = [\'%s\']
+-''' % (n,n)
++''' % (n,n))
+
+
+ __autodoc__ = []
+@@ -7516,7 +7517,7 @@ if 1: # Optimize subclass tree:
+ l.append(n1)
+ return l
+
+- for cls in Base_classes.values():
++ for cls in list(Base_classes.values()):
+ if not hasattr(cls, 'subclass_names'): continue
+ opt_subclass_names = []
+ for n in cls.subclass_names:
+@@ -7530,7 +7531,7 @@ if 1: # Optimize subclass tree:
+
+
+ # Initialize Base.subclasses dictionary:
+-for clsname, cls in Base_classes.items():
++for clsname, cls in list(Base_classes.items()):
+ subclass_names = getattr(cls, 'subclass_names', None)
+ if subclass_names is None:
+ logger.debug('%s class is missing subclass_names list' % (clsname))
+@@ -7548,7 +7549,7 @@ for clsname, cls in Base_classes.items()
+ # print '%s not implemented needed by %s' % (n,clsname)
+
+ if 1:
+- for cls in Base_classes.values():
++ for cls in list(Base_classes.values()):
+ subclasses = Base.subclasses.get(cls.__name__,[])
+ subclasses_names = [c.__name__ for c in subclasses]
+ subclass_names = getattr(cls,'subclass_names', [])
+--- fparser-0.0.5.orig/src/fparser/block_statements.py
++++ fparser-0.0.5/src/fparser/block_statements.py
+@@ -80,10 +80,10 @@ __all__ = ['BeginSource', 'Module', 'Pyt
+ import re
+ import sys
+
+-from base_classes import BeginStatement, EndStatement, Statement, \
++from .base_classes import BeginStatement, EndStatement, Statement, \
+ AttributeHolder, ProgramBlock, Variable
+-from readfortran import Line
+-from utils import split_comma, filter_stmts, parse_bind, parse_result, \
++from .readfortran import Line
++from .utils import split_comma, filter_stmts, parse_bind, parse_result, \
+ AnalyzeError, is_name
+
+ class HasImplicitStmt(object):
+@@ -93,7 +93,7 @@ class HasImplicitStmt(object):
+ def get_type_by_name(self, name):
+ implicit_rules = self.a.implicit_rules
+ if implicit_rules is None:
+- raise AnalyzeError,'Implicit rules mapping is null while getting %r type' % (name)
++ raise AnalyzeError('Implicit rules mapping is null while getting %r type' % (name))
+ l = name[0].lower()
+ if l in implicit_rules:
+ return implicit_rules[l]
+@@ -115,7 +115,7 @@ class HasImplicitStmt(object):
+ if implicit_rules is None:
+ return tab + 'IMPLICIT NONE\n'
+ items = {}
+- for c,t in implicit_rules.items():
++ for c,t in list(implicit_rules.items()):
+ if c.startswith('default'):
+ continue
+ st = t.tostr()
+@@ -127,7 +127,7 @@ class HasImplicitStmt(object):
+ return tab + '! default IMPLICIT rules apply\n'
+ s = 'IMPLICIT'
+ ls = []
+- for st,l in items.items():
++ for st,l in list(items.items()):
+ l.sort()
+ ls.append(st + ' (%s)' % (', '.join(l)))
+ s += ' ' + ', '.join(ls)
+@@ -139,7 +139,7 @@ class HasUseStmt(object):
+ use_provides = {})
+
+ def get_entity(self, name):
+- for modname, modblock in self.top.a.module.items():
++ for modname, modblock in list(self.top.a.module.items()):
+ for stmt in modblock.content:
+ if getattr(stmt,'name','') == name:
+ return stmt
+@@ -185,7 +185,7 @@ class HasVariables(object):
+ def topyf(self,tab='', only_variables = None):
+ s = ''
+ if only_variables is None:
+- only_variables = self.a.variables.keys()
++ only_variables = list(self.a.variables.keys())
+ for name in only_variables:
+ var = self.a.variables[name]
+ s += tab + str(var) + '\n'
+@@ -197,7 +197,7 @@ class HasTypeDecls(object):
+
+ def topyf(self, tab=''):
+ s = ''
+- for name, stmt in self.a.type_decls.items():
++ for name, stmt in list(self.a.type_decls.items()):
+ s += stmt.topyf(tab=' '+tab)
+ return s
+
+@@ -318,11 +318,11 @@ class BeginSource(BeginStatement):
+
+ def topyf(self, tab=''): # XXXX
+ s = ''
+- for name, stmt in self.a.module.items():
++ for name, stmt in list(self.a.module.items()):
+ s += stmt.topyf(tab=tab)
+- for name, stmt in self.a.external_subprogram.items():
++ for name, stmt in list(self.a.external_subprogram.items()):
+ s += stmt.topyf(tab=tab)
+- for name, stmt in self.a.blockdata.items():
++ for name, stmt in list(self.a.blockdata.items()):
+ s += stmt.topyf(tab=tab)
+ return s
+ # Module
+@@ -386,7 +386,7 @@ class Module(BeginStatement, HasAttribut
+ # self.show_message('Not analyzed content: %s' % content)
+
+ module_provides = self.a.module_provides
+- for name, var in self.a.variables.items():
++ for name, var in list(self.a.variables.items()):
+ if var.is_public():
+ if name in module_provides:
+ self.warning('module data object name conflict with %s, overriding.' % (name))
+@@ -401,10 +401,10 @@ class Module(BeginStatement, HasAttribut
+ s += HasAttributes.topyf(self, tab=tab+' ')
+ s += HasTypeDecls.topyf(self, tab=tab+' ')
+ s += HasVariables.topyf(self, tab=tab+' ')
+- for name, stmt in self.a.module_interface.items():
++ for name, stmt in list(self.a.module_interface.items()):
+ s += stmt.topyf(tab=tab+' ')
+ s += tab + ' CONTAINS\n'
+- for name, stmt in self.a.module_subprogram.items():
++ for name, stmt in list(self.a.module_subprogram.items()):
+ s += stmt.topyf(tab=tab+' ')
+ s += tab + 'END MODULE ' + self.name + '\n'
+ return s
+@@ -556,7 +556,7 @@ class Interface(BeginStatement, HasAttri
+ if isinstance(stmt, self.end_stmt_cls):
+ break
+ stmt.analyze()
+- #assert isinstance(stmt, SubProgramStatement),`stmt.__class__.__name__`
++ #assert isinstance(stmt, SubProgramStatement),repr(stmt.__class__.__name__)
+ if content:
+ logger.info('Not analyzed content: %s' % content)
+ # self.show_message('Not analyzed content: %s' % content)
+@@ -570,7 +570,7 @@ class Interface(BeginStatement, HasAttri
+ if self.name in parent_interface:
+ p = parent_interface[self.name]
+ last = p.content.pop()
+- assert isinstance(last,EndInterface),`last.__class__`
++ assert isinstance(last,EndInterface),repr(last.__class__)
+ p.content += self.content
+ p.update_attributes(self.a.attributes)
+ else:
+@@ -605,14 +605,14 @@ class SubProgramStatement(BeginStatement
+ line = item.get_line()
+ m = self.match(line)
+ i = line.lower().find(clsname)
+- assert i!=-1,`clsname, line`
++ assert i!=-1,repr(clsname, line)
+ self.prefix = line[:i].rstrip()
+ self.name = line[i:m.end()].lstrip()[len(clsname):].strip()
+ line = line[m.end():].lstrip()
+ args = []
+ if line.startswith('('):
+ i = line.find(')')
+- assert i!=-1,`line`
++ assert i!=-1,repr(line)
+ line2 = item.apply_map(line[:i+1])
+ for a in line2[1:-1].split(','):
+ a=a.strip()
+@@ -625,11 +625,11 @@ class SubProgramStatement(BeginStatement
+ if isinstance(self, Function):
+ self.result, suffix = parse_result(suffix, item)
+ if suffix:
+- assert self.bind is None,`self.bind`
++ assert self.bind is None,repr(self.bind)
+ self.bind, suffix = parse_result(suffix, item)
+ if self.result is None:
+ self.result = self.name
+- assert not suffix,`suffix`
++ assert not suffix,repr(suffix)
+ self.args = args
+ self.typedecl = None
+ return BeginStatement.process_item(self)
+@@ -640,7 +640,7 @@ class SubProgramStatement(BeginStatement
+ if self.prefix:
+ s += self.prefix + ' '
+ if self.typedecl is not None:
+- assert isinstance(self, Function),`self.__class__.__name__`
++ assert isinstance(self, Function),repr(self.__class__.__name__)
+ s += self.typedecl.tostr() + ' '
+ s += clsname
+ suf = ''
+@@ -684,7 +684,7 @@ class SubProgramStatement(BeginStatement
+ stmt = content.pop(0)
+ while isinstance (stmt, Comment):
+ stmt = content.pop(0)
+- assert isinstance(stmt, self.end_stmt_cls),`stmt`
++ assert isinstance(stmt, self.end_stmt_cls),repr(stmt)
+ elif isinstance(stmt, self.end_stmt_cls):
+ continue
+ else:
+@@ -794,7 +794,7 @@ class Function(SubProgramStatement):
+
+ def subroutine_wrapper(self):
+ code = self.subroutine_wrapper_code()
+- from api import parse
++ from .api import parse
+ block = parse(code) # XXX: set include_dirs
+ while len(block.content)==1:
+ block = block.content[0]
+@@ -980,7 +980,7 @@ class IfThen(BeginStatement):
+ def process_item(self):
+ item = self.item
+ line = item.get_line()[2:-4].strip()
+- assert line[0]=='(' and line[-1]==')',`line`
++ assert line[0]=='(' and line[-1]==')',repr(line)
+ self.expr = item.apply_map(line[1:-1].strip())
+ self.construct_name = item.name
+ return BeginStatement.process_item(self)
+@@ -1027,7 +1027,7 @@ class If(BeginStatement):
+ return
+
+ def tostr(self):
+- assert len(self.content)==1,`self.content`
++ assert len(self.content)==1,repr(self.content)
+ return 'IF (%s) %s' % (self.expr, str(self.content[0]).lstrip())
+
+ def tofortran(self,isfix=None):
+@@ -1159,7 +1159,7 @@ class Type(BeginStatement, HasVariables,
+ i = line.find('(')
+ if i!=-1:
+ self.name = line[:i].rstrip()
+- assert line[-1]==')',`line`
++ assert line[-1]==')',repr(line)
+ self.params = split_comma(line[i+1:-1].lstrip())
+ else:
+ self.name = line
+@@ -1186,7 +1186,7 @@ class Type(BeginStatement, HasVariables,
+ for spec in self.specs:
+ i = spec.find('(')
+ if i!=-1:
+- assert spec.endswith(')'),`spec`
++ assert spec.endswith(')'),repr(spec)
+ s = spec[:i].rstrip().upper()
+ n = spec[i+1:-1].strip()
+ if s=='EXTENDS':
+@@ -1194,7 +1194,7 @@ class Type(BeginStatement, HasVariables,
+ continue
+ elif s=='BIND':
+ args,rest = parse_bind(spec)
+- assert not rest,`rest`
++ assert not rest,repr(rest)
+ spec = 'BIND(%s)' % (', '.join(args))
+ else:
+ spec = '%s(%s)' % (s,n)
+@@ -1257,7 +1257,7 @@ class Type(BeginStatement, HasVariables,
+ return _cache[id(self)]
+ except KeyError:
+ s = 0
+- for name,var in self.a.components.items():
++ for name,var in list(self.a.components.items()):
+ s += var.get_bit_size()
+ _cache[id(self)] = s
+ return s
+@@ -1296,13 +1296,13 @@ class Enum(BeginStatement):
+
+ ###################################################
+
+-import statements
+-import typedecl_statements
++from . import statements
++from . import typedecl_statements
+ __all__.extend(statements.__all__)
+ __all__.extend(typedecl_statements.__all__)
+
+-from statements import *
+-from typedecl_statements import *
++from .statements import *
++from .typedecl_statements import *
+
+ f2py_stmt = [Threadsafe, FortranName, Depend, Check, CallStatement,
+ CallProtoArgument]
+--- fparser-0.0.5.orig/src/fparser/parsefortran.py
++++ fparser-0.0.5/src/fparser/parsefortran.py
+@@ -68,6 +68,8 @@
+ #Author: Pearu Peterson <pearu at cens.ioc.ee>
+ #Created: May 2006
+
++from __future__ import print_function
++
+ __autodoc__ = ['FortranParser']
+ __all__ = ['FortranParser']
+
+@@ -77,9 +79,9 @@ import traceback
+ import logging
+ from numpy.distutils.misc_util import yellow_text, red_text
+
+-from readfortran import FortranFileReader, FortranStringReader
+-from block_statements import BeginSource
+-from utils import AnalyzeError
++from .readfortran import FortranFileReader, FortranStringReader
++from .block_statements import BeginSource
++from .utils import AnalyzeError
+
+ logger = logging.getLogger('fparser')
+
+@@ -177,7 +179,7 @@ end python module foo
+ reader = FortranStringReader(string, True, True)
+ parser = FortranParser(reader)
+ block = parser.parse()
+- print block
++ print (block)
+
+ def test_free90():
+ string = """
+@@ -208,7 +210,7 @@ end module foo
+ reader = FortranStringReader(string, True, False)
+ parser = FortranParser(reader)
+ block = parser.parse()
+- print block
++ print (block)
+
+ def test_f77():
+ string = """\
+@@ -225,7 +227,7 @@ def test_f77():
+ reader = FortranStringReader(string, False, True)
+ parser = FortranParser(reader)
+ block = parser.parse()
+- print block
++ print (block)
+
+ def simple_main():
+ import sys
+@@ -233,12 +235,12 @@ def simple_main():
+ return parse_all_f()
+ for filename in sys.argv[1:]:
+ reader = FortranFileReader(filename)
+- print yellow_text('Processing '+filename+' (mode=%r)' % (reader.mode))
++ print (yellow_text('Processing '+filename+' (mode=%r)' % (reader.mode)))
+ parser = FortranParser(reader)
+ parser.parse()
+ parser.analyze()
+- print parser.block.torepr(4)
+- #print parser.block
++ print (parser.block.torepr(4))
++ #print (parser.block)
+
+ def profile_main():
+ import hotshot, hotshot.stats
+@@ -254,10 +256,10 @@ def parse_all_f():
+ for filename in open('opt_all_f.txt'):
+ filename = filename.strip()
+ reader = FortranFileReader(filename)
+- print yellow_text('Processing '+filename+' (mode=%r)' % (reader.mode))
++ print (yellow_text('Processing '+filename+' (mode=%r)' % (reader.mode)))
+ parser = FortranParser(reader)
+ block = parser.parse()
+- print block
++ print (block)
+
+ if __name__ == "__main__":
+ #test_f77()
+--- fparser-0.0.5.orig/src/fparser/pattern_tools.py
++++ fparser-0.0.5/src/fparser/pattern_tools.py
+@@ -75,6 +75,8 @@ Created: Oct 2006
+ -----
+ """
+
++from __future__ import print_function
++
+ dollar_ok = True
+
+ import re
+@@ -157,7 +159,7 @@ class Pattern(object):
+ if '' in t[1:-1]: return
+ rhs = t[-1].strip()
+ pattern_match = t[-2].strip()
+- assert abs(self).match(pattern_match),`self,string,t,pattern_match`
++ assert abs(self).match(pattern_match),repr(self,string,t,pattern_match)
+ lhs = (''.join(t[:-2])).strip()
+ return lhs, pattern_match, rhs
+
+@@ -174,7 +176,7 @@ class Pattern(object):
+ lhs = t[0].strip()
+ pattern_match = t[1].strip()
+ rhs = (''.join(t[2:])).strip()
+- assert abs(self).match(pattern_match),`pattern_match`
++ assert abs(self).match(pattern_match),repr(pattern_match)
+ return lhs, pattern_match, rhs
+
+ def __abs__(self):
+@@ -199,14 +201,14 @@ class Pattern(object):
+ pattern = self.pattern + other.pattern
+ flags = self._flags | other._flags
+ else:
+- assert isinstance(other,str),`other`
++ assert isinstance(other,str),repr(other)
+ label = '%s%s' % (self.label, other)
+ pattern = self.pattern + other
+ flags = self._flags
+ return Pattern(label, pattern, flags=flags)
+
+ def __rand__(self, other):
+- assert isinstance(other,str),`other`
++ assert isinstance(other,str),repr(other)
+ label = '%s%s' % (other, self.label)
+ pattern = other + self.pattern
+ return Pattern(label, pattern, flags=self._flags)
+@@ -229,7 +231,7 @@ class Pattern(object):
+ pattern = self.pattern + r'\s*' + other.pattern
+ flags = self._flags | other._flags
+ else:
+- assert isinstance(other,str),`other`
++ assert isinstance(other,str),repr(other)
+ label = '%s %s' % (self.label, other)
+ other = self._special_symbol_map.get(other, other)
+ pattern = self.pattern + r'\s*' + other
+@@ -237,7 +239,7 @@ class Pattern(object):
+ return Pattern(label, pattern, flags = flags)
+
+ def __radd__(self, other):
+- assert isinstance(other,str),`other`
++ assert isinstance(other,str),repr(other)
+ label = '%s %s' % (other, self.label)
+ other = self._special_symbol_map.get(other, other)
+ pattern = other + r'\s*' + self.pattern
+@@ -246,7 +248,7 @@ class Pattern(object):
+ def named(self, name = None):
+ if name is None:
+ label = self.label
+- assert label[0]+label[-1]=='<>' and ' ' not in label,`label`
++ assert label[0]+label[-1]=='<>' and ' ' not in label,repr(label)
+ else:
+ label = '<%s>' % (name)
+ pattern = '(?P%s%s)' % (label.replace('-','_'), self.pattern)
+@@ -449,9 +451,9 @@ def _test():
+ def assert_equal(result, expect):
+ try:
+ assert result==expect
+- except AssertionError, msg:
+- raise AssertionError,"Expected %r but got %r: %s" \
+- % (expect, result, msg)
++ except AssertionError as msg:
++ raise AssertionError("Expected %r but got %r: %s" \
++ % (expect, result, msg))
+
+ m = mult_op.named()
+ assert m.rsplit('a * b')
+@@ -468,7 +470,7 @@ def _test():
+ assert_equal(m.rsplit('a * b ** c'),('a * b','**','c'))
+ assert_equal(m.lsplit('a ** b ** c'),('a','**','b ** c'))
+ assert_equal(m.rsplit('a ** b ** c'),('a ** b','**','c'))
+- print 'ok'
++ print ('ok')
+
+ if __name__ == '__main__':
+ _test()
+--- fparser-0.0.5.orig/src/fparser/readfortran.py
++++ fparser-0.0.5/src/fparser/readfortran.py
... 4988 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/fparser.git
More information about the Python-modules-commits
mailing list