projects
/
claws.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9e4d6e4
)
Fix bug 3285 ‘modify tbird2claws.py to handle subdirectory’
author
Ricardo Mones
<ricardo@mones.org>
Thu, 18 Sep 2014 08:35:22 +0000
(10:35 +0200)
committer
Ricardo Mones
<ricardo@mones.org>
Thu, 18 Sep 2014 08:35:22 +0000
(10:35 +0200)
tools/tbird2claws.py
patch
|
blob
|
history
diff --git
a/tools/tbird2claws.py
b/tools/tbird2claws.py
index e47290be6e1f5981d1b77e9c08fc33890b21eb1f..6144a68e1eeb5acefe4016e5ab5e17a0c8a0e83c 100755
(executable)
--- a/
tools/tbird2claws.py
+++ b/
tools/tbird2claws.py
@@
-95,19
+95,31
@@
def process_file(filepath, outputdir):
offs = harvest_offsets(filepath)
make_messages(outputdir, filepath, offs, 1)
offs = harvest_offsets(filepath)
make_messages(outputdir, filepath, offs, 1)
+def clean_path(path):
+ """Rename all directories and subdirectories <X>.sbd to <X>
+ """
+ l = []
+ f = os.path.basename(path)
+ while f and f != "":
+ if f.endswith('.sbd'):
+ f = f[:-4]
+ l.append(f)
+ path = os.path.dirname(path)
+ f = os.path.basename(path)
+ l.reverse()
+ r = os.path.join(*l)
+ return r
+
+
def convert_tree(in_treepath, out_treepath):
"""Traverse your thunderbird tree, converting each message file found into
a claws-mail message directory.
"""
for path,subs,files in os.walk(in_treepath):
def convert_tree(in_treepath, out_treepath):
"""Traverse your thunderbird tree, converting each message file found into
a claws-mail message directory.
"""
for path,subs,files in os.walk(in_treepath):
+ outpath = clean_path(path)
if files:
for f in [x for x in files if not x.endswith('.msf')]:
if files:
for f in [x for x in files if not x.endswith('.msf')]:
- if path.endswith('.sbd'):
- outpath = path[:-4]
- else:
- outpath = path
- print path,f
process_file(os.path.join(path,f),
os.path.join(out_treepath,outpath,f))
process_file(os.path.join(path,f),
os.path.join(out_treepath,outpath,f))