2016-07-31 19:37:20 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import print_function
|
|
|
|
from lib.css_parser import parse, CssParserException
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import glob
|
|
|
|
|
2017-02-05 21:24:28 +01:00
|
|
|
# check for the venv
|
|
|
|
from lib import sanity_check
|
|
|
|
sanity_check.check_venv(__file__)
|
2016-07-31 19:37:20 +02:00
|
|
|
|
|
|
|
def validate(fn):
|
|
|
|
# type: (str) -> None
|
|
|
|
text = open(fn).read()
|
|
|
|
section_list = parse(text)
|
|
|
|
if text != section_list.text():
|
|
|
|
print('BOO! %s broken' % (fn,))
|
|
|
|
open('foo.txt', 'w').write(section_list.text())
|
|
|
|
os.system('diff %s foo.txt' % (fn,))
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
def check_our_files():
|
|
|
|
# type: () -> None
|
|
|
|
fns = glob.glob('static/styles/*.css')
|
|
|
|
for fn in fns:
|
|
|
|
try:
|
|
|
|
validate(fn)
|
|
|
|
except CssParserException as e:
|
2017-02-01 15:31:24 +01:00
|
|
|
msg = '''
|
|
|
|
ERROR! Some CSS seems to be misformatted.
|
|
|
|
{}
|
|
|
|
See line {} in file {}
|
|
|
|
'''.format(e.msg, e.token.line, fn)
|
|
|
|
print(msg)
|
2016-07-31 19:37:20 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
check_our_files()
|