rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
db_file_path = wordgroupz_dir+'/wordz'
db_file_path = wordgroupz_dir+'/wordgroupz.db'
def stopped(self): return self._stop.isSet()
544f236d51f79279c6b1e20751e385292f039631 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/544f236d51f79279c6b1e20751e385292f039631/wordgroupz.py
c.execute("""insert into groups values ('no-category','Uncategorized words')""")
c.execute("""insert into groups values ('no-category','Uncategorized words', '', '', '')""")
def add_to_db(self,word, grp, detail): conn = sqlite3.connect(db_file_path) c = conn.cursor() conn.text_factory = str if grp not in self.list_groups() and grp is not '': if word is '': wn = wordnet.get_definition(grp) t = (grp,detail,wn, '', '') else: wn = wordnet.get_definition(grp) t = (grp,'', wn, '', '') c.execute("""insert into groups values (?,?,?,?,?)""",t) conn.commit() #allow words with no groups to be added elif 'no-category' not in self.list_groups() and grp is '': c.execute("""insert into groups values ('no-category','Uncategorized words')""") if word is not '' and word not in self.list_words_per_group(grp): if grp == '': grp = 'no-category' wn = wordnet.get_definition(word) #print wn t = (word, grp, detail, wn, '', '', '0:0') c.execute('''insert into word_groups values(?,?,?,?,?,?,?)''', t) conn.commit() c.close()
544f236d51f79279c6b1e20751e385292f039631 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/544f236d51f79279c6b1e20751e385292f039631/wordgroupz.py
t = t + self.acc_dict[i] count = count + 1 t = t/count
if i not in self.new_word: t = t + self.acc_dict[i] count = count + 1 if count != 0: t = t/count else: t = 0
def __init__(self): self.builder = gtk.Builder() self.builder.add_from_file("wordgroupz.glade") self.window = self.builder.get_object("MainWindow") self.window.set_icon_from_file("/usr/share/pixmaps/wordgroupz.png") self.window.set_title("wordGroupz") self.builder.connect_signals(self) self.get_word = self.builder.get_object("get_word") self.get_group = gtk.combo_box_entry_new_text() self.get_group.set_tooltip_text("Enter a group for your word") self.details = self.builder.get_object("textview1") self.eventbox1 = self.builder.get_object('eventbox1') self.eventbox1.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#444444')) self.get_group.child.connect('key-press-event',self.item_list_changed) self.frame2 = self.builder.get_object('frame2') self.frame2.hide() #self.vpan = self.builder.get_object("vpaned1") self.output_txtview = self.builder.get_object("textview2") for x in wordz_db.list_groups(): self.get_group.append_text(x) self.table1 = self.builder.get_object("table1") self.get_group.show() self.table1.attach(self.get_group, 1,2,1,2)
544f236d51f79279c6b1e20751e385292f039631 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/544f236d51f79279c6b1e20751e385292f039631/wordgroupz.py
if i[0] == word and i[1] == '0:0':
if i[0] == word and i[1] == '0:0' and word not in self.new_word:
def custom_tree_col_view(self, column, renderer, model, iter, data): word = model.get_value(iter, 0) for i in data: if i[0] == word and i[1] == '0:0': self.new_word.append(word) if word in self.new_word: renderer.set_property('text', 'New') else: renderer.set_property('text', None)
544f236d51f79279c6b1e20751e385292f039631 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/544f236d51f79279c6b1e20751e385292f039631/wordgroupz.py
class get_def_thread(threading.Thread): stopthread = threading.Event() def run(self): word = win.tree_value dic = 'webster' if wordz_db.check_ws(win.tree_value): defs = wordz_db.get_dict_data(dic, win.tree_value)[0] else: d = online_dict() defs = d.get_def(word) wordz_db.save_webster(win.tree_value, defs) defs = '\n' + "webster:\n" + defs + '\n' """ elif dic == 'wordnet': if wordz_db.check_wn(win.tree_value): defs = wordz_db.get_dict_data(dic, win.tree_value)[0] else: defs = wordnet.get_definition(word) defs = '\n' + 'wordnet:\n' + defs + '\n' elif dic == 'wiktionary': if wordz_db.check_wik(win.tree_value): defs = wordz_db.get_dict_data(dic, win.tree_value)[0].strip("'").strip('"') defs = '\n' + 'wiktionary:\n'+defs + '\n' else: defs = '' buff = win.output_txtview.get_buffer() end = buff.get_iter_at_offset(-1) buff.place_cursor(end) buff.insert_interactive_at_cursor(defs, True)""" label = win.builder.get_object('label13') label.set_text(defs) def stop(self): self._stop.set() def stopped(self): return self._stop.isSet()
def wrapper(*args): t = threading.Thread(target=f, args = args) t.start()
a509c36fd38664667e331a176bcde28763fa8f43 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/a509c36fd38664667e331a176bcde28763fa8f43/wordgroupz.py
if ws != u'' or ws !=None:
if ws != u'' and ws !=None: self.builder.get_object('label10').hide() self.builder.get_object('label9').hide() self.builder.get_object('scrolledwindow7').show()
def show_details_tree(self): self.details_treestore.clear() wn = '' wik = '' ws = '' for i in self.vbox12.get_children(): self.vbox12.remove(i) for i in self.vbox8.get_children(): self.vbox8.remove(i) for i in self.vbox13.get_children(): self.vbox13.remove(i) try: wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] except: pass try: ws = wordz_db.get_dict_data('webster', self.tree_value)[0] except: pass try: wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0].strip("'") #print "wiktionary"+ wik except: pass try: if wn != u'': table = gtk.Table(columns=2) table.show() self.vbox12.pack_start(table, False, padding = 5) i = 0 t = wn.split('\n') #piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': #sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) #hbox_n = gtk.HBox() event_b = gtk.EventBox() event_b.set_visible_window(True) event_b.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_OUT) #frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("grey")) frame.show() event_b.show() #hbox_n.pack_start(frame, false) #hbox_n.show_all() label = gtk.Label(x) label.set_alignment(0.0, 0) #hbox_n.pack_start(label, False, padding = 2) table.attach(label, 0, 1, i, i+1, xoptions = gtk.FILL) label.show() #hbox_n.pack_start(frame, padding = 10) table.attach(frame, 1, 2, i, i+1) table.set_row_spacing(i, 10) table.set_col_spacing(0, 5) #hbox_n.show() #self.vbox12.pack_start(hbox_n, False, padding=5) vbox = gtk.VBox() vbox.show_all() event_b.add(vbox) frame.add(event_b) i = i + 1 elif x.startswith('\t') and not x.startswith('\tSynonyms:'): #sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) vbox1 = gtk.VBox() label = gtk.Label() l = len(x.strip('\t')) label.set_markup('<b><big>'+x.strip('\t')[0:2]+'</big></b>'+x.strip('\t')[2:l]) #label.set_markup(x.strip('\t')) ##print x.lstrip('\t')[0:2] #l = len(x.strip('\t')) #print x.lstrip('\t')[0:l] if self.window.get_size() == self.window.get_default_size(): label.set_line_wrap(True) label.set_selectable(True) label.set_alignment(0.0, 0.5) label.show() #label.show() vbox1.pack_start(label, True) vbox1.show() vbox.pack_start(vbox1, False) elif x.startswith('\tSynonyms:'): #self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) frame = gtk.Frame('Synonyms') label = gtk.Label() label.set_markup(('<b><span foreground="white">'+ cgi.escape(x.strip('\tSynonyms:')) + '</span></b>')) label.set_alignment(0.0, 0.5) label.show() eventbox = gtk.EventBox() eventbox.set_visible_window(True) eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#5C97BF")) #eventbox.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white")) eventbox.add(label) eventbox.show() frame.add(eventbox) frame.show() hbox = gtk.HBox() label = gtk.Label(' '*5) #label.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("blue")) label.show() hbox.pack_start(label, False) hbox.pack_start(frame) hbox.show() vbox1.pack_start(hbox, False) except: pass if wik != u'': t = wik.split('\n') #print t[0:6] #piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) table = gtk.Table(1, 2) table.set_col_spacing(0, 5) table.show() self.vbox8.pack_start(table, False) i = 0 h1 = [] j = 0 for x in t: #print 'j = ', #print j #j = j+1 if x.startswith('#'): #print sub_str #sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) #h1.append(x.lstrip('#')) #print x.lstrip('#') #sub_str = '' #sub_sub_str = '' #sub_sub_str = '' eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() main_label = gtk.Label() main_label.set_markup('<b>'+x.lstrip('#')+'</b>') main_label.set_alignment(0.1, 0) main_label.show() table.attach(main_label, 0, 1, i, i+1, xoptions=gtk.FILL) main_frame = gtk.Frame() main_frame.show() main_vbox = gtk.VBox() main_vbox.show() main_frame.add(main_vbox) sub_vbox = gtk.VBox() sub_vbox.show() main_vbox.pack_start(sub_vbox, False) label = gtk.Label(' ') label.show() label.set_alignment(0, 0.5) #label.set_line_wrap(True) eventb.add(label) sub_vbox.pack_start(eventb, False) table.attach(main_frame, 1, 2, i, i+1) table.set_row_spacing(i, 10) table.set_col_spacing(0, 5) i = i + 1 elif not x.startswith('\t') and not x.startswith('#') and not x.startswith('\t#'): #print 'hi' #self.details_treestore.append(sub_iter, [x]) s = label.get_text() if x == u'': label.set_text( s + '\n' + x) else: label.set_text(s + x) #print label.get_text() #label.show() elif x.startswith('\t#'): #print sub_str #sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) #print x.lstrip('\t#') #sub_sub_str = '' #pass eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() sub_sub_vbox = gtk.VBox() sub_sub_vbox.show() hbox = gtk.HBox() hbox.show() sub_sub_label = gtk.Label('\t') sub_sub_label.show() hbox.pack_start(sub_sub_vbox, False) sub_sub_vbox.pack_start(sub_sub_label, False) sub_sub_frame = gtk.Frame(' ') label = sub_sub_frame.get_label_widget() label.set_markup('<b>'+x.lstrip('\t#')+'</b>') try: if sub_sub_frame.get_label_widget()!=NULL: sub_sub_frame.set_label_widget(label) except: pass sub_sub_frame.show() sub_label = gtk.Label('') sub_label.show() sub_sub_sub_vbox = gtk.VBox() sub_sub_sub_vbox.show() sub_sub_frame.add(sub_sub_sub_vbox) eventb.add(sub_label) sub_label.set_alignment(0,0.5) sub_label.set_use_markup(True) sub_sub_sub_vbox.pack_start(eventb, False) hbox.pack_start(sub_sub_frame) sub_vbox.pack_start(hbox, False) elif x.startswith('\t') and not x.startswith('\t#') and not x.startswith('\t\t'): #self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) #sub_sub_str = sub_sub_str + x.lstrip('\t') if sub_label.get_use_markup() == False: sub_label.set_use_markup(True) if x == '\t': sub_label.set_label(sub_label.get_text() + '\n' + x) else: x = x.lstrip('\t') if len(x)>1: x.lstrip() #print x[0:2] if x[0].isdigit(): sub_label.set_label(sub_label.get_label()+'<b>'+x[0:2]+'</b>'+x[2:len(x)]) else: sub_label.set_label(sub_label.get_label()+x) pass elif x.startswith('\t\t#'): #print x.split('#') #sub_sub_sub_iter = self.details_treestore.append(sub_sub_iter, ['<b>'+x.lstrip('\t\t#')+'</b>']) eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() sub_sub_sub_frame = gtk.Frame(' ') label = sub_sub_sub_frame.get_label_widget() label.set_markup('<b>'+x.lstrip('\t\t#')+'</b>') try: if sub_sub_sub_frame.get_label_widget()!=NULL: sub_sub_sub_frame.set_label_widget(label) except: pass sub_sub_sub_frame.show() sub_sub_sub_sub_vbox = gtk.VBox() sub_sub_sub_sub_vbox.show() sub_sub_sub_vbox.pack_start(sub_sub_sub_frame, False) sub_sub_sub_frame.add(sub_sub_sub_sub_vbox) sub_sub_label = gtk.Label(' ') sub_sub_label.set_alignment(0,0.5) eventb.add(sub_sub_label) sub_sub_label.show() sub_sub_sub_sub_vbox.pack_start(eventb, False) #sub_sub_vbox.pack_start(sub_sub_sub_frame, False) elif x.startswith('\t\t') and not x.startswith('\t\t#'): #print x ''' if x.strip('\t\t') != '': if x.find('terms derived from')>=0: self.details_treestore.append(sub_sub_sub_iter, ['<u><i>'+ x.lstrip('\t\t')+'</i></u>']) else: self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')])''' if x.strip('\t\t') !='': if x.find('terms derived from')>=0: sub_sub_label.set_text( sub_sub_label.get_text()+'\n'+ x.lstrip('\t\t')) else: sub_sub_label.set_text( sub_sub_label.get_text()+'\n'+ x.lstrip('\t\t'))
a509c36fd38664667e331a176bcde28763fa8f43 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/a509c36fd38664667e331a176bcde28763fa8f43/wordgroupz.py
def show_details_tree(self): self.details_treestore.clear() wn = '' wik = '' ws = '' for i in self.vbox12.get_children(): self.vbox12.remove(i) for i in self.vbox8.get_children(): self.vbox8.remove(i) for i in self.vbox13.get_children(): self.vbox13.remove(i) try: wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] except: pass try: ws = wordz_db.get_dict_data('webster', self.tree_value)[0] except: pass try: wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0].strip("'") #print "wiktionary"+ wik except: pass try: if wn != u'': table = gtk.Table(columns=2) table.show() self.vbox12.pack_start(table, False, padding = 5) i = 0 t = wn.split('\n') #piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': #sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) #hbox_n = gtk.HBox() event_b = gtk.EventBox() event_b.set_visible_window(True) event_b.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_OUT) #frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("grey")) frame.show() event_b.show() #hbox_n.pack_start(frame, false) #hbox_n.show_all() label = gtk.Label(x) label.set_alignment(0.0, 0) #hbox_n.pack_start(label, False, padding = 2) table.attach(label, 0, 1, i, i+1, xoptions = gtk.FILL) label.show() #hbox_n.pack_start(frame, padding = 10) table.attach(frame, 1, 2, i, i+1) table.set_row_spacing(i, 10) table.set_col_spacing(0, 5) #hbox_n.show() #self.vbox12.pack_start(hbox_n, False, padding=5) vbox = gtk.VBox() vbox.show_all() event_b.add(vbox) frame.add(event_b) i = i + 1 elif x.startswith('\t') and not x.startswith('\tSynonyms:'): #sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) vbox1 = gtk.VBox() label = gtk.Label() l = len(x.strip('\t')) label.set_markup('<b><big>'+x.strip('\t')[0:2]+'</big></b>'+x.strip('\t')[2:l]) #label.set_markup(x.strip('\t')) ##print x.lstrip('\t')[0:2] #l = len(x.strip('\t')) #print x.lstrip('\t')[0:l] if self.window.get_size() == self.window.get_default_size(): label.set_line_wrap(True) label.set_selectable(True) label.set_alignment(0.0, 0.5) label.show() #label.show() vbox1.pack_start(label, True) vbox1.show() vbox.pack_start(vbox1, False) elif x.startswith('\tSynonyms:'): #self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) frame = gtk.Frame('Synonyms') label = gtk.Label() label.set_markup(('<b><span foreground="white">'+ cgi.escape(x.strip('\tSynonyms:')) + '</span></b>')) label.set_alignment(0.0, 0.5) label.show() eventbox = gtk.EventBox() eventbox.set_visible_window(True) eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#5C97BF")) #eventbox.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white")) eventbox.add(label) eventbox.show() frame.add(eventbox) frame.show() hbox = gtk.HBox() label = gtk.Label(' '*5) #label.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("blue")) label.show() hbox.pack_start(label, False) hbox.pack_start(frame) hbox.show() vbox1.pack_start(hbox, False) except: pass if wik != u'': t = wik.split('\n') #print t[0:6] #piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) table = gtk.Table(1, 2) table.set_col_spacing(0, 5) table.show() self.vbox8.pack_start(table, False) i = 0 h1 = [] j = 0 for x in t: #print 'j = ', #print j #j = j+1 if x.startswith('#'): #print sub_str #sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) #h1.append(x.lstrip('#')) #print x.lstrip('#') #sub_str = '' #sub_sub_str = '' #sub_sub_str = '' eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() main_label = gtk.Label() main_label.set_markup('<b>'+x.lstrip('#')+'</b>') main_label.set_alignment(0.1, 0) main_label.show() table.attach(main_label, 0, 1, i, i+1, xoptions=gtk.FILL) main_frame = gtk.Frame() main_frame.show() main_vbox = gtk.VBox() main_vbox.show() main_frame.add(main_vbox) sub_vbox = gtk.VBox() sub_vbox.show() main_vbox.pack_start(sub_vbox, False) label = gtk.Label(' ') label.show() label.set_alignment(0, 0.5) #label.set_line_wrap(True) eventb.add(label) sub_vbox.pack_start(eventb, False) table.attach(main_frame, 1, 2, i, i+1) table.set_row_spacing(i, 10) table.set_col_spacing(0, 5) i = i + 1 elif not x.startswith('\t') and not x.startswith('#') and not x.startswith('\t#'): #print 'hi' #self.details_treestore.append(sub_iter, [x]) s = label.get_text() if x == u'': label.set_text( s + '\n' + x) else: label.set_text(s + x) #print label.get_text() #label.show() elif x.startswith('\t#'): #print sub_str #sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) #print x.lstrip('\t#') #sub_sub_str = '' #pass eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() sub_sub_vbox = gtk.VBox() sub_sub_vbox.show() hbox = gtk.HBox() hbox.show() sub_sub_label = gtk.Label('\t') sub_sub_label.show() hbox.pack_start(sub_sub_vbox, False) sub_sub_vbox.pack_start(sub_sub_label, False) sub_sub_frame = gtk.Frame(' ') label = sub_sub_frame.get_label_widget() label.set_markup('<b>'+x.lstrip('\t#')+'</b>') try: if sub_sub_frame.get_label_widget()!=NULL: sub_sub_frame.set_label_widget(label) except: pass sub_sub_frame.show() sub_label = gtk.Label('') sub_label.show() sub_sub_sub_vbox = gtk.VBox() sub_sub_sub_vbox.show() sub_sub_frame.add(sub_sub_sub_vbox) eventb.add(sub_label) sub_label.set_alignment(0,0.5) sub_label.set_use_markup(True) sub_sub_sub_vbox.pack_start(eventb, False) hbox.pack_start(sub_sub_frame) sub_vbox.pack_start(hbox, False) elif x.startswith('\t') and not x.startswith('\t#') and not x.startswith('\t\t'): #self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) #sub_sub_str = sub_sub_str + x.lstrip('\t') if sub_label.get_use_markup() == False: sub_label.set_use_markup(True) if x == '\t': sub_label.set_label(sub_label.get_text() + '\n' + x) else: x = x.lstrip('\t') if len(x)>1: x.lstrip() #print x[0:2] if x[0].isdigit(): sub_label.set_label(sub_label.get_label()+'<b>'+x[0:2]+'</b>'+x[2:len(x)]) else: sub_label.set_label(sub_label.get_label()+x) pass elif x.startswith('\t\t#'): #print x.split('#') #sub_sub_sub_iter = self.details_treestore.append(sub_sub_iter, ['<b>'+x.lstrip('\t\t#')+'</b>']) eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() sub_sub_sub_frame = gtk.Frame(' ') label = sub_sub_sub_frame.get_label_widget() label.set_markup('<b>'+x.lstrip('\t\t#')+'</b>') try: if sub_sub_sub_frame.get_label_widget()!=NULL: sub_sub_sub_frame.set_label_widget(label) except: pass sub_sub_sub_frame.show() sub_sub_sub_sub_vbox = gtk.VBox() sub_sub_sub_sub_vbox.show() sub_sub_sub_vbox.pack_start(sub_sub_sub_frame, False) sub_sub_sub_frame.add(sub_sub_sub_sub_vbox) sub_sub_label = gtk.Label(' ') sub_sub_label.set_alignment(0,0.5) eventb.add(sub_sub_label) sub_sub_label.show() sub_sub_sub_sub_vbox.pack_start(eventb, False) #sub_sub_vbox.pack_start(sub_sub_sub_frame, False) elif x.startswith('\t\t') and not x.startswith('\t\t#'): #print x ''' if x.strip('\t\t') != '': if x.find('terms derived from')>=0: self.details_treestore.append(sub_sub_sub_iter, ['<u><i>'+ x.lstrip('\t\t')+'</i></u>']) else: self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')])''' if x.strip('\t\t') !='': if x.find('terms derived from')>=0: sub_sub_label.set_text( sub_sub_label.get_text()+'\n'+ x.lstrip('\t\t')) else: sub_sub_label.set_text( sub_sub_label.get_text()+'\n'+ x.lstrip('\t\t'))
a509c36fd38664667e331a176bcde28763fa8f43 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/a509c36fd38664667e331a176bcde28763fa8f43/wordgroupz.py
def show_details_tree(self): self.details_treestore.clear() wn = '' wik = '' ws = '' for i in self.vbox12.get_children(): self.vbox12.remove(i) for i in self.vbox8.get_children(): self.vbox8.remove(i) for i in self.vbox13.get_children(): self.vbox13.remove(i) try: wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] except: pass try: ws = wordz_db.get_dict_data('webster', self.tree_value)[0] except: pass try: wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0].strip("'") #print "wiktionary"+ wik except: pass try: if wn != u'': table = gtk.Table(columns=2) table.show() self.vbox12.pack_start(table, False, padding = 5) i = 0 t = wn.split('\n') #piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': #sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) #hbox_n = gtk.HBox() event_b = gtk.EventBox() event_b.set_visible_window(True) event_b.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_OUT) #frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("grey")) frame.show() event_b.show() #hbox_n.pack_start(frame, false) #hbox_n.show_all() label = gtk.Label(x) label.set_alignment(0.0, 0) #hbox_n.pack_start(label, False, padding = 2) table.attach(label, 0, 1, i, i+1, xoptions = gtk.FILL) label.show() #hbox_n.pack_start(frame, padding = 10) table.attach(frame, 1, 2, i, i+1) table.set_row_spacing(i, 10) table.set_col_spacing(0, 5) #hbox_n.show() #self.vbox12.pack_start(hbox_n, False, padding=5) vbox = gtk.VBox() vbox.show_all() event_b.add(vbox) frame.add(event_b) i = i + 1 elif x.startswith('\t') and not x.startswith('\tSynonyms:'): #sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) vbox1 = gtk.VBox() label = gtk.Label() l = len(x.strip('\t')) label.set_markup('<b><big>'+x.strip('\t')[0:2]+'</big></b>'+x.strip('\t')[2:l]) #label.set_markup(x.strip('\t')) ##print x.lstrip('\t')[0:2] #l = len(x.strip('\t')) #print x.lstrip('\t')[0:l] if self.window.get_size() == self.window.get_default_size(): label.set_line_wrap(True) label.set_selectable(True) label.set_alignment(0.0, 0.5) label.show() #label.show() vbox1.pack_start(label, True) vbox1.show() vbox.pack_start(vbox1, False) elif x.startswith('\tSynonyms:'): #self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) frame = gtk.Frame('Synonyms') label = gtk.Label() label.set_markup(('<b><span foreground="white">'+ cgi.escape(x.strip('\tSynonyms:')) + '</span></b>')) label.set_alignment(0.0, 0.5) label.show() eventbox = gtk.EventBox() eventbox.set_visible_window(True) eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#5C97BF")) #eventbox.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white")) eventbox.add(label) eventbox.show() frame.add(eventbox) frame.show() hbox = gtk.HBox() label = gtk.Label(' '*5) #label.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("blue")) label.show() hbox.pack_start(label, False) hbox.pack_start(frame) hbox.show() vbox1.pack_start(hbox, False) except: pass if wik != u'': t = wik.split('\n') #print t[0:6] #piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) table = gtk.Table(1, 2) table.set_col_spacing(0, 5) table.show() self.vbox8.pack_start(table, False) i = 0 h1 = [] j = 0 for x in t: #print 'j = ', #print j #j = j+1 if x.startswith('#'): #print sub_str #sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) #h1.append(x.lstrip('#')) #print x.lstrip('#') #sub_str = '' #sub_sub_str = '' #sub_sub_str = '' eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() main_label = gtk.Label() main_label.set_markup('<b>'+x.lstrip('#')+'</b>') main_label.set_alignment(0.1, 0) main_label.show() table.attach(main_label, 0, 1, i, i+1, xoptions=gtk.FILL) main_frame = gtk.Frame() main_frame.show() main_vbox = gtk.VBox() main_vbox.show() main_frame.add(main_vbox) sub_vbox = gtk.VBox() sub_vbox.show() main_vbox.pack_start(sub_vbox, False) label = gtk.Label(' ') label.show() label.set_alignment(0, 0.5) #label.set_line_wrap(True) eventb.add(label) sub_vbox.pack_start(eventb, False) table.attach(main_frame, 1, 2, i, i+1) table.set_row_spacing(i, 10) table.set_col_spacing(0, 5) i = i + 1 elif not x.startswith('\t') and not x.startswith('#') and not x.startswith('\t#'): #print 'hi' #self.details_treestore.append(sub_iter, [x]) s = label.get_text() if x == u'': label.set_text( s + '\n' + x) else: label.set_text(s + x) #print label.get_text() #label.show() elif x.startswith('\t#'): #print sub_str #sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) #print x.lstrip('\t#') #sub_sub_str = '' #pass eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() sub_sub_vbox = gtk.VBox() sub_sub_vbox.show() hbox = gtk.HBox() hbox.show() sub_sub_label = gtk.Label('\t') sub_sub_label.show() hbox.pack_start(sub_sub_vbox, False) sub_sub_vbox.pack_start(sub_sub_label, False) sub_sub_frame = gtk.Frame(' ') label = sub_sub_frame.get_label_widget() label.set_markup('<b>'+x.lstrip('\t#')+'</b>') try: if sub_sub_frame.get_label_widget()!=NULL: sub_sub_frame.set_label_widget(label) except: pass sub_sub_frame.show() sub_label = gtk.Label('') sub_label.show() sub_sub_sub_vbox = gtk.VBox() sub_sub_sub_vbox.show() sub_sub_frame.add(sub_sub_sub_vbox) eventb.add(sub_label) sub_label.set_alignment(0,0.5) sub_label.set_use_markup(True) sub_sub_sub_vbox.pack_start(eventb, False) hbox.pack_start(sub_sub_frame) sub_vbox.pack_start(hbox, False) elif x.startswith('\t') and not x.startswith('\t#') and not x.startswith('\t\t'): #self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) #sub_sub_str = sub_sub_str + x.lstrip('\t') if sub_label.get_use_markup() == False: sub_label.set_use_markup(True) if x == '\t': sub_label.set_label(sub_label.get_text() + '\n' + x) else: x = x.lstrip('\t') if len(x)>1: x.lstrip() #print x[0:2] if x[0].isdigit(): sub_label.set_label(sub_label.get_label()+'<b>'+x[0:2]+'</b>'+x[2:len(x)]) else: sub_label.set_label(sub_label.get_label()+x) pass elif x.startswith('\t\t#'): #print x.split('#') #sub_sub_sub_iter = self.details_treestore.append(sub_sub_iter, ['<b>'+x.lstrip('\t\t#')+'</b>']) eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() sub_sub_sub_frame = gtk.Frame(' ') label = sub_sub_sub_frame.get_label_widget() label.set_markup('<b>'+x.lstrip('\t\t#')+'</b>') try: if sub_sub_sub_frame.get_label_widget()!=NULL: sub_sub_sub_frame.set_label_widget(label) except: pass sub_sub_sub_frame.show() sub_sub_sub_sub_vbox = gtk.VBox() sub_sub_sub_sub_vbox.show() sub_sub_sub_vbox.pack_start(sub_sub_sub_frame, False) sub_sub_sub_frame.add(sub_sub_sub_sub_vbox) sub_sub_label = gtk.Label(' ') sub_sub_label.set_alignment(0,0.5) eventb.add(sub_sub_label) sub_sub_label.show() sub_sub_sub_sub_vbox.pack_start(eventb, False) #sub_sub_vbox.pack_start(sub_sub_sub_frame, False) elif x.startswith('\t\t') and not x.startswith('\t\t#'): #print x ''' if x.strip('\t\t') != '': if x.find('terms derived from')>=0: self.details_treestore.append(sub_sub_sub_iter, ['<u><i>'+ x.lstrip('\t\t')+'</i></u>']) else: self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')])''' if x.strip('\t\t') !='': if x.find('terms derived from')>=0: sub_sub_label.set_text( sub_sub_label.get_text()+'\n'+ x.lstrip('\t\t')) else: sub_sub_label.set_text( sub_sub_label.get_text()+'\n'+ x.lstrip('\t\t'))
a509c36fd38664667e331a176bcde28763fa8f43 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/a509c36fd38664667e331a176bcde28763fa8f43/wordgroupz.py
""" if j.startswith(' {'): hbox = gtk.HBox() hbox.show() label = gtk.Label(' ') label.show() hbox.pack_start(label, False) event = gtk.EventBox() event.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(' label = gtk.Label('') label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse('white')) label.set_alignment(0, 0) label.set_selectable(True) label.show() event.add(label) event.show() vbox.pack_start(event, padding=5)"""
def show_details_tree(self): self.details_treestore.clear() wn = '' wik = '' ws = '' for i in self.vbox12.get_children(): self.vbox12.remove(i) for i in self.vbox8.get_children(): self.vbox8.remove(i) for i in self.vbox13.get_children(): self.vbox13.remove(i) try: wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] except: pass try: ws = wordz_db.get_dict_data('webster', self.tree_value)[0] except: pass try: wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0].strip("'") #print "wiktionary"+ wik except: pass try: if wn != u'': table = gtk.Table(columns=2) table.show() self.vbox12.pack_start(table, False, padding = 5) i = 0 t = wn.split('\n') #piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': #sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) #hbox_n = gtk.HBox() event_b = gtk.EventBox() event_b.set_visible_window(True) event_b.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_OUT) #frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("grey")) frame.show() event_b.show() #hbox_n.pack_start(frame, false) #hbox_n.show_all() label = gtk.Label(x) label.set_alignment(0.0, 0) #hbox_n.pack_start(label, False, padding = 2) table.attach(label, 0, 1, i, i+1, xoptions = gtk.FILL) label.show() #hbox_n.pack_start(frame, padding = 10) table.attach(frame, 1, 2, i, i+1) table.set_row_spacing(i, 10) table.set_col_spacing(0, 5) #hbox_n.show() #self.vbox12.pack_start(hbox_n, False, padding=5) vbox = gtk.VBox() vbox.show_all() event_b.add(vbox) frame.add(event_b) i = i + 1 elif x.startswith('\t') and not x.startswith('\tSynonyms:'): #sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) vbox1 = gtk.VBox() label = gtk.Label() l = len(x.strip('\t')) label.set_markup('<b><big>'+x.strip('\t')[0:2]+'</big></b>'+x.strip('\t')[2:l]) #label.set_markup(x.strip('\t')) ##print x.lstrip('\t')[0:2] #l = len(x.strip('\t')) #print x.lstrip('\t')[0:l] if self.window.get_size() == self.window.get_default_size(): label.set_line_wrap(True) label.set_selectable(True) label.set_alignment(0.0, 0.5) label.show() #label.show() vbox1.pack_start(label, True) vbox1.show() vbox.pack_start(vbox1, False) elif x.startswith('\tSynonyms:'): #self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) frame = gtk.Frame('Synonyms') label = gtk.Label() label.set_markup(('<b><span foreground="white">'+ cgi.escape(x.strip('\tSynonyms:')) + '</span></b>')) label.set_alignment(0.0, 0.5) label.show() eventbox = gtk.EventBox() eventbox.set_visible_window(True) eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#5C97BF")) #eventbox.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white")) eventbox.add(label) eventbox.show() frame.add(eventbox) frame.show() hbox = gtk.HBox() label = gtk.Label(' '*5) #label.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("blue")) label.show() hbox.pack_start(label, False) hbox.pack_start(frame) hbox.show() vbox1.pack_start(hbox, False) except: pass if wik != u'': t = wik.split('\n') #print t[0:6] #piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) table = gtk.Table(1, 2) table.set_col_spacing(0, 5) table.show() self.vbox8.pack_start(table, False) i = 0 h1 = [] j = 0 for x in t: #print 'j = ', #print j #j = j+1 if x.startswith('#'): #print sub_str #sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) #h1.append(x.lstrip('#')) #print x.lstrip('#') #sub_str = '' #sub_sub_str = '' #sub_sub_str = '' eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() main_label = gtk.Label() main_label.set_markup('<b>'+x.lstrip('#')+'</b>') main_label.set_alignment(0.1, 0) main_label.show() table.attach(main_label, 0, 1, i, i+1, xoptions=gtk.FILL) main_frame = gtk.Frame() main_frame.show() main_vbox = gtk.VBox() main_vbox.show() main_frame.add(main_vbox) sub_vbox = gtk.VBox() sub_vbox.show() main_vbox.pack_start(sub_vbox, False) label = gtk.Label(' ') label.show() label.set_alignment(0, 0.5) #label.set_line_wrap(True) eventb.add(label) sub_vbox.pack_start(eventb, False) table.attach(main_frame, 1, 2, i, i+1) table.set_row_spacing(i, 10) table.set_col_spacing(0, 5) i = i + 1 elif not x.startswith('\t') and not x.startswith('#') and not x.startswith('\t#'): #print 'hi' #self.details_treestore.append(sub_iter, [x]) s = label.get_text() if x == u'': label.set_text( s + '\n' + x) else: label.set_text(s + x) #print label.get_text() #label.show() elif x.startswith('\t#'): #print sub_str #sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) #print x.lstrip('\t#') #sub_sub_str = '' #pass eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() sub_sub_vbox = gtk.VBox() sub_sub_vbox.show() hbox = gtk.HBox() hbox.show() sub_sub_label = gtk.Label('\t') sub_sub_label.show() hbox.pack_start(sub_sub_vbox, False) sub_sub_vbox.pack_start(sub_sub_label, False) sub_sub_frame = gtk.Frame(' ') label = sub_sub_frame.get_label_widget() label.set_markup('<b>'+x.lstrip('\t#')+'</b>') try: if sub_sub_frame.get_label_widget()!=NULL: sub_sub_frame.set_label_widget(label) except: pass sub_sub_frame.show() sub_label = gtk.Label('') sub_label.show() sub_sub_sub_vbox = gtk.VBox() sub_sub_sub_vbox.show() sub_sub_frame.add(sub_sub_sub_vbox) eventb.add(sub_label) sub_label.set_alignment(0,0.5) sub_label.set_use_markup(True) sub_sub_sub_vbox.pack_start(eventb, False) hbox.pack_start(sub_sub_frame) sub_vbox.pack_start(hbox, False) elif x.startswith('\t') and not x.startswith('\t#') and not x.startswith('\t\t'): #self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) #sub_sub_str = sub_sub_str + x.lstrip('\t') if sub_label.get_use_markup() == False: sub_label.set_use_markup(True) if x == '\t': sub_label.set_label(sub_label.get_text() + '\n' + x) else: x = x.lstrip('\t') if len(x)>1: x.lstrip() #print x[0:2] if x[0].isdigit(): sub_label.set_label(sub_label.get_label()+'<b>'+x[0:2]+'</b>'+x[2:len(x)]) else: sub_label.set_label(sub_label.get_label()+x) pass elif x.startswith('\t\t#'): #print x.split('#') #sub_sub_sub_iter = self.details_treestore.append(sub_sub_iter, ['<b>'+x.lstrip('\t\t#')+'</b>']) eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() sub_sub_sub_frame = gtk.Frame(' ') label = sub_sub_sub_frame.get_label_widget() label.set_markup('<b>'+x.lstrip('\t\t#')+'</b>') try: if sub_sub_sub_frame.get_label_widget()!=NULL: sub_sub_sub_frame.set_label_widget(label) except: pass sub_sub_sub_frame.show() sub_sub_sub_sub_vbox = gtk.VBox() sub_sub_sub_sub_vbox.show() sub_sub_sub_vbox.pack_start(sub_sub_sub_frame, False) sub_sub_sub_frame.add(sub_sub_sub_sub_vbox) sub_sub_label = gtk.Label(' ') sub_sub_label.set_alignment(0,0.5) eventb.add(sub_sub_label) sub_sub_label.show() sub_sub_sub_sub_vbox.pack_start(eventb, False) #sub_sub_vbox.pack_start(sub_sub_sub_frame, False) elif x.startswith('\t\t') and not x.startswith('\t\t#'): #print x ''' if x.strip('\t\t') != '': if x.find('terms derived from')>=0: self.details_treestore.append(sub_sub_sub_iter, ['<u><i>'+ x.lstrip('\t\t')+'</i></u>']) else: self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')])''' if x.strip('\t\t') !='': if x.find('terms derived from')>=0: sub_sub_label.set_text( sub_sub_label.get_text()+'\n'+ x.lstrip('\t\t')) else: sub_sub_label.set_text( sub_sub_label.get_text()+'\n'+ x.lstrip('\t\t'))
a509c36fd38664667e331a176bcde28763fa8f43 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/a509c36fd38664667e331a176bcde28763fa8f43/wordgroupz.py
else: self.builder.get_object('look_webster').set_sensitive(True) label = gtk.Label() label.show() try: label.set_alignment(0.10, 0.10) except: pass label.set_text('Webster definition not in database,\nPlease click on "Look up"') self.vbox13.pack_start(label, False)
else: self.builder.get_object('look_webster').set_sensitive(True) self.builder.get_object('label9').show() self.builder.get_object('label10').hide() self.builder.get_object('scrolledwindow7').hide()
def show_details_tree(self): self.details_treestore.clear() wn = '' wik = '' ws = '' for i in self.vbox12.get_children(): self.vbox12.remove(i) for i in self.vbox8.get_children(): self.vbox8.remove(i) for i in self.vbox13.get_children(): self.vbox13.remove(i) try: wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] except: pass try: ws = wordz_db.get_dict_data('webster', self.tree_value)[0] except: pass try: wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0].strip("'") #print "wiktionary"+ wik except: pass try: if wn != u'': table = gtk.Table(columns=2) table.show() self.vbox12.pack_start(table, False, padding = 5) i = 0 t = wn.split('\n') #piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': #sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) #hbox_n = gtk.HBox() event_b = gtk.EventBox() event_b.set_visible_window(True) event_b.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_OUT) #frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("grey")) frame.show() event_b.show() #hbox_n.pack_start(frame, false) #hbox_n.show_all() label = gtk.Label(x) label.set_alignment(0.0, 0) #hbox_n.pack_start(label, False, padding = 2) table.attach(label, 0, 1, i, i+1, xoptions = gtk.FILL) label.show() #hbox_n.pack_start(frame, padding = 10) table.attach(frame, 1, 2, i, i+1) table.set_row_spacing(i, 10) table.set_col_spacing(0, 5) #hbox_n.show() #self.vbox12.pack_start(hbox_n, False, padding=5) vbox = gtk.VBox() vbox.show_all() event_b.add(vbox) frame.add(event_b) i = i + 1 elif x.startswith('\t') and not x.startswith('\tSynonyms:'): #sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) vbox1 = gtk.VBox() label = gtk.Label() l = len(x.strip('\t')) label.set_markup('<b><big>'+x.strip('\t')[0:2]+'</big></b>'+x.strip('\t')[2:l]) #label.set_markup(x.strip('\t')) ##print x.lstrip('\t')[0:2] #l = len(x.strip('\t')) #print x.lstrip('\t')[0:l] if self.window.get_size() == self.window.get_default_size(): label.set_line_wrap(True) label.set_selectable(True) label.set_alignment(0.0, 0.5) label.show() #label.show() vbox1.pack_start(label, True) vbox1.show() vbox.pack_start(vbox1, False) elif x.startswith('\tSynonyms:'): #self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) frame = gtk.Frame('Synonyms') label = gtk.Label() label.set_markup(('<b><span foreground="white">'+ cgi.escape(x.strip('\tSynonyms:')) + '</span></b>')) label.set_alignment(0.0, 0.5) label.show() eventbox = gtk.EventBox() eventbox.set_visible_window(True) eventbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#5C97BF")) #eventbox.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white")) eventbox.add(label) eventbox.show() frame.add(eventbox) frame.show() hbox = gtk.HBox() label = gtk.Label(' '*5) #label.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("blue")) label.show() hbox.pack_start(label, False) hbox.pack_start(frame) hbox.show() vbox1.pack_start(hbox, False) except: pass if wik != u'': t = wik.split('\n') #print t[0:6] #piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) table = gtk.Table(1, 2) table.set_col_spacing(0, 5) table.show() self.vbox8.pack_start(table, False) i = 0 h1 = [] j = 0 for x in t: #print 'j = ', #print j #j = j+1 if x.startswith('#'): #print sub_str #sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) #h1.append(x.lstrip('#')) #print x.lstrip('#') #sub_str = '' #sub_sub_str = '' #sub_sub_str = '' eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() main_label = gtk.Label() main_label.set_markup('<b>'+x.lstrip('#')+'</b>') main_label.set_alignment(0.1, 0) main_label.show() table.attach(main_label, 0, 1, i, i+1, xoptions=gtk.FILL) main_frame = gtk.Frame() main_frame.show() main_vbox = gtk.VBox() main_vbox.show() main_frame.add(main_vbox) sub_vbox = gtk.VBox() sub_vbox.show() main_vbox.pack_start(sub_vbox, False) label = gtk.Label(' ') label.show() label.set_alignment(0, 0.5) #label.set_line_wrap(True) eventb.add(label) sub_vbox.pack_start(eventb, False) table.attach(main_frame, 1, 2, i, i+1) table.set_row_spacing(i, 10) table.set_col_spacing(0, 5) i = i + 1 elif not x.startswith('\t') and not x.startswith('#') and not x.startswith('\t#'): #print 'hi' #self.details_treestore.append(sub_iter, [x]) s = label.get_text() if x == u'': label.set_text( s + '\n' + x) else: label.set_text(s + x) #print label.get_text() #label.show() elif x.startswith('\t#'): #print sub_str #sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) #print x.lstrip('\t#') #sub_sub_str = '' #pass eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() sub_sub_vbox = gtk.VBox() sub_sub_vbox.show() hbox = gtk.HBox() hbox.show() sub_sub_label = gtk.Label('\t') sub_sub_label.show() hbox.pack_start(sub_sub_vbox, False) sub_sub_vbox.pack_start(sub_sub_label, False) sub_sub_frame = gtk.Frame(' ') label = sub_sub_frame.get_label_widget() label.set_markup('<b>'+x.lstrip('\t#')+'</b>') try: if sub_sub_frame.get_label_widget()!=NULL: sub_sub_frame.set_label_widget(label) except: pass sub_sub_frame.show() sub_label = gtk.Label('') sub_label.show() sub_sub_sub_vbox = gtk.VBox() sub_sub_sub_vbox.show() sub_sub_frame.add(sub_sub_sub_vbox) eventb.add(sub_label) sub_label.set_alignment(0,0.5) sub_label.set_use_markup(True) sub_sub_sub_vbox.pack_start(eventb, False) hbox.pack_start(sub_sub_frame) sub_vbox.pack_start(hbox, False) elif x.startswith('\t') and not x.startswith('\t#') and not x.startswith('\t\t'): #self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) #sub_sub_str = sub_sub_str + x.lstrip('\t') if sub_label.get_use_markup() == False: sub_label.set_use_markup(True) if x == '\t': sub_label.set_label(sub_label.get_text() + '\n' + x) else: x = x.lstrip('\t') if len(x)>1: x.lstrip() #print x[0:2] if x[0].isdigit(): sub_label.set_label(sub_label.get_label()+'<b>'+x[0:2]+'</b>'+x[2:len(x)]) else: sub_label.set_label(sub_label.get_label()+x) pass elif x.startswith('\t\t#'): #print x.split('#') #sub_sub_sub_iter = self.details_treestore.append(sub_sub_iter, ['<b>'+x.lstrip('\t\t#')+'</b>']) eventb = gtk.EventBox() eventb.set_visible_window(True) eventb.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#AED6EF")) eventb.show() sub_sub_sub_frame = gtk.Frame(' ') label = sub_sub_sub_frame.get_label_widget() label.set_markup('<b>'+x.lstrip('\t\t#')+'</b>') try: if sub_sub_sub_frame.get_label_widget()!=NULL: sub_sub_sub_frame.set_label_widget(label) except: pass sub_sub_sub_frame.show() sub_sub_sub_sub_vbox = gtk.VBox() sub_sub_sub_sub_vbox.show() sub_sub_sub_vbox.pack_start(sub_sub_sub_frame, False) sub_sub_sub_frame.add(sub_sub_sub_sub_vbox) sub_sub_label = gtk.Label(' ') sub_sub_label.set_alignment(0,0.5) eventb.add(sub_sub_label) sub_sub_label.show() sub_sub_sub_sub_vbox.pack_start(eventb, False) #sub_sub_vbox.pack_start(sub_sub_sub_frame, False) elif x.startswith('\t\t') and not x.startswith('\t\t#'): #print x ''' if x.strip('\t\t') != '': if x.find('terms derived from')>=0: self.details_treestore.append(sub_sub_sub_iter, ['<u><i>'+ x.lstrip('\t\t')+'</i></u>']) else: self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')])''' if x.strip('\t\t') !='': if x.find('terms derived from')>=0: sub_sub_label.set_text( sub_sub_label.get_text()+'\n'+ x.lstrip('\t\t')) else: sub_sub_label.set_text( sub_sub_label.get_text()+'\n'+ x.lstrip('\t\t'))
a509c36fd38664667e331a176bcde28763fa8f43 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/a509c36fd38664667e331a176bcde28763fa8f43/wordgroupz.py
self.builder.get_object('look_webster').set_sensitive(False) label = self.builder.get_object('label13') label.set_text('Searching...')
def _startthread(self): #print 'searching webster' self.builder.get_object('look_webster').set_sensitive(False) label = self.builder.get_object('label13') label.set_text('Searching...') word = self.tree_value dic = 'webster' if wordz_db.check_ws(win.tree_value): defs = wordz_db.get_dict_data(dic, win.tree_value)[0] else: d = online_dict() defs = d.get_def(word) wordz_db.save_webster(win.tree_value, defs) defs = '\n' + "webster:\n" + defs + '\n' #print defs label.set_text(defs.encode('utf-8')) self.builder.get_object('look_webster').set_sensitive(True)
a509c36fd38664667e331a176bcde28763fa8f43 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/a509c36fd38664667e331a176bcde28763fa8f43/wordgroupz.py
def _startthread(self): #print 'searching webster' self.builder.get_object('look_webster').set_sensitive(False) label = self.builder.get_object('label13') label.set_text('Searching...') word = self.tree_value dic = 'webster' if wordz_db.check_ws(win.tree_value): defs = wordz_db.get_dict_data(dic, win.tree_value)[0] else: d = online_dict() defs = d.get_def(word) wordz_db.save_webster(win.tree_value, defs) defs = '\n' + "webster:\n" + defs + '\n' #print defs label.set_text(defs.encode('utf-8')) self.builder.get_object('look_webster').set_sensitive(True)
a509c36fd38664667e331a176bcde28763fa8f43 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/a509c36fd38664667e331a176bcde28763fa8f43/wordgroupz.py
label.set_text(defs.encode('utf-8'))
def _startthread(self): #print 'searching webster' self.builder.get_object('look_webster').set_sensitive(False) label = self.builder.get_object('label13') label.set_text('Searching...') word = self.tree_value dic = 'webster' if wordz_db.check_ws(win.tree_value): defs = wordz_db.get_dict_data(dic, win.tree_value)[0] else: d = online_dict() defs = d.get_def(word) wordz_db.save_webster(win.tree_value, defs) defs = '\n' + "webster:\n" + defs + '\n' #print defs label.set_text(defs.encode('utf-8')) self.builder.get_object('look_webster').set_sensitive(True)
a509c36fd38664667e331a176bcde28763fa8f43 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/a509c36fd38664667e331a176bcde28763fa8f43/wordgroupz.py
th = get_def_thread()
def autolabel(rects): # attach some text labels for rect in rects: height = rect.get_height() ax.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height), ha='center', va='bottom')
a509c36fd38664667e331a176bcde28763fa8f43 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/a509c36fd38664667e331a176bcde28763fa8f43/wordgroupz.py
elif i[1] != '0:0' and i[0] in self.new_word: self.new_word.remove(i[0])
else: try: self.new_word.remove(i[0]) except: pass
def custom_tree_col_view(self, column, renderer, model, iter, data): word = model.get_value(iter, 0) for i in data: if i[0] == word and i[1] == '0:0' and word not in self.new_word: self.new_word.append(word) elif i[1] != '0:0' and i[0] in self.new_word: self.new_word.remove(i[0]) #print self.new_word if word in self.new_word: renderer.set_property('text', 'New') else: renderer.set_property('text', None)
3d4b7cae0d5feaf772d3ed4be964bb8a9304ed1f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/3d4b7cae0d5feaf772d3ed4be964bb8a9304ed1f/wordgroupz.py
self.window.show()
self.window.show()'''
def on_mcq_clicked(self, widget=None, event=None): self.window.hide() game = games.mcq() self.treestore.clear() conn = sqlite3.connect(db_file_path) c = conn.cursor() c.execute("""select word, accuracy from word_groups""") ls = c.fetchall() #print 'l', l c.close() self.acc_dict = {} for i in ls: if i[1] == u'0:0': self.acc_dict[i[0]] = 0 else: t = i[1].split(':') acc = float(t[0])/float(t[1])*100 acc = int(acc) self.acc_dict[i[0]] = acc #print self.acc_dict for group in wordz_db.list_groups(): l = wordz_db.list_words_per_group(group) t = 0 count = 0 for i in l: if i not in self.new_word: t = t + self.acc_dict[i] count = count + 1 if count!=0: t = t/count else: t = 0 #print self.acc_dict.keys() piter = self.treestore.append(None, [group,t]) for word in wordz_db.list_words_per_group(group): self.treestore.append(piter, [word,self.acc_dict[word]]) self.treeview.expand_all() self.window.show()
3d4b7cae0d5feaf772d3ed4be964bb8a9304ed1f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/3d4b7cae0d5feaf772d3ed4be964bb8a9304ed1f/wordgroupz.py
self.new_word.append(word)
def on_add_clicked(self, widget, data=None): word = self.get_word.get_text() if word not in self.new_word and word not in wordz_db.list_words(): self.new_word.append(word)
3d4b7cae0d5feaf772d3ed4be964bb8a9304ed1f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/3d4b7cae0d5feaf772d3ed4be964bb8a9304ed1f/wordgroupz.py
self.new_word = []
def on_back_clicked(self, widget=None, data=None): if self.search.get_text()!= '': self.frame2.hide() self.search.set_text('') self.welcome.show() self.note.set_alignment(0.5, 0.1) self.note.set_markup('<span foreground="white"><b>Nothing selected</b></span>') return self.treestore.clear() #self.search.set_text('') self.new_word = [] conn = sqlite3.connect(db_file_path) c = conn.cursor() c.execute("""select word, accuracy from word_groups""") ls = c.fetchall() #print 'l', ls c.close() self.acc_dict = {} for i in ls: if i[1] == u'0:0': self.acc_dict[i[0]] = 0 else: try: self.new_word.remove(i[0]) except: pass t = i[1].split(':') acc = float(t[0])/float(t[1])*100 acc = int(acc) self.acc_dict[i[0]] = acc
3d4b7cae0d5feaf772d3ed4be964bb8a9304ed1f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/3d4b7cae0d5feaf772d3ed4be964bb8a9304ed1f/wordgroupz.py
self.hbox2.pack_start(self.welcome)
def __init__(self): self.builder = gtk.Builder() self.builder.add_from_file("wordgroupz.glade") self.window = self.builder.get_object("MainWindow") self.window.set_icon_from_file("/usr/share/pixmaps/wordgroupz.png") self.window.set_title("wordGroupz") self.builder.connect_signals(self) self.get_word = self.builder.get_object("get_word") self.get_group = gtk.combo_box_entry_new_text() self.get_group.set_tooltip_text("Enter a group for your word") self.details = self.builder.get_object("textview1") self.eventbox1 = self.builder.get_object('eventbox1') self.eventbox1.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#444444')) self.get_group.child.connect('key-press-event',self.item_list_changed) #self.vpan = self.builder.get_object("vpaned1") self.output_txtview = self.builder.get_object("textview2") #pango self.fontdesc = pango.FontDescription("Purisa 10") #self.output_txtview.modify_font(self.fontdesc) for x in wordz_db.list_groups(): self.get_group.append_text(x) self.table1 = self.builder.get_object("table1") self.get_group.show() self.table1.attach(self.get_group, 1,2,1,2)
7259fb520fc5151ef0818ac3852f8ec5fb9b5ce3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/7259fb520fc5151ef0818ac3852f8ec5fb9b5ce3/wordgroupz.py
t = (grp,'', wn)
t = (grp,'', wn, '', '')
def add_to_db(self,word, grp, detail): conn = sqlite3.connect(db_file_path) c = conn.cursor() conn.text_factory = str if grp not in self.list_groups() and grp is not '': if word is '': wn = wordnet.get_definition(grp) t = (grp,detail,wn, '', '') else: wn = wordnet.get_definition(grp) t = (grp,'', wn) c.execute("""insert into groups values (?,?,?,?,?)""",t) conn.commit() #allow words with no groups to be added elif 'no-category' not in self.list_groups() and grp is '': c.execute("""insert into groups values ('no-category','Uncategorized words')""") if word is not '' and word not in self.list_words_per_group(grp): if grp == '': grp = 'no-category' wn = wordnet.get_definition(word) print wn t = (word, grp, detail, wn, '', '') c.execute('''insert into word_groups values(?,?,?,?,?,?)''', t) conn.commit() c.close()
9410949ed9d00e31fdd2b6a833bdb0065f074acc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/9410949ed9d00e31fdd2b6a833bdb0065f074acc/wordgroupz.py
c.execute("""select word, details from word_groups order by word""")
c.execute("""select word, wordnet from word_groups order by word""")
def get_details_for_flashcard(self): conn = sqlite3.connect(db_file_path) c = conn.cursor() c.execute("""select word, details from word_groups order by word""") data = c.fetchall() c.close() conn.close() return data
9410949ed9d00e31fdd2b6a833bdb0065f074acc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/9410949ed9d00e31fdd2b6a833bdb0065f074acc/wordgroupz.py
c.execute("""update word_groups set details='%s' where word=?"""% (details),t)
c.execute("""update word_groups set details="%s" where word=?"""% (details),t)
def update_details(self,tree_value, details): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (tree_value,) c.execute("""update word_groups set details='%s' where word=?"""% (details),t) conn.commit() c.close()
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
c.execute("""update groups set wiktionary='%s' where grp=?"""%(data), t)
c.execute("""update groups set wiktionary="%s" where grp=?"""%(data), t)
def save_wiktionary(self, word, data): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (word,) if word in self.list_groups(): c.execute("""update groups set wiktionary='%s' where grp=?"""%(data), t) else: c.execute("""update word_groups set wiktionary='%s' where word=?"""%(data), t) conn.commit() c.close() conn.close()
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
c.execute("""update word_groups set wiktionary='%s' where word=?"""%(data), t)
c.execute("""update word_groups set wiktionary="%s" where word=?"""%(data), t)
def save_wiktionary(self, word, data): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (word,) if word in self.list_groups(): c.execute("""update groups set wiktionary='%s' where grp=?"""%(data), t) else: c.execute("""update word_groups set wiktionary='%s' where word=?"""%(data), t) conn.commit() c.close() conn.close()
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
c.execute("""update groups set wordnet='%s' where grp=?"""%(data), t)
c.execute("""update groups set wordnet="%s" where grp=?"""%(data), t)
def save_wordnet(self, word, data): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (word,) if word in self.list_groups(): c.execute("""update groups set wordnet='%s' where grp=?"""%(data), t) else: c.execute("""update word_groups set wordnet='%s' where word=?"""%(data), t) conn.commit() c.close() conn.close()
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
c.execute("""update word_groups set wordnet='%s' where word=?"""%(data), t)
c.execute("""update word_groups set wordnet="%s" where word=?"""%(data), t)
def save_wordnet(self, word, data): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (word,) if word in self.list_groups(): c.execute("""update groups set wordnet='%s' where grp=?"""%(data), t) else: c.execute("""update word_groups set wordnet='%s' where word=?"""%(data), t) conn.commit() c.close() conn.close()
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
c.execute("""update groups set webster='%s' where grp=?"""%(data), t)
c.execute("""update groups set webster="%s" where grp=?"""%(data), t)
def save_webster(self, word, data): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (word,) if word in self.list_groups(): c.execute("""update groups set webster='%s' where grp=?"""%(data), t) else: c.execute("""update word_groups set webster='%s' where word=?"""%(data), t) conn.commit() c.close() conn.close()
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
c.execute("""update word_groups set webster='%s' where word=?"""%(data), t)
c.execute("""update word_groups set webster="%s" where word=?"""%(data), t)
def save_webster(self, word, data): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (word,) if word in self.list_groups(): c.execute("""update groups set webster='%s' where grp=?"""%(data), t) else: c.execute("""update word_groups set webster='%s' where word=?"""%(data), t) conn.commit() c.close() conn.close()
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
self.wiki_word = str(soup.html.title).split(' ')[0].split('>')[1] print 'wiki_word'+self.wiki_word
def load_finished(self, webview, frame): self.progress.set_visible(False) self.status_label.set_text('Content loaded.') self.status_label.hide() self.status_label.set_text('') self.browser_load_status = 'finished' if self.audio_found == True: self.save_audio.set_sensitive(True) else: pass if self.count == 0: self.count = 1 else: self.look_for_audio() return html = self.browser.get_html() self.head_file = open('wiktionary_header', 'r') self.head = self.head_file.read() self.head_file.close() self.head = self.head.replace('enter_title', self.tree_value) #self.status_label.set_text('Scrapping...') soup = BeautifulSoup(self.head+'<body>'+html+'</body></html>')
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
if self.selected_word is self.wiki_word and (self.browser_load_status is 'finished' or 'loading'):
if self.tree_value == self.wiki_word and (self.browser_load_status is 'finished' or 'loading'):
def on_notebook1_switch_page(self, notebook, page, page_num): #print 'page switched' #print page_num width, height = self.window.get_size() if page_num==1: self.window.resize(max(width, 800), max(height, 550)) #print self.tree_value, self.wiki_word, self.browser_load_status if self.selected_word is self.wiki_word and (self.browser_load_status is 'finished' or 'loading'): pass else: #self.url = 'http://en.wiktionary.org/wiki/' + self.tree_value #self.browser.open(self.url) self.on_lookup_wiki_clicked() elif page_num == 0: self.window.resize(min(width, 700), min(height, 550))
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
def show_details_tree(self): wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] #print wn ws = wordz_db.get_dict_data('webster', self.tree_value)[0] wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0] self.details_treestore.clear() if wn is not None: t = wn.split('\n') #print t piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) elif x.startswith('\t') and not x.startswith('\tSynonyms:'): sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) elif x.startswith('\tSynonyms:'): self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) if wik is not None: t = wik.split('\n') piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) #sub_iter = self.details_treestore.append(piter, [wik]) print t for x in t: if x.startswith('#'): sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) elif not x.startswith('\t') and not x.startswith('#'): self.details_treestore.append(sub_iter, [x]) elif x.startswith('\t#'): sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) elif x.startswith('\t') and not x.startswith('\t#'): self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) elif x.startswith('\t\t#'): sub_sub_sub_iter = self.details_treestore.append(sub_iter, ['<i>'+x.lstrip('\t\t#')+'</i>']) elif x.startswith('\t\t') and not x.startswith('\t\t#'): self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')]) #print self.details_cell.get_property('is-expander') self.details_treeview.expand_all()
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
if wn is not None:
if wn != u'':
def show_details_tree(self): wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] #print wn ws = wordz_db.get_dict_data('webster', self.tree_value)[0] wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0] self.details_treestore.clear() if wn is not None: t = wn.split('\n') #print t piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) elif x.startswith('\t') and not x.startswith('\tSynonyms:'): sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) elif x.startswith('\tSynonyms:'): self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) if wik is not None: t = wik.split('\n') piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) #sub_iter = self.details_treestore.append(piter, [wik]) print t for x in t: if x.startswith('#'): sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) elif not x.startswith('\t') and not x.startswith('#'): self.details_treestore.append(sub_iter, [x]) elif x.startswith('\t#'): sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) elif x.startswith('\t') and not x.startswith('\t#'): self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) elif x.startswith('\t\t#'): sub_sub_sub_iter = self.details_treestore.append(sub_iter, ['<i>'+x.lstrip('\t\t#')+'</i>']) elif x.startswith('\t\t') and not x.startswith('\t\t#'): self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')]) #print self.details_cell.get_property('is-expander') self.details_treeview.expand_all()
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
def show_details_tree(self): wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] #print wn ws = wordz_db.get_dict_data('webster', self.tree_value)[0] wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0] self.details_treestore.clear() if wn is not None: t = wn.split('\n') #print t piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) elif x.startswith('\t') and not x.startswith('\tSynonyms:'): sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) elif x.startswith('\tSynonyms:'): self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) if wik is not None: t = wik.split('\n') piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) #sub_iter = self.details_treestore.append(piter, [wik]) print t for x in t: if x.startswith('#'): sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) elif not x.startswith('\t') and not x.startswith('#'): self.details_treestore.append(sub_iter, [x]) elif x.startswith('\t#'): sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) elif x.startswith('\t') and not x.startswith('\t#'): self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) elif x.startswith('\t\t#'): sub_sub_sub_iter = self.details_treestore.append(sub_iter, ['<i>'+x.lstrip('\t\t#')+'</i>']) elif x.startswith('\t\t') and not x.startswith('\t\t#'): self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')]) #print self.details_cell.get_property('is-expander') self.details_treeview.expand_all()
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
if wik is not None:
if wik is not u'':
def show_details_tree(self): wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] #print wn ws = wordz_db.get_dict_data('webster', self.tree_value)[0] wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0] self.details_treestore.clear() if wn is not None: t = wn.split('\n') #print t piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) elif x.startswith('\t') and not x.startswith('\tSynonyms:'): sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) elif x.startswith('\tSynonyms:'): self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) if wik is not None: t = wik.split('\n') piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) #sub_iter = self.details_treestore.append(piter, [wik]) print t for x in t: if x.startswith('#'): sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) elif not x.startswith('\t') and not x.startswith('#'): self.details_treestore.append(sub_iter, [x]) elif x.startswith('\t#'): sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) elif x.startswith('\t') and not x.startswith('\t#'): self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) elif x.startswith('\t\t#'): sub_sub_sub_iter = self.details_treestore.append(sub_iter, ['<i>'+x.lstrip('\t\t#')+'</i>']) elif x.startswith('\t\t') and not x.startswith('\t\t#'): self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')]) #print self.details_cell.get_property('is-expander') self.details_treeview.expand_all()
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
print t
def show_details_tree(self): wn = wordz_db.get_dict_data('wordnet', self.tree_value)[0] #print wn ws = wordz_db.get_dict_data('webster', self.tree_value)[0] wik = wordz_db.get_dict_data('wiktionary', self.tree_value)[0] self.details_treestore.clear() if wn is not None: t = wn.split('\n') #print t piter = self.details_treestore.append(None, ['<span foreground="blue"><big><b>Wordnet</b></big></span>']) for x in t: if not x.startswith('\t') and x is not u'': sub_iter = self.details_treestore.append(piter, ['<b>'+x+'</b>']) elif x.startswith('\t') and not x.startswith('\tSynonyms:'): sub_sub_iter = self.details_treestore.append(sub_iter, [x.strip('\t')]) elif x.startswith('\tSynonyms:'): self.details_treestore.append(sub_sub_iter, [x.strip('\t').replace('Synonyms', '<span foreground="blue">Synonyms</span>')]) if wik is not None: t = wik.split('\n') piter = self.details_treestore.append(None,['<span foreground="blue"><big><b>Wiktionary</b></big></span>']) #sub_iter = self.details_treestore.append(piter, [wik]) print t for x in t: if x.startswith('#'): sub_iter = self.details_treestore.append(piter, ['<b>'+x.lstrip('#')+'</b>']) elif not x.startswith('\t') and not x.startswith('#'): self.details_treestore.append(sub_iter, [x]) elif x.startswith('\t#'): sub_sub_iter = self.details_treestore.append(sub_iter, ['<b>'+x.lstrip('\t#')+'</b>']) elif x.startswith('\t') and not x.startswith('\t#'): self.details_treestore.append(sub_sub_iter, [x.lstrip('\t')]) elif x.startswith('\t\t#'): sub_sub_sub_iter = self.details_treestore.append(sub_iter, ['<i>'+x.lstrip('\t\t#')+'</i>']) elif x.startswith('\t\t') and not x.startswith('\t\t#'): self.details_treestore.append(sub_sub_sub_iter, [x.lstrip('\t\t')]) #print self.details_cell.get_property('is-expander') self.details_treeview.expand_all()
8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/8f3acae2f8bc5581b5ba3c68cc4ada8f0e1617a9/wordgroupz.py
self.scrolledwindow2 = self.builder.get_object("scrolledwindow2") self.scrolledwindow2.add_with_viewport(self.treeview)
self.scrolledwindow2 = gtk.ScrolledWindow() self.scrolledwindow2.add(self.treeview) self.scrolledwindow2.show() self.scrolledwindow2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.vbox6 = self.builder.get_object('vbox6') self.vbox6.pack_start(self.scrolledwindow2)
def __init__(self): self.builder = gtk.Builder() self.builder.add_from_file("wordgroupz.glade") self.window = self.builder.get_object("MainWindow") self.window.set_icon_from_file("/usr/share/pixmaps/wordgroupz.png") self.window.set_title("wordGroupz") self.builder.connect_signals(self) self.get_word = self.builder.get_object("get_word") self.get_group = gtk.combo_box_entry_new_text() self.get_group.set_tooltip_text("Enter a group for your word") self.details = self.builder.get_object("textview1") self.eventbox1 = self.builder.get_object('eventbox1') self.eventbox1.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#444444')) self.get_group.child.connect('key-press-event',self.item_list_changed) #self.vpan = self.builder.get_object("vpaned1") self.output_txtview = self.builder.get_object("textview2") for x in wordz_db.list_groups(): self.get_group.append_text(x) self.table1 = self.builder.get_object("table1") self.get_group.show() self.table1.attach(self.get_group, 1,2,1,2)
c6e8ca5d3096af2d5c320abede2cacab0c3ab5fc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/c6e8ca5d3096af2d5c320abede2cacab0c3ab5fc/wordgroupz.py
return metadata.get("file_size")
if metadata: return metadata.get("file_size") return None
def get_torrent_size(self, torrent_url): """download torrent from the url and try to extract size""" try: import gzip import StringIO import hachoir_parser import hachoir_metadata except ImportError: return
f0e763e7314e7af95ee66b1de90bdf26ba784496 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7656/f0e763e7314e7af95ee66b1de90bdf26ba784496/feed_command.py
client = transmission.transmission.Client(**args)
client = transmissionrpc.Client(**args)
def _send_command(self, torrent): args = {"address": str(self.host), "port": int(self.port)} if self.username: args["user"] = str(self.username) args["password"] = str(self.passwd) client = transmission.transmission.Client(**args)
06abe150c7e4bf707d8216fee3666cdbd6709388 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7656/06abe150c7e4bf707d8216fee3666cdbd6709388/transm.py
except transmission.transmission.TransmissionError,e:
except transmissionrpc.TransmissionError,e:
def _send_command(self, torrent): args = {"address": str(self.host), "port": int(self.port)} if self.username: args["user"] = str(self.username) args["password"] = str(self.passwd) client = transmission.transmission.Client(**args)
06abe150c7e4bf707d8216fee3666cdbd6709388 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7656/06abe150c7e4bf707d8216fee3666cdbd6709388/transm.py
return self.get_current_weather()
return self.get_random_weather()
def get_random_weather(self): """ Returns a random weather, never returns the previous weather. """ l = ["rainy", "sunny", "cold", "normal"] i = random.randint(0, 3) if i == self.p_i: return self.get_current_weather() else: self.p_i = i print "se genero el clima: ", l[i] return l[i]
37f32d0df5724255a332e4b250c61585b619f113 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/37f32d0df5724255a332e4b250c61585b619f113/game_manager.py
"""
def draw(self, screen): if self.first: # First time blits the entire background self.first = False screen.blit(self.background, self.rect) return [self.rect] else: # Next blits only the changed areas changes = [] for win in self.windows: changes.extend(win.draw(screen)) return changes #[rect.move(self.rect.left, self.rect.top) for rect in changes]
f357230bc61b0a0ab2aed6fd845d07baf290bdbf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/f357230bc61b0a0ab2aed6fd845d07baf290bdbf/window.py
self.overall_section = BarSection(windows_controller, _("Total"), bars_loader.get_overall_bar(), [] , (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 32), "assets/layout/icon_total.png") self.physica_section = BarSection(windows_controller, _("physica"), self.bars[0], self.bars[0].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 60), "assets/layout/icon_physica.png")
self.overall_section = BarSection(windows_controller, _("Total"), bars_loader.get_overall_bar(), [] , (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 20), "assets/layout/icon_total.png") self.physica_section = BarSection(windows_controller, _("physica"), self.bars[0], self.bars[0].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 50), "assets/layout/icon_physica.png")
def __init__(self, container, rect, frame_rate, windows_controller, bars_loader): Window.__init__(self, container, rect, frame_rate, windows_controller) # rect and surface: self.rect.size = (227, 590) # game bars self.bars = bars_loader.get_second_level_bars() # sections self.score_section = ScoreSection(StatusBar("score_bar", "score", None, bars_loader.get_overall_bar(), 100, 15), (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 0), 1) self.overall_section = BarSection(windows_controller, _("Total"), bars_loader.get_overall_bar(), [] , (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 32), "assets/layout/icon_total.png") self.physica_section = BarSection(windows_controller, _("physica"), self.bars[0], self.bars[0].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 60), "assets/layout/icon_physica.png") self.hygiene_section = BarSection(windows_controller, _("hygiene"), self.bars[1], self.bars[1].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 80), "assets/layout/icon_hygiene.png") self.nutrition_section = BarSection(windows_controller, _("nutrition"), self.bars[2], self.bars[2].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 100), "assets/layout/icon_nutrition.png") self.spare_time_section = BarSection(windows_controller, _("spare time"), self.bars[3], self.bars[3].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 120), "assets/layout/icon_spare_time.png") self.sections_list = [self.score_section, self.overall_section, self.physica_section, self.hygiene_section, self.nutrition_section, self.spare_time_section] self.accordeon = Accordeon([self.physica_section, self.hygiene_section, self.nutrition_section, self.spare_time_section]) self.set_bg_image("assets/layout/status.png") #self.score_section, self.windows += [section for section in self.sections_list if section != self.score_section] # Score section no va porque no está convertida a window
3b417d3d58979c821331d6dbdeea980d65168e27 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/3b417d3d58979c821331d6dbdeea980d65168e27/status_bars.py
self.nutrition_section = BarSection(windows_controller, _("nutrition"), self.bars[2], self.bars[2].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 100), "assets/layout/icon_nutrition.png") self.spare_time_section = BarSection(windows_controller, _("spare time"), self.bars[3], self.bars[3].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 120), "assets/layout/icon_spare_time.png")
self.nutrition_section = BarSection(windows_controller, _("nutrition"), self.bars[2], self.bars[2].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 110), "assets/layout/icon_nutrition.png") self.spare_time_section = BarSection(windows_controller, _("spare time"), self.bars[3], self.bars[3].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 140), "assets/layout/icon_spare_time.png")
def __init__(self, container, rect, frame_rate, windows_controller, bars_loader): Window.__init__(self, container, rect, frame_rate, windows_controller) # rect and surface: self.rect.size = (227, 590) # game bars self.bars = bars_loader.get_second_level_bars() # sections self.score_section = ScoreSection(StatusBar("score_bar", "score", None, bars_loader.get_overall_bar(), 100, 15), (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 0), 1) self.overall_section = BarSection(windows_controller, _("Total"), bars_loader.get_overall_bar(), [] , (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 32), "assets/layout/icon_total.png") self.physica_section = BarSection(windows_controller, _("physica"), self.bars[0], self.bars[0].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 60), "assets/layout/icon_physica.png") self.hygiene_section = BarSection(windows_controller, _("hygiene"), self.bars[1], self.bars[1].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 80), "assets/layout/icon_hygiene.png") self.nutrition_section = BarSection(windows_controller, _("nutrition"), self.bars[2], self.bars[2].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 100), "assets/layout/icon_nutrition.png") self.spare_time_section = BarSection(windows_controller, _("spare time"), self.bars[3], self.bars[3].children_list, (SECTION_WIDTH, SECTION_MIN_HEIGHT), (SECTION_OFFSET_X, 120), "assets/layout/icon_spare_time.png") self.sections_list = [self.score_section, self.overall_section, self.physica_section, self.hygiene_section, self.nutrition_section, self.spare_time_section] self.accordeon = Accordeon([self.physica_section, self.hygiene_section, self.nutrition_section, self.spare_time_section]) self.set_bg_image("assets/layout/status.png") #self.score_section, self.windows += [section for section in self.sections_list if section != self.score_section] # Score section no va porque no está convertida a window
3b417d3d58979c821331d6dbdeea980d65168e27 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/3b417d3d58979c821331d6dbdeea980d65168e27/status_bars.py
self.root_bar_display = BarDisplay(BAR_HEIGHT, (size[0] - 2), (BAR_OFFSET_X, (size[1] / 2) - 13), self.root_bar, ROOT_BAR_COLOR)
self.root_bar_display = BarDisplay(BAR_HEIGHT, (size[0] - 2), (BAR_OFFSET_X, SECTION_TOP_PADDING), self.root_bar, ROOT_BAR_COLOR)
def __init__(self, windows_controller, name, root_bar, children_bar, size, position, icon_path): rect = pygame.Rect(position, size) Window.__init__(self, rect, rect, 1, windows_controller) # section attributes self.name = name self.root_bar = root_bar self.children_bar = children_bar # visuals self.root_bar_display = BarDisplay(BAR_HEIGHT, (size[0] - 2), (BAR_OFFSET_X, (size[1] / 2) - 13), self.root_bar, ROOT_BAR_COLOR) self.displays_list = self.__get_displays() # obtengo los displays para cada barra. self.fixed_widgets = [] if icon_path: icon = pygame.image.load(icon_path).convert_alpha() self.icon = Widget(self.rect, pygame.Rect((0, 0), icon.get_size()), 1, icon) self.fixed_widgets.append(self.icon) else: self.icon = None # visuals constant self.init_top = self.rect[1] self.init_height = size[1] self.max_expand = len(children_bar) * (BAR_HEIGHT + 1) self.expanded = False # Este flag se activa cuando se están mostrando las sub-barras self.__calculate() # calculo la posición de cada barra en la sección
3b417d3d58979c821331d6dbdeea980d65168e27 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/3b417d3d58979c821331d6dbdeea980d65168e27/status_bars.py
y = 0
y = SECTION_TOP_PADDING
def __calculate(self): """ Calcula la posición de cada barra dependiendo de si está expandida o no la sección. """ # Refresh the absolute position of the root bar self.root_bar_display.container = self.rect self.root_bar_display.set_rect_in_container(self.root_bar_display.rect_in_container) self.widgets = [self.root_bar_display] if self.expanded: y = 0 for display in self.displays_list: y += (BAR_HEIGHT + 1) display.container = self.rect display.rect_in_container.top = y display.set_rect_in_container(display.rect_in_container) self.widgets.append(display) self.widgets.extend(self.fixed_widgets)
3b417d3d58979c821331d6dbdeea980d65168e27 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/3b417d3d58979c821331d6dbdeea980d65168e27/status_bars.py
if(button.rect.top == 130):
if(button.rect_in_container.top == 130):
def _cb_button_click_choice(self, button): global FIN_MC if(button.rect.top == 130): self.s_correct.play() FIN_MC = True # Damos por finalizada la pregunta else: self.s_incorrect.play()
cc6d24d8d879fb1634a3f01aabf0d4cf9bcdc9de /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/cc6d24d8d879fb1634a3f01aabf0d4cf9bcdc9de/challenges.py
if isinstance(color, pygame.Color):
if isinstance(color, tuple): return color elif isinstance(color, pygame.Color):
def get_color_tuple(color): if isinstance(color, pygame.Color): return (color.r, color.g, color.b, color.a) elif isinstance(color, tuple): return color else: color = pygame.Color(color) return get_color_tuple(color)
1fa502cf9b2c9eb0c58a41b1a5faf3e5d274eac3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/1fa502cf9b2c9eb0c58a41b1a5faf3e5d274eac3/utilities.py
elif isinstance(color, tuple): return color
def get_color_tuple(color): if isinstance(color, pygame.Color): return (color.r, color.g, color.b, color.a) elif isinstance(color, tuple): return color else: color = pygame.Color(color) return get_color_tuple(color)
1fa502cf9b2c9eb0c58a41b1a5faf3e5d274eac3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/1fa502cf9b2c9eb0c58a41b1a5faf3e5d274eac3/utilities.py
<<<<<<< HEAD
def __init__(self, container, rect, frame_rate, clock, screen, windows_controller): Window.__init__(self, container, rect, frame_rate, (0, 0, 0), screen, windows_controller) self.name = "main" self.clock = clock self.windows = [] # Lista de ventanas que 'componen' la ventana principal
41308cebde99d110214259ef2b77f55042443609 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/41308cebde99d110214259ef2b77f55042443609/window.py
=======
def __init__(self, container, rect, frame_rate, clock, screen, windows_controller): Window.__init__(self, container, rect, frame_rate, (0, 0, 0), screen, windows_controller) self.name = "main" self.clock = clock self.windows = [] # Lista de ventanas que 'componen' la ventana principal
41308cebde99d110214259ef2b77f55042443609 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/41308cebde99d110214259ef2b77f55042443609/window.py
self.windows.append(self.status_bars) >>>>>>> 73f0d4ce24750887870a439c77676d1efa9d84a4
def __init__(self, container, rect, frame_rate, clock, screen, windows_controller): Window.__init__(self, container, rect, frame_rate, (0, 0, 0), screen, windows_controller) self.name = "main" self.clock = clock self.windows = [] # Lista de ventanas que 'componen' la ventana principal
41308cebde99d110214259ef2b77f55042443609 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/41308cebde99d110214259ef2b77f55042443609/window.py
self.active_char_action.time_left = time_span
self.active_char_action.time_left = self.active_char_action.time_span
def interrupt_active_action(self, action_id): """ Stops the active action if exist, and set as active the action with the 'action_id'. If the action_id is 'None', just stops the active action. """ self.active_char_action.time_left = time_span self.active_char_action = None if(action_id): action = self.get_action(action_id) if(action): self.active_char_action = action
487fc7866fbe3a584da49fd428b76aea48031c12 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/487fc7866fbe3a584da49fd428b76aea48031c12/game_manager.py
self.remove_button(self.b_event_personal)
if self.b_event_personal in self.buttons: self.remove_button(self.b_event_personal)
def remove_personal_event(self, event): self.active_personal_events.remove(event) self.windows_controller.hide_active_tooltip() self.remove_button(self.b_event_personal) self.b_event_personal = None
dcaca4e4df0b40b12eee6822999b3815825ac6d3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/dcaca4e4df0b40b12eee6822999b3815825ac6d3/panel_window.py
self.game_manager.add_active_action(action_id)
self.game_manager.set_active_action(action_id)
def send_action(self, action_id): """ Send an action to the game_manager. The action was selected in one of the sub-items """ self.game_manager.add_active_action(action_id)
64c3248fa1bab23224e6a87cbdbefe24b061267a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/64c3248fa1bab23224e6a87cbdbefe24b061267a/menu.py
arrow_position = self.status_bar.value * (self.rect_in_container.width - 2.0) / self.status_bar.max
position = self.status_bar.value * (self.rect_in_container.width) / (BAR_WIDTH) arrow_position = min([position, BAR_WIDTH + BAR_OFFSET_X])
def draw(self, screen): if self.last_value != self.status_bar.value: if isinstance(self.status_bar, WeightBar): arrow_position = self.status_bar.value * (self.rect_in_container.width - 2.0) / self.status_bar.max self.surface.blit(self.background, (0, 0)) self.surface.blit(self.arrow, (arrow_position, 14)) elif isinstance(self.status_bar, StatusBar): rect = pygame.Rect((1, 2), (self.rect_in_container.width - 2, self.rect_in_container.height - 4)) charged_rect = pygame.Rect(rect) # create a copy charged_rect.width = self.status_bar.value * rect.width / self.status_bar.max color = self.get_color() self.surface.fill(BAR_BACK_COLOR, rect) self.surface.fill(color, charged_rect) self.surface.blit(self.background, (0, 0)) # Background blits over the charge, because it has the propper alpha if self.show_name: self.surface.blit(self.font.render(self.label, 1, pygame.Color(SUB_BAR_TEXT_COLOR)), (8, 4)) screen.blit(self.surface, self.rect_absolute) return self.rect_absolute
de53ded4d45bc6d6d19acc60b746cf0c1eed6a34 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/de53ded4d45bc6d6d19acc60b746cf0c1eed6a34/status_bars.py
if changes: pygame.display.update(changes) update = False
if changes: pygame.display.update(changes) update = False
def main(fromSugar): """Main function of the game. This function initializes the game and enters the PyGame main loop. """ if fromSugar: import gtk # Optimizes sound quality and buffer for quick loading pygame.mixer.pre_init(22050, -16, 8, 256) # Inits PyGame module pygame.init() target_size = (1000, 700) if not fromSugar: screen = pygame.display.set_mode(target_size) screen = pygame.display.get_surface() assert screen, "No screen" pygame.display.update() # This clock is used to keep the game at the desired FPS. clock = pygame.time.Clock() windows = [] windows.append(window.BlinkWindow(pygame.Rect((700, 0),(300,140)), 5, pygame.Color("red"))) windows.append(window.BlinkWindow(pygame.Rect((700, 150),(300,140)), 5, pygame.Color("blue"))) windows.append(window.StatusWindow(pygame.Rect((700, 300),(300,140)), 2, pygame.Color("gray"))) windows.append(window.MainWindow(pygame.Rect((0, 0),(600,500)), 1)) windows.append(animation.Apple(pygame.Rect((150, 500),(150,172)), 10)) windows.append(menu.Menu(pygame.Rect((150, 500),(150,172)), 1)) windows.append(animation.FPS(pygame.Rect((650, 80),(50,20)), 15, clock)) frames = 0 # Main loop update = True # The first time the screen need to be updated running = True while running: if fromSugar: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Waits for events, if none the game pauses: # http://wiki.laptop.org/go/Game_development_HOWTO#Reducing_CPU_Load milliseconds = clock.tick(MAX_FPS) # waits if the game is running faster than MAX_FPS events = pygame.event.get() if events: for event in events: if event.type == pygame.QUIT: running = False elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: running = False changes = [] for win in windows: if frames % win.frame_rate == 0: changes.extend(win.draw(screen)) if changes: pygame.display.update(changes) update = False frames += 1 # Una vez que sale del loop manda la senal de quit para que cierre la ventana pygame.quit()
c696e91dd6d022450cbb7662c66ae723301a6acf /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/c696e91dd6d022450cbb7662c66ae723301a6acf/game.py
self.exit = Item(container, frame_rate, "salir", "assets/icons/icon_quit.png", CLOSE_MENU, [], self, font, True)
self.exit = Item(container, frame_rate, "salir", "assets/icons/icon_quit.png", CLOSE_MENU, [], self, font, None, None, True)
def __init__(self, frame_rate, container, windows_controller, item_list, center, radius, game_manager, font): rect = pygame.Rect((0, 0), SIZE) rect.center = center self.windows_controller = windows_controller self.game_manager = game_manager Window.__init__(self, container, rect, frame_rate, windows_controller, "menu_window")
408713152991ab52a8677b494c3959a97ba2391f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/408713152991ab52a8677b494c3959a97ba2391f/menu.py
self.back = Item(container, frame_rate, "back", "assets/icons/icon_quit.png", BACK_MENU, [], self, font, True)
self.back = Item(container, frame_rate, "back", "assets/icons/icon_quit.png", BACK_MENU, [], self, font, None, None, True)
def __init__(self, frame_rate, container, windows_controller, item_list, center, radius, game_manager, font): rect = pygame.Rect((0, 0), SIZE) rect.center = center self.windows_controller = windows_controller self.game_manager = game_manager Window.__init__(self, container, rect, frame_rate, windows_controller, "menu_window")
408713152991ab52a8677b494c3959a97ba2391f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/408713152991ab52a8677b494c3959a97ba2391f/menu.py
action.perform()
action.perform() self.windows_controller.show_action_animation(action)
def set_active_action(self, action_id): #place = get_place(self.character.actual_place) #if(place.allowed_action(action_id)): #continúa con la acción, solo si es permitida en el lugar if(not self.active_char_action): #Si existe una accion activa no la interrumpe if(True): #dont check char's place yet action = self.get_action(action_id) if(action): action.perform() self.active_char_action = action
d1b699d8a33f18fba2db42d0c8b00e5776b2884e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/d1b699d8a33f18fba2db42d0c8b00e5776b2884e/game_manager.py
action.perform() self.windows_controller.show_action_animation(action)
def interrupt_active_action(self, action_id): """ Stops the active action if exist, and set as active the action with the 'action_id'. If the action_id is 'None', just stops the active action. """ self.active_char_action.time_left = time_span self.active_char_action = None if(action_id): action = self.get_action(action_id) if(action): action.perform() self.windows_controller.show_action_animation(action) self.active_char_action = action
d1b699d8a33f18fba2db42d0c8b00e5776b2884e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/d1b699d8a33f18fba2db42d0c8b00e5776b2884e/game_manager.py
event = events.SocialEvent("unkown.png", "assets/characters/teacher.png", "health_check", _("Control médico"), 5.0, 30, probability, u"¿Este año fuiste al doctor?", 100)
event = events.SocialEvent("unkown.png", "assets/characters/teacher.png", "health_check", _("Control médico"), 5.0, 30, probability, u"¿Este año fuiste al doctor?", None, 100)
def __load_events(self, bars_controller): #Events constructor params: #picture, kid_animation_path, id, description, appereance_probability, time_span, kind, event_status, effect, kid_message, #preferred_mood=9, message_time_span = time_span) _events = [] # Personal Events # probabiliy configuration: (bar, type, threshold, probability_percentaje) probability = [("v_frutas", "indirect", 10.0, 30.0)] effect = effects.Effect(bars_controller, [("energy", -1.0), ("fun", -0.5)]) event = events.PersonalEvent("ill.jpg", None, "constipation", _("Constipation"), 5, 15, "personal", probability, effect, u"Me duele la panza y no \n puedo ir al baño", 2, 50) _events.append(event) probability = [("w_hands", "indirect", 25.0, 30.0)] effect = effects.Effect(bars_controller, [("energy", -1.0), ("fun", -0.5), ("agua", -1.0), ("defenses", -0.5)]) event = events.PersonalEvent("ill.jpg", None, "diarrhea", _("Diarrhea"), 5, 15, "personal", probability, effect, "Tengo diarrea", 2, 50) _events.append(event) probability = [("nutrition", "indirect", 100.0, 20.0), ("relaxing", "indirect", 100.0, 20.0)] effect = effects.Effect(bars_controller, [("energy", -1.0), ("fun", -0.5), ("relaxing", -0.5)]) event = events.PersonalEvent("ill.jpg", None, "headache", _("Headache"), 5, 15, "personal", probability, effect, "Me duele la cabeza", 2, 50) _events.append(event) probability = [("b_teeth", "indirect", 25.0, 50.0), ("dulces", "direct", 75.0, 20.0)] effect = effects.Effect(bars_controller, [("energy", -1.0), ("defenses", -1.0), ("fun", -1.0), ("relaxing", -1.0)]) event = events.PersonalEvent("caries.jpg", None, "caries", _("Caries"), 5, 15, "personal", probability, effect, "Me duele una muela", 5, 50) _events.append(event) probability = [("overall_bar", "constant", 100.0, 15.0)] effect = effects.Effect(bars_controller, [("nutrition", -0.3), ("energy", -1.0), ("resistencia", -0.9), ("fat", -0.5)]) event = events.PersonalEvent("ill.jpg", "assets/events/stomach_ache", "stomach_ache", _("Stomach ache"), 5, 15, "personal", probability, effect, "Me duele la panza! :(", 2, 50) _events.append(event) #Social events #(picture, person_path, name, description, appereance_probability, time_span, condicioned_bars, message, message_time_span) probability = [("b_teeth", "indirect", 50.0, 70.0), ("dulces", "direct", 75.0, 30.0)] #editar parametros: event = events.SocialEvent("caries.jpg", "assets/characters/teacher.png", "p_caries", _("Prevenir caries"), 5.0, 15, probability, u"Deberías lavarte los \ndientes", None, 100) _events.append(event)
42c6e205cc48cdae4d1b3b4803d1c831e453bd59 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/42c6e205cc48cdae4d1b3b4803d1c831e453bd59/app_init.py
window.Window.__init__(self, container, rect, frame_rate, windows_controller, pygame.Color("Gray"))
window.Window.__init__(self, container, rect, frame_rate, windows_controller, pygame.Color("gray"))
def __init__(self, container, rect, frame_rate, windows_controller, character): window.Window.__init__(self, container, rect, frame_rate, windows_controller, pygame.Color("Gray")) kid_rect = pygame.Rect((20, 20), (1,1)) self.kid = CustomizatedKid(self.rect, kid_rect, 1, character) self.add_child(self.kid) self.btn_close = utilities.TextButton(self.rect, pygame.Rect((770, 5), (30, 30)), 1, "X", 30, (0, 0, 0), self._cb_button_click_close) self.btn_hair = utilities.TextButton(self.rect, pygame.Rect((500, 150), (70, 30)), 1, _("Hair"), 30, (0, 0, 0), self._cb_button_hair) self.btn_skin = utilities.TextButton(self.rect, pygame.Rect((500, 200), (70, 30)), 1, _("Skin"), 30, (0, 0, 0), self._cb_button_skin) self.btn_socks = utilities.TextButton(self.rect, pygame.Rect((500, 250), (70, 30)), 1, _("Socks"), 30, (0, 0, 0), self._cb_button_socks) self.btn_shoes = utilities.TextButton(self.rect, pygame.Rect((500, 300), (70, 30)), 1, _("Shoes"), 30, (0, 0, 0), self._cb_button_shoes) self.buttons += [self.btn_close, self.btn_hair, self.btn_skin, self.btn_socks, self.btn_shoes] self.widgets += [self.btn_close, self.btn_hair, self.btn_skin, self.btn_socks, self.btn_shoes] self.hair_color_index = 0 self.skin_color_index = 0 self.socks_color_index = 0 self.shoes_color_index = 0
eb1f5cb63a434a77345ef767701cdffc55045c11 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/eb1f5cb63a434a77345ef767701cdffc55045c11/customization.py
widget.Widget.__init__(self, container, rect, frame_rate, pygame.Color("Black"))
widget.Widget.__init__(self, container, rect, frame_rate, pygame.Color("black"))
def __init__(self, container, rect, frame_rate, character): widget.Widget.__init__(self, container, rect, frame_rate, pygame.Color("Black")) self.character = character self.mappings = CustomizatedKid.COLOR_MAP.copy() self.character.mappings = self.mappings self.set_gender("male") self.background = self.kid
eb1f5cb63a434a77345ef767701cdffc55045c11 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/3492/eb1f5cb63a434a77345ef767701cdffc55045c11/customization.py
def random_vec(xv, yv):
def random_vec(x, y):
def random_vec(xv, yv): return Vec2d( random.uniform(-xv, xv), random.uniform(-yv, yv))
908b9ce85973496edaf97963c68f96766603514b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13474/908b9ce85973496edaf97963c68f96766603514b/utils.py
random.uniform(-xv, xv), random.uniform(-yv, yv))
random.uniform(-x, x), random.uniform(-y, y))
def random_vec(xv, yv): return Vec2d( random.uniform(-xv, xv), random.uniform(-yv, yv))
908b9ce85973496edaf97963c68f96766603514b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13474/908b9ce85973496edaf97963c68f96766603514b/utils.py
if not self.score_changed: self.score_changed(score)
if self.score_changed: self.score_changed(score)
def score(self, score): if self.__score == score: return self.__score = score if not self.score_changed: self.score_changed(score)
54ef31a33b7bca7e03a76727faed4a8c13a36566 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/13474/54ef31a33b7bca7e03a76727faed4a8c13a36566/Naubino.py
''' if not os.path.exists(os.path.join(os.path.abspath('.'), 'images')): os.mkdir(os.path.join(os.path.abspath('.'), 'images')) gencards.generator(os.path.join(os.path.abspath('.'), 'images')) '''
def __init__(self): self.r = 0 self.tw = None # create a new window self.win = gtk.Window(gtk.WINDOW_TOPLEVEL) self.win.maximize() self.win.set_title("%s: %s" % (_("Visual Match"), _("Click on cards to create sets of three."))) self.win.connect("delete_event", lambda w, e: gtk.main_quit())
e4a64eca2c257da825c8379d225fa379555ffb85 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/e4a64eca2c257da825c8379d225fa379555ffb85/visualmatch.py
self.vmw = game.Game(canvas, \ os.path.join(os.path.abspath('.'), \ 'images/'))
self.vmw = Game(canvas, os.path.join(os.path.abspath('.'), 'images/'))
def __init__(self): self.r = 0 self.tw = None # create a new window self.win = gtk.Window(gtk.WINDOW_TOPLEVEL) self.win.maximize() self.win.set_title("%s: %s" % (_("Visual Match"), _("Click on cards to create sets of three."))) self.win.connect("delete_event", lambda w, e: gtk.main_quit())
e4a64eca2c257da825c8379d225fa379555ffb85 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/e4a64eca2c257da825c8379d225fa379555ffb85/visualmatch.py
try:
if 1==1:
def load_score(self): try: f = file(os.path.join(os.path.abspath('.'), 'visualmatch.score'), "r") s = [f.read().split(":"), f.read().split(":")] f.close self.vmw.low_score = (int(s[0]), int(s[1])) print "low score is: %d" % (self.vmw.low_score) except: self.vmw.low_score = [-1, -1]
e4a64eca2c257da825c8379d225fa379555ffb85 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/e4a64eca2c257da825c8379d225fa379555ffb85/visualmatch.py
s = [f.read().split(":"), f.read().split(":")]
s = f.readlines()
def load_score(self): try: f = file(os.path.join(os.path.abspath('.'), 'visualmatch.score'), "r") s = [f.read().split(":"), f.read().split(":")] f.close self.vmw.low_score = (int(s[0]), int(s[1])) print "low score is: %d" % (self.vmw.low_score) except: self.vmw.low_score = [-1, -1]
e4a64eca2c257da825c8379d225fa379555ffb85 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/e4a64eca2c257da825c8379d225fa379555ffb85/visualmatch.py
self.vmw.low_score = (int(s[0]), int(s[1])) print "low score is: %d" % (self.vmw.low_score) except:
self.vmw.low_score = [int(s[0].split(':')[1].strip()), int(s[1].split(':')[1].strip())] print "low score is: %s" % (self.vmw.low_score) else:
def load_score(self): try: f = file(os.path.join(os.path.abspath('.'), 'visualmatch.score'), "r") s = [f.read().split(":"), f.read().split(":")] f.close self.vmw.low_score = (int(s[0]), int(s[1])) print "low score is: %d" % (self.vmw.low_score) except: self.vmw.low_score = [-1, -1]
e4a64eca2c257da825c8379d225fa379555ffb85 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/e4a64eca2c257da825c8379d225fa379555ffb85/visualmatch.py
f.write("low_score_beginner:%s" % str(int(self.vmw.low_score[0]))) f.write("low_score_expert:%s" % str(int(self.vmw.low_score[1])))
f.writelines(["low_score_beginner:%d\n" % int(self.vmw.low_score[0]), "low_score_expert:%d\n" % int(self.vmw.low_score[1])])
def save_score(self): f = file(os.path.join(os.path.abspath('.'), 'visualmatch.score'), "w") f.write("low_score_beginner:%s" % str(int(self.vmw.low_score[0]))) f.write("low_score_expert:%s" % str(int(self.vmw.low_score[1]))) f.close
e4a64eca2c257da825c8379d225fa379555ffb85 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/e4a64eca2c257da825c8379d225fa379555ffb85/visualmatch.py
basename = None
name = None
def _import_cb(self, button=None): """ Import custom cards from the Journal """ basename = None chooser = ObjectChooser(_('Choose custom card'), self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \ what_filter=mime.GENERIC_TYPE_IMAGE)
eb838e67153a1e314712a930f0fc94cd4cd94677 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/eb838e67153a1e314712a930f0fc94cd4cd94677/VisualMatchActivity.py
basename, suffix = name.split('.', 2)
def _import_cb(self, button=None): """ Import custom cards from the Journal """ basename = None chooser = ObjectChooser(_('Choose custom card'), self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \ what_filter=mime.GENERIC_TYPE_IMAGE)
eb838e67153a1e314712a930f0fc94cd4cd94677 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/eb838e67153a1e314712a930f0fc94cd4cd94677/VisualMatchActivity.py
if basename is not None: self._find_custom_paths(basename, mime_type) def _find_custom_paths(self, basename, mime_type):
if name is not None: self._find_custom_paths(name, mime_type) def _find_custom_paths(self, name, mime_type): parts = name.split('.') basename = parts[0] suffix = '' if len(parts) > 2: for i in range(2,len(name)): suffix += '.' suffix += parts[i]
def _import_cb(self, button=None): """ Import custom cards from the Journal """ basename = None chooser = ObjectChooser(_('Choose custom card'), self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \ what_filter=mime.GENERIC_TYPE_IMAGE)
eb838e67153a1e314712a930f0fc94cd4cd94677 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/eb838e67153a1e314712a930f0fc94cd4cd94677/VisualMatchActivity.py
basename + '.' + str(j+1):
basename + '.' + str(j+1) + suffix:
def _find_custom_paths(self, basename, mime_type): dsobjects, nobjects = datastore.find({'mime_type': str(mime_type)}) self.vmw.custom_paths = [] if nobjects > 0: for j in range(DECKSIZE): for i in range(nobjects): if dsobjects[i].metadata['title'] == \ basename + '.' + str(j+1): _logger.debug('result of find: %s' %\ dsobjects[i].metadata['title']) self.vmw.custom_paths.append(dsobjects[i].file_path) break self.vmw.card_type = 'custom' if len(self.vmw.custom_paths) < 9: self.vmw.card_type = 'pattern' elif len(self.vmw.custom_paths) < 27: self.vmw.level = DIFFICULTY_LEVEL.index(LOW) elif len(self.vmw.custom_paths) < 81: self.vmw.level = DIFFICULTY_LEVEL.index(MEDIUM) else: self.vmw.level = DIFFICULTY_LEVEL.index(HIGH) if self.vmw.card_type == 'custom': self.button_custom.set_icon('new-custom-game') self.button_custom.set_tooltip(_('New custom game')) self.metadata['custom_name'] = basename self.metadata['custom_mime_type'] = mime_type self.set_level_label() return
eb838e67153a1e314712a930f0fc94cd4cd94677 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/eb838e67153a1e314712a930f0fc94cd4cd94677/VisualMatchActivity.py
list = self.list
list = self.list[:]
def find_sprite(self, pos): list = self.list list.reverse() for spr in list: if spr.hit(pos): return spr return None
2bcb201f5793136addbe598bee33798cc39ca435 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/2bcb201f5793136addbe598bee33798cc39ca435/sprites.py
if 1==1:
try:
def load_score(self): if 1==1: f = file(os.path.join(os.path.abspath('.'), 'visualmatch.score'), "r") s = f.readlines() f.close self.vmw.low_score = [int(s[0].split(':')[1].strip()), int(s[1].split(':')[1].strip())] print "low score is: %s" % (self.vmw.low_score) else: self.vmw.low_score = [-1, -1]
c8b608536ab28a28101a655e16992e0c3ea5eb36 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/c8b608536ab28a28101a655e16992e0c3ea5eb36/visualmatch.py
else:
except:
def load_score(self): if 1==1: f = file(os.path.join(os.path.abspath('.'), 'visualmatch.score'), "r") s = f.readlines() f.close self.vmw.low_score = [int(s[0].split(':')[1].strip()), int(s[1].split(':')[1].strip())] print "low score is: %s" % (self.vmw.low_score) else: self.vmw.low_score = [-1, -1]
c8b608536ab28a28101a655e16992e0c3ea5eb36 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/c8b608536ab28a28101a655e16992e0c3ea5eb36/visualmatch.py
self._stroke_width = 1
self._stroke_width = 1.0
def __init__(self): self._scale = 1 self._stroke_width = 1 self._fill = RED_FILL self._stroke = RED_STROKE self._font = 'DejaVu'
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
self.set_stroke_width(2.0)
self._set_stroke_width(2.0)
def _svg_circle_of_dots(self, n, x, y): rtab = {5:9, 7:13, 11:17} r = rtab[n] ox = 0 oy = 32.5 da = pi * 2 / n a = 0 nx = ox + sin(a) * r ny = oy + cos(a) * r svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, ")\">\n") self.set_stroke_width(2.0) for i in range(n): svg_string += self._svg_circle(nx, ny, 3) a += da nx = ox + sin(a) * r ny = oy + cos(a) * r svg_string += "</g>\n" return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
self.set_stroke_width(2.0)
self._set_stroke_width(2.0)
def _svg_line_of_dots(self, n, x, y): cxtab = {5:37.5, 7:27.5, 11:7.5, 10:37.5, 14:27.5, 22:7.5, 15:37.5, 21:27.5, 33:7.5} svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, ")\">\n") cx = cxtab[n] self.set_stroke_width(2.0) for i in range(n): svg_string += self._svg_circle(cx, 5, 3) cx += 10 svg_string += "</g>\n" return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
self.set_stroke_width(2.0)
self._set_stroke_width(2.0)
def _svg_hash(self, n, x, y): cxtab = {5:42.5, 7:32.5, 11:22.5, 10:42.5, 14:32.5, 22:22.5, 15:42.5, 21:32.5, 33:22.5} cy = 5 x2 = cxtab[n] x1 = 7.5 + x2 svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, ")\">\n") self.set_stroke_width(2.0) for i in range(n): if (i + 1) % 5 == 0: svg_string += self._svg_line(x1-40, 7.5, x2, 7.5) else: svg_string += self._svg_line(x1, 0, x2, 15) x1 += 7.5 x2 += 7.5 svg_string += "</g>\n" return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
print "quipu: %d %d %d" % (n, x, y)
def _svg_quipu(self, n, x, y): print "quipu: %d %d %d" % (n, x, y) svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, ")\">\n") x2 = x self.set_stroke_width(2.0) svg_string += self._svg_line(x2-40, 7.5, x2+40, 7.5) x2 -= 20 x1 = x2 + 7.5 for i in range(n): svg_string += self._svg_line(x1, 0, x2, 15) x1 += 7.5 x2 += 7.5 svg_string += "</g>\n" return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
self.set_stroke_width(2.0)
self._set_stroke_width(2.0)
def _svg_quipu(self, n, x, y): print "quipu: %d %d %d" % (n, x, y) svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, ")\">\n") x2 = x self.set_stroke_width(2.0) svg_string += self._svg_line(x2-40, 7.5, x2+40, 7.5) x2 -= 20 x1 = x2 + 7.5 for i in range(n): svg_string += self._svg_line(x1, 0, x2, 15) x1 += 7.5 x2 += 7.5 svg_string += "</g>\n" return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, "\">\n") self.set_stroke_width(1.5) self.set_colors([self._stroke, "none"]) svg_string += self._svg_rect(25, 25, 2, 2, 0, 0) self.set_stroke_width(2) self.set_colors([self._stroke, self._stroke])
self._set_stroke_width(1.5) self._set_colors([self._stroke, "none"]) svg_string = self._svg_rect(25, 25, 2, 2, x, y) self._set_stroke_width(2) self._set_colors([self._stroke, self._stroke])
def _svg_die(self, n, x, y): svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, "\">\n") self.set_stroke_width(1.5) self.set_colors([self._stroke, "none"]) svg_string += self._svg_rect(25, 25, 2, 2, 0, 0) self.set_stroke_width(2) self.set_colors([self._stroke, self._stroke]) if n in [2, 3, 4, 5, 6]: svg_string += self._svg_circle(6, 6, 1.5) svg_string += self._svg_circle(19, 19, 1.5) if n in [1, 3, 5]: svg_string += self._svg_circle(12.5, 12.5, 1.5) if n in [4, 5, 6]: svg_string += self._svg_circle(19, 6, 1.5) svg_string += self._svg_circle(6, 19, 1.5) if n in [6]: svg_string += self._svg_circle(6, 12.5, 1.5) svg_string += self._svg_circle(19, 12.5, 1.5) svg_string += "</g>\n" return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
svg_string += self._svg_circle(6, 6, 1.5) svg_string += self._svg_circle(19, 19, 1.5)
svg_string += self._svg_circle(6 + x, 6 + y, 1.5) svg_string += self._svg_circle(19 + x, 19 + y, 1.5)
def _svg_die(self, n, x, y): svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, "\">\n") self.set_stroke_width(1.5) self.set_colors([self._stroke, "none"]) svg_string += self._svg_rect(25, 25, 2, 2, 0, 0) self.set_stroke_width(2) self.set_colors([self._stroke, self._stroke]) if n in [2, 3, 4, 5, 6]: svg_string += self._svg_circle(6, 6, 1.5) svg_string += self._svg_circle(19, 19, 1.5) if n in [1, 3, 5]: svg_string += self._svg_circle(12.5, 12.5, 1.5) if n in [4, 5, 6]: svg_string += self._svg_circle(19, 6, 1.5) svg_string += self._svg_circle(6, 19, 1.5) if n in [6]: svg_string += self._svg_circle(6, 12.5, 1.5) svg_string += self._svg_circle(19, 12.5, 1.5) svg_string += "</g>\n" return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
svg_string += self._svg_circle(12.5, 12.5, 1.5)
svg_string += self._svg_circle(12.5 + x, 12.5 + y, 1.5)
def _svg_die(self, n, x, y): svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, "\">\n") self.set_stroke_width(1.5) self.set_colors([self._stroke, "none"]) svg_string += self._svg_rect(25, 25, 2, 2, 0, 0) self.set_stroke_width(2) self.set_colors([self._stroke, self._stroke]) if n in [2, 3, 4, 5, 6]: svg_string += self._svg_circle(6, 6, 1.5) svg_string += self._svg_circle(19, 19, 1.5) if n in [1, 3, 5]: svg_string += self._svg_circle(12.5, 12.5, 1.5) if n in [4, 5, 6]: svg_string += self._svg_circle(19, 6, 1.5) svg_string += self._svg_circle(6, 19, 1.5) if n in [6]: svg_string += self._svg_circle(6, 12.5, 1.5) svg_string += self._svg_circle(19, 12.5, 1.5) svg_string += "</g>\n" return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
svg_string += self._svg_circle(19, 6, 1.5) svg_string += self._svg_circle(6, 19, 1.5)
svg_string += self._svg_circle(19 + x, 6 + y, 1.5) svg_string += self._svg_circle(6 + x, 19 + y, 1.5)
def _svg_die(self, n, x, y): svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, "\">\n") self.set_stroke_width(1.5) self.set_colors([self._stroke, "none"]) svg_string += self._svg_rect(25, 25, 2, 2, 0, 0) self.set_stroke_width(2) self.set_colors([self._stroke, self._stroke]) if n in [2, 3, 4, 5, 6]: svg_string += self._svg_circle(6, 6, 1.5) svg_string += self._svg_circle(19, 19, 1.5) if n in [1, 3, 5]: svg_string += self._svg_circle(12.5, 12.5, 1.5) if n in [4, 5, 6]: svg_string += self._svg_circle(19, 6, 1.5) svg_string += self._svg_circle(6, 19, 1.5) if n in [6]: svg_string += self._svg_circle(6, 12.5, 1.5) svg_string += self._svg_circle(19, 12.5, 1.5) svg_string += "</g>\n" return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
svg_string += self._svg_circle(6, 12.5, 1.5) svg_string += self._svg_circle(19, 12.5, 1.5) svg_string += "</g>\n"
svg_string += self._svg_circle(6 + x, 12.5 + y, 1.5) svg_string += self._svg_circle(19 + x, 12.5 + y, 1.5)
def _svg_die(self, n, x, y): svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, "\">\n") self.set_stroke_width(1.5) self.set_colors([self._stroke, "none"]) svg_string += self._svg_rect(25, 25, 2, 2, 0, 0) self.set_stroke_width(2) self.set_colors([self._stroke, self._stroke]) if n in [2, 3, 4, 5, 6]: svg_string += self._svg_circle(6, 6, 1.5) svg_string += self._svg_circle(19, 19, 1.5) if n in [1, 3, 5]: svg_string += self._svg_circle(12.5, 12.5, 1.5) if n in [4, 5, 6]: svg_string += self._svg_circle(19, 6, 1.5) svg_string += self._svg_circle(6, 19, 1.5) if n in [6]: svg_string += self._svg_circle(6, 12.5, 1.5) svg_string += self._svg_circle(19, 12.5, 1.5) svg_string += "</g>\n" return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
self.set_stroke_width(1.8)
self._set_stroke_width(1.8)
def _svg_star(self, n, x, y): turntable = {5:3, 7:3, 11:5} turns = turntable[n] x1 = 0 y1 = 0 a = 0 svg_string = "%s%f%s%f%s" % ("<g\n transform=\"translate(", x, ", ", y, ")\">\n") self.set_stroke_width(1.8) for i in range(n * turns): x2 = x1 + sin(a) * 40 y2 = y1 + cos(a) * 40 svg_string += self._svg_line(x1, y1, x2, y2) x1 = x2 y1 = y2 a += turns * 2 * pi / n svg_string += "</g>\n" return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
self.set_colors([stroke, WHITE])
self._set_colors([stroke, WHITE])
def _svg_donut(self, x, style, stroke, fill): svg_string = "" if style == "none": self.set_colors([stroke, WHITE]) elif style == "gradient": self.set_colors([stroke, fill]) else: self.set_colors([stroke, stroke]) svg_string += self._svg_circle(x + 17, 38, 16) self.set_colors([stroke, fill]) svg_string += self._svg_circle(x + 17, 38, 8) return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
self.set_colors([stroke, fill]) else: self.set_colors([stroke, stroke])
self._set_colors([stroke, fill]) else: self._set_colors([stroke, stroke])
def _svg_donut(self, x, style, stroke, fill): svg_string = "" if style == "none": self.set_colors([stroke, WHITE]) elif style == "gradient": self.set_colors([stroke, fill]) else: self.set_colors([stroke, stroke]) svg_string += self._svg_circle(x + 17, 38, 16) self.set_colors([stroke, fill]) svg_string += self._svg_circle(x + 17, 38, 8) return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
self.set_colors([stroke, fill])
self._set_colors([stroke, fill])
def _svg_donut(self, x, style, stroke, fill): svg_string = "" if style == "none": self.set_colors([stroke, WHITE]) elif style == "gradient": self.set_colors([stroke, fill]) else: self.set_colors([stroke, stroke]) svg_string += self._svg_circle(x + 17, 38, 16) self.set_colors([stroke, fill]) svg_string += self._svg_circle(x + 17, 38, 8) return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
self.set_stroke_width(1.8)
self._set_stroke_width(1.8)
def _svg_bar(self, x, y): self.set_stroke_width(1.8) svg_string = " <rect\n" svg_string += " width=\"%f\"\n" % (40) svg_string += " height=\"%f\"\n" % (5) svg_string += " x=\"%f\"\n" % (x) svg_string += " y=\"%f\"\n" % (y) svg_string += self._svg_style() return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
def header(self):
def _header(self):
def header(self): svg_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"" svg_string += " standalone=\"no\"?>\n" svg_string += "<!-- Created with Emacs -->\n" svg_string += "<svg\n" svg_string += " xmlns:svg=\"http://www.w3.org/2000/svg\"\n" svg_string += " xmlns=\"http://www.w3.org/2000/svg\"\n" svg_string += " version=\"1.0\"\n" svg_string += "%s%f%s" % (" width=\"", 125 * self._scale, "\"\n") svg_string += "%s%f%s" % (" height=\"", 75 * self._scale, "\">\n") svg_string += "%s%f%s%f%s" % ("<g\n transform=\"matrix(", self._scale, ", 0, 0, ", self._scale, ", 0, 0)\">\n") svg_string += self._background() return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
def footer(self):
def _footer(self):
def footer(self): svg_string = "</g>\n" svg_string += "</svg>\n" return svg_string
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
def set_font(self, font='DejaVu'):
def _set_font(self, font='DejaVu'):
def set_font(self, font='DejaVu'): self._font = font
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
def set_scale(self, scale=1.0):
def _set_scale(self, scale=1.0):
def set_scale(self, scale=1.0): self._scale = scale
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py
def set_colors(self, colors):
def _set_colors(self, colors):
def set_colors(self, colors): self._stroke = colors[0] self._fill = colors[1]
3abdde2d4415b99e072401aa95cc310d13046e05 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7609/3abdde2d4415b99e072401aa95cc310d13046e05/gencards.py