Skip to content

Commit ca71700

Browse files
committed
Enhance JSON attribute handling in import_ind.py and update config.yml for taiga_pri.json mapping
1 parent e8835ca commit ca71700

File tree

3 files changed

+172
-71
lines changed

3 files changed

+172
-71
lines changed

config.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,91 @@
11
---
2+
taiga_pri.json:
3+
exclude:
4+
- sn: ^#
5+
- givenName: ^#
6+
- customFields.formation: .+
7+
mapping:
8+
inetOrgPerson.cn:
9+
- "nom"
10+
- "prenom"
11+
inetOrgPerson.displayName:
12+
- "prenom"
13+
- "nom"
14+
inetOrgPerson.sn: "nom"
15+
inetOrgPerson.givenName: "prenom"
16+
additionalFields.attributes.supannPerson.supannPrenomsEtatCivil: "prenom"
17+
$setOnInsert.inetOrgPerson.employeeNumber:
18+
- "id_coord"
19+
customFields.photo: "photo_nom"
20+
customFields.formation: "formation"
21+
$setOnInsert.inetOrgPerson.uid:
22+
- "prenom"
23+
- "nom"
24+
additionalFields.attributes.supannPerson.supannEtuId: "num_etd"
25+
additionalFields.attributes.supannPerson.supannRefId:
26+
- "id_coord"
27+
- "id_etd"
28+
$setOnInsert.inetOrgPerson.departmentEmployee:
29+
- "id_coord"
30+
$setOnInsert.inetOrgPerson.mail:
31+
- "prenom"
32+
- "nom"
33+
inetOrgPerson.mobile: "tel_mob"
34+
inetOrgPerson.postalAddress:
35+
- "adresse"
36+
- "CP"
37+
- "Ville"
38+
additionalFields.attributes.supannPerson.supanncivilite: "civilite"
39+
additionalFields.attributes.supannPerson.supannOIDCGenre: "civilite"
40+
additionalFields.attributes.supannPerson.supannNomdeNaissance: "nom_marital"
41+
additionalFields.attributes.supannPerson.supannOIDCDatedeNaissance: "nss_date"
42+
additionalFields.attributes.supannPerson.supannAutreMail: "email2"
43+
additionalFields.attributes.eduPerson.edupersonprincipalname:
44+
- "prenom"
45+
- "nom"
46+
customFields.photo: "photo_nom"
47+
additionalFields:
48+
additionalFields.objectClasses:
49+
- "supannPerson"
50+
- "eduPerson"
51+
- "sogxuser"
52+
additionalFields.attributes.supannPerson.supannTypeEntiteAffectation:
53+
- "etd"
54+
state: -1
55+
inetOrgPerson.employeeType: "TAIGA"
56+
$setOnInsert.inetOrgPerson.departmentNumber:
57+
- "etd"
58+
additionalFields.attributes.supannPerson.supannEtablissement: "{UAI}0690184A"
59+
$setOnInsert.additionalFields.attributes.eduPerson.edupersonaffiliation:
60+
- "etudiant"
61+
- "member"
62+
$setOnInsert.additionalFields.attributes.eduPerson.edupersonprimaryaffiliation: "etudiant"
63+
$setOnInsert.additionalFields.attributes.sogxuser.sogxquota: 600
64+
$setOnInsert.additionalFields.attributes.sogxuser.sogxdisableflag: 0
65+
transforms:
66+
inetOrgPerson.cn: "join(delimiter=' ')"
67+
inetOrgPerson.displayName: "join(delimiter=' ')"
68+
inetOrgPerson.postalAddress: "join(delimiter=',')"
69+
$setOnInsert.inetOrgPerson.uid:
70+
- "join(delimiter='.')"
71+
- "remove_accents"
72+
- "lower"
73+
- "replace(old=' ',new='-')"
74+
- "regex(pattern='(?<=\\b\\w)([a-zA-Z0-9_\\-]+\\.)', replace='')"
75+
$setOnInsert.inetOrgPerson.mail:
76+
- "join(delimiter='.')"
77+
- "lower"
78+
- "remove_accents"
79+
- "replace(old=' ',new='-')"
80+
- "suffix(string='@lyon.archi.fr')"
81+
additionalFields.attributes.eduPerson.edupersonprincipalname:
82+
- "join(delimiter='.')"
83+
- "remove_accents"
84+
- "lower"
85+
- "replace(old=' ',new='-')"
86+
- "regex(pattern='(?<=\\b\\w)([a-zA-Z0-9_\\-]+\\.)', replace='')"
87+
- "suffix(string='@lyon.archi.fr')"
88+
289
taiga_etd.json:
390
exclude:
491
- sn: ^#

main.py

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -51,75 +51,75 @@
5151
"id": "*",
5252
},
5353
},
54-
{
55-
"function": export_ind,
56-
"method": "ExportInd",
57-
"params": {
58-
**ensa_infos,
59-
"type": "etd",
60-
"id": "*",
61-
},
62-
},
63-
{
64-
"function": export_ind,
65-
"method": "ExportInd",
66-
"params": {
67-
**ensa_infos,
68-
"type": "adm",
69-
"id": "*",
70-
},
71-
},
72-
{
73-
"function": export_ind,
74-
"method": "ExportInd",
75-
"params": {
76-
**ensa_infos,
77-
"type": "esn",
78-
"id": "*",
79-
},
80-
},
81-
{
82-
"function": export_pictures,
83-
"method": "ExportPhotos",
84-
"methodBase64": "ExportPhoto",
85-
"params": {
86-
**ensa_infos,
87-
"type": "etd",
88-
"id": "*",
89-
},
90-
"paramsBase64": {
91-
"type": "etd",
92-
**ensa_infos,
93-
},
94-
},
95-
{
96-
"function": export_pictures,
97-
"method": "ExportPhotos",
98-
"methodBase64": "ExportPhoto",
99-
"params": {
100-
**ensa_infos,
101-
"type": "adm",
102-
"id": "*",
103-
},
104-
"paramsBase64": {
105-
"type": "adm",
106-
**ensa_infos,
107-
},
108-
},
109-
{
110-
"function": export_pictures,
111-
"method": "ExportPhotos",
112-
"methodBase64": "ExportPhoto",
113-
"params": {
114-
**ensa_infos,
115-
"type": "esn",
116-
"id": "*",
117-
},
118-
"paramsBase64": {
119-
"type": "esn",
120-
**ensa_infos,
121-
},
122-
},
54+
# {
55+
# "function": export_ind,
56+
# "method": "ExportInd",
57+
# "params": {
58+
# **ensa_infos,
59+
# "type": "etd",
60+
# "id": "*",
61+
# },
62+
# },
63+
# {
64+
# "function": export_ind,
65+
# "method": "ExportInd",
66+
# "params": {
67+
# **ensa_infos,
68+
# "type": "adm",
69+
# "id": "*",
70+
# },
71+
# },
72+
# {
73+
# "function": export_ind,
74+
# "method": "ExportInd",
75+
# "params": {
76+
# **ensa_infos,
77+
# "type": "esn",
78+
# "id": "*",
79+
# },
80+
# },
81+
# {
82+
# "function": export_pictures,
83+
# "method": "ExportPhotos",
84+
# "methodBase64": "ExportPhoto",
85+
# "params": {
86+
# **ensa_infos,
87+
# "type": "etd",
88+
# "id": "*",
89+
# },
90+
# "paramsBase64": {
91+
# "type": "etd",
92+
# **ensa_infos,
93+
# },
94+
# },
95+
# {
96+
# "function": export_pictures,
97+
# "method": "ExportPhotos",
98+
# "methodBase64": "ExportPhoto",
99+
# "params": {
100+
# **ensa_infos,
101+
# "type": "adm",
102+
# "id": "*",
103+
# },
104+
# "paramsBase64": {
105+
# "type": "adm",
106+
# **ensa_infos,
107+
# },
108+
# },
109+
# {
110+
# "function": export_pictures,
111+
# "method": "ExportPhotos",
112+
# "methodBase64": "ExportPhoto",
113+
# "params": {
114+
# **ensa_infos,
115+
# "type": "esn",
116+
# "id": "*",
117+
# },
118+
# "paramsBase64": {
119+
# "type": "esn",
120+
# **ensa_infos,
121+
# },
122+
# },
123123
]
124124

125125

src/import_ind.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,23 @@ async def send_request(session, url,exclusions, json, force):
5252

5353
for regex in exclusions:
5454
for r in regex:
55-
value=json.get('inetOrgPerson').get(r)
55+
# Handle nested attributes with dot notation (parent.enfant ...)
56+
if '.' in r:
57+
parts = r.split('.')
58+
current = json
59+
for part in parts:
60+
if current and isinstance(current, dict) and part in current:
61+
current = current.get(part)
62+
else:
63+
current = None
64+
break
65+
value = current
66+
else:
67+
# Default to inetOrgPerson if no dot in attribute name
68+
value = json.get('inetOrgPerson', {}).get(r)
69+
5670
if value:
57-
result=re.search(regex[r],value)
71+
result = re.search(regex[r], value)
5872
if result != None:
5973
print(f"EXCLUDED {json.get('inetOrgPerson', {}).get('employeeNumber')} {json.get('inetOrgPerson', {}).get('cn')}")
6074
return

0 commit comments

Comments
 (0)