# HG changeset patch # User Augie Fackler # Date 1580748962 18000 # Node ID 27787a43712f95620a8b6e9dddcc3fe4010d1955 # Parent 74172a234dd3f7377fc7fce92366fd5180848a65 resourceutil: blacken diff -r 74172a234dd3 -r 27787a43712f mercurial/utils/resourceutil.py --- a/mercurial/utils/resourceutil.py Thu Feb 06 15:46:55 2020 -0800 +++ 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)