Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
@obj.some_method(:param1 => "ajklsdljksdlaksjdslkjas",
:param2 => 42,
:param3 => {
:foo => :bar
})
{
@obj.some_method(:param1 => "ajklsdljksdlaksjdslkjas",
:param2 => 42,
:param3 => {
:foo => :bar
})
}#!/usr/bin/env python
from __future__ import with_statement
import sys, os
from mercurial import hg, ui
def get_changed_files():
repo = hg.repository(ui.ui(), '.')
def collect_files(changeset):
files = changeset.files()
for child in changeset.children():
files += collect_files(child)
return files
node = repo.changectx(os.environ['HG_NODE'])
return list(set(collect_files(node)))
indent_settings = (
('.html', 2),
('.css', 2),
('.js', 2),
('.py', 4),
)
if __name__ == '__main__':
auto_fix = len(sys.argv) == 2 and sys.argv[1] == '--fix'
fail = False
for file in get_changed_files():
for ext, tabwidth in indent_settings:
if file.endswith(ext):
break
else:
continue
with open(file) as fp:
data = fp.read()
if '\t' in data:
fail = True
if auto_fix:
print 'fixing %s' % file
with open(file, 'w') as fp:
fp.write(data.expandtabs(tabwidth))
else:
print 'tabs found in %s' % file
if fail:
sys.exit(1)
О трэйлинг вайтспейсах замолвите слово