comparison roundup/cgi/templating.py @ 7023:ae6fa7b32e2d

flake8: E711 comparison to None should be 'if cond is not None:'
author John Rouillard <rouilj@ieee.org>
date Sun, 09 Oct 2022 17:40:14 -0400
parents f4bfc1af5d95
children bac315283a55
comparison
equal deleted inserted replaced
7022:f4bfc1af5d95 7023:ae6fa7b32e2d
583 The latter is xhtml. Recognize booleans by: 583 The latter is xhtml. Recognize booleans by:
584 value is None 584 value is None
585 Code can use None to indicate a pure boolean. 585 Code can use None to indicate a pure boolean.
586 ''' 586 '''
587 return ' '.join(['%s="%s"'%(k,html_escape(str(v), True)) 587 return ' '.join(['%s="%s"'%(k,html_escape(str(v), True))
588 if v != None else '%s'%(k) 588 if v is not None else '%s'%(k)
589 for k,v in sorted(attrs.items())]) 589 for k,v in sorted(attrs.items())])
590 590
591 591
592 def xhtml_cgi_escape_attrs(**attrs): 592 def xhtml_cgi_escape_attrs(**attrs):
593 ''' Boolean attributes like 'disabled', 'required' 593 ''' Boolean attributes like 'disabled', 'required'
597 The latter is html4 or 5. Recognize booleans by: 597 The latter is html4 or 5. Recognize booleans by:
598 value is None 598 value is None
599 Code can use None to indicate a pure boolean. 599 Code can use None to indicate a pure boolean.
600 ''' 600 '''
601 return ' '.join(['%s="%s"'%(k,html_escape(str(v), True)) 601 return ' '.join(['%s="%s"'%(k,html_escape(str(v), True))
602 if v != None else '%s="%s"'%(k,k) 602 if v is not None else '%s="%s"'%(k,k)
603 for k,v in sorted(attrs.items())]) 603 for k,v in sorted(attrs.items())])
604 604
605 605
606 def input_html4(**attrs): 606 def input_html4(**attrs):
607 """Generate an 'input' (html4) element with given attributes""" 607 """Generate an 'input' (html4) element with given attributes"""
3282 from the url. 3282 from the url.
3283 """ 3283 """
3284 q = urllib_.quote 3284 q = urllib_.quote
3285 sc = self.special_char 3285 sc = self.special_char
3286 l = ['%s=%s'%(k,is_us(v) and q(v) or v) 3286 l = ['%s=%s'%(k,is_us(v) and q(v) or v)
3287 for k,v in args.items() if v != None] 3287 for k,v in args.items() if v is not None]
3288 # pull out the special values (prefixed by @ or :) 3288 # pull out the special values (prefixed by @ or :)
3289 specials = {} 3289 specials = {}
3290 for key in args.keys(): 3290 for key in args.keys():
3291 if key[0] in '@:': 3291 if key[0] in '@:':
3292 specials[key[1:]] = args[key] 3292 specials[key[1:]] = args[key]

Roundup Issue Tracker: http://roundup-tracker.org/