@@ -62,7 +62,6 @@ def escapeURL(url):
62
62
return url
63
63
64
64
import feedvalidator .formatter .text_html
65
- import feedvalidator .formatter .text_ucn
66
65
67
66
def buildCodeListing (events , rawdata , url ):
68
67
# print feed
@@ -78,7 +77,7 @@ def buildCodeListing(events, rawdata, url):
78
77
codelisting = "" .join (codelines )
79
78
return applyTemplate ('code_listing.tmpl' , {"codelisting" :codelisting , "url" :escapeURL (url )})
80
79
81
- def yieldEventList (output , unicorn = 0 ):
80
+ def yieldEventList (output ):
82
81
errors , warnings = output .getErrors (), output .getWarnings ()
83
82
84
83
yield output .header ()
@@ -87,37 +86,26 @@ def yieldEventList(output, unicorn=0):
87
86
if errors and warnings :
88
87
yield output .footer ()
89
88
if len (warnings ) == 1 :
90
- if unicorn :
91
- yield applyTemplate ('andwarn1_ucn.tmpl' )
92
- else :
93
- yield applyTemplate ('andwarn1.tmpl' )
89
+ yield applyTemplate ('andwarn1.tmpl' )
94
90
else :
95
- if unicorn :
96
- yield applyTemplate ('andwarn2_ucn.tmpl' )
97
- else :
98
- yield applyTemplate ('andwarn2.tmpl' )
91
+ yield applyTemplate ('andwarn2.tmpl' )
99
92
yield output .header ()
100
93
for o in output .getWarnings ():
101
94
yield o
102
95
yield output .footer ()
103
96
104
97
from feedvalidator .formatter .text_html import Formatter
105
- from feedvalidator .formatter .text_ucn import Formatter as UCNFormatter
106
98
107
- def postvalidate (url , events , rawdata , feedType , autofind = 1 , firstOccurrenceOnly = 1 , unicornFormatter = 0 ):
99
+ def postvalidate (url , events , rawdata , feedType , autofind = 1 , firstOccurrenceOnly = 1 ):
108
100
"""returns dictionary including 'url', 'events', 'rawdata', 'output', 'specialCase', 'feedType'"""
109
101
# filter based on compatibility level
110
102
from feedvalidator import compatibility
111
103
filterFunc = compatibility .AA # hardcoded for now
112
104
events = filterFunc (events )
113
105
114
106
specialCase = None
115
- if not unicornFormatter :
116
- groupEvents = 0
117
- formattedOutput = Formatter (events , rawdata )
118
- else :
119
- groupEvents = 1
120
- formattedOutput = UCNFormatter (events , rawdata )
107
+ groupEvents = 0
108
+ formattedOutput = Formatter (events , rawdata )
121
109
if formattedOutput :
122
110
# check for special cases
123
111
specialCase = compatibility .analyze (events , rawdata )
@@ -134,7 +122,7 @@ def postvalidate(url, events, rawdata, feedType, autofind=1, firstOccurrenceOnly
134
122
events = params ['loggedEvents' ]
135
123
rawdata = params ['rawdata' ]
136
124
feedType = params ['feedType' ]
137
- return postvalidate (url , events , rawdata , feedType , 0 , firstOccurrenceOnly , unicornFormatter )
125
+ return postvalidate (url , events , rawdata , feedType , 0 , firstOccurrenceOnly )
138
126
except :
139
127
pass
140
128
@@ -228,92 +216,6 @@ def checker_app(environ, start_response):
228
216
yield applyTemplate ('fault.tmpl' , {'code' :sys .exc_info ()[0 ],
229
217
'string' :sys .exc_info ()[1 ], 'traceback' :xmlEncode (tb )})
230
218
231
- elif (output_option == "ucn" ):
232
- start_response ('200 OK' , [('Content-type' , 'application/xml; charset=' + ENCODING )])
233
-
234
- if url :
235
- # validate
236
- goon = 0
237
- url = sanitizeURL (url )
238
- try :
239
- params = feedvalidator .validateURL (url , firstOccurrenceOnly = 0 , wantRawData = 1 , groupEvents = 1 )
240
- events = params ['loggedEvents' ]
241
- rawdata = params ['rawdata' ]
242
- feedType = params ['feedType' ]
243
- goon = 1
244
- except ValidationFailure as vfv :
245
- yield applyTemplate ('header_ucn.tmpl' , {'url' :escapeURL (url )})
246
- output = UCNFormatter ([vfv .event ], None )
247
- for item in yieldEventList (output , 1 ):
248
- yield item
249
- yield applyTemplate ('error_ucn.tmpl' )
250
- except :
251
- yield applyTemplate ('header_ucn.tmpl' , {'url' :escapeURL (url )})
252
- yield applyTemplate ('error_ucn.tmpl' )
253
- if goon :
254
- # post-validate (will do RSS autodiscovery if needed)
255
- validationData = postvalidate (url , events , rawdata , feedType , autofind = 1 , firstOccurrenceOnly = 0 , unicornFormatter = 1 )
256
-
257
- # write output header
258
- url = validationData ['url' ]
259
- feedType = validationData ['feedType' ]
260
- rawdata = validationData ['rawdata' ]
261
-
262
- htmlUrl = escapeURL (urllib .parse .quote (url ))
263
- try :
264
- htmlUrl = htmlUrl .encode ('idna' ).decode ('utf-8' )
265
- except :
266
- pass
267
- docType = 'feed'
268
- if feedType == TYPE_ATOM_ENTRY : docType = 'entry'
269
- if feedType == TYPE_XRD : docType = 'document'
270
- if feedType == TYPE_APP_CATEGORIES : docType = 'Document'
271
- if feedType == TYPE_APP_SERVICE : docType = 'Document'
272
- if feedType == TYPE_OPENSEARCH : docType = 'description document'
273
-
274
- yield applyTemplate ('header_ucn.tmpl' , {'url' :escapeURL (url )})
275
-
276
- output = validationData .get ('output' , None )
277
-
278
- # print special case, if any
279
- specialCase = validationData .get ('specialCase' , None )
280
- if specialCase :
281
- yield applyTemplate ('%s_ucn.tmpl' % specialCase )
282
-
283
- msc = output .mostSeriousClass ()
284
-
285
- # Explain the overall verdict
286
- if msc == Error :
287
- from feedvalidator .logging import ObsoleteNamespace
288
- if len (output .getErrors ())== 1 and \
289
- isinstance (output .data [0 ],ObsoleteNamespace ):
290
- yield applyTemplate ('notsupported_ucn.tmpl' )
291
- elif specialCase != 'html' :
292
- yield applyTemplate ('invalid_ucn.tmpl' )
293
- else :
294
- yield applyTemplate ('congrats_ucn.tmpl' , {"feedType" :FEEDTYPEDISPLAY [feedType ], "graphic" :VALIDFEEDGRAPHIC [feedType ], "HOMEPATH" :HOMEPATH , "docType" :docType })
295
- if msc == Warning :
296
- yield applyTemplate ('warning_ucn.tmpl' )
297
- elif msc == Info :
298
- yield applyTemplate ('info_ucn.tmpl' )
299
-
300
- # Print any issues, whether or not the overall feed is valid
301
- if output :
302
- if specialCase != 'html' :
303
- for item in yieldEventList (output , 1 ):
304
- yield item
305
-
306
- # As long as there were no errors, show that the feed is valid
307
- if msc != Error :
308
- # valid
309
- yield applyTemplate ('valid_ucn.tmpl' , {"url" :htmlUrl , "srcUrl" :htmlUrl , "feedType" :FEEDTYPEDISPLAY [feedType ], "graphic" :VALIDFEEDGRAPHIC [feedType ], "HOMEURL" :HOMEURL , "HOMEPATH" :HOMEPATH , "docType" :docType })
310
- else :
311
- # nothing to validate, just write basic form
312
- yield applyTemplate ('header_ucn.tmpl' , {'url' :'http://www.w3.org' })
313
- yield applyTemplate ('special_ucn.tmpl' , {})
314
-
315
- yield applyTemplate ('footer_ucn.tmpl' )
316
-
317
219
else :
318
220
start_response ('200 OK' , [('Content-type' , 'text/html; charset=' + ENCODING )])
319
221
0 commit comments