mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-11 19:08:40 +00:00
[Lint] Use Black to auto-format code
The move to using auto-formatter makes it easier to read, submit and speeds up development time. https://github.com/ambv/black/ Although I would prefer 79 chars, the default line length of 88 chars used by black suffices. The flake8 line length remains at 120 chars since black does not touch comments or docstrings and this will require another round of fixes. The only black setting that is not standard is the use of double-quotes for strings so disabled any formatting of these. Note however that flake8 will still flag usage of double-quotes. I may change my mind on double vs single quotes but for now leave them. A new pyproject.toml file has been created for black configuration.
This commit is contained in:
parent
bcca07443c
commit
b1cdc32f73
233 changed files with 9460 additions and 4112 deletions
|
@ -35,13 +35,25 @@ def module_exists(module_name):
|
|||
|
||||
# Imports sorted by resulting file size.
|
||||
if module_exists('closure'):
|
||||
|
||||
def minify_closure(file_in, file_out):
|
||||
try:
|
||||
subprocess.check_call(['closure', '-W', 'QUIET',
|
||||
'--js', file_in, '--js_output_file', file_out])
|
||||
subprocess.check_call(
|
||||
[
|
||||
'closure',
|
||||
'-W',
|
||||
'QUIET',
|
||||
'--js',
|
||||
file_in,
|
||||
'--js_output_file',
|
||||
file_out,
|
||||
]
|
||||
)
|
||||
return True
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
|
||||
|
||||
elif module_exists('slimit'):
|
||||
from slimit import minify
|
||||
else:
|
||||
|
@ -108,7 +120,10 @@ def minify_js_dir(source_dir):
|
|||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 2:
|
||||
JS_SOURCE_DIRS = ['deluge/ui/web/js/deluge-all', 'deluge/ui/web/js/extjs/ext-extensions']
|
||||
JS_SOURCE_DIRS = [
|
||||
'deluge/ui/web/js/deluge-all',
|
||||
'deluge/ui/web/js/extjs/ext-extensions',
|
||||
]
|
||||
else:
|
||||
JS_SOURCE_DIRS = [os.path.abspath(sys.argv[1])]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue