Skip to content

Commit 5d759b5

Browse files
committed
lint
1 parent 0ad7f62 commit 5d759b5

File tree

1 file changed

+28
-29
lines changed
  • Raspberry_Pi_Severance_MDR_Terminal

1 file changed

+28
-29
lines changed

Raspberry_Pi_Severance_MDR_Terminal/lumon.py

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@ def get_username():
4040
except Exception:
4141
pass
4242
return "Mark S."
43+
44+
def generate_serial_number(username):
45+
"""
46+
Generate a Severance-style serial number based on the username.
47+
Format: 0xAAAAAA : 0xBBBBBB where A and B are hex values derived from username.
48+
"""
49+
username_bytes = username.encode('utf-8')
50+
first_hex = 0
51+
for i in range(min(3, len(username_bytes))):
52+
first_hex = (first_hex << 8) | username_bytes[i]
53+
second_hex = 0
54+
if len(username_bytes) > 3:
55+
remaining_bytes = username_bytes[3:]
56+
for i, byte in enumerate(remaining_bytes):
57+
second_hex ^= (byte << (8 * (i % 3)))
58+
else:
59+
hash_obj = hashlib.md5(username_bytes)
60+
digest = hash_obj.digest()
61+
second_hex = int.from_bytes(digest[:3], byteorder='big')
62+
serial = f"0x{first_hex:06X} : 0x{second_hex:06X}"
63+
return serial
64+
def calculate_distance(x1, y1, x2, y2):
65+
"""Calculate Euclidean distance between two points"""
66+
return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
4367
# pylint: disable=too-many-branches,too-many-lines,broad-except,unused-argument
4468
# pylint: disable=too-many-statements,too-many-locals,too-many-public-methods,too-many-nested-blocks
4569
class MacrodataRefinementTerminal:
@@ -53,8 +77,8 @@ def __init__(self, username=None, location=LOCATION):
5377
self.completion = 0
5478
self.total_goal = TOTAL_REFINEMENT_GOAL
5579
self.total_refined = 0
56-
self.image_path = f"/home/{self.username}/lumon-logo.png"
57-
self.logo_img = Image.open(f"/home/{self.username}/lumon-logo-small.png")
80+
self.image_path = "lumon-logo.png"
81+
self.logo_img = Image.open("lumon-logo-small.png")
5882

5983
# graphics
6084
self.root = tk.Tk()
@@ -213,27 +237,6 @@ def apply_mouse_avoidance(self, number):
213237
if abs(number.mouse_offset_y) < 0.05:
214238
number.mouse_offset_y = 0
215239

216-
def generate_serial_number(self, username):
217-
"""
218-
Generate a Severance-style serial number based on the username.
219-
Format: 0xAAAAAA : 0xBBBBBB where A and B are hex values derived from username.
220-
"""
221-
username_bytes = username.encode('utf-8')
222-
first_hex = 0
223-
for i in range(min(3, len(username_bytes))):
224-
first_hex = (first_hex << 8) | username_bytes[i]
225-
second_hex = 0
226-
if len(username_bytes) > 3:
227-
remaining_bytes = username_bytes[3:]
228-
for i, byte in enumerate(remaining_bytes):
229-
second_hex ^= (byte << (8 * (i % 3)))
230-
else:
231-
hash_obj = hashlib.md5(username_bytes)
232-
digest = hash_obj.digest()
233-
second_hex = int.from_bytes(digest[:3], byteorder='big')
234-
serial = f"0x{first_hex:06X} : 0x{second_hex:06X}"
235-
return serial
236-
237240
def save_progress(self, filepath=None):
238241
"""
239242
Save the current progress and bin data to a JSON file.
@@ -396,7 +399,7 @@ def create_ui_elements(self):
396399
self.margin + usable_width + 5, bottom_frame_y + footer_height,
397400
outline=self.palette.FG, fill=self.palette.FG, width=2
398401
)
399-
serial = self.generate_serial_number(self.username)
402+
serial = generate_serial_number(self.username)
400403
self.ui_elements['serial'] = self.canvas.create_text(
401404
self.margin + usable_width/2, bottom_frame_y + footer_height/2,
402405
text=serial,
@@ -883,7 +886,7 @@ def select_random_wiggle_group(self):
883886
return
884887
seed_number = random.choice(available_numbers)
885888
for number in available_numbers:
886-
number.distance_to_seed = self.calculate_distance(
889+
number.distance_to_seed = calculate_distance(
887890
seed_number.x, seed_number.y, number.x, number.y
888891
)
889892
available_numbers.sort(key=lambda n: n.distance_to_seed)
@@ -893,10 +896,6 @@ def select_random_wiggle_group(self):
893896
for number in self.wiggle_numbers:
894897
number.needs_refinement = True
895898

896-
def calculate_distance(self, x1, y1, x2, y2):
897-
"""Calculate Euclidean distance between two points"""
898-
return math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
899-
900899
def wiggle_selected_numbers(self):
901900
"""Apply smooth, floating wiggle effect to numbers
902901
that need refinement and update haptics

0 commit comments

Comments
 (0)