Skip to content

Commit

Permalink
Intoduction of the ips output directory.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
funilrys committed May 27, 2023
1 parent 106d586 commit 17f5de7
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 0 deletions.
15 changes: 15 additions & 0 deletions PyFunceble/cli/filesystem/status_file.py
Expand Up @@ -576,6 +576,8 @@ def generate_plain_file(self) -> "StatusFileGenerator":
Generates the plain file.
"""

location = None

if not hasattr(self.status, "ip_syntax") or not self.status.ip_syntax:
location = os.path.join(
self.get_output_basedir(),
Expand All @@ -589,6 +591,19 @@ def generate_plain_file(self) -> "StatusFileGenerator":
self.file_printer.template_to_use = "plain"
self.file_printer.print_interpolated_line()

if self.status.ip_syntax:
location = os.path.join(
self.get_output_basedir(),
PyFunceble.cli.storage.OUTPUTS.ips.directory,
self.status.status.upper(),
PyFunceble.cli.storage.OUTPUTS.ips.filename,
)

self.file_printer.destination = location
self.file_printer.dataset = self.status.to_dict()
self.file_printer.template_to_use = "plain"
self.file_printer.print_interpolated_line()

return self

@ensure_status_is_given
Expand Down
3 changes: 3 additions & 0 deletions PyFunceble/cli/storage.py
Expand Up @@ -134,6 +134,7 @@

UNIX_OUTPUTS: dict = {
"domains": {"filename": "list"},
"ips": {"filename": "list"},
"hosts": {"filename": "hosts", "ip_filename": "ips"},
"analytic": {
"filenames": {
Expand All @@ -152,6 +153,7 @@

WIN_OUTPUTS: dict = {
"domains": {"filename": "list.txt"},
"ips": {"filename": "list.txt"},
"hosts": {"filename": "hosts.txt", "ip_filename": "ips.txt"},
"analytic": {
"filenames": {
Expand All @@ -170,6 +172,7 @@

UNIVERSAL_OUTPUTS: dict = {
"domains": {"directory": "domains", "filename": "list"},
"ips": {"directory": "ips", "filename": "list"},
"hosts": {"directory": "hosts", "filename": "hosts", "ip_filename": "ips"},
"analytic": {
"directories": {
Expand Down
42 changes: 42 additions & 0 deletions PyFunceble/data/infrastructure/dir_structure_production.json
Expand Up @@ -113,6 +113,48 @@
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
}
},
"ips": {
".gitignore": {
"content": "*\n!.gitignore\n!/ACTIVE/\n!/INACTIVE/\n!/INVALID/\n!/MALICIOUS/\n!/SANE/\n!/VALID/\n",
"hash": "a273966a13322ad4da9fbad4bd7247ca046de503de543c6f909e5e2b"
}
},
"ips/ACTIVE": {
".gitignore": {
"content": "*\n!.gitignore\n",
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
}
},
"ips/INACTIVE": {
".gitignore": {
"content": "*\n!.gitignore\n",
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
}
},
"ips/INVALID": {
".gitignore": {
"content": "*\n!.gitignore\n",
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
}
},
"ips/MALICIOUS": {
".gitignore": {
"content": "*\n!.gitignore\n",
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
}
},
"ips/SANE": {
".gitignore": {
"content": "*\n!.gitignore\n",
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
}
},
"ips/VALID": {
".gitignore": {
"content": "*\n!.gitignore\n",
"hash": "0bd551cb904befcee06b7a99ef7ac54dba91ee21b5944c78759c1e4b"
}
},
"logs": {
".gitignore": {
"content": "*\n!.gitignore\n!/date_format/\n!/no_referrer/\n!/percentage/\n!/whois/\n",
Expand Down
1 change: 1 addition & 0 deletions output/__pyfunceble_origin__/.gitignore
Expand Up @@ -2,6 +2,7 @@
!.gitignore
!Analytic/
!domains/
!ips/
!hosts/
!logs/
!splitted/
8 changes: 8 additions & 0 deletions output/__pyfunceble_origin__/ips/.gitignore
@@ -0,0 +1,8 @@
*
!.gitignore
!/ACTIVE/
!/INACTIVE/
!/INVALID/
!/MALICIOUS/
!/SANE/
!/VALID/
2 changes: 2 additions & 0 deletions output/__pyfunceble_origin__/ips/ACTIVE/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 2 additions & 0 deletions output/__pyfunceble_origin__/ips/INACTIVE/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 2 additions & 0 deletions output/__pyfunceble_origin__/ips/INVALID/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 2 additions & 0 deletions output/__pyfunceble_origin__/ips/MALICIOUS/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 2 additions & 0 deletions output/__pyfunceble_origin__/ips/SANE/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 2 additions & 0 deletions output/__pyfunceble_origin__/ips/VALID/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore

0 comments on commit 17f5de7

Please sign in to comment.