Skip to content

Commit 17f5de7

Browse files
committed
Intoduction of the ips output directory.
This patch fixes #268. Indeed, before this patch, there wasn't anything for IP in the plain format. This patch fixes it by introducing a new ips directory which is used to store any IP related information - when the generation of the plain format is active. Contributors: * @T145
1 parent 106d586 commit 17f5de7

File tree

11 files changed

+81
-0
lines changed

11 files changed

+81
-0
lines changed

PyFunceble/cli/filesystem/status_file.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,8 @@ def generate_plain_file(self) -> "StatusFileGenerator":
576576
Generates the plain file.
577577
"""
578578

579+
location = None
580+
579581
if not hasattr(self.status, "ip_syntax") or not self.status.ip_syntax:
580582
location = os.path.join(
581583
self.get_output_basedir(),
@@ -589,6 +591,19 @@ def generate_plain_file(self) -> "StatusFileGenerator":
589591
self.file_printer.template_to_use = "plain"
590592
self.file_printer.print_interpolated_line()
591593

594+
if self.status.ip_syntax:
595+
location = os.path.join(
596+
self.get_output_basedir(),
597+
PyFunceble.cli.storage.OUTPUTS.ips.directory,
598+
self.status.status.upper(),
599+
PyFunceble.cli.storage.OUTPUTS.ips.filename,
600+
)
601+
602+
self.file_printer.destination = location
603+
self.file_printer.dataset = self.status.to_dict()
604+
self.file_printer.template_to_use = "plain"
605+
self.file_printer.print_interpolated_line()
606+
592607
return self
593608

594609
@ensure_status_is_given

PyFunceble/cli/storage.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134

135135
UNIX_OUTPUTS: dict = {
136136
"domains": {"filename": "list"},
137+
"ips": {"filename": "list"},
137138
"hosts": {"filename": "hosts", "ip_filename": "ips"},
138139
"analytic": {
139140
"filenames": {
@@ -152,6 +153,7 @@
152153

153154
WIN_OUTPUTS: dict = {
154155
"domains": {"filename": "list.txt"},
156+
"ips": {"filename": "list.txt"},
155157
"hosts": {"filename": "hosts.txt", "ip_filename": "ips.txt"},
156158
"analytic": {
157159
"filenames": {
@@ -170,6 +172,7 @@
170172

171173
UNIVERSAL_OUTPUTS: dict = {
172174
"domains": {"directory": "domains", "filename": "list"},
175+
"ips": {"directory": "ips", "filename": "list"},
173176
"hosts": {"directory": "hosts", "filename": "hosts", "ip_filename": "ips"},
174177
"analytic": {
175178
"directories": {

PyFunceble/data/infrastructure/dir_structure_production.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,48 @@
113113
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
114114
}
115115
},
116+
"ips": {
117+
".gitignore": {
118+
"content": "*\n!.gitignore\n!/ACTIVE/\n!/INACTIVE/\n!/INVALID/\n!/MALICIOUS/\n!/SANE/\n!/VALID/\n",
119+
"hash": "a273966a13322ad4da9fbad4bd7247ca046de503de543c6f909e5e2b"
120+
}
121+
},
122+
"ips/ACTIVE": {
123+
".gitignore": {
124+
"content": "*\n!.gitignore\n",
125+
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
126+
}
127+
},
128+
"ips/INACTIVE": {
129+
".gitignore": {
130+
"content": "*\n!.gitignore\n",
131+
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
132+
}
133+
},
134+
"ips/INVALID": {
135+
".gitignore": {
136+
"content": "*\n!.gitignore\n",
137+
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
138+
}
139+
},
140+
"ips/MALICIOUS": {
141+
".gitignore": {
142+
"content": "*\n!.gitignore\n",
143+
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
144+
}
145+
},
146+
"ips/SANE": {
147+
".gitignore": {
148+
"content": "*\n!.gitignore\n",
149+
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
150+
}
151+
},
152+
"ips/VALID": {
153+
".gitignore": {
154+
"content": "*\n!.gitignore\n",
155+
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
156+
}
157+
},
116158
"logs": {
117159
".gitignore": {
118160
"content": "*\n!.gitignore\n!/date_format/\n!/no_referrer/\n!/percentage/\n!/whois/\n",

output/__pyfunceble_origin__/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
!.gitignore
33
!Analytic/
44
!domains/
5+
!ips/
56
!hosts/
67
!logs/
78
!splitted/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*
2+
!.gitignore
3+
!/ACTIVE/
4+
!/INACTIVE/
5+
!/INVALID/
6+
!/MALICIOUS/
7+
!/SANE/
8+
!/VALID/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

0 commit comments

Comments
 (0)