-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3-sociosdana.py
executable file
·120 lines (106 loc) · 2.14 KB
/
3-sociosdana.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python
import common
codigos_postales = [
46012,
46014,
46117,
46160,
46164,
46165,
46166,
46168,
46175,
46190,
46191,
46195,
46196,
46197,
46198,
46200,
46210,
46220,
46230,
46240,
46250,
46290,
46300,
46314,
46315,
46320,
46330,
46340,
46360,
46367,
46368,
46369,
46370,
46380,
46388,
46389,
46392,
46393,
46410,
46417,
46418,
46430,
46440,
46450,
46460,
46469,
46470,
46600,
46610,
46613,
46614,
46650,
46680,
46687,
46688,
46689,
46760,
46900,
46910,
46940,
46950,
46960,
46970,
46980,
]
print("Loading file from disk")
users = common.readjson(filename="socios")
affected = []
telegramids = []
for user in users:
if (
"estat" in user
and user["estat"] == "COLESTVAL"
and "estatColegiat" in user
and user["estatColegiat"]["nom"] == "ESTALTA"
):
try:
cp = int(user["persona"]["adreces"][0]["municipi"]["codipostal"])
except Exception:
cp = 0
if cp in codigos_postales:
affected.append(user["idColegiat"])
if isinstance(user["campsDinamics"], dict):
for field in common.telegramfields:
if field in user["campsDinamics"]:
try:
userid = user["campsDinamics"][field]
except Exception:
userid = False
if userid and (
"estat" in user
and user["estat"] == "COLESTVAL"
and "estatColegiat" in user
and user["estatColegiat"]["nom"] == "ESTALTA"
):
telegramids.append(userid)
affected = sorted(set(affected))
print("########## SOCIOS #######")
print(affected)
print(len(affected))
print("########## IDS Telegram #######")
print(sorted(set(telegramids)))
print(len(telegramids))