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
This commit is contained in:
parent
09cab0fa65
commit
f15550f9fe
@ -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
|
||||
|
@ -101,3 +101,8 @@ def main():
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
# Tell emacs to use python-mode
|
||||
# Local variables:
|
||||
# mode: python
|
||||
# End:
|
||||
|
Loading…
Reference in New Issue
Block a user