diff options
author | George Hazan <george.hazan@gmail.com> | 2012-11-28 18:45:54 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-11-28 18:45:54 +0000 |
commit | a70382b0e8bed265a1d314d9f6aae8f2dd48d20b (patch) | |
tree | 9a99a073c0d7b9483dab51a0eebf04a9119f61ed /plugins/Quotes/docs/Utility/DukasCopy.py | |
parent | 68fb5b69ea8403a3f9dcb70b3133eb10e1711000 (diff) |
ex-protos moved to the Plugins folder
git-svn-id: http://svn.miranda-ng.org/main/trunk@2545 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Quotes/docs/Utility/DukasCopy.py')
-rw-r--r-- | plugins/Quotes/docs/Utility/DukasCopy.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/Quotes/docs/Utility/DukasCopy.py b/plugins/Quotes/docs/Utility/DukasCopy.py new file mode 100644 index 0000000000..2d12d1c4ec --- /dev/null +++ b/plugins/Quotes/docs/Utility/DukasCopy.py @@ -0,0 +1,48 @@ +from html.parser import HTMLParser
+import sys
+
+class MyHTMLParser(HTMLParser):
+ def __init__(self, in_fn,out_fn):
+ HTMLParser.__init__(self)
+ f_in = open(in_fn,'r')
+ self.quote = 0
+ self.descr = ''
+ self.f_out = open(out_fn,'w')
+ self.feed(f_in.read())
+ f_in.close()
+ self.f_out.close()
+
+ def handle_starttag(self, tag, attrs):
+ #print ("start of a %s" % tag)
+ #print (attrs)
+ self.start = 1
+ if tag == 'input':
+ self.f_out.write('\n<quote>')
+ for k in attrs:
+ if k[0] == 'stname':
+ self.f_out.write('\n\t<symbol>%s</symbol>'%k[1])
+ if k[0] == 'stid':
+ self.f_out.write('\n\t<id>%s</id>'%k[1])
+ self.quote = 1
+
+
+ def handle_endtag(self, tag):
+ self.start = 0
+ if tag == 'tr' and self.quote == 1:
+ if self.descr:
+ self.f_out.write('\n\t<description>%s</description>'%self.descr)
+ self.f_out.write('\n</quote>')
+ self.quote = 0
+ self.descr = 1
+ #print ("end of a %s" % tag)
+
+ def handle_data(self, data):
+ if self.start == 1:
+ self.descr = data
+ #print ("Data %s" % self.descr)
+
+
+
+parser = MyHTMLParser(sys.argv[1],sys.argv[2])
+parser.close()
+
\ No newline at end of file |