Skip to content

Commit

Permalink
Default to utf8 in setup_helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
avylove committed Oct 20, 2017
1 parent bbd370d commit 608972c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions setup_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Functions to help with build and setup
"""

import io
import os
import re
import sys
Expand All @@ -16,12 +17,12 @@
RE_VERSION = re.compile(r'__version__\s*=\s*[\'\"](.+)[\'\"]$')


def get_version(filename):
def get_version(filename, encoding='utf8'):
"""
Get __version__ definition out of a source file
"""

with open(filename) as sourcecode:
with io.open(filename, encoding=encoding) as sourcecode:
for line in sourcecode:
version = RE_VERSION.match(line)
if version:
Expand All @@ -30,24 +31,24 @@ def get_version(filename):
return None


def readme(filename):
def readme(filename, encoding='utf8'):
"""
Read the contents of a file
"""

with open(filename) as source:
with io.open(filename, encoding=encoding) as source:
return source.read()


def print_spelling_errors(filename):
def print_spelling_errors(filename, encoding='utf8'):
"""
Print misspelled words returned by sphinxcontrib-spelling
"""

filesize = os.stat(filename).st_size
if filesize:
sys.stdout.write('Misspelled Words:\n')
with open(filename) as wordlist:
with io.open(filename, encoding=encoding) as wordlist:
for line in wordlist:
sys.stdout.write(' ' + line)
return 1
Expand Down

0 comments on commit 608972c

Please sign in to comment.