rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
def key_press_event_cb(self, win, event): pressed = event.keyval keys = gtk.keysyms if event.state == 0: if pressed == keys.KP_Add: self.zoom('ZoomIn') elif pressed == keys.KP_Subtract: self.zoom('ZoomOut') elif pressed == keys.Left: self.move('MoveLeft') elif pressed == keys.Right: self.move('MoveRight') elif pressed...
def key_press_event_cb_before(self, win, event): ANY_MODIFIER = gtk.gdk.SHIFT_MASK | gtk.gdk.MOD1_MASK | gtk.gdk.CONTROL_MASK if event.state & ANY_MODIFIER: return False if event.keyval == gtk.keysyms.Left: self.move('MoveLeft') elif event.keyval == gtk.keysyms.Right: self.move('MoveRight') elif event.keyval == gtk.ke...
def key_press_event_cb(self, win, event): #print event.keyval, event.state pressed = event.keyval keys = gtk.keysyms if event.state == 0: # no modifiers if pressed == keys.KP_Add: self.zoom('ZoomIn') elif pressed == keys.KP_Subtract: self.zoom('ZoomOut') elif pressed == keys.Left: self.move('MoveLeft') elif pressed == ...
vbox.pack_start(self.brushlist, expand=True, fill=True)
scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scroll.add_with_viewport(self.brushlist) vbox.pack_start(scroll)
def __init__(self, app): gtk.Window.__init__(self) self.app = app self.app.brush_selected_callbacks.insert(0, self.brush_selected_cb)
self.set_size_request(450, 500)
self.resize(350, 500)
def clear_cb(window, mdw): mdw.clear()
self.set_size_request(preview_total_w, preview_total_h)
self.redraw_thumbnails()
def __init__(self, app): gtk.DrawingArea.__init__(self) self.pixbuf = None self.app = app self.app.brush_selected_callbacks.append(self.brush_selected_cb)
height = max(height, self.tiles_h * preview_total_h)
height = self.tiles_h * preview_total_h self.set_size_request(0, height)
def redraw_thumbnails(self, width = None, height = None): if width is None: if not self.pixbuf: return width = self.pixbuf.get_width() height = self.pixbuf.get_height() self.tiles_w = (width / preview_total_w) or 1 self.tiles_h = len(self.app.brushes)/self.tiles_w + 1 height = max(height, self.tiles_h * preview_total_h...
if self.pixbuf.get_height() >= size.height:
if self.pixbuf.get_height() == size.height:
def configure_event_cb(self, widget, size): if self.pixbuf and self.pixbuf.get_width() == size.width: if self.pixbuf.get_height() >= size.height: return self.redraw_thumbnails(size.width, size.height)
e_x, e_y, e_w, e_h,
0, 0, p_w, p_h,
#def draw_rgb_image(gc, x, y, width, height, dith, rgb_buf, rowstride=-1, xdith=0, ydith=0)
pixels, rowstride, e_x, e_y)
pixels, rowstride)
#def draw_rgb_image(gc, x, y, width, height, dith, rgb_buf, rowstride=-1, xdith=0, ydith=0)
assert self.grabbed is None
def button_press_cb(self, widget, event): if not event.button == 1: return x, y = self.eventpoint(event.x, event.y) nearest = None for i in range(len(self.points)): px, py = self.points[i] dist = abs(px - x) if nearest is None or dist < mindist: mindist = dist nearest = i if mindist > 0.05 and len(self.points) < self.m...
"Copyright (C) 2005 Martin Renold &lt;martinxyz@gmx.ch&gt;\n\n"
"Copyright (C) 2005-2006 Martin Renold &lt;martinxyz@gmx.ch&gt;\n\n"
def show_about_cb(self, action): d = gtk.MessageDialog(self, buttons=gtk.BUTTONS_OK) d.set_markup("MyPaint - pressure sensitive painting application\n" "Copyright (C) 2005 Martin Renold &lt;martinxyz@gmx.ch&gt;\n\n" "Contributors:\n" "Artis Rozent\xc4\x81ls &lt;artis@aaa.apollo.lv&gt;\n" #"UTF-8 Test: \xE2\x82\xAC (sho...
"Artis Rozent\xc4\x81ls &lt;artis@aaa.apollo.lv&gt;\n"
"Artis Rozent\xc4\x81ls &lt;artis@aaa.apollo.lv&gt; (brushes)\n"
def show_about_cb(self, action): d = gtk.MessageDialog(self, buttons=gtk.BUTTONS_OK) d.set_markup("MyPaint - pressure sensitive painting application\n" "Copyright (C) 2005 Martin Renold &lt;martinxyz@gmx.ch&gt;\n\n" "Contributors:\n" "Artis Rozent\xc4\x81ls &lt;artis@aaa.apollo.lv&gt;\n" #"UTF-8 Test: \xE2\x82\xAC (sho...
if not os.path.isdir(self.confpath): os.mkdir(self.confpath)
if not os.path.isdir(self.confpath): if os.path.isdir('dot-mypaint'): print "Copying default configuration and brush collection:" command = "cp -a dot-mypaint " + self.confpath print command os.system(command) print "Done." else: print "Default config file and brush collection not found." if not os.path.isdir(self.conf...
def __init__(self, confpath, loadimage): self.confpath = confpath if not os.path.isdir(self.confpath): os.mkdir(self.confpath) self.brushpath = self.confpath + 'brushes/' if not os.path.isdir(self.brushpath): os.mkdir(self.brushpath)
def cmp_brushes(a, b): return cmp(a.painting_time, b.painting_time) self.brushes.sort(cmp_brushes) self.brushes.reverse() painting_time_limit = 6*60*60 max_painting_time = max([b.painting_time for b in self.brushes]) if max_painting_time > painting_time_limit: for b in self.brushes: b.painting_time *= 1.0 / max_painti...
if self.brushes: def cmp_brushes(a, b): return cmp(a.painting_time, b.painting_time) self.brushes.sort(cmp_brushes) self.brushes.reverse() painting_time_limit = 6*60*60 max_painting_time = max([b.painting_time for b in self.brushes]) if max_painting_time > painting_time_limit: for b in self.brushes: b.painting_time *...
def __init__(self, confpath, loadimage): self.confpath = confpath if not os.path.isdir(self.confpath): os.mkdir(self.confpath) self.brushpath = self.confpath + 'brushes/' if not os.path.isdir(self.brushpath): os.mkdir(self.brushpath)
pass
if self.recording: trash = self.mdw.stop_recording() print 'Discarded', len(trash), 'bytes of stroke data.' self.mdw.start_recording() self.recording = True
def record_stroke_cb(self, action): pass
pass
if self.recording: self.recorded_stroke = self.mdw.stop_recording() print 'Recorded', len(self.recorded_stroke), 'bytes.' self.recording = False self.mdw.replay(self.recorded_stroke)
def replay_stroke_cb(self, action): pass
req = request()
req = request(self.manager)
def dofindall( self, collection): hrefs = [] req = request() req.method = "PROPFIND" req.ruri = collection[0] req.headers["Depth"] = "1" if len(collection[1]): req.user = collection[1] if len(collection[2]): req.pswd = collection[2] req.data = data() req.data.value = """<?xml version="1.0" encoding="utf-8" ?>
req = request()
req = request(self.manager)
def dodeleteall( self, deletes ): if len(deletes) == 0: return True for deleter in deletes: req = request() req.method = "DELETE" req.ruri = deleter[0] if len(deleter[1]): req.user = deleter[1] if len(deleter[2]): req.pswd = deleter[2] self.dorequest( req, False, False )
req = request()
req = request(self.manager)
def dofindnew( self, collection): hresult = "" req = request() req.method = "PROPFIND" req.ruri = collection[0] req.headers["Depth"] = "1" if len(collection[1]): req.user = collection[1] if len(collection[2]): req.pswd = collection[2] req.data = data() req.data.value = """<?xml version="1.0" encoding="utf-8" ?>
req = request()
req = request(self.manager)
def doenddelete( self, description ): if len(self.end_deletes) == 0: return True description += " " * max(1, STATUSTXT_WIDTH - len(description)) self.manager.log(manager.LOG_HIGH, description, before=1, after=0) for deleter in self.end_deletes: req = request() req.method = "DELETE" req.ruri = deleter[0] if len(deleter[...
self.dname = value
dname = value
def readCommandLine(self): sname = "scripts/server/serverinfo.xml" pname = None dname = "scripts/tests" fnames = [] all = False options, args = getopt.getopt(sys.argv[1:], "s:p:dx:", ["all"]) # Process single options for option, value in options: if option == "-s": sname = value elif option == "-p": pname = value elif...
pretty=False
pretty=True
def masterScriptGen(V,dir): # s='' if buildEngine=='scons': s+="Import('*')\n" s+=processVars(V,dir) for env,ttype in installable.keys(): # one of shlib, staticlib, program if len(installable[(env,ttype)])==0: continue # commented temporarily # if you need this back, uncomment also the other lines marked by EXPLICIT_IN...
ret+=",%sLIBS=%s"%(fieldSep,toStr(libs))
ret+=",%sLIBS=%s['LIBS']+%s"%(fieldSep,env,toStr(libs))
def DelAndWarnNonexistentPath(x): if not exists(normpath(join(dirAbsPath,x))): warning("Include path `%s' is invalid, removed!"%(normpath(join(dirAbsPath,x)))) return False return True
if len(argv) < 4:
if len(argv) < 3:
def main(argv): global path_svnrepo, path_srcurl print """svnpull.py
assert fi.lineno() == lineno
assert fi.lineno() == lineno, (filename + ' ' + str(fi.lineno()) + ' ' + str(lineno))
def doit(inp) : '''Take a file object as input. The input is the text report produced by Checkstyle. It is processed for violations.''' filename = None for l in inp.xreadlines() : if re.search(r"'\(' is preceded with whitespace", l) : m = re.search(r'^(.*?):(.*?):(.*?):', l) assert m != None filename = m.group(1) li...
if os.islink(fname):
if os.path.islink(fname):
def _export_dir_to_system(self, fullpath): wspath = self._wspath(fullpath) # remove dangling files first for root, dirs, files in os.walk(fullpath, topdown=False): for name in files: fname = join(root, name) wsname = self._wspath(fname) if not os.path.exists(wsname) and not os.path.islink(wsname): print 'removing', fna...
if os.getuid != 0:
if os.getuid() != 0:
def __init__(self, cfg): self.maincfg = cfg self.cfg = EtcSvnConfig() self.workspace = self.maincfg.get('workspace', 'wcpath') self.svn = pysvn.Client() self.repos_url = self.maincfg.get('repos', 'url') if os.getuid != 0: print 'EtcSvn must be run as root' raise RuntimeError os.umask(077)
raise RuntimeError
sys.exit(1)
def __init__(self, cfg): self.maincfg = cfg self.cfg = EtcSvnConfig() self.workspace = self.maincfg.get('workspace', 'wcpath') self.svn = pysvn.Client() self.repos_url = self.maincfg.get('repos', 'url') if os.getuid != 0: print 'EtcSvn must be run as root' raise RuntimeError os.umask(077)
for root, dirs, files in os.walk(self.workspace, topdown=False): for name in files: os.remove(join(root, name)) for name in dirs: os.rmdir(join(root, name)) os.rmdir(self.workspace)
if os.path.isdir(self.workspace): for root, dirs, files in os.walk(self.workspace, topdown=False): for name in files: os.remove(join(root, name)) for name in dirs: os.rmdir(join(root, name)) os.rmdir(self.workspace) else: print 'No workspace is present'
def remove_workspace(self): # copied from python library reference for root, dirs, files in os.walk(self.workspace, topdown=False): for name in files: os.remove(join(root, name)) for name in dirs: os.rmdir(join(root, name)) os.rmdir(self.workspace)
def print_record_list_for_similarity_boxen(req, title, recID_score_list, ln=cdslang):
def print_record_list_for_similarity_boxen(req, title, recID_score_list, ln=cdslang, search_pattern=''):
def print_record_list_for_similarity_boxen(req, title, recID_score_list, ln=cdslang): """Print list of records in the "hs" (HTML Similarity) format for similarity boxes. FIXME: templatize. """ recID_score_list_to_be_printed = [] # firstly find 5 first public records to print: nb_records_to_be_printed = 0 nb_records_see...
(score,print_record(recID, format="hs", ln=ln)))
(score,print_record(recID, format="hs", ln=ln, search_pattern=search_pattern, uid=uid)))
def print_record_list_for_similarity_boxen(req, title, recID_score_list, ln=cdslang): """Print list of records in the "hs" (HTML Similarity) format for similarity boxes. FIXME: templatize. """ recID_score_list_to_be_printed = [] # firstly find 5 first public records to print: nb_records_to_be_printed = 0 nb_records_see...
def print_records(req, recIDs, jrec=1, rg=10, format='hb', ot='', ln=cdslang, relevances=[], relevances_prologue="(", relevances_epilogue="%%)", decompress=zlib.decompress):
def print_records(req, recIDs, jrec=1, rg=10, format='hb', ot='', ln=cdslang, relevances=[], relevances_prologue="(", relevances_epilogue="%%)", decompress=zlib.decompress, search_pattern=''):
def print_records(req, recIDs, jrec=1, rg=10, format='hb', ot='', ln=cdslang, relevances=[], relevances_prologue="(", relevances_epilogue="%%)", decompress=zlib.decompress): """Prints list of records 'recIDs' formatted accoding to 'format' in groups of 'rg' starting from 'jrec'. Assumes that the input list 'recIDs' is ...
req.write(print_record(recIDs[irec], format, ot, ln))
req.write(print_record(recIDs[irec], format, ot, ln, search_pattern=search_pattern, uid=uid))
def print_records(req, recIDs, jrec=1, rg=10, format='hb', ot='', ln=cdslang, relevances=[], relevances_prologue="(", relevances_epilogue="%%)", decompress=zlib.decompress): """Prints list of records 'recIDs' formatted accoding to 'format' in groups of 'rg' starting from 'jrec'. Assumes that the input list 'recIDs' is ...
x = print_record(recIDs[irec], format, ot, ln)
x = print_record(recIDs[irec], format, ot, ln, search_pattern=search_pattern, uid=uid)
def print_records(req, recIDs, jrec=1, rg=10, format='hb', ot='', ln=cdslang, relevances=[], relevances_prologue="(", relevances_epilogue="%%)", decompress=zlib.decompress): """Prints list of records 'recIDs' formatted accoding to 'format' in groups of 'rg' starting from 'jrec'. Assumes that the input list 'recIDs' is ...
temp['record'] = print_record(recIDs[irec], format, ot, ln)
temp['record'] = print_record(recIDs[irec], format, ot, ln, search_pattern=search_pattern, uid=uid)
def print_records(req, recIDs, jrec=1, rg=10, format='hb', ot='', ln=cdslang, relevances=[], relevances_prologue="(", relevances_epilogue="%%)", decompress=zlib.decompress): """Prints list of records 'recIDs' formatted accoding to 'format' in groups of 'rg' starting from 'jrec'. Assumes that the input list 'recIDs' is ...
'record' : print_record(recIDs[irec], format, ot, ln),
'record' : print_record(recIDs[irec], format, ot, ln, search_pattern=search_pattern, uid=uid),
def print_records(req, recIDs, jrec=1, rg=10, format='hb', ot='', ln=cdslang, relevances=[], relevances_prologue="(", relevances_epilogue="%%)", decompress=zlib.decompress): """Prints list of records 'recIDs' formatted accoding to 'format' in groups of 'rg' starting from 'jrec'. Assumes that the input list 'recIDs' is ...
def print_record(recID, format='hb', ot='', ln=cdslang, decompress=zlib.decompress):
def print_record(recID, format='hb', ot='', ln=cdslang, decompress=zlib.decompress, search_pattern=None, uid=None):
def print_record(recID, format='hb', ot='', ln=cdslang, decompress=zlib.decompress): "Prints record 'recID' formatted accoding to 'format'." _ = gettext_set_language(ln) out = "" # sanity check: record_exist_p = record_exists(recID) if record_exist_p == 0: # doesn't exist return out # print record opening tags, if ...
out_record_in_format = call_bibformat(recID, format)
out_record_in_format = call_bibformat(recID, format, ln, search_pattern=search_pattern, uid=uid)
def print_record(recID, format='hb', ot='', ln=cdslang, decompress=zlib.decompress): "Prints record 'recID' formatted accoding to 'format'." _ = gettext_set_language(ln) out = "" # sanity check: record_exist_p = record_exists(recID) if record_exist_p == 0: # doesn't exist return out # print record opening tags, if ...
out += call_bibformat(recID, format)
out += call_bibformat(recID, format, ln, search_pattern=search_pattern, uid=uid)
def print_record(recID, format='hb', ot='', ln=cdslang, decompress=zlib.decompress): "Prints record 'recID' formatted accoding to 'format'." _ = gettext_set_language(ln) out = "" # sanity check: record_exist_p = record_exists(recID) if record_exist_p == 0: # doesn't exist return out # print record opening tags, if ...
def call_bibformat(recID, format="HD"):
def call_bibformat(recID, format="HD", ln=cdslang, search_pattern=None, uid=None):
def call_bibformat(recID, format="HD"): """Calls BibFormat for the record RECID in the desired output format FORMAT. This function is mainly used to display all but brief formats, if they are not stored in the 'bibfmt' table. Note: this functions always try to return HTML, so when bibformat returns XML with embedded H...
out = "" pipe_input, pipe_output, pipe_error = os.popen3(["%s/bibformat" % bindir, "otype=%s" % format], 'rw') pipe_input.write(print_record(recID, "xm")) pipe_input.close() bibformat_output = pipe_output.read() pipe_output.close() pipe_error.close() if bibformat_output.startswith("<record>"): dom = minidom.parseString...
if use_old_bibformat: out = "" pipe_input, pipe_output, pipe_error = os.popen3(["%s/bibformat" % bindir, "otype=%s" % format], 'rw') pipe_input.write(get_xml(recID, "xm")) pipe_input.close() bibformat_output = pipe_output.read() pipe_output.close() pipe_error.close() if bibformat_output.startswith("<record>"): dom = m...
def call_bibformat(recID, format="HD"): """Calls BibFormat for the record RECID in the desired output format FORMAT. This function is mainly used to display all but brief formats, if they are not stored in the 'bibfmt' table. Note: this functions always try to return HTML, so when bibformat returns XML with embedded H...
out = bibformat_output return out
return format_record(recID, of=format, ln=ln, search_pattern=search_pattern, uid=uid)
def call_bibformat(recID, format="HD"): """Calls BibFormat for the record RECID in the desired output format FORMAT. This function is mainly used to display all but brief formats, if they are not stored in the 'bibfmt' table. Note: this functions always try to return HTML, so when bibformat returns XML with embedded H...
print_records(req, range(recid,recidb), -1, -9999, of, ot, ln)
print_records(req, range(recid,recidb), -1, -9999, of, ot, ln, search_pattern=p)
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg=10, sf="", so="d", sp="", rm="", of="id", ot="", as=0, p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc=0, jrec=0, recid=-1, recidb=-1, sysno="", id=-1, idb=-1, sysnb="", action="", d1y=0, d1m=0, d1d=0, d2y=0, d2m=0...
results_similar_relevances, results_similar_relevances_prologue, results_similar_relevances_epilogue)
results_similar_relevances, results_similar_relevances_prologue, results_similar_relevances_epilogue, search_pattern=p)
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg=10, sf="", so="d", sp="", rm="", of="id", ot="", as=0, p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc=0, jrec=0, recid=-1, recidb=-1, sysno="", id=-1, idb=-1, sysnb="", action="", d1y=0, d1m=0, d1d=0, d2y=0, d2m=0...
print_records(req, results_cocited_recIDs, jrec, rg, of, ot, ln)
print_records(req, results_cocited_recIDs, jrec, rg, of, ot, ln, search_pattern=p)
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg=10, sf="", so="d", sp="", rm="", of="id", ot="", as=0, p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc=0, jrec=0, recid=-1, recidb=-1, sysno="", id=-1, idb=-1, sysnb="", action="", d1y=0, d1m=0, d1d=0, d2y=0, d2m=0...
results_final_relevances, results_final_relevances_prologue, results_final_relevances_epilogue)
results_final_relevances, results_final_relevances_prologue, results_final_relevances_epilogue, search_pattern=p)
def perform_request_search(req=None, cc=cdsname, c=None, p="", f="", rg=10, sf="", so="d", sp="", rm="", of="id", ot="", as=0, p1="", f1="", m1="", op1="", p2="", f2="", m2="", op2="", p3="", f3="", m3="", sc=0, jrec=0, recid=-1, recidb=-1, sysno="", id=-1, idb=-1, sysnb="", action="", d1y=0, d1m=0, d1d=0, d2y=0, d2m=0...
<form action="%(weburl)s/yourbaskets.py/add" method="post">
<form action="%(weburl)s/yourbaskets/add" method="post">
def tmpl_records_format_htmlbrief(self, ln, weburl, rows, relevances_prologue, relevances_epilogue): """Returns the htmlbrief format of the records
if options.module_install_path is None:
if not options.module_install_path:
def main(): """Generate the build tree and the Makefiles """ options, args = parse_args() print 'Command line options:' pprint.pprint(options.__dict__) print configuration = get_pyqt_configuration(options) options = check_sip(configuration, options) options = check_os(configuration, options) options = check_compiler...
while options.extra_libs.count('qwt'): options.extra_libs.remove('qwt') elif 'qwt' not in options.extra_libs: options.extra_libs.append('qwt')
while options.extra_libs.count(qwt): options.extra_libs.remove(qwt) elif qwt not in options.extra_libs: options.extra_libs.append(qwt)
def setup_qwt5_build(configuration, options, package): """Setup the qwt package build """ if 'Qwt5' not in options.modules: return print 'Setup the qwt package build.' build_dir = options.qwt tmp_dir = 'tmp-%s' % options.qwt build_file = os.path.join(tmp_dir, '%s.sbf' % options.qwt) extra_sources = [] extra_headers =...
curve.setStyle(Qwt.QwtPlotCurve.Spline) curve.setCurveAttribute(Qwt.QwtPlotCurve.Xfy)
curve.setCurveType(Qwt.QwtPlotCurve.Xfy) curve.setStyle(Qwt.QwtPlotCurve.Lines) curveFitter = Qwt.QwtSplineCurveFitter() curveFitter.setSplineSize(150) curve.setCurveFitter(curveFitter)
def __init__(self, *args): Qt.QFrame.__init__(self, *args)
curve.setStyle(Qwt.QwtPlotCurve.Spline) curve.setCurveAttribute(Qwt.QwtPlotCurve.Periodic) curve.setCurveAttribute(Qwt.QwtPlotCurve.Parametric) curve.setSplineSize(200)
curve.setStyle(Qwt.QwtPlotCurve.Lines) curve.setCurveAttribute(Qwt.QwtPlotCurve.Fitted) curveFitter = Qwt.QwtSplineCurveFitter() curveFitter.setFitMode(Qwt.QwtSplineCurveFitter.ParametricSpline) curveFitter.setSplineSize(200) curve.setCurveFitter(curveFitter)
def __init__(self, *args): Qt.QFrame.__init__(self, *args)
curve.setStyle(Qwt.QwtPlotCurve.Spline) curve.setSplineSize(200)
curve.setStyle(Qwt.QwtPlotCurve.Lines) curve.setCurveAttribute(Qwt.QwtPlotCurve.Fitted) curveFitter = Qwt.QwtSplineCurveFitter() curveFitter.setSplineSize(200) curve.setCurveFitter(curveFitter)
def __init__(self, *args): Qt.QFrame.__init__(self, *args)
self.__plot.print_(p)
self.__plot.print_(printer)
def printPlot(self): printer = Qt.QPrinter(Qt.QPrinter.HighResolution) printer.setColorMode(Qt.QPrinter.Color) printDialog = Qt.QPrintDialog(printer) if printDialog.exec_(): self.__plot.print_(p)
install_dir = options.package_install_path,
install_dir = options.module_install_path,
def setup_iqt_build(configuration, options, package): """Setup the iqt package build """ if 'iqt' not in options.modules: return print 'Setup the iqt package build.' build_dir = options.iqt tmp_dir = 'tmp-' + build_dir build_file = os.path.join(tmp_dir, '%s.sbf' % options.iqt) # zap the temporary directory try: shut...
compileall.compile_dir(build_dir, 1, options.package_install_path)
compileall.compile_dir(build_dir, 1, options.module_install_path)
def setup_qwt5_build(configuration, options, package): """Setup the qwt package build """ if 'Qwt5' not in options.modules: return print 'Setup the qwt package build.' build_dir = options.qwt tmp_dir = 'tmp-%s' % options.qwt build_file = os.path.join(tmp_dir, '%s.sbf' % options.qwt) extra_sources = [] extra_headers =...
os.path.join(build_dir, '*.py*'))], options.package_install_path])
os.path.join(build_dir, '*.py*'))], options.module_install_path])
def setup_qwt5_build(configuration, options, package): """Setup the qwt package build """ if 'Qwt5' not in options.modules: return print 'Setup the qwt package build.' build_dir = options.qwt tmp_dir = 'tmp-%s' % options.qwt build_file = os.path.join(tmp_dir, '%s.sbf' % options.qwt) extra_sources = [] extra_headers =...
install_dir = options.package_install_path,
install_dir = options.module_install_path,
def setup_qwt5_build(configuration, options, package): """Setup the qwt package build """ if 'Qwt5' not in options.modules: return print 'Setup the qwt package build.' build_dir = options.qwt tmp_dir = 'tmp-%s' % options.qwt build_file = os.path.join(tmp_dir, '%s.sbf' % options.qwt) extra_sources = [] extra_headers =...
options.package_install_path = os.path.join( configuration.pyqt_mod_dir, 'Qwt5')
if options.module_install_path is None: options.module_install_path = os.path.join( configuration.pyqt_mod_dir, 'Qwt5')
def main(): """Generate the build tree and the Makefiles """ options, args = parse_args() print 'Command line options:' pprint.pprint(options.__dict__) print configuration = get_pyqt_configuration(options) options = check_sip(configuration, options) options = check_os(configuration, options) options = check_compiler...
perc_unsure = 100.0 * self.num_unsure / num_seen
perc_unsure = 100.0 * num_unsure / num_seen
def GetStats(self, session_only=False): """Return a description of the statistics.
self.open('r')
if Options.options["Hammie", "train_on_filter"]: self.open('c') else: self.open('r')
def filter(self, msg): self.open('r') return self.h.filter(msg)
opts, args = getopt.getopt(sys.argv[1:], 'hxd:p:nfgstGSo:', ['help', 'examples', 'option='])
opts, args = getopt.getopt(sys.argv[1:], 'hvxd:p:nfgstGSo:', ['help', 'version', 'examples', 'option='])
def main(): h = HammieFilter() actions = [] opts, args = getopt.getopt(sys.argv[1:], 'hxd:p:nfgstGSo:', ['help', 'examples', 'option=']) create_newdb = False for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-x', '--examples'): examples() elif opt in ('-o', '--option'): Options.options.set_from_c...
except self.manager.message_storeMsgStoreException, details: if "0x80070005" in details:
except self.manager.message_store.MsgStoreException, details: hr, msg, exc, argErr = details.mapi_exception if hr == winerror.E_ACCESSDENIED:
def _CheckSelectionsValid(self, is_close = False): if self.in_check_selections_valid: return self.in_check_selections_valid = True try: if self.single_select: if is_close: # Make sure one is selected. for ignore in self._YieldCheckedChildren(): break else: self.manager.ReportInformation("You must select a folder") retu...
domain_guess = options["pop3proxy", "remote_servers"][0] for pre in ["pop.", "pop3.", "mail.",]: if domain_guess.startswith(pre): domain_guess = domain_guess[len(pre):]
remote_servers = options["pop3proxy", "remote_servers"] if remote_servers: domain_guess = remote_servers[0] for pre in ["pop.", "pop3.", "mail.",]: if domain_guess.startswith(pre): domain_guess = domain_guess[len(pre):] else: domain_guess = "[YOUR ISP]"
def onBugreport(self): """Create a message to post to spambayes@python.org that hopefully has enough information for us to help this person with their problem.""" self._writePreamble("Send Help Message", ("help", "Help")) report = self.html.bugreport.clone() # Prefill the report sb_ver = Version.get_version_string(self...
parms[name[:-2]].append(value)
parms[name[:-2]] += (value,)
def verifyInput(self, parms): '''Check that the given input is valid.''' # Most of the work here is done by the options class, but # we may have a few extra checks that are beyond its capabilities errmsg = ''
for r in [FLAGS_RE, INTERNALDATE_RE, RFC822_RE, UID_RE]:
for r in [FLAGS_RE, INTERNALDATE_RE, RFC822_RE, UID_RE, RFC822_HEADER_RE]:
def _extract_fetch_data(response): '''Extract data from the response given to an IMAP FETCH command.''' # response might be a tuple containing literal data if type(response) == types.TupleType: literal = response[1] response = response[0] else: literal = None # the first item will always be the message number mo = FETC...
self[options["pop3proxy", "mailid_header_name"]] = self.id
def Save(self): '''Save message to imap server.''' # we can't actually update the message with IMAP # so what we do is create a new message and delete the old one if self.folder is None: raise RuntimeError, """Can't save a message that doesn't have a folder.""" if self.id is None: raise RuntimeError, """Can't save a me...
response = imap.uid("SEARCH", "HEADER", options["pop3proxy", "mailid_header_name"], self.id)
response = imap.uid("SEARCH", "(UNDELETED HEADER " + \ options["pop3proxy", "mailid_header_name"] + \ " " + self.id + ")")
def Save(self): '''Save message to imap server.''' # we can't actually update the message with IMAP # so what we do is create a new message and delete the old one if self.folder is None: raise RuntimeError, """Can't save a message that doesn't have a folder.""" if self.id is None: raise RuntimeError, """Can't save a me...
self.rfc822_command = "RFC822.PEEK"
def __init__(self, folder_name): self.name = folder_name self.rfc822_command = "RFC822.PEEK" # Unique names for cached messages - see _generate_id below. self.lastBaseMessageName = '' self.uniquifier = 2
response = imap.uid("FETCH", key, self.rfc822_command) if response[0] != "OK": self.rfc822_command = "RFC822" response = imap.uid("FETCH", key, self.rfc822_command) self._check(response, "uid fetch")
response = imap.uid("FETCH", key, "RFC822.HEADER") self._check(response, "uid fetch header lines")
def __getitem__(self, key): '''Return message matching the given uid''' imap.SelectFolder(self.name) # We really want to use RFC822.PEEK here, as that doesn't effect # the status of the message. Unfortunately, it appears that not # all IMAP servers support this, even though it is in RFC1730 response = imap.uid("FETCH"...
messageText = data["RFC822"] msg = imapmessage_from_string(messageText)
msg = IMAPMessage()
def __getitem__(self, key): '''Return message matching the given uid''' imap.SelectFolder(self.name) # We really want to use RFC822.PEEK here, as that doesn't effect # the status of the message. Unfortunately, it appears that not # all IMAP servers support this, even though it is in RFC1730 response = imap.uid("FETCH"...
msg.uid = data["UID"] if msg.setIdFromPayload() is None:
msg.uid = key r = re.compile(re.escape(options["pop3proxy", "mailid_header_name"]) + \ "\:\s*(\d+(\-\d)?)") mo = r.search(data["RFC822.HEADER"]) if mo is None:
def __getitem__(self, key): '''Return message matching the given uid''' imap.SelectFolder(self.name) # We really want to use RFC822.PEEK here, as that doesn't effect # the status of the message. Unfortunately, it appears that not # all IMAP servers support this, even though it is in RFC1730 response = imap.uid("FETCH"...
parent = parent.GetParent()
try: parent = parent.GetParent() except MsgStoreException: break
def GetFQName(self): parts = [] parent = self while parent is not None: parts.insert(0, parent.name) parent = parent.GetParent() # We now end up with [0] being an empty string??, [1] being the # information store root folder name, etc. Outlook etc all just # use the information store name here. if not parts[0]: del pa...
if not parts[0]:
if parts and not parts[0]:
def GetFQName(self): parts = [] parent = self while parent is not None: parts.insert(0, parent.name) parent = parent.GetParent() # We now end up with [0] being an empty string??, [1] being the # information store root folder name, etc. Outlook etc all just # use the information store name here. if not parts[0]: del pa...
folder = self.msgstore._OpenEntry(self.id) prop_ids = PR_PARENT_ENTRYID, hr, data = folder.GetProps(prop_ids,0) parent_eid = data[0][1] parent_id = self.id[0], parent_eid if hr != 0 or \ self.msgstore.session.CompareEntryIDs(parent_eid, self.id[1]): return None parent = self.msgstore._OpenEntry(parent_id) return sel...
try: folder = self.msgstore._OpenEntry(self.id) prop_ids = PR_PARENT_ENTRYID, hr, data = folder.GetProps(prop_ids,0) parent_eid = data[0][1] parent_id = self.id[0], parent_eid if hr != 0 or \ self.msgstore.session.CompareEntryIDs(parent_eid, self.id[1]): return None parent = self.msgstore._OpenEntry(parent_id) retur...
def GetParent(self): # return a folder object with the parent, or None folder = self.msgstore._OpenEntry(self.id) prop_ids = PR_PARENT_ENTRYID, hr, data = folder.GetProps(prop_ids,0) # Put parent ids together parent_eid = data[0][1] parent_id = self.id[0], parent_eid if hr != 0 or \ self.msgstore.session.CompareEntryID...
table.SetColumns(MAPIMsgStoreMsg.message_init_props, 0)
def GetMessageGenerator(self, only_filter_candidates = True): folder = self.OpenEntry() table = folder.GetContentsTable(0) if only_filter_candidates: # Limit ourselves to IPM.* objects - ie, messages. restriction = (mapi.RES_PROPERTY, # a property restriction (mapi.RELOP_GE, # >= PR_MESSAGE_CLASS_A, # of the t...
sc_re = re.compile("%s:(.*)\n" % \
sc_re = re.compile("%s:\s*([\d.]+)" % \
def onClassify(self, file, text, which): """Classify an uploaded or pasted message.""" message = file or text message = message.replace('\r\n', '\n').replace('\r', '\n') # For Macs results = self._buildCluesTable(message) results.classifyAnother = self._buildClassifyBox() self._writePreamble("Classify") self.write(resu...
content_type = f.info().get('content-type') if content_type is None or \ not content_type.startswith("text/html"): self.bad_urls["url:non_html"] += (url,) return ["url:non_html"] page = f.read() headers = str(f.info()) f.close()
try: content_type = f.info().get('content-type') if content_type is None or \ not content_type.startswith("text/html"): self.bad_urls["url:non_html"] += (url,) return ["url:non_html"] page = f.read() headers = str(f.info()) f.close() except socket.error: return []
def slurp(self, proto, url): # We generate these tokens: # url:non_resolving # url:non_html # url:http_XXX (for each type of http error encounted, # for example 404, 403, ...) # And tokenise the received page (but we do not slurp this). # Actually, the special url: tokens barely showed up in my testin...
print " %s trained." % (num_ham_trained)
print "\n %s trained." % (num_ham_trained)
def Train(self): if options["globals", "verbose"]: t = time.time()
print " %s trained." % (num_spam_trained)
print "\n %s trained." % (num_spam_trained)
def Train(self): if options["globals", "verbose"]: t = time.time()
self.manager.EnsureOutlookFieldsForFolder(msgstore_folder.GetID())
try: self.manager.EnsureOutlookFieldsForFolder(msgstore_folder.GetID()) except: print "ERROR: Failed to check folder '%s' for " \ "Spam field" % name etype, value, tb = sys.exc_info() tb = None traceback.print_exception(etype, value, tb)
def _HookFolderEvents(self, folder_ids, include_sub, HandlerClass): new_hooks = {} for msgstore_folder in self.manager.message_store.GetFolderGenerator( folder_ids, include_sub): existing = self.folder_hooks.get(msgstore_folder.id) if existing is None or existing.__class__ != HandlerClass: folder = msgstore_folder.GetO...
def RegisterAddin(klass):
def _DoRegister(klass, root):
def RegisterAddin(klass): # prints to help debug binary install issues. import _winreg key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Outlook\\Addins") subkey = _winreg.CreateKey(key, klass._reg_progid_) _winreg.SetValueEx(subkey, "CommandLineSafe", 0, _winreg.REG_DWORD, 0) _winreg.Set...
key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER,
key = _winreg.CreateKey(root,
def RegisterAddin(klass): # prints to help debug binary install issues. import _winreg key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Outlook\\Addins") subkey = _winreg.CreateKey(key, klass._reg_progid_) _winreg.SetValueEx(subkey, "CommandLineSafe", 0, _winreg.REG_DWORD, 0) _winreg.Set...
print "Training on message '%s' - " % subject,
print "Training on message '%s' in '%s - " % \ (subject, msgstore_message.GetFolder().GetFQName()),
def TrainAsHam(msgstore_message, manager, rescore = True): import train subject = msgstore_message.subject print "Training on message '%s' - " % subject, if train.train_message(msgstore_message, False, manager.classifier_data): print "trained as good" # Simplest way to rescore is to re-filter with all_actions = False i...
print "Training on message '%s' - " % subject,
print "Training on message '%s' in '%s - " % \ (subject, msgstore_message.GetFolder().GetFQName()),
def TrainAsSpam(msgstore_message, manager, rescore = True): import train subject = msgstore_message.subject print "Training on message '%s' - " % subject, if train.train_message(msgstore_message, True, manager.classifier_data): print "trained as spam" # Simplest way to rescore is to re-filter with all_actions = False i...
print "Message '%s' had a Spam classification of '%s'" \ % (msgstore_message.GetSubject(), disposition)
print "Message '%s' in '%s' had a Spam classification of '%s'" \ % (msgstore_message.GetSubject(), folder_name, disposition)
def ProcessMessage(msgstore_message, manager): manager.LogDebug(2, "ProcessMessage starting for message '%s'" \ % msgstore_message.subject) try: if not msgstore_message.IsFilterCandidate(): manager.LogDebug(1, "Skipping message '%s' - we don't filter ones like that!" \ % msgstore_message.subject) return if HaveSeenMes...
manager.LogDebug(2, "ProcessMessage finished for", msgstore_message)
manager.LogDebug(2, "ProcessMessage finished for", msgstore_message.subject)
def ProcessMessage(msgstore_message, manager): manager.LogDebug(2, "ProcessMessage starting for message '%s'" \ % msgstore_message.subject) try: if not msgstore_message.IsFilterCandidate(): manager.LogDebug(1, "Skipping message '%s' - we don't filter ones like that!" \ % msgstore_message.subject) return if HaveSeenMes...
HamFolderItemsEvent)
HamFolderItemsEvent, "filtering")
def UpdateFolderHooks(self): config = self.manager.config.filter new_hooks = {} new_hooks.update( self._HookFolderEvents(config.watch_folder_ids, config.watch_include_sub, HamFolderItemsEvent) ) # For spam manually moved if config.spam_folder_id: new_hooks.update( self._HookFolderEvents([config.spam_folder_id], False, ...
SpamFolderItemsEvent)
SpamFolderItemsEvent, "incremental training")
def UpdateFolderHooks(self): config = self.manager.config.filter new_hooks = {} new_hooks.update( self._HookFolderEvents(config.watch_folder_ids, config.watch_include_sub, HamFolderItemsEvent) ) # For spam manually moved if config.spam_folder_id: new_hooks.update( self._HookFolderEvents([config.spam_folder_id], False, ...
def _HookFolderEvents(self, folder_ids, include_sub, HandlerClass):
def _HookFolderEvents(self, folder_ids, include_sub, HandlerClass, what):
def _HookFolderEvents(self, folder_ids, include_sub, HandlerClass): new_hooks = {} for msgstore_folder in self.manager.message_store.GetFolderGenerator( folder_ids, include_sub): existing = self.folder_hooks.get(msgstore_folder.id) if existing is None or existing.__class__ != HandlerClass: name = msgstore_folder.GetFQN...
print "SpamBayes: Watching for new messages in folder", name
print "SpamBayes: Watching (for %s) in '%s'" % (what, name)
def _HookFolderEvents(self, folder_ids, include_sub, HandlerClass): new_hooks = {} for msgstore_folder in self.manager.message_store.GetFolderGenerator( folder_ids, include_sub): existing = self.folder_hooks.get(msgstore_folder.id) if existing is None or existing.__class__ != HandlerClass: name = msgstore_folder.GetFQN...
regimes = []
rules = []
def main(): group_action = None guess_action = None regime = "perfect" which = None opts, args = getopt.getopt(sys.argv[1:], 's:r:', ['help', 'examples']) for opt, arg in opts: if opt == '-s': which = int(arg) - 1 if opt == '-r': regime = arg nsets = len(glob.glob("Data/Ham/Set*")) files = glob.glob("Data/*/Set*/*"...
exec """regimes.append(regimes.%s())""" % (regime) in globals(), locals()
exec """rules.append(regimes.%s())""" % (regime) in globals(), locals()
def main(): group_action = None guess_action = None regime = "perfect" which = None opts, args = getopt.getopt(sys.argv[1:], 's:r:', ['help', 'examples']) for opt, arg in opts: if opt == '-s': which = int(arg) - 1 if opt == '-r': regime = arg nsets = len(glob.glob("Data/Ham/Set*")) files = glob.glob("Data/*/Set*/*"...
sys.stderr.write("%-78s\r" % ("%s : %d" % (base, set))) sys.stderr.flush()
def main(): group_action = None guess_action = None regime = "perfect" which = None opts, args = getopt.getopt(sys.argv[1:], 's:r:', ['help', 'examples']) for opt, arg in opts: if opt == '-s': which = int(arg) - 1 if opt == '-r': regime = arg nsets = len(glob.glob("Data/Ham/Set*")) files = glob.glob("Data/*/Set*/*"...
regimes[j].group_action(j, tests[j])
rules[j].group_action(j, tests[j])
def main(): group_action = None guess_action = None regime = "perfect" which = None opts, args = getopt.getopt(sys.argv[1:], 's:r:', ['help', 'examples']) for opt, arg in opts: if opt == '-s': which = int(arg) - 1 if opt == '-r': regime = arg nsets = len(glob.glob("Data/Ham/Set*")) files = glob.glob("Data/*/Set*/*"...
todo = regimes[j].guess_action(j, tests[j], guess, actual, msg)
todo = rules[j].guess_action(j, tests[j], guess, actual, msg)
def main(): group_action = None guess_action = None regime = "perfect" which = None opts, args = getopt.getopt(sys.argv[1:], 's:r:', ['help', 'examples']) for opt, arg in opts: if opt == '-s': which = int(arg) - 1 if opt == '-r': regime = arg nsets = len(glob.glob("Data/Ham/Set*")) files = glob.glob("Data/*/Set*/*"...
def OEAccountKeys(permission = win32con.KEY_READ | win32con.KEY_SET_VALUE):
def OEAccountKeys(permission = None):
def OEAccountKeys(permission = win32con.KEY_READ | win32con.KEY_SET_VALUE): """Return registry keys for each of the OE mail accounts, along with information about what type of mail account it is.""" possible_root_keys = [] # This appears to be the place for OE6 and WinXP # (So I'm guessing also for NT4) if sys.getwind...
DEBUG = False
def __setstate__(self, t): (self.atime, self.spamcount, self.hamcount, self.killcount, self.spamprob) = t
if self.DEBUG: print "spamprob(%r)" % wordstream
def xspamprob(self, wordstream, evidence=False): """Return best-guess probability that wordstream is spam.
if self.DEBUG: print 'nbest P(%r) = %g' % (word, prob)
def xspamprob(self, wordstream, evidence=False): """Return best-guess probability that wordstream is spam.
if self.DEBUG: print 'New probabilities:' for w, r in self.wordinfo.iteritems(): print "P(%r) = %g" % (w, r.spamprob)
def update_probabilities(self): """Update the word probabilities in the spam database.
if self.DEBUG: print "clearjunk removing word %r: %r" % (w, r)
def clearjunk(self, oldesttime): """Forget useless wordinfo records. This can shrink the database size.