Skip to content

Commit

Permalink
Use importlib instead of pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwager committed Aug 28, 2024
1 parent 7e0f722 commit 4699a1e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions fierce/fierce.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,21 @@ def find_subdomain_list_file(filename):
return os.path.abspath(filename_path)

try:
import pkg_resources
import importlib
except ImportError:
return filename

# If the relative check failed then attempt to find the list file
# in the pip package directory. This will typically happen on pip package
# installs (duh)
package_filename_path = os.path.join("lists", filename)
try:
full_package_path = pkg_resources.resource_filename(
"fierce",
package_filename_path
)
# Use importlib.resources.as_file when Python 3.9 is minimum version
full_package_path = importlib.resources.path("fierce.lists", filename)
except ImportError:
return filename

return full_package_path
with full_package_path as path:
return str(path)


def head_request(url, timeout=2):
Expand Down

0 comments on commit 4699a1e

Please sign in to comment.