Skip to content

Commit

Permalink
Turn lists directory into module and use that
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwager committed Aug 28, 2024
1 parent 182b306 commit c6956bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 2 additions & 9 deletions fierce/fierce.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,15 @@ def find_subdomain_list_file(filename):
if os.path.exists(filename_path):
return os.path.abspath(filename_path)

try:
from importlib import resources
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)
try:
# Use importlib.resources.as_file when Python 3.9 is minimum version
full_package_path = resources.path("fierce.lists", filename)
from fierce import lists
except ImportError:
return filename

with full_package_path as path:
return str(path)
return str(lists.CURDIR / filename)


def head_request(url, timeout=2):
Expand Down
7 changes: 7 additions & 0 deletions fierce/lists/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pathlib


CURDIR = pathlib.Path(__file__).parent
DEFAULT_LIST = CURDIR / "default.txt"
_20000_LIST = "20000.txt"
_5000_LIST = "5000.txt"

0 comments on commit c6956bb

Please sign in to comment.