-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate2.py
executable file
·40 lines (34 loc) · 1.13 KB
/
update2.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
#!/usr/bin/env python
'''
inserire i vecchi valori di config.cfg nel database
config.cfg --> database
'''
from mangareader import store, Manga, Mail, Chapter
import re
def convert_name(manga):
return manga.replace("'","")\
.replace(' - ',' ')\
.replace(' ','-')\
.replace('!','')\
.replace(':','')\
.lower()
if __name__ == "__main__":
# Se presenti, linka i capitoli scaricati ai rispettivi manga
mangas = store.find(Manga)
for manga in mangas:
manga_name =unicode('%' + convert_name(manga.name) + '%')
try:
chapters = store.find(Chapter, Chapter.link.like(manga_name))
for chapter in chapters:
if not chapter.id_manga:
chapter.id_manga = manga.id
print ' set id_manga: %s (%s)' % (manga.id, manga.name)
except:
print 'problemi con %s' % manga_name
exit(1)
store.commit()
# check
chapters = store.find(Chapter)
for chapter in chapters:
if not chapter.id_manga:
print 'capitolo non associato: %s' % chapter.link