mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
refactor: pycode: do not call endswith twice
This commit is contained in:
parent
69d67e7050
commit
df31bc3ac8
@ -56,12 +56,11 @@ class ModuleAnalyzer:
|
||||
# all methods for getting filename failed, so raise...
|
||||
raise PycodeError('no source found for module %r' % modname)
|
||||
filename = path.normpath(path.abspath(filename))
|
||||
lfilename = filename.lower()
|
||||
if lfilename.endswith('.pyo') or lfilename.endswith('.pyc'):
|
||||
if filename.lower().endswith(('.pyo', '.pyc')):
|
||||
filename = filename[:-1]
|
||||
if not path.isfile(filename) and path.isfile(filename + 'w'):
|
||||
filename += 'w'
|
||||
elif not (lfilename.endswith('.py') or lfilename.endswith('.pyw')):
|
||||
elif not filename.lower().endswith(('.py', '.pyw')):
|
||||
raise PycodeError('source is not a .py file: %r' % filename)
|
||||
elif ('.egg' + path.sep) in filename:
|
||||
pat = '(?<=\\.egg)' + re.escape(path.sep)
|
||||
|
Loading…
Reference in New Issue
Block a user