@@ -62,7 +62,6 @@ def escapeURL(url):
6262      return  url 
6363
6464import  feedvalidator .formatter .text_html 
65- import  feedvalidator .formatter .text_ucn 
6665
6766def  buildCodeListing (events , rawdata , url ):
6867    # print feed 
@@ -78,7 +77,7 @@ def buildCodeListing(events, rawdata, url):
7877    codelisting  =  "" .join (codelines )
7978    return  applyTemplate ('code_listing.tmpl' , {"codelisting" :codelisting , "url" :escapeURL (url )})
8079
81- def  yieldEventList (output ,  unicorn = 0 ):
80+ def  yieldEventList (output ):
8281  errors , warnings  =  output .getErrors (), output .getWarnings ()
8382
8483  yield  output .header ()
@@ -87,37 +86,26 @@ def yieldEventList(output, unicorn=0):
8786  if  errors  and  warnings :
8887    yield  output .footer ()
8988    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' )
9490    else :
95-       if  unicorn :
96-         yield  applyTemplate ('andwarn2_ucn.tmpl' )
97-       else :
98-         yield  applyTemplate ('andwarn2.tmpl' )
91+       yield  applyTemplate ('andwarn2.tmpl' )
9992    yield  output .header ()
10093  for  o  in  output .getWarnings ():
10194    yield  o 
10295  yield  output .footer ()
10396
10497from  feedvalidator .formatter .text_html  import  Formatter 
105- from  feedvalidator .formatter .text_ucn  import  Formatter  as  UCNFormatter 
10698
107- def  postvalidate (url , events , rawdata , feedType , autofind = 1 , firstOccurrenceOnly = 1 ,  unicornFormatter = 0 ):
99+ def  postvalidate (url , events , rawdata , feedType , autofind = 1 , firstOccurrenceOnly = 1 ):
108100    """returns dictionary including 'url', 'events', 'rawdata', 'output', 'specialCase', 'feedType'""" 
109101    # filter based on compatibility level 
110102    from  feedvalidator  import  compatibility 
111103    filterFunc  =  compatibility .AA  # hardcoded for now 
112104    events  =  filterFunc (events )
113105
114106    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 )
121109    if  formattedOutput :
122110        # check for special cases 
123111        specialCase  =  compatibility .analyze (events , rawdata )
@@ -134,7 +122,7 @@ def postvalidate(url, events, rawdata, feedType, autofind=1, firstOccurrenceOnly
134122                    events  =  params ['loggedEvents' ]
135123                    rawdata  =  params ['rawdata' ]
136124                    feedType  =  params ['feedType' ]
137-                     return  postvalidate (url , events , rawdata , feedType , 0 , firstOccurrenceOnly ,  unicornFormatter )
125+                     return  postvalidate (url , events , rawdata , feedType , 0 , firstOccurrenceOnly )
138126            except :
139127                pass 
140128
@@ -228,92 +216,6 @@ def checker_app(environ, start_response):
228216            yield  applyTemplate ('fault.tmpl' , {'code' :sys .exc_info ()[0 ],
229217              'string' :sys .exc_info ()[1 ], 'traceback' :xmlEncode (tb )})
230218
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- 
317219    else :
318220        start_response ('200 OK' , [('Content-type' , 'text/html; charset='  +  ENCODING )])
319221
0 commit comments