Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: sitescripts/reports/bin/parseNewReports.py

Issue 8625042: Reports - user usefullness (Closed)
Left Patch Set: Created Oct. 18, 2012, 1:17 p.m.
Right Patch Set: Reports - user usefulness Created Oct. 29, 2012, 12:35 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « sitescripts/reports/bin/mailDigests.py ('k') | sitescripts/reports/bin/updateDigests.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This Source Code is subject to the terms of the Mozilla Public License 3 # This Source Code is subject to the terms of the Mozilla Public License
4 # version 2.0 (the "License"). You can obtain a copy of the License at 4 # version 2.0 (the "License"). You can obtain a copy of the License at
5 # http://mozilla.org/MPL/2.0/. 5 # http://mozilla.org/MPL/2.0/.
6 6
7 import os, sys, re, marshal, codecs 7 import os, sys, re, marshal, codecs
8 from urlparse import urlparse 8 from urlparse import urlparse
9 from time import time 9 from time import time
10 from xml.parsers.expat import ParserCreate, ExpatError, ErrorString 10 from xml.parsers.expat import ParserCreate, ExpatError, ErrorString
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 executeQuery(cursor, 60 executeQuery(cursor,
61 '''SELECT guid FROM #PFX#reports WHERE guid = %s''', 61 '''SELECT guid FROM #PFX#reports WHERE guid = %s''',
62 (guid)) 62 (guid))
63 report = cursor.fetchone() 63 report = cursor.fetchone()
64 64
65 if report != None: 65 if report != None:
66 os.remove(xmlFile) 66 os.remove(xmlFile)
67 return 67 return
68 68
69 source = open(xmlFile, 'rb') 69 source = open(xmlFile, 'rb')
70 reportData = {'status': '', 'utility': 0, 'warnings': {}, 'requests': [], 'fil ters': [], 'subscriptions': [], 'extensions': [], 'errors': [], 'time': time()} 70 reportData = {'status': '', 'usefulness': 0, 'warnings': {}, 'requests': [], ' filters': [], 'subscriptions': [], 'extensions': [], 'errors': [], 'time': time( )}
71 tagStack = [] 71 tagStack = []
72 72
73 parser = ParserCreate() 73 parser = ParserCreate()
74 parser.StartElementHandler = processElementStart 74 parser.StartElementHandler = processElementStart
75 parser.EndElementHandler = processElementEnd 75 parser.EndElementHandler = processElementEnd
76 parser.CharacterDataHandler = processText 76 parser.CharacterDataHandler = processText
77 try: 77 try:
78 parser.ParseFile(source) 78 parser.ParseFile(source)
79 except ExpatError, error: 79 except ExpatError, error:
80 reportData['warnings']['!parsing'] = 'Parsing error in the report: %s at lin e %i column %i' % (ErrorString(error.code), error.lineno, error.offset) 80 reportData['warnings']['!parsing'] = 'Parsing error in the report: %s at lin e %i column %i' % (ErrorString(error.code), error.lineno, error.offset)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 reportData['warnings'][itemPath] = 'Field %s exceeded length limit a nd was truncated' % itemPath 262 reportData['warnings'][itemPath] = 'Field %s exceeded length limit a nd was truncated' % itemPath
263 elif isinstance(data[key], basestring): 263 elif isinstance(data[key], basestring):
264 limit = lengthRestrictions.get(keyPath, lengthRestrictions['default_string ']) 264 limit = lengthRestrictions.get(keyPath, lengthRestrictions['default_string '])
265 if len(data[key]) > limit: 265 if len(data[key]) > limit:
266 data[key] = data[key][0:limit] + u'…' 266 data[key] = data[key][0:limit] + u'…'
267 reportData['warnings'][keyPath] = 'Field %s exceeded length limit and wa s truncated' % keyPath 267 reportData['warnings'][keyPath] = 'Field %s exceeded length limit and wa s truncated' % keyPath
268 268
269 if __name__ == '__main__': 269 if __name__ == '__main__':
270 setupStderr() 270 setupStderr()
271 scanReports(get_config().get('reports', 'dataPath')) 271 scanReports(get_config().get('reports', 'dataPath'))
LEFTRIGHT

Powered by Google App Engine
This is Rietveld