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 Jan 18, 2025
1 parent 99be97b commit 524c165
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 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--17-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--18-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
17 changes: 7 additions & 10 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-17', '%Y-%m-%d').date()
local_version = datetime.strptime('2025-01-18', '%Y-%m-%d').date()


class SSLContextAdapter(requests.adapters.HTTPAdapter):
Expand Down Expand Up @@ -548,7 +548,7 @@ def calculate_trends(values):
#
# At least five analyses of the URL are required to calculate reliable
# trends, and only the five most recent analyses are considered. The
# possible trend results are:
# possible trends are:
#
# 'Stable': All five values are identical.
# 'Improving': Values consistently decrease.
Expand Down Expand Up @@ -1080,7 +1080,7 @@ def parse_user_agent(user_agent=False):

def nourl_user_agent(user_agent_id):
try:
if int(user_agent_id) == 0:
if user_agent_id == '0':
return get_user_agent('0')
print_error_detail('[args_useragent]')
except ValueError:
Expand All @@ -1093,14 +1093,11 @@ def get_user_agent(user_agent_id):
user_agents = [line.strip() for line in islice(ua_source, SLICE_INT[1],
None)]

if user_agent_id == str(0):
if user_agent_id == '0':
print_user_agents(user_agents)
for line in user_agents:
if line.startswith(f"{user_agent_id}.-"):
offset = len(user_agent_id) + 3 if len(user_agent_id) == 1 else \
len(user_agent_id) + 2
return line[offset:].strip()

return line[4:].strip()
print_error_detail('[ua_invalid]')
sys.exit()

Expand Down Expand Up @@ -1627,7 +1624,7 @@ def handle_server_error(http_status_code, l10n_id):
print(detail)
else:
print((URL_LIST[2] if http_status_code in range(500, 512) else
URL_LIST[1]) + str(http_status_code))
URL_LIST[1]))
else:
print_error_detail('[server_serror]')
sys.exit()
Expand Down Expand Up @@ -1689,7 +1686,7 @@ def handle_http_error(r, exception_d):
except requests.exceptions.HTTPError as err_http:
http_status_code = err_http.response.status_code
l10n_id = f'[server_{http_status_code}]'
if str(http_status_code).startswith('5'):
if http_status_code // 100 == 5:
handle_server_error(http_status_code, l10n_id)
except tuple(exception_d.keys()) as e:
ex = exception_d.get(type(e))
Expand Down

0 comments on commit 524c165

Please sign in to comment.