Add travis script and gitattributes

This commit is contained in:
Otto Winter 2019-02-11 14:32:13 +01:00
parent 0a7479f9c2
commit 6ca7b2de93
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
3 changed files with 46 additions and 0 deletions

8
.gitattributes vendored Normal file
View File

@ -0,0 +1,8 @@
* text eol=lf
*.ico binary
*.jpg binary
*.png binary
*.zip binary
*.mp3 binary
*.gif binary

4
.travis.yml Normal file
View File

@ -0,0 +1,4 @@
language: python
python: "3.7"
script:
- python3 travis.py

34
travis.py Normal file
View File

@ -0,0 +1,34 @@
from pathlib import Path
import sys
errors = []
def find_all(a_str, sub):
for i, line in enumerate(a_str.splitlines(keepends=False)):
column = 0
while True:
column = line.find(sub, column)
if column == -1:
break
yield i, column
column += len(sub)
for f in sorted(Path('.').glob('*.rst')):
try:
content = f.read_text('utf-8')
except UnicodeDecodeError:
errors.append("File {} is not readable as UTF-8. Please set your editor to UTF-8 mode."
"".format(f))
for line, col in find_all(content, '\t'):
errors.append("File {} contains tab character on line {}:{}. "
"Please convert tabs to spaces.".format(f, line, col))
for line, col in find_all(content, '\r'):
errors.append("File {} contains windows newline on line {}:{}. "
"Please set your editor to unix newline mode.".format(f, line, col))
for error in errors:
print(error)
sys.exit(len(errors))