From 13c0ea75256e5f274968cc0775be989fc091f4a4 Mon Sep 17 00:00:00 2001 From: Chris Lane Date: Fri, 18 Jan 2019 14:50:00 -0500 Subject: [PATCH] Addressing issue #372 Previous pull-requests #406 and #413 attempted to resolve #372. They were, however, never merged in. Given that #391 was just merged (which rewrites a significant amount of prior code), I here took what we learned from #406 and #413 and re-implemented it. This approach will be less error-prone than attempting to rebase either of the former on the changes introduced in #391. --- cheat/sheet.py | 3 ++- cheat/sheets.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cheat/sheet.py b/cheat/sheet.py index 5b27f21..81553a1 100644 --- a/cheat/sheet.py +++ b/cheat/sheet.py @@ -1,3 +1,4 @@ +import io import os import shutil @@ -74,5 +75,5 @@ class Sheet: if not self.exists(sheet): Utils.die('No cheatsheet found for ' + sheet) - with open(self.path(sheet)) as cheatfile: + with io.open(self.path(sheet), encoding='utf-8') as cheatfile: return cheatfile.read() diff --git a/cheat/sheets.py b/cheat/sheets.py index 6f772d2..986003d 100644 --- a/cheat/sheets.py +++ b/cheat/sheets.py @@ -1,3 +1,4 @@ +import io import os from cheat.utils import Utils @@ -92,7 +93,7 @@ class Sheets: for cheatsheet in sorted(self.get().items()): match = '' - for line in open(cheatsheet[1]): + for line in io.open(cheatsheet[1], encoding='utf-8'): if term in line: match += ' ' + self._utils.highlight(term, line)