src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Imports/ImportNode.py

branch
eric7
changeset 9272
06ed98a19b79
parent 9221
bf71ee032bb4
child 9278
36448ca469c2
equal deleted inserted replaced
9271:f655c20ff500 9272:06ed98a19b79
15 from functools import total_ordering 15 from functools import total_ordering
16 16
17 from .ImportsEnums import GroupEnum, NodeTypeEnum 17 from .ImportsEnums import GroupEnum, NodeTypeEnum
18 18
19 19
20 class ImportNodeException(Exception): 20 class ImportNodeError(Exception):
21 """ 21 """
22 Class representing an exception for an invalid import node. 22 Class representing an exception for an invalid import node.
23 """ 23 """
24 24
25 pass 25 pass
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)

eric ide

mercurial