rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if sys.exc_info() != (None,None,None):
if capture_traceback and sys.exc_info() != (None,None,None):
def __init__(self,fn='rl_dbgmemo.dbg',mode='w',getScript=1,modules=(),**kw): import time, socket self.fn = fn if mode!='w': return self.store = store = {} if sys.exc_info() != (None,None,None): import traceback s = getStringIO() traceback.print_exc(None,s) store['__traceback'] = s.getvalue() cwd=os.getcwd() lcwd = os.l...
S = self._CPage and [CondPageBreak(aH+1)] or []
S = getattr(self,'_CPage',1) and [CondPageBreak(aH+1)] or []
def split(self, aW, aH): S = self._CPage and [CondPageBreak(aH+1)] or [] for f in self._flowables: S.append(f) return S
f.write(str(self.startxref) + LINEEND)
f.write(('%d' % self.startxref) + LINEEND)
def writeTrailer(self, f): f.write('trailer' + LINEEND) f.write('<< /Size %d /Root %d 0 R /Info %d 0 R>>' % (len(self.objects) + 1, 1, self.infopos) + LINEEND) f.write('startxref' + LINEEND) f.write(str(self.startxref) + LINEEND)
fn = float(len(P)) return reduce(lambda x,y: (x[0]+y[0]/fn,x[1]+y[1]/fn),P,(0,0))
return reduce(lambda x,y, fn=float(len(P)): (x[0]+y[0]/fn,x[1]+y[1]/fn),P,(0,0))
def centroid(P): '''compute average point of a set of points''' fn = float(len(P)) return reduce(lambda x,y: (x[0]+y[0]/fn,x[1]+y[1]/fn),P,(0,0))
def goodTest(x,t,tb=0,**kw):
def goodTest(x,t,tb=0,inOnly=0,**kw):
def goodTest(x,t,tb=0,**kw): try: P=_pyRXP.Parser(**kw) r = P(x) rb = 0 except: et, ev, _unused = sys.exc_info() r = '%s %s' % (et.__name__, str(ev)) rb = 1 s = '' for k,v in kw.items(): s = s+', %s=%s' % (k,str(v)) if type(t) is type(''): t = t.replace('\r','\\r') t = t.replace('\n','\\n') if type(r) is type(''): r =...
if r==t and rb==tb:
if (inOnly and t in r) or (r==t) and rb==tb:
def goodTest(x,t,tb=0,**kw): try: P=_pyRXP.Parser(**kw) r = P(x) rb = 0 except: et, ev, _unused = sys.exc_info() r = '%s %s' % (et.__name__, str(ev)) rb = 1 s = '' for k,v in kw.items(): s = s+', %s=%s' % (k,str(v)) if type(t) is type(''): t = t.replace('\r','\\r') t = t.replace('\n','\\n') if type(r) is type(''): r =...
def failTest(x,t,tb=1,**kw): goodTest(x,t,tb,**kw)
def failTest(x,t,tb=1,inOnly=0,**kw): goodTest(x,t,tb,inOnly=inOnly,**kw) def bigDepth(n): return n and '<tag%d>%s</tag%d>' % (n,bigDepth(n-1),n) or 'middle'
def failTest(x,t,tb=1,**kw): goodTest(x,t,tb,**kw)
failTest(bigDepth(257),"""Error Internal error, stack limit reached!\n""", inOnly=1)
def _runTests(pyRXP): global _pyRXP _pyRXP = pyRXP print >>_logf, '############# Testing',pyRXP.__name__ try: for k,v in pyRXP.parser_flags.items(): eval('pyRXP.Parser(%s=%d)' % (k,v)) print >>_logf,'Parser keywords OK' _dot('.') except: traceback.print_exc() print >>_logf,'Parser keywords BAD' _dot('E') try: for k,v i...
c=s.fontsize,d=self.canv: d.stringWidth(a,b,c), v))
c=s.fontsize,d=d.stringWidth: d(a,b,c), v))
def _calc(self):
if op == 'GRID': self._drawBox( (sc, sr), (ec, er), weight, color) self._drawInnerGrid( (sc, sr), (ec, er), weight, color) elif op in ('BOX', 'OUTLINE',): self._drawBox( (sc, sr), (ec, er), weight, color) elif op == 'INNERGRID': self._drawInnerGrid( (sc, sr), (ec, er), weight, color) elif op == 'LINEBELOW': self._drawH...
getattr(self,_LineOpMap.get(op, '_drawUnknown' ))( (sc, sr), (ec, er), weight, color)
def _drawLines(self): for op, (sc, sr), (ec, er), weight, color in self._linecmds: if sc < 0: sc = sc + self._ncols if ec < 0: ec = ec + self._ncols if sr < 0: sr = sr + self._nrows if er < 0: er = er + self._nrows if op == 'GRID': self._drawBox( (sc, sr), (ec, er), weight, color) self._drawInnerGrid( (sc, sr), (ec, er...
self._calc()
def _splitRows(self,availHeight): self._calc() h = 0 n = 0 lim = len(self._rowHeights) while n<lim: hn = h + self._rowHeights[n] if hn>availHeight: break h = hn n = n + 1
y = rowpos + (cellstyle.bottomPadding + rowheight-cellstyle.topPadding+(n-1)*leading)/2.0+leading-fontsize
y = rowpos + (cellstyle.bottomPadding + rowheight-cellstyle.topPadding+(n-1)*leading)/2.0
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFil...
LINECOMMANDS = ( 'GRID', 'BOX', 'OUTLINE', 'INNERGRID', 'BOXGRID', 'LINEBELOW', 'LINEABOVE', 'LINEBEFORE', 'LINEAFTER', )
_LineOpMap = { 'GRID':'_drawGrid', 'BOX':'_drawBox', 'OUTLINE':'_drawBox', 'INNERGRID':'_drawInnerGrid', 'LINEBELOW':'_drawHLinesB', 'LINEABOVE':'_drawHLines', 'LINEBEFORE':'_drawVLines', 'LINEAFTER':'_drawVLinesA', } LINECOMMANDS = _LineOpMap.keys()
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFil...
t=apply(Table,([('Attribute', 'Synonyms'), ('alignment', 'align, alignment'), ('bulletColor', 'bulletcolor, bcolor'), ('bulletFontName', 'bfont, bulletfontname'), ('bulletFontSize', 'bfontsize, bulletfontsize'), ('bulletIndent', 'bindent, bulletindent'), ('firstLineIndent', 'findent, firstlineindent'), ('fontName', 'fa...
t = Table([ ('Attribute', 'Synonyms'), ('alignment', 'align, alignment'), ('bulletColor', 'bulletcolor, bcolor'), ('bulletFontName', 'bfont, bulletfontname'), ('bulletFontSize', 'bfontsize, bulletfontsize'), ('bulletIndent', 'bindent, bulletindent'), ('firstLineIndent', 'findent, firstlineindent'), ('fontName', 'face, ...
def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2,...
if W>maxWidth:
if W>maxWidth+_FUZZ:
def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H
if H<=maxHeight:
if H<=maxHeight-_FUZZ:
def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H
import glob
def bruteForceSearchForAFM(faceName): """Looks in all AFM files on path for face with given name. Returns AFM file name or None. Ouch!""" import glob from reportlab.rl_config import T1SearchPath for dirname in T1SearchPath: if not rl_isdir(dirname): continue possibles = glob.glob(dirname + os.sep + '*.[aA][fF][mM]')...
possibles = glob.glob(dirname + os.sep + '*.[aA][fF][mM]')
possibles = rl_glob(dirname + os.sep + '*.[aA][fF][mM]')
def bruteForceSearchForAFM(faceName): """Looks in all AFM files on path for face with given name. Returns AFM file name or None. Ouch!""" import glob from reportlab.rl_config import T1SearchPath for dirname in T1SearchPath: if not rl_isdir(dirname): continue possibles = glob.glob(dirname + os.sep + '*.[aA][fF][mM]')...
g.add(String(x+self.boxWidth/2.,(self.boxHeight-ascent)/2.),
g.add(String(x+self.boxWidth/2.,(self.boxHeight-ascent)/2.,
def draw(self): g = Group() ys = self.bottomPadding+(self.triangleHeight/2)+self.sourceLabelOffset+self.sourceLabelFontSize if self.background: x,y = self._getDrawingDimensions() g.add(Rect(-self.leftPadding,-ys,x,y, strokeColor=None, strokeWidth=0, fillColor=self.background))
fontSize = self.labelFontSize)
fontSize = self.labelFontSize))
def draw(self): g = Group() ys = self.bottomPadding+(self.triangleHeight/2)+self.sourceLabelOffset+self.sourceLabelFontSize if self.background: x,y = self._getDrawingDimensions() g.add(Rect(-self.leftPadding,-ys,x,y, strokeColor=None, strokeWidth=0, fillColor=self.background))
print 'Error: %s '+ cmdname or cmd
print 'Error: '+ cmdname or cmd
def do_exec(cmd, cmdname=None): i=os.popen(cmd,'r') print i.read() i = i.close() if i is not None: if cmdname is not None: print 'Error: %s '+ cmdname or cmd sys.exit(1)
_fonts[font.fontName] = font
fontName = str(font.fontName) _fonts[fontName] = font
def registerFont(font): "Registers a font, including setting up info for accelerated stringWidth" #assert isinstance(font, Font), 'Not a Font: %s' % font _fonts[font.fontName] = font if not font._multiByte: if _stringWidth: _rl_accel.setFontInfo(string.lower(font.fontName), _dummyEncoding, font.face.ascent, font.face.d...
_rl_accel.setFontInfo(string.lower(font.fontName),
_rl_accel.setFontInfo(string.lower(fontName),
def registerFont(font): "Registers a font, including setting up info for accelerated stringWidth" #assert isinstance(font, Font), 'Not a Font: %s' % font _fonts[font.fontName] = font if not font._multiByte: if _stringWidth: _rl_accel.setFontInfo(string.lower(font.fontName), _dummyEncoding, font.face.ascent, font.face.d...
text = self.labels[i] if text: si = self.strands[i] labelRadius = si.labelRadius ex = centerx + labelRadius*car ey = centery + labelRadius*sar L = Label() L.setText(text) L.x = ex L.y = ey L.boxAnchor = _findNearestAngleValue(angle*180/pi,_ANGLE2ANCHOR) L.fontName = si.fontName L.fontSize = si.fontSize L.fillColor = si...
if labels: text = labels[i] if text: si = self.strands[i] labelRadius = si.labelRadius ex = centerx + labelRadius*car ey = centery + labelRadius*sar L = Label() L.setText(text) L.x = ex L.y = ey L.boxAnchor = _findNearestAngleValue(angle*180/pi,_ANGLE2ANCHOR) L.fontName = si.fontName L.fontSize = si.fontSize L.fillColo...
def draw(self): # normalize slice data g = self.makeBackground() or Group()
p = [self.CX(i,0),self.CY(i,0), self.CX(i,1),self.CY(i,1), self.OX(i,angle,1),self.OY(i,angle,1), self.OX(i,angle,0),self.OY(i,angle,0)] L.append((rd,Polygon(p, strokeColor=strokeColor, fillColor=fillColor,strokeWidth=strokeWidth,strokeLineJoin=1)))
if abs(angle-_270r)>1e-6: p = [self.CX(i,0),self.CY(i,0), self.CX(i,1),self.CY(i,1), self.OX(i,angle,1),self.OY(i,angle,1), self.OX(i,angle,0),self.OY(i,angle,0)] L.append((rd,Polygon(p, strokeColor=strokeColor, fillColor=fillColor,strokeWidth=strokeWidth,strokeLineJoin=1)))
def _fillSide(self,L,i,angle,strokeColor,strokeWidth,fillColor): rd = self.rad_dist(angle) if rd<self.rad_dist(self._sl3d[i].mid): p = [self.CX(i,0),self.CY(i,0), self.CX(i,1),self.CY(i,1), self.OX(i,angle,1),self.OY(i,angle,1), self.OX(i,angle,0),self.OY(i,angle,0)] L.append((rd,Polygon(p, strokeColor=strokeColor, fil...
stripe = Rect(x, self.y, self.delta, h)
if x + self.delta > self.x + w: w1 = self.x + w - x else: w1 = self.delta stripe = Rect(x, self.y, w1, h)
def makeInnerTiles(self): # inner grid lines group = Group()
rmStripe = Rect(self.x + w - self.delta0, self.y, self.delta0, h)
rmStripe = Rect(x, self.y, self.x + w - x, h)
def makeInnerTiles(self): # inner grid lines group = Group()
stripe = Rect(self.x, y, w, self.delta)
if y + self.delta > self.y + w: h1 = self.y + w - y else: h1 = self.delta stripe = Rect(self.x, y, w, h1)
def makeInnerTiles(self): # inner grid lines group = Group()
umStripe = Rect(self.x, self.y + w - self.delta0, w, self.delta0)
umStripe = Rect(self.x, self.y + w - self.delta0, w, self.y + h - y)
def makeInnerTiles(self): # inner grid lines group = Group()
D = Drawing(450,650) for row in range(5): y = 530 - row*120
D = Drawing(450, 650) d = 80 s = 60 for row in range(10): y = 530 - row*d
def test(): D = Drawing(450,650) for row in range(5): y = 530 - row*120 if row == 0: for col in range(3): x = 20 + col*120 g = Grid0() g.x = x g.y = y g.useRects = 0 g.useLines = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 1: for col in ran...
x = 20 + col*120
x = 20 + col*d
def test(): D = Drawing(450,650) for row in range(5): y = 530 - row*120 if row == 0: for col in range(3): x = 20 + col*120 g = Grid0() g.x = x g.y = y g.useRects = 0 g.useLines = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 1: for col in ran...
canv = self.canv
canv = getattr(self,'canv',None)
def _listCellGeom(self, V,w,s,W=None,H=None): aW = w-s.leftPadding-s.rightPadding t = 0 w = 0 canv = self.canv for v in V: vw, vh = v.wrapOn(canv,aW, 72000) if W is not None: W.append(vw) if H is not None: H.append(vh) w = max(w,vw) t = t + vh + v.getSpaceBefore()+v.getSpaceAfter() return w, t - V[0].getSpaceBefore()-V...
path = [baseDir]
if type(baseDir) not in SeqTypes path = [baseDir] else: path = list(baseDir) path = filter(None,basDir)
def recursiveImport(modulename, baseDir=None, noCWD=0, debug=0): """Dynamically imports possible packagized module, or raises ImportError""" import imp parts = string.split(modulename, '.') name = parts[0] #this hosed my brain..redo it slowly (AR). #path = list(baseDir and (type(baseDir) not in SeqTypes and [baseDir]...
datafile=qpath+job[:-3]+"sff"
fileext="sff" if os.path.splitext(datafilename)[1].lower()==".cff": fileext="cff" datafile=qpath+job[:-3]+fileext
def removejob(user,jobid,cslist): if (checkconfig() == -1) or (checkfaxuser(user,1) == 0): raise CSConfigError if not listtypes.has_key(cslist) or CheckJobID(jobid)==-1: raise -1 qpath=BuildListPath(cslist,user) job ="" if listtypes[cslist][1]==1: job=user+"-" job=job+listtypes[cslist][0]+"-"+jobid+".txt" #job=prefix...
raise CSUserInputError("nvalid input (fax) file")
raise CSUserInputError("Invalid input (fax) file")
def sendfax(user,dialstring,sourcefile,cstarttime="",addressee="",subject="",useprefix=None): if (checkconfig == -1) or (checkfaxuser(user,1) == 0) or (not sourcefile): raise CSConfigError if not dialstring: raise CSUserInputError("empty dialstring") if ((cs_helpers.getOption(CAPI_config,user,"outgoing_MSN","")=="") a...
self.SaveRankingData() self.LoadRegattaRanking()
pass
def UpdateRegattaRanking(self): self.SaveRankingData() self.LoadRegattaRanking()
if str(value) == str(self.T_DetailRanking.item(s, 0).text()) and s != pos: return 0
if self.T_DetailRanking.item(s, 0): newVal = self.T_DetailRanking.item(s, 0).text() if str(value) == str(newVal) and s != pos: return 0
def ChechForSkipper(self, value, pos): for s in range(0, self.T_DetailRanking.rowCount()): if str(value) == str(self.T_DetailRanking.item(s, 0).text()) and s != pos: return 0
Ranks = {}
Ranks = {} risultati = datafile.options('result') if len(risultati) == 0: return
def LoadRegattaRanking(self): try: current_class = str(self.L_Regattas.currentItem().text()) if current_class[-1:] == '*': k = self.ShowQuestionDialog("Save data ?") if k == QtGui.QMessageBox.Yes: self.SaveRankingData(Regatta=current_class[:-1]) else: self.L_Regattas.currentItem().setText(current_class[:-1]) except: pa...
for c in range(0,len(Ranks[sk])):
lenRanks = len(Ranks[sk]) for c in range(0,lenRanks):
def LoadRegattaRanking(self): try: current_class = str(self.L_Regattas.currentItem().text()) if current_class[-1:] == '*': k = self.ShowQuestionDialog("Save data ?") if k == QtGui.QMessageBox.Yes: self.SaveRankingData(Regatta=current_class[:-1]) else: self.L_Regattas.currentItem().setText(current_class[:-1]) except: pa...
self.T_DetailRanking.insertColumn(self.T_DetailRanking.columnCount()-1)
def AddRace(self): self.T_DetailRanking.insertColumn(self.T_DetailRanking.columnCount()-1) cols = self.T_DetailRanking.columnCount() if cols == 2: self.T_DetailRanking.insertColumn(self.T_DetailRanking.columnCount()-1) cols += 1 TableHeader=[] for c in range(0, cols -1): TableHeader.append("%s %d"%("Race",(c))) TableHe...
def _element_content(self, element): """ Distill the textual content recursively. Added since I do not know how to use the lib for this. (Tuttle) """ out = "" for child in element.childNodes: if child.nodeType == ELEMENT_NODE: out += self._element_content(child) elif child.nodeType == xml.dom.minidom.Node.TEXT_NODE: o...
def _element_content(self, element): """ Distill the textual content recursively. Added since I do not know how to use the lib for this. (Tuttle) """
print >> sys.stderr, 'Assuming rendered msgid in %s, not included:\n%s\n' % \ (self._curr_fn, element.toprettyxml(' '))
print >> sys.stderr, 'Assuming rendered msgid in %s, not included:\n %s\n' % \ (self._curr_fn, element.toprettyxml(' ', '\n '))
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
msgid = self._element_content(element) print >> sys.stderr, 'Warning: Literal msgids should be avoided in %s, still adding:\n%s\n' % \ (self._curr_fn, element.toprettyxml(' '))
msgid = self._make_msgstr(element, shrink = False) print >> sys.stderr, 'Warning: Literal msgids should be avoided in %s, still adding:\n %s\n' % \ (self._curr_fn, element.toprettyxml(' ', '\n '))
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
msgstr = self._make_msgstr(element)
msgstr = self._make_msgstr(element, shrink = True)
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
print >> sys.stderr, 'Assuming rendered msgid in %s:\n%s\n' % \
print >> sys.stderr, 'Assuming rendered msgid in %s, not included:\n%s\n' % \
def _do_attributes(self, element, domain): rendered = [] if element.hasAttribute('tal:attributes'): attrs = element.getAttribute('tal:attributes').split(';') attrs = [attr.strip() for attr in attrs if attr.strip()] rendered = [attr.split()[0] for attr in attrs]
def _make_msgstr(self, element):
def _make_msgstr(self, element, shrink = True):
def _make_msgstr(self, element): node = copy.deepcopy(element) self._make_pretty(node) msgstr = '' for child in node.childNodes: chunk = child.toxml() # XXX Do we need to escape anything else? chunk = chunk.replace('"', '\\"') chunk = ' '.join(chunk.split()) msgstr += chunk + ' '
chunk = ' '.join(chunk.split()) msgstr += chunk + ' '
if shrink: chunk = ' '.join(chunk.split()) + ' ' msgstr += chunk
def _make_msgstr(self, element): node = copy.deepcopy(element) self._make_pretty(node) msgstr = '' for child in node.childNodes: chunk = child.toxml() # XXX Do we need to escape anything else? chunk = chunk.replace('"', '\\"') chunk = ' '.join(chunk.split()) msgstr += chunk + ' '
msgstr = msgstr.strip()
lines = msgstr.split("\n") for i in range(len(lines)): lines[i] = ' ' + lines[i].strip() msgstr = ''.join(lines).strip()
def read(self): """Reads in from all given ZPTs and builds up MessageCatalogs accordingly.
if msgid:
else:
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
attrs['i18n:attributes'].split(';')]
attrs['i18n:attributes'].split(';') if i18nattr]
def _valid_i18ned_attr(attr, attrs): """This returns 1 for attributes attr that are part of attrs and are translated using i18n:attributes. It also returns 1 for any attr that does not exist at all in attrs.""" if attrs.has_key(attr) and _translatable(attrs[attr]): if attrs.has_key('i18n:attributes'): if attrs['i18n:a...
for key in data_dict.keys():
for key in data_dict:
def merge(self,__loc_data__=None,__conflict_solve=None,**kw): """S.merge(data,conflict,k=v1,k=v2,...) -> merge data and k=v into S.
origins.append([sx[i]/dar[0], center[1], center[2]])
origins.append([sx[i], center[1], center[2]])
def _add_slices(self, item, sgrid, contours=False): cvector = item.get('cvector') center = sgrid.GetCenter() dar = self._axis.get('daspect') sx, sy, sz = item.get('slices') if len(shape(sx)) == 2 and shape(sx) == shape(sy) == shape(sz): s = Surface(sx,sy,sz) sgrid2 = self._get_2d_structured_grid(s) plane = vtk.vtkStruc...
origins.append([center[0], sy[i]/dar[1], center[2]])
origins.append([center[0], sy[i], center[2]])
def _add_slices(self, item, sgrid, contours=False): cvector = item.get('cvector') center = sgrid.GetCenter() dar = self._axis.get('daspect') sx, sy, sz = item.get('slices') if len(shape(sx)) == 2 and shape(sx) == shape(sy) == shape(sz): s = Surface(sx,sy,sz) sgrid2 = self._get_2d_structured_grid(s) plane = vtk.vtkStruc...
origins.append([center[0], center[1], sz[i]/dar[2]])
origins.append([center[0], center[1], sz[i]])
def _add_slices(self, item, sgrid, contours=False): cvector = item.get('cvector') center = sgrid.GetCenter() dar = self._axis.get('daspect') sx, sy, sz = item.get('slices') if len(shape(sx)) == 2 and shape(sx) == shape(sy) == shape(sz): s = Surface(sx,sy,sz) sgrid2 = self._get_2d_structured_grid(s) plane = vtk.vtkStruc...
assert shape == cdata.shape, \
assert v.shape == cdata.shape, \
def _parseargs_isosurface(self, *args): nargs = len(args) if nargs >= 5 and nargs <= 6: # isosurface(X,Y,Z,V,isovalue) x, y, z, v = _check_xyzv(*args[:4]) isovalue = float(args[4]) elif nargs >= 2 and nargs <= 3: # isosurface(V,isovalue) x, y, z, v = _check_xyzv(args[0]) isovalue = float(args[1]) else: raise TypeError,...
legendcounter=len(ax.get('plotitems'))
def plot(self, *args, **kwargs): """Draw line and scatter plots.
legendcounter = len(ax.get('plotitems'))-legendcounter
no_lines = len(lines)
def plot(self, *args, **kwargs): """Draw line and scatter plots.
if len(legends) == legendcounter: for i in range(legendcounter): legend = legends[legendcounter-i-1]
if len(legends) == no_lines: for i in range(no_lines): legend = legends[no_lines-i-1]
def plot(self, *args, **kwargs): """Draw line and scatter plots.
(len(legends), legendcounter)
(len(legends), no_lines)
def plot(self, *args, **kwargs): """Draw line and scatter plots.
for arg in ['--Numeric', '--numarray', ' --numpy']:
for arg in ['--Numeric', '--numarray', '--numpy']: try: __import__(arg[2:]) except: print "You don't have %s installed" %arg[2:] continue
def testMeshGrid_DenseFromNodenseMeshgridOutput(self): # sparse fails for dense output when input has singleton dimensions x = seq(-2,2,0.1) y = seq(-4,4,1) xx, yy = meshgrid(x,y) # xx and yy now has singleton dimension self.assertEqual(rank(xx), 2) self.assertEqual(rank(yy), 2) self.assertEqual(multiply.reduce(xx.shap...
from easyviz.blt_ import *
from scitools.easyviz.blt_ import *
def test1(self): try: if 'pyx_' in _plts: use(_plts['pyx_'], globals()) figure() plot((2, 2, 3, 4), 'kv-', (3, 3, 4, 6), 'kv', x='auto') axis(-1, 5, -1, 10) title('A very long title') legend('line 1', 'line 2') #latextext = r"$2\pi\gamma k\Omega$" #$plt._g.text(0, 0, latextext) hold('on') plot((5, 3, 5, 5)) legend('li...
from easyviz.matplotlib_ import plt
from scitools.easyviz.matplotlib_ import plt
def test(self): self.setUp() try: figure() plot((1,2,3), (4,6,5), 'ro--') legend('tril') axis(0, 5, 0, 10) hold('on') plot((2,4,5), (4,4,4), '') legend('notrill', 'trill2') plot((1,2,3,4,5,6), (1,3,2,4,3,6), 'k:x') legend('nils') import Numeric x=Numeric.array((1,2,3,4)) plot(x, x**2, 'y') axis(0, 10, 0, 10) hardcopy('...
from easyviz.examples import *
from scitools.easyviz.examples import *
def test(self): self.setUp() try: figure() plot((1,2,3), (4,6,5), 'ro--') legend('tril') axis(0, 5, 0, 10) hold('on') plot((2,4,5), (4,4,4), '') legend('notrill', 'trill2') plot((1,2,3,4,5,6), (1,3,2,4,3,6), 'k:x') legend('nils') import Numeric x=Numeric.array((1,2,3,4)) plot(x, x**2, 'y') axis(0, 10, 0, 10) hardcopy('...
"python -c '''from easyviz.unittest_ import *;unittest.main()'''")
"python -c '''from scitools.easyviz.unittest_ import *;unittest.main()'''")
def main(): postscriptfiles = '' + \ " ".join(glob.glob('*.eps')) + \ " ".join(glob.glob('*.ps')) if len(postscriptfiles) > 0: print "Warning: you have old ps/eps files in testdir." print "These files might be overwritten by this test" print "The files are: ",postscriptfiles #rm *.ps *.eps *.pyc *~ -f #unittest.main()...
self.set(**kwargs)
def __init__(self, *args, **kwargs): PlotProperties.__init__(self, **kwargs) self._prop.update(Streams._local_prop) self._parseargs(*args) self.set(**kwargs)
for key in 'stepsize tubescale ribbonwith'.split():
for key in 'stepsize tubescale ribbonwidth'.split():
def set(self, **kwargs): PlotProperties.set(self, **kwargs)
def system(command, verbose=True, failure_handling='exit')
def system(command, verbose=True, failure_handling='exit'):
def system(command, verbose=True, failure_handling='exit') """ Wrapping of the os.system command. Actually, the commands.getstatusoutput function is used, and the output from the system command is fetched. @param command: operating system command to be executed. @param verbose: False: no output, True: print command. @...
- plot(y1,...,x=x)
- plot(y1,y2,...,x=x)
def plot(self, *args, **kwargs): """Draw line and scatter plots.
for i in range(len(args)-1): if not isinstance(args[i], str): if isinstance(args[i+1], str): lines.append(Line(x=kwargs['x'], y=args[i], format=args[1+i])) else: lines.append(Line(x=kwargs['x'], y=args[i], format='')) if i == nargs-2:
if nargs == 1 or (nargs == 2 and isinstance(args[1], str)): if nargs == 1: lines.append(Line(x=kwargs['x'], y=args[0], format='')) else: lines.append(Line(x=kwargs['x'], y=args[0], format=args[1])) else: for i in range(len(args)-1): if not isinstance(args[i], str): if isinstance(args[i+1], str):
def plot(self, *args, **kwargs): """Draw line and scatter plots.
y=args[i+1],
y=args[i], format=args[1+i])) else: lines.append(Line(x=kwargs['x'], y=args[i],
def plot(self, *args, **kwargs): """Draw line and scatter plots.
for i in range(len(args)-1): if not isinstance(args[i], str): if isinstance(args[i+1], str): lines.append(Line(x=kwargs['x'], y=kwargs['y'], z=args[i], format=args[1+i])) else: lines.append(Line(x=kwargs['x'], y=kwargs['y'], z=args[i], format='')) if i == nargs-2:
if nargs == 1 or (nargs == 2 and isinstance(args[1], str)): if nargs == 1: lines.append(Line(x=kwargs['x'], y=kwargs['y'], z=args[0], format='')) else: lines.append(Line(x=kwargs['x'], y=kwargs['y'], z=args[0], format=args[1])) else: for i in range(len(args)-1): if not isinstance(args[i], str): if isinstance(args[i+1],...
def plot3(self, *args, **kwargs): """Draw lines and points in 3D space.
z=args[i+1],
z=args[i], format=args[1+i])) else: lines.append(Line(x=kwargs['x'], y=kwargs['y'], z=args[i],
def plot3(self, *args, **kwargs): """Draw lines and points in 3D space.
self._browser = WebBrowser()
self._browser = WebView()
def __init__(self, browser=None): Activity.__init__(self)
s = re.sub('&[A-Za-z.-]*;', ' ', s) s = re.sub('<[a-zA-Z0-9 =\\\\":/.-_?]*>', ' ', s) s = re.sub('<[a-zA-Z0-9 =\\\\":/.-_?]*/>', ' ', s) s = re.sub('</[a-zA-Z0-9]*>', ' ', s)
s = re.sub('&[^;]*;', ' ', s) s = re.sub('<[^>]*>', ' ', s) s = re.sub('<[^>]*/>', ' ', s) s = re.sub('</[^>]*>', ' ', s)
def getCleanMsgstr(self): s = self.getMsgstr() space = ('\\n', '\\t') empty = ('&',) import re s = re.sub('&[A-Za-z.-]*;', ' ', s) s = re.sub('<[a-zA-Z0-9 =\\\\":/.-_?]*>', ' ', s) s = re.sub('<[a-zA-Z0-9 =\\\\":/.-_?]*/>', ' ', s) s = re.sub('</[a-zA-Z0-9]*>', ' ', s) for t in space: s = s.replace(t, ' ') for t in emp...
if x < lts - lwf + 1 and textToSearch[x + lwf] in string.letters:
if x < lts - lwf - 1 and textToSearch[x + lwf] in string.letters:
def searchWordInText(self, wordToFind, textToSearch, context, index): x = textToSearch.find(wordToFind, index) if x < 0: return (x, None) lwf = len(wordToFind) lts = len(textToSearch) if x > 0 and textToSearch[x - 1] in string.letters: return (x, None) if x < lts - lwf + 1 and textToSearch[x + lwf] in string.letters: r...
print "usage: %s connstring [-d dblib] outdir [propsfile]" % progname
print "usage: %s [-d dbmodule] connstring outdir [propsfile]" % progname
def usage_exit(progname, msg=None): if msg: print msg print print "usage: %s connstring [-d dblib] outdir [propsfile]" % progname sys.exit(2)
nullable = (notnull != 't')
assert notnull in ('t', 'f', 1, 0), notnull nullable = (notnull not in ('t', 1))
def _get_column_info(conn): Q = """SELECT c.relname, a.attname, t.typname, a.attlen, a.attnotnull, a.atthasdef, a.atttypmod FROM pg_class c, pg_attribute a, pg_type t WHERE c.relname !~ '^pg_' and c.relname !~ '^Inv' and c.relkind = 'r' and a.attnum > 0 and a.attrelid = c.oid and a.atttypid = t.oid""" tables = {} for t...
self._index_items.append((table.name, "table", tablefilename))
self._index_items.append((table.name, "table", "table-%s.html" % table.name))
def _generate_table_pages(self): for table in self.tables: print "doing table", table.name tablefilename = os.path.join(self.outdir, "table-%s.html" % table.name) self._index_items.append((table.name, "table", tablefilename)) f = open(tablefilename, 'w') nav = '<a href="index.html">Table index</a> | <a href="symbol-ind...
tgargs = string.split(tgargs, '\\000')
if string.find(tgargs, '\000') != -1: tgargs = string.split(tgargs, '\000') else: tgargs = string.split(tgargs, '\\000') if len(tgargs) != 7: raise RuntimeError, "error parsing trigger args for foreign key: %s" \ % repr(tgargs)
def _get_foreign_keys(conn): """Find foreign keys by looking at triggers. (Query adapted from query posted to pgsql-general by Michael Fork according to http://www.geocrawler.com/mail/msg.php3?msg_id=4895586&list=12) """ fkeys = {} for (tgargs,) in _query(conn, ''' SELECT pt.tgargs FROM pg_class pc, pg_proc pg_proc, pg...
cols = string.replace(cols, ' ', ',')
def first(row): return row[0]
decode(data_type, 'DATE', 11,
decode(data_type, 'DATE', '11',
def _get_column_info(conn): "Get a dictionary of (table, [list of column details]) tuples for all tables" # AJT 13.11.2001 - Note date is hard coded to '11'. Probably should special # case this in the documentation class to ignore the length of dates. stmt = """SELECT table_name, column_name, data_type, nullable, decod...
for table, attr, typ, notnull, hasdef, length in _query(conn, stmt):
for table, attr, typ, nullable, hasdef, length in _query(conn, stmt):
def _get_column_info(conn): "Get a dictionary of (table, [list of column details]) tuples for all tables" # AJT 13.11.2001 - Note date is hard coded to '11'. Probably should special # case this in the documentation class to ignore the length of dates. stmt = """SELECT table_name, column_name, data_type, nullable, decod...
assert notnull in ('Y', 'N'), notnull nullable = (notnull == 'Y')
assert nullable in ('Y', 'N'), nullable nullable = (nullable == 'Y')
def _get_column_info(conn): "Get a dictionary of (table, [list of column details]) tuples for all tables" # AJT 13.11.2001 - Note date is hard coded to '11'. Probably should special # case this in the documentation class to ignore the length of dates. stmt = """SELECT table_name, column_name, data_type, nullable, decod...
if self.protocol not in [ '1910' ] :
if self.protocol not in [ '0014' ] :
def __init__( self , host = '127.0.0.1' , port = 5154 ) :
data = struct.unpack( '>18H' , data )
data = struct.unpack( '>21H' , data )
def queryGame( self ) :
redSize , greenSize , blueSize , purpleSize , rogueMax , \ redMax , greenMax , blueMax , purpleMax , shakeWins , \ shakeTimeout , maxPlayerScore , maxTeamScore , maxTime \
redSize , greenSize , blueSize , purpleSize , obsSize, \ rogueMax , redMax , greenMax , blueMax , purpleMax , obsMax, \ shakeWins , shakeTimeout , maxPlayerScore , maxTeamScore , \ maxTime , elapsedTime \
def queryGame( self ) :
'rogue' : ( rogueSize , rogueMax ) , 'red' : ( redSize , redMax ) , 'green' : ( greenSize , greenMax ) , 'blue' : ( blueSize , blueMax ) , 'purple' : ( purpleSize , purpleMax ) ,
'rogue' : ( rogueSize , rogueMax ) , 'red' : ( redSize , redMax ) , 'green' : ( greenSize , greenMax ) , 'blue' : ( blueSize , blueMax ) , 'purple' : ( purpleSize , purpleMax ) , 'observer' : ( obsSize , obsMax ) ,
def queryGame( self ) :
'maxTime' : maxTime / 10.
'maxTime' : maxTime / 10 , 'elapsedTime' : elapsedTime / 10 ,
def queryGame( self ) :
sys.stderr.write(filename + '\n')
def check_file(filename, lines): sys.stderr.write(filename + '\n') line_checks = [ check_tab_characters, check_long_lines ] token_checks = [ check_double_semicolons, check_missing_spaces_around, check_missing_spaces_after, check_extra_spaces_after, check_missing_spaces_before, check_extra_spaces_before, check_spaced_un...
line = re.sub(r'[bB]ug '<a href="' + bugzilla_url + '\\1">\\g<0></a>', line)
def format_date(d): # Don't depend on locale months = (None, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December') d = time.strptime(d, '%Y-%m-%d') return '%s %d, %d' % (months[d.tm_mon], d.tm_mday, d.tm_year)
re_enum = re.compile(r'^\s+(?P<ident>[A-Z][A-Z0-9_]+)\s*=', re.M)
re_enum = re.compile(r'^\s+(?P<ident>[A-Z][A-Z0-9_]+)\s*[=,]', re.M)
command -nargs=+ HiLink hi def link <args>
def print_decls(decldict):
def print_decls(decldict, value):
def print_decls(decldict): for t, d in decldict.items(): d = d.keys() if not d: continue d.sort() print 'syn keyword %s%s %s' % (syntax_name, normalize(t), ' '.join(d))
d = d.keys()
d = [k for k, v in d.items() if v == value]
def print_decls(decldict): for t, d in decldict.items(): d = d.keys() if not d: continue d.sort() print 'syn keyword %s%s %s' % (syntax_name, normalize(t), ' '.join(d))
depdecls = dict([(x, {}) for x in types])
deprecated_found = False identdefs = {}
def override(decldict, overides): for o, v in overides.items(): v = v.upper() has_it = False for k, d in decldict.items(): if d.has_key(o): has_it = True del d[o] if has_it: decldict[v][o] = 1
insert_to = depdecls
value = 'deprecated' deprecated_found = True
def override(decldict, overides): for o, v in overides.items(): v = v.upper() has_it = False for k, d in decldict.items(): if d.has_key(o): has_it = True del d[o] if has_it: decldict[v][o] = 1
insert_to = decls
value = None
def override(decldict, overides): for o, v in overides.items(): v = v.upper() has_it = False for k, d in decldict.items(): if d.has_key(o): has_it = True del d[o] if has_it: decldict[v][o] = 1
insert_to[d['type']][d['ident']] = 1
m = re_ident_macro.search(d['body']) if m: identdefs[d['ident']] = m.group('ident') decls[d['type']][d['ident']] = value
def override(decldict, overides): for o, v in overides.items(): v = v.upper() has_it = False for k, d in decldict.items(): if d.has_key(o): has_it = True del d[o] if has_it: decldict[v][o] = 1
insert_to['CONSTANT'][e.group('ident')] = 1
decls['CONSTANT'][e.group('ident')] = value for macro, body in identdefs.items(): for k, d in decls.items(): if not d.has_key(body): continue if k == 'FUNCTION' or k == 'MACRO': decls['MACRO'][macro] = decls['DEFINE'][macro] del decls['DEFINE'][macro]
def override(decldict, overides): for o, v in overides.items(): v = v.upper() has_it = False for k, d in decldict.items(): if d.has_key(o): has_it = True del d[o] if has_it: decldict[v][o] = 1
override(depdecls, options['override'])
def override(decldict, overides): for o, v in overides.items(): v = v.upper() has_it = False for k, d in decldict.items(): if d.has_key(o): has_it = True del d[o] if has_it: decldict[v][o] = 1
print_decls(decls) if [x for x in depdecls.values() if x]:
print_decls(decls, None) if deprecated_found:
def override(decldict, overides): for o, v in overides.items(): v = v.upper() has_it = False for k, d in decldict.items(): if d.has_key(o): has_it = True del d[o] if has_it: decldict[v][o] = 1