Suppression des dossiers et autres fichiers invalides de l'API
This commit is contained in:
parent
1f5de562be
commit
3d295f3a02
1 changed files with 15 additions and 2 deletions
17
main.py
17
main.py
|
@ -89,6 +89,7 @@ def visit_folder(domain, api, rules, tok):
|
|||
#print('api titles:', '|'.join(sorted([f.title for f in Lapi])))
|
||||
|
||||
# supprime les dossiers de l'api (ils ne devraient pas apparaître)
|
||||
Linvalid = [f for f in Lapi if (not tok.conf.is_valid_file(f.name)) or not (filerule.match_rules(f.path+'/'+f.name, rules))]
|
||||
Lapi = [f for f in Lapi if tok.conf.is_valid_file(f.name)]
|
||||
|
||||
# Compare avec la liste de l'api
|
||||
|
@ -148,12 +149,24 @@ def visit_folder(domain, api, rules, tok):
|
|||
for f, _ in Llink2:
|
||||
Lunref.remove(f)
|
||||
|
||||
print('invalid:\n'+'\n'.join(str(f.api_fileid)+' '+str(f) for f in Linvalid))
|
||||
print('missing (', len(Lmissing), '):\n','\n'.join([str(e.api_id)+':'+repr(e)+'('+e.title+')' for e in sorted(Lmissing, key=lambda e:e.title)]))
|
||||
print('\n'*3)
|
||||
print('unreferenced:\n','\n'.join(str(f) for f in sorted(Lunref, key=lambda e:e.title)))
|
||||
print('unreferenced:\n'+'\n'.join(str(f) for f in sorted(Lunref, key=lambda e:e.title)))
|
||||
print('\n'*3)
|
||||
#print('unreferenced titles:\n', '\n'.join(sorted([f.title for f in Lunref])))
|
||||
|
||||
|
||||
# Supprime les fichiers invalides (dossiers/ ne répondent à aucune règle)
|
||||
for i, film in enumerate(Linvalid):
|
||||
print('['+str(i+1)+'/'+str(len(Linvalid))+']'+'invalid:', film)
|
||||
try:
|
||||
resp = api.delete_file(id=film.api_fileid)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print('film '+film.title+' not deleted')
|
||||
raise Exception('end')
|
||||
time.sleep(1)
|
||||
|
||||
# Supprime les fichiers qui n'existent plus
|
||||
for i, film in enumerate(Lmissing):
|
||||
print('['+str(i+1)+'/'+str(len(Lmissing))+']'+'missing:', film)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue