##// END OF EJS Templates
scripts: run isort on scripts too
Mads Kiilerich -
r8156:abb83e4e default
parent child Browse files
Show More
@@ -1,37 +1,39 b''
1 #!/usr/bin/env python3
1 #!/usr/bin/env python3
2 """
2 """
3 pyflakes with filter configuration for Kallithea.
3 pyflakes with filter configuration for Kallithea.
4 Inspired by pyflakes/api.py and flake8/plugins/pyflakes.py .
4 Inspired by pyflakes/api.py and flake8/plugins/pyflakes.py .
5 """
5 """
6
6
7 import sys
7 import sys
8
8 import pyflakes.api
9 import pyflakes.api
9 import pyflakes.messages
10 import pyflakes.messages
10
11
12
11 class Reporter:
13 class Reporter:
12
14
13 warned = False
15 warned = False
14
16
15 def flake(self, warning):
17 def flake(self, warning):
16 # ignore known warnings
18 # ignore known warnings
17 if isinstance(warning, pyflakes.messages.UnusedVariable):
19 if isinstance(warning, pyflakes.messages.UnusedVariable):
18 return
20 return
19 if warning.filename == 'kallithea/bin/kallithea_cli_ishell.py':
21 if warning.filename == 'kallithea/bin/kallithea_cli_ishell.py':
20 if isinstance(warning, pyflakes.messages.ImportStarUsed) and warning.message_args == ('kallithea.model.db',):
22 if isinstance(warning, pyflakes.messages.ImportStarUsed) and warning.message_args == ('kallithea.model.db',):
21 return
23 return
22 if isinstance(warning, pyflakes.messages.UnusedImport) and warning.message_args == ('kallithea.model.db.*',):
24 if isinstance(warning, pyflakes.messages.UnusedImport) and warning.message_args == ('kallithea.model.db.*',):
23 return
25 return
24
26
25 print('%s:%s %s [%s %s]' % (warning.filename, warning.lineno, warning.message % warning.message_args, type(warning).__name__, warning.message_args))
27 print('%s:%s %s [%s %s]' % (warning.filename, warning.lineno, warning.message % warning.message_args, type(warning).__name__, warning.message_args))
26 self.warned = True
28 self.warned = True
27
29
28 def unexpectedError(self, filename, msg):
30 def unexpectedError(self, filename, msg):
29 print('Unexpected error for %s: %s' % (filename, msg))
31 print('Unexpected error for %s: %s' % (filename, msg))
30
32
31
33
32 reporter = Reporter()
34 reporter = Reporter()
33
35
34 for filename in sorted(set(sys.argv[1:])):
36 for filename in sorted(set(sys.argv[1:])):
35 pyflakes.api.checkPath(filename, reporter=reporter)
37 pyflakes.api.checkPath(filename, reporter=reporter)
36 if reporter.warned:
38 if reporter.warned:
37 raise SystemExit(1)
39 raise SystemExit(1)
@@ -1,23 +1,23 b''
1 #!/bin/bash -x
1 #!/bin/bash -x
2
2
3 # Enforce some consistency in whitespace - just to avoid spurious whitespaces changes
3 # Enforce some consistency in whitespace - just to avoid spurious whitespaces changes
4
4
5 files=`hg mani | egrep -v '/fontello/|/email_templates/|(^LICENSE-MERGELY.html|^docs/Makefile|^scripts/whitespacecleanup.sh|/(graph|mergely|native.history)\.js|/test_dump_html_mails.ref.html|\.png|\.gif|\.ico|\.pot|\.po|\.mo|\.tar\.gz|\.diff)$'`
5 files=`hg mani | egrep -v '/fontello/|/email_templates/|(^LICENSE-MERGELY.html|^docs/Makefile|^scripts/whitespacecleanup.sh|/(graph|mergely|native.history)\.js|/test_dump_html_mails.ref.html|\.png|\.gif|\.ico|\.pot|\.po|\.mo|\.tar\.gz|\.diff)$'`
6
6
7 sed -i "s/`printf '\r'`//g" $files
7 sed -i "s/`printf '\r'`//g" $files
8 sed -i -e "s,`printf '\t'`, ,g" $files
8 sed -i -e "s,`printf '\t'`, ,g" $files
9 sed -i -e "s, *$,,g" $files
9 sed -i -e "s, *$,,g" $files
10 sed -i -e 's,\([^ ]\)\\$,\1 \\,g' -e 's,\(["'"'"']["'"'"']["'"'"']\) \\$,\1\\,g' $files
10 sed -i -e 's,\([^ ]\)\\$,\1 \\,g' -e 's,\(["'"'"']["'"'"']["'"'"']\) \\$,\1\\,g' $files
11 # ensure one trailing newline - remove empty last line and make last line include trailing newline:
11 # ensure one trailing newline - remove empty last line and make last line include trailing newline:
12 sed -i -e '$,${/^$/d}' -e '$a\' $files
12 sed -i -e '$,${/^$/d}' -e '$a\' $files
13
13
14 sed -i -e 's,\([^ /]\){,\1 {,g' `hg loc '*.css'`
14 sed -i -e 's,\([^ /]\){,\1 {,g' `hg loc '*.css'`
15 sed -i -e 's|^\([^ /].*,\)\([^ ]\)|\1 \2|g' `hg loc '*.css'`
15 sed -i -e 's|^\([^ /].*,\)\([^ ]\)|\1 \2|g' `hg loc '*.css'`
16
16
17 hg mani | xargs chmod -x
17 hg mani | xargs chmod -x
18 hg loc 'set:!binary()&grep("^#!")&!(**_tmpl.py)&!(**/template**)' | xargs chmod +x
18 hg loc 'set:!binary()&grep("^#!")&!(**_tmpl.py)&!(**/template**)' | xargs chmod +x
19
19
20 # isort is installed from dev_requirements.txt
20 # isort is installed from dev_requirements.txt
21 isort --line-width 160 --wrap-length 160 --lines-after-imports 2 `hg loc '*.py'`
21 hg loc 'set:!binary()&grep("^#!.*python")' '*.py' | xargs isort --line-width 160 --wrap-length 160 --lines-after-imports 2
22
22
23 hg diff
23 hg diff
General Comments 0
You need to be logged in to leave comments. Login now