forked from miaout17/blogtrans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blogtrans.py
50 lines (41 loc) · 1.36 KB
/
blogtrans.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
41
42
43
44
45
46
47
48
49
50
from blogtrans.ui.MainWindow import *
import sys, traceback
import getopt
import wx
# Importers / Exporters
from blogtrans.wretch.WretchImporter import WretchImporter
from blogtrans.mt import *
from blogtrans.blogger.BloggerExporter import *
from blogtrans.blogger.BloggerImporter import *
def trap_error(func) :
def f() :
try:
func()
except Exception, inst :
type, value, tb = sys.exc_info()
print "\n".join(traceback.format_exception(type, value, tb))
raw_input()
return f
@trap_error
def main() :
long_opts = [ "import-wretch=", "import-blogger=" ]
opts, args = getopt.getopt(sys.argv[1:], "n", long_opts)
blogdata = None
no_window = False
for o, a in opts :
if o=="-n" :
no_window = True
if o=="--import-wretch" :
blogdata = WretchImporter(a).parse()
print "%d articles, %d comments" % ( blogdata.article_count(), blogdata.comment_count() )
if o=="--import-blogger" :
blogdata = BloggerImporter(a).parse()
print "%d articles, %d comments" % ( blogdata.article_count(), blogdata.comment_count() )
if not no_window :
app = wx.PySimpleApp()
frame = MainWindow()
if blogdata!=None:
frame.setBlogData(blogdata)
app.MainLoop()
if __name__ == "__main__" :
main()