Skip to content

Commit

Permalink
Restore compatibility with Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoPrevato committed Nov 3, 2023
1 parent 16aea75 commit a91205b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions blacksheep/server/resources.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
from importlib.resources import files
"""
This module offers methods to return file paths for resources. Its original purpose is
to provide contents of static files stored for conveniency in the blacksheep.server.res
package.
"""

try:
from importlib.resources import files

def get_resource_file_path(anchor, file_name: str) -> str:
return str(files(anchor) / file_name)
def get_resource_file_path(anchor, file_name: str) -> str:
return str(files(anchor) / file_name)
except ImportError:
# Python 3.8
import pkg_resources

def get_resource_file_path(anchor, file_name: str) -> str:
return pkg_resources.resource_filename(anchor, file_name)


def get_resource_file_content(file_name: str) -> str:
Expand Down

0 comments on commit a91205b

Please sign in to comment.