Skip to content

Commit

Permalink
Minor: Code optimizations
Browse files Browse the repository at this point in the history
Improved several print functions
  • Loading branch information
rfc-st committed Jan 25, 2025
1 parent 6e583cb commit a0f98b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<a target="_blank" href="https://github.com/rfc-st/humble/blob/master/screenshots/humble_python.PNG" title="Minimum Python version required to run this tool"><img src="https://img.shields.io/badge/Python-%3E%3D3.8-blue?labelColor=343b41"></a>
<a target="_blank" href="LICENSE" title="License of this tool"><img src="https://img.shields.io/badge/License-MIT-blue.svg?labelColor=343b41"></a>
<a target="_blank" href="https://github.com/rfc-st/humble/releases" title="Latest release of this tool"><img src="https://img.shields.io/github/v/release/rfc-st/humble?display_name=release&label=Latest%20Release&labelColor=343b41"></a>
<a target="_blank" href="https://github.com/rfc-st/humble/commits/master" title="Latest commit of this tool"><img src="https://img.shields.io/badge/Latest_Commit-2025--01--24-blue.svg?labelColor=343b41"></a>
<a target="_blank" href="https://github.com/rfc-st/humble/commits/master" title="Latest commit of this tool"><img src="https://img.shields.io/badge/Latest_Commit-2025--01--25-blue.svg?labelColor=343b41"></a>
<a target="_blank" href="https://pkg.kali.org/pkg/humble" title="Official tool in Kali Linux"><img src="https://img.shields.io/badge/Kali%20Linux-Tool-blue?labelColor=343b41"></a>
<br />
<a target="_blank" href="#" title="Featured on:"><img src="https://img.shields.io/badge/Featured%20on:-343b41"></a>
Expand Down
28 changes: 14 additions & 14 deletions humble.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
XML_STRING = ('Ref: ', 'Value: ', 'Valor: ')

current_time = datetime.now().strftime("%Y/%m/%d - %H:%M:%S")
local_version = datetime.strptime('2025-01-24', '%Y-%m-%d').date()
local_version = datetime.strptime('2025-01-25', '%Y-%m-%d').date()


class SSLContextAdapter(requests.adapters.HTTPAdapter):
Expand Down Expand Up @@ -490,7 +490,7 @@ def generate_date_groups(year_cnt, url_ln):
year_str = f" {year}: {year_cnt[year]} \
{get_detail('[analysis_y]').rstrip()}"
month_cnts = get_month_counts(year, url_ln)
months_str = '\n'.join([f" ({count}){month_name.rstrip()}" for
months_str = '\n'.join([f" ({count}){month_name.rstrip()}" for
month_name, count in month_cnts.items()])
year_str += f"\n{months_str}\n"
years_str.append(year_str)
Expand All @@ -510,7 +510,7 @@ def get_month_counts(year, url_ln):
def get_highlights(adj_url_ln):
sections_h = SECTION_S[:-1]
fields_h = [2, 3, 4, 5, 6]
return [f"{print_detail_l(sections_h[i], analytics=True)}\n"
return [f" {print_detail_l(sections_h[i], analytics=True)}\n"
f" {print_detail_l('[best_analysis]', analytics=True)}: \
{calculate_highlights(adj_url_ln, fields_h[i], min if i != 0 else max)}\n"
f" {print_detail_l('[worst_analysis]', analytics=True)}: \
Expand Down Expand Up @@ -866,30 +866,30 @@ def print_detail(id_mode, num_lines=1):


def print_detail_l(id_mode, analytics=False):
for i, line in enumerate(l10n_main):
if line.startswith(id_mode):
for idmode_ln, idnext_ln in zip(l10n_main, l10n_main[1:]):
if idmode_ln.startswith(id_mode):
if not analytics:
print(l10n_main[i+1].replace('\n', ''), end='')
print(idnext_ln.replace('\n', ''), end='')
else:
return l10n_main[i+1].replace('\n', '').replace(':', '')[1:]
return idnext_ln.replace('\n', '').replace(':', '')[1:]


def print_detail_r(id_mode, is_red=False):
style_str = STYLE[1] if is_red else STYLE[0]
for i, line in enumerate(l10n_main):
if line.startswith(id_mode):
for idmode_ln, idnext_ln in zip(l10n_main, l10n_main[1:]):
if idmode_ln.startswith(id_mode):
if not args.output:
print(f"{style_str}{l10n_main[i+1]}", end='')
print(f"{style_str}{idnext_ln}", end='')
else:
print(l10n_main[i+1], end='')
print(idnext_ln, end='')
if not is_red:
print("")


def print_detail_s(id_mode):
for i, line in enumerate(l10n_main):
if line.startswith(id_mode):
return f"\n{l10n_main[i+1].rstrip()}"
for idmode_ln, idnext_ln in zip(l10n_main, l10n_main[1:]):
if idmode_ln.startswith(id_mode):
return f"\n{idnext_ln.strip()}"


def get_detail(id_mode, replace=False):
Expand Down

0 comments on commit a0f98b3

Please sign in to comment.