mirror of
https://github.com/pdxlocations/contact.git
synced 2026-06-25 04:21:22 +02:00
Merge pull request #101 from rfschmid:use-nodes-by-num
Use nodesByNum instead of iterating over nodes
This commit is contained in:
+4
-5
@@ -10,12 +10,11 @@ import ui.dialog
|
||||
import globals
|
||||
|
||||
def draw_node_details():
|
||||
nodes_snapshot = list(globals.interface.nodes.values())
|
||||
|
||||
node = None
|
||||
for node in nodes_snapshot:
|
||||
if globals.node_list[globals.selected_node] == node['num']:
|
||||
break
|
||||
try:
|
||||
node = globals.interface.nodesByNum[globals.node_list[globals.selected_node]]
|
||||
except KeyError:
|
||||
return
|
||||
|
||||
function_win.erase()
|
||||
function_win.box()
|
||||
|
||||
@@ -57,21 +57,6 @@ def convert_to_camel_case(string):
|
||||
camel_case_string = ''.join(word.capitalize() for word in words)
|
||||
return camel_case_string
|
||||
|
||||
def get_name_from_number(number, type='long'):
|
||||
name = ""
|
||||
nodes_snapshot = list(globals.interface.nodes.values())
|
||||
|
||||
for node in nodes_snapshot:
|
||||
if number == node['num']:
|
||||
if type == 'long':
|
||||
return node['user']['longName']
|
||||
elif type == 'short':
|
||||
return node['user']['shortName']
|
||||
else:
|
||||
pass
|
||||
# If no match is found, use the ID as a string
|
||||
return str(decimal_to_hex(number))
|
||||
|
||||
def get_time_ago(timestamp):
|
||||
now = datetime.now()
|
||||
dt = datetime.fromtimestamp(timestamp)
|
||||
|
||||
Reference in New Issue
Block a user