Skip to content

Commit

Permalink
Use pythonic comparisons with None
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Apr 25, 2024
1 parent e207df4 commit d518cfd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion paste/auth/digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _split_auth_string(auth_string):
prev = "%s,%s" % (prev, item)
continue
except AttributeError:
if prev == None:
if prev is None:
prev = item
continue
else:
Expand Down
4 changes: 2 additions & 2 deletions paste/errordocument.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def change_response(status, headers, exc_info=None):
self.global_conf,
**self.params
)
if not (new_url == None or isinstance(new_url, str)):
if not (new_url is None or isinstance(new_url, str)):
raise TypeError(
'Expected the url to internally '
'redirect to in the StatusBasedForward mapper'
Expand Down Expand Up @@ -311,7 +311,7 @@ def change_response(status, headers, exc_info=None):
self.global_conf,
self.kw
)
if not (new_url == None or isinstance(new_url, str)):
if not (new_url is None or isinstance(new_url, str)):
raise TypeError(
'Expected the url to internally '
'redirect to in the _StatusBasedRedirect error_mapper'
Expand Down
22 changes: 11 additions & 11 deletions paste/util/PySourceColor.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ def str2css(sourcestring, colors=None, title='',
linenumbers=0, form=None):
"""Converts a code string to colorized CSS/HTML. Returns CSS/HTML string
If form != None then this will return (stylesheet_str, code_str)
If form is not None then this will return (stylesheet_str, code_str)
colors=null,mono,lite,dark,dark2,idle,or pythonwin
"""
if markup.lower() not in ['css' ,'xhtml']:
Expand All @@ -936,7 +936,7 @@ def str2css(sourcestring, colors=None, title='',
linenumbers=linenumbers)
parse.format(form)
stringIO.seek(0)
if form != None:
if form is not None:
return parse._sendCSSStyle(external=1), stringIO.read()
else:
return None, stringIO.read()
Expand Down Expand Up @@ -969,7 +969,7 @@ def str2file(sourcestring, outfile, colors=None, title='',
f.writelines(html)
f.close()
#write css
if css != None and dosheet:
if css is not None and dosheet:
dir = os.path.dirname(outfile)
outcss = os.path.join(dir,'pystyle.css')
f = open(outcss,'wt')
Expand Down Expand Up @@ -1014,9 +1014,9 @@ def convert(source, outdir=None, colors=None,
# Then we need to colorize them with path2file
else:
fileList = walkdir(source)
if fileList != None:
if fileList is not None:
# make sure outdir is a dir
if outdir != None:
if outdir is not None:
if os.path.splitext(outdir)[1] != '':
outdir = os.path.split(outdir)[0]
for item in fileList:
Expand All @@ -1032,7 +1032,7 @@ def path2file(sourcePath, out=None, colors=None, show=0,
header=None, footer=None, linenumbers=0, count=1):
""" Converts python source to html file"""
# If no outdir is given we use the sourcePath
if out == None:#this is a guess
if out is None:#this is a guess
htmlPath = sourcePath + '.html'
else:
# If we do give an out_dir, and it does
Expand Down Expand Up @@ -1107,7 +1107,7 @@ def pageconvert(path, out=None, colors=lite, markup='xhtml', linenumbers=0,
that is written in a webpage enclosed in tags.
"""
if out == None:
if out is None:
out = os.path.dirname(path)
infile = open(path, 'r').read()
css,page = tagreplace(sourcestr=infile,colors=colors,
Expand Down Expand Up @@ -1219,7 +1219,7 @@ class Parser:
def __init__(self, raw, colors=None, title='', out=sys.stdout,
markup='html', header=None, footer=None, linenumbers=0):
"""Store the source text & set some flags"""
if colors == None:
if colors is None:
colors = defaultColors
self.raw = raw.expandtabs().rstrip()
self.title = os.path.basename(title)
Expand Down Expand Up @@ -1611,7 +1611,7 @@ def _doPageStart(self):
getattr(self, '_do%sStart'%(self.markup))()

def _doPageHeader(self):
if self.header != None:
if self.header is not None:
if self.header.find('#$#') != -1 or \
self.header.find('#$#') != -1 or \
self.header.find('#%#') != -1:
Expand All @@ -1622,7 +1622,7 @@ def _doPageHeader(self):
getattr(self, '_do%sHeader'%(self.markup))()

def _doPageFooter(self):
if self.footer != None:
if self.footer is not None:
if self.footer.find('#$#') != -1 or \
self.footer.find('#@#') != -1 or \
self.footer.find('#%#') != -1:
Expand Down Expand Up @@ -1859,7 +1859,7 @@ def _getCSSStyle(self, key):
if seperate_sides==0 and border:
style.append('border: %s %s;'%(border,size))
else:
if border == None:
if border is None:
border = 'solid'
if 'v' in tags:# bottom border
style.append('border-bottom:%s %s;'%(border,size))
Expand Down

0 comments on commit d518cfd

Please sign in to comment.