Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tes3awy committed Jun 15, 2021
1 parent 018b210 commit ba6cadc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions read_subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ def read_subnets(file_path: str = "subnets.csv") -> list[list]:
# Read subnets CSV file
with open(file=file_path, mode="r") as csvfile:
next(csvfile) # Skip header line
csv_data = csv.reader(csvfile, delimiter=",")

csv_data = csv.reader(
csvfile, delimiter="\n", dialect="excel", doublequote=True
)
for subnet in csv_data:
subnets.append(subnet)
subnets.append(subnet[0])

return subnets
4 changes: 2 additions & 2 deletions subnetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def subnetting(input_subnets: list[list]) -> list[dict]:
try:
results = []
# Loop over input_subnets
for netsubnet in input_subnets:
cidr_notation = ipaddress.IPv4Network(netsubnet[0])
for net_subnet in input_subnets:
cidr_notation = ipaddress.IPv4Network(net_subnet)

# Find range of IP addresses
hosts = list(cidr_notation.hosts())
Expand Down

0 comments on commit ba6cadc

Please sign in to comment.