Skip to content

Commit

Permalink
Add docstrings to resource-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Feb 26, 2024
1 parent 3ae9ed7 commit fd6797b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/nav/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit fd6797b

Please sign in to comment.