39 @type list of str |
39 @type list of str |
40 @param astNode reference to the ast node |
40 @param astNode reference to the ast node |
41 @type ast.AST |
41 @type ast.AST |
42 @param checker reference to the checker object |
42 @param checker reference to the checker object |
43 @type ImportsChecker |
43 @type ImportsChecker |
44 @exception ImportNodeException raised to indicate an invalid node was |
44 @exception ImportNodeError raised to indicate an invalid node was |
45 given to this class |
45 given to this class |
46 """ |
46 """ |
47 if not isinstance(astNode, (ast.Import, ast.ImportFrom)): |
47 if not isinstance(astNode, (ast.Import, ast.ImportFrom)): |
48 raise ImportNodeException( |
48 raise ImportNodeError( |
49 "Node type {0} not recognized".format(type(astNode)) |
49 "Node type {0} not recognized".format(type(astNode)) |
50 ) |
50 ) |
51 |
51 |
52 self.node = astNode |
52 self.node = astNode |
53 self.error = None |
53 self.error = None |
121 """ |
121 """ |
122 Special method to create a string representation of the instance. |
122 Special method to create a string representation of the instance. |
123 |
123 |
124 @return string representation of the instance |
124 @return string representation of the instance |
125 @rtype str |
125 @rtype str |
126 @exception ImportNodeException raised to indicate an invalid node was |
126 @exception ImportNodeError raised to indicate an invalid node was |
127 given to this class |
127 given to this class |
128 """ |
128 """ |
129 if self.nodeType not in (NodeTypeEnum.IMPORT, NodeTypeEnum.IMPORT_FROM): |
129 if self.nodeType not in (NodeTypeEnum.IMPORT, NodeTypeEnum.IMPORT_FROM): |
130 raise ImportNodeException( |
130 raise ImportNodeError( |
131 "The node type {0} is not recognized.".format(self.nodeType) |
131 "The node type {0} is not recognized.".format(self.nodeType) |
132 ) |
132 ) |
133 |
133 |
134 if self.nodeType == NodeTypeEnum.IMPORT: |
134 if self.nodeType == NodeTypeEnum.IMPORT: |
135 return "import {0}".format(self.moduleName) |
135 return "import {0}".format(self.moduleName) |