bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def makeInnerTiles(self): # inner grid lines group = Group()
|
defmakeInnerTiles(self):#innergridlinesgroup=Group()
| 5,900
|
def makeInnerTiles(self): # inner grid lines group = Group()
|
def makeInnerTiles(self): # inner grid lines group = Group()
| 5,901
|
def makeInnerTiles(self): # inner grid lines group = Group()
|
def makeInnerTiles(self): # inner grid lines group = Group()
| 5,902
|
def makeInnerTiles(self): # inner grid lines group = Group()
|
defmakeInnerTiles(self):#innergridlinesgroup=Group()
| 5,903
|
def makeInnerTiles(self): # inner grid lines group = Group()
|
def makeInnerTiles(self): # inner grid lines group = Group()
| 5,904
|
def makeInnerTiles(self): # inner grid lines group = Group()
|
def makeInnerTiles(self): # inner grid lines group = Group()
| 5,905
|
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 range(3): x = 20 + col*120 g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*120 g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
|
def test(): D = Drawing(450, 650) d = 80 s = 60 for row in range(10): y = 530 - row*d 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 range(3): x = 20 + col*120 g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*120 g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
| 5,906
|
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 range(3): x = 20 + col*120 g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*120 g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
|
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*d 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 range(3): x = 20 + col*d g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*d g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
| 5,907
|
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 range(3): x = 20 + col*120 g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*120 g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
|
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*d 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 range(3): x = 20 + col*d g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*d g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
| 5,908
|
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 range(3): x = 20 + col*120 g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*120 g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
|
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*d 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 range(3): x = 20 + col*d g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*d g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
| 5,909
|
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 range(3): x = 20 + col*120 g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*120 g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
|
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*d 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 range(3): x = 20 + col*d g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*d g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
| 5,910
|
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 range(3): x = 20 + col*120 g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*120 g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
|
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*d 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 range(3): x = 20 + col*d g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*d g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*d sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
| 5,911
|
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[-1].getSpaceAfter()
|
def _listCellGeom(self, V,w,s,W=None,H=None): aW = w-s.leftPadding-s.rightPadding t = 0 w = 0 canv = getattr(self,'canv',None) 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[-1].getSpaceAfter()
| 5,912
|
def __init__(self, fileName): if not haveImages: warnOnce('Imaging Library not available, unable to import bitmaps') return #start wih lots of null private fields, to be populated by #the relevant engine. self.fileName = fileName self._image = None self._width = None self._height = None self._transparent = None self._data = None
|
def __init__(self, fileName): if not haveImages: warnOnce('Imaging Library not available, unable to import bitmaps') return #start wih lots of null private fields, to be populated by #the relevant engine. self.fileName = fileName self._image = None self._width = None self._height = None self._transparent = None self._data = None
| 5,913
|
def __init__(self, fileName): if not haveImages: warnOnce('Imaging Library not available, unable to import bitmaps') return #start wih lots of null private fields, to be populated by #the relevant engine. self.fileName = fileName self._image = None self._width = None self._height = None self._transparent = None self._data = None
|
def __init__(self, fileName): if not haveImages: warnOnce('Imaging Library not available, unable to import bitmaps') return #start wih lots of null private fields, to be populated by #the relevant engine. self.fileName = fileName self._image = None self._width = None self._height = None self._transparent = None self._data = None
| 5,914
|
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] or filter(None,baseDir)) or None) if baseDir is None: path = sys.path[:] else: path = [baseDir] if noCWD: if '.' in path: path.remove('.') abspath = os.path.abspath('.') if abspath in path: path.remove(abspath) else: if '.' not in path: path.insert(0,'.') if debug: import pprint pp = pprint.pprint print 'path=',pp(path) #make import errors a bit more informative fullName = name try: (file, pathname, description) = imp.find_module(name, path) childModule = parentModule = imp.load_module(name, file, pathname, description) if debug: print 'imported module = %s' % parentModule for name in parts[1:]: fullName = fullName + '.' + name if debug: print 'trying part %s' % name (file, pathname, description) = imp.find_module(name, [os.path.dirname(parentModule.__file__)]) childModule = imp.load_module(fullName, file, pathname, description) if debug: print 'imported module = %s' % childModule setattr(parentModule, name, childModule) parentModule = childModule except ImportError: msg = "cannot import '%s' while attempting recursive import of '%s'" % (fullName, modulename) if baseDir: msg = msg + " under paths '%s'" % `path` raise ImportError, msg return childModule
|
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] or filter(None,baseDir)) or None) if baseDir is None: path = sys.path[:] else: path = [baseDir]if noCWD: if '.' in path: path.remove('.') abspath = os.path.abspath('.') if abspath in path: path.remove(abspath) else: if '.' not in path: path.insert(0,'.')if debug: import pprint pp = pprint.pprint print 'path=',pp(path)#make import errors a bit more informative fullName = name try: (file, pathname, description) = imp.find_module(name, path) childModule = parentModule = imp.load_module(name, file, pathname, description) if debug: print 'imported module = %s' % parentModule for name in parts[1:]: fullName = fullName + '.' + name if debug: print 'trying part %s' % name (file, pathname, description) = imp.find_module(name, [os.path.dirname(parentModule.__file__)]) childModule = imp.load_module(fullName, file, pathname, description) if debug: print 'imported module = %s' % childModulesetattr(parentModule, name, childModule) parentModule = childModule except ImportError: msg = "cannot import '%s' while attempting recursive import of '%s'" % (fullName, modulename) if baseDir: msg = msg + " under paths '%s'" % `path` raise ImportError, msgreturn childModule
| 5,915
|
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] or filter(None,baseDir)) or None) if baseDir is None: path = sys.path[:] else: path = [baseDir] if noCWD: if '.' in path: path.remove('.') abspath = os.path.abspath('.') if abspath in path: path.remove(abspath) else: if '.' not in path: path.insert(0,'.') if debug: import pprint pp = pprint.pprint print 'path=',pp(path) #make import errors a bit more informative fullName = name try: (file, pathname, description) = imp.find_module(name, path) childModule = parentModule = imp.load_module(name, file, pathname, description) if debug: print 'imported module = %s' % parentModule for name in parts[1:]: fullName = fullName + '.' + name if debug: print 'trying part %s' % name (file, pathname, description) = imp.find_module(name, [os.path.dirname(parentModule.__file__)]) childModule = imp.load_module(fullName, file, pathname, description) if debug: print 'imported module = %s' % childModule setattr(parentModule, name, childModule) parentModule = childModule except ImportError: msg = "cannot import '%s' while attempting recursive import of '%s'" % (fullName, modulename) if baseDir: msg = msg + " under paths '%s'" % `path` raise ImportError, msg return childModule
|
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] or filter(None,baseDir)) or None) if baseDir is None: path = sys.path[:] else: if type(baseDir) not in SeqTypes path = [baseDir] else: path = list(baseDir) path = filter(None,basDir) if noCWD: if '.' in path: path.remove('.') abspath = os.path.abspath('.') if abspath in path: path.remove(abspath) else: if '.' not in path: path.insert(0,'.') if debug: import pprint pp = pprint.pprint print 'path=',pp(path) #make import errors a bit more informative fullName = name try: (file, pathname, description) = imp.find_module(name, path) childModule = parentModule = imp.load_module(name, file, pathname, description) if debug: print 'imported module = %s' % parentModule for name in parts[1:]: fullName = fullName + '.' + name if debug: print 'trying part %s' % name (file, pathname, description) = imp.find_module(name, [os.path.dirname(parentModule.__file__)]) childModule = imp.load_module(fullName, file, pathname, description) if debug: print 'imported module = %s' % childModule setattr(parentModule, name, childModule) parentModule = childModule except ImportError: msg = "cannot import '%s' while attempting recursive import of '%s'" % (fullName, modulename) if baseDir: msg = msg + " under paths '%s'" % `path` raise ImportError, msg return childModule
| 5,916
|
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+"-"+jobid+".txt" if (not os.access(qpath+job,os.W_OK)): print '<p><b> Job file "%s" (ID:%s) is not valid job to remove (List:%s)</b></p>' % (job,jobid,cslist) return -1 control=cs_helpers.readConfig(qpath+job) # in capisuite 0.4.3, the filename options in failed and done store the original file path # (e.g. /var/spool/capisuite/users/me/senq/fax-12.sff). if cslist!="faxdone" and cslist!="faxfailed": datafile=control.get("GLOBAL","filename") else: datafile=qpath+job[:-3]+"sff" if not datafile: return -1 try: lockfile=open(qpath+job[:-3]+"lock","w") # lock so that it isn't deleted while sending (or else) fcntl.lockf(lockfile,fcntl.LOCK_EX | fcntl.LOCK_NB) os.unlink(qpath+job) os.unlink(datafile) fcntl.lockf(lockfile,fcntl.LOCK_UN) os.unlink(qpath+job[:-3]+"lock") except IOError,err: if (err.errno in (errno.EACCES,errno.EAGAIN)): print "<p><b>Job is currently in transmission or in similar use. Can't remove.</b></p>"
|
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+"-"+jobid+".txt" if (not os.access(qpath+job,os.W_OK)): print '<p><b> Job file "%s" (ID:%s) is not valid job to remove (List:%s)</b></p>' % (job,jobid,cslist) return -1 control=cs_helpers.readConfig(qpath+job) # in capisuite 0.4.3, the filename options in failed and done store the original file path # (e.g. /var/spool/capisuite/users/me/senq/fax-12.sff). if cslist!="faxdone" and cslist!="faxfailed": datafile=control.get("GLOBAL","filename") else: fileext="sff" if os.path.splitext(datafilename)[1].lower()==".cff": fileext="cff" datafile=qpath+job[:-3]+fileext if not datafile: return -1 try: lockfile=open(qpath+job[:-3]+"lock","w") # lock so that it isn't deleted while sending (or else) fcntl.lockf(lockfile,fcntl.LOCK_EX | fcntl.LOCK_NB) os.unlink(qpath+job) os.unlink(datafile) fcntl.lockf(lockfile,fcntl.LOCK_UN) os.unlink(qpath+job[:-3]+"lock") except IOError,err: if (err.errno in (errno.EACCES,errno.EAGAIN)): print "<p><b>Job is currently in transmission or in similar use. Can't remove.</b></p>"
| 5,917
|
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","")=="") and \ (CAPI_config.get(user,"fax_numbers","")=="")): raise CSGeneralError("Sorry, your are not allowed to send a fax") filetype = os.path.splitext(sourcefile)[1].lower()[1:] # splittext returns a list of 2, so no "None" check needed if not filetype: raise CSUserInputError("nvalid input (fax) file") # Convert to empty string, if set to "None" if addressee==None: addressee="" if subject==None: subject="" # filter out common separators from dialstring, check it dialstring=dialstring.translate(string.maketrans("",""),"-/ ()") if re.compile("[^0-9\+]+").search(dialstring): raise CSUserInputError("Invalid dialstring") prefix=cs_helpers.getOption(CAPI_config,user,"dial_prefix","") if (useprefix): dialstring=prefix+dialstring if (not os.access(sourcefile,os.R_OK)): raise CSInternalError("Cannot read fax source file:"+cgi.escape(sourcefile,1)) sendq = os.path.join(UsersFax_Path,user,"sendq")+"/" newname=cs_helpers.uniqueName(sendq,"fax",filetype) # --TODO--Error check!!!! shutil.copy(sourcefile,newname) if not cstarttime: cstarttime = time.ctime() cs_helpers.writeDescription(newname,"dialstring=\""+dialstring+"\"\n" +"starttime=\""+cstarttime+"\"\ntries=\"0\"\n" +"user=\""+user+"\"\naddressee=\""+addressee+"\"\nsubject=\"" +subject+"\"\n") os.chmod(newname,0600) os.chmod(newname[:-3]+"txt",0600) if (os.getuid()==0): user_entry=pwd.getpwnam(user) os.chown(newname,user_entry[2],user_entry[3]) os.chown(newname[:-3]+"txt",user_entry[2],user_entry[3]) #print "<p>",sourcefile,"successful enqueued as",newname,"for",dialstring,"</p>"
|
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","")=="") and \ (CAPI_config.get(user,"fax_numbers","")=="")): raise CSGeneralError("Sorry, your are not allowed to send a fax") filetype = os.path.splitext(sourcefile)[1].lower()[1:] # splittext returns a list of 2, so no "None" check needed if not filetype: raise CSUserInputError("Invalid input (fax) file") # Convert to empty string, if set to "None" if addressee==None: addressee="" if subject==None: subject="" # filter out common separators from dialstring, check it dialstring=dialstring.translate(string.maketrans("",""),"-/ ()") if re.compile("[^0-9\+]+").search(dialstring): raise CSUserInputError("Invalid dialstring") prefix=cs_helpers.getOption(CAPI_config,user,"dial_prefix","") if (useprefix): dialstring=prefix+dialstring if (not os.access(sourcefile,os.R_OK)): raise CSInternalError("Cannot read fax source file:"+cgi.escape(sourcefile,1)) sendq = os.path.join(UsersFax_Path,user,"sendq")+"/" newname=cs_helpers.uniqueName(sendq,"fax",filetype) # --TODO--Error check!!!! shutil.copy(sourcefile,newname) if not cstarttime: cstarttime = time.ctime() cs_helpers.writeDescription(newname,"dialstring=\""+dialstring+"\"\n" +"starttime=\""+cstarttime+"\"\ntries=\"0\"\n" +"user=\""+user+"\"\naddressee=\""+addressee+"\"\nsubject=\"" +subject+"\"\n") os.chmod(newname,0600) os.chmod(newname[:-3]+"txt",0600) if (os.getuid()==0): user_entry=pwd.getpwnam(user) os.chown(newname,user_entry[2],user_entry[3]) os.chown(newname[:-3]+"txt",user_entry[2],user_entry[3]) #print "<p>",sourcefile,"successful enqueued as",newname,"for",dialstring,"</p>"
| 5,918
|
def UpdateRegattaRanking(self): self.SaveRankingData() self.LoadRegattaRanking()
|
def UpdateRegattaRanking(self): self.SaveRankingData() self.LoadRegattaRanking()
| 5,919
|
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
|
def ChechForSkipper(self, value, pos): for s in range(0, self.T_DetailRanking.rowCount()): 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
| 5,920
|
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: pass current_class = '' if self.T_DetailRanking.rowCount() > 1: self.ClearRankTable() for c in range(0, self.L_Regattas.count()): if self.L_Regattas.isItemSelected(self.L_Regattas.item(c)) == True: current_class = self.L_Regattas.item(c).text() break if current_class != '': File = self.inputpath+re.sub(' ','_',str(current_class))+".cla" Header = self.tr("Race") try: datafile = ConfigParser.ConfigParser() datafile.readfp(open(File)) except: return x = 0 TableHeader = ["Skipper"] points = {} Ranks = {} for sk in datafile.options('result'): _pt = datafile.get('result', sk) pt = _pt.split(',') tot = 0 Ranks[sk] = pt for p in pt: if p == 'DNF': tot = tot + self.DNF else: tot = tot + int(p) Ranks[sk].append(str(tot)) points[sk] = tot it = points.items() it = [(v, k) for (k, v) in it] it.sort() it = [(k, v) for (v, k) in it] for c in range(0,len(Ranks[sk])): self.T_DetailRanking.insertColumn(c+1) TableHeader.append("%s %d"%(Header,(c+1))) TableHeader.remove(TableHeader[len(TableHeader)-1]) TableHeader.append("Tot") self.T_DetailRanking.setHorizontalHeaderLabels(TableHeader) for sk_ in it: sk = sk_[0] self.T_DetailRanking.insertRow(self.T_DetailRanking.rowCount()) ski = QtGui.QTableWidgetItem(sk) self.T_DetailRanking.setItem(x,0,ski) c = 1 for p in Ranks[sk]: if p == '999': p = 'DNF' pt = QtGui.QTableWidgetItem(p) pt.setTextAlignment(QtCore.Qt.AlignCenter) self.T_DetailRanking.setItem(x,c,pt) c = c + 1 x = x + 1 self.T_DetailRanking.resizeColumnsToContents()
|
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: pass current_class = '' if self.T_DetailRanking.rowCount() > 1: self.ClearRankTable() for c in range(0, self.L_Regattas.count()): if self.L_Regattas.isItemSelected(self.L_Regattas.item(c)) == True: current_class = self.L_Regattas.item(c).text() break if current_class != '': File = self.inputpath+re.sub(' ','_',str(current_class))+".cla" Header = self.tr("Race") try: datafile = ConfigParser.ConfigParser() datafile.readfp(open(File)) except: return x = 0 TableHeader = ["Skipper"] points = {} Ranks = {} risultati = datafile.options('result') if len(risultati) == 0: return for sk in datafile.options('result'): _pt = datafile.get('result', sk) pt = _pt.split(',') tot = 0 Ranks[sk] = pt for p in pt: if p == 'DNF': tot = tot + self.DNF else: tot = tot + int(p) Ranks[sk].append(str(tot)) points[sk] = tot it = points.items() it = [(v, k) for (k, v) in it] it.sort() it = [(k, v) for (v, k) in it] for c in range(0,len(Ranks[sk])): self.T_DetailRanking.insertColumn(c+1) TableHeader.append("%s %d"%(Header,(c+1))) TableHeader.remove(TableHeader[len(TableHeader)-1]) TableHeader.append("Tot") self.T_DetailRanking.setHorizontalHeaderLabels(TableHeader) for sk_ in it: sk = sk_[0] self.T_DetailRanking.insertRow(self.T_DetailRanking.rowCount()) ski = QtGui.QTableWidgetItem(sk) self.T_DetailRanking.setItem(x,0,ski) c = 1 for p in Ranks[sk]: if p == '999': p = 'DNF' pt = QtGui.QTableWidgetItem(p) pt.setTextAlignment(QtCore.Qt.AlignCenter) self.T_DetailRanking.setItem(x,c,pt) c = c + 1 x = x + 1 self.T_DetailRanking.resizeColumnsToContents()
| 5,921
|
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: pass current_class = '' if self.T_DetailRanking.rowCount() > 1: self.ClearRankTable() for c in range(0, self.L_Regattas.count()): if self.L_Regattas.isItemSelected(self.L_Regattas.item(c)) == True: current_class = self.L_Regattas.item(c).text() break if current_class != '': File = self.inputpath+re.sub(' ','_',str(current_class))+".cla" Header = self.tr("Race") try: datafile = ConfigParser.ConfigParser() datafile.readfp(open(File)) except: return x = 0 TableHeader = ["Skipper"] points = {} Ranks = {} for sk in datafile.options('result'): _pt = datafile.get('result', sk) pt = _pt.split(',') tot = 0 Ranks[sk] = pt for p in pt: if p == 'DNF': tot = tot + self.DNF else: tot = tot + int(p) Ranks[sk].append(str(tot)) points[sk] = tot it = points.items() it = [(v, k) for (k, v) in it] it.sort() it = [(k, v) for (v, k) in it] for c in range(0,len(Ranks[sk])): self.T_DetailRanking.insertColumn(c+1) TableHeader.append("%s %d"%(Header,(c+1))) TableHeader.remove(TableHeader[len(TableHeader)-1]) TableHeader.append("Tot") self.T_DetailRanking.setHorizontalHeaderLabels(TableHeader) for sk_ in it: sk = sk_[0] self.T_DetailRanking.insertRow(self.T_DetailRanking.rowCount()) ski = QtGui.QTableWidgetItem(sk) self.T_DetailRanking.setItem(x,0,ski) c = 1 for p in Ranks[sk]: if p == '999': p = 'DNF' pt = QtGui.QTableWidgetItem(p) pt.setTextAlignment(QtCore.Qt.AlignCenter) self.T_DetailRanking.setItem(x,c,pt) c = c + 1 x = x + 1 self.T_DetailRanking.resizeColumnsToContents()
|
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: pass current_class = '' if self.T_DetailRanking.rowCount() > 1: self.ClearRankTable() for c in range(0, self.L_Regattas.count()): if self.L_Regattas.isItemSelected(self.L_Regattas.item(c)) == True: current_class = self.L_Regattas.item(c).text() break if current_class != '': File = self.inputpath+re.sub(' ','_',str(current_class))+".cla" Header = self.tr("Race") try: datafile = ConfigParser.ConfigParser() datafile.readfp(open(File)) except: return x = 0 TableHeader = ["Skipper"] points = {} Ranks = {} for sk in datafile.options('result'): _pt = datafile.get('result', sk) pt = _pt.split(',') tot = 0 Ranks[sk] = pt for p in pt: if p == 'DNF': tot = tot + self.DNF else: tot = tot + int(p) Ranks[sk].append(str(tot)) points[sk] = tot it = points.items() it = [(v, k) for (k, v) in it] it.sort() it = [(k, v) for (v, k) in it] lenRanks = len(Ranks[sk]) for c in range(0,lenRanks): self.T_DetailRanking.insertColumn(c+1) TableHeader.append("%s %d"%(Header,(c+1))) TableHeader.remove(TableHeader[len(TableHeader)-1]) TableHeader.append("Tot") self.T_DetailRanking.setHorizontalHeaderLabels(TableHeader) for sk_ in it: sk = sk_[0] self.T_DetailRanking.insertRow(self.T_DetailRanking.rowCount()) ski = QtGui.QTableWidgetItem(sk) self.T_DetailRanking.setItem(x,0,ski) c = 1 for p in Ranks[sk]: if p == '999': p = 'DNF' pt = QtGui.QTableWidgetItem(p) pt.setTextAlignment(QtCore.Qt.AlignCenter) self.T_DetailRanking.setItem(x,c,pt) c = c + 1 x = x + 1 self.T_DetailRanking.resizeColumnsToContents()
| 5,922
|
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))) TableHeader[0] = "Skipper" TableHeader.append("Tot") self.T_DetailRanking.setHorizontalHeaderLabels(TableHeader) self.T_DetailRanking.resizeColumnsToContents()
|
def AddRace(self): cols = self.T_DetailRanking.columnCount() if cols == 2: cols += 1 TableHeader=[] for c in range(0, cols -1): TableHeader.append("%s %d"%("Race",(c))) TableHeader[0] = "Skipper" TableHeader.append("Tot") self.T_DetailRanking.setHorizontalHeaderLabels(TableHeader) self.T_DetailRanking.resizeColumnsToContents()
| 5,923
|
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))) TableHeader[0] = "Skipper" TableHeader.append("Tot") self.T_DetailRanking.setHorizontalHeaderLabels(TableHeader) self.T_DetailRanking.resizeColumnsToContents()
|
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))) TableHeader[0] = "Skipper" TableHeader.append("Tot") self.T_DetailRanking.setHorizontalHeaderLabels(TableHeader) self.T_DetailRanking.resizeColumnsToContents()
| 5,924
|
def _element_content(self, element): """ Distill the textual content recursively. Added since I do not know how to use the lib for this. (Tuttle) """
|
def _element_content(self, element): """ Distill the textual content recursively. Added since I do not know how to use the lib for this. (Tuttle) """
| 5,925
|
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
|
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
| 5,926
|
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
|
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
| 5,927
|
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
|
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
| 5,928
|
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 _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]
| 5,929
|
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 + ' '
|
def _make_msgstr(self, element, shrink = True): 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 + ' '
| 5,930
|
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 + ' '
|
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 + ' '
| 5,931
|
def read(self): """Reads in from all given ZPTs and builds up MessageCatalogs accordingly.
|
def read(self): """Reads in from all given ZPTs and builds up MessageCatalogs accordingly.
| 5,932
|
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
|
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
| 5,933
|
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
|
def _do_translate(self, element, domain): filename = self._curr_fn excerpt = self._make_excerpt(element) msgid = element.getAttribute('i18n:translate')
| 5,934
|
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:attributes'].find(';') == -1: # old syntax i18nattrs = [i18nattr.strip() for i18nattr in \ attrs['i18n:attributes'].split()] else: # new syntax i18nattrs = [i18nattr.strip().split()[0] for i18nattr in \ attrs['i18n:attributes'].split(';')] if not (attr in i18nattrs): return 0 else: return 1 else: return 0 return 1
|
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:attributes'].find(';') == -1: # old syntax i18nattrs = [i18nattr.strip() for i18nattr in \ attrs['i18n:attributes'].split()] else: # new syntax i18nattrs = [i18nattr.strip().split()[0] for i18nattr in \ attrs['i18n:attributes'].split(';') if i18nattr] if not (attr in i18nattrs): return 0 else: return 1 else: return 0 return 1
| 5,935
|
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.
|
defmerge(self,__loc_data__=None,__conflict_solve=None,**kw):"""S.merge(data,conflict,k=v1,k=v2,...)->mergedataandk=vintoS.
| 5,936
|
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.
|
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.
| 5,937
|
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.vtkStructuredGridGeometryFilter() plane.SetInput(sgrid2) plane.Update() data = self._cut_data(plane) implds = vtk.vtkImplicitDataSet() implds.SetDataSet(data.GetOutput()) implds.Modified() cut = vtk.vtkCutter() cut.SetInput(sgrid) cut.SetCutFunction(implds) cut.GenerateValues(10, -2,2) cut.GenerateCutScalarsOn() cut.Update() mapper = vtk.vtkPolyDataMapper() mapper.SetInput(cut.GetOutput()) mapper.SetLookupTable(self._axis._vtk_colormap) caxis = self._axis.get('caxis') if None in caxis: caxis = data.GetOutput().GetScalarRange() mapper.SetScalarRange(caxis) mapper.Update() actor = vtk.vtkActor() actor.SetMapper(mapper) self._set_shading(item, data, actor) self._set_actor_properties(item, actor) self._axis._renderer.AddActor(actor) self._axis._vtk_apd.AddInput(cut.GetOutput()) self._axis._vtk_apd.AddInput(data.GetOutput()) else: origins = [] normals = [] sx = ravel(sx)/dar[0] sy = ravel(sy)/dar[1] sz = ravel(sz)/dar[2] for i in range(len(sx)): normals.append([1,0,0]) origins.append([sx[i]/dar[0], center[1], center[2]]) for i in range(len(sy)): normals.append([0,1,0]) origins.append([center[0], sy[i]/dar[1], center[2]]) for i in range(len(sz)): normals.append([0,0,1]) origins.append([center[0], center[1], sz[i]/dar[2]]) for i in range(len(normals)): plane = vtk.vtkPlane() plane.SetOrigin(origins[i]) plane.SetNormal(normals[i]) cut = vtk.vtkCutter() cut.SetInput(sgrid) cut.SetCutFunction(plane) cut.Update() data = self._cut_data(cut) mapper = vtk.vtkPolyDataMapper() if contours: iso = vtk.vtkContourFilter() iso.SetInput(data.GetOutput()) if cvector is not None: for i in range(len(cvector)): iso.SetValue(i, cvector[i]) else: zmin, zmax = data.GetOutput().GetScalarRange() iso.GenerateValues(item.get('clevels'), zmin, zmax) iso.Update() mapper.SetInput(iso.GetOutput()) else: mapper.SetInput(data.GetOutput()) mapper.SetLookupTable(self._axis._vtk_colormap) caxis = self._axis.get('caxis') if None in caxis: caxis = sgrid.GetScalarRange() mapper.SetScalarRange(caxis) mapper.Update() actor = vtk.vtkActor() actor.SetMapper(mapper) if not contours: self._set_shading(item, data, actor) self._set_actor_properties(item, actor) self._axis._renderer.AddActor(actor) self._axis._vtk_apd.AddInput(cut.GetOutput())
|
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.vtkStructuredGridGeometryFilter() plane.SetInput(sgrid2) plane.Update() data = self._cut_data(plane) implds = vtk.vtkImplicitDataSet() implds.SetDataSet(data.GetOutput()) implds.Modified() cut = vtk.vtkCutter() cut.SetInput(sgrid) cut.SetCutFunction(implds) cut.GenerateValues(10, -2,2) cut.GenerateCutScalarsOn() cut.Update() mapper = vtk.vtkPolyDataMapper() mapper.SetInput(cut.GetOutput()) mapper.SetLookupTable(self._axis._vtk_colormap) caxis = self._axis.get('caxis') if None in caxis: caxis = data.GetOutput().GetScalarRange() mapper.SetScalarRange(caxis) mapper.Update() actor = vtk.vtkActor() actor.SetMapper(mapper) self._set_shading(item, data, actor) self._set_actor_properties(item, actor) self._axis._renderer.AddActor(actor) self._axis._vtk_apd.AddInput(cut.GetOutput()) self._axis._vtk_apd.AddInput(data.GetOutput()) else: origins = [] normals = [] sx = ravel(sx)/dar[0] sy = ravel(sy)/dar[1] sz = ravel(sz)/dar[2] for i in range(len(sx)): normals.append([1,0,0]) origins.append([sx[i], center[1], center[2]]) for i in range(len(sy)): normals.append([0,1,0]) origins.append([center[0], sy[i]/dar[1], center[2]]) for i in range(len(sz)): normals.append([0,0,1]) origins.append([center[0], center[1], sz[i]/dar[2]]) for i in range(len(normals)): plane = vtk.vtkPlane() plane.SetOrigin(origins[i]) plane.SetNormal(normals[i]) cut = vtk.vtkCutter() cut.SetInput(sgrid) cut.SetCutFunction(plane) cut.Update() data = self._cut_data(cut) mapper = vtk.vtkPolyDataMapper() if contours: iso = vtk.vtkContourFilter() iso.SetInput(data.GetOutput()) if cvector is not None: for i in range(len(cvector)): iso.SetValue(i, cvector[i]) else: zmin, zmax = data.GetOutput().GetScalarRange() iso.GenerateValues(item.get('clevels'), zmin, zmax) iso.Update() mapper.SetInput(iso.GetOutput()) else: mapper.SetInput(data.GetOutput()) mapper.SetLookupTable(self._axis._vtk_colormap) caxis = self._axis.get('caxis') if None in caxis: caxis = sgrid.GetScalarRange() mapper.SetScalarRange(caxis) mapper.Update() actor = vtk.vtkActor() actor.SetMapper(mapper) if not contours: self._set_shading(item, data, actor) self._set_actor_properties(item, actor) self._axis._renderer.AddActor(actor) self._axis._vtk_apd.AddInput(cut.GetOutput())
| 5,938
|
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.vtkStructuredGridGeometryFilter() plane.SetInput(sgrid2) plane.Update() data = self._cut_data(plane) implds = vtk.vtkImplicitDataSet() implds.SetDataSet(data.GetOutput()) implds.Modified() cut = vtk.vtkCutter() cut.SetInput(sgrid) cut.SetCutFunction(implds) cut.GenerateValues(10, -2,2) cut.GenerateCutScalarsOn() cut.Update() mapper = vtk.vtkPolyDataMapper() mapper.SetInput(cut.GetOutput()) mapper.SetLookupTable(self._axis._vtk_colormap) caxis = self._axis.get('caxis') if None in caxis: caxis = data.GetOutput().GetScalarRange() mapper.SetScalarRange(caxis) mapper.Update() actor = vtk.vtkActor() actor.SetMapper(mapper) self._set_shading(item, data, actor) self._set_actor_properties(item, actor) self._axis._renderer.AddActor(actor) self._axis._vtk_apd.AddInput(cut.GetOutput()) self._axis._vtk_apd.AddInput(data.GetOutput()) else: origins = [] normals = [] sx = ravel(sx)/dar[0] sy = ravel(sy)/dar[1] sz = ravel(sz)/dar[2] for i in range(len(sx)): normals.append([1,0,0]) origins.append([sx[i]/dar[0], center[1], center[2]]) for i in range(len(sy)): normals.append([0,1,0]) origins.append([center[0], sy[i]/dar[1], center[2]]) for i in range(len(sz)): normals.append([0,0,1]) origins.append([center[0], center[1], sz[i]/dar[2]]) for i in range(len(normals)): plane = vtk.vtkPlane() plane.SetOrigin(origins[i]) plane.SetNormal(normals[i]) cut = vtk.vtkCutter() cut.SetInput(sgrid) cut.SetCutFunction(plane) cut.Update() data = self._cut_data(cut) mapper = vtk.vtkPolyDataMapper() if contours: iso = vtk.vtkContourFilter() iso.SetInput(data.GetOutput()) if cvector is not None: for i in range(len(cvector)): iso.SetValue(i, cvector[i]) else: zmin, zmax = data.GetOutput().GetScalarRange() iso.GenerateValues(item.get('clevels'), zmin, zmax) iso.Update() mapper.SetInput(iso.GetOutput()) else: mapper.SetInput(data.GetOutput()) mapper.SetLookupTable(self._axis._vtk_colormap) caxis = self._axis.get('caxis') if None in caxis: caxis = sgrid.GetScalarRange() mapper.SetScalarRange(caxis) mapper.Update() actor = vtk.vtkActor() actor.SetMapper(mapper) if not contours: self._set_shading(item, data, actor) self._set_actor_properties(item, actor) self._axis._renderer.AddActor(actor) self._axis._vtk_apd.AddInput(cut.GetOutput())
|
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.vtkStructuredGridGeometryFilter() plane.SetInput(sgrid2) plane.Update() data = self._cut_data(plane) implds = vtk.vtkImplicitDataSet() implds.SetDataSet(data.GetOutput()) implds.Modified() cut = vtk.vtkCutter() cut.SetInput(sgrid) cut.SetCutFunction(implds) cut.GenerateValues(10, -2,2) cut.GenerateCutScalarsOn() cut.Update() mapper = vtk.vtkPolyDataMapper() mapper.SetInput(cut.GetOutput()) mapper.SetLookupTable(self._axis._vtk_colormap) caxis = self._axis.get('caxis') if None in caxis: caxis = data.GetOutput().GetScalarRange() mapper.SetScalarRange(caxis) mapper.Update() actor = vtk.vtkActor() actor.SetMapper(mapper) self._set_shading(item, data, actor) self._set_actor_properties(item, actor) self._axis._renderer.AddActor(actor) self._axis._vtk_apd.AddInput(cut.GetOutput()) self._axis._vtk_apd.AddInput(data.GetOutput()) else: origins = [] normals = [] sx = ravel(sx)/dar[0] sy = ravel(sy)/dar[1] sz = ravel(sz)/dar[2] for i in range(len(sx)): normals.append([1,0,0]) origins.append([sx[i]/dar[0], center[1], center[2]]) for i in range(len(sy)): normals.append([0,1,0]) origins.append([center[0], sy[i], center[2]]) for i in range(len(sz)): normals.append([0,0,1]) origins.append([center[0], center[1], sz[i]/dar[2]]) for i in range(len(normals)): plane = vtk.vtkPlane() plane.SetOrigin(origins[i]) plane.SetNormal(normals[i]) cut = vtk.vtkCutter() cut.SetInput(sgrid) cut.SetCutFunction(plane) cut.Update() data = self._cut_data(cut) mapper = vtk.vtkPolyDataMapper() if contours: iso = vtk.vtkContourFilter() iso.SetInput(data.GetOutput()) if cvector is not None: for i in range(len(cvector)): iso.SetValue(i, cvector[i]) else: zmin, zmax = data.GetOutput().GetScalarRange() iso.GenerateValues(item.get('clevels'), zmin, zmax) iso.Update() mapper.SetInput(iso.GetOutput()) else: mapper.SetInput(data.GetOutput()) mapper.SetLookupTable(self._axis._vtk_colormap) caxis = self._axis.get('caxis') if None in caxis: caxis = sgrid.GetScalarRange() mapper.SetScalarRange(caxis) mapper.Update() actor = vtk.vtkActor() actor.SetMapper(mapper) if not contours: self._set_shading(item, data, actor) self._set_actor_properties(item, actor) self._axis._renderer.AddActor(actor) self._axis._vtk_apd.AddInput(cut.GetOutput())
| 5,939
|
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.vtkStructuredGridGeometryFilter() plane.SetInput(sgrid2) plane.Update() data = self._cut_data(plane) implds = vtk.vtkImplicitDataSet() implds.SetDataSet(data.GetOutput()) implds.Modified() cut = vtk.vtkCutter() cut.SetInput(sgrid) cut.SetCutFunction(implds) cut.GenerateValues(10, -2,2) cut.GenerateCutScalarsOn() cut.Update() mapper = vtk.vtkPolyDataMapper() mapper.SetInput(cut.GetOutput()) mapper.SetLookupTable(self._axis._vtk_colormap) caxis = self._axis.get('caxis') if None in caxis: caxis = data.GetOutput().GetScalarRange() mapper.SetScalarRange(caxis) mapper.Update() actor = vtk.vtkActor() actor.SetMapper(mapper) self._set_shading(item, data, actor) self._set_actor_properties(item, actor) self._axis._renderer.AddActor(actor) self._axis._vtk_apd.AddInput(cut.GetOutput()) self._axis._vtk_apd.AddInput(data.GetOutput()) else: origins = [] normals = [] sx = ravel(sx)/dar[0] sy = ravel(sy)/dar[1] sz = ravel(sz)/dar[2] for i in range(len(sx)): normals.append([1,0,0]) origins.append([sx[i]/dar[0], center[1], center[2]]) for i in range(len(sy)): normals.append([0,1,0]) origins.append([center[0], sy[i]/dar[1], center[2]]) for i in range(len(sz)): normals.append([0,0,1]) origins.append([center[0], center[1], sz[i]/dar[2]]) for i in range(len(normals)): plane = vtk.vtkPlane() plane.SetOrigin(origins[i]) plane.SetNormal(normals[i]) cut = vtk.vtkCutter() cut.SetInput(sgrid) cut.SetCutFunction(plane) cut.Update() data = self._cut_data(cut) mapper = vtk.vtkPolyDataMapper() if contours: iso = vtk.vtkContourFilter() iso.SetInput(data.GetOutput()) if cvector is not None: for i in range(len(cvector)): iso.SetValue(i, cvector[i]) else: zmin, zmax = data.GetOutput().GetScalarRange() iso.GenerateValues(item.get('clevels'), zmin, zmax) iso.Update() mapper.SetInput(iso.GetOutput()) else: mapper.SetInput(data.GetOutput()) mapper.SetLookupTable(self._axis._vtk_colormap) caxis = self._axis.get('caxis') if None in caxis: caxis = sgrid.GetScalarRange() mapper.SetScalarRange(caxis) mapper.Update() actor = vtk.vtkActor() actor.SetMapper(mapper) if not contours: self._set_shading(item, data, actor) self._set_actor_properties(item, actor) self._axis._renderer.AddActor(actor) self._axis._vtk_apd.AddInput(cut.GetOutput())
|
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.vtkStructuredGridGeometryFilter() plane.SetInput(sgrid2) plane.Update() data = self._cut_data(plane) implds = vtk.vtkImplicitDataSet() implds.SetDataSet(data.GetOutput()) implds.Modified() cut = vtk.vtkCutter() cut.SetInput(sgrid) cut.SetCutFunction(implds) cut.GenerateValues(10, -2,2) cut.GenerateCutScalarsOn() cut.Update() mapper = vtk.vtkPolyDataMapper() mapper.SetInput(cut.GetOutput()) mapper.SetLookupTable(self._axis._vtk_colormap) caxis = self._axis.get('caxis') if None in caxis: caxis = data.GetOutput().GetScalarRange() mapper.SetScalarRange(caxis) mapper.Update() actor = vtk.vtkActor() actor.SetMapper(mapper) self._set_shading(item, data, actor) self._set_actor_properties(item, actor) self._axis._renderer.AddActor(actor) self._axis._vtk_apd.AddInput(cut.GetOutput()) self._axis._vtk_apd.AddInput(data.GetOutput()) else: origins = [] normals = [] sx = ravel(sx)/dar[0] sy = ravel(sy)/dar[1] sz = ravel(sz)/dar[2] for i in range(len(sx)): normals.append([1,0,0]) origins.append([sx[i]/dar[0], center[1], center[2]]) for i in range(len(sy)): normals.append([0,1,0]) origins.append([center[0], sy[i]/dar[1], center[2]]) for i in range(len(sz)): normals.append([0,0,1]) origins.append([center[0], center[1], sz[i]]) for i in range(len(normals)): plane = vtk.vtkPlane() plane.SetOrigin(origins[i]) plane.SetNormal(normals[i]) cut = vtk.vtkCutter() cut.SetInput(sgrid) cut.SetCutFunction(plane) cut.Update() data = self._cut_data(cut) mapper = vtk.vtkPolyDataMapper() if contours: iso = vtk.vtkContourFilter() iso.SetInput(data.GetOutput()) if cvector is not None: for i in range(len(cvector)): iso.SetValue(i, cvector[i]) else: zmin, zmax = data.GetOutput().GetScalarRange() iso.GenerateValues(item.get('clevels'), zmin, zmax) iso.Update() mapper.SetInput(iso.GetOutput()) else: mapper.SetInput(data.GetOutput()) mapper.SetLookupTable(self._axis._vtk_colormap) caxis = self._axis.get('caxis') if None in caxis: caxis = sgrid.GetScalarRange() mapper.SetScalarRange(caxis) mapper.Update() actor = vtk.vtkActor() actor.SetMapper(mapper) if not contours: self._set_shading(item, data, actor) self._set_actor_properties(item, actor) self._axis._renderer.AddActor(actor) self._axis._vtk_apd.AddInput(cut.GetOutput())
| 5,940
|
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, "Wrong number of arguments"
|
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, "Wrong number of arguments"
| 5,941
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
| 5,942
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
| 5,943
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
| 5,944
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
| 5,945
|
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.shape), size(xx)) self.assertEqual(multiply.reduce(yy.shape), size(yy)) # This one should fail when xx and yy is not flat as well xx, yy = meshgrid(xx.flat, yy.flat, sparse=False) # no singleton self.assertEqual(shape(xx), (size(y), size(x))) self.assertEqual(shape(yy), (size(y), size(x))) xx, yy = meshgrid(x,y) # Add singleton dimensions xx, yy = meshgrid(xx, yy, sparse=False) self.assertEqual(shape(xx), (size(y), size(x))) self.assertEqual(shape(yy), (size(y), size(x)))
|
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.shape), size(xx)) self.assertEqual(multiply.reduce(yy.shape), size(yy)) # This one should fail when xx and yy is not flat as well xx, yy = meshgrid(xx.flat, yy.flat, sparse=False) # no singleton self.assertEqual(shape(xx), (size(y), size(x))) self.assertEqual(shape(yy), (size(y), size(x))) xx, yy = meshgrid(x,y) # Add singleton dimensions xx, yy = meshgrid(xx, yy, sparse=False) self.assertEqual(shape(xx), (size(y), size(x))) self.assertEqual(shape(yy), (size(y), size(x)))
| 5,946
|
def NumPy_type(a): """ @param a: NumPy array @return: "Numeric", "numarray", or "numpy", depending on which module that was used to generate the a array """ # check basic_NumPy type first to avoid possible import errors types = {'Numeric': 'Numeric.ArrayType', 'numarray': 'numarray.NumArray', 'numpy': 'numpy.ndarray'} if isinstance(a, eval(types[basic_NumPy])): return basic_NumPy import Numeric if isinstance(a, Numeric.ArrayType): return 'Numeric' import numarray if isinstance(a, numarray.NumArray): return 'numarray' import numpy if isinstance(a, numpy.ndarray): return 'numpy'
|
def NumPy_type(a): """ @param a: NumPy array @return: "Numeric", "numarray", or "numpy", depending on which module that was used to generate the a array """ # check basic_NumPy type first to avoid possible import errors types = {'Numeric': 'Numeric.ArrayType', 'numarray': 'numarray.NumArray', 'numpy': 'numpy.ndarray'} if isinstance(a, eval(types[basic_NumPy])): return basic_NumPy import Numeric if isinstance(a, Numeric.ArrayType): return 'Numeric' import numarray if isinstance(a, numarray.NumArray): return 'numarray' import numpy if isinstance(a, numpy.ndarray): return 'numpy'
| 5,947
|
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('line 3') hardcopy('testpyx.eps') except: print 'pyx_ error: \nDebugging plt' #debug(plt)
|
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('line 3') hardcopy('testpyx.eps') except: print 'pyx_ error: \nDebugging plt' #debug(plt)
| 5,948
|
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('blt_test1.ps') figure() plot((1,2,3), 'r:', (2,3,4), 'b-', (3,4,5), 'k-.',\ (4,6,6), 'g--')#, x='auto') legend('dotted', 'solid', 'dotdashed', 'dashed') hardcopy('blt_test2.ps') figure() plot((1,10,100), log='y') hold('on') loglog((1,19,199), (10,100,1000)) legend('loglog', 'loglog') title('one scale') xlabel('x') ylabel('y') hardcopy('blt_test3.ps') except: print "Error: running debug(plt)" #debug(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('blt_test1.ps') figure() plot((1,2,3), 'r:', (2,3,4), 'b-', (3,4,5), 'k-.',\ (4,6,6), 'g--')#, x='auto') legend('dotted', 'solid', 'dotdashed', 'dashed') hardcopy('blt_test2.ps') figure() plot((1,10,100), log='y') hold('on') loglog((1,19,199), (10,100,1000)) legend('loglog', 'loglog') title('one scale') xlabel('x') ylabel('y') hardcopy('blt_test3.ps') except: print "Error: running debug(plt)" #debug(plt)
| 5,949
|
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('blt_test1.ps') figure() plot((1,2,3), 'r:', (2,3,4), 'b-', (3,4,5), 'k-.',\ (4,6,6), 'g--')#, x='auto') legend('dotted', 'solid', 'dotdashed', 'dashed') hardcopy('blt_test2.ps') figure() plot((1,10,100), log='y') hold('on') loglog((1,19,199), (10,100,1000)) legend('loglog', 'loglog') title('one scale') xlabel('x') ylabel('y') hardcopy('blt_test3.ps') except: print "Error: running debug(plt)" #debug(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('blt_test1.ps') figure() plot((1,2,3), 'r:', (2,3,4), 'b-', (3,4,5), 'k-.',\ (4,6,6), 'g--')#, x='auto') legend('dotted', 'solid', 'dotdashed', 'dashed') hardcopy('blt_test2.ps') figure() plot((1,10,100), log='y') hold('on') loglog((1,19,199), (10,100,1000)) legend('loglog', 'loglog') title('one scale') xlabel('x') ylabel('y') hardcopy('blt_test3.ps') except: print "Error: running debug(plt)" #debug(plt)
| 5,950
|
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() # There is a sys.exit() inside here.... if False: os.system( "python -c '''from easyviz.unittest_ import *;unittest.main()'''") suite = unittest.makeSuite(easyvizTest, 'test') suite = unittest.makeSuite(bltTest, 'test') suite = unittest.makeSuite(gnuplotTest, 'test') else: unittest.TextTestRunner(verbosity=2).run( unittest.makeSuite(easyvizTest)) if False: if os.uname()[0] == 'Linux': psviewer = 'gv' for file in glob.glob('*.ps'): os.system('%s %s &' %(psviewer, file)) for file in glob.glob('*.eps'): os.system('%s %s &' %(psviewer, file)) #raw_input('Press return when files are examined') else: show()
|
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() # There is a sys.exit() inside here.... if False: os.system( "python -c '''from scitools.easyviz.unittest_ import *;unittest.main()'''") suite = unittest.makeSuite(easyvizTest, 'test') suite = unittest.makeSuite(bltTest, 'test') suite = unittest.makeSuite(gnuplotTest, 'test') else: unittest.TextTestRunner(verbosity=2).run( unittest.makeSuite(easyvizTest)) if False: if os.uname()[0] == 'Linux': psviewer = 'gv' for file in glob.glob('*.ps'): os.system('%s %s &' %(psviewer, file)) for file in glob.glob('*.eps'): os.system('%s %s &' %(psviewer, file)) #raw_input('Press return when files are examined') else: show()
| 5,951
|
def __init__(self, *args, **kwargs): PlotProperties.__init__(self, **kwargs) self._prop.update(Streams._local_prop) self._parseargs(*args) self.set(**kwargs)
|
def __init__(self, *args, **kwargs): PlotProperties.__init__(self, **kwargs) self._prop.update(Streams._local_prop) self._parseargs(*args) self.set(**kwargs)
| 5,952
|
def set(self, **kwargs): PlotProperties.set(self, **kwargs)
|
def set(self, **kwargs): PlotProperties.set(self, **kwargs)
| 5,953
|
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. @param failure_handling: one of 'exit', 'warning', 'exception', or 'silent'. In case of failure, the output from the command is always displayed. @return: the same as commands.getstatusoutput, i.e., a boolean failure variable and the output string (result of command). """ if verbose: print 'Running operating system command\n %s' % command failure, output = commands.getstatusoutput(command) if failure: msg = 'Failure when running operating system command'\ '\n %s\nOutput:\n%s' % (command, output) if failure_handling == 'exit': print msg, '\nExecution aborted!' sys.exit(1) if failure_handling == 'warning': print 'Warning:', msg elif failure_handling == 'exception': raise OSError, msg elif failure_handling == 'silent': pass else: raise ValueError, 'wrong value "%s" of failure_handling' % \ failure_handling return failure, output
|
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. @param failure_handling: one of 'exit', 'warning', 'exception', or 'silent'. In case of failure, the output from the command is always displayed. @return: the same as commands.getstatusoutput, i.e., a boolean failure variable and the output string (result of command). """ if verbose: print 'Running operating system command\n %s' % command failure, output = commands.getstatusoutput(command) if failure: msg = 'Failure when running operating system command'\ '\n %s\nOutput:\n%s' % (command, output) if failure_handling == 'exit': print msg, '\nExecution aborted!' sys.exit(1) if failure_handling == 'warning': print 'Warning:', msg elif failure_handling == 'exception': raise OSError, msg elif failure_handling == 'silent': pass else: raise ValueError, 'wrong value "%s" of failure_handling' % \ failure_handling return failure, output
| 5,954
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
| 5,955
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
| 5,956
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
|
def plot(self, *args, **kwargs): """Draw line and scatter plots.
| 5,957
|
def plot3(self, *args, **kwargs): """Draw lines and points in 3D space.
|
def plot3(self, *args, **kwargs): """Draw lines and points in 3D space.
| 5,958
|
def plot3(self, *args, **kwargs): """Draw lines and points in 3D space.
|
def plot3(self, *args, **kwargs): """Draw lines and points in 3D space.
| 5,959
|
def __init__(self, browser=None): Activity.__init__(self)
|
def __init__(self, browser=None): Activity.__init__(self)
| 5,960
|
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 empty: s = s.replace(t, '') return s
|
def getCleanMsgstr(self): s = self.getMsgstr() space = ('\\n', '\\t') empty = ('&',) import re s = re.sub('&[^;]*;', ' ', s) s = re.sub('<[^>]*>', ' ', s) s = re.sub('<[^>]*/>', ' ', s) s = re.sub('</[^>]*>', ' ', s) for t in space: s = s.replace(t, ' ') for t in empty: s = s.replace(t, '') return s
| 5,961
|
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: return (x, None) xa, ea = x - context, '...' if xa < 0: xa, ea = 0, '' xb, eb = x + lwf + context, '...' if xb > lts: xb, eb = lts, '' return (x, ea + textToSearch[xa:xb] + eb)
|
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: return (x, None) xa, ea = x - context, '...' if xa < 0: xa, ea = 0, '' xb, eb = x + lwf + context, '...' if xb > lts: xb, eb = lts, '' return (x, ea + textToSearch[xa:xb] + eb)
| 5,962
|
def usage_exit(progname, msg=None): if msg: print msg print print "usage: %s connstring [-d dblib] outdir [propsfile]" % progname sys.exit(2)
|
def usage_exit(progname, msg=None): if msg: print msg print print "usage: %s [-d dbmodule] connstring outdir [propsfile]" % progname sys.exit(2)
| 5,963
|
def get_columns(self): return map(self.get_column, self._colnames)
|
def get_columns(self): return map(self.get_column, self._colnames)
| 5,964
|
def get_column_names(self): return self._col_names
|
def get_column_names(self): return self._col_names
| 5,965
|
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 table, attr, typ, length, notnull, hasdef, typmod in _query(conn, Q): t = tables.get(table, None) if not t: t = [] tables[table] = t nullable = (notnull != 't') hasdef = (hasdef == 't') if length == -1: length = typmod t.append((attr, typ, nullable, hasdef, length)) return tables
|
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 table, attr, typ, length, notnull, hasdef, typmod in _query(conn, Q): t = tables.get(table, None) if not t: t = [] tables[table] = t assert notnull in ('t', 'f', 1, 0), notnull nullable = (notnull not in ('t', 1)) hasdef = (hasdef == 't') if length == -1: length = typmod t.append((attr, typ, nullable, hasdef, length)) return tables
| 5,966
|
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-index.html">Symbol index</a> | %s' % table.name f.write(self._standard_header(table.name, nav)) f.write('<h1>Table %s</h1>\n' % table.name) f.write('<hr noshade size=1>\n') shortdesc = self.descs.get('table.%s.shortdesc' % table.name, None) if shortdesc: f.write('<p>%s</p>\n' % shortdesc) notes = self.descs.get('table.%s.notes' % table.name, None) if notes: f.write('<h2>Notes</h2>\n') f.write(notes) # allows html f.write('<h2>Columns</h2>\n') f.write('<table border=1>\n<tr bgcolor="%s"><th>Column</th><th>Type</th><th>Nullable</th><th>Default</th><th>Description</th></tr>\n' % self.heading_bg_colour) for col in table.get_columns(): self._index_items.append((col.name, "column in table %s" % table.name, "table-%s.html#col-%s" % (table.name, col.name))) f.write('<tr>') pkey = (col.name == table.primary_key_name) if pkey: name_str = '<strong>%s</strong>' % col.name else: name_str = col.name if col.references is not None: other_table, other_col = col.references f.write('<td><a href="table-%s.html#col-%s">%s</a></td>' % (other_table, other_col, name_str)) else: f.write('<td>%s</td>' % name_str) f.write('<td>%s (%s)</td>' % (col.type, col.length)) f.write('<td>%s</td>' % (col.nullable and 'yes' or 'no')) f.write('<td>%s</td>' % (col.default_value)) col_desc = self.descs.get('table.%s.column.%s.shortdesc' % (table.name, col.name), " ") f.write('<td>%s</td>' % col_desc) f.write('</tr>\n')
|
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", "table-%s.html" % table.name)) f = open(tablefilename, 'w') nav = '<a href="index.html">Table index</a> | <a href="symbol-index.html">Symbol index</a> | %s' % table.name f.write(self._standard_header(table.name, nav)) f.write('<h1>Table %s</h1>\n' % table.name) f.write('<hr noshade size=1>\n') shortdesc = self.descs.get('table.%s.shortdesc' % table.name, None) if shortdesc: f.write('<p>%s</p>\n' % shortdesc) notes = self.descs.get('table.%s.notes' % table.name, None) if notes: f.write('<h2>Notes</h2>\n') f.write(notes) # allows html f.write('<h2>Columns</h2>\n') f.write('<table border=1>\n<tr bgcolor="%s"><th>Column</th><th>Type</th><th>Nullable</th><th>Default</th><th>Description</th></tr>\n' % self.heading_bg_colour) for col in table.get_columns(): self._index_items.append((col.name, "column in table %s" % table.name, "table-%s.html#col-%s" % (table.name, col.name))) f.write('<tr>') pkey = (col.name == table.primary_key_name) if pkey: name_str = '<strong>%s</strong>' % col.name else: name_str = col.name if col.references is not None: other_table, other_col = col.references f.write('<td><a href="table-%s.html#col-%s">%s</a></td>' % (other_table, other_col, name_str)) else: f.write('<td>%s</td>' % name_str) f.write('<td>%s (%s)</td>' % (col.type, col.length)) f.write('<td>%s</td>' % (col.nullable and 'yes' or 'no')) f.write('<td>%s</td>' % (col.default_value)) col_desc = self.descs.get('table.%s.column.%s.shortdesc' % (table.name, col.name), " ") f.write('<td>%s</td>' % col_desc) f.write('</tr>\n')
| 5,967
|
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_proc pg_proc_1, pg_trigger pg_trigger, pg_trigger pg_trigger_1, pg_proc pp, pg_trigger pt WHERE pt.tgrelid = pc.oid AND pp.oid = pt.tgfoid AND pg_trigger.tgconstrrelid = pc.oid AND pg_proc.oid = pg_trigger.tgfoid AND pg_trigger_1.tgfoid = pg_proc_1.oid AND pg_trigger_1.tgconstrrelid = pc.oid AND ((pp.proname LIKE '%ins') AND (pg_proc.proname LIKE '%upd') AND (pg_proc_1.proname LIKE '%del') AND (pg_trigger.tgrelid=pt.tgconstrrelid) AND (pg_trigger_1.tgrelid = pt.tgconstrrelid))'''): tgargs = string.split(tgargs, '\\000') (name, owner_table, referenced_table, unknown, column, referenced_table_pkey, blank) = tgargs t = fkeys.get(owner_table, None) if not t: t = {} fkeys[owner_table] = t t[column] = (referenced_table, referenced_table_pkey) return fkeys
|
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_proc pg_proc_1, pg_trigger pg_trigger, pg_trigger pg_trigger_1, pg_proc pp, pg_trigger pt WHERE pt.tgrelid = pc.oid AND pp.oid = pt.tgfoid AND pg_trigger.tgconstrrelid = pc.oid AND pg_proc.oid = pg_trigger.tgfoid AND pg_trigger_1.tgfoid = pg_proc_1.oid AND pg_trigger_1.tgconstrrelid = pc.oid AND ((pp.proname LIKE '%ins') AND (pg_proc.proname LIKE '%upd') AND (pg_proc_1.proname LIKE '%del') AND (pg_trigger.tgrelid=pt.tgconstrrelid) AND (pg_trigger_1.tgrelid = pt.tgconstrrelid))'''): 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) (name, owner_table, referenced_table, unknown, column, referenced_table_pkey, blank) = tgargs t = fkeys.get(owner_table, None) if not t: t = {} fkeys[owner_table] = t t[column] = (referenced_table, referenced_table_pkey) return fkeys
| 5,968
|
def first(row): return row[0]
|
def first(row): return row[0]
| 5,969
|
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, decode(default_length, NULL, 0, 1) hasdef, decode(data_type, 'DATE', 11, 'NUMBER', nvl(data_precision,38)||'.'||data_scale, data_length) data_length FROM user_tab_columns""" tables = {} for table, attr, typ, notnull, hasdef, length in _query(conn, stmt): t = tables.get(table, None) if not t: t = [] tables[table] = t # If notnull is not one of 'Y' or 'N' raise AssertionError assert notnull in ('Y', 'N'), notnull nullable = (notnull == 'Y') t.append((attr, typ, nullable, hasdef, length)) return tables
|
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, decode(default_length, NULL, 0, 1) hasdef, decode(data_type, 'DATE', '11', 'NUMBER', nvl(data_precision,38)||'.'||data_scale, data_length) data_length FROM user_tab_columns""" tables = {} for table, attr, typ, notnull, hasdef, length in _query(conn, stmt): t = tables.get(table, None) if not t: t = [] tables[table] = t # If notnull is not one of 'Y' or 'N' raise AssertionError assert notnull in ('Y', 'N'), notnull nullable = (notnull == 'Y') t.append((attr, typ, nullable, hasdef, length)) return tables
| 5,970
|
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, decode(default_length, NULL, 0, 1) hasdef, decode(data_type, 'DATE', 11, 'NUMBER', nvl(data_precision,38)||'.'||data_scale, data_length) data_length FROM user_tab_columns""" tables = {} for table, attr, typ, notnull, hasdef, length in _query(conn, stmt): t = tables.get(table, None) if not t: t = [] tables[table] = t # If notnull is not one of 'Y' or 'N' raise AssertionError assert notnull in ('Y', 'N'), notnull nullable = (notnull == 'Y') t.append((attr, typ, nullable, hasdef, length)) return tables
|
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, decode(default_length, NULL, 0, 1) hasdef, decode(data_type, 'DATE', 11, 'NUMBER', nvl(data_precision,38)||'.'||data_scale, data_length) data_length FROM user_tab_columns""" tables = {} for table, attr, typ, nullable, hasdef, length in _query(conn, stmt): t = tables.get(table, None) if not t: t = [] tables[table] = t # If notnull is not one of 'Y' or 'N' raise AssertionError assert notnull in ('Y', 'N'), notnull nullable = (notnull == 'Y') t.append((attr, typ, nullable, hasdef, length)) return tables
| 5,971
|
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, decode(default_length, NULL, 0, 1) hasdef, decode(data_type, 'DATE', 11, 'NUMBER', nvl(data_precision,38)||'.'||data_scale, data_length) data_length FROM user_tab_columns""" tables = {} for table, attr, typ, notnull, hasdef, length in _query(conn, stmt): t = tables.get(table, None) if not t: t = [] tables[table] = t # If notnull is not one of 'Y' or 'N' raise AssertionError assert notnull in ('Y', 'N'), notnull nullable = (notnull == 'Y') t.append((attr, typ, nullable, hasdef, length)) return tables
|
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, decode(default_length, NULL, 0, 1) hasdef, decode(data_type, 'DATE', 11, 'NUMBER', nvl(data_precision,38)||'.'||data_scale, data_length) data_length FROM user_tab_columns""" tables = {} for table, attr, typ, notnull, hasdef, length in _query(conn, stmt): t = tables.get(table, None) if not t: t = [] tables[table] = t # If notnull is not one of 'Y' or 'N' raise AssertionError assert nullable in ('Y', 'N'), nullable nullable = (nullable == 'Y') t.append((attr, typ, nullable, hasdef, length)) return tables
| 5,972
|
def __init__( self , host = '127.0.0.1' , port = 5154 ) :
|
def __init__( self , host = '127.0.0.1' , port = 5154 ) :
| 5,973
|
def queryGame( self ) :
|
def queryGame( self ) :
| 5,974
|
def queryGame( self ) :
|
def queryGame( self ) :
| 5,975
|
def queryGame( self ) :
|
def queryGame( self ) :
| 5,976
|
def queryGame( self ) :
|
def queryGame( self ) :
| 5,977
|
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_unary_pm, check_singlular_opening_braces, check_keyword_spacing, check_multistatements, check_oneliners, check_eol_operators, check_function_call_spaces, check_return_case_parentheses, check_boolean_comparisons, check_boolean_arguments ] # Check trailing spaces and then pre-rstrip lines, after tokenization # we can lstrip them too warnings = [] check_trailing_spaces(lines, warnings) lines = [l.rstrip() for l in lines] for check in line_checks: check(lines, warnings) tokens = tokenize(lines, warnings) find_matching_parentheses(tokens) lines = [l.lstrip() for l in lines] for check in token_checks: check(tokens, lines, warnings) warnings.sort() for w in warnings: print '%s:%d: %s' % (filename, w[0]+1, w[1])
|
def check_file(filename, lines): 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_unary_pm, check_singlular_opening_braces, check_keyword_spacing, check_multistatements, check_oneliners, check_eol_operators, check_function_call_spaces, check_return_case_parentheses, check_boolean_comparisons, check_boolean_arguments ] # Check trailing spaces and then pre-rstrip lines, after tokenization # we can lstrip them too warnings = [] check_trailing_spaces(lines, warnings) lines = [l.rstrip() for l in lines] for check in line_checks: check(lines, warnings) tokens = tokenize(lines, warnings) find_matching_parentheses(tokens) lines = [l.lstrip() for l in lines] for check in token_checks: check(tokens, lines, warnings) warnings.sort() for w in warnings: print '%s:%d: %s' % (filename, w[0]+1, w[1])
| 5,978
|
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)
|
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)
| 5,979
|
command -nargs=+ HiLink hi def link <args>
|
command -nargs=+ HiLink hi def link <args>
| 5,980
|
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))
|
def print_decls(decldict, value): 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))
| 5,981
|
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))
|
def print_decls(decldict): for t, d in decldict.items(): d = [k for k, v in d.items() if v == value] if not d: continue d.sort() print 'syn keyword %s%s %s' % (syntax_name, normalize(t), ' '.join(d))
| 5,982
|
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
|
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
| 5,983
|
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
|
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
| 5,984
|
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
|
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
| 5,985
|
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
|
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
| 5,986
|
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
|
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
| 5,987
|
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
|
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
| 5,988
|
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
|
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
| 5,989
|
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
|
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
| 5,990
|
def __init__(self, mapping): self.__dict__.update(mapping)
|
def __init__(self, mapping): self.__dict__.update(mapping)
| 5,991
|
def run(args): run_mode = args.pop(0) assert run_mode in run_modes filename = args.pop(0) data = Gwyddion.dump.read(filename) dfield = data['/0/data'] a = dfield['data'] n = len(a) mean_value = (min(a) + max(a))/2.0 for i in range(n): a[i] = mean_value - a[i] Gwyddion.dump.write(data, filename)
|
def run(args): run_mode = args.pop(0) assert run_mode in run_modes filename = args.pop(0) data = Gwyddion.dump.read(filename) dfield = data['/0/data'] a = dfield['data'] n = len(a) mirror = min(a) + max(a) for i in range(n): a[i] = mean_value - a[i] Gwyddion.dump.write(data, filename)
| 5,992
|
def run(args): run_mode = args.pop(0) assert run_mode in run_modes filename = args.pop(0) data = Gwyddion.dump.read(filename) dfield = data['/0/data'] a = dfield['data'] n = len(a) mean_value = (min(a) + max(a))/2.0 for i in range(n): a[i] = mean_value - a[i] Gwyddion.dump.write(data, filename)
|
def run(args): run_mode = args.pop(0) assert run_mode in run_modes filename = args.pop(0) data = Gwyddion.dump.read(filename) dfield = data['/0/data'] a = dfield['data'] n = len(a) mean_value = (min(a) + max(a))/2.0 for i in range(n): a[i] = mirror - a[i] Gwyddion.dump.write(data, filename)
| 5,993
|
def recurse(each): cwd = os.getcwd() makefile = get_file('Makefile.am') each(makefile) subdirs = get_list(makefile, 'SUBDIRS') for s in subdirs: os.chdir(s) recurse(each) os.chdir(cwd)
|
def recurse(each): cwd = os.getcwd() try: makefile = get_file('Makefile.am') except IOError: return each(makefile) subdirs = get_list(makefile, 'SUBDIRS') for s in subdirs: os.chdir(s) recurse(each) os.chdir(cwd)
| 5,994
|
def check_missing_spaces_around(tokens, lines, warnings): "Check for missing spaces around <, >, =, etc." operators = '<', '>', '&&', '||', '?', '{' for i, t in enumerate(tokens): if t.typ != Token.punct: continue if t.string not in operators and t.string.find('=') == -1: continue prec = tokens[i-1] mbefore = prec.line == t.line and prec.end == t.col succ = tokens[i+1] mafter = succ.line == t.line and t.end == succ.col w = (None, 'Missing space before `%s\' (col %d): %s', 'Missing space after `%s\' (col %d): %s', 'Missing spaces around `%s\' (col %d): %s')[mbefore + 2*mafter] if w: warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
|
def check_missing_spaces_around(tokens, lines, warnings): "Check for missing spaces around <, >, =, etc." operators = '<', '>', '&&', '||', '?', '{' for t in tokens: if t.typ != Token.punct: continue if t.string not in operators and t.string.find('=') == -1: continue prec = tokens[i-1] mbefore = prec.line == t.line and prec.end == t.col succ = tokens[i+1] mafter = succ.line == t.line and t.end == succ.col w = (None, 'Missing space before `%s\' (col %d): %s', 'Missing space after `%s\' (col %d): %s', 'Missing spaces around `%s\' (col %d): %s')[mbefore + 2*mafter] if w: warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
| 5,995
|
def check_missing_spaces_around(tokens, lines, warnings): "Check for missing spaces around <, >, =, etc." operators = '<', '>', '&&', '||', '?', '{' for i, t in enumerate(tokens): if t.typ != Token.punct: continue if t.string not in operators and t.string.find('=') == -1: continue prec = tokens[i-1] mbefore = prec.line == t.line and prec.end == t.col succ = tokens[i+1] mafter = succ.line == t.line and t.end == succ.col w = (None, 'Missing space before `%s\' (col %d): %s', 'Missing space after `%s\' (col %d): %s', 'Missing spaces around `%s\' (col %d): %s')[mbefore + 2*mafter] if w: warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
|
def check_missing_spaces_around(tokens, lines, warnings): "Check for missing spaces around <, >, =, etc." operators = '<', '>', '&&', '||', '?', '{' for i, t in enumerate(tokens): if t.typ != Token.punct: continue if t.string not in operators and t.string.find('=') == -1: continue mbefore = t.prec.line == t.line and t.prec.end == t.col mafter = t.succ.line == t.line and t.end == t.succ.col w = (None, 'Missing space before `%s\' (col %d): %s', 'Missing space after `%s\' (col %d): %s', 'Missing spaces around `%s\' (col %d): %s')[mbefore + 2*mafter] if w: warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
| 5,996
|
def check_missing_spaces_after(tokens, lines, warnings): "Check for missing spaces after comma, colon" operators = ',', ':' for i, t in enumerate(tokens): if t.typ != Token.punct or t.string not in operators: continue succ = tokens[i+1] if succ.line == t.line and t.end == succ.col: w = 'Missing space after `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
|
def check_missing_spaces_after(tokens, lines, warnings): "Check for missing spaces after comma, colon" operators = ',', ':' for t in tokens: if t.typ != Token.punct or t.string not in operators: continue succ = tokens[i+1] if succ.line == t.line and t.end == succ.col: w = 'Missing space after `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
| 5,997
|
def check_missing_spaces_after(tokens, lines, warnings): "Check for missing spaces after comma, colon" operators = ',', ':' for i, t in enumerate(tokens): if t.typ != Token.punct or t.string not in operators: continue succ = tokens[i+1] if succ.line == t.line and t.end == succ.col: w = 'Missing space after `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
|
def check_missing_spaces_after(tokens, lines, warnings): "Check for missing spaces after comma, colon" operators = ',', ':' for i, t in enumerate(tokens): if t.typ != Token.punct or t.string not in operators: continue if t.succ.line == t.line and t.end == t.succ.col: w = 'Missing space after `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
| 5,998
|
def check_missing_spaces_before(tokens, lines, warnings): "Check for missing spaces before }" operators = '}', for i, t in enumerate(tokens): if t.typ != Token.punct or t.string not in operators: continue prec = tokens[i-1] if prec.line == t.line and prec.end == t.col: w = 'Missing space before `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
|
def check_missing_spaces_before(tokens, lines, warnings): "Check for missing spaces before }" operators = '}', for t in tokens: if t.typ != Token.punct or t.string not in operators: continue prec = tokens[i-1] if prec.line == t.line and prec.end == t.col: w = 'Missing space before `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
| 5,999
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.