-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions_contact.py
66 lines (58 loc) · 2.52 KB
/
functions_contact.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from .payload_contact import check_if_exist, check_account_for_email, check_account
from general_functions.functions import get_nodes
from kivymd.uix.snackbar import Snackbar
data_contact = {}
def build_contact(data):
global data_contact
result = set_and_get(data)
if result:
for key in result:
if result[key] is False:
Snackbar(text="connection with the server was lost", padding="20dp").open()
return None
if key == 'node2':
if result[key] is None:
Snackbar(text="Entity name not found", padding="20dp").open()
return None
else:
data_contact['node2'] = get_nodes(data)['node2']
if key == 'node3':
if result[key] is None:
Snackbar(text="Area name not found", padding="20dp").open()
return None
else:
data_contact['node3'] = get_nodes(data)['node3']
if key == 'node4':
if result[key] is None:
Snackbar(text="Member not found", padding="20dp").open()
return None
else:
print("result", result['node4'], type(result))
data_contact['node4'] = result['node4']['idName']
data_contact['id_tk'] = result['node4']['id']
else:
Snackbar(text="No result, the input is incorrect", padding="20dp").open()
return None
return data_contact
def set_and_get(data):
if data and len(data) >= 5:
if data[0] == '@':
""" the data is maybe entity name, check for nodes"""
data_contact = check_if_exist(data)
return data_contact
if data[0] == '.':
""" the data maybe is account name """
data_contact = {'node4': check_account(data)}
return data_contact
if data.find("@") > 3 and data.find(".") > 4 and data.find("#") == -1:
""" the data is maybe some email, try get account """
data_contact = {'node4': check_account_for_email(data)}
return data_contact
if data.find("@") == -1 and data.find(".") == -1 and data.find("#") == -1 and len(data) < 16:
""" the data maybe is account name, but without dot """
data = '.' + data
data_contact = {'node4': check_account(data)}
print("data_contact: ", data_contact)
return data_contact
else:
return None