Skip to content

Commit

Permalink
Add linting for Python 2 and 3
Browse files Browse the repository at this point in the history
This change adds pep8 linting for Python scripts and bashate linting
for shell scripts.

Signed-off-by: Nicolas Bock <[email protected]>
  • Loading branch information
nicolasbock committed Jan 30, 2022
1 parent b44bfb1 commit 412c2ec
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
7 changes: 0 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -691,13 +691,6 @@ else()
add_custom_target(dist)
endif()

include(FindPythonInterp)
if(NOT PYTHONINTERP_FOUND)
message(FATAL "Could not find Python interpreter")
endif()
configure_file(${PROJECT_SOURCE_DIR}/scripts/convert-template.in
${CMAKE_BINARY_DIR}/convert-template)

message(STATUS "When building executables with the bml library, please use the following link flags")

if(OPENMP_FOUND)
Expand Down
Empty file added scripts/__init__.py
Empty file.
20 changes: 9 additions & 11 deletions scripts/convert-template.in → scripts/convert_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

re_D = {}


def init_conversion(defs):
"""Initialize the regular expressions given a list of definitions.
"""
Expand All @@ -14,6 +15,7 @@ def init_conversion(defs):
continue
re_D[re.compile(tokens[0].strip())] = tokens[1].strip()


def convert_line(line, defs):
"""Convert a line given a list of definitions.
Expand All @@ -26,24 +28,23 @@ def convert_line(line, defs):
new_line = D.sub(re_D[D], new_line)
return new_line


def main():

import argparse

parser = argparse.ArgumentParser(description="This script acts in a very "
+ "similar way as the C preprocessor would. "
+ "It's just a lot simpler. :)")
parser = argparse.ArgumentParser(
description="This script acts in a very " +
"similar way as the C preprocessor would. " +
"It's just a lot simpler. :)")

parser.add_argument("SOURCE",
help="The Fortran source file")
parser.add_argument("SOURCE", help="The Fortran source file")

parser.add_argument("-o",
metavar="OUTPUT",
help="Write output to file OUTPUT")

parser.add_argument("-D",
help="Preprocessor macro",
action="append")
parser.add_argument("-D", help="Preprocessor macro", action="append")

options = parser.parse_args()

Expand All @@ -60,6 +61,3 @@ def main():
fd_out.write(convert_line(line, options.D) + "\n")
fd_out.close()
fd_in.close()

if __name__ == "__main__":
main()
11 changes: 11 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import setuptools

setuptools.setup(
name="bmlscripts",
version="0.1",
packages=setuptools.find_packages(),
entry_points={
"console_scripts": [
"convert-template = scripts.convert_template:main"
]}
)
14 changes: 14 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[tox]
envlist = py2, py3, lint

[testenv]
commands = python setup.py test

[testenv:lint]
deps =
pycodestyle
bashate
commands =
pycodestyle scripts
bashate \
build.sh scripts/indent.sh

0 comments on commit 412c2ec

Please sign in to comment.