Allow mode='rt' on open_resource() helper

This commit is contained in:
icreatedanaccount 2019-05-06 10:56:35 -04:00 committed by David Lord
parent 05a4e15ee4
commit ad709be46e
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
2 changed files with 27 additions and 0 deletions

View file

@ -1055,6 +1055,8 @@ class _PackageBoundObject(object):
subfolders use forward slashes as separator.
:param mode: resource file opening mode, default is 'rb'.
"""
if mode == 'rt':
mode = 'r'
if mode not in ("r", "rb"):
raise ValueError("Resources can only be opened for reading")
return open(os.path.join(self.root_path, resource), mode)