also:
don't mix tabs and spaces (replace tabs)
a syntax fix
several typo fixes
Patch by Daniel Zaoui
Timo Teräs
H. Merijn Brand
Anton Butanaev
Timo Teräs
H. Merijn Brand
Anton Butanaev
"Yasumatsu",
"Ralgh Young",
"YUP",
"Yasumatsu",
"Ralgh Young",
"YUP",
"Gál Zoltán",
"Marien Zwart",
"Martin Zwickel",
"Gál Zoltán",
"Marien Zwart",
"Martin Zwickel",
__author__ = 'Rodrigo Senra <rsenra@acm.org>'
__date__ = '2005-03-23'
__author__ = 'Rodrigo Senra <rsenra@acm.org>'
__date__ = '2005-03-23'
The script receives two parameters from command-line:
<Thunderbird folder path> <Claws Mail folder path>
The script receives two parameters from command-line:
<Thunderbird folder path> <Claws Mail folder path>
-Best way to use it is to go to inside yout Thunderbird
+Best way to use it is to go to inside your Thunderbird
root mailfolder directory and invoke it as:
<path>\python2.4 <path>\tbird2syl.py . <path to claws mail>\Mail
root mailfolder directory and invoke it as:
<path>\python2.4 <path>\tbird2syl.py . <path to claws mail>\Mail
"""Given the filepath, this runs through the file finding
the number of the line where a message begins.
"""Given the filepath, this runs through the file finding
the number of the line where a message begins.
- The functions returns a list of integers corresponding to
- the begining of messages.
+ The function returns a list of integers corresponding to
+ the beginning of messages.
"""
offsets = []
i = 0
state = 'begin'
for i,line in enumerate(open(filepath)):
if line.startswith('From - ') and state!='found_head':
"""
offsets = []
i = 0
state = 'begin'
for i,line in enumerate(open(filepath)):
if line.startswith('From - ') and state!='found_head':
- offsets.append(i)
- continue
+ offsets.append(i)
+ continue
# elif line.startswith('Return-Path') and state=='found_head':
# state = 'found_offset'
# offsets.append(i)
# elif line.startswith('Return-Path') and state=='found_head':
# state = 'found_offset'
# offsets.append(i)
def make_messages(outputdir, filepath, offsets, start):
"""Given a filepath holding several messages in Thunderbird format,
def make_messages(outputdir, filepath, offsets, start):
"""Given a filepath holding several messages in Thunderbird format,
- extarct the messages and create individual files for them, inside
+ extract the messages and create individual files for them, inside
outputdir with appropriate the appropriate naming scheme.
"""
if not os.path.exists(outputdir):
outputdir with appropriate the appropriate naming scheme.
"""
if not os.path.exists(outputdir):
aux = offsets[:]
msgoffs = zip(offsets[:-1], aux[1:])
for i,j in msgoffs:
aux = offsets[:]
msgoffs = zip(offsets[:-1], aux[1:])
for i,j in msgoffs:
- fd = open(os.path.join(outputdir,"%d"%start),"w")
- fd.write(''.join(lines[i:j-1])) #-1 to remove first from line
- fd.close()
- start +=1
+ fd = open(os.path.join(outputdir,"%d"%start),"w")
+ fd.write(''.join(lines[i:j-1])) #-1 to remove first from line
+ fd.close()
+ start +=1
def process_file(filepath, outputdir):
def process_file(filepath, outputdir):
- """Integrates a Thunderbird message file into a claws-mail message diretory.
+ """Integrates a Thunderbird message file into a claws-mail message directory.
"""
offs = harvest_offsets(filepath)
make_messages(outputdir, filepath, offs, 1)
"""
offs = harvest_offsets(filepath)
make_messages(outputdir, filepath, offs, 1)
for f in [x for x in files if not x.endswith('.msf')]:
process_file(os.path.join(path,f),
os.path.join(out_treepath,outpath,f))
for f in [x for x in files if not x.endswith('.msf')]:
process_file(os.path.join(path,f),
os.path.join(out_treepath,outpath,f))
if __name__=='__main__':
if len(sys.argv)<3:
if __name__=='__main__':
if len(sys.argv)<3:
+ if sys.version[0] == '2':
+ reload(sys)
+ sys.setdefaultencoding('utf8')
convert_tree(sys.argv[1], sys.argv[2])
convert_tree(sys.argv[1], sys.argv[2])