Skip to content

Commit

Permalink
Correct default subdomain file handling behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwager committed Feb 25, 2018
1 parent 49f9d57 commit ac7a507
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
13 changes: 6 additions & 7 deletions fierce/fierce.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def get_stripped_file_lines(filename):
"""
Return lines of a file with whitespace removed
"""
return [line.strip() for line in open(filename).readlines()]
return [line.strip() for line in filename.readlines()]


def get_subdomains(subdomains, subdomain_filename):
Expand Down Expand Up @@ -426,6 +426,10 @@ def parse_args():
help='time to wait between lookups'
)

# Attempt to intelligently find the subdomain list depending on
# how this library was installed.
default_subdomain_file = find_subdomain_list_file('default.txt')

subdomain_group = p.add_mutually_exclusive_group()
subdomain_group.add_argument(
'--subdomains',
Expand All @@ -436,7 +440,7 @@ def parse_args():
subdomain_group.add_argument(
'--subdomain-file',
action='store',
default="default.txt",
default=default_subdomain_file,
type=argparse.FileType('r'),
help='use subdomains specified in this file (one per line)'
)
Expand All @@ -457,11 +461,6 @@ def parse_args():

args = p.parse_args()

# Attempt to intelligently find the subdomain list depending on
# how this library was installed.
if args.subdomain_file and not os.path.exists(args.subdomain_file):
args.subdomain_file = find_subdomain_list_file(args.subdomain_file)

return args


Expand Down
8 changes: 4 additions & 4 deletions tests/test_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_update_resolver_nameservers_no_nameserver_use_file(self):
result = fierce.update_resolver_nameservers(
resolver,
nameservers,
nameserver_filename
open(nameserver_filename)
)

expected = contents.split()
Expand All @@ -110,7 +110,7 @@ def test_update_resolver_nameservers_prefer_nameservers_over_file(self):
result = fierce.update_resolver_nameservers(
resolver,
nameservers,
nameserver_filename
open(nameserver_filename)
)

expected = nameservers
Expand Down Expand Up @@ -168,7 +168,7 @@ def test_get_subdomains_no_subdomains_use_file(self):

result = fierce.get_subdomains(
subdomains,
subdomain_filename
open(subdomain_filename)
)

expected = contents.split()
Expand All @@ -190,7 +190,7 @@ def test_get_subdomains_prefer_subdomains_over_file(self):

result = fierce.get_subdomains(
subdomains,
subdomain_filename
open(subdomain_filename)
)

expected = subdomains
Expand Down

0 comments on commit ac7a507

Please sign in to comment.