[PATCH] import-checker: accept .pyc and .pyo files (issue4812)
Anton Shestakov
engored at ya.ru
Thu Sep 3 00:03:15 CDT 2015
03.09.2015, 04:17, "timeless at mozdev.org" <timeless at mozdev.org>:
> # HG changeset patch
> # User timeless at mozdev.org
> # Date 1441224455 14400
> # Wed Sep 02 16:07:35 2015 -0400
> # Node ID db4607bedf0785a1c49bdf53544cf8548fe4cac7
> # Parent f77a3f27cea533232dc107a72773e90e2de9549d
> import-checker: accept .pyc and .pyo files (issue4812)
>
> Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
> [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
>
> $ ls '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6'/BaseHTTPServer.py*
> /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.pyc
> /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.pyo
>
> diff --git a/contrib/import-checker.py b/contrib/import-checker.py
> --- a/contrib/import-checker.py
> +++ b/contrib/import-checker.py
> @@ -200,7 +200,10 @@
> for name in files:
> if name == '__init__.py':
> continue
> - if not (name.endswith('.py') or name.endswith('.so')
> + if not (name.endswith('.py')
> + or name.endswith('.so')
> + or name.endswith('.pyc')
> + or name.endswith('.pyo')
> or name.endswith('.pyd')):
This could be written like this:
if not name.endswith(('.py', '.so', '.pyc', '.pyo', '.pyd')):
since Python 2.5.
More information about the Mercurial-devel
mailing list