src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/SecurityContext.py

branch
eric7
changeset 10169
0f70a4ef4592
parent 9653
e67609152c5e
child 10439
21c28b0f9e41
equal deleted inserted replaced
10168:8312e0e76795 10169:0f70a4ef4592
15 # SPDX-License-Identifier: Apache-2.0 15 # SPDX-License-Identifier: Apache-2.0
16 # 16 #
17 17
18 import ast 18 import ast
19 import copy 19 import copy
20 import sys
21 20
22 import AstUtilities 21 import AstUtilities
23 22
24 from . import SecurityUtils 23 from . import SecurityUtils
25 24
218 @param literal AST literal to be converted 217 @param literal AST literal to be converted
219 @type ast.AST 218 @type ast.AST
220 @return converted Python object 219 @return converted Python object
221 @rtype Any 220 @rtype Any
222 """ 221 """
223 if AstUtilities.isNumber(literal): 222 if (
224 literalValue = literal.n 223 AstUtilities.isNumber(literal)
225 224 or AstUtilities.isString(literal)
226 elif AstUtilities.isString(literal) or AstUtilities.isBytes(literal): 225 or AstUtilities.isBytes(literal)
227 literalValue = literal.s 226 ):
227 literalValue = literal.value
228 228
229 elif isinstance(literal, ast.List): 229 elif isinstance(literal, ast.List):
230 returnList = [] 230 returnList = []
231 for li in literal.elts: 231 for li in literal.elts:
232 returnList.append(self.__getLiteralValue(li)) 232 returnList.append(self.__getLiteralValue(li))
245 literalValue = returnSet 245 literalValue = returnSet
246 246
247 elif isinstance(literal, ast.Dict): 247 elif isinstance(literal, ast.Dict):
248 literalValue = dict(zip(literal.keys, literal.values)) 248 literalValue = dict(zip(literal.keys, literal.values))
249 249
250 elif sys.version_info <= (3, 8, 0) and isinstance(literal, ast.Ellipsis): 250 elif AstUtilities.isEllipsis(literal):
251 # what do we want to do with this? 251 # what do we want to do with this?
252 literalValue = None 252 literalValue = None
253 253
254 elif isinstance(literal, ast.Name): 254 elif isinstance(literal, ast.Name):
255 literalValue = literal.id 255 literalValue = literal.id

eric ide

mercurial