-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnotes2mbox.py
More file actions
54 lines (43 loc) · 1.56 KB
/
notes2mbox.py
File metadata and controls
54 lines (43 loc) · 1.56 KB
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
# -*- coding: utf-8 -*-
# auteur : pzia <paparazzia@gmail.com>
# Pour utiliser ce script :
# * Installer python 2.6 pour windows
# * Installer pywin 2.6 pour windows
# * (optionnellement) enregistrer la dll com de notes : "regsvr32 c:\notes\nlsxbe.dll"
# * en ligne de commande (cmd) :
# SET PATH=%PATH%;C:\Python26
# **pour l'instant** fixer notesPasswd et notesNsfPath plus bas
# python notes2mbox.py
# => un fichier .mbox sera créé qu'il suffit de copier dans le répertoire ad-hoc de Thunderbird (ou d'un autre client...)
import sys
import NlconverterLib
#Constantes
notesPasswd = "foobar"
notesNsfPath = "C:\\archive.nsf"
#Connection à Notes
db = NlconverterLib.getNotesDb(notesNsfPath, notesPasswd)
#all = tous les documents
all=db.AllDocuments
ac = all.Count
print "Nombre de documents :", ac
c = 0 #compteur de documents
e = 0 #compteur d'erreur à la conversion
mc = NlconverterLib.NotesToMboxConverter(notesNsfPath+".mbox")
ic = NlconverterLib.NotesToIcalConverter(notesNsfPath+".ics")
doc = all.GetFirstDocument()
while doc and c < 100000 and e < 99999:
try:
mc.addDocument(doc)
ic.addDocument(doc)
except Exception, ex:
e += 1 #compte les exceptions
print "\n--Exception for message %d (%s)" % (c, ex)
mc.debug(doc)
finally:
doc = all.GetNextDocument(doc)
c+=1
if (c % 100) == 0:
sys.stderr.write("%.1f%%, e=%d, c=%d\n" % (float(100.*c/ac), e, c) )
print "Exceptions a traiter manuellement:", e, "... documents OK : ", c
mc.close()
ic.close()