rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
self.move_pattern_button.connect("clicked", self.on_move_pattern)
self.move_pattern_button.connect("clicked", self.on_move_patterns)
def __init__(self, palabra_window): gtk.Dialog.__init__(self, u"Pattern file manager" , palabra_window, gtk.DIALOG_MODAL) self.palabra_window = palabra_window self.set_size_request(640, 512) self.preview = GridPreview() self.preview.set_size_request(200, 256) self.patterns = {} # display_string filename id_of_grid self.store = gtk.TreeStore(str, str, str) self.reset_pattern_list() self.tree = gtk.TreeView(self.store) self.tree.set_headers_visible(False) self.tree.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.tree.get_selection().connect("changed", self.on_selection_changed) cell = gtk.CellRendererText() column = gtk.TreeViewColumn() column.pack_start(cell, True) column.set_attributes(cell, text=0) self.tree.append_column(column) right_vbox = gtk.VBox(False, 6) label = gtk.Label() label.set_markup(u"<b>Options for pattern files</b>") align = gtk.Alignment(0, 0.5) align.add(label) right_vbox.pack_start(align, False, False, 0) add_button = gtk.Button(stock=gtk.STOCK_ADD) add_button.connect("clicked", lambda button: self.add_file()) align = add_button.get_children()[0] hbox = align.get_children()[0] image, label = hbox.get_children() label.set_text(u"Add pattern file"); right_vbox.pack_start(add_button, False, False, 0) self.remove_button = gtk.Button(stock=gtk.STOCK_REMOVE) self.remove_button.connect("clicked", lambda button: self.remove_file()) self.remove_button.set_sensitive(False) align = self.remove_button.get_children()[0] hbox = align.get_children()[0] image, label = hbox.get_children() label.set_text(u"Remove pattern file(s)"); right_vbox.pack_start(self.remove_button, False, False, 0)
636935098d8b4b54170d3699eb9b3fb53ae953fe /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/636935098d8b4b54170d3699eb9b3fb53ae953fe/pattern.py
def on_copy_pattern(self, button):
def on_copy_patterns(self, button):
def on_copy_pattern(self, button): """Copy the currently selected patterns to a specified file.""" patterns = self._gather_selected_patterns() path = self._get_pattern_file() self.append_to_file(path, patterns)
636935098d8b4b54170d3699eb9b3fb53ae953fe /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/636935098d8b4b54170d3699eb9b3fb53ae953fe/pattern.py
self.append_to_file(path, patterns) def on_move_pattern(self, button):
if path: self.append_to_file(path, patterns) def on_move_patterns(self, button):
def on_copy_pattern(self, button): """Copy the currently selected patterns to a specified file.""" patterns = self._gather_selected_patterns() path = self._get_pattern_file() self.append_to_file(path, patterns)
636935098d8b4b54170d3699eb9b3fb53ae953fe /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/636935098d8b4b54170d3699eb9b3fb53ae953fe/pattern.py
self.append_to_file(path, patterns) self.remove_from_files(patterns)
if path: self.append_to_file(path, patterns) self.remove_from_files(patterns)
def on_move_pattern(self, button): """Move the currently selected patterns to a specified file.""" patterns = self._gather_selected_patterns() path = self._get_pattern_file() self.append_to_file(path, patterns) self.remove_from_files(patterns)
636935098d8b4b54170d3699eb9b3fb53ae953fe /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/636935098d8b4b54170d3699eb9b3fb53ae953fe/pattern.py
for word in self.lengths[length]: if self._predicate(constraints, word): if more_constraints is not None: filled_constraints = [(l, cs + [(i, word[j])]) for j, (i, l, cs) in enumerate(more_constraints)] for args in filled_constraints: if not self.has_matches(*args): yield word, False break
if length in self.lengths.keys(): for word in self.lengths[length]: if self._predicate(constraints, word): if more_constraints is not None: filled_constraints = [(l, cs + [(i, word[j])]) for j, (i, l, cs) in enumerate(more_constraints)] for args in filled_constraints: if not self.has_matches(*args): yield word, False break else: yield word, True
def search(self, length, constraints, more_constraints=None): for word in self.lengths[length]: if self._predicate(constraints, word): if more_constraints is not None: filled_constraints = [(l, cs + [(i, word[j])]) for j, (i, l, cs) in enumerate(more_constraints)] for args in filled_constraints: if not self.has_matches(*args): yield word, False break else: yield word, True else: yield word, True
1b413e61bc1faa486503c945be62a0da8380d752 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/1b413e61bc1faa486503c945be62a0da8380d752/word.py
else: yield word, True
def search(self, length, constraints, more_constraints=None): for word in self.lengths[length]: if self._predicate(constraints, word): if more_constraints is not None: filled_constraints = [(l, cs + [(i, word[j])]) for j, (i, l, cs) in enumerate(more_constraints)] for args in filled_constraints: if not self.has_matches(*args): yield word, False break else: yield word, True else: yield word, True
1b413e61bc1faa486503c945be62a0da8380d752 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/1b413e61bc1faa486503c945be62a0da8380d752/word.py
patterns = self._gather_selected_patterns() self.remove_from_files(patterns)
def on_remove_patterns(self, button): """Remove the currently selected patterns from their respective files.""" image = gtk.Image() image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG) dialog = gtk.Dialog(u"Remove patterns" , self , gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_MODAL , (gtk.STOCK_NO, gtk.RESPONSE_NO , gtk.STOCK_YES, gtk.RESPONSE_YES)) dialog.set_default_response(gtk.RESPONSE_CLOSE) dialog.set_title(u"Remove patterns")
8be9d0da1ac9fc4fcbc698deb6d4979b64bf27e0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/8be9d0da1ac9fc4fcbc698deb6d4979b64bf27e0/pattern.py
def __init__(self, palabra_window, size=None):
def __init__(self, parent, size=None):
def __init__(self, palabra_window, size=None): gtk.Dialog.__init__(self, u"Pattern editor" , palabra_window, gtk.DIALOG_MODAL) self.palabra_window = palabra_window self.set_size_request(512, 384) self.size = size if size else (15, 15) all_vbox = gtk.VBox(False, 0) controls = gtk.HBox(False, 0) self.tile_starts = [(p, q) for p in xrange(2) for q in xrange(2)] tile_combo = gtk.combo_box_new_text() for x, y in self.tile_starts: content = str(''.join(["(", str(x + 1), ",", str(y + 1), ")" ])) tile_combo.append_text(content) tile_combo.connect("changed", self.on_tile_changed) controls.pack_start(gtk.Label(u"Tile from: "), False, False, 0) controls.pack_start(tile_combo, False, False, 0) all_vbox.pack_start(controls, False, False, 0) controls = gtk.HBox(False, 0) controls.pack_start(gtk.Label(u"Fill with: "), False, False, 0) fill_combo = gtk.combo_box_new_text() fill_combo.append_text(u"Block") fill_combo.append_text(u"Void") fill_combo.connect("changed", self.on_fill_changed) controls.pack_start(fill_combo, False, False, 0) all_vbox.pack_start(controls, False, False, 0) self.preview = GridPreview() self.preview.set_size_request(256, -1) self.display_pattern(None) hbox = gtk.HBox(False, 0) hbox.set_border_width(12) hbox.set_spacing(18) hbox.pack_start(all_vbox, True, True, 0) hbox.pack_start(self.preview, False, False, 0) self.vbox.pack_start(hbox, True, True, 0) self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
a96a4d42ce0df9334e6156d30b1b80371ccf8d9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/a96a4d42ce0df9334e6156d30b1b80371ccf8d9c/pattern.py
, palabra_window, gtk.DIALOG_MODAL) self.palabra_window = palabra_window
, parent, gtk.DIALOG_MODAL)
def __init__(self, palabra_window, size=None): gtk.Dialog.__init__(self, u"Pattern editor" , palabra_window, gtk.DIALOG_MODAL) self.palabra_window = palabra_window self.set_size_request(512, 384) self.size = size if size else (15, 15) all_vbox = gtk.VBox(False, 0) controls = gtk.HBox(False, 0) self.tile_starts = [(p, q) for p in xrange(2) for q in xrange(2)] tile_combo = gtk.combo_box_new_text() for x, y in self.tile_starts: content = str(''.join(["(", str(x + 1), ",", str(y + 1), ")" ])) tile_combo.append_text(content) tile_combo.connect("changed", self.on_tile_changed) controls.pack_start(gtk.Label(u"Tile from: "), False, False, 0) controls.pack_start(tile_combo, False, False, 0) all_vbox.pack_start(controls, False, False, 0) controls = gtk.HBox(False, 0) controls.pack_start(gtk.Label(u"Fill with: "), False, False, 0) fill_combo = gtk.combo_box_new_text() fill_combo.append_text(u"Block") fill_combo.append_text(u"Void") fill_combo.connect("changed", self.on_fill_changed) controls.pack_start(fill_combo, False, False, 0) all_vbox.pack_start(controls, False, False, 0) self.preview = GridPreview() self.preview.set_size_request(256, -1) self.display_pattern(None) hbox = gtk.HBox(False, 0) hbox.set_border_width(12) hbox.set_spacing(18) hbox.pack_start(all_vbox, True, True, 0) hbox.pack_start(self.preview, False, False, 0) self.vbox.pack_start(hbox, True, True, 0) self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL) self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
a96a4d42ce0df9334e6156d30b1b80371ccf8d9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/a96a4d42ce0df9334e6156d30b1b80371ccf8d9c/pattern.py
c = clue if len(clue) > 0 else "<span foreground=\"red\">No clue yet.</span>"
c = gobject.markup_escape_text(clue) if len(clue) > 0 else "<span foreground=\"red\">No clue yet.</span>"
def create_display_string(self, n, direction, word, clue): """Construct the displayed string for a word/clue item.""" c = clue if len(clue) > 0 else "<span foreground=\"red\">No clue yet.</span>" d = {"across": "Across", "down": "Down"}[direction] return ''.join(["<b>", d, ", ", str(n), "</b>:\n<i>", word, "</i>\n", c])
140d7a663d58df35320dbb98d39e966d2139724f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/140d7a663d58df35320dbb98d39e966d2139724f/clue.py
if not grid.is_available(x, y + 1):
if not grid.is_available(x, y + 1) or not grid.is_available(x, y):
def render(context, grid, props): context.set_line_width(props.line["width"]) lines = grid.lines_of_cell(x, y) for p, q, ltype, side in lines: sx = props.grid_to_screen_x(p, False) sy = props.grid_to_screen_y(q, False) bar = grid.is_valid(x, y) and grid.has_bar(x, y, ltype) border = "border" in side if ltype == "top": rx = sx if side == "normal": context.set_line_width(props.line["width"]) ry = sy - 0.5 * props.line["width"] rdx = props.cell["size"] elif border: context.set_line_width(props.border["width"]) if side == "outerborder": ry = sy - 0.5 * props.border["width"] elif side == "innerborder": ry = sy + 0.5 * props.border["width"] if not grid.is_available(x, y + 1): ry -= props.line["width"] rdx = props.cell["size"] # adjust horizontal lines to fill empty spaces in corners dxl, dxr, is_lb, is_rb = get_adjustments(lines, props, x, y) rx -= dxl rdx += dxl rdx += dxr render_line(context, props, rx, ry, rdx, 0, bar, border) if is_lb: rx -= props.border["width"] rdx = props.border["width"] render_line(context, props, rx, ry, rdx, 0, False, True) if is_rb: rx += (props.cell["size"] + dxl) rdx = props.border["width"] render_line(context, props, rx, ry, rdx, 0, False, True) elif ltype == "left": if side == "normal": context.set_line_width(props.line["width"]) rx = sx - 0.5 * props.line["width"] rdy = props.cell["size"] elif border: context.set_line_width(props.border["width"]) if side == "outerborder": rx = sx - 0.5 * props.border["width"] elif side == "innerborder": rx = sx + 0.5 * props.border["width"] if not grid.is_available(x + 1, y): rx -= props.line["width"] rdy = props.cell["size"] render_line(context, props, rx, sy, 0, rdy, bar, border)
84a71b822a6194babdd7c2968f0183673f59b1cc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/84a71b822a6194babdd7c2968f0183673f59b1cc/view.py
if not grid.is_available(x + 1, y):
if not grid.is_available(x + 1, y) or not grid.is_available(x, y):
def render(context, grid, props): context.set_line_width(props.line["width"]) lines = grid.lines_of_cell(x, y) for p, q, ltype, side in lines: sx = props.grid_to_screen_x(p, False) sy = props.grid_to_screen_y(q, False) bar = grid.is_valid(x, y) and grid.has_bar(x, y, ltype) border = "border" in side if ltype == "top": rx = sx if side == "normal": context.set_line_width(props.line["width"]) ry = sy - 0.5 * props.line["width"] rdx = props.cell["size"] elif border: context.set_line_width(props.border["width"]) if side == "outerborder": ry = sy - 0.5 * props.border["width"] elif side == "innerborder": ry = sy + 0.5 * props.border["width"] if not grid.is_available(x, y + 1): ry -= props.line["width"] rdx = props.cell["size"] # adjust horizontal lines to fill empty spaces in corners dxl, dxr, is_lb, is_rb = get_adjustments(lines, props, x, y) rx -= dxl rdx += dxl rdx += dxr render_line(context, props, rx, ry, rdx, 0, bar, border) if is_lb: rx -= props.border["width"] rdx = props.border["width"] render_line(context, props, rx, ry, rdx, 0, False, True) if is_rb: rx += (props.cell["size"] + dxl) rdx = props.border["width"] render_line(context, props, rx, ry, rdx, 0, False, True) elif ltype == "left": if side == "normal": context.set_line_width(props.line["width"]) rx = sx - 0.5 * props.line["width"] rdy = props.cell["size"] elif border: context.set_line_width(props.border["width"]) if side == "outerborder": rx = sx - 0.5 * props.border["width"] elif side == "innerborder": rx = sx + 0.5 * props.border["width"] if not grid.is_available(x + 1, y): rx -= props.line["width"] rdy = props.cell["size"] render_line(context, props, rx, sy, 0, rdy, bar, border)
84a71b822a6194babdd7c2968f0183673f59b1cc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/84a71b822a6194babdd7c2968f0183673f59b1cc/view.py
g, meta, data = read_pattern_file(path)
def add_file(self): dialog = gtk.FileChooserDialog(u"Add pattern file" , self , gtk.FILE_CHOOSER_ACTION_OPEN , (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL , gtk.STOCK_OPEN, gtk.RESPONSE_OK)) filter = gtk.FileFilter() filter.set_name(u"Palabra pattern files (*.xml)") filter.add_pattern("*.xml") dialog.add_filter(filter) dialog.show_all() response = dialog.run() path = dialog.get_filename() dialog.destroy() if response == gtk.RESPONSE_OK: for g, pattern in self.patterns.items(): if g == path: mdialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL , gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, u"This file is already in the list.") mdialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) mdialog.set_title("Duplicate file") mdialog.run() mdialog.destroy() break else: try: preferences.prefs["pattern_files"].append(path) g, meta, data = read_pattern_file(path) self.patterns[path] = {"metadata": meta, "data": data} self._append_file(path, self.patterns[path]) self.tree.columns_autosize() except InvalidFileError: # TODO pass
0ac1bcc3d8a1acbe5a3310487cd632472b2a3424 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/0ac1bcc3d8a1acbe5a3310487cd632472b2a3424/pattern.py
return props.line["width"]
return False, props.line["width"]
def get_delta(x, y, side_no_extend, side_extend): """ Determine the delta in pixels. The delta is at least the normal line width. """ if ((x, y, "left", side_no_extend) in lines or (x, y - 1, "left", side_no_extend) in lines): return props.line["width"] elems = [(x, y, "left", "normal"), (x, y - 1, "left", "normal")] if True in map(lambda e: e in lines, elems): return props.line["width"] elems = [(x, y, "left", side_extend), (x, y - 1, "left", side_extend)] if True in map(lambda e: e in lines, elems): return props.border["width"] return 0
6d1c5dd773e800ee5cc58815a12a3eb7a83dbbd4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/6d1c5dd773e800ee5cc58815a12a3eb7a83dbbd4/view.py
if True in map(lambda e: e in lines, elems): return props.line["width"]
if True in [e in lines for e in elems]: return False, props.line["width"]
def get_delta(x, y, side_no_extend, side_extend): """ Determine the delta in pixels. The delta is at least the normal line width. """ if ((x, y, "left", side_no_extend) in lines or (x, y - 1, "left", side_no_extend) in lines): return props.line["width"] elems = [(x, y, "left", "normal"), (x, y - 1, "left", "normal")] if True in map(lambda e: e in lines, elems): return props.line["width"] elems = [(x, y, "left", side_extend), (x, y - 1, "left", side_extend)] if True in map(lambda e: e in lines, elems): return props.border["width"] return 0
6d1c5dd773e800ee5cc58815a12a3eb7a83dbbd4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/6d1c5dd773e800ee5cc58815a12a3eb7a83dbbd4/view.py
if True in map(lambda e: e in lines, elems): return props.border["width"] return 0 dx_left = get_delta(x, y, "innerborder", "outerborder") dx_right = get_delta(x + 1, y, "outerborder", "innerborder") return (dx_left, dx_right)
if True in [e in lines for e in elems]: return True, 0 return False, 0 is_left_border, dx_left = get_delta(x, y, "innerborder", "outerborder") is_right_border, dx_right = get_delta(x + 1, y, "outerborder", "innerborder") return (dx_left, dx_right, is_left_border, is_right_border)
def get_delta(x, y, side_no_extend, side_extend): """ Determine the delta in pixels. The delta is at least the normal line width. """ if ((x, y, "left", side_no_extend) in lines or (x, y - 1, "left", side_no_extend) in lines): return props.line["width"] elems = [(x, y, "left", "normal"), (x, y - 1, "left", "normal")] if True in map(lambda e: e in lines, elems): return props.line["width"] elems = [(x, y, "left", side_extend), (x, y - 1, "left", side_extend)] if True in map(lambda e: e in lines, elems): return props.border["width"] return 0
6d1c5dd773e800ee5cc58815a12a3eb7a83dbbd4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/6d1c5dd773e800ee5cc58815a12a3eb7a83dbbd4/view.py
def render(context, grid, props): context.set_line_width(props.line["width"]) lines = grid.lines_of_cell(x, y) for p, q, ltype, side in lines: sx = props.grid_to_screen_x(p, False) sy = props.grid_to_screen_y(q, False) bar = grid.is_valid(x, y) and grid.has_bar(x, y, ltype) border = "border" in side if ltype == "top": rx = sx if side == "normal": context.set_line_width(props.line["width"]) ry = sy - 0.5 * props.line["width"] rdx = props.cell["size"] elif border: context.set_line_width(props.border["width"]) if side == "outerborder": ry = sy - 0.5 * props.border["width"] elif side == "innerborder": ry = sy + 0.5 * props.border["width"] if not grid.is_available(x, y + 1): ry -= props.line["width"] rdx = props.cell["size"] # adjust horizontal lines to fill empty spaces in corners dxl, dxr = get_adjustments(lines, props, x, y) rx -= dxl rdx += dxl rdx += dxr render_line(context, props, rx, ry, rdx, 0, bar, border) elif ltype == "left": if side == "normal": context.set_line_width(props.line["width"]) rx = sx - 0.5 * props.line["width"] rdy = props.cell["size"] elif border: context.set_line_width(props.border["width"]) if side == "outerborder": rx = sx - 0.5 * props.border["width"] elif side == "innerborder": rx = sx + 0.5 * props.border["width"] if not grid.is_available(x + 1, y): rx -= props.line["width"] rdy = props.cell["size"] render_line(context, props, rx, sy, 0, rdy, bar, border)
6d1c5dd773e800ee5cc58815a12a3eb7a83dbbd4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/6d1c5dd773e800ee5cc58815a12a3eb7a83dbbd4/view.py
dxl, dxr = get_adjustments(lines, props, x, y)
dxl, dxr, is_lb, is_rb = get_adjustments(lines, props, x, y)
def render(context, grid, props): context.set_line_width(props.line["width"]) lines = grid.lines_of_cell(x, y) for p, q, ltype, side in lines: sx = props.grid_to_screen_x(p, False) sy = props.grid_to_screen_y(q, False) bar = grid.is_valid(x, y) and grid.has_bar(x, y, ltype) border = "border" in side if ltype == "top": rx = sx if side == "normal": context.set_line_width(props.line["width"]) ry = sy - 0.5 * props.line["width"] rdx = props.cell["size"] elif border: context.set_line_width(props.border["width"]) if side == "outerborder": ry = sy - 0.5 * props.border["width"] elif side == "innerborder": ry = sy + 0.5 * props.border["width"] if not grid.is_available(x, y + 1): ry -= props.line["width"] rdx = props.cell["size"] # adjust horizontal lines to fill empty spaces in corners dxl, dxr = get_adjustments(lines, props, x, y) rx -= dxl rdx += dxl rdx += dxr render_line(context, props, rx, ry, rdx, 0, bar, border) elif ltype == "left": if side == "normal": context.set_line_width(props.line["width"]) rx = sx - 0.5 * props.line["width"] rdy = props.cell["size"] elif border: context.set_line_width(props.border["width"]) if side == "outerborder": rx = sx - 0.5 * props.border["width"] elif side == "innerborder": rx = sx + 0.5 * props.border["width"] if not grid.is_available(x + 1, y): rx -= props.line["width"] rdy = props.cell["size"] render_line(context, props, rx, sy, 0, rdy, bar, border)
6d1c5dd773e800ee5cc58815a12a3eb7a83dbbd4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/6d1c5dd773e800ee5cc58815a12a3eb7a83dbbd4/view.py
def render(context, grid, props): context.set_line_width(props.line["width"]) lines = grid.lines_of_cell(x, y) for p, q, ltype, side in lines: sx = props.grid_to_screen_x(p, False) sy = props.grid_to_screen_y(q, False) bar = grid.is_valid(x, y) and grid.has_bar(x, y, ltype) border = "border" in side if ltype == "top": rx = sx if side == "normal": context.set_line_width(props.line["width"]) ry = sy - 0.5 * props.line["width"] rdx = props.cell["size"] elif border: context.set_line_width(props.border["width"]) if side == "outerborder": ry = sy - 0.5 * props.border["width"] elif side == "innerborder": ry = sy + 0.5 * props.border["width"] if not grid.is_available(x, y + 1): ry -= props.line["width"] rdx = props.cell["size"] # adjust horizontal lines to fill empty spaces in corners dxl, dxr = get_adjustments(lines, props, x, y) rx -= dxl rdx += dxl rdx += dxr render_line(context, props, rx, ry, rdx, 0, bar, border) elif ltype == "left": if side == "normal": context.set_line_width(props.line["width"]) rx = sx - 0.5 * props.line["width"] rdy = props.cell["size"] elif border: context.set_line_width(props.border["width"]) if side == "outerborder": rx = sx - 0.5 * props.border["width"] elif side == "innerborder": rx = sx + 0.5 * props.border["width"] if not grid.is_available(x + 1, y): rx -= props.line["width"] rdy = props.cell["size"] render_line(context, props, rx, sy, 0, rdy, bar, border)
6d1c5dd773e800ee5cc58815a12a3eb7a83dbbd4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/6d1c5dd773e800ee5cc58815a12a3eb7a83dbbd4/view.py
if node[0] == self.view_length:
if self.view_length == 0: return None if node[0] == self.view_length - 1:
def on_iter_next(self, node): if node[0] == self.view_length: return None return (node[0] + 1,)
1bf90626c72ed3cd56469f8ae1c76f21c1e1a26f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/1bf90626c72ed3cd56469f8ae1c76f21c1e1a26f/wordstore.py
"""Iterate over all cells of a slot that contains (x, y) in an unspecified order.""" p = self.in_direction(x, y, direction)
""" Iterate over all cells of a slot that contains (x, y) in an unspecified order. This function also regards a slot of length 1 as a slot. """ dx = 1 if direction == "across" else 0 dy = 1 if direction == "down" else 0 p = self.in_direction(x + dx, y + dy, direction)
def slot(self, x, y, direction): """Iterate over all cells of a slot that contains (x, y) in an unspecified order.""" p = self.in_direction(x, y, direction) q = self.in_direction(x, y, direction, reverse=True) for r, s in chain(p, q): yield r, s
bfcc3ee431ac6a272d625b702181aedacc9a2741 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/bfcc3ee431ac6a272d625b702181aedacc9a2741/grid.py
main.set("Version", "1.0")
def write_xpf(puzzle, backup=True): root = etree.Element("Puzzles") main = etree.SubElement(root, "Puzzle") main.set("Version", "1.0") elems = [("type", "Type") , ("title", "Title") , ("creator", "Author") , ("contributor", "Editor") , ("publisher", "Publisher") , ("date", "Date")] for dc, e in elems: if dc in puzzle.metadata and puzzle.metadata[dc]: child = etree.SubElement(main, e) child.text = puzzle.metadata[dc] size = etree.SubElement(main, "Size") rows = etree.SubElement(size, "Rows") rows.text = str(puzzle.grid.height) cols = etree.SubElement(size, "Cols") cols.text = str(puzzle.grid.width) def calc_char(x, y): cell = puzzle.grid.cell(x, y) if cell["block"]: return '.' c = cell["char"] return c if c else ' ' egrid = etree.SubElement(main, "Grid") for y in xrange(puzzle.grid.height): erow = etree.SubElement(egrid, "Row") chars = [calc_char(x, y) for x in xrange(puzzle.grid.width)] erow.text = ''.join(chars) default = puzzle.view.properties.default styles = puzzle.view.properties.styles circles = [cell for cell in styles if styles[cell].circle != default.circle] if circles: circles.sort(key=itemgetter(0, 1)) ecircles = etree.SubElement(main, "Circles") for x, y in circles: ecircle = etree.SubElement(ecircles, "Circle") ecircle.set("Row", str(y + 1)) ecircle.set("Col", str(x + 1)) shades = [cell for cell in styles if styles[cell].cell["color"] != default.cell["color"]] if shades: shades.sort(key=itemgetter(0, 1)) eshades = etree.SubElement(main, "Shades") for x, y in shades: eshade = etree.SubElement(eshades, "Shade") eshade.set("Row", str(y + 1)) eshade.set("Col", str(x + 1)) def to_hex(value): hv = hex(int(value / 65535.0 * 255))[2:] return hv if len(hv) == 2 else '0' + hv text = '#' + ''.join([to_hex(v) for v in styles[x, y].cell["color"]]) eshade.text = text clues = etree.SubElement(main, "Clues") for n, x, y, d, word, clue, explanation in puzzle.grid.gather_words(): eclue = etree.SubElement(clues, "Clue") eclue.set("Row", str(y + 1)) eclue.set("Col", str(x + 1)) eclue.set("Num", str(n)) eclue.set("Dir", {"across": "Across", "down": "Down"}[d]) eclue.set("Ans", word) if clue: eclue.text = clue contents = etree.tostring(root, xml_declaration=True, encoding="UTF-8") _write_puzzle(puzzle.filename, contents, backup)
119498d6d978a04fe2a0999c0db1e37ff62a314b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/119498d6d978a04fe2a0999c0db1e37ff62a314b/files.py
r_grid.set_char(x + i, y, c)
r_grid.set_char(x + i, y, c if c != ' ' else '')
def read_xpf(filename): # TODO check validity coordinates results = [] try: doc = etree.parse(filename) except etree.XMLSyntaxError: raise XPFParserError(u"No valid XML syntax.") puzzles = doc.getroot() if puzzles.tag != "Puzzles": raise XPFParserError(u"No root element called Puzzles found.") for puzzle in puzzles: if puzzle.tag != "Puzzle": print "Warning: skipping a child of Puzzles that is not a Puzzle." continue r_meta = {} r_width = None r_height = None r_grid = None r_notepad = "" r_styles = {} for child in puzzle: if child.tag == "Title": r_meta["title"] = child.text elif child.tag == "Author": r_meta["creator"] = child.text elif child.tag == "Editor": r_meta["contributor"] = child.text elif child.tag == "Copyright": r_meta["rights"] = child.text elif child.tag == "Publisher": r_meta["publisher"] = child.text elif child.tag == "Date": r_meta["date"] = child.text elif child.tag == "Size": for d in child: if d.tag == "Rows": r_height = int(d.text) elif d.tag == "Cols": r_width = int(d.text) elif child.tag == "Grid": if r_width is None: raise XPFParserError(u"The number of columns was not specified.") if r_height is None: raise XPFParserError(u"The number of rows was not specified.") assert r_width >= 0 assert r_height >= 0 r_grid = Grid(r_width, r_height) x, y = 0, 0 for row in child: if row.tag != "Row": print "Warning: skipping a child of Grid that is not a Row." continue content = row.text for i, c in enumerate(content): if c == '.': r_grid.set_block(x + i, y, True) else: r_grid.set_char(x + i, y, c) y += 1 elif child.tag == "Circles": for circle in child: if circle.tag != "Circle": print "Warning: skipping a child of Circles that is not a Circle." continue a_row = circle.get("Row") a_col = circle.get("Col") if a_row is None: print "Warning: skipping a child of Circles without a Row." continue if a_col is None: print "Warning: skipping a child of Circles without a Col." continue x = int(a_col) - 1 y = int(a_row) - 1 if (x, y) not in r_styles: r_styles[x, y] = CellStyle() r_styles[x, y].circle = True elif child.tag == "RebusEntries": pass # TODO elif child.tag == "Shades": for shade in child: if shade.tag != "Shade": print "Warning: skipping a child of Shades that is not a Shade." continue a_row = shade.get("Row") a_col = shade.get("Col") if a_row is None: print "Warning: skipping a child of Shades without a Row." continue if a_col is None: print "Warning: skipping a child of Shades without a Col." continue x = int(a_col) - 1 y = int(a_row) - 1 if shade.text: if (x, y) not in r_styles: r_styles[x, y] = CellStyle() if shade.text[0] == '#': colorhex = shade.text[1:] split = (colorhex[0:2], colorhex[2:4], colorhex[4:6]) rgb = [int((int(d, 16) / 255.0) * 65535) for d in split] r_styles[x, y].cell["color"] = tuple(rgb) else: print "TODO", shade.text else: print "Warning: Skipping a child of Shades with no content." continue elif child.tag == "Clues": for clue in child: if clue.tag != "Clue": print "Warning: skipping a child of Clues that is not a Clue." continue a_row = clue.get("Row") a_col = clue.get("Col") a_num = clue.get("Num") a_dir = clue.get("Dir") a_ans = clue.get("Ans") if a_row is not None and a_col is not None and a_dir is not None: x = int(a_col) - 1 y = int(a_row) - 1 if a_dir == "Across": direction = "across" elif a_dir == "Down": direction = "down" else: print "Warning: skipping a clue with a direction that is not across or down." continue r_grid.store_clue(x, y, direction, "text", clue.text) elif child.tag == "Notepad": r_notepad = child.text # TODO modify when arbitrary number schemes are implemented r_grid.assign_numbers() p = Puzzle(r_grid, r_styles) p.metadata = r_meta p.type = constants.PUZZLE_XPF p.notepad = r_notepad results.append(p) return results
54c9ce111936ca9939fd620cd4a09ce6a2604d88 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/54c9ce111936ca9939fd620cd4a09ce6a2604d88/files.py
r_grid.store_clue(x, y, direction, "text", clue.text)
if clue.text: r_grid.store_clue(x, y, direction, "text", clue.text) else: print "Warning: skipping a clue that has no text." continue
def read_xpf(filename): # TODO check validity coordinates results = [] try: doc = etree.parse(filename) except etree.XMLSyntaxError: raise XPFParserError(u"No valid XML syntax.") puzzles = doc.getroot() if puzzles.tag != "Puzzles": raise XPFParserError(u"No root element called Puzzles found.") for puzzle in puzzles: if puzzle.tag != "Puzzle": print "Warning: skipping a child of Puzzles that is not a Puzzle." continue r_meta = {} r_width = None r_height = None r_grid = None r_notepad = "" r_styles = {} for child in puzzle: if child.tag == "Title": r_meta["title"] = child.text elif child.tag == "Author": r_meta["creator"] = child.text elif child.tag == "Editor": r_meta["contributor"] = child.text elif child.tag == "Copyright": r_meta["rights"] = child.text elif child.tag == "Publisher": r_meta["publisher"] = child.text elif child.tag == "Date": r_meta["date"] = child.text elif child.tag == "Size": for d in child: if d.tag == "Rows": r_height = int(d.text) elif d.tag == "Cols": r_width = int(d.text) elif child.tag == "Grid": if r_width is None: raise XPFParserError(u"The number of columns was not specified.") if r_height is None: raise XPFParserError(u"The number of rows was not specified.") assert r_width >= 0 assert r_height >= 0 r_grid = Grid(r_width, r_height) x, y = 0, 0 for row in child: if row.tag != "Row": print "Warning: skipping a child of Grid that is not a Row." continue content = row.text for i, c in enumerate(content): if c == '.': r_grid.set_block(x + i, y, True) else: r_grid.set_char(x + i, y, c) y += 1 elif child.tag == "Circles": for circle in child: if circle.tag != "Circle": print "Warning: skipping a child of Circles that is not a Circle." continue a_row = circle.get("Row") a_col = circle.get("Col") if a_row is None: print "Warning: skipping a child of Circles without a Row." continue if a_col is None: print "Warning: skipping a child of Circles without a Col." continue x = int(a_col) - 1 y = int(a_row) - 1 if (x, y) not in r_styles: r_styles[x, y] = CellStyle() r_styles[x, y].circle = True elif child.tag == "RebusEntries": pass # TODO elif child.tag == "Shades": for shade in child: if shade.tag != "Shade": print "Warning: skipping a child of Shades that is not a Shade." continue a_row = shade.get("Row") a_col = shade.get("Col") if a_row is None: print "Warning: skipping a child of Shades without a Row." continue if a_col is None: print "Warning: skipping a child of Shades without a Col." continue x = int(a_col) - 1 y = int(a_row) - 1 if shade.text: if (x, y) not in r_styles: r_styles[x, y] = CellStyle() if shade.text[0] == '#': colorhex = shade.text[1:] split = (colorhex[0:2], colorhex[2:4], colorhex[4:6]) rgb = [int((int(d, 16) / 255.0) * 65535) for d in split] r_styles[x, y].cell["color"] = tuple(rgb) else: print "TODO", shade.text else: print "Warning: Skipping a child of Shades with no content." continue elif child.tag == "Clues": for clue in child: if clue.tag != "Clue": print "Warning: skipping a child of Clues that is not a Clue." continue a_row = clue.get("Row") a_col = clue.get("Col") a_num = clue.get("Num") a_dir = clue.get("Dir") a_ans = clue.get("Ans") if a_row is not None and a_col is not None and a_dir is not None: x = int(a_col) - 1 y = int(a_row) - 1 if a_dir == "Across": direction = "across" elif a_dir == "Down": direction = "down" else: print "Warning: skipping a clue with a direction that is not across or down." continue r_grid.store_clue(x, y, direction, "text", clue.text) elif child.tag == "Notepad": r_notepad = child.text # TODO modify when arbitrary number schemes are implemented r_grid.assign_numbers() p = Puzzle(r_grid, r_styles) p.metadata = r_meta p.type = constants.PUZZLE_XPF p.notepad = r_notepad results.append(p) return results
54c9ce111936ca9939fd620cd4a09ce6a2604d88 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/54c9ce111936ca9939fd620cd4a09ce6a2604d88/files.py
cell = self._default_cell() self.data = [[copy.copy(cell) for x in xrange(width)] for y in xrange(height)]
self.data = [[self._default_cell() for x in xrange(width)] for y in xrange(height)]
def initialize(self, width, height): """Reset the grid to the given dimensions with all empty cells.""" self.width = width self.height = height self.lines = {} # code below is faster than calling _default_cell all the time cell = self._default_cell() self.data = [[copy.copy(cell) for x in xrange(width)] for y in xrange(height)] # TODO modify when arbitrary number schemes are implemented self.assign_numbers() #self.compute_lines()
e03e310ad8705600f978ab4a71d896a30cd81f31 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/e03e310ad8705600f978ab4a71d896a30cd81f31/grid.py
_write_grid(root, grid)
_write_crossword(root, Puzzle(grid))
def write_patterns(filename, patterns): root = etree.Element("palabra") root.set("version", constants.VERSION) for grid in patterns: _write_grid(root, grid) contents = etree.tostring(root, xml_declaration=True, encoding="UTF-8") f = open(filename, "w") f.write(contents) f.close()
5a4562d2811cb9aa4579fe7f3cadd1ebc5b22766 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/5a4562d2811cb9aa4579fe7f3cadd1ebc5b22766/files.py
word = "".join(map(lambda c: c.lower(), segment))
word = "".join([c.lower() if c else " " for c in segment])
def check_segment(direction, segment, cells): result = [] word = "".join(map(lambda c: c.lower(), segment)) badwords = self.palabra_window.blacklist.get_substring_matches(word) for i in xrange(len(word)): for b in badwords: if word[i:i + len(b)] == b: p, q = cells[i] result.append((p, q, direction, len(b))) return result
f8a8f11b30e692e064d185fdb3309f631899bc51 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/f8a8f11b30e692e064d185fdb3309f631899bc51/editor.py
self.add_word(node.children[c], word, offset + 1)
self._add_word(node.children[c], word, offset + 1)
def _add_word(self, node, word, offset): if offset >= len(word): node.words.append(word) return c = word[offset] if c not in node.children: node.children[c] = Node() self.add_word(node.children[c], word, offset + 1)
cac5afdfb6a3e92cee9f0b85fe64494c97895e8e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/cac5afdfb6a3e92cee9f0b85fe64494c97895e8e/word.py
def is_file(store, path): return store.iter_parent(store.get_iter(path)) is None
47f8ab87bfb42070bdc7b8cb0e80c78e31c73718 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/47f8ab87bfb42070bdc7b8cb0e80c78e31c73718/pattern.py
raise XPFParserError("uNo version specified for this XPF file. Possible older than v1.0?")
raise XPFParserError(u"No version specified for this XPF file. Possible older than v1.0?")
def read_xpf(filename): # TODO check validity coordinates results = [] try: doc = etree.parse(filename) except etree.XMLSyntaxError: raise XPFParserError(u"No valid XML syntax.") puzzles = doc.getroot() if puzzles.tag != "Puzzles": raise XPFParserError(u"No root element called Puzzles found.") version = puzzles.get("Version") if version is None: raise XPFParserError("uNo version specified for this XPF file. Possible older than v1.0?") try: version = float(version) except ValueError: raise XPFParserError("uXPF version is not a valid number") if version < 1.0: raise XPFParserError("uXPF versions older than 1.0 are not supported.") for puzzle in puzzles: if puzzle.tag != "Puzzle": print "Warning: skipping a child of Puzzles that is not a Puzzle." continue r_meta = {} r_width = None r_height = None r_grid = None r_notepad = "" r_styles = {} for child in puzzle: if child.tag == "Type": r_meta["type"] = child.text elif child.tag == "Title": r_meta["title"] = child.text elif child.tag == "Author": r_meta["creator"] = child.text elif child.tag == "Editor": r_meta["contributor"] = child.text elif child.tag == "Copyright": r_meta["rights"] = child.text elif child.tag == "Publisher": r_meta["publisher"] = child.text elif child.tag == "Date": r_meta["date"] = child.text elif child.tag == "Size": for d in child: if d.tag == "Rows": r_height = int(d.text) elif d.tag == "Cols": r_width = int(d.text) elif child.tag == "Grid": if r_width is None: raise XPFParserError(u"The number of columns was not specified.") if r_height is None: raise XPFParserError(u"The number of rows was not specified.") assert r_width >= 0 assert r_height >= 0 r_grid = Grid(r_width, r_height) x, y = 0, 0 for row in child: if row.tag != "Row": print "Warning: skipping a child of Grid that is not a Row." continue content = row.text for i, c in enumerate(content): if c == '.': r_grid.set_block(x + i, y, True) else: r_grid.set_char(x + i, y, c if c != ' ' else '') y += 1 elif child.tag == "Circles": for circle in child: if circle.tag != "Circle": print "Warning: skipping a child of Circles that is not a Circle." continue a_row = circle.get("Row") a_col = circle.get("Col") if a_row is None: print "Warning: skipping a child of Circles without a Row." continue if a_col is None: print "Warning: skipping a child of Circles without a Col." continue x = int(a_col) - 1 y = int(a_row) - 1 if (x, y) not in r_styles: r_styles[x, y] = CellStyle() r_styles[x, y].circle = True elif child.tag == "RebusEntries": for rebus in child: if rebus.tag != "Rebus": print "Warning: skipping a child of RebusEntries that is not a Rebus." continue a_row = rebus.get("Row") if a_row is None: print "Warning: skipping a child of RebusEntries without a Row." continue a_col = rebus.get("Col") if a_col is None: print "Warning: skipping a child of RebusEntries without a Col." continue a_short = rebus.get("Short") if a_short is None: print "Warning: skipping a child of RebusEntries without a Short." continue content = rebus.text if len(content) == 0: print "Warning: skipping a child of RebusEntries without content." continue x = int(a_col) - 1 y = int(a_row) - 1 print "TODO - rebus found:", x, y, a_short, content elif child.tag == "Shades": for shade in child: if shade.tag != "Shade": print "Warning: skipping a child of Shades that is not a Shade." continue a_row = shade.get("Row") a_col = shade.get("Col") if a_row is None: print "Warning: skipping a child of Shades without a Row." continue if a_col is None: print "Warning: skipping a child of Shades without a Col." continue x = int(a_col) - 1 y = int(a_row) - 1 if shade.text: if (x, y) not in r_styles: r_styles[x, y] = CellStyle() if shade.text == "gray": shade.text = "#808080" if shade.text[0] == '#': colorhex = shade.text[1:] split = (colorhex[0:2], colorhex[2:4], colorhex[4:6]) rgb = [int((int(d, 16) / 255.0) * 65535) for d in split] r_styles[x, y].cell["color"] = tuple(rgb) else: print "Warning: Skipping a child of Shades with no content." continue elif child.tag == "Clues": for clue in child: if clue.tag != "Clue": print "Warning: skipping a child of Clues that is not a Clue." continue a_row = clue.get("Row") a_col = clue.get("Col") a_num = clue.get("Num") a_dir = clue.get("Dir") a_ans = clue.get("Ans") if a_row is not None and a_col is not None and a_dir is not None: x = int(a_col) - 1 y = int(a_row) - 1 if a_dir == "Across": direction = "across" elif a_dir == "Down": direction = "down" else: print "Warning: skipping a clue with a direction that is not across or down." continue if clue.text: r_grid.store_clue(x, y, direction, "text", clue.text) elif child.tag == "Notepad": r_notepad = child.text # TODO modify when arbitrary number schemes are implemented r_grid.assign_numbers() p = Puzzle(r_grid, r_styles) p.metadata = r_meta p.type = constants.PUZZLE_XPF p.filename = filename p.notepad = r_notepad results.append(p) return results
99bde605b5fe31b10e22a4fddca3c3ef7773a6d0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/99bde605b5fe31b10e22a4fddca3c3ef7773a6d0/files.py
max_id = int(max(data.keys())) + 1
try: max_id = int(max(data.keys())) + 1 except ValueError: max_id = 1
def append_to_file(self, path, patterns): """Append all patterns to the specified file.""" try: g, meta, data = read_pattern_file(path) except InvalidFileError: # TODO return max_id = int(max(data.keys())) + 1 for f, keys in patterns.items(): for k in keys: data[str(max_id)] = self.patterns[f]["data"][k] max_id += 1 write_pattern_file(g, meta, data)
9cf384f7bec68d2d4bf694e7f57b06682a9a43e7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/9cf384f7bec68d2d4bf694e7f57b06682a9a43e7/pattern.py
data = [d for (f, _, d) in self.patterns if f in files] grids = reduce(operator.add, data) stats = [(g.count_words(), g.count_blocks(), g) for g in grids] stats.sort() self.current_patterns = [grid for (_, _, grid) in stats] self.load_empty_grid(*self.size_component.get_size())
if files: data = [d for (f, _, d) in self.patterns if f in files] grids = reduce(operator.add, data) stats = [(g.count_words(), g.count_blocks(), g) for g in grids] stats.sort() self.current_patterns = [grid for (_, _, grid) in stats] self.load_empty_grid(*self.size_component.get_size())
def on_file_changed(self, combo): index = combo.get_active() if index == 0: files = preferences.prefs["pattern_files"] else: files = preferences.prefs["pattern_files"][index - 1:index] data = [d for (f, _, d) in self.patterns if f in files] grids = reduce(operator.add, data) stats = [(g.count_words(), g.count_blocks(), g) for g in grids] stats.sort() self.current_patterns = [grid for (_, _, grid) in stats] self.load_empty_grid(*self.size_component.get_size())
624b0febd8cdd0a008f6f046d56fa62ce12a4b3e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/624b0febd8cdd0a008f6f046d56fa62ce12a4b3e/newpuzzle.py
if all([is_file(store, p) for p in paths]):
if paths and all([is_file(store, p) for p in paths]):
def is_file(store, path): return store.iter_parent(store.get_iter(path)) is None
ad7c12481cc468cfb54d486338b065f114cb7f85 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/ad7c12481cc468cfb54d486338b065f114cb7f85/pattern.py
self.set_full_selection(x, y, direction)
self._set_full_selection(x, y, direction)
def select(x, y, direction): """Select the word at (x, y, direction) in the grid.""" self.tools["clue"].settings["use_scrolling"] = False self.set_full_selection(x, y, direction) self.tools["clue"].settings["use_scrolling"] = True
a0e2580f817835eebfb69dab038a155847a764b4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/a0e2580f817835eebfb69dab038a155847a764b4/editor.py
self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
def __init__(self, palabra_window): gtk.Dialog.__init__(self, u"Pattern file manager" , palabra_window, gtk.DIALOG_MODAL) self.palabra_window = palabra_window self.set_size_request(640, 640) self.preview = GridPreview() self.preview.set_size_request(200, 250) self.patterns = {} for f in preferences.prefs["pattern_files"]: g, meta, data = read_pattern_file(f) self.patterns[f] = {"metadata": meta, "data": data} # display_string filename id_of_grid self.store = gtk.TreeStore(str, str, str) for item in self.patterns.items(): self._append_file(*item) self.tree = gtk.TreeView(self.store) self.tree.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.tree.get_selection().connect("changed", self.on_selection_changed) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(u"Pattern files") column.pack_start(cell, True) column.set_attributes(cell, text=0) self.tree.append_column(column) right_vbox = gtk.VBox(False, 6) label = gtk.Label() label.set_markup(u"<b>Pattern files</b>") align = gtk.Alignment(0, 0.5) align.add(label) right_vbox.pack_start(align, False, False, 0) add_button = gtk.Button(stock=gtk.STOCK_ADD) add_button.connect("clicked", lambda button: self.add_file()) align = add_button.get_children()[0] hbox = align.get_children()[0] image, label = hbox.get_children() label.set_text(u"Add pattern file"); right_vbox.pack_start(add_button, False, False, 0) self.remove_button = gtk.Button(stock=gtk.STOCK_REMOVE) self.remove_button.connect("clicked", lambda button: self.remove_file()) self.remove_button.set_sensitive(False) align = self.remove_button.get_children()[0] hbox = align.get_children()[0] image, label = hbox.get_children() label.set_text(u"Remove pattern file(s)"); right_vbox.pack_start(self.remove_button, False, False, 0)
ac4d684f2857957160465445d4d8e003d01c35e9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/ac4d684f2857957160465445d4d8e003d01c35e9/pattern.py
path = dialog.get_filename()
def add_file(self): dialog = gtk.FileChooserDialog(u"Add pattern file" , self , gtk.FILE_CHOOSER_ACTION_OPEN , (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL , gtk.STOCK_OPEN, gtk.RESPONSE_OK)) dialog.show_all() response = dialog.run() if response == gtk.RESPONSE_OK: path = dialog.get_filename() for g, pattern in self.patterns.items(): if g == path: dialog.destroy() mdialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL , gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, u"This file is already in the list.") mdialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) mdialog.set_title("Duplicate file") mdialog.run() mdialog.destroy() break else: dialog.destroy() preferences.prefs["pattern_files"].append(path) g, meta, data = read_pattern_file(path) self.patterns[path] = {"metadata": meta, "data": data} self._append_file(path, self.patterns[path]) self.tree.columns_autosize()
ac4d684f2857957160465445d4d8e003d01c35e9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/ac4d684f2857957160465445d4d8e003d01c35e9/pattern.py
dialog.destroy()
def add_file(self): dialog = gtk.FileChooserDialog(u"Add pattern file" , self , gtk.FILE_CHOOSER_ACTION_OPEN , (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL , gtk.STOCK_OPEN, gtk.RESPONSE_OK)) dialog.show_all() response = dialog.run() if response == gtk.RESPONSE_OK: path = dialog.get_filename() for g, pattern in self.patterns.items(): if g == path: dialog.destroy() mdialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL , gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, u"This file is already in the list.") mdialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) mdialog.set_title("Duplicate file") mdialog.run() mdialog.destroy() break else: dialog.destroy() preferences.prefs["pattern_files"].append(path) g, meta, data = read_pattern_file(path) self.patterns[path] = {"metadata": meta, "data": data} self._append_file(path, self.patterns[path]) self.tree.columns_autosize()
ac4d684f2857957160465445d4d8e003d01c35e9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/ac4d684f2857957160465445d4d8e003d01c35e9/pattern.py
dialog.destroy()
def add_file(self): dialog = gtk.FileChooserDialog(u"Add pattern file" , self , gtk.FILE_CHOOSER_ACTION_OPEN , (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL , gtk.STOCK_OPEN, gtk.RESPONSE_OK)) dialog.show_all() response = dialog.run() if response == gtk.RESPONSE_OK: path = dialog.get_filename() for g, pattern in self.patterns.items(): if g == path: dialog.destroy() mdialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL , gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, u"This file is already in the list.") mdialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) mdialog.set_title("Duplicate file") mdialog.run() mdialog.destroy() break else: dialog.destroy() preferences.prefs["pattern_files"].append(path) g, meta, data = read_pattern_file(path) self.patterns[path] = {"metadata": meta, "data": data} self._append_file(path, self.patterns[path]) self.tree.columns_autosize()
ac4d684f2857957160465445d4d8e003d01c35e9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/ac4d684f2857957160465445d4d8e003d01c35e9/pattern.py
def add_file(self): dialog = gtk.FileChooserDialog(u"Add pattern file" , self , gtk.FILE_CHOOSER_ACTION_OPEN , (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL , gtk.STOCK_OPEN, gtk.RESPONSE_OK)) dialog.show_all() response = dialog.run() if response == gtk.RESPONSE_OK: path = dialog.get_filename() for g, pattern in self.patterns.items(): if g == path: dialog.destroy() mdialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL , gtk.MESSAGE_INFO, gtk.BUTTONS_NONE, u"This file is already in the list.") mdialog.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE) mdialog.set_title("Duplicate file") mdialog.run() mdialog.destroy() break else: dialog.destroy() preferences.prefs["pattern_files"].append(path) g, meta, data = read_pattern_file(path) self.patterns[path] = {"metadata": meta, "data": data} self._append_file(path, self.patterns[path]) self.tree.columns_autosize()
ac4d684f2857957160465445d4d8e003d01c35e9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/ac4d684f2857957160465445d4d8e003d01c35e9/pattern.py
def export_to_png(puzzle, filename, output, settings): width = puzzle.view.properties.visual_width(False) height = puzzle.view.properties.visual_height(False) surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) context = cairo.Context(surface) context.rectangle(0, 0, width, height) r, g, b = puzzle.view.properties.cell["color"] context.set_source_rgb(r / 65535.0, g / 65535.0, b / 65535.0) context.fill() if output == "grid": puzzle.view.render(context, constants.VIEW_MODE_EMPTY) elif output == "solution": puzzle.view.render(context, constants.VIEW_MODE_SOLUTION) surface.write_to_png(filename) surface.finish()
f5af7ae822f9c43df2c17fc6d4bc77f68a5f5083 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/f5af7ae822f9c43df2c17fc6d4bc77f68a5f5083/files.py
def export_to_png(puzzle, filename, output, settings): width = puzzle.view.properties.visual_width(False) height = puzzle.view.properties.visual_height(False) surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) context = cairo.Context(surface) context.rectangle(0, 0, width, height) r, g, b = puzzle.view.properties.cell["color"] context.set_source_rgb(r / 65535.0, g / 65535.0, b / 65535.0) context.fill() if output == "grid": puzzle.view.render(context, constants.VIEW_MODE_EMPTY) elif output == "solution": puzzle.view.render(context, constants.VIEW_MODE_SOLUTION) surface.write_to_png(filename) surface.finish()
f5af7ae822f9c43df2c17fc6d4bc77f68a5f5083 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/f5af7ae822f9c43df2c17fc6d4bc77f68a5f5083/files.py
r, g, b = puzzle.view.properties.cell["color"] context.set_source_rgb(r / 65535.0, g / 65535.0, b / 65535.0) context.fill()
def export_to_png(puzzle, filename, output, settings): width = puzzle.view.properties.visual_width(False) height = puzzle.view.properties.visual_height(False) surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) context = cairo.Context(surface) context.rectangle(0, 0, width, height) r, g, b = puzzle.view.properties.cell["color"] context.set_source_rgb(r / 65535.0, g / 65535.0, b / 65535.0) context.fill() if output == "grid": puzzle.view.render(context, constants.VIEW_MODE_EMPTY) elif output == "solution": puzzle.view.render(context, constants.VIEW_MODE_SOLUTION) surface.write_to_png(filename) surface.finish()
f5af7ae822f9c43df2c17fc6d4bc77f68a5f5083 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/f5af7ae822f9c43df2c17fc6d4bc77f68a5f5083/files.py
def export_to_png(puzzle, filename, output, settings): width = puzzle.view.properties.visual_width(False) height = puzzle.view.properties.visual_height(False) surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) context = cairo.Context(surface) context.rectangle(0, 0, width, height) r, g, b = puzzle.view.properties.cell["color"] context.set_source_rgb(r / 65535.0, g / 65535.0, b / 65535.0) context.fill() if output == "grid": puzzle.view.render(context, constants.VIEW_MODE_EMPTY) elif output == "solution": puzzle.view.render(context, constants.VIEW_MODE_SOLUTION) surface.write_to_png(filename) surface.finish()
f5af7ae822f9c43df2c17fc6d4bc77f68a5f5083 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/f5af7ae822f9c43df2c17fc6d4bc77f68a5f5083/files.py
if transform >= constants.TRANSFORM_STRUCTURE: self.editor.puzzle.grid.assign_numbers() if transform >= constants.TRANSFORM_CONTENT: self.editor.refresh_clues()
if content_changed: if transform >= constants.TRANSFORM_STRUCTURE: self.editor.puzzle.grid.assign_numbers() if transform >= constants.TRANSFORM_CONTENT: self.editor.refresh_clues()
def update_window(self, content_changed=False, transform=constants.TRANSFORM_STRUCTURE): puzzle = self.puzzle_manager.current_puzzle if puzzle is None: self.set_title(u"Palabra") self.pop_status(constants.STATUS_GRID) else: status = puzzle.grid.determine_status(False) message = self.determine_status_message(status) self.update_status(constants.STATUS_GRID, message) selection = self.get_selection() if selection is not None: sel_x, sel_y = selection valid = puzzle.grid.is_valid(sel_x, sel_y) for item, predicate in self.selection_toggle_items: item.set_sensitive(valid and predicate(puzzle)) if valid and not puzzle.grid.is_available(sel_x, sel_y): self.set_selection(-1, -1) for item in self.puzzle_toggle_items: item.set_sensitive(puzzle is not None) self.update_undo_redo() try: if transform >= constants.TRANSFORM_STRUCTURE: # TODO modify when arbitrary number schemes are implemented self.editor.puzzle.grid.assign_numbers() if transform >= constants.TRANSFORM_CONTENT: self.editor.refresh_clues() self.editor.force_redraw = True self.editor.refresh_words() self.editor.refresh_visual_size() except AttributeError: pass self.panel.queue_draw()
2ec4abcc9f05c91a8e90118a89261cd0dd7cbd70 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/2ec4abcc9f05c91a8e90118a89261cd0dd7cbd70/gui.py
self.editor.settings["symmetries"] = options
try: self.editor.settings["symmetries"] = options except AttributeError: pass
def set_symmetry(options): self.editor.settings["symmetries"] = options
d135b3e2da397186e6f00bbb1ca7ab15b68ea1d9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6427/d135b3e2da397186e6f00bbb1ca7ab15b68ea1d9/gui.py
pasted_id = view.connect("paste-clipboard", self.on_paste) doc.set_data("AutoTabPluginHandlerIds", (loaded_id, saved_id, pasted_id))
doc.set_data("AutoTabPluginHandlerIds", (loaded_id, saved_id))
def connect_handlers(self, view): doc = view.get_buffer() # Using connect_after() because we want other plugins to do their # thing first. loaded_id = doc.connect_after("loaded", self.auto_tab, view) saved_id = doc.connect_after("saved", self.auto_tab, view) pasted_id = view.connect("paste-clipboard", self.on_paste) doc.set_data("AutoTabPluginHandlerIds", (loaded_id, saved_id, pasted_id))
2911cc9f04b21f90c99ed91bdcc4be7f5f55ebca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/2911cc9f04b21f90c99ed91bdcc4be7f5f55ebca/autotab.py
loaded_id, saved_id, pasted_id = doc.get_data("AutoTabPluginHandlerIds")
loaded_id, saved_id = doc.get_data("AutoTabPluginHandlerIds")
def disconnect_handlers(self, view): doc = view.get_buffer() loaded_id, saved_id, pasted_id = doc.get_data("AutoTabPluginHandlerIds") doc.disconnect(loaded_id) doc.disconnect(saved_id) view.disconnect(pasted_id) doc.set_data("AutoTabPluginHandlerIds", None)
2911cc9f04b21f90c99ed91bdcc4be7f5f55ebca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/2911cc9f04b21f90c99ed91bdcc4be7f5f55ebca/autotab.py
view.disconnect(pasted_id)
def disconnect_handlers(self, view): doc = view.get_buffer() loaded_id, saved_id, pasted_id = doc.get_data("AutoTabPluginHandlerIds") doc.disconnect(loaded_id) doc.disconnect(saved_id) view.disconnect(pasted_id) doc.set_data("AutoTabPluginHandlerIds", None)
2911cc9f04b21f90c99ed91bdcc4be7f5f55ebca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/2911cc9f04b21f90c99ed91bdcc4be7f5f55ebca/autotab.py
for i in (2, 3, 4, 8): if last_indent + i == indent: last_indent_spaces = i indent_count[i] += 1; last_indent = indent break
indent_diff = abs(indent - last_indent) if indent_diff in (2, 3, 4, 8): last_indent_spaces = indent_diff indent_count[indent_diff] += 1; last_indent = indent
def auto_tab(self, doc, error, view): if error is not None: pass
2911cc9f04b21f90c99ed91bdcc4be7f5f55ebca /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/2911cc9f04b21f90c99ed91bdcc4be7f5f55ebca/autotab.py
def activate(self, window): self.window = window self.spaces_instead_of_tabs = False self.tabs_width = 2 # Prime the statusbar self.statusbar = window.get_statusbar() self.context_id = self.statusbar.get_context_id("AutoTab") self.message_id = None
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
def activate(self, window): self.window = window self.spaces_instead_of_tabs = False self.tabs_width = 2 # Prime the statusbar self.statusbar = window.get_statusbar() self.context_id = self.statusbar.get_context_id("AutoTab") self.message_id = None
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
client = gconf.client_get_default()
client = gconf.client_get_default() if client.__class__.__name__ == 'FakeGConfClient': client.set_defaults(window)
def activate(self, window): self.window = window self.spaces_instead_of_tabs = False self.tabs_width = 2 # Prime the statusbar self.statusbar = window.get_statusbar() self.context_id = self.statusbar.get_context_id("AutoTab") self.message_id = None
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
def disconnect_handlers(self, view): doc = view.get_buffer() loaded_id, saved_id = doc.get_data("AutoTabPluginHandlerIds") doc.disconnect(loaded_id) doc.disconnect(saved_id) doc.set_data("AutoTabPluginHandlerIds", None)
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
def new_tabs_size(self, client, id=None, entry=None, data=None): self.tabs_width = client.get_int("/apps/gedit-2/preferences/editor/tabs/tabs_size") self.update_tabs(self.tabs_width, self.spaces_instead_of_tabs)
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
def update_tabs(self, size, space): view = self.window.get_active_view() if view: view.set_tab_width(size) view.set_insert_spaces_instead_of_tabs(space) self.update_status()
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
def auto_tab(self, doc, error, view): if error is not None: pass
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
def auto_tab(self, doc, error, view): if error is not None: pass
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
def auto_tab(self, doc, error, view): if error is not None: pass
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
def auto_tab(self, doc, error, view): if error is not None: pass
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
def auto_tab(self, doc, error, view): if error is not None: pass
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
def auto_tab(self, doc, error, view): if error is not None: pass
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
def auto_tab(self, doc, error, view): if error is not None: pass
1bf5ae6197182b30af795bc41d5eb7a0f40dd192 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/1bf5ae6197182b30af795bc41d5eb7a0f40dd192/autotab.py
self.statusbar.remove(self.context_id, self.message_id)
self.statusbar.remove_message(self.context_id, self.message_id)
def deactivate(self, window): tab_added_id = window.get_data("AutoTabPluginHandlerId") window.disconnect(tab_added_id) window.set_data("AutoTabPluginHandlerId", None)
7dce8eb4b527c38e661df849594480c6c6374bc7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/7dce8eb4b527c38e661df849594480c6c6374bc7/autotab.py
self.statusbar.remove(self.context_id, self.message_id)
self.statusbar.remove_message(self.context_id, self.message_id)
def update_status(self): view = self.window.get_active_view() if view: space = view.get_insert_spaces_instead_of_tabs() size = view.get_tab_width() if space: message = "%i Spaces" % size else: message = "Tabs" if self.message_id: self.statusbar.remove(self.context_id, self.message_id) self.message_id = self.statusbar.push(self.context_id, "Indentation: %s" % message)
7dce8eb4b527c38e661df849594480c6c6374bc7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/6065/7dce8eb4b527c38e661df849594480c6c6374bc7/autotab.py
for status in self.render_flow:
for status in self.render_flow(data):
def render(self, data): """render the OpenDocument with the user data
60c88c66c0c5b68dd8b5ddb687d1d178d01dac01 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/5612/60c88c66c0c5b68dd8b5ddb687d1d178d01dac01/main.py
self.vpan.set_position(275)
tmp = 0 w, h = self.window.get_size() self.vpan.set_position(h) tmp = self.vpan.get_position() print tmp self.vpan.set_position(int((275.0/450)*h))
def tree_select_changed(self, widget=None, event=None): model, iter = self.selection.get_selected() value = model.get_value(iter,0) #print value if value not in list_groups(): self.vpan.set_position(275) else: self.vpan.set_position(10000) detail = get_details(value) buff = self.output_txtview.get_buffer() buff.set_text(detail) self.output_txtview.set_buffer(buff)
b35ac0bc384cf082ae603d692369925f2c13cf46 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/b35ac0bc384cf082ae603d692369925f2c13cf46/wordgroupz.py
self.get_group.append_text(grp)
tmp = list_groups() n = len(tmp) print n print self.get_group.get_text_column() for i in range(0,n): self.get_group.remove_text(0) for x in tmp: self.get_group.append_text(x)
def refresh_groups(self, grp): self.get_group.append_text(grp)
b35ac0bc384cf082ae603d692369925f2c13cf46 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/b35ac0bc384cf082ae603d692369925f2c13cf46/wordgroupz.py
gtk.main_quit()
self.dialog.destroy()
def on_window_destroy(self, widget=None, event=None): gtk.main_quit()
f61255c6748e87eca1f28b2940e88463d2a03da4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/f61255c6748e87eca1f28b2940e88463d2a03da4/games.py
self.dialog.destroy()
self.dialog.hide()
def on_dialog_proceed_clicked(self, widget=None, event=None): self.no_of_ques = self.count_ self.dialog.destroy() self.set_up_mcq() self.builder.get_object('window3').show()
f61255c6748e87eca1f28b2940e88463d2a03da4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/f61255c6748e87eca1f28b2940e88463d2a03da4/games.py
gtk.main_quit()
def on_dialog_destroy(self, widget=None, event=None): self.dialog.destroy() #gtk.main_quit()
f61255c6748e87eca1f28b2940e88463d2a03da4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/f61255c6748e87eca1f28b2940e88463d2a03da4/games.py
self.tree_value = self.model.get_value(self.iter,0) if self.tree_value not in wordz_db.list_groups(): self.hbox3.show() w, h = self.window.get_size() self.vpan.set_position(h) tmp = self.vpan.get_position() self.vpan.set_position(int((255.0/450)*h)) else: self.vpan.set_position(10000) self.hbox3.hide() if self.output_txtview.get_editable(): self.output_txtview.set_editable(False) detail = wordz_db.get_details(self.tree_value) buff = self.output_txtview.get_buffer() buff.set_text(detail) self.output_txtview.set_buffer(buff)
if self.iter is not None: self.tree_value = self.model.get_value(self.iter,0) if self.tree_value not in wordz_db.list_groups(): self.hbox3.show() w, h = self.window.get_size() self.vpan.set_position(h) tmp = self.vpan.get_position() self.vpan.set_position(int((255.0/450)*h)) else: self.vpan.set_position(10000) self.hbox3.hide() if self.output_txtview.get_editable(): self.output_txtview.set_editable(False) detail = wordz_db.get_details(self.tree_value) buff = self.output_txtview.get_buffer() buff.set_text(detail) self.output_txtview.set_buffer(buff)
def tree_select_changed(self, widget=None, event=None): self.model, self.iter = self.selection.get_selected() self.tree_value = self.model.get_value(self.iter,0)
79df1b95932d9086a110c25fd81489f7f454a083 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/79df1b95932d9086a110c25fd81489f7f454a083/wordgroupz.py
self.search.connect('changed',self.on_search_changed)
self.search.connect('changed',self.on_search_changed)
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.details = self.builder.get_object("textview1") 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 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)
e940197cbd5bd83a44f5fd387df2bfd0ff7d8037 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/e940197cbd5bd83a44f5fd387df2bfd0ff7d8037/wordgroupz.py
print s
def get_def(self, word): l = self.match(word, db='!', strat='exact') for db, word in l: defs = self.definition(word, db=db) if defs == []: print >> sys.stderr, 'no-match' return 2 db, dbdescr, defstr = defs[0] s = '\n\n\n'.join([defstr for _, _, defstr in defs]) print s return s
9a1c110e26ca2c1de615e4d844f3eb2b1058bb80 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/9a1c110e26ca2c1de615e4d844f3eb2b1058bb80/wordgroupz_new.py
""" self.chose_dict_hbox = self.builder.get_object('hbox6')
self.chose_dict_hbox = self.builder.get_object('hbox7') vseparator = gtk.VSeparator() vseparator.show() self.chose_dict_hbox.pack_start(vseparator, False, padding=5) label = gtk.Label('Dictionary') label.show() self.chose_dict_hbox.pack_start(label, False)
def __init__(self): self.builder = gtk.Builder() self.builder.add_from_file("wordgroupz_new.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.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)
9a1c110e26ca2c1de615e4d844f3eb2b1058bb80 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/9a1c110e26ca2c1de615e4d844f3eb2b1058bb80/wordgroupz_new.py
self.chose_dict_hbox.pack_start(self.chose_dict, True, True, padding = 5) """
self.chose_dict_hbox.pack_start(self.chose_dict, False, True, padding = 5)
def __init__(self): self.builder = gtk.Builder() self.builder.add_from_file("wordgroupz_new.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.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)
9a1c110e26ca2c1de615e4d844f3eb2b1058bb80 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/9a1c110e26ca2c1de615e4d844f3eb2b1058bb80/wordgroupz_new.py
def __init__(self): self.builder = gtk.Builder() self.builder.add_from_file("wordgroupz_new.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.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)
9a1c110e26ca2c1de615e4d844f3eb2b1058bb80 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/9a1c110e26ca2c1de615e4d844f3eb2b1058bb80/wordgroupz_new.py
print filepath
def on_speak_clicked(self, widget=None, event=None): filepath = audio_file_path+'/'+self.tree_value+'.ogg' print filepath if os.path.isfile(filepath): self.player.set_property("uri", "file://" + filepath) self.player.set_state(gst.STATE_PLAYING) else: self.player.set_state(gst.STATE_NULL)
9a1c110e26ca2c1de615e4d844f3eb2b1058bb80 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/9a1c110e26ca2c1de615e4d844f3eb2b1058bb80/wordgroupz_new.py
print self.audio_file
def look_for_audio(self): page = self.browser.get_html() #print page soup = BeautifulSoup('<html>'+str(page)+'</html>') div = soup.html.body.findAll('div', attrs={'id':'ogg_player_1'}) if div is None: print "No audio available" else: l = str(div).split(',') for i in l: if i.find('videoUrl')>0: self.download_url = i.split(': ')[1].strip('"') #print self.download_url self.wiki_word = str(soup.html.title).split(' ')[0].split('>')[1] self.save_audio.set_sensitive(True) self.audio_file = self.wiki_word+'.ogg' print self.audio_file
9a1c110e26ca2c1de615e4d844f3eb2b1058bb80 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/9a1c110e26ca2c1de615e4d844f3eb2b1058bb80/wordgroupz_new.py
print 'page switched' print page_num
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.tree_value 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) elif page_num == 0: self.window.resize(min(width, 700), min(height, 550))
9a1c110e26ca2c1de615e4d844f3eb2b1058bb80 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/9a1c110e26ca2c1de615e4d844f3eb2b1058bb80/wordgroupz_new.py
print self.tree_value, self.wiki_word, self.browser_load_status
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.tree_value 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) elif page_num == 0: self.window.resize(min(width, 700), min(height, 550))
9a1c110e26ca2c1de615e4d844f3eb2b1058bb80 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/9a1c110e26ca2c1de615e4d844f3eb2b1058bb80/wordgroupz_new.py
print self.tree_value
def tree_select_changed(self, widget=None, event=None): self.model, self.iter = self.selection.get_selected() if self.iter is not None: if self.welcome is self.hbox2.get_children()[1]: self.hbox2.remove(self.welcome) self.hbox2.pack_start(self.vbox7) self.tree_value = self.model.get_value(self.iter,0) self.notebook1 = self.builder.get_object('notebook1') cur_page = self.notebook1.get_current_page() if cur_page is 1: self.url = ('http://en.wiktionary.org/wiki/'+self.tree_value) self.browser.open(self.url) #self.get_audio()
9a1c110e26ca2c1de615e4d844f3eb2b1058bb80 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/9a1c110e26ca2c1de615e4d844f3eb2b1058bb80/wordgroupz_new.py
print dic
def on_get_details1_clicked(self, widget, data=None): word = self.tree_value dic = self.chose_dict.get_active_text() print dic if dic == 'online webster': d = online_dict() defs = d.get_def(word) defs = '\n' + '='*10 + '\n' + "\nfrom online webster:\n" + defs elif dic == 'offline wordnet': defs = '\n' + '='*10 + '\n' + wordnet.get_definition(word) buff = self.output_txtview.get_buffer() end = buff.get_iter_at_offset(-1) buff.place_cursor(end) buff.insert_interactive_at_cursor(defs, True)
9a1c110e26ca2c1de615e4d844f3eb2b1058bb80 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/9a1c110e26ca2c1de615e4d844f3eb2b1058bb80/wordgroupz_new.py
if not 'groups' in tables: c.execute('''create table groups (grp text)''')
def db_init(self): if not os.path.exists(wordgroupz_dir): os.mkdir(wordgroupz_dir, 0755) conn = sqlite3.connect(db_file_path) c = conn.cursor() tables = [] for x in c.execute('''select name from sqlite_master'''): tables.append(x[0]) if not 'word_groups' in tables: c.execute('''create table word_groups (word text, grp text, details text)''') #if not 'groups' in tables: # c.execute('''create table groups # (grp text)''') conn.commit() c.close() conn.close()
eba433485830e647ddd80b79d3570b93a29200f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/eba433485830e647ddd80b79d3570b93a29200f4/wordgroupz_new.py
def delete_group(self, tree_value): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (tree_value,) c.execute("""delete from groups where grp=?""",t) conn.commit() c.close()
def list_groups(self): conn = sqlite3.connect(db_file_path) c = conn.cursor() groups = [] for row in c.execute("""select grp from groups order by grp"""): if row[0] is not u'': groups.append(row[0]) c.close() return groups
eba433485830e647ddd80b79d3570b93a29200f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/eba433485830e647ddd80b79d3570b93a29200f4/wordgroupz_new.py
self.audio_file = str(soup.html.title).split(' ')[0].strip('<title>')+'.ogg'
self.audio_file = str(soup.html.title).split(' ')[0].split('>')[1]+'.ogg' print self.audio_file
def look_for_audio(self): page = self.browser.get_html() #print page soup = BeautifulSoup('<html>'+str(page)+'</html>') div = soup.html.body.findAll('div', attrs={'id':'ogg_player_1'}) if div is None: print "No audio available" else: l = str(div).split(',') for i in l: if i.find('videoUrl')>0: self.download_url = i.split(': ')[1].strip('"') print self.download_url self.save_audio.set_sensitive(True) self.audio_file = str(soup.html.title).split(' ')[0].strip('<title>')+'.ogg'
eba433485830e647ddd80b79d3570b93a29200f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/eba433485830e647ddd80b79d3570b93a29200f4/wordgroupz_new.py
wordz_db.delete_word(self.tree_value)
if self.tree_value in wordz_db.list_groups(): wordz_db.delete_group(self.tree_value) else: wordz_db.delete_word(self.tree_value)
def on_delete_clicked(self, widget=None, event=None): wordz_db.delete_word(self.tree_value) self.treestore.remove(self.iter)
eba433485830e647ddd80b79d3570b93a29200f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/eba433485830e647ddd80b79d3570b93a29200f4/wordgroupz_new.py
def refresh_groups(self, grp):
def refresh_groups(self, grp, flag=0):
def refresh_groups(self, grp): tmp = wordz_db.list_groups() n = len(tmp) for i in range(0,n): self.get_group.remove_text(0) for x in tmp: self.get_group.append_text(x)
eba433485830e647ddd80b79d3570b93a29200f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/eba433485830e647ddd80b79d3570b93a29200f4/wordgroupz_new.py
for i in range(0,n):
for i in range(0,n+flag):
def refresh_groups(self, grp): tmp = wordz_db.list_groups() n = len(tmp) for i in range(0,n): self.get_group.remove_text(0) for x in tmp: self.get_group.append_text(x)
eba433485830e647ddd80b79d3570b93a29200f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/eba433485830e647ddd80b79d3570b93a29200f4/wordgroupz_new.py
if row[0] is not 'dummy':
if row[0] is not u'':
def list_groups(): conn = sqlite3.connect(db_file_path) c = conn.cursor() groups = [] for row in c.execute("""select grp from groups order by grp"""): if row[0] is not 'dummy': groups.append(row[0]) c.close() return groups
eb9268c56074e60c9baf0d8e0bb92c6db50dd879 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/eb9268c56074e60c9baf0d8e0bb92c6db50dd879/wordgroupz.py
if word is not '':
if word is not '' and word not in list_words_per_group(grp):
def add_to_db(word, grp): conn = sqlite3.connect(db_file_path) c = conn.cursor() t = (grp,) if grp not in list_groups(): c.execute("""insert into groups values (?)""",t) conn.commit() if word is not '': t = (word, grp) c.execute('''insert into word_groups values(?,?)''', t) conn.commit() c.close()
eb9268c56074e60c9baf0d8e0bb92c6db50dd879 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/eb9268c56074e60c9baf0d8e0bb92c6db50dd879/wordgroupz.py
elif i[1] != '0:0' and i[1] in self.new_word:
elif i[0] != '0:0' and i[1] 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' and word not in self.new_word: self.new_word.append(word) elif i[1] != '0:0' and i[1] in self.new_word: self.new_word.remove(i[0]) if word in self.new_word: renderer.set_property('text', 'New') else: renderer.set_property('text', None)
b2b7934db4fa58c0e3bf062cefdddcfb0660a1fb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/b2b7934db4fa58c0e3bf062cefdddcfb0660a1fb/wordgroupz.py
print self.new_word
def on_add_clicked(self, widget, data=None): word = self.get_word.get_text() get_group_ch = self.get_group.child group = get_group_ch.get_text() conts = self.details.get_buffer() start = conts.get_iter_at_offset(0) end = conts.get_iter_at_offset(-1) detail = conts.get_text(start, end) wordz_db.add_to_db(word, group, detail) self.refresh_groups(group) self.treestore.clear() self.new_word.append(word) if word not in self.new_word: self.new_word.append(word) print self.new_word self.on_back_clicked()
b2b7934db4fa58c0e3bf062cefdddcfb0660a1fb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/b2b7934db4fa58c0e3bf062cefdddcfb0660a1fb/wordgroupz.py
self.delete_b = self.builder.get_object('delete') self.play_b = self.builder.get_object('speak')
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)
f1eb60aee989dcf191e25d63123e58bea48e79be /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/f1eb60aee989dcf191e25d63123e58bea48e79be/wordgroupz.py
self.show_details_tree()
self.show_details_tree()
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.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>')
f1eb60aee989dcf191e25d63123e58bea48e79be /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/f1eb60aee989dcf191e25d63123e58bea48e79be/wordgroupz.py
piter = self.treestore.append(None, [i])
piter = self.treestore.append(None, [i, self.acc_dict[i]])
def on_search_changed(self,widget=None,event=None): search_txt = self.search.get_text() words = list self.treestore.clear() if search_txt == '': self.on_back_clicked() return for group in wordz_db.list_groups(): for i in wordz_db.list_words_per_group(group): if i.startswith(search_txt): piter = self.treestore.append(None, [i]) #for word in wordz_db.list_words_per_group(group): # self.treestore.append(piter, [word])
f1eb60aee989dcf191e25d63123e58bea48e79be /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/f1eb60aee989dcf191e25d63123e58bea48e79be/wordgroupz.py
self.delete_b = self.builder.get_object('delete') self.play_b = self.builder.get_object('speak')
def tree_select_changed(self, widget=None, event=None): self.model, self.iter = self.selection.get_selected() self.frame2.show() if self.iter is not None: self.delete_b = self.builder.get_object('delete') self.play_b = self.builder.get_object('speak') self.delete_b.set_sensitive(True) self.play_b.set_sensitive(True) if self.welcome is self.hbox2.get_children()[1]: self.welcome.hide() # self.hbox2.remove(self.welcome) # self.hbox2.pack_start(self.builder.get_object('frame2')) self.tree_value = self.model.get_value(self.iter,0) #print self.tree_value self.selected_word.show() self.selected_word.set_text(self.tree_value) #self.notebook2 = self.builder.get_object('notebook2') #cur_page = self.notebook2.get_current_page() #if self.tree_value not in wordz_db.list_groups(): #print self.tree_value self.hbox5.show() ''' w, h = self.window.get_size() self.vpan.set_position(h) tmp = self.vpan.get_position() self.vpan.set_position(int((240.0/450)*h)) else: self.vpan.set_position(10000) self.hbox3.hide()''' #if self.output_txtview.get_editable(): # self.output_txtview.set_editable(False) detail = wordz_db.get_details(self.tree_value) buff = self.output_txtview.get_buffer() buff.set_text(detail) self.output_txtview.set_buffer(buff) #self.output_txtview.modify_font(self.fontdesc) self.show_details_tree()
f1eb60aee989dcf191e25d63123e58bea48e79be /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/f1eb60aee989dcf191e25d63123e58bea48e79be/wordgroupz.py
piter = self.treestore.append(None, [group])
l = wordz_db.list_words_per_group(group) t = 0 count = 0 for i in l: t = t + self.acc_dict[i] count = count + 1 t = t/count piter = self.treestore.append(None, [group, t])
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('') for group in wordz_db.list_groups(): piter = self.treestore.append(None, [group]) for word in wordz_db.list_words_per_group(group): self.treestore.append(piter, [word]) self.treeview.expand_all() #buff = self.output_txtview.get_buffer() #buff.set_text('Nothing selected') #self.output_txtview.set_buffer(buff) self.selected_word.set_text('') #self.show_details_tree() #self.selected_word.hide() self.frame2.hide() self.welcome.show() self.note.set_alignment(0.5, 0.1) self.note.set_markup('<span foreground="white"><b>Nothing selected</b></span>')
f1eb60aee989dcf191e25d63123e58bea48e79be /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/f1eb60aee989dcf191e25d63123e58bea48e79be/wordgroupz.py
self.treestore.append(piter, [word])
self.treestore.append(piter, [word, self.acc_dict[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('') for group in wordz_db.list_groups(): piter = self.treestore.append(None, [group]) for word in wordz_db.list_words_per_group(group): self.treestore.append(piter, [word]) self.treeview.expand_all() #buff = self.output_txtview.get_buffer() #buff.set_text('Nothing selected') #self.output_txtview.set_buffer(buff) self.selected_word.set_text('') #self.show_details_tree() #self.selected_word.hide() self.frame2.hide() self.welcome.show() self.note.set_alignment(0.5, 0.1) self.note.set_markup('<span foreground="white"><b>Nothing selected</b></span>')
f1eb60aee989dcf191e25d63123e58bea48e79be /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/f1eb60aee989dcf191e25d63123e58bea48e79be/wordgroupz.py
elif i[0] != '0:0' and i[1] in self.new_word:
elif i[1] != '0:0' and i[0] 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' and word not in self.new_word: self.new_word.append(word) elif i[0] != '0:0' and i[1] in self.new_word: self.new_word.remove(i[0]) if word in self.new_word: renderer.set_property('text', 'New') else: renderer.set_property('text', None)
3023d92cd253880a8928730b6b0f6ac4e8e60322 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/3023d92cd253880a8928730b6b0f6ac4e8e60322/wordgroupz.py
if word not in self.new_word: self.new_word.append(word)
def on_add_clicked(self, widget, data=None): word = self.get_word.get_text() get_group_ch = self.get_group.child group = get_group_ch.get_text() conts = self.details.get_buffer() start = conts.get_iter_at_offset(0) end = conts.get_iter_at_offset(-1) detail = conts.get_text(start, end) wordz_db.add_to_db(word, group, detail) self.refresh_groups(group) self.treestore.clear() self.new_word.append(word) if word not in self.new_word: self.new_word.append(word) #print self.new_word self.on_back_clicked()
3023d92cd253880a8928730b6b0f6ac4e8e60322 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10994/3023d92cd253880a8928730b6b0f6ac4e8e60322/wordgroupz.py