-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-nueva-hornada.py
executable file
·87 lines (69 loc) · 2.26 KB
/
4-nueva-hornada.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
#!/usr/bin/env python
import configparser
import datetime
import os
import dateutil.parser
import common
config = configparser.ConfigParser()
config.read(os.path.expanduser("~/.avast.ini"))
token = common.gettoken(
user=config["auth"]["RWusername"], password=config["auth"]["RWpassword"]
)
headers = {"Authorization": f"Bearer {token}"}
# Definiciones
nuevos = 74
# Leer datos
socios = common.readjson("socios")
categorias = common.readjson("categorias")
today = datetime.date.today()
# Locate our member in the list of members
for socio in socios:
if (
"estat" in socio
and socio["estat"] == "COLESTVAL"
and "estatColegiat" in socio
and socio["estatColegiat"]["nom"] == "ESTALTA"
):
# ID Socio
socioid = socio["idColegiat"]
alta = socio["dataAlta"]
numsocio = int(socio["numColegiat"])
# Find our born year
try:
alta = dateutil.parser.parse(alta)
except Exception:
alta = False
print(f"ERROR: Sin fecha alta para socio ID: {socioid}")
categoriassocio = []
for categoria in socio["colegiatHasModalitats"]:
idcategoria = int(categoria["idModalitat"])
categoriassocio.append(idcategoria)
if alta.year >= 2024 and alta.month >= 9:
targetcategorias = [nuevos]
else:
targetcategorias = []
if numsocio > 60000:
targetcategorias = []
for categoria in targetcategorias:
if categoria not in categoriassocio:
print(
"IFF",
socioid,
categoria,
categoriassocio,
categoria in categoriassocio,
)
response = common.addcategoria(token, socioid, categoria)
categoria = nuevos
if categoria in categoriassocio and (
targetcategorias == [] or targetcategorias is None
):
# Remove Temporal if not in range
print(
"RFF",
socioid,
categoria,
categoriassocio,
categoria in categoriassocio,
)
response = common.delcategoria(token, socioid, categoria)