Skip to content

Commit

Permalink
MInor: Code optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc-st committed Jul 10, 2023
1 parent f0943ef commit d88cc96
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
32 changes: 16 additions & 16 deletions humble.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
from fpdf import FPDF
from time import time
from datetime import datetime
from collections import Counter, defaultdict
from os import linesep, path, remove
from colorama import Fore, Style, init
from collections import Counter, defaultdict
from argparse import ArgumentParser, RawDescriptionHelpFormatter
import sys
import re
import sys
import requests
import tldextract

Expand Down Expand Up @@ -150,15 +150,15 @@ def check_updates(version):


def fng_analytics_global_groups(fng_lines):
pattern = r'\[([^\]]+)\]'
content_count = Counter(match.strip() for line in fng_lines for match in
re.findall(pattern, line))
total_lines = len(fng_lines)
print(f"{get_detail('[fng_top]', replace=True)}{total_lines}\
pattern_fng_global = r'\[([^\]]+)\]'
content_cnt = Counter(match.strip() for line in fng_lines for match in
re.findall(pattern_fng_global, line))
total_ln = len(fng_lines)
print(f"{get_detail('[fng_top]', replace=True)}{total_ln}\
{get_detail('[fng_top_2]', replace=True)}\n")
for content, count in content_count.most_common(20):
percentage = round(count / total_lines * 100, 2)
print(f" [{content}]: {percentage}% ({count})")
for content, count in content_cnt.most_common(20):
pct_fng_global = round(count / total_ln * 100, 2)
print(f" [{content}]: {pct_fng_global}% ({count})")


def fng_analytics_global():
Expand All @@ -169,15 +169,15 @@ def fng_analytics_global():
fng_analytics_global_groups(fng_lines)


def fng_analytics_groups(fng_lines, term):
pattern = r'\[(.*?)\]'
def fng_analytics_groups(fng_ln, term):
pattern_fng = r'\[(.*?)\]'
distinct_content = \
{match[1].strip()
for line in fng_lines if (match := re.search(pattern, line)) and
for line in fng_ln if (match := re.search(pattern_fng, line)) and
term.lower() in match[1].lower()}
term_count = sum(bool((match := re.search(pattern, line)) and term.lower()
in match[1].lower()) for line in fng_lines)
return distinct_content, term_count
term_cnt = sum(bool((match := re.search(pattern_fng, line)) and
term.lower() in match[1].lower()) for line in fng_ln)
return distinct_content, term_cnt


def fng_analytics_sorted(fng_lines, term, distinct_content):
Expand Down
6 changes: 3 additions & 3 deletions i10n/details.txt
Original file line number Diff line number Diff line change
Expand Up @@ -878,13 +878,13 @@ Highlights
HTTP fingerprint headers statistics

[fng_source]
(source: "additional/fingerprint.txt")
(source file: "additional/fingerprint.txt")

[fng_add]
Related to

[fng_top]
Top 20 in relation to the
Top 20 groups in relation to the

[fng_top_2]
headers of the source
headers of the source file
4 changes: 2 additions & 2 deletions i10n/details_es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -878,13 +878,13 @@ A destacar
Estadísticas de huella digital por cabeceras

[fng_source]
(fuente: "additional/fingerprint.txt")
(fichero fuente: "additional/fingerprint.txt")

[fng_add]
Asociadas a

[fng_top]
Top 20 en relación a las
Top 20 de grupos en relación a las

[fng_top_2]
cabeceras del fichero fuente

0 comments on commit d88cc96

Please sign in to comment.