Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-01-26 04:23:15 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-01-26 04:23:15 +0300
commit7980265e7e509f5d9c9ed0f281c67d0662d4f464 (patch)
treeae0c530d26a4b4d94b7bdae141f41f64fd064fa9 /tests/python/pep8.py
parent65d40b3eeb8bd92ec74a2c3c03c73a331dccf668 (diff)
Tests: replace os.system w/ subprocess.call
Saves on process creation and avoids being tripped up by command line parsing. Based on D2967 by @ldo with edits.
Diffstat (limited to 'tests/python/pep8.py')
-rw-r--r--tests/python/pep8.py148
1 files changed, 87 insertions, 61 deletions
diff --git a/tests/python/pep8.py b/tests/python/pep8.py
index dde4250f6aa..ebf2c5eabb7 100644
--- a/tests/python/pep8.py
+++ b/tests/python/pep8.py
@@ -19,6 +19,8 @@
# <pep8-80 compliant>
import os
+import subprocess
+import shutil
# depends on pep8, frosted, pylint
# for Ubuntu
@@ -71,6 +73,79 @@ def is_pep8(path):
return 0
+def check_files_flake8(files):
+ print("\n\n\n# running flake8...")
+
+ # these are very picky and often hard to follow
+ # while keeping common script formatting.
+ ignore = (
+ "E122",
+ "E123",
+ "E124",
+ "E125",
+ "E126",
+ "E127",
+ "E128",
+ # "imports not at top of file."
+ # prefer to load as needed (lazy load addons etc).
+ "E402",
+ # "do not compare types, use 'isinstance()'"
+ # times types are compared,
+ # I rather keep them specific
+ "E721",
+ )
+
+ for f, pep8_type in files:
+
+ if pep8_type == 1:
+ # E501:80 line length
+ ignore_tmp = ignore + ("E501", )
+ else:
+ ignore_tmp = ignore
+
+ subprocess.call((
+ "flake8",
+ "--isolated",
+ "--ignore=%s" % ",".join(ignore_tmp),
+ f,
+ ))
+
+
+def check_files_frosted(files):
+ print("\n\n\n# running frosted...")
+ for f, pep8_type in files:
+ subprocess.call(("frosted", f))
+
+
+def check_files_pylint(files):
+ print("\n\n\n# running pylint...")
+ for f, pep8_type in files:
+ # let pep8 complain about line length
+ subprocess.call((
+ "pylint",
+ "--disable="
+ "C0111," # missing doc string
+ "C0103," # invalid name
+ "C0413," # import should be placed at the top
+ "W0613," # unused argument, may add this back
+ # but happens a lot for 'context' for eg.
+ "W0232," # class has no __init__, Operator/Panel/Menu etc
+ "W0142," # Used * or ** magic
+ # even needed in some cases
+ "R0902," # Too many instance attributes
+ "R0903," # Too many statements
+ "R0911," # Too many return statements
+ "R0912," # Too many branches
+ "R0913," # Too many arguments
+ "R0914," # Too many local variables
+ "R0915,", # Too many statements
+ "--output-format=parseable",
+ "--reports=n",
+ "--max-line-length=1000",
+ f,
+ ))
+
+
def main():
files = []
files_skip = []
@@ -113,70 +188,21 @@ def main():
print("%s:%d:0: empty class (), remove" % (f, i + 1))
del re, class_check
- print("\n\n\n# running flake8...")
-
- # these are very picky and often hard to follow
- # while keeping common script formatting.
- ignore = (
- "E122",
- "E123",
- "E124",
- "E125",
- "E126",
- "E127",
- "E128",
- # "imports not at top of file."
- # prefer to load as needed (lazy load addons etc).
- "E402",
- # "do not compare types, use 'isinstance()'"
- # times types are compared,
- # I rather keep them specific
- "E721",
- )
-
- for f, pep8_type in files:
-
- if pep8_type == 1:
- # E501:80 line length
- ignore_tmp = ignore + ("E501", )
- else:
- ignore_tmp = ignore
+ if shutil.which("flake8"):
+ check_files_flake8(files)
+ else:
+ print("Skipping flake8 checks (command not found)")
- os.system("flake8 "
- "--isolated "
- "--ignore=%s '%s'" %
- (",".join(ignore_tmp), f))
+ if shutil.which("frosted"):
+ check_files_frosted(files)
+ else:
+ print("Skipping frosted checks (command not found)")
- # frosted
- print("\n\n\n# running frosted...")
- for f, pep8_type in files:
- os.system("frosted '%s'" % f)
+ if shutil.which("pylint"):
+ check_files_pylint(files)
+ else:
+ print("Skipping pylint checks (command not found)")
- print("\n\n\n# running pylint...")
- for f, pep8_type in files:
- # let pep8 complain about line length
- os.system("pylint "
- "--disable="
- "C0111," # missing doc string
- "C0103," # invalid name
- "C0413," # import should be placed at the top
- "W0613," # unused argument, may add this back
- # but happens a lot for 'context' for eg.
- "W0232," # class has no __init__, Operator/Panel/Menu etc
- "W0142," # Used * or ** magic
- # even needed in some cases
- "R0902," # Too many instance attributes
- "R0903," # Too many statements
- "R0911," # Too many return statements
- "R0912," # Too many branches
- "R0913," # Too many arguments
- "R0914," # Too many local variables
- "R0915," # Too many statements
- " "
- "--output-format=parseable "
- "--reports=n "
- "--max-line-length=1000"
- " '%s'" % f)
if __name__ == "__main__":