-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Remove commented imports and commented code lines - Replace pkg_resources with importlib.resources.files - Fix problems caused by importlib.resources.files handling the anchor differnetly than pkg_resources - Sort imports
- Loading branch information
1 parent
72e7b30
commit 16aea75
Showing
8 changed files
with
21 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,13 @@ | ||
from os import path | ||
from importlib.resources import files | ||
|
||
# import pkg_resources | ||
try: | ||
from importlib.resources import files as pkg_resources_files | ||
|
||
def get_resource_file_path(anchor, resource_name: str) -> str: | ||
return str(pkg_resources_files(anchor) / resource_name) | ||
def get_resource_file_path(anchor, file_name: str) -> str: | ||
return str(files(anchor) / file_name) | ||
|
||
def get_resource_file_content(file_name: str) -> str: | ||
with open( | ||
get_resource_file_path(__name__, path.join(".", "res", file_name)), | ||
mode="rt", | ||
) as source: | ||
return source.read() | ||
|
||
except ImportError: | ||
# import pkg_resources | ||
from pkg_resources import resource_filename | ||
|
||
def get_resource_file_path(anchor, resource_name: str) -> str: | ||
return resource_filename(anchor, resource_name) | ||
|
||
def get_resource_file_content(file_name: str) -> str: | ||
with open( | ||
get_resource_file_path(__name__, path.join(".", "res", file_name)), | ||
mode="rt", | ||
) as source: | ||
return source.read() | ||
def get_resource_file_content(file_name: str) -> str: | ||
with open( | ||
get_resource_file_path("blacksheep.server.res", file_name), | ||
mode="rt", | ||
) as source: | ||
return source.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import sys | ||
|
||
import pytest | ||
|
||
from blacksheep.common.files.pathsutils import ( | ||
|