D7774: resourceutil: implement `contents()` to iterate over resources in a package
mharbison72 (Matt Harbison)
phabricator at mercurial-scm.org
Mon Dec 30 05:43:14 UTC 2019
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D7774
AFFECTED FILES
mercurial/utils/resourceutil.py
CHANGE DETAILS
diff --git a/mercurial/utils/resourceutil.py b/mercurial/utils/resourceutil.py
--- a/mercurial/utils/resourceutil.py
+++ b/mercurial/utils/resourceutil.py
@@ -55,6 +55,10 @@
pycompat.sysstr(package), encoding.strfromlocal(name)
)
+ def contents(package):
+ for r in resources.contents(pycompat.sysstr(package)):
+ yield encoding.strtolocal(r)
+
except (ImportError, AttributeError):
@@ -72,3 +76,9 @@
return os.path.isfile(pycompat.fsdecode(path))
except (IOError, OSError):
return False
+
+ def contents(package):
+ path = pycompat.fsdecode(_package_path(package))
+
+ for p in os.listdir(path):
+ yield pycompat.fsencode(p)
To: mharbison72, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list