Changeset - abb83e4edfd9
[Not reviewed]
default
0 2 0
Mads Kiilerich (mads) - 6 years ago 2020-03-06 19:37:10
mads@kiilerich.com
scripts: run isort on scripts too
2 files changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
scripts/pyflakes
Show inline comments
 
#!/usr/bin/env python3
 
"""
 
pyflakes with filter configuration for Kallithea.
 
Inspired by pyflakes/api.py and flake8/plugins/pyflakes.py .
 
"""
 

	
 
import sys
 

	
 
import pyflakes.api
 
import pyflakes.messages
 

	
 

	
 
class Reporter:
 

	
 
    warned = False
 

	
 
    def flake(self, warning):
 
        # ignore known warnings
 
        if isinstance(warning, pyflakes.messages.UnusedVariable):
 
            return
 
        if warning.filename == 'kallithea/bin/kallithea_cli_ishell.py':
 
            if isinstance(warning, pyflakes.messages.ImportStarUsed) and warning.message_args == ('kallithea.model.db',):
 
                return
 
            if isinstance(warning, pyflakes.messages.UnusedImport) and warning.message_args == ('kallithea.model.db.*',):
 
                return
 

	
 
        print('%s:%s %s   [%s %s]' % (warning.filename, warning.lineno, warning.message % warning.message_args, type(warning).__name__, warning.message_args))
 
        self.warned = True
 

	
 
    def unexpectedError(self, filename, msg):
 
        print('Unexpected error for %s: %s' % (filename, msg))
 

	
 

	
 
reporter = Reporter()
 

	
 
for filename in sorted(set(sys.argv[1:])):
 
    pyflakes.api.checkPath(filename, reporter=reporter)
 
if reporter.warned:
 
    raise SystemExit(1)
scripts/whitespacecleanup.sh
Show inline comments
 
#!/bin/bash -x
 

	
 
# Enforce some consistency in whitespace - just to avoid spurious whitespaces changes
 

	
 
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)$'`
 

	
 
sed -i "s/`printf '\r'`//g" $files
 
sed -i -e "s,`printf '\t'`,    ,g" $files
 
sed -i -e "s,  *$,,g" $files
 
sed -i -e 's,\([^ ]\)\\$,\1 \\,g' -e 's,\(["'"'"']["'"'"']["'"'"']\) \\$,\1\\,g' $files
 
# ensure one trailing newline - remove empty last line and make last line include trailing newline:
 
sed -i -e '$,${/^$/d}' -e '$a\' $files
 

	
 
sed -i -e 's,\([^ /]\){,\1 {,g' `hg loc '*.css'`
 
sed -i -e 's|^\([^ /].*,\)\([^ ]\)|\1 \2|g' `hg loc '*.css'`
 

	
 
hg mani | xargs chmod -x
 
hg loc 'set:!binary()&grep("^#!")&!(**_tmpl.py)&!(**/template**)' | xargs chmod +x
 

	
 
# isort is installed from dev_requirements.txt
 
isort --line-width 160 --wrap-length 160 --lines-after-imports 2 `hg loc '*.py'`
 
hg loc 'set:!binary()&grep("^#!.*python")' '*.py' | xargs isort --line-width 160 --wrap-length 160 --lines-after-imports 2
 

	
 
hg diff
0 comments (0 inline, 0 general)