diff options
Diffstat (limited to 'lib/python/qmk/path.py')
-rw-r--r-- | lib/python/qmk/path.py | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/python/qmk/path.py b/lib/python/qmk/path.py index e7e3ec53f..0cdfe353c 100644 --- a/lib/python/qmk/path.py +++ b/lib/python/qmk/path.py | |||
@@ -5,8 +5,6 @@ import os | |||
5 | 5 | ||
6 | from qmk.errors import NoSuchKeyboardError | 6 | from qmk.errors import NoSuchKeyboardError |
7 | 7 | ||
8 | from bs4 import UnicodeDammit | ||
9 | |||
10 | def keymap(keyboard): | 8 | def keymap(keyboard): |
11 | """Locate the correct directory for storing a keymap. | 9 | """Locate the correct directory for storing a keymap. |
12 | 10 | ||
@@ -35,19 +33,14 @@ def normpath(path): | |||
35 | 33 | ||
36 | return os.path.normpath(os.path.join(os.environ['ORIG_CWD'], path)) | 34 | return os.path.normpath(os.path.join(os.environ['ORIG_CWD'], path)) |
37 | 35 | ||
38 | def unicode_text(filename): | 36 | def file_lines(filename): |
39 | """Returns the contents of filename as a UTF-8 string. Tries to DTRT when it comes to encoding. | 37 | """ Return a files content, line by line |
40 | """ | ||
41 | with open(filename, "rb") as fd: | ||
42 | text = UnicodeDammit(fd.read()) | ||
43 | |||
44 | if text.contains_replacement_characters: | ||
45 | log_warning("%s: Could not determine file encoding, some characters were replaced." % (filename,)) | ||
46 | |||
47 | return text.unicode_markup or "" | ||
48 | 38 | ||
39 | Args: | ||
40 | filename: path to the file | ||
49 | 41 | ||
50 | def unicode_lines(filename): | 42 | Returns: |
51 | """Returns the contents of filename as a UTF-8 string. Tries to DTRT when it comes to encoding. | 43 | an list, in which each item is a line of the file |
52 | """ | 44 | """ |
53 | return unicode_text(filename).split("\n") | 45 | with open(filename, "r") as fd: |
46 | return fd.readlines() | ||