Implement "get_file_contents" helper

This commit is contained in:
Ivan Kravets
2018-12-27 14:48:22 +02:00
parent 74218f4f93
commit aa2bc4a63b
5 changed files with 17 additions and 15 deletions

View File

@@ -852,6 +852,15 @@ def ensure_udev_rules():
return True
def get_file_contents(path):
try:
with open(path) as f:
return f.read()
except UnicodeDecodeError:
with open(path, encoding="latin-1") as f:
return f.read()
def rmtree_(path):
def _onerror(_, name, __):