Skip to content

Commit

Permalink
added some regex for better parsing & matching
Browse files Browse the repository at this point in the history
  • Loading branch information
radovan committed Oct 8, 2009
1 parent fa0b7ff commit 5b4805c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pygtranslator
Expand Up @@ -3,7 +3,7 @@
__version__ = "0.2"
__author__ = "xrado"

import sys,os
import sys,os,re

## Windows
if sys.platform == 'win32':
Expand Down Expand Up @@ -118,7 +118,7 @@ class PyGTranslator:

self.combo = self.xml.get_widget('combobox1')
f_list = gtk.ListStore(str,str)
self.FROM = self.get_langs("<select name=sl id=old_sl tabindex=0>");
self.FROM = self.get_langs("<selectfrom>");
self.FROM = sorted( self.FROM.items(), key=lambda x: x[1] )
for a in self.FROM: f_list.append([a[1],a[0]])
cell = gtk.CellRendererText()
Expand All @@ -129,7 +129,7 @@ class PyGTranslator:

self.combo2 = self.xml.get_widget('combobox2')
f_list2 = gtk.ListStore(str,str)
self.TO = self.get_langs("<select name=tl id=old_tl tabindex=0>");
self.TO = self.get_langs("<selectto>");
self.TO = sorted( self.TO.items(), key=lambda x: x[1] )
for a in self.TO: f_list2.append([a[1],a[0]])
cell2 = gtk.CellRendererText()
Expand Down Expand Up @@ -199,6 +199,8 @@ class PyGTranslator:

if resp.status == 200:
result = resp.read()
result = re.sub('\<select\ name\=sl.*?\>','<selectfrom>',result)
result = re.sub('\<select\ name\=tl.*?\>','<selectto>',result)
result = result[result.index(start):]
result = result[result.index("<option"):]
result = result[:result.index("</select>")]
Expand Down

0 comments on commit 5b4805c

Please sign in to comment.