From 06e0020f6bdaaf8ba2e306e0d57fc81b4c94c3bc Mon Sep 17 00:00:00 2001 From: "Ben R. Ryan" Date: Fri, 6 Aug 2021 08:59:19 -0600 Subject: [PATCH 1/8] Bad python for commit test --- src/mesh/python/x3d_generator.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mesh/python/x3d_generator.py b/src/mesh/python/x3d_generator.py index 98e82269c..552916f01 100755 --- a/src/mesh/python/x3d_generator.py +++ b/src/mesh/python/x3d_generator.py @@ -16,7 +16,15 @@ # -- create argument parser parser = argparse.ArgumentParser(description='Generate X3D mesh file.') -parser.add_argument('-mt', '--mesh_type', type=str, default='orth_2d_mesh', +parser.add_argument('-mt', + + + + + + + +'--mesh_type', type=str, default='orth_2d_mesh', help='Select mesh type.') parser.add_argument('-nd', '--num_per_dim', type=int, nargs='+', default=[1, 1], help='Number of cells per dimension.') From d744b28d8111090e69949e40904719cf3fb8f641 Mon Sep 17 00:00:00 2001 From: "Ben R. Ryan" Date: Fri, 6 Aug 2021 09:05:45 -0600 Subject: [PATCH 2/8] ? --- src/mesh/python/x3d_generator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesh/python/x3d_generator.py b/src/mesh/python/x3d_generator.py index 552916f01..3db456bf8 100755 --- a/src/mesh/python/x3d_generator.py +++ b/src/mesh/python/x3d_generator.py @@ -24,6 +24,7 @@ + '--mesh_type', type=str, default='orth_2d_mesh', help='Select mesh type.') parser.add_argument('-nd', '--num_per_dim', type=int, nargs='+', default=[1, 1], From 18f4d47bc91c9f3020f6250aad79990743d6d656 Mon Sep 17 00:00:00 2001 From: "Ben R. Ryan" Date: Fri, 6 Aug 2021 10:29:10 -0600 Subject: [PATCH 3/8] Add autopep8 --- environment/git/install-hooks.sh | 2 +- environment/git/pre-commit | 2 ++ environment/git/pre-commit-autopep8 | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 environment/git/pre-commit-autopep8 diff --git a/environment/git/install-hooks.sh b/environment/git/install-hooks.sh index 2db431b63..c1ef038c7 100755 --- a/environment/git/install-hooks.sh +++ b/environment/git/install-hooks.sh @@ -13,7 +13,7 @@ ########################################################### # CONFIGURATION: # select which pre-commit hooks are going to be installed -HOOKS="pre-commit pre-commit-clang-format pre-commit-flake8 pre-commit-fprettify" +HOOKS="pre-commit pre-commit-clang-format pre-commit-autopep8 pre-commit-flake8 pre-commit-fprettify" HOOKS="$HOOKS pre-commit-cmake-format pre-commit-cmake-lint" TOOLS="common.sh" ########################################################### diff --git a/environment/git/pre-commit b/environment/git/pre-commit index 2494e2cea..573435e47 100755 --- a/environment/git/pre-commit +++ b/environment/git/pre-commit @@ -16,6 +16,8 @@ # the order in which they are listed. HOOKS="pre-commit-clang-format" +# only run autopep8 if the tool is available +[[ $(which autopep8 2> /dev/null | wc -w) -gt 0 ]] && HOOKS+=" pre-commit-autopep8" # only run flake8 if the tool is available. [[ $(which flake8 2> /dev/null | wc -w) -gt 0 ]] && HOOKS+=" pre-commit-flake8" # only run cmake-format if the tool is available. diff --git a/environment/git/pre-commit-autopep8 b/environment/git/pre-commit-autopep8 new file mode 100755 index 000000000..21a6cb98d --- /dev/null +++ b/environment/git/pre-commit-autopep8 @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +import os +import subprocess + +if __name__ == '__main__': + output = subprocess.run(['git', 'rev-parse', '--show-toplevel'], capture_output=True) + base_dir = output.stdout.decode('utf-8').strip() + output = subprocess.run(['git', 'status', '--porcelain'], capture_output=True) + all_files = output.stdout.decode('utf-8') + modified_files = [] + for line in all_files.split('\n'): + if 'A' in line[0:2] or 'M' in line[0:2]: + modified_files.append(os.path.join(base_dir, line[2:].strip())) + + for filename in modified_files: + autopep8_call = ['autopep8', '--in-place', filename] + subprocess.call(autopep8_call) + subprocess.call(['git', 'add', filename]) From a8381bc3280af18632ceb084d7e495662fa56614 Mon Sep 17 00:00:00 2001 From: "Ben R. Ryan" Date: Fri, 6 Aug 2021 10:29:47 -0600 Subject: [PATCH 4/8] Cleanup --- src/mesh/python/x3d_generator.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/mesh/python/x3d_generator.py b/src/mesh/python/x3d_generator.py index 3db456bf8..98e82269c 100755 --- a/src/mesh/python/x3d_generator.py +++ b/src/mesh/python/x3d_generator.py @@ -16,16 +16,7 @@ # -- create argument parser parser = argparse.ArgumentParser(description='Generate X3D mesh file.') -parser.add_argument('-mt', - - - - - - - - -'--mesh_type', type=str, default='orth_2d_mesh', +parser.add_argument('-mt', '--mesh_type', type=str, default='orth_2d_mesh', help='Select mesh type.') parser.add_argument('-nd', '--num_per_dim', type=int, nargs='+', default=[1, 1], help='Number of cells per dimension.') From 07b9518e49649308147858be85f30a89b4ac9864 Mon Sep 17 00:00:00 2001 From: "Ben R. Ryan" Date: Fri, 6 Aug 2021 10:30:01 -0600 Subject: [PATCH 5/8] bad formatting --- src/mesh/python/x3d_generator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesh/python/x3d_generator.py b/src/mesh/python/x3d_generator.py index 98e82269c..3c41ca748 100755 --- a/src/mesh/python/x3d_generator.py +++ b/src/mesh/python/x3d_generator.py @@ -16,7 +16,8 @@ # -- create argument parser parser = argparse.ArgumentParser(description='Generate X3D mesh file.') -parser.add_argument('-mt', '--mesh_type', type=str, default='orth_2d_mesh', +parser.add_argument('-mt', + '--mesh_type', type=str, default='orth_2d_mesh', help='Select mesh type.') parser.add_argument('-nd', '--num_per_dim', type=int, nargs='+', default=[1, 1], help='Number of cells per dimension.') From d0df4d9d6c8949fa8fc5b7caefb689ade30085dd Mon Sep 17 00:00:00 2001 From: "Ben R. Ryan" Date: Fri, 6 Aug 2021 10:30:50 -0600 Subject: [PATCH 6/8] testing again --- src/mesh/python/x3d_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/python/x3d_generator.py b/src/mesh/python/x3d_generator.py index 3c41ca748..c38ebee95 100755 --- a/src/mesh/python/x3d_generator.py +++ b/src/mesh/python/x3d_generator.py @@ -17,7 +17,7 @@ parser = argparse.ArgumentParser(description='Generate X3D mesh file.') parser.add_argument('-mt', - '--mesh_type', type=str, default='orth_2d_mesh', + '--mesh_type', type=str, default='orth_2d_mesh', help='Select mesh type.') parser.add_argument('-nd', '--num_per_dim', type=int, nargs='+', default=[1, 1], help='Number of cells per dimension.') From dc4e775b0e30b5295747086879287ed62083784f Mon Sep 17 00:00:00 2001 From: "Ben R. Ryan" Date: Fri, 6 Aug 2021 10:31:03 -0600 Subject: [PATCH 7/8] One more test --- src/mesh/python/x3d_generator.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mesh/python/x3d_generator.py b/src/mesh/python/x3d_generator.py index c38ebee95..a46a8d5a0 100755 --- a/src/mesh/python/x3d_generator.py +++ b/src/mesh/python/x3d_generator.py @@ -16,8 +16,7 @@ # -- create argument parser parser = argparse.ArgumentParser(description='Generate X3D mesh file.') -parser.add_argument('-mt', - '--mesh_type', type=str, default='orth_2d_mesh', +parser.add_argument('-mt', '--mesh_type', type=str, default='orth_2d_mesh', help='Select mesh type.') parser.add_argument('-nd', '--num_per_dim', type=int, nargs='+', default=[1, 1], help='Number of cells per dimension.') From a376c6c516626995c485a90a08db6b0e6945a93d Mon Sep 17 00:00:00 2001 From: "Ben R. Ryan" Date: Fri, 6 Aug 2021 10:31:27 -0600 Subject: [PATCH 8/8] That test didnt work for flake8 anyway --- src/mesh/python/x3d_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/python/x3d_generator.py b/src/mesh/python/x3d_generator.py index a46a8d5a0..98e82269c 100755 --- a/src/mesh/python/x3d_generator.py +++ b/src/mesh/python/x3d_generator.py @@ -16,7 +16,7 @@ # -- create argument parser parser = argparse.ArgumentParser(description='Generate X3D mesh file.') -parser.add_argument('-mt', '--mesh_type', type=str, default='orth_2d_mesh', +parser.add_argument('-mt', '--mesh_type', type=str, default='orth_2d_mesh', help='Select mesh type.') parser.add_argument('-nd', '--num_per_dim', type=int, nargs='+', default=[1, 1], help='Number of cells per dimension.')