Skip to content

Commit d3116cd

Browse files
committed
Clean up whitespaces
1 parent 10e054b commit d3116cd

15 files changed

Lines changed: 40 additions & 58 deletions

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def _get_project_details():
13-
13+
1414
with open("../pyproject.toml") as pyproject:
1515
content = pyproject.read()
1616

pyzmap/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from .api import APIServer
32
from .cli import main as cli_main
43
from .config import ZMapScanConfig

pyzmap/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import sys
32

43
from pyzmap.cli import main

pyzmap/api.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async def lifespan(app: FastAPI):
3939

4040
@app.get("/", tags=["Info"])
4141
async def root():
42-
42+
4343
return {
4444
"name": "PyZmap API",
4545
"version": app.state.zmap.get_version(),
@@ -49,31 +49,31 @@ async def root():
4949

5050
@app.get("/probe-modules", tags=["Info"], response_model=list[str])
5151
async def get_probe_modules():
52-
52+
5353
return app.state.zmap.get_probe_modules()
5454

5555

5656
@app.get("/output-modules", tags=["Info"], response_model=list[str])
5757
async def get_output_modules():
58-
58+
5959
return app.state.zmap.get_output_modules()
6060

6161

6262
@app.get("/output-fields", tags=["Info"], response_model=list[str])
6363
async def get_output_fields(probe_module: str | None = None):
64-
64+
6565
return app.state.zmap.get_output_fields(probe_module)
6666

6767

6868
@app.get("/interfaces", tags=["Info"], response_model=list[str])
6969
async def get_interfaces():
70-
70+
7171
return [iface for iface in psutil.net_if_addrs().keys()]
7272

7373

7474
@app.post("/blocklist", tags=["Input"])
7575
async def create_blocklist(request: BlocklistRequest) -> FileResponse:
76-
76+
7777
try:
7878
# Use provided output file or create temporary one
7979
output_file = request.output_file
@@ -98,7 +98,7 @@ async def create_blocklist(request: BlocklistRequest) -> FileResponse:
9898
async def generate_standard_blocklist(
9999
request: StandardBlocklistRequest,
100100
) -> FileResponse:
101-
101+
102102
try:
103103
# Use provided output file or create temporary one
104104
output_file = request.output_file
@@ -120,7 +120,7 @@ async def generate_standard_blocklist(
120120

121121
@app.post("/allowlist", tags=["Input"])
122122
async def create_allowlist(request: BlocklistRequest) -> FileResponse:
123-
123+
124124
try:
125125
# Use provided output file or create temporary one
126126
output_file = request.output_file
@@ -143,7 +143,7 @@ async def create_allowlist(request: BlocklistRequest) -> FileResponse:
143143

144144
@app.post("/scan-sync", tags=["Scan"], response_model=ScanResult)
145145
async def sync_scan(scan_request: ScanRequest):
146-
146+
147147
# Set default output file if not provided
148148
output_file = scan_request.output_file
149149
if not output_file:

pyzmap/cli.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import logging
32
import sys
43

@@ -9,7 +8,7 @@
98

109

1110
def setup_logging(verbose: bool) -> None:
12-
11+
1312
log_level = logging.DEBUG if verbose else logging.INFO
1413
logging.basicConfig(
1514
level=log_level,
@@ -18,7 +17,7 @@ def setup_logging(verbose: bool) -> None:
1817

1918

2019
def print_version(ctx: click.Context, _, value: bool) -> None:
21-
20+
2221
if not value or ctx.resilient_parsing:
2322
return
2423
try:
@@ -40,7 +39,7 @@ def print_version(ctx: click.Context, _, value: bool) -> None:
4039
help="Show ZMap version and exit.",
4140
)
4241
def cli() -> None:
43-
42+
4443
pass
4544

4645

@@ -70,7 +69,7 @@ def api(host: str, port: int, verbose: bool) -> None:
7069

7170

7271
def main() -> None:
73-
72+
7473
cli(auto_envvar_prefix="pyzmap")
7574

7675

pyzmap/config.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import json
32
from dataclasses import asdict, dataclass
43
from typing import Any
@@ -45,11 +44,11 @@ class ZMapScanConfig:
4544
user_metadata: dict[str, Any] | str | None = None
4645

4746
def __post_init__(self):
48-
47+
4948
self._validate()
5049

5150
def _validate(self) -> None:
52-
51+
5352
if self.target_port is not None and not (0 <= self.target_port <= 65535):
5453
raise ZMapConfigError(
5554
f"Invalid target port: {self.target_port}. "
@@ -101,40 +100,40 @@ def _validate(self) -> None:
101100

102101
@staticmethod
103102
def _is_valid_mac(mac: str) -> bool:
104-
103+
105104
import re
106105

107106
return bool(re.match(r"^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$", mac))
108107

109108
def to_dict(self) -> dict[str, Any]:
110-
109+
111110
result = {}
112111
for key, value in asdict(self).items():
113112
if value is not None:
114113
result[key] = value
115114
return result
116115

117116
def to_json(self) -> str:
118-
117+
119118
return json.dumps(self.to_dict(), indent=2)
120119

121120
@classmethod
122121
def from_dict(cls, data: dict[str, Any]) -> "ZMapScanConfig":
123-
122+
124123
return cls(**data)
125124

126125
@classmethod
127126
def from_json(cls, json_str: str) -> "ZMapScanConfig":
128-
127+
129128
return cls.from_dict(json.loads(json_str))
130129

131130
def save_to_file(self, filename: str) -> None:
132-
131+
133132
with open(filename, "w", encoding="utf-8") as f:
134133
f.write(self.to_json())
135134

136135
@classmethod
137136
def load_from_file(cls, filename: str) -> "ZMapScanConfig":
138-
137+
139138
with open(filename, encoding="utf-8") as f:
140139
return cls.from_json(f.read())

pyzmap/core.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from collections.abc import Callable
32
from typing import Any
43

@@ -11,7 +10,6 @@
1110

1211
# Option categories for ZMap configuration
1312
class ZMapOptionCategories:
14-
1513

1614
INPUT_OPTIONS = frozenset(
1715
{

pyzmap/exceptions.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
2-
31
class ZMapError(Exception):
4-
52

63
pass
74

85

96
class ZMapCommandError(ZMapError):
10-
117

128
def __init__(self, command: str, returncode: int, stderr: str):
139
self.command = command
@@ -21,24 +17,20 @@ def __init__(self, command: str, returncode: int, stderr: str):
2117

2218

2319
class ZMapConfigError(ZMapError):
24-
2520

2621
pass
2722

2823

2924
class ZMapInputError(ZMapError):
30-
3125

3226
pass
3327

3428

3529
class ZMapOutputError(ZMapError):
36-
3730

3831
pass
3932

4033

4134
class ZMapParserError(ZMapError):
42-
4335

4436
pass

pyzmap/input.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import ipaddress
32
import os
43
from typing import Any
@@ -9,7 +8,7 @@
98
class ZMapInput:
109

1110
def __init__(self):
12-
11+
1312
self.blocklist_file: str | None = None
1413
self.allowlist_file: str | None = None
1514
self.input_file: str | None = None
@@ -120,7 +119,7 @@ def generate_standard_blocklist(self, output_file: str) -> str:
120119
return self.create_blocklist_file(private_ranges, output_file)
121120

122121
def to_dict(self) -> dict[str, Any]:
123-
122+
124123
result = {}
125124

126125
if self.blocklist_file:

pyzmap/output.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import os
32
from typing import Any
43

@@ -8,7 +7,7 @@
87
class ZMapOutput:
98

109
def __init__(self):
11-
10+
1211
self.output_file: str | None = None
1312
self.output_fields: list[str] | str | None = None
1413
self.output_module: str | None = None
@@ -82,23 +81,23 @@ def set_verbosity(self, level: int) -> None:
8281
self.verbosity = level
8382

8483
def enable_quiet_mode(self) -> None:
85-
84+
8685
self.quiet = True
8786

8887
def disable_quiet_mode(self) -> None:
89-
88+
9089
self.quiet = False
9190

9291
def enable_syslog(self) -> None:
93-
92+
9493
self.disable_syslog = False
9594

9695
def disable_syslog_logging(self) -> None:
97-
96+
9897
self.disable_syslog = True
9998

10099
def to_dict(self) -> dict[str, Any]:
101-
100+
102101
result = {}
103102

104103
if self.output_file:

0 commit comments

Comments
 (0)