OLD | NEW |
1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. | 1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr | 2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # | 3 # |
4 # This file is part of astroid. | 4 # This file is part of astroid. |
5 # | 5 # |
6 # astroid is free software: you can redistribute it and/or modify it | 6 # astroid is free software: you can redistribute it and/or modify it |
7 # under the terms of the GNU Lesser General Public License as published by the | 7 # under the terms of the GNU Lesser General Public License as published by the |
8 # Free Software Foundation, either version 2.1 of the License, or (at your | 8 # Free Software Foundation, either version 2.1 of the License, or (at your |
9 # option) any later version. | 9 # option) any later version. |
10 # | 10 # |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return '%s(%s)' % (expr_str, ', '.join(args)) | 141 return '%s(%s)' % (expr_str, ', '.join(args)) |
142 | 142 |
143 def visit_class(self, node): | 143 def visit_class(self, node): |
144 """return an astroid.Class node as string""" | 144 """return an astroid.Class node as string""" |
145 decorate = node.decorators and node.decorators.accept(self) or '' | 145 decorate = node.decorators and node.decorators.accept(self) or '' |
146 bases = ', '.join([n.accept(self) for n in node.bases]) | 146 bases = ', '.join([n.accept(self) for n in node.bases]) |
147 if sys.version_info[0] == 2: | 147 if sys.version_info[0] == 2: |
148 bases = bases and '(%s)' % bases or '' | 148 bases = bases and '(%s)' % bases or '' |
149 else: | 149 else: |
150 metaclass = node.metaclass() | 150 metaclass = node.metaclass() |
151 if metaclass: | 151 if metaclass and not node.has_metaclass_hack(): |
152 if bases: | 152 if bases: |
153 bases = '(%s, metaclass=%s)' % (bases, metaclass.name) | 153 bases = '(%s, metaclass=%s)' % (bases, metaclass.name) |
154 else: | 154 else: |
155 bases = '(metaclass=%s)' % metaclass.name | 155 bases = '(metaclass=%s)' % metaclass.name |
156 else: | 156 else: |
157 bases = bases and '(%s)' % bases or '' | 157 bases = bases and '(%s)' % bases or '' |
158 docs = node.doc and '\n%s"""%s"""' % (INDENT, node.doc) or '' | 158 docs = node.doc and '\n%s"""%s"""' % (INDENT, node.doc) or '' |
159 return '\n\n%sclass %s%s:%s\n%s\n' % (decorate, node.name, bases, docs, | 159 return '\n\n%sclass %s%s:%s\n%s\n' % (decorate, node.name, bases, docs, |
160 self._stmt_list(node.body)) | 160 self._stmt_list(node.body)) |
161 | 161 |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 _names.append(name) | 490 _names.append(name) |
491 return ', '.join(_names) | 491 return ', '.join(_names) |
492 | 492 |
493 | 493 |
494 if sys.version_info >= (3, 0): | 494 if sys.version_info >= (3, 0): |
495 AsStringVisitor = AsStringVisitor3k | 495 AsStringVisitor = AsStringVisitor3k |
496 | 496 |
497 # this visitor is stateless, thus it can be reused | 497 # this visitor is stateless, thus it can be reused |
498 to_code = AsStringVisitor() | 498 to_code = AsStringVisitor() |
499 | 499 |
OLD | NEW |