From f15550f9fe2db8a9fe86fb89f28039aa5c46323b Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 23 Nov 2016 19:44:50 +1100 Subject: [PATCH] Special case dib-python in dib-lint It seems that on Xenial, it does not take much to confuse "file" and it's mime guessing such that it thinks some files are not python. "package-installs-v2" is a good example, since it has an interpreter "dib-python" that "file" doesn't know about, and no extension. While looking at this, I've added emacs vars here so it opens in python mode. Change-Id: I01994b08c5ad8987925f1eec4062f5b6ee72eb8f --- bin/dib-lint | 9 +++++++-- elements/package-installs/bin/package-installs-v2 | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/dib-lint b/bin/dib-lint index c58865e5..a8c10d4d 100755 --- a/bin/dib-lint +++ b/bin/dib-lint @@ -83,10 +83,15 @@ for i in $(find elements -type f \ error "$i is not executable" fi - # Ensure 4 spaces indent are used - if [[ "$(file -b -k --mime-type $i)" =~ "text/x-python" ]]; then + # run flake8 over python files. note our "dib-python" + # interpreter can confuse the magic matching being done in + # "file" and make it think the file is not python; + # special-case it. + if [[ "$(file -b -k --mime-type $i)" =~ "text/x-python" ]] || \ + [[ $firstline =~ "dib-python" ]]; then flake8 $i || error "$i failed flake8" else + # Ensure 4 spaces indent are used if ! excluded indent ; then indent_regex='^\( \{4\}\)* \{1,3\}[^ ]' if grep -q "$indent_regex" ${i}; then diff --git a/elements/package-installs/bin/package-installs-v2 b/elements/package-installs/bin/package-installs-v2 index f1814dd7..b4a4d0d8 100755 --- a/elements/package-installs/bin/package-installs-v2 +++ b/elements/package-installs/bin/package-installs-v2 @@ -101,3 +101,8 @@ def main(): if __name__ == '__main__': main() + +# Tell emacs to use python-mode +# Local variables: +# mode: python +# End: