Mercurial > hg
changeset 44241:aea79f41ee55
resourceutil: blacken
author | Augie Fackler <augie@google.com> |
---|---|
date | Mon, 03 Feb 2020 11:56:02 -0500 |
parents | 15eb90965a00 |
children | dbbae122f5e4 |
files | mercurial/utils/resourceutil.py |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/utils/resourceutil.py Mon Feb 03 11:51:52 2020 -0500 +++ b/mercurial/utils/resourceutil.py Mon Feb 03 11:56:02 2020 -0500 @@ -30,7 +30,7 @@ # the location of data files matching the source code -if mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app': +if mainfrozen() and getattr(sys, "frozen", None) != "macosx_app": # executable version (py2exe) doesn't support __file__ datapath = os.path.dirname(pycompat.sysexecutable) _rootpath = datapath @@ -41,16 +41,18 @@ # pseudo resources are found in their directory next to the # executable. def _package_path(package): - dirs = package.split(b'.') - assert dirs[0] == b'mercurial' + dirs = package.split(b".") + assert dirs[0] == b"mercurial" return os.path.join(_rootpath, *dirs[1:]) + else: datapath = os.path.dirname(os.path.dirname(pycompat.fsencode(__file__))) _rootpath = os.path.dirname(datapath) def _package_path(package): - return os.path.join(_rootpath, *package.split(b'.')) + return os.path.join(_rootpath, *package.split(b".")) + try: from importlib import resources @@ -79,7 +81,7 @@ def open_resource(package, name): path = os.path.join(_package_path(package), name) - return open(path, 'rb') + return open(path, "rb") def is_resource(package, name): path = os.path.join(_package_path(package), name)