Show More
|
1 | NO CONTENT: new file 100644 |
@@ -8,7 +8,6 b'' | |||
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import itertools |
|
11 | import os | |
|
12 | 11 | import re |
|
13 | 12 | import textwrap |
|
14 | 13 | |
@@ -314,11 +313,11 b' def loaddoc(topic, subdir=None):' | |||
|
314 | 313 | """Return a delayed loader for help/topic.txt.""" |
|
315 | 314 | |
|
316 | 315 | def loader(ui): |
|
317 | docdir = os.path.join(resourceutil.datapath, b'helptext') | |
|
316 | package = b'helptext' | |
|
318 | 317 | if subdir: |
|
319 | docdir = os.path.join(docdir, subdir) | |
|
320 | path = os.path.join(docdir, topic + b".txt") | |
|
321 |
doc = gettext( |
|
|
318 | package = b'helptext' + b'.' + subdir | |
|
319 | with resourceutil.open_resource(package, topic + b'.txt') as fp: | |
|
320 | doc = gettext(fp.read()) | |
|
322 | 321 | for rewriter in helphooks.get(topic, []): |
|
323 | 322 | doc = rewriter(ui, topic, doc) |
|
324 | 323 | return doc |
@@ -35,3 +35,25 b" if mainfrozen() and getattr(sys, 'frozen" | |||
|
35 | 35 | datapath = os.path.dirname(pycompat.sysexecutable) |
|
36 | 36 | else: |
|
37 | 37 | datapath = os.path.dirname(os.path.dirname(pycompat.fsencode(__file__))) |
|
38 | ||
|
39 | try: | |
|
40 | import importlib | |
|
41 | ||
|
42 | # Force loading of the resources module | |
|
43 | importlib.resources.open_binary | |
|
44 | ||
|
45 | def open_resource(package, name): | |
|
46 | package = b'mercurial.' + package | |
|
47 | return importlib.resources.open_binary( | |
|
48 | pycompat.sysstr(package), pycompat.sysstr(name) | |
|
49 | ) | |
|
50 | ||
|
51 | ||
|
52 | except AttributeError: | |
|
53 | ||
|
54 | def _package_path(package): | |
|
55 | return os.path.join(datapath, *package.split(b'.')) | |
|
56 | ||
|
57 | def open_resource(package, name): | |
|
58 | path = os.path.join(_package_path(package), name) | |
|
59 | return open(path, 'rb') |
General Comments 0
You need to be logged in to leave comments.
Login now