128 @param text source text |
128 @param text source text |
129 @type str |
129 @type str |
130 @return tuple containing the result dictionary |
130 @return tuple containing the result dictionary |
131 @rtype (tuple of dict) |
131 @rtype (tuple of dict) |
132 """ |
132 """ |
133 |
|
134 # Check type for py2: if not str it's unicode |
133 # Check type for py2: if not str it's unicode |
135 if sys.version_info[0] == 2: |
134 if sys.version_info[0] == 2: |
136 try: |
135 try: |
137 text = text.encode('utf-8') |
136 text = text.encode('utf-8') |
138 except UnicodeError: |
137 except UnicodeError: |
185 """ |
184 """ |
186 d = { |
185 d = { |
187 "name": str(item), |
186 "name": str(item), |
188 "type": getattr(item, "typ", ""), |
187 "type": getattr(item, "typ", ""), |
189 "file": getattr(item, "file", ""), |
188 "file": getattr(item, "file", ""), |
190 "line": getattr(item, "lineno", ""), |
189 "line": getattr(item, "lineno", ""), |
191 } |
190 } |
192 return d |
191 return d |
193 |
192 |
194 def getResults(self): |
193 def getResults(self): |
195 """ |
194 """ |
197 |
196 |
198 @return scan results |
197 @return scan results |
199 @rtype dict |
198 @rtype dict |
200 """ |
199 """ |
201 return { |
200 return { |
202 "DefinedAttributes": |
201 "DefinedAttributes": |
203 [self.__item2Dict(i) for i in self.defined_attrs], |
202 [self.__item2Dict(i) for i in self.defined_attrs], |
204 "DefinedFunctions": |
203 "DefinedFunctions": |
205 [self.__item2Dict(i) for i in self.defined_funcs], |
204 [self.__item2Dict(i) for i in self.defined_funcs], |
206 "DefinedSlots": |
205 "DefinedSlots": |
207 [self.__item2Dict(i) for i in self.defined_slots], |
206 [self.__item2Dict(i) for i in self.defined_slots], |
208 "DefinedProperties": |
207 "DefinedProperties": |
209 [self.__item2Dict(i) for i in self.defined_props], |
208 [self.__item2Dict(i) for i in self.defined_props], |
210 "DefinedVariables": |
209 "DefinedVariables": |
211 [self.__item2Dict(i) for i in self.defined_vars], |
210 [self.__item2Dict(i) for i in self.defined_vars], |
212 "UsedAttributes": |
211 "UsedAttributes": |
213 [self.__item2Dict(i) for i in self.used_attrs], |
212 [self.__item2Dict(i) for i in self.used_attrs], |
214 "UsedVariables": |
213 "UsedVariables": |
215 [self.__item2Dict(i) for i in self.used_vars], |
214 [self.__item2Dict(i) for i in self.used_vars], |
216 "TupleVariables": |
215 "TupleVariables": |
217 [self.__item2Dict(i) for i in self.tuple_assign_vars], |
216 [self.__item2Dict(i) for i in self.tuple_assign_vars], |
218 "Aliases": |
217 "Aliases": |
219 [self.__item2Dict(i) for i in self.names_imported_as_aliases], |
218 [self.__item2Dict(i) for i in self.names_imported_as_aliases], |
220 } |
219 } |