I have always been a windows user and this is my first time using solaris, so don't assume I know anything about shell scripts. lets say I have some 3 different python program in a folder.
$:pwd
/pythonpgm
$:ls
1.py 2.py 3.py
I am using pylint to staticlly analyze my code
$:pylint -rn 1.py
Instead of using it individually on each file, I want to write a Makefile so that I have to do this only once. How to write a makefile for this? and call make?
Pylint returns bit-encoded exit codes. For example, an exit code of 20 means there was at least one warning message (4) and at least one convention message (16) and nothing else.
Using your editor, create a file called Makefile
in your current directory and put this in it:
pylint: ; @for py in *.py; do echo "Linting $$py"; pylint -rn $$py; done
Now you just run make
.
That's about as simple as it gets. If you want something more sophisticated, you can use:
PYLINT = pylint
PYLINTFLAGS = -rn
PYTHONFILES := $(wildcard *.py)
pylint: $(patsubst %.py,%.pylint,$(PYTHONFILES))
%.pylint:
$(PYLINT) $(PYLINTFLAGS) $*.py
(note, the first character on the last line above MUST BE a real TAB character, it cannot be spaces). The advantage to this one is you can run make 1.pylint
to just run pylint on the single file 1.py
, or run make
to run it on all files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With