From fd6797b97e7d9307c6957f1464975743220e8431 Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Mon, 26 Feb 2024 14:09:24 +0100 Subject: [PATCH] Add docstrings to resource-functions --- python/nav/util.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/nav/util.py b/python/nav/util.py index ece1da4558..770ac51827 100644 --- a/python/nav/util.py +++ b/python/nav/util.py @@ -522,11 +522,21 @@ def _range_to_str(x, y): def resource_filename(package, filename): + """Return the path of the filename as it is inside the package + + package: either a dotted path to a module or a module object + filename: str or pathlib.Path + """ ref = resource_files(package) / filename with as_file(ref) as path: return str(path) def resource_bytes(package, filename): + """Read and return a bytes-object of the filename found in the package + + package: either a dotted path to a module or a module object + filename: str or pathlib.Path + """ ref = resource_files(package) / filename return ref.read_bytes()