mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
ac1698099d
* Remove unnecessary sys.exit calls. * Add files filtering for code-smell tests. * Enhance test-constraints code-smell test. * Simplify compile sanity test. * Pass paths to importer on stdin. * Pass paths to yamllinter on stdin. * Add work-around for unicode path filtering. * Enhance configure-remoting-ps1 code-smell test. * Enhance integration-aliases code-smell test. * Enhance azure-requirements code-smell test. * Enhance no-illegal-filenames code-smell test.
28 lines
677 B
Python
Executable file
28 lines
677 B
Python
Executable file
#!/usr/bin/env python
|
|
"""Python syntax checker with lint friendly output."""
|
|
|
|
import parser
|
|
import sys
|
|
|
|
|
|
def main():
|
|
status = 0
|
|
|
|
for path in sys.argv[1:] or sys.stdin.read().splitlines():
|
|
with open(path, 'r') as source_fd:
|
|
source = source_fd.read()
|
|
|
|
try:
|
|
parser.suite(source)
|
|
except SyntaxError:
|
|
ex_type, ex, ex_traceback = sys.exc_info()
|
|
status = 1
|
|
message = ex.text.splitlines()[0].strip()
|
|
sys.stdout.write("%s:%d:%d: SyntaxError: %s\n" % (path, ex.lineno, ex.offset, message))
|
|
sys.stdout.flush()
|
|
|
|
sys.exit(status)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|