DataViews/CodeMetrics.py

changeset 45
9a18f4dbb493
parent 13
1af94a91f439
child 96
9624a110667d
equal deleted inserted replaced
44:fe5cd20cb0eb 45:9a18f4dbb493
209 209
210 @param filename name of the Python file to be analyzed (string) 210 @param filename name of the Python file to be analyzed (string)
211 @param total dictionary receiving the overall code statistics 211 @param total dictionary receiving the overall code statistics
212 @return a statistics object with the collected code statistics (SourceStat) 212 @return a statistics object with the collected code statistics (SourceStat)
213 """ 213 """
214 file = open(filename, 'r')
215 try: 214 try:
216 text = file.read() 215 text = Utilities.readEncodedFile(filename)[0]
217 finally: 216 except (UnicodeError, IOError):
218 file.close() 217 return SourceStat()
219 218
220 parser = Parser() 219 parser = Parser()
221 parser.parse(text) 220 parser.parse(text)
222 221
223 stats = SourceStat() 222 stats = SourceStat()

eric ide

mercurial