SELinux Archive on lore.kernel.org
 help / Atom feed
* [PATCH 1/1] scripts/run-flake8: run on Python scripts not ending with .py
@ 2019-01-05 15:59 Nicolas Iooss
  2019-01-08 13:11 ` Petr Lautrbach
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Iooss @ 2019-01-05 15:59 UTC (permalink / raw)
  To: selinux

When running flake8 on a directory, it does not analyze files without an
extension, like semanage_migrate_store, mlscolor-test, etc. Use grep to
find files with a Python shebang and build a list which is then given to
flake8.

This commit is possible now that some clean-up patches have been
applied, such as commit 69c56bd2f6e9 ("python/chcat: improve the code
readability") and b7227aaec1da ("mcstrans: fix Python linter warnings on
test scripts") and 3cb974d2d2a7 ("semanage_migrate_store: fix many
Python linter warnings").

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 scripts/run-flake8 | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/run-flake8 b/scripts/run-flake8
index 6ad029fa6852..24b1202fde99 100755
--- a/scripts/run-flake8
+++ b/scripts/run-flake8
@@ -4,6 +4,11 @@
 # Run on the base directory if no argument has been given
 if [ $# -eq 0 ] ; then
     cd "$(dirname -- "$0")/.." || exit $?
+
+    # Run on both files ending with .py and Python files without extension
+    # shellcheck disable=SC2046
+    set -- $( (find . -name '*.py' ; grep --exclude-dir=.git -l -e '^#!\s*/usr/bin/python' -e '^#!/usr/bin/env python' -r .) | sort -u )
+    echo "Analyzing $# Python scripts"
 fi
 
 # Assign each ignore warning on a line, in order to ease testing enabling the warning again
-- 
2.20.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] scripts/run-flake8: run on Python scripts not ending with .py
  2019-01-05 15:59 [PATCH 1/1] scripts/run-flake8: run on Python scripts not ending with .py Nicolas Iooss
@ 2019-01-08 13:11 ` Petr Lautrbach
  2019-01-09 12:19   ` Petr Lautrbach
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Lautrbach @ 2019-01-08 13:11 UTC (permalink / raw)
  To: selinux; +Cc: Nicolas Iooss

Nicolas Iooss <nicolas.iooss@m4x.org> writes:

> When running flake8 on a directory, it does not analyze files without an
> extension, like semanage_migrate_store, mlscolor-test, etc. Use grep to
> find files with a Python shebang and build a list which is then given to
> flake8.
>
> This commit is possible now that some clean-up patches have been
> applied, such as commit 69c56bd2f6e9 ("python/chcat: improve the code
> readability") and b7227aaec1da ("mcstrans: fix Python linter warnings on
> test scripts") and 3cb974d2d2a7 ("semanage_migrate_store: fix many
> Python linter warnings").
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>

Acked-by: Petr Lautrbach <plautrba@redhat.com>

https://github.com/SELinuxProject/selinux/pull/128

> ---
>  scripts/run-flake8 | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/scripts/run-flake8 b/scripts/run-flake8
> index 6ad029fa6852..24b1202fde99 100755
> --- a/scripts/run-flake8
> +++ b/scripts/run-flake8
> @@ -4,6 +4,11 @@
>  # Run on the base directory if no argument has been given
>  if [ $# -eq 0 ] ; then
>      cd "$(dirname -- "$0")/.." || exit $?
> +
> +    # Run on both files ending with .py and Python files without extension
> +    # shellcheck disable=SC2046
> +    set -- $( (find . -name '*.py' ; grep --exclude-dir=.git -l -e '^#!\s*/usr/bin/python' -e '^#!/usr/bin/env python' -r .) | sort -u )
> +    echo "Analyzing $# Python scripts"
>  fi
>  
>  # Assign each ignore warning on a line, in order to ease testing enabling the warning again

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] scripts/run-flake8: run on Python scripts not ending with .py
  2019-01-08 13:11 ` Petr Lautrbach
@ 2019-01-09 12:19   ` Petr Lautrbach
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Lautrbach @ 2019-01-09 12:19 UTC (permalink / raw)
  To: selinux; +Cc: Nicolas Iooss

Petr Lautrbach <plautrba@redhat.com> writes:

> Nicolas Iooss <nicolas.iooss@m4x.org> writes:
>
>> When running flake8 on a directory, it does not analyze files without an
>> extension, like semanage_migrate_store, mlscolor-test, etc. Use grep to
>> find files with a Python shebang and build a list which is then given to
>> flake8.
>>
>> This commit is possible now that some clean-up patches have been
>> applied, such as commit 69c56bd2f6e9 ("python/chcat: improve the code
>> readability") and b7227aaec1da ("mcstrans: fix Python linter warnings on
>> test scripts") and 3cb974d2d2a7 ("semanage_migrate_store: fix many
>> Python linter warnings").
>>
>> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
>
> Acked-by: Petr Lautrbach <plautrba@redhat.com>
>
> https://github.com/SELinuxProject/selinux/pull/128

And it's merged now.

>
>> ---
>>  scripts/run-flake8 | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/scripts/run-flake8 b/scripts/run-flake8
>> index 6ad029fa6852..24b1202fde99 100755
>> --- a/scripts/run-flake8
>> +++ b/scripts/run-flake8
>> @@ -4,6 +4,11 @@
>>  # Run on the base directory if no argument has been given
>>  if [ $# -eq 0 ] ; then
>>      cd "$(dirname -- "$0")/.." || exit $?
>> +
>> +    # Run on both files ending with .py and Python files without extension
>> +    # shellcheck disable=SC2046
>> +    set -- $( (find . -name '*.py' ; grep --exclude-dir=.git -l -e '^#!\s*/usr/bin/python' -e '^#!/usr/bin/env python' -r .) | sort -u )
>> +    echo "Analyzing $# Python scripts"
>>  fi
>>  
>>  # Assign each ignore warning on a line, in order to ease testing enabling the warning again

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-05 15:59 [PATCH 1/1] scripts/run-flake8: run on Python scripts not ending with .py Nicolas Iooss
2019-01-08 13:11 ` Petr Lautrbach
2019-01-09 12:19   ` Petr Lautrbach

SELinux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/selinux/0 selinux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 selinux selinux/ https://lore.kernel.org/selinux \
		selinux@vger.kernel.org selinux@archiver.kernel.org
	public-inbox-index selinux


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.selinux


AGPL code for this site: git clone https://public-inbox.org/ public-inbox