rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
fdGraph = force_directed.Graph(hlGraph.edgeTuples, len(hlGraph.vertexList)) | fdGraph = ForceDirected.Graph(hlGraph.edgeTuples, len(hlGraph.vertexList)) | def runLayout(hlGraph): """Given a high-level Graph instance, run layout and write an SVG file""" # Make a force_directed graph from that fdGraph = force_directed.Graph(hlGraph.edgeTuples, len(hlGraph.vertexList)) print fdGraph fdGraph.randomize(0, 0, 1000, 1000) try: while 1: print "energy: %f" % fdGraph.iteration() ... |
rows = cPickle.load(open('cia-dataset.p')) | rows = cPickle.load(open('examples/cia-dataset.p')) | def runLayout(hlGraph): """Given a high-level Graph instance, run layout and write an SVG file""" # Make a force_directed graph from that fdGraph = force_directed.Graph(hlGraph.edgeTuples, len(hlGraph.vertexList)) print fdGraph fdGraph.randomize(0, 0, 1000, 1000) try: while 1: print "energy: %f" % fdGraph.iteration() ... |
% (_config.WWW_ROOT_DIR, _(u'Back to front page'))) | % (_config.WWW_ROOT_DIR + '/', _(u'Back to front page'))) | def ok_page(req, message): page_header(req, u'Joukahainen: %s' % _(u'operation succeeded')) jotools.write(req, u'<h1>%s</h1><p>%s</p>\n' % (_(u'operation succeeded'), message)) jotools.write(req, u'<p><a href="%s">%s ...</a></p>\n' \ % (_config.WWW_ROOT_DIR, _(u'Back to front page'))) page_footer(req) req.write('\n</ht... |
WCHARS = u"abcdefghijklmnopqrstuvwxyzåäöszèéšžABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖŠŽÈÉŠŽ-'|=" | WCHARS = u"abcdefghijklmnopqrstuvwxyzåäöszèéšžáóABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖŠŽÈÉŠŽ-'|=" | def _get_infl_vowel_type(db, wid, word): # Check the database dbtype = _get_db_vowel_type(db, wid) if dbtype != hfutils.VOWEL_DEFAULT: return dbtype # Check alternative spellings altforms_res = db.query('SELECT related_word FROM related_word WHERE wid = %i' % wid) for altform_r in altforms_res.getresult(): altform = un... |
req.write(req, (u" | req.write((u" | def _malaga_line(db, req, wid, word, classid, hf_class, hf_histclass): altforms_res = db.query('SELECT related_word FROM related_word WHERE wid = %i' % wid) if altforms_res.ntuples() == 0: altforms = [word] else: altforms = [] for res in altforms_res.getresult(): altforms.append(unicode(res[0], 'UTF-8')) for altform in... |
req.write((u'[perusmuoto: "%s", alku: "%s", luokka: %s, jatko: <%s>, äs: %s%s];\n' \ % (word, alku, wclass_s, jatko, malaga_vtype, flags)).encode('UTF-8')) | req.write((u'[perusmuoto: "%s", alku: "%s", luokka: %s, jatko: <%s>, äs: %s%s%s];\n' \ % (word, alku, wclass_s, jatko, malaga_vtype, flags, _get_structure(altform, wclass_s))).encode('UTF-8')) | def _malaga_line(db, req, wid, word, classid, hf_class, hf_histclass): altforms_res = db.query('SELECT related_word FROM related_word WHERE wid = %i' % wid) if altforms_res.ntuples() == 0: altforms = [word] else: altforms = [] for res in altforms_res.getresult(): altforms.append(unicode(res[0], 'UTF-8')) forced_vtype =... |
pattern = string.replace(u'V', u'(?:a|e|i|o|u|y|ä|ö|é|è|á|ó|â)') pattern = string.replace(u'C', u'(?:b|c|d|f|g|h|j|k|l|m|n|p|q|r|s|t|v|w|x|z|š|ž)') pattern = string.replace(u'A', u'(?:a|ä)') pattern = string.replace(u'O', u'(?:o|ö)') pattern = string.replace(u'U', u'(?:u|y)') | string = string.replace(u'V', u'(?:a|e|i|o|u|y|ä|ö|é|è|á|ó|â)') string = string.replace(u'C', u'(?:b|c|d|f|g|h|j|k|l|m|n|p|q|r|s|t|v|w|x|z|š|ž)') string = string.replace(u'A', u'(?:a|ä)') string = string.replace(u'O', u'(?:o|ö)') string = string.replace(u'U', u'(?:u|y)') | def expandre(string): if not checkre(string): return None pattern = string.replace(u'V', u'(?:a|e|i|o|u|y|ä|ö|é|è|á|ó|â)') pattern = string.replace(u'C', u'(?:b|c|d|f|g|h|j|k|l|m|n|p|q|r|s|t|v|w|x|z|š|ž)') pattern = string.replace(u'A', u'(?:a|ä)') pattern = string.replace(u'O', u'(?:o|ö)') pattern = string.replace(u'U... |
u'<table class="border"><tr><th>%s</th><th>%s</th><th></th></tr>\n' \ | u'<table class="border"><tr><th>%s</th><th>%s</th><th>%s</th></tr>\n' \ | def add(req): (uid, uname, editable) = jotools.get_login_user(req) if not editable: joheaders.error_page(req, _(u'You are not allowed to edit data')) return '\n' db = jodb.connect() if req.method != 'POST': joheaders.error_page(req, _(u'Only POST requests are allowed')) return '\n' db.query("BEGIN") if jotools.get_para... |
sesssha.update(time.time()) sesssha.update(random.random()) sesssha.update(os.times()) | sesssha.update(`time.time()`) sesssha.update(`random.random()`) sesssha.update(`os.times()`) | def login(req, username = None, password = None, wid = None): if req.method != 'POST': joheaders.error_page(req, u"Vain POST-pyynnöt ovat sallittuja") return '\n' if username == None or password == None or not jotools.checkuname(unicode(username, 'UTF-8')): joheaders.error_page(req, u"Käyttäjätunnus tai salasana puutt... |
if results.ntuples() > 500: | if results.ntuples() > 1000: | def listchanges(req, sdate = None, edate = None): db = jodb.connect() (uid, uname, editable) = jotools.get_login_user(req) joheaders.page_header_navbar_level1(req, _(u'List changes'), uid, uname) edt = datetime.datetime.now() sdt = edt - datetime.timedelta(days=1) if sdate != None: try: stime = time.strptime(sdate, u'... |
req.headers_out['Set-Cookie'] = 'session=%s; path=%s' % (sesskey, _config.WWW_ROOT_DIR) | if _config.WWW_ROOT_DIR == '': cookiepath = '/' else: cookiepath = _config.WWW_ROOT_DIR req.headers_out['Set-Cookie'] = 'session=%s; path=%s' % (sesskey, cookiepath) | def login(req, username = None, password = None, wid = None): if req.method != 'POST': joheaders.error_page(req, u"Vain POST-pyynnöt ovat sallittuja") return '\n' if username == None or password == None or not jotools.checkuname(unicode(username, 'UTF-8')): joheaders.error_page(req, u"Käyttäjätunnus tai salasana puutt... |
<p> | def classlist(req): joheaders.page_header(req, u'Etsi sanalle taivutusluokka') jotools.write(req, u''' | |
</p> | def classlist(req): joheaders.page_header(req, u'Etsi sanalle taivutusluokka') jotools.write(req, u''' | |
<label>Sana: <input type="text" name="word" /><br /> Sanaluokka: <select name="class"> <option selected="1" value="1">Nomini</option> | <label>Sana: <input type="text" name="word" /></label><br /> <label>Sanaluokka: <select name="class"> <option selected="selected" value="1">Nomini</option> | def classlist(req): joheaders.page_header(req, u'Etsi sanalle taivutusluokka') jotools.write(req, u''' |
</select><br /> Astevaihteluluokka: <select name="gclass"> <option selected="1" value="">ei astevaihtelua</option> | </select></label><br /> <label>Astevaihteluluokka: <select name="gclass"> <option selected="selected" value="">ei astevaihtelua</option> | def classlist(req): joheaders.page_header(req, u'Etsi sanalle taivutusluokka') jotools.write(req, u''' |
</select><br /> <input type="submit" value="Hae mahdolliset taivutukset"></p> | </select></label><br /> <input type="submit" value="Hae mahdolliset taivutukset" /></p> | def classlist(req): joheaders.page_header(req, u'Etsi sanalle taivutusluokka') jotools.write(req, u''' |
if cid == None: | if cid == None and row != -1: | def _get_class_selector(classlist, cid, row, include_no_class): if cid == None: retstr = u'' for res in classlist: retstr = retstr + (u'<label><input type="radio" name="class%i" ' + u'value="%i">%s</input></label>') \ % (row, res[0], jotools.escape_html(unicode(res[1], 'UTF-8'))) if include_no_class: retstr = retstr + ... |
jotools.write(req, _get_class_selector(class_res, word['cid'], i, False)) | incnocls = word['oword'] != None jotools.write(req, _get_class_selector(class_res, word['cid'], i, incnocls)) | def _add_entry_fields(req, db, words = None, count = 1): class_res = db.query("select classid, name from wordclass").getresult() if words == None: for i in range(count): jotools.write(req, u'<tr><td><input type="text" name="word%i" /></td><td>' % i) for res in class_res: jotools.write(req, (u'<label><input type="radio"... |
jotools.write(req, _get_class_selector(class_res, word['cid'], i, False)) | jotools.write(req, _get_class_selector(class_res, word['cid'], -1, False)) | def _add_entry_fields(req, db, words = None, count = 1): class_res = db.query("select classid, name from wordclass").getresult() if words == None: for i in range(count): jotools.write(req, u'<tr><td><input type="text" name="word%i" /></td><td>' % i) for res in class_res: jotools.write(req, (u'<label><input type="radio"... |
u'sanat, jotka edelleen haluat lisättäviksi ja yritä tallennusta ' + u'uudelleen.</p>') | u'sanat, jotka edelleen haluat lisättäviksi.</p>') | def add(req): (uid, uname, editable) = jotools.get_login_user(req) if not editable: joheaders.error_page(req, u'Ei oikeuksia tietojen muuttamiseen') return '\n' db = jodb.connect() if req.method != 'POST': joheaders.error_page(req, u'Vain POST-pyynnöt ovat sallittuja') return '\n' db.query("BEGIN") if jotools.get_param... |
u'<input type="submit" value="Lisää sanoja"></p></form>\n') | u'<input type="submit" value="Jatka"></p></form>\n') | def add(req): (uid, uname, editable) = jotools.get_login_user(req) if not editable: joheaders.error_page(req, u'Ei oikeuksia tietojen muuttamiseen') return '\n' db = jodb.connect() if req.method != 'POST': joheaders.error_page(req, u'Vain POST-pyynnöt ovat sallittuja') return '\n' db.query("BEGIN") if jotools.get_param... |
size = np.asarray(size) | size = np.asarray(size, np.int32) | def maxsize(self, size): size = np.asarray(size) fcboxlib.boxarray_maxsize(self.cptr, size) |
slave_proxy = SuSlave(to_parent, from_parent, Slave()) | if __name__ == '__main__': from select import select | def rmtree(self, request, path): shutil.rmtree(path) request.send(None) |
while read_watches or write_watches: readable, writable = select(read_watches, write_watches, [])[:2] for w in readable: if not w.ready(): read_watches.remove(w) for w in writable: if not w.ready(): write_watches.remove(w) | to_parent, from_parent = map(int, sys.argv[1:]) sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))) slave_proxy = SuSlave(to_parent, from_parent, Slave()) while read_watches or write_watches: readable, writable = select(read_watches, write_watches, [])[:2] for w in readable: if not w.r... | def rmtree(self, request, path): shutil.rmtree(path) request.send(None) |
g.timeout_add(long(timeout * 1000), self._timeout) | gobject.timeout_add(long(timeout * 1000), self._timeout) | def __init__(self, timeout): """Trigger after 'timeout' seconds (may be a fraction).""" Blocker.__init__(self) rox.toplevel_ref() g.timeout_add(long(timeout * 1000), self._timeout) |
self._tag = g.input_add(self._stream, g.gdk.INPUT_READ, | self._tag = gobject.io_add_watch(self._stream, gobject.IO_IN, | def add_task(self, task): Blocker.add_task(self, task) if self._tag is None: self._tag = g.input_add(self._stream, g.gdk.INPUT_READ, lambda src, cond: self.trigger()) |
g.input_remove(self._tag) | gobject.source_remove(self._tag) | def remove_task(self, task): Blocker.remove_task(self, task) if not self._rox_lib_tasks: g.input_remove(self._tag) self._tag = None |
INPUT_WRITE = 0x14 self._tag = g.input_add(self._stream, INPUT_WRITE, | self._tag = gobject.io_add_watch(self._stream, gobject.IO_OUT, | def add_task(self, task): Blocker.add_task(self, task) if self._tag is None: INPUT_WRITE = 0x14 # g.gdk.INPUT_WRITE sometimes wrong!! self._tag = g.input_add(self._stream, INPUT_WRITE, lambda src, cond: self.trigger()) |
FILE = 0 | LEAF = 0 | def destroy(box): global savebox # For pychecker savebox = None |
gobject.TYPE_STRING, gobject.TYPE_STRING) | gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) | def __init__(self, tb): g.Frame.__init__(self, _('Stack trace (innermost last)')) |
column = g.TreeViewColumn('File', cell, text = ExceptionExplorer.FILE) | column = g.TreeViewColumn('File', cell, text = ExceptionExplorer.LEAF) | def __init__(self, tb): g.Frame.__init__(self, _('Stack trace (innermost last)')) |
filename = os.path.basename(filename) | leafname = os.path.basename(filename) | def __init__(self, tb): g.Frame.__init__(self, _('Stack trace (innermost last)')) |
self.model.set(new, ExceptionExplorer.FILE, filename, | self.model.set(new, ExceptionExplorer.LEAF, leafname, | def __init__(self, tb): g.Frame.__init__(self, _('Stack trace (innermost last)')) |
ExceptionExplorer.CODE, line) | ExceptionExplorer.CODE, line, ExceptionExplorer.FILE, filename) | def __init__(self, tb): g.Frame.__init__(self, _('Stack trace (innermost last)')) |
'Search <Choices> for a suitable icon. Returns a GtkImage.' | 'Search <Choices> for a suitable icon. Returns a pixbuf, or None.' | def image_for_type(type): 'Search <Choices> for a suitable icon. Returns a GtkImage.' media, subtype = type.split('/', 1) path = choices.load('MIME-icons', media + '_' + subtype + '.png') if not path: path = choices.load('MIME-icons', media + '.png') if path: pixbuf = gdk.pixbuf_new_from_file(path) else: pixbuf = None ... |
pixbuf = gdk.pixbuf_new_from_file(path) | return gdk.pixbuf_new_from_file(path) | def image_for_type(type): 'Search <Choices> for a suitable icon. Returns a GtkImage.' media, subtype = type.split('/', 1) path = choices.load('MIME-icons', media + '_' + subtype + '.png') if not path: path = choices.load('MIME-icons', media + '.png') if path: pixbuf = gdk.pixbuf_new_from_file(path) else: pixbuf = None ... |
pixbuf = None if pixbuf: image = g.Image() image.set_from_pixbuf(pixbuf) return image return g.image_new_from_stock(g.STOCK_MISSING_IMAGE) | return None | def image_for_type(type): 'Search <Choices> for a suitable icon. Returns a GtkImage.' media, subtype = type.split('/', 1) path = choices.load('MIME-icons', media + '_' + subtype + '.png') if not path: path = choices.load('MIME-icons', media + '.png') if path: pixbuf = gdk.pixbuf_new_from_file(path) else: pixbuf = None ... |
self.icon = image_for_type(type) | self.icon = g.Image() self._set_icon(type) | def _create_drag_area(self, type): align = g.Alignment() align.set(.5, .5, 0, 0) |
if not icon: icon = image_for_type(type) self.icon.set_from_pixbuf(icon.get_pixbuf()) | if icon: self.icon.set_from_pixbuf(icon.get_pixbuf()) else: self._set_icon(type) | def set_type(self, type, icon = None): """Change the icon and drag target to 'type'. If 'icon' is given (as a GtkImage) then that icon is used, otherwise an appropriate icon for the type is used.""" if not icon: icon = image_for_type(type) self.icon.set_from_pixbuf(icon.get_pixbuf()) self._set_drag_source(type) |
drag_box.drag_source_set_icon_pixbuf(self.icon.get_pixbuf()) | pixbuf = self.icon.get_pixbuf() if pixbuf: drag_box.drag_source_set_icon_pixbuf(pixbuf) | def drag_begin(self, drag_box, context): self.drag_in_progress = 1 self.destroy_on_drag_end = 0 self.using_xds = 0 self.data_sent = 0 drag_box.drag_source_set_icon_pixbuf(self.icon.get_pixbuf()) |
if hasattr(g, 'input_add_full'): | import gobject if not hasattr(gobject, 'io_add_watch'): | def start(self): """Create the subprocess. Calls pre_fork() and forks. The parent then calls parent_post_fork() and returns, while the child calls child_post_fork() and then child_run().""" assert self.child is None |
import gobject | def start(self): """Create the subprocess. Calls pre_fork() and forks. The parent then calls parent_post_fork() and returns, while the child calls child_post_fork() and then child_run().""" assert self.child is None | |
gobject.IO_IN | gobject.IO_HUP, self._got_errors) | gobject.IO_IN | gobject.IO_HUP | gobject.IO_ERR, self._got_errors) | def start(self): """Create the subprocess. Calls pre_fork() and forks. The parent then calls parent_post_fork() and returns, while the child calls child_post_fork() and then child_run().""" assert self.child is None |
return | return 1 | def _got_errors(self, source, cond): got = os.read(self.err_from_child, 100) if got: self.got_error_output(got) return |
self.do_box(node, label, g.HBox(FALSE, 4)) | return self.do_box(node, label, g.HBox(FALSE, 4)) | def build_hbox(self, node, label): """<hbox>...</hbox> to layout child widgets horizontally.""" self.do_box(node, label, g.HBox(FALSE, 4)) |
self.do_box(node, label, g.VBox(FALSE, 0)) | return self.do_box(node, label, g.VBox(FALSE, 0)) | def build_vbox(self, node, label): """<vbox>...</vbox> to layout child widgets vertically.""" self.do_box(node, label, g.VBox(FALSE, 0)) |
v = map(int, vs.split('.')) if v[0] < major or v[1] < minor or v[2] < micro: | v = tuple(map(int, vs.split('.'))) if v < (major, minor, micro): | def version(major, minor, micro): """Find ROX-Lib2, with a version >= (major, minor, micro), and add it to sys.path. If version is missing or too old, either prompt the user, or (if possible) upgrade it automatically. If 'rox' is already in PYTHONPATH, just use that (assume the injector is being used).""" try: import r... |
ag.connect('accel_changed', keys_changed) | import gobject gobject.GObject.connect(ag, 'accel_changed', keys_changed) | def keys_changed(*unused): program, name = _save_name path = choices.save(program, name) if path: try: g.accel_map_save(path) except AttributeError: print "Error saving keybindings to", path |
if os.path.islink(old): | if old and os.path.islink(old): | def load_types(self): |
oname='script' | oname='' | def load_types(self): |
win.destory() | win.destroy() | def _install_type_handler(types, dir, desc, application=None, overwrite=True): if len(types)<1: return if not application: application=rox.app_dir if application[0]!='/': application=os.path.abspath(application) win=InstallList(application, desc, dir, types) if win.run()!=rox.g.RESPONSE_ACCEPT: win.destroy() return ... |
if path: key = None | def __init__(self, name, items): """names should be unique (eg, 'popup', 'main', etc). items is a list of menu items: [(name, callback_name, type, key), ...]. 'name' is the item's path. 'callback_name' is the NAME of a method to call. 'type' is as for g.ItemFactory. 'key' is only used if no bindings are in Choices.""" ... | |
c = self.get_style().bg[g.STATE_NORMAL] | c = self.c_box.get_style().bg[g.STATE_NORMAL] | def response(dialog, resp): if resp != g.RESPONSE_OK: dialog.destroy() return self.set(dialog.colorsel.get_current_color()) dialog.destroy() self.option_box.check_widget(self.option) |
self.subdirs = [SubDir(self, d) for d in self.get('Icon Theme', 'Directories').split(';')] | subdirs = self.get('Icon Theme', 'Directories') subdirs = subdirs.replace(';', ',') self.subdirs = [SubDir(self, d) for d in subdirs.split(',')] | def __init__(self, dir): self.dir = dir sections = file(os.path.join(dir, "index.theme")).read().split('\n[') self.sections = {} for s in sections: lines = s.split('\n') sname = lines[0].strip() # Python < 2.2.2 doesn't support an argument to strip... assert sname[-1] == ']' if sname.startswith('['): sname = sname[1:-... |
If 'icon' is given (as (pixmap, mask)) then that icon is used, | If 'icon' is given (as a GtkImage) then that icon is used, | def set_type(self, type, icon = None): """Change the icon and drag target to 'type'. If 'icon' is given (as (pixmap, mask)) then that icon is used, otherwise an appropriate icon for the type is used.""" if icon: pixmap, mask = icon else: pixmap, mask = icon_for_type(self, type) self.icon.set(pixmap, mask) self._set_dra... |
if icon: pixmap, mask = icon else: pixmap, mask = icon_for_type(self, type) self.icon.set(pixmap, mask) | if not icon: icon = image_for_type(type) self.icon.set_from_pixbuf(icon.get_pixbuf()) | def set_type(self, type, icon = None): """Change the icon and drag target to 'type'. If 'icon' is given (as (pixmap, mask)) then that icon is used, otherwise an appropriate icon for the type is used.""" if icon: pixmap, mask = icon else: pixmap, mask = icon_for_type(self, type) self.icon.set(pixmap, mask) self._set_dra... |
g.input_add(self.to_peer, g.gdk.INPUT_WRITE, | INPUT_WRITE = 0x14 g.input_add(self.to_peer.fileno(), INPUT_WRITE, | def enable_write_watch(self): from rox import g g.input_add(self.to_peer, g.gdk.INPUT_WRITE, lambda src, cond: self.write_ready()) |
if self.to_peer == -1: | if self.to_peer is None: | def write_object(self, object): if self.to_peer == -1: raise Exception('Peer is defunct') if not self.out_buffer: self.enable_write_watch() |
n = os.write(self.to_peer, self.out_buffer) | n = os.write(self.to_peer.fileno(), self.out_buffer) | def write_ready(self): """Returns True if the buffer is not empty on exit.""" while self.out_buffer: w = select([], [self.to_peer], [], 0)[1] if not w: print "Not ready for writing" return True n = os.write(self.to_peer, self.out_buffer) self.out_buffer = self.out_buffer[n:] return False |
new = os.read(self.from_peer, 1000) | new = os.read(self.from_peer.fileno(), 1000) | def read_ready(self): new = os.read(self.from_peer, 1000) if not new: self.finish() raise Exception("Lost connection to slave!") self.in_buffer += new while ':' in self.in_buffer: l, rest = self.in_buffer.split(':', 1) l = int(l) if len(rest) < l: return True # Haven't got everything yet s = rest[:l] self.in_buffer = ... |
raise Exception("Lost connection to slave!") | self.lost_connection() | def read_ready(self): new = os.read(self.from_peer, 1000) if not new: self.finish() raise Exception("Lost connection to slave!") self.in_buffer += new while ':' in self.in_buffer: l, rest = self.in_buffer.split(':', 1) l = int(l) if len(rest) < l: return True # Haven't got everything yet s = rest[:l] self.in_buffer = ... |
self.to_slave = -1 self.from_slave = -1 | self.to_slave = self.from_slave = None def lost_connection(self): raise Exception("Lost connection to peer!") | def finish(self): self.to_slave = -1 self.from_slave = -1 |
self.int_value = int(float(self.value)) | if self.value == 'True': self.int_value = 1 elif self.value == 'False': self.int_value = 0 else: self.int_value = int(float(self.value)) | def _set(self, value): if self.value != value: self.value = str(value) self.has_changed = 1 try: self.int_value = int(float(self.value)) except: self.int_value = -1 |
drag_box.connect('drag_end', self.drag_end) | def __init__(self, window, media, subtype, discard = FALSE): GtkWindow.__init__(self, WINDOW_DIALOG) self.discard = discard self.set_title('Save As:') self.set_position(WIN_POS_MOUSE) self.set_border_width(4) self.window = window | |
self.using_xds = 1 def drag_end(self, widget, context): if self.using_xds: uri = read_xds_property(context, TRUE) if uri: path = get_local_path(uri) if path: self.window.set_uri(path) else: self.window.set_uri(uri) else: | def drag_data_get(self, widget, context, selection_data, info, time): if info == TARGET_RAW: self.window.send_raw(selection_data) self.data_sent = 1 return elif info != TARGET_XDS: report_error("Bad target requested!") return | |
path = get_local_path(uri) if path: self.window.set_uri(path) else: self.window.set_uri(uri) | def drag_end(self, widget, context): if self.using_xds: uri = read_xds_property(context, TRUE) if uri: path = get_local_path(uri) if path: self.window.set_uri(path) else: self.window.set_uri(uri) else: write_xds_property(context, None) | |
check=False, injint=injint) | check=False) | def install_send_to_types(types, application=None, injint=None): """Install application in the SendTo menu for 1 or more types. application should be the full path to the AppDir. If application is None then it is the running program which will be installed. The user is asked to confirm the setting for each type.""" if... |
self.build_section(section, parent) | self.build_section(section, None) | def __init__(self, options_group, options_xml): """options_xml is an XML file, usually <app_dir>/Options.xml, which defines the layout of the OptionsBox. |
self.connect('destroy', self.destroyed) def got_response(self, widget, response): | self.connect('destroy', destroyed) def got_response(widget, response): | def destroyed(widget): rox.toplevel_unref() if self.changed(): self.options.save() |
self.connect('response', self.got_response) | self.connect('response', got_response) | def got_response(self, widget, response): if response == g.RESPONSE_OK: self.destroy() elif response == REVERT: for o in self.options: o._set(self.revert[o]) self.update_widgets() self.options.notify() self.update_revert() |
model = g.TreeStore(gobject.TYPE_STRING, g.Widget.__gtype__) | model = g.TreeStore(gobject.TYPE_STRING, gobject.TYPE_INT) | def build_window_frame(self): "Create the main structure of the window." hbox = g.HBox(FALSE, 4) self.vbox.pack_start(hbox, TRUE, TRUE, 0) |
self.sections.set(iter, 0, section.getAttribute('title')) | self.sections.set(iter, 0, section.getAttribute('title'), 1, self.notebook.page_num(page)) | def build_section(self, section, parent): """Create a new page for the notebook and a new entry in the sections tree, and build all the widgets inside the page.""" page = g.VBox(FALSE, 4) page.set_border_width(4) self.notebook.append_page(page, g.Label('unused')) |
vbox = g.VBox(FALSE, 0) | vbox = g.VBox(FALSE, 4) | def build_frame(self, node, label): """<frame label='Title'>...</frame> to put a border around a group of options.""" frame = g.Frame(label) vbox = g.VBox(FALSE, 0) vbox.set_border_width(4) frame.add(vbox) |
r = int(colour[1:5], 16) g = int(colour[5:9], 16) b = int(colour[9:13], 16) | r = string.atoi(colour[1:5], 16) g = string.atoi(colour[5:9], 16) b = string.atoi(colour[9:13], 16) | def set_colour(self, colour): try: r = int(colour[1:5], 16) g = int(colour[5:9], 16) b = int(colour[9:13], 16) except: print "Invalid colour spec:", colour r, g, b = (0, 0, 0) self.set_colour_rgb(r, g, b) |
new = Tmp() | new = _Tmp() | def __init__(self, command, src, dst): """Execute 'command' with src as stdin and writing to stream dst. If either stream is not a fileno() stream, temporary files will be used as required. Either stream may be None if input or output is not required. Call the wait() method to wait for the command to finish. 'command' ... |
self.start() | self.done = False self.waiting = False | def __init__(self, command, src, dst): """Execute 'command' with src as stdin and writing to stream dst. If either stream is not a fileno() stream, temporary files will be used as required. Either stream may be None if input or output is not required. Call the wait() method to wait for the command to finish. 'command' ... |
self.tmp_stream = Tmp() | self.tmp_stream = _Tmp() | def pre_fork(self): # Output to 'dst' directly if it's a fileno stream. Otherwise, # send output to a temporary file. assert self.tmp_stream is None |
err = None | def child_died(self, status): errors = self.errors.strip() | |
err = ChildKilled elif errors: err = ChildError("Errors from command '%s':\n%s" % (self.command, errors)) elif status != 0: err = ChildError("Command '%s' returned an error code!" % self.command) if not err and self.tmp_stream: self.tmp_stream.seek(0) self.dst.write(self.tmp_stream.read()) | self.done = ChildKilled() elif errors or status: try: self.check_errors(errors, status) self.done = True except Exception, e: self.done = e else: self.done = True assert self.done is True or isinstance(self.done, Exception) if self.done is True: if self.tmp_stream: self.tmp_stream.seek(0) self.dst.write(self.tmp_st... | def child_died(self, status): errors = self.errors.strip() |
self.callback(err) | if self.waiting: assert self.done self.waiting = False g.mainquit() | def child_died(self, status): errors = self.errors.strip() |
done = [] def set_done(exception): done.append(exception) g.mainquit() self.callback = set_done while not done: | if self.child is None: self.start() self.waiting = True while not self.done: | def wait(self): """Run a recursive mainloop until the command terminates. Raises an exception on error.""" done = [] def set_done(exception): done.append(exception) g.mainquit() self.callback = set_done while not done: g.mainloop() exception, = done if exception: raise exception |
exception, = done if exception: raise exception | if self.done is not True: raise self.done | def set_done(exception): done.append(exception) g.mainquit() |
def Tmp(mode = 'w+b', suffix = '-tmp'): | def _Tmp(mode = 'w+b', suffix = '-tmp'): | def Tmp(mode = 'w+b', suffix = '-tmp'): "Create a seekable, randomly named temp file (deleted automatically after use)." import tempfile try: return tempfile.NamedTemporaryFile(mode, suffix = suffix) except: # python2.2 doesn't have NamedTemporaryFile... pass import random name = tempfile.mktemp(`random.randint(1, 100... |
print "Test Tmp()..." file = Tmp() | print "Test _Tmp()..." file = _Tmp() | def pipe_through_command(command, src, dst): PipeThroughCommand(command, src, dst).wait() |
src = Tmp() | src = _Tmp() | def pipe_through_command(command, src, dst): PipeThroughCommand(command, src, dst).wait() |
self.destroy() if self.discard: self.document.close() | if self.drag_in_progress: self.destroy_on_drag_end = 1 else: self.destroy() if self.discard: self.document.close() | def drag_data_get(self, widget, context, selection_data, info, time): if info == TARGET_RAW: self.save_as_selection(selection_data) self.data_sent = 1 write_xds_property(context, None) self.destroy() if self.discard: self.document.close() return elif info != TARGET_XDS: write_xds_property(context, None) report_error("B... |
widget.connect('drag_data_received', self.xds_data_received) | widget.connect('drag-data-received', self.xds_data_received) widget.connect('drag-drop', self.xds_drag_drop) def xds_drag_drop(self, widget, context, data, info, time): """Called when something is dropped on us. Decide which of the " offered targets to request and ask for it. xds_data_received will be called when it f... | def xds_proxy_for(self, widget): "Handle drops on this widget as if they were to 'self'." # (Konqueror requires ACTION_MOVE) widget.drag_dest_set(g.DEST_DEFAULT_MOTION | g.DEST_DEFAULT_HIGHLIGHT, self.targets, gdk.ACTION_COPY | gdk.ACTION_MOVE | gdk.ACTION_PRIVATE) widget.connect('drag_data_received', self.xds_data_re... |
if find(name, '.') != -1: | if name.find('.') != -1: | def our_host_name(): """Try to return the canonical name for this computer. This is used in the drag-and-drop protocol to work out whether a drop is coming from a remote machine (and therefore has to be fetched differently).""" from socket import gethostbyaddr, gethostname global _host_name if _host_name: return _host_... |
path=basedir.save_config_path(site, dir, leaf) | path=basedir.save_config_path(site, dir) path=os.path.join(path, leaf) | def save_path(site, dir, leaf, create=1): parent=basedir.save_config_path(site, dir) if os.path.isdir(parent): path=basedir.save_config_path(site, dir, leaf) else: path=choices.save(dir, leaf, create) return path |
info.free() | def lookup_icon(self, iconname, size, flags=0): info=self.gtk_theme.lookup_icon(iconname, size, flags) if info: path=info.get_filename() info.free() return path return None | |
g.input_remove(self.tag) | gobject.source_remove(self.tag) | def _got_errors(self, source, cond): got = os.read(self.err_from_child, 100) if got: self.got_error_output(got) return True |
box.set_has_separator(False) | def destroy(box): global savebox # For pychecker savebox = None | |
raise Exception("Document %s can't save!" % document) | raise Exception("Document %s can't save!" % self.document) | def create_drag_area(self, type): align = GtkAlignment() align.set(.5, .5, 0, 0) |
sname = lines[0].strip('[] \t') | sname = lines[0].strip() assert sname[-1] == ']' if sname.startswith('['): sname = sname[1:-1] else: sname = sname[:-1] | def __init__(self, dir): self.dir = dir sections = file(os.path.join(dir, "index.theme")).read().split('\n[') self.sections = {} for s in sections: lines = s.split('\n') sname = lines[0].strip('[] \t') section = self.sections[sname] = {} for line in lines[1:]: if not line.strip(): continue if line.startswith('#'): cont... |
assert status == 0x100 | exitstatus = os.WEXITSTATUS(status) assert exitstatus != 0 | def run(): maker = su.SuProxyMaker( 'Need to become root to test this module.') yield maker.blocker root = maker.get_root() |
_window_icon=None | def report_exception(): """Display the current python exception in an error box, returning when the user closes the box. This is useful in the 'except' clause of a 'try' block. Uses rox.debug.show_exception().""" type, value, tb = sys.exc_info() import debug debug.show_exception(type, value, tb) | |
message = applyColorTags(message) | def connectionMade(self): import sys mailMsg = email.message_from_file(sys.stdin) f = open(mailLog, "a") f.write(mailMsg.as_string()) f.close() subjectFields = mailMsg['Subject'].split(" ") message = mailMsg.get_payload() subjectFields[1] = subjectFields[1].lower() if subjectFields[1][0] == "#": subjectFields[1] = sub... | |
f = open(commandLog, "a") f.write(commandLine) f.close() self.transport.write(commandLine) | logCommand(commandLine) self.transport.write(applyColorTags(commandLine)) | def connectionMade(self): import sys mailMsg = email.message_from_file(sys.stdin) f = open(mailLog, "a") f.write(mailMsg.as_string()) f.close() subjectFields = mailMsg['Subject'].split(" ") message = mailMsg.get_payload() subjectFields[1] = subjectFields[1].lower() if subjectFields[1][0] == "#": subjectFields[1] = sub... |
self.transport.write("%s %s\r\n" % (subjectFields[0], subjectFields[1])) | commandLine = "%s %s\r\n" % (subjectFields[0], subjectFields[1]) logCommand(commandLine) self.transport.write(commandLine) | def connectionMade(self): import sys mailMsg = email.message_from_file(sys.stdin) f = open(mailLog, "a") f.write(mailMsg.as_string()) f.close() subjectFields = mailMsg['Subject'].split(" ") message = mailMsg.get_payload() subjectFields[1] = subjectFields[1].lower() if subjectFields[1][0] == "#": subjectFields[1] = sub... |
obj.setData(safe_read(obj.additional_data_wanted)) | if obj.additional_data_wanted: obj.setData(safe_read(obj.additional_data_wanted)) else: obj.setData('') | def safe_read(len, read=read): try: return read(len) except: import sys # fetch the exception object, so that we may know what went wrong corpse = 'Exception during read from pgserver', sys.exc_info()[1] raise Dead(*corpse) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.