repo_name
stringlengths
6
100
path
stringlengths
4
294
copies
stringclasses
981 values
size
stringlengths
4
6
content
stringlengths
606
896k
license
stringclasses
15 values
input_ids
listlengths
1.02k
1.02k
labels
listlengths
1.02k
1.02k
attention_mask
listlengths
1.02k
1.02k
tonnrueter/pymca_devel
PyMca/Object3D/Object3DPlugins/Object3DStack.py
1
24743
import os try: import OpenGL.GL as GL import OpenGL.GLU as GLU except ImportError: raise ImportError, "OpenGL must be installed to use these functionalities" import numpy try: from PyMca import spslut except: import spslut try: from PyMca.Object3D import Object3DFileDialogs from PyMca.Object3D import Object3DBase except ImportError: from Object3D import Object3DFileDialogs from Object3D import Object3DBase try: from PyMca.Object3D import Object3DCTools except ImportError: try: from Object3D import Object3DCTools except: import Object3DCTools import Object3DMeshConfig qt = Object3DMeshConfig.qt import weakref #import buffers DEBUG = 0 import time DRAW_MODES = ['NONE', 'POINT', 'WIRE', 'SURFACE', 'LIGHT', 'POINT_SELECTION'] COLORMAPLIST = [spslut.GREYSCALE, spslut.REVERSEGREY, spslut.TEMP, spslut.RED, spslut.GREEN, spslut.BLUE, spslut.MANY] class Object3DStack(Object3DBase.Object3D): def __init__(self, name = "3D-Array"): Object3DBase.Object3D.__init__(self, name) self._alpha = 255 self.drawListDict = {} self._forceListCalculation = {} self.vertices = None self.vertexColors = None self.vertexSelectionColors = None self._selected = False self._vertexSelectionMode = False self.drawMode = 'POINT' self.__isosurfacesDict = {} for i in range(5): self.__isosurfacesDict[i] = {} self.__isosurfacesDict[i]['list'] = 0 self.__isosurfacesDict[i]['value'] = 0 self.__isosurfacesDict[i]['color'] = 'red' self.__isosurfacesDict[i]['r'] = 0xFF self.__isosurfacesDict[i]['g'] = 0 self.__isosurfacesDict[i]['b'] = 0 self.__isosurfacesDict[i]['a'] = 0xFF self._configuration['common']['supportedmodes'] = [1, 1, 1, 1] self._configuration['common']['mode'] = 1 #centered on XY plane and on Z self._configuration['common']['anchor'] = [2, 2, 2] #self._verticesBufferObject = None #self._vertexColorBufferObject = None #self._vertexSelectionColorBufferObject = None def initPrivateConfiguration(self, name): """ Specific configuration """ self._configuration['private'] = {} if self._privateConfigurationWidget is None: self._privateConfigurationWidget = Object3DMeshConfig.\ Object3DMeshConfig(None, name) self._configuration['private']['widget'] = weakref.proxy(self._privateConfigurationWidget) self._configuration['private']['colorfilter'] = 1 self._configuration['private']['isosurfaces'] = [[1, 20, 'green', 0, 0xFF, 0, 0xFF]] #green #self._configuration['private']['isosurfaces'] = [[1, 10, None, 0, 0, 0, 0xFF]] #auto self._configuration['private']['useminmax'] = [0, 100, 200] self._configuration['private']['infolabel'] = "Object3DStack %s" % name def __del__(self): for key in self.drawListDict.keys(): if key.upper() != "NONE": if self.drawListDict[key] > 0: GL.glDeleteLists(self.drawListDict[key], 1) for key in self.__isosurfacesDict.keys(): if self.__isosurfacesDict[key]['list'] > 0: GL.glDeleteLists(self.__isosurfacesDict[key]['list'], 1) try: Object3DBase.Object3D.__del__(self) except AttributeError: pass def setConfiguration(self, ddict): old_alpha = 1.0 - self._configuration['common']['transparency'] Object3DBase.Object3D.setConfiguration(self, ddict) new_alpha = 1.0 - self._configuration['common']['transparency'] if (new_alpha != old_alpha): self._setAlpha(new_alpha) self.drawMode = DRAW_MODES[self._configuration['common']['mode']] if ddict['common'].has_key('event'): if ddict['common']['event'] == 'ColormapChanged': self.getColors() def _setAlpha(self, alpha): if alpha < 0: alpha = 0 elif alpha >= 1.0: alpha = 255 else: self._alpha = int(255 * alpha) if self.vertexColors is None: return self.vertexColors[:, 3] = self._alpha def setData(self, *args, **kw): return self.setStack(*args, **kw) def setStack(self, data, x=None, y=None, z=None, xyz=None): """ setStack(data, data, xyz=None) data is the array of vertex values. xyz = [x,y,z] are three arrays with the grid coordinates """ if hasattr(data, "info") and hasattr(data, "data"): #It is an actual stack self._actualStack = True self.values = data.data[:] else: self._actualStack = False self.values = data[:] if self.values.dtype != numpy.float32: print("WARNING: Converting to float32") self.values = self.values.astype(numpy.float32) if (x is None) and (y is None) and (xyz is None): xsize, ysize, zsize = self.values.shape self._x = numpy.arange(xsize).astype(numpy.float32) self._y = numpy.arange(ysize).astype(numpy.float32) self._z = numpy.arange(zsize).astype(numpy.float32) if self._actualStack: xCal = map(float, eval(data.info.get('CAxis0CalibrationParameters', '[0., 1.0, 0.0]'))) yCal = map(float, eval(data.info.get('CAxis1CalibrationParameters', '[0., 1.0, 0.0]'))) zCal = map(float, eval(data.info.get('CAxis2CalibrationParameters', '[0., 1.0, 0.0]'))) self._x[:] = xCal[0] + self._x * (xCal[1] + xCal[2] * self._x) self._y[:] = yCal[0] + self._y * (yCal[1] + yCal[2] * self._y) self._z[:] = zCal[0] + self._z * (zCal[1] + zCal[2] * self._z) self.xSize, self.ySize, self.zSize = xsize, ysize, zsize elif xyz is not None: self.xSize, self.ySize, self.zSize = self.values.shape self._x[:] = xyz[0][:] self._y[:] = xyz[1][:] self._z[:] = xyz[2][:] elif (x is not None) and (y is not None): #regular mesh self._x = numpy.array(x).astype(numpy.float32) self._y = numpy.array(y).astype(numpy.float32) self._x.shape = -1, 1 self._y.shape = -1, 1 self.xSize = self._x.shape[0] self.ySize = self._y.shape[0] if z is not None: self._z = numpy.array(z).astype(numpy.float32) if len(self._z.shape) == 0: #assume just a number self.zSize = 1 else: self._z.shape = -1, 1 self.zSize = self._z.shape[0] else: a=1 for v in self.values.shape: a *= v zsize = int(a/(self.xSize * self.ySize)) self._z = numpy.arange(zsize).astype(numpy.float32) self.zSize = zsize else: raise ValueError, "Unhandled case" old_shape = self.values.shape self.nVertices = self.xSize * self.ySize * self.zSize self.values.shape = self.nVertices, 1 self.getColors() self._obtainLimits() #restore original shape self.values.shape = old_shape def getColors(self): old_shape = self.values.shape self.values.shape = -1, 1 self._configuration['common']['colormap'][4]=self.values.min() self._configuration['common']['colormap'][5]=self.values.max() colormap = self._configuration['common']['colormap'] (self.vertexColors,size,minmax)= spslut.transform(self.values, (1,0), (colormap[6],3.0), "RGBX", COLORMAPLIST[int(str(colormap[0]))], colormap[1], (colormap[2], colormap[3]), (0, 255),1) self.values.shape = old_shape self.vertexColors.shape = self.nVertices, 4 self.vertexColors[:, 3] = self._alpha #selection colors # if I have more than pow(2, 24) vertices # the vertex with number pow(2, 24) will never be selected return i = numpy.arange(self.nVertices) self.vertexSelectionColors = numpy.zeros((self.nVertices,4), numpy.uint8) self.vertexSelectionColors[:,0] = (i & 255) self.vertexSelectionColors[:,1] = ((i >> 8) & 255) self.vertexSelectionColors[:,2] = ((i >> 16) & 255) self.vertexSelectionColors[:,3] = 255 - (i >> 24) def _obtainLimits(self): xmin, ymin, zmin = self._x.min(), self._y.min(), self._z.min() xmax, ymax, zmax = self._x.max(), self._y.max(), self._z.max() self.setLimits(xmin, ymin, zmin, xmax, ymax, zmax) def drawObject(self): if self.values is None: return if DEBUG: t0=time.time() GL.glPushAttrib(GL.GL_ALL_ATTRIB_BITS) GL.glShadeModel(GL.GL_FLAT) if self.drawMode == 'NONE': pass elif (GL.glGetIntegerv(GL.GL_RENDER_MODE) == GL.GL_SELECT) or \ self._vertexSelectionMode: self.buildPointList(selection=True) elif self.drawMode == 'POINT': self.buildPointList(selection=False) #self.buildPointListNEW(selection=False) elif self.drawMode == 'POINT_SELECTION': self.buildPointList(selection=True) elif self.drawMode in ['LINES', 'WIRE']: Object3DCTools.draw3DGridLines(self._x, self._y, self._z, self.vertexColors, self.values, self._configuration['private']['colorfilter'], self._configuration['private']['useminmax']) elif self.drawMode == "SURFACE": flag = 1 i = 0 for use, value, label, cr, cg, cb, ca in self._configuration['private']['isosurfaces']: color = (cr, cg, cb, ca) if None in color: color = None if use: flag = 0 GL.glEnable(GL.GL_LIGHTING) if color is not None: GL.glColor4ub(color[0], color[1], color[2], self._alpha) colorflag = False if self.__isosurfacesDict[i]['list'] > 0: if self.__isosurfacesDict[i]['color'] == color: colorflag = True elif (self.__isosurfacesDict[i]['color'] != None) and\ (color != None): colorflag = True if self.__isosurfacesDict[i]['list'] > 0: if (self.__isosurfacesDict[i]['value'] == value) and\ colorflag: GL.glCallList(self.__isosurfacesDict[i]['list']) i += 1 continue GL.glDeleteLists(self.__isosurfacesDict[i]['list'], 1) self.__isosurfacesDict[i]['value']= value self.__isosurfacesDict[i]['color']= color self.__isosurfacesDict[i]['list'] = GL.glGenLists(1) GL.glNewList(self.__isosurfacesDict[i]['list'], GL.GL_COMPILE) GL.glBegin(GL.GL_TRIANGLES) Object3DCTools.gridMarchingCubes(self._x, self._y, self._z, self.values, value, color, (1, 1, 1), 1) #Object3DCTools.gridMarchingCubes(self._x, self._y, self._z, self.values, value, None, (1, 1, 1), 1) GL.glEnd() GL.glEndList() GL.glCallList(self.__isosurfacesDict[i]['list']) GL.glDisable(GL.GL_LIGHTING) i += 1 if flag: #This is useless, only isosurfaces makes sense Object3DCTools.draw3DGridQuads(self._x, self._y, self._z, self.vertexColors, self.values, self._configuration['private']['colorfilter'], self._configuration['private']['useminmax']) else: print "UNSUPPORTED MODE" GL.glPopAttrib() if DEBUG: print "Drawing takes ", time.time() - t0 def _getVertexSelectionColors(self): self.vertexSelectionColors = numpy.zeros((self.nVertices,4), numpy.uint8) #split the color generation in two blocks #to reduce the amount of memory needed half = int(self.nVertices/2) i = numpy.arange(0, half) self.vertexSelectionColors[:half,0] = (i & 255) self.vertexSelectionColors[:half,1] = ((i >> 8) & 255) self.vertexSelectionColors[:half,2] = ((i >> 16) & 255) self.vertexSelectionColors[:half,3] = 255 - (i >> 24) i = numpy.arange(half, self.nVertices) self.vertexSelectionColors[half:,0] = (i & 255) self.vertexSelectionColors[half:,1] = ((i >> 8) & 255) self.vertexSelectionColors[half:,2] = ((i >> 16) & 255) self.vertexSelectionColors[half:,3] = 255 - (i >> 24) def isVertexSelectionModeSupported(self): return True def buildPointList(self, selection=False): if selection: if self.vertexSelectionColors is None: self._getVertexSelectionColors() if self._configuration['private']['colorfilter']: tinyNumber = 1.0e-10 minValue = self._configuration['common']['colormap'][2] + tinyNumber maxValue = self._configuration['common']['colormap'][3] - tinyNumber Object3DCTools.draw3DGridPoints(self._x, self._y, self._z, self.vertexSelectionColors, self.values, 0, [1, minValue, maxValue]) else: Object3DCTools.draw3DGridPoints(self._x, self._y, self._z, self.vertexSelectionColors, self.values, 0, self._configuration['private']['useminmax']) else: Object3DCTools.draw3DGridPoints(self._x, self._y, self._z, self.vertexColors, self.values, self._configuration['private']['colorfilter'], self._configuration['private']['useminmax']) def buildWireList(self): Object3DCTools.draw3DGridLines(self._x, self._y, self._z, self.vertexColors) def __fillVerticesBufferObject(self): if self.vertices is None: self.vertices = Object3DCTools.get3DGridFromXYZ(self._x, self._y, self._z) self.indices = numpy.arange(self.nVertices) self._verticesBufferObject = buffers.VertexBuffer(self.vertices, GL.GL_STATIC_DRAW) self.vertices = None print "self._vertexBufferObject = ", self._verticesBufferObject def __fillVertexColorsBufferObject(self): if self.vertexColors is None: if self.vertexSelectionColors is None: i = numpy.arange(self.nVertices) self.vertexSelectionColors = numpy.zeros((self.nVertices,4), numpy.uint8) self.vertexSelectionColors[:,0] = (i & 255) self.vertexSelectionColors[:,1] = ((i >> 8) & 255) self.vertexSelectionColors[:,2] = ((i >> 16) & 255) self.vertexSelectionColors[:,3] = 255 - (i >> 24) self._vertexColorsBufferObject = buffers.VertexBuffer(self.vertexSelectionColors, GL.GL_STATIC_DRAW) print "self._vertexColorsBufferObject = ", self._vertexColorsBufferObject def buildPointListNEW(self, selection=False): if self._verticesBufferObject is None: self.__fillVerticesBufferObject() if self._vertexColorsBufferObject is None: self.__fillVertexColorsBufferObject() #self._vertexSelectionColorBufferObject = None GL.glEnableClientState(GL.GL_VERTEX_ARRAY) GL.glEnableClientState(GL.GL_COLOR_ARRAY) self._verticesBufferObject.bind() self._vertexColorsBufferObject.bind() GL.glDrawElements(GL.GL_POINTS, self.indices) GL.glDisableClientState(GL.GL_VERTEX_ARRAY) GL.glDisableClientState(GL.GL_COLOR_ARRAY) def buildPointListOLD(self): if self.vertices is None: self.vertices = Object3DCTools.get3DGridFromXYZ(self._x, self._y, self._z) GL.glVertexPointerf(self.vertices) GL.glColorPointerub(self.vertexColors) GL.glEnableClientState(GL.GL_VERTEX_ARRAY) GL.glEnableClientState(GL.GL_COLOR_ARRAY) GL.glDrawArrays(GL.GL_POINTS, 0, self.nVertices) def buildPointList0(self): """ This is just to test memory and speed """ n1, n2, n3 = 256, 256, 256 print "OLD TOTAL = ",71 * 80 * 2000 print "TOTAL = ", 256 * 256 * 256 zdata = numpy.arange(n1*n2*n3).astype(numpy.float32) zdata.shape= -1, 1 print zdata.shape (image,size,minmax)= spslut.transform(zdata, (1,0), (spslut.LINEAR,3.0), "RGBX", spslut.TEMP, 1, (0, 1), (0, 255),1) image.shape = -1, 4 image[:,3] = 255 #self.vertexColors = image.astype(numpy.float32) x = numpy.arange(n1).astype(numpy.float32) y = numpy.arange(n2).astype(numpy.float32) z = numpy.arange(n3).astype(numpy.float32) #Object3DCTools.draw3DGridQuads(x, y, y) #Object3DCTools.draw3DGridLines(x, y, z, image) Object3DCTools.draw3DGridPoints(x, y, z, image) self.zdata = zdata def getIndexValues(self, index): """ x,y,z, I """ xindex = int(index/(self.ySize*self.zSize)) yindex = int((index % (self.ySize*self.zSize))/self.zSize) zindex = index % self.zSize #print "index = ", index, "xindex = ", xindex, "yindex = ", yindex, "zindex = ", zindex if len(self.values.shape) == 3: value = self.values[xindex, yindex, zindex] else: value = self.values[index] return self._x[xindex], self._y[yindex], self._z[zindex], value MENU_TEXT = '4D Stack' def getObject3DInstance(config=None): #for the time being a former configuration #for serializing purposes is not implemented #I do the import here for the case PyMca is not installed #because the modules could be instanstiated without using #this method try: from PyMca import EDFStack from PyMca import TiffStack except ImportError: import EDFStack import TiffStack fileTypeList = ['EDF Z Stack (*edf *ccd)', 'EDF X Stack (*edf *ccd)', 'TIFF Stack (*tif *tiff)'] old = Object3DFileDialogs.Object3DDirs.nativeFileDialogs * 1 Object3DFileDialogs.Object3DDirs.nativeFileDialogs = False fileList, filterUsed = Object3DFileDialogs.getFileList(None, fileTypeList, "Please select the object file(s)", "OPEN", True) Object3DFileDialogs.Object3DDirs.nativeFileDialogs = old if not len(fileList): return None if filterUsed == fileTypeList[0]: fileindex = 2 else: fileindex = 1 #file index is irrelevant in case of an actual 3D stack. filename = fileList[0] legend = os.path.basename(filename) if filterUsed == fileTypeList[2]: #TIFF stack = TiffStack.TiffStack(dtype=numpy.float32, imagestack=False) stack.loadFileList(fileList, fileindex=1) elif len(fileList) == 1: stack = EDFStack.EDFStack(dtype=numpy.float32, imagestack=False) stack.loadIndexedStack(filename, fileindex=fileindex) else: stack = EDFStack.EDFStack(dtype=numpy.float32, imagestack=False) stack.loadFileList(fileList, fileindex=fileindex) if stack is None: raise IOError("Problem reading stack.") object3D = Object3DStack(name=legend) object3D.setStack(stack) return object3D if __name__ == "__main__": import sys from Object3D import SceneGLWindow import os try: from PyMca import EDFStack from PyMca import EdfFile except ImportError: import EDFStack import EdfFile import getopt options = '' longoptions = ["fileindex=","begin=", "end="] try: opts, args = getopt.getopt( sys.argv[1:], options, longoptions) except getopt.error,msg: print msg sys.exit(1) fileindex = 2 begin = None end = None for opt, arg in opts: if opt in '--begin': begin = int(arg) elif opt in '--end': end = int(arg) elif opt in '--fileindex': fileindex = int(arg) app = qt.QApplication(sys.argv) window = SceneGLWindow.SceneGLWindow() window.show() if len(sys.argv) == 1: object3D = getObject3DInstance() if object3D is not None: window.addObject(object3D) else: if len(sys.argv) > 1: stack = EDFStack.EDFStack(dtype=numpy.float32, imagestack=False) filename = args[0] else: stack = EDFStack.EDFStack(dtype=numpy.float32, imagestack=False) filename = "..\COTTE\ch09\ch09__mca_0005_0000_0070.edf" if os.path.exists(filename): print "fileindex = ", fileindex stack.loadIndexedStack(filename, begin=begin, end=end, fileindex=fileindex) object3D = Object3DStack() object3D.setStack(stack) stack = 0 else: print "filename %s does not exists" % filename sys.exit(1) time.sleep(1) print "START ADDING" window.addObject(object3D, "STACK") window.setSelectedObject("STACK") print "END ADDING" window.glWidget.setZoomFactor(1.0) window.show() app.exec_()
gpl-2.0
[ 646, 747, 199, 893, 26, 272, 492, 24374, 14, 2226, 221, 465, 3563, 272, 492, 24374, 14, 20935, 465, 3563, 53, 199, 2590, 3545, 26, 272, 746, 3545, 12, 298, 4299, 2226, 1471, 506, 4903, 370, 675, 3520, 805, 10874, 1417, 2, 199, 646, 2680, 199, 893, 26, 272, 687, 1611, 45, 696, 492, 308, 1190, 30562, 199, 2590, 26, 272, 492, 308, 1190, 30562, 199, 893, 26, 272, 687, 1611, 45, 696, 14, 1692, 19, 36, 492, 6935, 19, 36, 1173, 1341, 18238, 272, 687, 1611, 45, 696, 14, 1692, 19, 36, 492, 6935, 19, 36, 1563, 199, 2590, 3545, 26, 272, 687, 6935, 19, 36, 492, 6935, 19, 36, 1173, 1341, 18238, 272, 687, 6935, 19, 36, 492, 6935, 19, 36, 1563, 199, 199, 893, 26, 272, 687, 1611, 45, 696, 14, 1692, 19, 36, 492, 6935, 19, 36, 1028, 5998, 199, 2590, 3545, 26, 272, 862, 26, 267, 687, 6935, 19, 36, 492, 6935, 19, 36, 1028, 5998, 272, 871, 26, 267, 492, 6935, 19, 36, 1028, 5998, 199, 199, 646, 6935, 19, 36, 12241, 2028, 199, 8440, 275, 6935, 19, 36, 12241, 2028, 14, 8440, 199, 646, 13852, 199, 3, 646, 19383, 199, 5287, 275, 378, 199, 646, 900, 258, 199, 12118, 63, 31095, 275, 788, 9185, 297, 1598, 283, 7217, 297, 1598, 283, 18759, 907, 297, 1598, 283, 51, 1230, 13199, 297, 1598, 283, 21613, 297, 1598, 283, 7217, 63, 4859, 1075, 418, 199, 199, 7134, 5443, 4924, 275, 359, 681, 2482, 337, 14, 39, 907, 57, 24333, 12, 308, 1190, 30562, 14, 907, 21233, 39, 907, 57, 12, 308, 1190, 30562, 14, 12510, 12, 355, 308, 1190, 30562, 14, 7387, 12, 308, 1190, 30562, 14, 22501, 12, 308, 1190, 30562, 14, 23536, 12, 308, 1190, 30562, 14, 6588, 57, 61, 199, 199, 533, 6935, 19, 3177, 13058, 8, 1692, 19, 36, 1563, 14, 1692, 19, 36, 304, 272, 347, 636, 826, 721, 277, 12, 536, 275, 298, 19, 36, 13, 3836, 2349, 267, 6935, 19, 36, 1563, 14, 1692, 19, 36, 855, 826, 721, 277, 12, 536, 9, 267, 291, 423, 4468, 275, 5450, 398, 291, 14, 5485, 1296, 2141, 275, 1052, 267, 291, 423, 3990, 1296, 13862, 425, 275, 1052, 267, 291, 14, 12637, 275, 488, 267, 291, 14, 11417, 20094, 275, 488, 267, 291, 14, 11417, 7713, 20094, 275, 488, 267, 291, 423, 5511, 258, 275, 756, 267, 291, 423, 11417, 7713, 1385, 275, 756, 267, 291, 14, 5485, 1385, 275, 283, 7217, 7, 267, 291, 855, 374, 736, 300, 4309, 2141, 275, 1052, 267, 367, 284, 315, 1425, 8, 21, 304, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 61, 275, 1052, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 513, 418, 275, 378, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 585, 418, 275, 378, 3777, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 2326, 418, 275, 283, 581, 7, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 82, 418, 275, 378, 9039, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 71, 418, 275, 378, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 66, 418, 275, 378, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 65, 418, 275, 378, 9039, 267, 291, 423, 4758, 459, 2330, 2545, 4946, 10433, 418, 275, 359, 17, 12, 413, 12, 413, 12, 413, 61, 267, 291, 423, 4758, 459, 2330, 2545, 632, 418, 275, 413, 398, 327, 20080, 641, 1323, 57, 16388, 436, 641, 3107, 267, 291, 423, 4758, 459, 2330, 2545, 11498, 418, 275, 359, 18, 12, 499, 12, 499, 61, 398, 327, 277, 423, 12637, 3299, 1692, 275, 488, 267, 327, 277, 423, 11417, 4117, 3299, 1692, 275, 488, 267, 327, 277, 423, 11417, 7713, 4117, 3299, 1692, 275, 488, 339, 347, 4205, 12185, 5688, 8, 277, 12, 536, 304, 267, 408, 267, 20411, 2897, 267, 408, 267, 291, 423, 4758, 459, 4239, 418, 275, 1052, 267, 340, 291, 423, 4239, 5688, 3339, 365, 488, 26, 288, 291, 423, 4239, 5688, 3339, 275, 6935, 19, 36, 12241, 2028, 3134, 6901, 6935, 19, 36, 12241, 2028, 8, 403, 12, 536, 9, 267, 291, 423, 4758, 459, 4239, 2545, 3440, 418, 275, 13852, 14, 3280, 8, 277, 423, 4239, 5688, 3339, 9, 267, 291, 423, 4758, 459, 4239, 2545, 2326, 1541, 418, 275, 413, 267, 291, 423, 4758, 459, 4239, 2545, 374, 736, 300, 4309, 418, 275, 3474, 17, 12, 3388, 12, 283, 7731, 297, 378, 12, 378, 9039, 12, 378, 12, 378, 9039, 2677, 327, 7731, 267, 327, 277, 423, 4758, 459, 4239, 2545, 374, 736, 300, 4309, 418, 275, 3474, 17, 12, 1616, 12, 488, 12, 378, 12, 378, 12, 378, 12, 378, 9039, 2677, 327, 2495, 267, 291, 423, 4758, 459, 4239, 2545, 1180, 827, 988, 418, 259, 275, 359, 16, 12, 2948, 12, 1926, 61, 267, 291, 423, 4758, 459, 4239, 2545, 4904, 393, 902, 418, 275, 298, 1692, 19, 3177, 13058, 450, 83, 2, 450, 536, 5493, 347, 636, 2264, 721, 277, 304, 267, 367, 790, 315, 291, 14, 5485, 1296, 2141, 14, 1612, 837, 288, 340, 790, 14, 4142, 342, 1137, 298, 9185, 582, 355, 340, 291, 14, 5485, 1296, 2141, 59, 498, 61, 690, 378, 26, 490, 3563, 14, 3528, 5392, 15116, 8, 277, 14, 5485, 1296, 2141, 59, 498, 467, 413, 9, 398, 367, 790, 315, 291, 855, 374, 736, 300, 4309, 2141, 14, 1612, 837, 288, 340, 291, 855, 374, 736, 300, 4309, 2141, 59, 498, 2733, 513, 418, 690, 378, 26, 355, 3563, 14, 3528, 5392, 15116, 8, 277, 855, 374, 736, 300, 4309, 2141, 59, 498, 2733, 513, 995, 413, 9, 2151, 267, 862, 26, 288, 6935, 19, 36, 1563, 14, 1692, 19, 36, 855, 2264, 721, 277, 9, 267, 871, 4281, 26, 288, 986, 339, 347, 663, 5688, 8, 277, 12, 366, 807, 304, 267, 2269, 63, 4468, 275, 413, 14, 16, 446, 291, 423, 4758, 459, 2330, 2545, 1515, 27292, 418, 267, 6935, 19, 36, 1563, 14, 1692, 19, 36, 14, 409, 5688, 8, 277, 12, 366, 807, 9, 267, 892, 63 ]
[ 747, 199, 893, 26, 272, 492, 24374, 14, 2226, 221, 465, 3563, 272, 492, 24374, 14, 20935, 465, 3563, 53, 199, 2590, 3545, 26, 272, 746, 3545, 12, 298, 4299, 2226, 1471, 506, 4903, 370, 675, 3520, 805, 10874, 1417, 2, 199, 646, 2680, 199, 893, 26, 272, 687, 1611, 45, 696, 492, 308, 1190, 30562, 199, 2590, 26, 272, 492, 308, 1190, 30562, 199, 893, 26, 272, 687, 1611, 45, 696, 14, 1692, 19, 36, 492, 6935, 19, 36, 1173, 1341, 18238, 272, 687, 1611, 45, 696, 14, 1692, 19, 36, 492, 6935, 19, 36, 1563, 199, 2590, 3545, 26, 272, 687, 6935, 19, 36, 492, 6935, 19, 36, 1173, 1341, 18238, 272, 687, 6935, 19, 36, 492, 6935, 19, 36, 1563, 199, 199, 893, 26, 272, 687, 1611, 45, 696, 14, 1692, 19, 36, 492, 6935, 19, 36, 1028, 5998, 199, 2590, 3545, 26, 272, 862, 26, 267, 687, 6935, 19, 36, 492, 6935, 19, 36, 1028, 5998, 272, 871, 26, 267, 492, 6935, 19, 36, 1028, 5998, 199, 199, 646, 6935, 19, 36, 12241, 2028, 199, 8440, 275, 6935, 19, 36, 12241, 2028, 14, 8440, 199, 646, 13852, 199, 3, 646, 19383, 199, 5287, 275, 378, 199, 646, 900, 258, 199, 12118, 63, 31095, 275, 788, 9185, 297, 1598, 283, 7217, 297, 1598, 283, 18759, 907, 297, 1598, 283, 51, 1230, 13199, 297, 1598, 283, 21613, 297, 1598, 283, 7217, 63, 4859, 1075, 418, 199, 199, 7134, 5443, 4924, 275, 359, 681, 2482, 337, 14, 39, 907, 57, 24333, 12, 308, 1190, 30562, 14, 907, 21233, 39, 907, 57, 12, 308, 1190, 30562, 14, 12510, 12, 355, 308, 1190, 30562, 14, 7387, 12, 308, 1190, 30562, 14, 22501, 12, 308, 1190, 30562, 14, 23536, 12, 308, 1190, 30562, 14, 6588, 57, 61, 199, 199, 533, 6935, 19, 3177, 13058, 8, 1692, 19, 36, 1563, 14, 1692, 19, 36, 304, 272, 347, 636, 826, 721, 277, 12, 536, 275, 298, 19, 36, 13, 3836, 2349, 267, 6935, 19, 36, 1563, 14, 1692, 19, 36, 855, 826, 721, 277, 12, 536, 9, 267, 291, 423, 4468, 275, 5450, 398, 291, 14, 5485, 1296, 2141, 275, 1052, 267, 291, 423, 3990, 1296, 13862, 425, 275, 1052, 267, 291, 14, 12637, 275, 488, 267, 291, 14, 11417, 20094, 275, 488, 267, 291, 14, 11417, 7713, 20094, 275, 488, 267, 291, 423, 5511, 258, 275, 756, 267, 291, 423, 11417, 7713, 1385, 275, 756, 267, 291, 14, 5485, 1385, 275, 283, 7217, 7, 267, 291, 855, 374, 736, 300, 4309, 2141, 275, 1052, 267, 367, 284, 315, 1425, 8, 21, 304, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 61, 275, 1052, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 513, 418, 275, 378, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 585, 418, 275, 378, 3777, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 2326, 418, 275, 283, 581, 7, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 82, 418, 275, 378, 9039, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 71, 418, 275, 378, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 66, 418, 275, 378, 288, 291, 855, 374, 736, 300, 4309, 2141, 59, 73, 2733, 65, 418, 275, 378, 9039, 267, 291, 423, 4758, 459, 2330, 2545, 4946, 10433, 418, 275, 359, 17, 12, 413, 12, 413, 12, 413, 61, 267, 291, 423, 4758, 459, 2330, 2545, 632, 418, 275, 413, 398, 327, 20080, 641, 1323, 57, 16388, 436, 641, 3107, 267, 291, 423, 4758, 459, 2330, 2545, 11498, 418, 275, 359, 18, 12, 499, 12, 499, 61, 398, 327, 277, 423, 12637, 3299, 1692, 275, 488, 267, 327, 277, 423, 11417, 4117, 3299, 1692, 275, 488, 267, 327, 277, 423, 11417, 7713, 4117, 3299, 1692, 275, 488, 339, 347, 4205, 12185, 5688, 8, 277, 12, 536, 304, 267, 408, 267, 20411, 2897, 267, 408, 267, 291, 423, 4758, 459, 4239, 418, 275, 1052, 267, 340, 291, 423, 4239, 5688, 3339, 365, 488, 26, 288, 291, 423, 4239, 5688, 3339, 275, 6935, 19, 36, 12241, 2028, 3134, 6901, 6935, 19, 36, 12241, 2028, 8, 403, 12, 536, 9, 267, 291, 423, 4758, 459, 4239, 2545, 3440, 418, 275, 13852, 14, 3280, 8, 277, 423, 4239, 5688, 3339, 9, 267, 291, 423, 4758, 459, 4239, 2545, 2326, 1541, 418, 275, 413, 267, 291, 423, 4758, 459, 4239, 2545, 374, 736, 300, 4309, 418, 275, 3474, 17, 12, 3388, 12, 283, 7731, 297, 378, 12, 378, 9039, 12, 378, 12, 378, 9039, 2677, 327, 7731, 267, 327, 277, 423, 4758, 459, 4239, 2545, 374, 736, 300, 4309, 418, 275, 3474, 17, 12, 1616, 12, 488, 12, 378, 12, 378, 12, 378, 12, 378, 9039, 2677, 327, 2495, 267, 291, 423, 4758, 459, 4239, 2545, 1180, 827, 988, 418, 259, 275, 359, 16, 12, 2948, 12, 1926, 61, 267, 291, 423, 4758, 459, 4239, 2545, 4904, 393, 902, 418, 275, 298, 1692, 19, 3177, 13058, 450, 83, 2, 450, 536, 5493, 347, 636, 2264, 721, 277, 304, 267, 367, 790, 315, 291, 14, 5485, 1296, 2141, 14, 1612, 837, 288, 340, 790, 14, 4142, 342, 1137, 298, 9185, 582, 355, 340, 291, 14, 5485, 1296, 2141, 59, 498, 61, 690, 378, 26, 490, 3563, 14, 3528, 5392, 15116, 8, 277, 14, 5485, 1296, 2141, 59, 498, 467, 413, 9, 398, 367, 790, 315, 291, 855, 374, 736, 300, 4309, 2141, 14, 1612, 837, 288, 340, 291, 855, 374, 736, 300, 4309, 2141, 59, 498, 2733, 513, 418, 690, 378, 26, 355, 3563, 14, 3528, 5392, 15116, 8, 277, 855, 374, 736, 300, 4309, 2141, 59, 498, 2733, 513, 995, 413, 9, 2151, 267, 862, 26, 288, 6935, 19, 36, 1563, 14, 1692, 19, 36, 855, 2264, 721, 277, 9, 267, 871, 4281, 26, 288, 986, 339, 347, 663, 5688, 8, 277, 12, 366, 807, 304, 267, 2269, 63, 4468, 275, 413, 14, 16, 446, 291, 423, 4758, 459, 2330, 2545, 1515, 27292, 418, 267, 6935, 19, 36, 1563, 14, 1692, 19, 36, 14, 409, 5688, 8, 277, 12, 366, 807, 9, 267, 892, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
kennethgillen/ansible
lib/ansible/modules/files/fetch.py
29
3714
# this is a virtual module that is entirely implemented server side # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['stableinterface'], 'supported_by': 'core'} DOCUMENTATION = ''' --- module: fetch short_description: Fetches a file from remote nodes description: - This module works like M(copy), but in reverse. It is used for fetching files from remote machines and storing them locally in a file tree, organized by hostname. Note that this module is written to transfer log files that might not be present, so a missing remote file won't be an error unless fail_on_missing is set to 'yes'. version_added: "0.2" options: src: description: - The file on the remote system to fetch. This I(must) be a file, not a directory. Recursive fetching may be supported in a later release. required: true default: null aliases: [] dest: description: - A directory to save the file into. For example, if the I(dest) directory is C(/backup) a I(src) file named C(/etc/profile) on host C(host.example.com), would be saved into C(/backup/host.example.com/etc/profile) required: true default: null fail_on_missing: version_added: "1.1" description: - When set to 'yes', the task will fail if the source file is missing. required: false choices: [ "yes", "no" ] default: "no" validate_checksum: version_added: "1.4" description: - Verify that the source and destination checksums match after the files are fetched. required: false choices: [ "yes", "no" ] default: "yes" aliases: [ "validate_md5" ] flat: version_added: "1.2" description: - Allows you to override the default behavior of appending hostname/path/to/file to the destination. If dest ends with '/', it will use the basename of the source file, similar to the copy module. Obviously this is only handy if the filenames are unique. requirements: [] author: - "Ansible Core Team" - "Michael DeHaan" notes: - When running fetch with C(become), the M(slurp) module will also be used to fetch the contents of the file for determining the remote checksum. This effectively doubles the transfer size, and depending on the file size can consume all available memory on the remote or local hosts causing a C(MemoryError). Due to this it is advisable to run this module without C(become) whenever possible. ''' EXAMPLES = ''' # Store file into /tmp/fetched/host.example.com/tmp/somefile - fetch: src: /tmp/somefile dest: /tmp/fetched # Specifying a path directly - fetch: src: /tmp/somefile dest: /tmp/prefix-{{ inventory_hostname }} flat: yes # Specifying a destination path - fetch: src: /tmp/uniquefile dest: /tmp/special/ flat: yes # Storing in a path relative to the playbook - fetch: src: /tmp/uniquefile dest: special/prefix-{{ inventory_hostname }} flat: yes '''
gpl-3.0
[ 3, 642, 365, 282, 5791, 859, 626, 365, 21926, 6366, 1654, 5366, 199, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 5267, 199, 3612, 63, 1802, 26, 16347, 397, 282, 570, 687, 3982, 3380, 199, 1802, 26, 1362, 446, 961, 859, 5419, 2839, 603, 8, 1574, 395, 1325, 315, 3837, 14, 2779, 365, 1202, 367, 21239, 2126, 1584, 687, 3982, 20601, 436, 16915, 3062, 17738, 315, 282, 570, 3123, 12, 2126, 20765, 1759, 701, 6246, 14, 3390, 626, 642, 859, 365, 5313, 370, 9307, 2126, 943, 1584, 626, 5594, 440, 506, 3451, 12, 880, 282, 4124, 3982, 570, 7859, 1133, 2126, 506, 376, 1125, 7444, 2449, 63, 265, 63, 4752, 365, 663, 370, 283, 5066, 1370, 199, 1023, 63, 3270, 26, 298, 16, 14, 18, 2, 199, 1419, 26, 523, 2928, 26, 272, 1369, 26, 489, 446, 710, 570, 641, 314, 3982, 2656, 370, 5267, 14, 961, 473, 8, 7790, 9, 506, 282, 570, 12, 440, 282, 267, 2082, 14, 18306, 3398, 21239, 1443, 506, 3748, 315, 282, 2945, 4683, 14, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 2053, 26, 272, 1369, 26, 489, 446, 437, 2082, 370, 3354, 314, 570, 1901, 14, 2104, 2893, 12, 340, 314, 473, 8, 2614, 9, 267, 2082, 365, 445, 29478, 5751, 9, 282, 473, 8, 2164, 9, 570, 4310, 445, 29478, 6839, 15, 2913, 9, 641, 1591, 267, 445, 8, 1102, 14, 2694, 14, 957, 395, 3955, 506, 6290, 1901, 267, 445, 29478, 5751, 15, 1102, 14, 2694, 14, 957, 15, 6839, 15, 2913, 9, 272, 1415, 26, 2549, 272, 849, 26, 2973, 523, 2449, 63, 265, 63, 4752, 26, 272, 1015, 63, 3270, 26, 298, 17, 14, 17, 2, 272, 1369, 26, 489, 446, 3979, 663, 370, 283, 5066, 297, 314, 2120, 911, 2449, 340, 314, 1350, 570, 365, 4124, 14, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 272, 849, 26, 298, 889, 2, 523, 4107, 63, 8928, 26, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 272, 1369, 26, 489, 446, 7635, 626, 314, 1350, 436, 5724, 9040, 83, 1336, 2410, 314, 1584, 787, 19251, 14, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 272, 849, 26, 298, 5066, 2, 272, 5481, 26, 359, 298, 3502, 63, 1064, 21, 2, 1622, 523, 6829, 26, 272, 1015, 63, 3270, 26, 298, 17, 14, 18, 2, 272, 1369, 26, 489, 446, 22819, 1265, 370, 4278, 314, 849, 5953, 402, 24373, 267, 6246, 15, 515, 15, 475, 15, 493, 370, 314, 5724, 14, 221, 982, 2053, 11187, 543, 17220, 652, 267, 911, 675, 314, 9593, 402, 314, 1350, 570, 12, 8545, 370, 314, 1331, 859, 14, 267, 17985, 2971, 590, 642, 365, 1454, 4926, 89, 340, 314, 6203, 787, 3747, 14, 199, 7538, 26, 942, 199, 2502, 26, 272, 446, 298, 10047, 11672, 11682, 2, 272, 446, 298, 45, 11781, 22453, 2, 199, 5983, 26, 272, 446, 3979, 3879, 5267, 543, 445, 8, 13970, 395, 314, 603, 8, 2482, 300, 80, 9, 859, 911, 2597, 506, 489, 1202, 370, 5267, 314, 4072, 402, 314, 570, 367, 26638, 314, 3982, 489, 9040, 14, 961, 27881, 4270, 83, 314, 9307, 1568, 12, 436, 489, 10298, 641, 314, 570, 1568, 883, 9451, 1006, 2808, 4402, 641, 314, 489, 3982, 503, 2257, 7057, 25498, 282, 445, 8, 8628, 547, 680, 25855, 370, 642, 652, 365, 489, 1503, 5068, 461, 370, 1255, 642, 859, 1928, 445, 8, 13970, 9, 18119, 3962, 14, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 13874, 570, 1901, 1182, 2791, 15, 27236, 15, 1102, 14, 2694, 14, 957, 15, 2791, 15, 3972, 493, 199, 13, 5267, 26, 272, 2928, 26, 1182, 2791, 15, 3972, 493, 272, 2053, 26, 1182, 2791, 15, 27236, 199, 199, 3, 13327, 316, 282, 931, 5370, 199, 13, 5267, 26, 272, 2928, 26, 1182, 2791, 15, 3972, 493, 272, 2053, 26, 1182, 2791, 15, 1861, 13, 3638, 8200, 63, 4269, 3586, 272, 6829, 26, 9456, 199, 199, 3, 13327, 316, 282, 5724, 931, 199, 13, 5267, 26, 272, 2928, 26, 1182, 2791, 15, 3235, 493, 272, 2053, 26, 1182, 2791, 15, 6664, 15, 272, 6829, 26, 9456, 199, 199, 3, 1933, 6854, 315, 282, 931, 3847, 370, 314, 15695, 199, 13, 5267, 26, 272, 2928, 26, 1182, 2791, 15, 3235, 493, 272, 2053, 26, 4539, 15, 1861, 13, 3638, 8200, 63, 4269, 3586, 272, 6829, 26, 9456, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 642, 365, 282, 5791, 859, 626, 365, 21926, 6366, 1654, 5366, 199, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 16, 297, 490, 283, 1205, 356, 788, 11989, 3266, 995, 490, 283, 4946, 63, 991, 356, 283, 1018, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 5267, 199, 3612, 63, 1802, 26, 16347, 397, 282, 570, 687, 3982, 3380, 199, 1802, 26, 1362, 446, 961, 859, 5419, 2839, 603, 8, 1574, 395, 1325, 315, 3837, 14, 2779, 365, 1202, 367, 21239, 2126, 1584, 687, 3982, 20601, 436, 16915, 3062, 17738, 315, 282, 570, 3123, 12, 2126, 20765, 1759, 701, 6246, 14, 3390, 626, 642, 859, 365, 5313, 370, 9307, 2126, 943, 1584, 626, 5594, 440, 506, 3451, 12, 880, 282, 4124, 3982, 570, 7859, 1133, 2126, 506, 376, 1125, 7444, 2449, 63, 265, 63, 4752, 365, 663, 370, 283, 5066, 1370, 199, 1023, 63, 3270, 26, 298, 16, 14, 18, 2, 199, 1419, 26, 523, 2928, 26, 272, 1369, 26, 489, 446, 710, 570, 641, 314, 3982, 2656, 370, 5267, 14, 961, 473, 8, 7790, 9, 506, 282, 570, 12, 440, 282, 267, 2082, 14, 18306, 3398, 21239, 1443, 506, 3748, 315, 282, 2945, 4683, 14, 272, 1415, 26, 2549, 272, 849, 26, 2973, 272, 5481, 26, 942, 523, 2053, 26, 272, 1369, 26, 489, 446, 437, 2082, 370, 3354, 314, 570, 1901, 14, 2104, 2893, 12, 340, 314, 473, 8, 2614, 9, 267, 2082, 365, 445, 29478, 5751, 9, 282, 473, 8, 2164, 9, 570, 4310, 445, 29478, 6839, 15, 2913, 9, 641, 1591, 267, 445, 8, 1102, 14, 2694, 14, 957, 395, 3955, 506, 6290, 1901, 267, 445, 29478, 5751, 15, 1102, 14, 2694, 14, 957, 15, 6839, 15, 2913, 9, 272, 1415, 26, 2549, 272, 849, 26, 2973, 523, 2449, 63, 265, 63, 4752, 26, 272, 1015, 63, 3270, 26, 298, 17, 14, 17, 2, 272, 1369, 26, 489, 446, 3979, 663, 370, 283, 5066, 297, 314, 2120, 911, 2449, 340, 314, 1350, 570, 365, 4124, 14, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 272, 849, 26, 298, 889, 2, 523, 4107, 63, 8928, 26, 272, 1015, 63, 3270, 26, 298, 17, 14, 20, 2, 272, 1369, 26, 489, 446, 7635, 626, 314, 1350, 436, 5724, 9040, 83, 1336, 2410, 314, 1584, 787, 19251, 14, 272, 1415, 26, 3055, 272, 3415, 26, 359, 298, 5066, 401, 298, 889, 2, 1622, 272, 849, 26, 298, 5066, 2, 272, 5481, 26, 359, 298, 3502, 63, 1064, 21, 2, 1622, 523, 6829, 26, 272, 1015, 63, 3270, 26, 298, 17, 14, 18, 2, 272, 1369, 26, 489, 446, 22819, 1265, 370, 4278, 314, 849, 5953, 402, 24373, 267, 6246, 15, 515, 15, 475, 15, 493, 370, 314, 5724, 14, 221, 982, 2053, 11187, 543, 17220, 652, 267, 911, 675, 314, 9593, 402, 314, 1350, 570, 12, 8545, 370, 314, 1331, 859, 14, 267, 17985, 2971, 590, 642, 365, 1454, 4926, 89, 340, 314, 6203, 787, 3747, 14, 199, 7538, 26, 942, 199, 2502, 26, 272, 446, 298, 10047, 11672, 11682, 2, 272, 446, 298, 45, 11781, 22453, 2, 199, 5983, 26, 272, 446, 3979, 3879, 5267, 543, 445, 8, 13970, 395, 314, 603, 8, 2482, 300, 80, 9, 859, 911, 2597, 506, 489, 1202, 370, 5267, 314, 4072, 402, 314, 570, 367, 26638, 314, 3982, 489, 9040, 14, 961, 27881, 4270, 83, 314, 9307, 1568, 12, 436, 489, 10298, 641, 314, 570, 1568, 883, 9451, 1006, 2808, 4402, 641, 314, 489, 3982, 503, 2257, 7057, 25498, 282, 445, 8, 8628, 547, 680, 25855, 370, 642, 652, 365, 489, 1503, 5068, 461, 370, 1255, 642, 859, 1928, 445, 8, 13970, 9, 18119, 3962, 14, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 13874, 570, 1901, 1182, 2791, 15, 27236, 15, 1102, 14, 2694, 14, 957, 15, 2791, 15, 3972, 493, 199, 13, 5267, 26, 272, 2928, 26, 1182, 2791, 15, 3972, 493, 272, 2053, 26, 1182, 2791, 15, 27236, 199, 199, 3, 13327, 316, 282, 931, 5370, 199, 13, 5267, 26, 272, 2928, 26, 1182, 2791, 15, 3972, 493, 272, 2053, 26, 1182, 2791, 15, 1861, 13, 3638, 8200, 63, 4269, 3586, 272, 6829, 26, 9456, 199, 199, 3, 13327, 316, 282, 5724, 931, 199, 13, 5267, 26, 272, 2928, 26, 1182, 2791, 15, 3235, 493, 272, 2053, 26, 1182, 2791, 15, 6664, 15, 272, 6829, 26, 9456, 199, 199, 3, 1933, 6854, 315, 282, 931, 3847, 370, 314, 15695, 199, 13, 5267, 26, 272, 2928, 26, 1182, 2791, 15, 3235, 493, 272, 2053, 26, 4539, 15, 1861, 13, 3638, 8200, 63, 4269, 3586, 272, 6829, 26, 9456, 199, 2344, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
djhaskin987/psutil
test/_sunos.py
45
1345
#!/usr/bin/env python # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Sun OS specific tests. These are implicitly run by test_psutil.py.""" import sys from test_psutil import sh, unittest import psutil class SunOSSpecificTestCase(unittest.TestCase): def test_swap_memory(self): out = sh('swap -l -k') lines = out.strip().split('\n')[1:] if not lines: raise ValueError('no swap device(s) configured') total = free = 0 for line in lines: line = line.split() t, f = line[-2:] t = t.replace('K', '') f = f.replace('K', '') total += int(int(t) * 1024) free += int(int(f) * 1024) used = total - free psutil_swap = psutil.swap_memory() self.assertEqual(psutil_swap.total, total) self.assertEqual(psutil_swap.used, used) self.assertEqual(psutil_swap.free, free) def test_main(): test_suite = unittest.TestSuite() test_suite.addTest(unittest.makeSuite(SunOSSpecificTestCase)) result = unittest.TextTestRunner(verbosity=2).run(test_suite) return result.wasSuccessful() if __name__ == '__main__': if not test_main(): sys.exit(1)
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 8937, 12, 598, 4674, 311, 8035, 320, 820, 364, 22205, 1370, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 22546, 4403, 2488, 2295, 14, 221, 5723, 787, 19796, 1255, 701, 511, 63, 31903, 14, 647, 1041, 199, 199, 646, 984, 199, 199, 504, 511, 63, 31903, 492, 1033, 12, 2882, 199, 646, 22214, 421, 199, 533, 25625, 47, 2300, 910, 1792, 1746, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 9286, 63, 4844, 8, 277, 304, 267, 734, 275, 1033, 360, 9286, 446, 76, 446, 75, 358, 267, 2385, 275, 734, 14, 1913, 1252, 1294, 2258, 78, 5832, 17, 2938, 267, 340, 440, 2385, 26, 288, 746, 1722, 360, 889, 11413, 2243, 8, 83, 9, 7526, 358, 267, 3141, 275, 2867, 275, 378, 267, 367, 1004, 315, 2385, 26, 288, 1004, 275, 1004, 14, 1294, 342, 288, 307, 12, 289, 275, 1004, 1988, 18, 2938, 288, 307, 275, 307, 14, 1814, 360, 43, 297, 4074, 288, 289, 275, 289, 14, 1814, 360, 43, 297, 4074, 288, 3141, 847, 1109, 8, 442, 8, 84, 9, 627, 6619, 9, 288, 2867, 847, 1109, 8, 442, 8, 70, 9, 627, 6619, 9, 267, 1202, 275, 3141, 446, 2867, 398, 22214, 63, 9286, 275, 22214, 14, 9286, 63, 4844, 342, 267, 291, 14, 629, 8, 31903, 63, 9286, 14, 2923, 12, 3141, 9, 267, 291, 14, 629, 8, 31903, 63, 9286, 14, 2972, 12, 1202, 9, 267, 291, 14, 629, 8, 31903, 63, 9286, 14, 4624, 12, 2867, 9, 421, 199, 318, 511, 63, 973, 837, 272, 511, 63, 5768, 275, 2882, 14, 10591, 342, 272, 511, 63, 5768, 14, 15714, 8, 2796, 14, 18275, 8, 22546, 47, 2300, 910, 1792, 1746, 430, 272, 754, 275, 2882, 14, 24285, 8, 9833, 29, 18, 680, 1065, 8, 396, 63, 5768, 9, 272, 372, 754, 14, 10274, 20839, 342, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 340, 440, 511, 63, 973, 837, 267, 984, 14, 2224, 8, 17, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 3, 1898, 334, 67, 9, 8937, 12, 598, 4674, 311, 8035, 320, 820, 364, 22205, 1370, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 624, 22546, 4403, 2488, 2295, 14, 221, 5723, 787, 19796, 1255, 701, 511, 63, 31903, 14, 647, 1041, 199, 199, 646, 984, 199, 199, 504, 511, 63, 31903, 492, 1033, 12, 2882, 199, 646, 22214, 421, 199, 533, 25625, 47, 2300, 910, 1792, 1746, 8, 2796, 14, 1746, 304, 339, 347, 511, 63, 9286, 63, 4844, 8, 277, 304, 267, 734, 275, 1033, 360, 9286, 446, 76, 446, 75, 358, 267, 2385, 275, 734, 14, 1913, 1252, 1294, 2258, 78, 5832, 17, 2938, 267, 340, 440, 2385, 26, 288, 746, 1722, 360, 889, 11413, 2243, 8, 83, 9, 7526, 358, 267, 3141, 275, 2867, 275, 378, 267, 367, 1004, 315, 2385, 26, 288, 1004, 275, 1004, 14, 1294, 342, 288, 307, 12, 289, 275, 1004, 1988, 18, 2938, 288, 307, 275, 307, 14, 1814, 360, 43, 297, 4074, 288, 289, 275, 289, 14, 1814, 360, 43, 297, 4074, 288, 3141, 847, 1109, 8, 442, 8, 84, 9, 627, 6619, 9, 288, 2867, 847, 1109, 8, 442, 8, 70, 9, 627, 6619, 9, 267, 1202, 275, 3141, 446, 2867, 398, 22214, 63, 9286, 275, 22214, 14, 9286, 63, 4844, 342, 267, 291, 14, 629, 8, 31903, 63, 9286, 14, 2923, 12, 3141, 9, 267, 291, 14, 629, 8, 31903, 63, 9286, 14, 2972, 12, 1202, 9, 267, 291, 14, 629, 8, 31903, 63, 9286, 14, 4624, 12, 2867, 9, 421, 199, 318, 511, 63, 973, 837, 272, 511, 63, 5768, 275, 2882, 14, 10591, 342, 272, 511, 63, 5768, 14, 15714, 8, 2796, 14, 18275, 8, 22546, 47, 2300, 910, 1792, 1746, 430, 272, 754, 275, 2882, 14, 24285, 8, 9833, 29, 18, 680, 1065, 8, 396, 63, 5768, 9, 272, 372, 754, 14, 10274, 20839, 342, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 340, 440, 511, 63, 973, 837, 267, 984, 14, 2224, 8, 17, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
agraubert/agutil
agutil/parallel/src/dispatcher.py
1
2555
from .exceptions import _ParallelBackgroundException from .worker import ThreadWorker, ProcessWorker from itertools import zip_longest WORKERTYPE_THREAD = ThreadWorker WORKERTYPE_PROCESS = ProcessWorker class IterDispatcher: def __init__( self, func, *args, maximum=15, workertype=WORKERTYPE_THREAD, **kwargs ): self.func = func self.maximum = maximum self.args = [iter(arg) for arg in args] self.kwargs = {key: iter(v) for (key, v) in kwargs.items()} self.worker = workertype def run(self): yield from self.dispatch() def dispatch(self): self.worker = self.worker(self.maximum) try: output = [] for args, kwargs in self._iterargs(): # _args = args if args is not None else [] # _kwargs = kwargs if kwargs is not None else {} output.append(self.worker.work( self.func, *args, **kwargs )) for callback in output: result = callback() if isinstance(result, _ParallelBackgroundException): raise result.exc yield result finally: self.worker.close() def _iterargs(self): while True: args = [] had_arg = False for src in self.args: try: args.append(next(src)) had_arg = True except StopIteration: return # args.append(None) kwargs = {} for key, src in self.kwargs.items(): try: kwargs[key] = next(src) had_arg = True except StopIteration: return # kwargs[key] = None if not had_arg: return yield args, kwargs def __iter__(self): yield from self.dispatch() def is_alive(self): return self.worker.is_alive() class DemandDispatcher: def __init__(self, func, maximum=15, workertype=WORKERTYPE_THREAD): self.maximum = maximum self.func = func self.worker = workertype(self.maximum) def dispatch(self, *args, **kwargs): try: return self.worker.work(self.func, *args, **kwargs) except BaseException: self.worker.close() raise def close(self): self.worker.close()
mit
[ 504, 1275, 3924, 492, 485, 25721, 14148, 1726, 199, 504, 1275, 6599, 492, 11086, 12678, 12, 7132, 12678, 199, 504, 7975, 492, 3482, 63, 20820, 199, 199, 8406, 540, 2711, 63, 16103, 275, 11086, 12678, 199, 8406, 540, 2711, 63, 10494, 275, 7132, 12678, 421, 199, 533, 11953, 15461, 26, 272, 347, 636, 826, 721, 267, 291, 12, 267, 2562, 12, 267, 627, 589, 12, 267, 5696, 29, 1046, 12, 267, 7239, 466, 29, 8406, 540, 2711, 63, 16103, 12, 267, 1011, 958, 272, 3461, 267, 291, 14, 1532, 275, 2562, 267, 291, 14, 11555, 275, 5696, 267, 291, 14, 589, 275, 359, 1661, 8, 1273, 9, 367, 1680, 315, 1249, 61, 267, 291, 14, 958, 275, 469, 498, 26, 2740, 8, 86, 9, 367, 334, 498, 12, 373, 9, 315, 2074, 14, 1744, 12737, 267, 291, 14, 6599, 275, 7239, 466, 339, 347, 1255, 8, 277, 304, 267, 1995, 687, 291, 14, 6052, 342, 339, 347, 7634, 8, 277, 304, 267, 291, 14, 6599, 275, 291, 14, 6599, 8, 277, 14, 11555, 9, 267, 862, 26, 288, 1072, 275, 942, 288, 367, 1249, 12, 2074, 315, 291, 423, 1661, 589, 837, 355, 327, 485, 589, 275, 1249, 340, 1249, 365, 440, 488, 587, 942, 355, 327, 485, 958, 275, 2074, 340, 2074, 365, 440, 488, 587, 1052, 355, 1072, 14, 740, 8, 277, 14, 6599, 14, 800, 8, 490, 291, 14, 1532, 12, 490, 627, 589, 12, 490, 1011, 958, 355, 5082, 288, 367, 3233, 315, 1072, 26, 355, 754, 275, 3233, 342, 355, 340, 1228, 8, 1099, 12, 485, 25721, 14148, 1726, 304, 490, 746, 754, 14, 2804, 355, 1995, 754, 267, 3753, 26, 288, 291, 14, 6599, 14, 1600, 342, 339, 347, 485, 1661, 589, 8, 277, 304, 267, 1830, 715, 26, 288, 1249, 275, 942, 288, 10530, 63, 1273, 275, 756, 288, 367, 2928, 315, 291, 14, 589, 26, 355, 862, 26, 490, 1249, 14, 740, 8, 2184, 8, 2164, 430, 490, 10530, 63, 1273, 275, 715, 355, 871, 10852, 26, 490, 372, 221, 327, 1249, 14, 740, 8, 403, 9, 288, 2074, 275, 1052, 288, 367, 790, 12, 2928, 315, 291, 14, 958, 14, 1744, 837, 355, 862, 26, 490, 2074, 59, 498, 61, 275, 2163, 8, 2164, 9, 490, 10530, 63, 1273, 275, 715, 355, 871, 10852, 26, 490, 372, 221, 327, 2074, 59, 498, 61, 275, 488, 288, 340, 440, 10530, 63, 1273, 26, 355, 372, 288, 1995, 1249, 12, 2074, 339, 347, 636, 1661, 721, 277, 304, 267, 1995, 687, 291, 14, 6052, 342, 339, 347, 365, 63, 9631, 8, 277, 304, 267, 372, 291, 14, 6599, 14, 374, 63, 9631, 342, 421, 199, 533, 1487, 10333, 15461, 26, 272, 347, 636, 826, 721, 277, 12, 2562, 12, 5696, 29, 1046, 12, 7239, 466, 29, 8406, 540, 2711, 63, 16103, 304, 267, 291, 14, 11555, 275, 5696, 267, 291, 14, 1532, 275, 2562, 267, 291, 14, 6599, 275, 7239, 466, 8, 277, 14, 11555, 9, 339, 347, 7634, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 372, 291, 14, 6599, 14, 800, 8, 277, 14, 1532, 12, 627, 589, 12, 1011, 958, 9, 267, 871, 25416, 26, 288, 291, 14, 6599, 14, 1600, 342, 288, 746, 339, 347, 4002, 8, 277, 304, 267, 291, 14, 6599, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1275, 3924, 492, 485, 25721, 14148, 1726, 199, 504, 1275, 6599, 492, 11086, 12678, 12, 7132, 12678, 199, 504, 7975, 492, 3482, 63, 20820, 199, 199, 8406, 540, 2711, 63, 16103, 275, 11086, 12678, 199, 8406, 540, 2711, 63, 10494, 275, 7132, 12678, 421, 199, 533, 11953, 15461, 26, 272, 347, 636, 826, 721, 267, 291, 12, 267, 2562, 12, 267, 627, 589, 12, 267, 5696, 29, 1046, 12, 267, 7239, 466, 29, 8406, 540, 2711, 63, 16103, 12, 267, 1011, 958, 272, 3461, 267, 291, 14, 1532, 275, 2562, 267, 291, 14, 11555, 275, 5696, 267, 291, 14, 589, 275, 359, 1661, 8, 1273, 9, 367, 1680, 315, 1249, 61, 267, 291, 14, 958, 275, 469, 498, 26, 2740, 8, 86, 9, 367, 334, 498, 12, 373, 9, 315, 2074, 14, 1744, 12737, 267, 291, 14, 6599, 275, 7239, 466, 339, 347, 1255, 8, 277, 304, 267, 1995, 687, 291, 14, 6052, 342, 339, 347, 7634, 8, 277, 304, 267, 291, 14, 6599, 275, 291, 14, 6599, 8, 277, 14, 11555, 9, 267, 862, 26, 288, 1072, 275, 942, 288, 367, 1249, 12, 2074, 315, 291, 423, 1661, 589, 837, 355, 327, 485, 589, 275, 1249, 340, 1249, 365, 440, 488, 587, 942, 355, 327, 485, 958, 275, 2074, 340, 2074, 365, 440, 488, 587, 1052, 355, 1072, 14, 740, 8, 277, 14, 6599, 14, 800, 8, 490, 291, 14, 1532, 12, 490, 627, 589, 12, 490, 1011, 958, 355, 5082, 288, 367, 3233, 315, 1072, 26, 355, 754, 275, 3233, 342, 355, 340, 1228, 8, 1099, 12, 485, 25721, 14148, 1726, 304, 490, 746, 754, 14, 2804, 355, 1995, 754, 267, 3753, 26, 288, 291, 14, 6599, 14, 1600, 342, 339, 347, 485, 1661, 589, 8, 277, 304, 267, 1830, 715, 26, 288, 1249, 275, 942, 288, 10530, 63, 1273, 275, 756, 288, 367, 2928, 315, 291, 14, 589, 26, 355, 862, 26, 490, 1249, 14, 740, 8, 2184, 8, 2164, 430, 490, 10530, 63, 1273, 275, 715, 355, 871, 10852, 26, 490, 372, 221, 327, 1249, 14, 740, 8, 403, 9, 288, 2074, 275, 1052, 288, 367, 790, 12, 2928, 315, 291, 14, 958, 14, 1744, 837, 355, 862, 26, 490, 2074, 59, 498, 61, 275, 2163, 8, 2164, 9, 490, 10530, 63, 1273, 275, 715, 355, 871, 10852, 26, 490, 372, 221, 327, 2074, 59, 498, 61, 275, 488, 288, 340, 440, 10530, 63, 1273, 26, 355, 372, 288, 1995, 1249, 12, 2074, 339, 347, 636, 1661, 721, 277, 304, 267, 1995, 687, 291, 14, 6052, 342, 339, 347, 365, 63, 9631, 8, 277, 304, 267, 372, 291, 14, 6599, 14, 374, 63, 9631, 342, 421, 199, 533, 1487, 10333, 15461, 26, 272, 347, 636, 826, 721, 277, 12, 2562, 12, 5696, 29, 1046, 12, 7239, 466, 29, 8406, 540, 2711, 63, 16103, 304, 267, 291, 14, 11555, 275, 5696, 267, 291, 14, 1532, 275, 2562, 267, 291, 14, 6599, 275, 7239, 466, 8, 277, 14, 11555, 9, 339, 347, 7634, 8, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 862, 26, 288, 372, 291, 14, 6599, 14, 800, 8, 277, 14, 1532, 12, 627, 589, 12, 1011, 958, 9, 267, 871, 25416, 26, 288, 291, 14, 6599, 14, 1600, 342, 288, 746, 339, 347, 4002, 8, 277, 304, 267, 291, 14, 6599, 14, 1600, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
noironetworks/nova
nova/tests/unit/virt/vmwareapi/test_ds_util_datastore_selection.py
42
7367
# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import collections import re from oslo_utils import units from oslo_vmware.objects import datastore as ds_obj from nova import test from nova.virt.vmwareapi import ds_util ResultSet = collections.namedtuple('ResultSet', ['objects']) ObjectContent = collections.namedtuple('ObjectContent', ['obj', 'propSet']) DynamicProperty = collections.namedtuple('Property', ['name', 'val']) MoRef = collections.namedtuple('ManagedObjectReference', ['value']) class VMwareDSUtilDatastoreSelectionTestCase(test.NoDBTestCase): def setUp(self): super(VMwareDSUtilDatastoreSelectionTestCase, self).setUp() self.data = [ ['VMFS', 'os-some-name', True, 'normal', 987654321, 12346789], ['NFS', 'another-name', True, 'normal', 9876543210, 123467890], ['BAD', 'some-name-bad', True, 'normal', 98765432100, 1234678900], ['VMFS', 'some-name-good', False, 'normal', 987654321, 12346789], ['VMFS', 'new-name', True, 'inMaintenance', 987654321, 12346789] ] def build_result_set(self, mock_data, name_list=None): # datastores will have a moref_id of ds-000 and # so on based on their index in the mock_data list if name_list is None: name_list = self.propset_name_list objects = [] for id, row in enumerate(mock_data): obj = ObjectContent( obj=MoRef(value="ds-%03d" % id), propSet=[]) for index, value in enumerate(row): obj.propSet.append( DynamicProperty(name=name_list[index], val=row[index])) objects.append(obj) return ResultSet(objects=objects) @property def propset_name_list(self): return ['summary.type', 'summary.name', 'summary.accessible', 'summary.maintenanceMode', 'summary.capacity', 'summary.freeSpace'] def test_filter_datastores_simple(self): datastores = self.build_result_set(self.data) best_match = ds_obj.Datastore(ref='fake_ref', name='ds', capacity=0, freespace=0) rec = ds_util._select_datastore(None, datastores, best_match) self.assertIsNotNone(rec.ref, "could not find datastore!") self.assertEqual('ds-001', rec.ref.value, "didn't find the right datastore!") self.assertEqual(123467890, rec.freespace, "did not obtain correct freespace!") def test_filter_datastores_empty(self): data = [] datastores = self.build_result_set(data) best_match = ds_obj.Datastore(ref='fake_ref', name='ds', capacity=0, freespace=0) rec = ds_util._select_datastore(None, datastores, best_match) self.assertEqual(best_match, rec) def test_filter_datastores_no_match(self): datastores = self.build_result_set(self.data) datastore_regex = re.compile('no_match.*') best_match = ds_obj.Datastore(ref='fake_ref', name='ds', capacity=0, freespace=0) rec = ds_util._select_datastore(None, datastores, best_match, datastore_regex) self.assertEqual(best_match, rec, "did not match datastore properly") def test_filter_datastores_specific_match(self): data = [ ['VMFS', 'os-some-name', True, 'normal', 987654321, 1234678], ['NFS', 'another-name', True, 'normal', 9876543210, 123467890], ['BAD', 'some-name-bad', True, 'normal', 98765432100, 1234678900], ['VMFS', 'some-name-good', True, 'normal', 987654321, 12346789], ['VMFS', 'some-other-good', False, 'normal', 987654321000, 12346789000], ['VMFS', 'new-name', True, 'inMaintenance', 987654321000, 12346789000] ] # only the DS some-name-good is accessible and matches the regex datastores = self.build_result_set(data) datastore_regex = re.compile('.*-good$') best_match = ds_obj.Datastore(ref='fake_ref', name='ds', capacity=0, freespace=0) rec = ds_util._select_datastore(None, datastores, best_match, datastore_regex) self.assertIsNotNone(rec, "could not find datastore!") self.assertEqual('ds-003', rec.ref.value, "didn't find the right datastore!") self.assertNotEqual('ds-004', rec.ref.value, "accepted an unreachable datastore!") self.assertEqual('some-name-good', rec.name) self.assertEqual(12346789, rec.freespace, "did not obtain correct freespace!") self.assertEqual(987654321, rec.capacity, "did not obtain correct capacity!") def test_filter_datastores_missing_props(self): data = [ ['VMFS', 'os-some-name', 987654321, 1234678], ['NFS', 'another-name', 9876543210, 123467890], ] # no matches are expected when 'summary.accessible' is missing prop_names = ['summary.type', 'summary.name', 'summary.capacity', 'summary.freeSpace'] datastores = self.build_result_set(data, prop_names) best_match = ds_obj.Datastore(ref='fake_ref', name='ds', capacity=0, freespace=0) rec = ds_util._select_datastore(None, datastores, best_match) self.assertEqual(best_match, rec, "no matches were expected") def test_filter_datastores_best_match(self): data = [ ['VMFS', 'spam-good', True, 20 * units.Gi, 10 * units.Gi], ['NFS', 'eggs-good', True, 40 * units.Gi, 15 * units.Gi], ['NFS41', 'nfs41-is-good', True, 35 * units.Gi, 12 * units.Gi], ['BAD', 'some-name-bad', True, 30 * units.Gi, 20 * units.Gi], ['VMFS', 'some-name-good', True, 50 * units.Gi, 5 * units.Gi], ['VMFS', 'some-other-good', True, 10 * units.Gi, 10 * units.Gi], ] datastores = self.build_result_set(data) datastore_regex = re.compile('.*-good$') # the current best match is better than all candidates best_match = ds_obj.Datastore(ref='ds-100', name='best-ds-good', capacity=20 * units.Gi, freespace=19 * units.Gi) rec = ds_util._select_datastore(None, datastores, best_match, datastore_regex) self.assertEqual(best_match, rec, "did not match datastore properly")
apache-2.0
[ 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 5055, 199, 646, 295, 199, 199, 504, 11258, 63, 1208, 492, 6204, 199, 504, 11258, 63, 18970, 14, 1462, 492, 12007, 465, 6364, 63, 1113, 199, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 4549, 14, 18970, 1246, 492, 6364, 63, 1974, 199, 199, 21722, 275, 5055, 14, 18921, 360, 21722, 297, 788, 1462, 1105, 199, 1692, 2714, 275, 5055, 14, 18921, 360, 1692, 2714, 297, 788, 1113, 297, 283, 4469, 1084, 1105, 199, 14451, 3697, 275, 5055, 14, 18921, 360, 3697, 297, 788, 354, 297, 283, 637, 1105, 199, 3716, 2891, 275, 5055, 14, 18921, 360, 22625, 1692, 5083, 297, 788, 585, 1105, 421, 199, 533, 27391, 3177, 9562, 30444, 7713, 1746, 8, 396, 14, 32437, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 6849, 1068, 3177, 9562, 30444, 7713, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 576, 275, 359, 288, 788, 6849, 7079, 297, 283, 736, 13, 3972, 13, 354, 297, 715, 12, 283, 3302, 297, 1749, 1555, 11157, 12638, 12, 14763, 1822, 1407, 467, 288, 788, 46, 7079, 297, 283, 13565, 13, 354, 297, 715, 12, 283, 3302, 297, 1749, 1555, 11157, 708, 709, 12, 14763, 1822, 13173, 467, 288, 788, 9439, 297, 283, 3972, 13, 354, 13, 4087, 297, 715, 12, 283, 3302, 297, 1749, 1555, 11157, 708, 1960, 12, 14763, 1822, 1407, 383, 467, 288, 788, 6849, 7079, 297, 283, 3972, 13, 354, 13, 8302, 297, 756, 12, 283, 3302, 297, 1749, 1555, 11157, 12638, 12, 14763, 1822, 1407, 467, 288, 788, 6849, 7079, 297, 283, 1222, 13, 354, 297, 715, 12, 283, 262, 6756, 12182, 297, 1749, 1555, 11157, 12638, 12, 14763, 1822, 1407, 61, 267, 1622, 339, 347, 1900, 63, 1099, 63, 409, 8, 277, 12, 1683, 63, 576, 12, 536, 63, 513, 29, 403, 304, 267, 327, 666, 18958, 911, 1172, 282, 1655, 70, 63, 344, 402, 6364, 13, 1493, 436, 267, 327, 880, 641, 4079, 641, 3932, 1478, 315, 314, 1683, 63, 576, 769, 267, 340, 536, 63, 513, 365, 488, 26, 288, 536, 63, 513, 275, 291, 14, 4469, 409, 63, 354, 63, 513, 398, 2251, 275, 942, 267, 367, 1305, 12, 1962, 315, 3874, 8, 1805, 63, 576, 304, 288, 1559, 275, 6935, 2714, 8, 355, 1559, 29, 3716, 2891, 8, 585, 628, 795, 3295, 1644, 68, 2, 450, 1305, 395, 355, 5931, 1084, 14285, 288, 367, 1478, 12, 574, 315, 3874, 8, 1143, 304, 355, 1559, 14, 4469, 1084, 14, 740, 8, 490, 21907, 3697, 8, 354, 29, 354, 63, 513, 59, 1080, 467, 1139, 29, 1143, 59, 1080, 2459, 288, 2251, 14, 740, 8, 1113, 9, 267, 372, 30751, 8, 1462, 29, 1462, 9, 339, 768, 1829, 272, 347, 5931, 409, 63, 354, 63, 513, 8, 277, 304, 267, 372, 788, 4705, 14, 466, 297, 283, 4705, 14, 354, 297, 283, 4705, 14, 24669, 297, 355, 283, 4705, 14, 19725, 1385, 297, 283, 4705, 14, 10457, 297, 355, 283, 4705, 14, 4624, 7643, 418, 339, 347, 511, 63, 1541, 63, 576, 18958, 63, 4129, 8, 277, 304, 267, 666, 18958, 275, 291, 14, 1506, 63, 1099, 63, 409, 8, 277, 14, 576, 9, 267, 5526, 63, 1431, 275, 6364, 63, 1113, 14, 30444, 8, 1121, 534, 3183, 63, 1121, 297, 536, 534, 795, 297, 2892, 14893, 29, 16, 12, 289, 5710, 1142, 29, 16, 9, 267, 6488, 275, 6364, 63, 1974, 423, 2416, 63, 11450, 8, 403, 12, 666, 18958, 12, 5526, 63, 1431, 9, 398, 291, 14, 10389, 8, 2761, 14, 1121, 12, 298, 15153, 440, 2342, 12007, 9124, 267, 291, 14, 629, 360, 795, 13, 4587, 297, 6488, 14, 1121, 14, 585, 12, 586, 298, 328, 4272, 1133, 2342, 314, 2451, 12007, 9124, 267, 291, 14, 629, 8, 4321, 1822, 13173, 12, 6488, 14, 70, 5710, 1142, 12, 586, 298, 14887, 440, 3332, 3211, 289, 5710, 1142, 9124, 339, 347, 511, 63, 1541, 63, 576, 18958, 63, 1667, 8, 277, 304, 267, 666, 275, 942, 267, 666, 18958, 275, 291, 14, 1506, 63, 1099, 63, 409, 8, 576, 9, 398, 5526, 63, 1431, 275, 6364, 63, 1113, 14, 30444, 8, 1121, 534, 3183, 63, 1121, 297, 536, 534, 795, 297, 2892, 14893, 29, 16, 12, 289, 5710, 1142, 29, 16, 9, 267, 6488, 275, 6364, 63, 1974, 423, 2416, 63, 11450, 8, 403, 12, 666, 18958, 12, 5526, 63, 1431, 9, 398, 291, 14, 629, 8, 7010, 63, 1431, 12, 6488, 9, 339, 347, 511, 63, 1541, 63, 576, 18958, 63, 889, 63, 1431, 8, 277, 304, 267, 666, 18958, 275, 291, 14, 1506, 63, 1099, 63, 409, 8, 277, 14, 576, 9, 267, 12007, 63, 3821, 275, 295, 14, 2014, 360, 889, 63, 1431, 24915, 398, 5526, 63, 1431, 275, 6364, 63, 1113, 14, 30444, 8, 1121, 534, 3183, 63, 1121, 297, 536, 534, 795, 297, 2892, 14893, 29, 16, 12, 289, 5710, 1142, 29, 16, 9, 267, 6488, 275, 6364, 63, 1974, 423, 2416, 63, 11450, 8, 403, 12, 666, 18958, 12, 3147, 5526, 63, 1431, 12, 3147, 12007, 63, 3821, 9, 398, 291, 14, 629, 8, 7010, 63, 1431, 12, 6488, 12, 298, 14887, 440, 1336, 12007, 7684, 531, 339, 347, 511, 63, 1541, 63, 576, 18958, 63, 6100, 63, 1431, 8, 277, 304, 398, 666, 275, 359, 288, 788, 6849, 7079, 297, 283, 736, 13, 3972, 13, 354, 297 ]
[ 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 5055, 199, 646, 295, 199, 199, 504, 11258, 63, 1208, 492, 6204, 199, 504, 11258, 63, 18970, 14, 1462, 492, 12007, 465, 6364, 63, 1113, 199, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 4549, 14, 18970, 1246, 492, 6364, 63, 1974, 199, 199, 21722, 275, 5055, 14, 18921, 360, 21722, 297, 788, 1462, 1105, 199, 1692, 2714, 275, 5055, 14, 18921, 360, 1692, 2714, 297, 788, 1113, 297, 283, 4469, 1084, 1105, 199, 14451, 3697, 275, 5055, 14, 18921, 360, 3697, 297, 788, 354, 297, 283, 637, 1105, 199, 3716, 2891, 275, 5055, 14, 18921, 360, 22625, 1692, 5083, 297, 788, 585, 1105, 421, 199, 533, 27391, 3177, 9562, 30444, 7713, 1746, 8, 396, 14, 32437, 304, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 6849, 1068, 3177, 9562, 30444, 7713, 1746, 12, 291, 680, 5996, 342, 267, 291, 14, 576, 275, 359, 288, 788, 6849, 7079, 297, 283, 736, 13, 3972, 13, 354, 297, 715, 12, 283, 3302, 297, 1749, 1555, 11157, 12638, 12, 14763, 1822, 1407, 467, 288, 788, 46, 7079, 297, 283, 13565, 13, 354, 297, 715, 12, 283, 3302, 297, 1749, 1555, 11157, 708, 709, 12, 14763, 1822, 13173, 467, 288, 788, 9439, 297, 283, 3972, 13, 354, 13, 4087, 297, 715, 12, 283, 3302, 297, 1749, 1555, 11157, 708, 1960, 12, 14763, 1822, 1407, 383, 467, 288, 788, 6849, 7079, 297, 283, 3972, 13, 354, 13, 8302, 297, 756, 12, 283, 3302, 297, 1749, 1555, 11157, 12638, 12, 14763, 1822, 1407, 467, 288, 788, 6849, 7079, 297, 283, 1222, 13, 354, 297, 715, 12, 283, 262, 6756, 12182, 297, 1749, 1555, 11157, 12638, 12, 14763, 1822, 1407, 61, 267, 1622, 339, 347, 1900, 63, 1099, 63, 409, 8, 277, 12, 1683, 63, 576, 12, 536, 63, 513, 29, 403, 304, 267, 327, 666, 18958, 911, 1172, 282, 1655, 70, 63, 344, 402, 6364, 13, 1493, 436, 267, 327, 880, 641, 4079, 641, 3932, 1478, 315, 314, 1683, 63, 576, 769, 267, 340, 536, 63, 513, 365, 488, 26, 288, 536, 63, 513, 275, 291, 14, 4469, 409, 63, 354, 63, 513, 398, 2251, 275, 942, 267, 367, 1305, 12, 1962, 315, 3874, 8, 1805, 63, 576, 304, 288, 1559, 275, 6935, 2714, 8, 355, 1559, 29, 3716, 2891, 8, 585, 628, 795, 3295, 1644, 68, 2, 450, 1305, 395, 355, 5931, 1084, 14285, 288, 367, 1478, 12, 574, 315, 3874, 8, 1143, 304, 355, 1559, 14, 4469, 1084, 14, 740, 8, 490, 21907, 3697, 8, 354, 29, 354, 63, 513, 59, 1080, 467, 1139, 29, 1143, 59, 1080, 2459, 288, 2251, 14, 740, 8, 1113, 9, 267, 372, 30751, 8, 1462, 29, 1462, 9, 339, 768, 1829, 272, 347, 5931, 409, 63, 354, 63, 513, 8, 277, 304, 267, 372, 788, 4705, 14, 466, 297, 283, 4705, 14, 354, 297, 283, 4705, 14, 24669, 297, 355, 283, 4705, 14, 19725, 1385, 297, 283, 4705, 14, 10457, 297, 355, 283, 4705, 14, 4624, 7643, 418, 339, 347, 511, 63, 1541, 63, 576, 18958, 63, 4129, 8, 277, 304, 267, 666, 18958, 275, 291, 14, 1506, 63, 1099, 63, 409, 8, 277, 14, 576, 9, 267, 5526, 63, 1431, 275, 6364, 63, 1113, 14, 30444, 8, 1121, 534, 3183, 63, 1121, 297, 536, 534, 795, 297, 2892, 14893, 29, 16, 12, 289, 5710, 1142, 29, 16, 9, 267, 6488, 275, 6364, 63, 1974, 423, 2416, 63, 11450, 8, 403, 12, 666, 18958, 12, 5526, 63, 1431, 9, 398, 291, 14, 10389, 8, 2761, 14, 1121, 12, 298, 15153, 440, 2342, 12007, 9124, 267, 291, 14, 629, 360, 795, 13, 4587, 297, 6488, 14, 1121, 14, 585, 12, 586, 298, 328, 4272, 1133, 2342, 314, 2451, 12007, 9124, 267, 291, 14, 629, 8, 4321, 1822, 13173, 12, 6488, 14, 70, 5710, 1142, 12, 586, 298, 14887, 440, 3332, 3211, 289, 5710, 1142, 9124, 339, 347, 511, 63, 1541, 63, 576, 18958, 63, 1667, 8, 277, 304, 267, 666, 275, 942, 267, 666, 18958, 275, 291, 14, 1506, 63, 1099, 63, 409, 8, 576, 9, 398, 5526, 63, 1431, 275, 6364, 63, 1113, 14, 30444, 8, 1121, 534, 3183, 63, 1121, 297, 536, 534, 795, 297, 2892, 14893, 29, 16, 12, 289, 5710, 1142, 29, 16, 9, 267, 6488, 275, 6364, 63, 1974, 423, 2416, 63, 11450, 8, 403, 12, 666, 18958, 12, 5526, 63, 1431, 9, 398, 291, 14, 629, 8, 7010, 63, 1431, 12, 6488, 9, 339, 347, 511, 63, 1541, 63, 576, 18958, 63, 889, 63, 1431, 8, 277, 304, 267, 666, 18958, 275, 291, 14, 1506, 63, 1099, 63, 409, 8, 277, 14, 576, 9, 267, 12007, 63, 3821, 275, 295, 14, 2014, 360, 889, 63, 1431, 24915, 398, 5526, 63, 1431, 275, 6364, 63, 1113, 14, 30444, 8, 1121, 534, 3183, 63, 1121, 297, 536, 534, 795, 297, 2892, 14893, 29, 16, 12, 289, 5710, 1142, 29, 16, 9, 267, 6488, 275, 6364, 63, 1974, 423, 2416, 63, 11450, 8, 403, 12, 666, 18958, 12, 3147, 5526, 63, 1431, 12, 3147, 12007, 63, 3821, 9, 398, 291, 14, 629, 8, 7010, 63, 1431, 12, 6488, 12, 298, 14887, 440, 1336, 12007, 7684, 531, 339, 347, 511, 63, 1541, 63, 576, 18958, 63, 6100, 63, 1431, 8, 277, 304, 398, 666, 275, 359, 288, 788, 6849, 7079, 297, 283, 736, 13, 3972, 13, 354, 297, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
roselleebarle04/django
tests/i18n/patterns/tests.py
256
14326
from __future__ import unicode_literals import os from django.core.exceptions import ImproperlyConfigured from django.core.urlresolvers import clear_url_caches, reverse, translate_url from django.http import HttpResponsePermanentRedirect from django.middleware.locale import LocaleMiddleware from django.template import Context, Template from django.test import SimpleTestCase, override_settings from django.test.utils import override_script_prefix from django.utils import translation from django.utils._os import upath class PermanentRedirectLocaleMiddleWare(LocaleMiddleware): response_redirect_class = HttpResponsePermanentRedirect @override_settings( USE_I18N=True, LOCALE_PATHS=[ os.path.join(os.path.dirname(upath(__file__)), 'locale'), ], LANGUAGE_CODE='en-us', LANGUAGES=[ ('nl', 'Dutch'), ('en', 'English'), ('pt-br', 'Brazilian Portuguese'), ], MIDDLEWARE_CLASSES=[ 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', ], ROOT_URLCONF='i18n.patterns.urls.default', TEMPLATES=[{ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(os.path.dirname(upath(__file__)), 'templates')], 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.i18n', ], }, }], ) class URLTestCaseBase(SimpleTestCase): """ TestCase base-class for the URL tests. """ def setUp(self): # Make sure the cache is empty before we are doing our tests. clear_url_caches() def tearDown(self): # Make sure we will leave an empty cache for other testcases. clear_url_caches() class URLPrefixTests(URLTestCaseBase): """ Tests if the `i18n_patterns` is adding the prefix correctly. """ def test_not_prefixed(self): with translation.override('en'): self.assertEqual(reverse('not-prefixed'), '/not-prefixed/') self.assertEqual(reverse('not-prefixed-included-url'), '/not-prefixed-include/foo/') with translation.override('nl'): self.assertEqual(reverse('not-prefixed'), '/not-prefixed/') self.assertEqual(reverse('not-prefixed-included-url'), '/not-prefixed-include/foo/') def test_prefixed(self): with translation.override('en'): self.assertEqual(reverse('prefixed'), '/en/prefixed/') with translation.override('nl'): self.assertEqual(reverse('prefixed'), '/nl/prefixed/') @override_settings(ROOT_URLCONF='i18n.patterns.urls.wrong') def test_invalid_prefix_use(self): self.assertRaises(ImproperlyConfigured, lambda: reverse('account:register')) @override_settings(ROOT_URLCONF='i18n.patterns.urls.disabled') class URLDisabledTests(URLTestCaseBase): @override_settings(USE_I18N=False) def test_prefixed_i18n_disabled(self): with translation.override('en'): self.assertEqual(reverse('prefixed'), '/prefixed/') with translation.override('nl'): self.assertEqual(reverse('prefixed'), '/prefixed/') @override_settings(ROOT_URLCONF='i18n.patterns.urls.path_unused') class PathUnusedTests(URLTestCaseBase): """ Check that if no i18n_patterns is used in root urlconfs, then no language activation happens based on url prefix. """ def test_no_lang_activate(self): response = self.client.get('/nl/foo/') self.assertEqual(response.status_code, 200) self.assertEqual(response['content-language'], 'en') self.assertEqual(response.context['LANGUAGE_CODE'], 'en') class URLTranslationTests(URLTestCaseBase): """ Tests if the pattern-strings are translated correctly (within the `i18n_patterns` and the normal `patterns` function). """ def test_no_prefix_translated(self): with translation.override('en'): self.assertEqual(reverse('no-prefix-translated'), '/translated/') self.assertEqual(reverse('no-prefix-translated-slug', kwargs={'slug': 'yeah'}), '/translated/yeah/') with translation.override('nl'): self.assertEqual(reverse('no-prefix-translated'), '/vertaald/') self.assertEqual(reverse('no-prefix-translated-slug', kwargs={'slug': 'yeah'}), '/vertaald/yeah/') with translation.override('pt-br'): self.assertEqual(reverse('no-prefix-translated'), '/traduzidos/') self.assertEqual(reverse('no-prefix-translated-slug', kwargs={'slug': 'yeah'}), '/traduzidos/yeah/') def test_users_url(self): with translation.override('en'): self.assertEqual(reverse('users'), '/en/users/') with translation.override('nl'): self.assertEqual(reverse('users'), '/nl/gebruikers/') self.assertEqual(reverse('prefixed_xml'), '/nl/prefixed.xml') with translation.override('pt-br'): self.assertEqual(reverse('users'), '/pt-br/usuarios/') def test_translate_url_utility(self): with translation.override('en'): self.assertEqual(translate_url('/en/non-existent/', 'nl'), '/en/non-existent/') self.assertEqual(translate_url('/en/users/', 'nl'), '/nl/gebruikers/') # Namespaced URL self.assertEqual(translate_url('/en/account/register/', 'nl'), '/nl/profiel/registeren/') self.assertEqual(translation.get_language(), 'en') with translation.override('nl'): self.assertEqual(translate_url('/nl/gebruikers/', 'en'), '/en/users/') self.assertEqual(translation.get_language(), 'nl') class URLNamespaceTests(URLTestCaseBase): """ Tests if the translations are still working within namespaces. """ def test_account_register(self): with translation.override('en'): self.assertEqual(reverse('account:register'), '/en/account/register/') with translation.override('nl'): self.assertEqual(reverse('account:register'), '/nl/profiel/registeren/') class URLRedirectTests(URLTestCaseBase): """ Tests if the user gets redirected to the right URL when there is no language-prefix in the request URL. """ def test_no_prefix_response(self): response = self.client.get('/not-prefixed/') self.assertEqual(response.status_code, 200) def test_en_redirect(self): response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='en') self.assertRedirects(response, '/en/account/register/') response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) def test_en_redirect_wrong_url(self): response = self.client.get('/profiel/registeren/', HTTP_ACCEPT_LANGUAGE='en') self.assertEqual(response.status_code, 404) def test_nl_redirect(self): response = self.client.get('/profiel/registeren/', HTTP_ACCEPT_LANGUAGE='nl') self.assertRedirects(response, '/nl/profiel/registeren/') response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) def test_nl_redirect_wrong_url(self): response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='nl') self.assertEqual(response.status_code, 404) def test_pt_br_redirect(self): response = self.client.get('/conta/registre-se/', HTTP_ACCEPT_LANGUAGE='pt-br') self.assertRedirects(response, '/pt-br/conta/registre-se/') response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) def test_pl_pl_redirect(self): # language from outside of the supported LANGUAGES list response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='pl-pl') self.assertRedirects(response, '/en/account/register/') response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) @override_settings( MIDDLEWARE_CLASSES=[ 'i18n.patterns.tests.PermanentRedirectLocaleMiddleWare', 'django.middleware.common.CommonMiddleware', ], ) def test_custom_redirect_class(self): response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='en') self.assertRedirects(response, '/en/account/register/', 301) class URLVaryAcceptLanguageTests(URLTestCaseBase): """ Tests that 'Accept-Language' is not added to the Vary header when using prefixed URLs. """ def test_no_prefix_response(self): response = self.client.get('/not-prefixed/') self.assertEqual(response.status_code, 200) self.assertEqual(response.get('Vary'), 'Accept-Language') def test_en_redirect(self): response = self.client.get('/account/register/', HTTP_ACCEPT_LANGUAGE='en') self.assertRedirects(response, '/en/account/register/') self.assertFalse(response.get('Vary')) response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) self.assertFalse(response.get('Vary')) class URLRedirectWithoutTrailingSlashTests(URLTestCaseBase): """ Tests the redirect when the requested URL doesn't end with a slash (`settings.APPEND_SLASH=True`). """ def test_not_prefixed_redirect(self): response = self.client.get('/not-prefixed', HTTP_ACCEPT_LANGUAGE='en') self.assertRedirects(response, '/not-prefixed/', 301) def test_en_redirect(self): response = self.client.get('/account/register', HTTP_ACCEPT_LANGUAGE='en', follow=True) # We only want one redirect, bypassing CommonMiddleware self.assertListEqual(response.redirect_chain, [('/en/account/register/', 302)]) self.assertRedirects(response, '/en/account/register/', 302) response = self.client.get('/prefixed.xml', HTTP_ACCEPT_LANGUAGE='en', follow=True) self.assertRedirects(response, '/en/prefixed.xml', 302) class URLRedirectWithoutTrailingSlashSettingTests(URLTestCaseBase): """ Tests the redirect when the requested URL doesn't end with a slash (`settings.APPEND_SLASH=False`). """ @override_settings(APPEND_SLASH=False) def test_not_prefixed_redirect(self): response = self.client.get('/not-prefixed', HTTP_ACCEPT_LANGUAGE='en') self.assertEqual(response.status_code, 404) @override_settings(APPEND_SLASH=False) def test_en_redirect(self): response = self.client.get('/account/register-without-slash', HTTP_ACCEPT_LANGUAGE='en') self.assertRedirects(response, '/en/account/register-without-slash', 302) response = self.client.get(response['location']) self.assertEqual(response.status_code, 200) class URLResponseTests(URLTestCaseBase): """ Tests if the response has the right language-code. """ def test_not_prefixed_with_prefix(self): response = self.client.get('/en/not-prefixed/') self.assertEqual(response.status_code, 404) def test_en_url(self): response = self.client.get('/en/account/register/') self.assertEqual(response.status_code, 200) self.assertEqual(response['content-language'], 'en') self.assertEqual(response.context['LANGUAGE_CODE'], 'en') def test_nl_url(self): response = self.client.get('/nl/profiel/registeren/') self.assertEqual(response.status_code, 200) self.assertEqual(response['content-language'], 'nl') self.assertEqual(response.context['LANGUAGE_CODE'], 'nl') def test_wrong_en_prefix(self): response = self.client.get('/en/profiel/registeren/') self.assertEqual(response.status_code, 404) def test_wrong_nl_prefix(self): response = self.client.get('/nl/account/register/') self.assertEqual(response.status_code, 404) def test_pt_br_url(self): response = self.client.get('/pt-br/conta/registre-se/') self.assertEqual(response.status_code, 200) self.assertEqual(response['content-language'], 'pt-br') self.assertEqual(response.context['LANGUAGE_CODE'], 'pt-br') class URLRedirectWithScriptAliasTests(URLTestCaseBase): """ #21579 - LocaleMiddleware should respect the script prefix. """ def test_language_prefix_with_script_prefix(self): prefix = '/script_prefix' with override_script_prefix(prefix): response = self.client.get('/prefixed/', HTTP_ACCEPT_LANGUAGE='en', SCRIPT_NAME=prefix) self.assertRedirects(response, '%s/en/prefixed/' % prefix, target_status_code=404) class URLTagTests(URLTestCaseBase): """ Test if the language tag works. """ def test_strings_only(self): t = Template("""{% load i18n %} {% language 'nl' %}{% url 'no-prefix-translated' %}{% endlanguage %} {% language 'pt-br' %}{% url 'no-prefix-translated' %}{% endlanguage %}""") self.assertEqual(t.render(Context({})).strip().split(), ['/vertaald/', '/traduzidos/']) def test_context(self): ctx = Context({'lang1': 'nl', 'lang2': 'pt-br'}) tpl = Template("""{% load i18n %} {% language lang1 %}{% url 'no-prefix-translated' %}{% endlanguage %} {% language lang2 %}{% url 'no-prefix-translated' %}{% endlanguage %}""") self.assertEqual(tpl.render(ctx).strip().split(), ['/vertaald/', '/traduzidos/']) def test_args(self): tpl = Template("""{% load i18n %} {% language 'nl' %}{% url 'no-prefix-translated-slug' 'apo' %}{% endlanguage %} {% language 'pt-br' %}{% url 'no-prefix-translated-slug' 'apo' %}{% endlanguage %}""") self.assertEqual(tpl.render(Context({})).strip().split(), ['/vertaald/apo/', '/traduzidos/apo/']) def test_kwargs(self): tpl = Template("""{% load i18n %} {% language 'nl' %}{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %} {% language 'pt-br' %}{% url 'no-prefix-translated-slug' slug='apo' %}{% endlanguage %}""") self.assertEqual(tpl.render(Context({})).strip().split(), ['/vertaald/apo/', '/traduzidos/apo/'])
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 16522, 492, 5436, 63, 633, 63, 17595, 12, 3837, 12, 9028, 63, 633, 199, 504, 1639, 14, 1014, 492, 6183, 31776, 7071, 199, 504, 1639, 14, 5754, 14, 5508, 492, 28298, 6608, 199, 504, 1639, 14, 1160, 492, 9470, 12, 5458, 199, 504, 1639, 14, 396, 492, 24424, 12, 4278, 63, 1751, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1579, 63, 1861, 199, 504, 1639, 14, 1208, 492, 7761, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 421, 199, 533, 3492, 11433, 7071, 20342, 30734, 55, 1530, 8, 20342, 6608, 304, 272, 1177, 63, 4876, 63, 533, 275, 6183, 31776, 7071, 421, 199, 32, 4415, 63, 1751, 8, 272, 4815, 63, 41, 1085, 46, 29, 549, 12, 272, 20639, 37, 63, 20202, 1524, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 384, 1619, 3460, 493, 22159, 283, 5508, 659, 272, 2156, 272, 30508, 2962, 63, 6012, 534, 287, 13, 527, 297, 272, 30508, 5383, 1524, 267, 661, 7530, 297, 283, 36, 337, 335, 659, 267, 661, 287, 297, 283, 19410, 659, 267, 661, 541, 13, 3289, 297, 283, 17171, 90, 1638, 290, 10977, 1518, 310, 261, 659, 272, 2156, 272, 30718, 63, 13748, 1524, 267, 283, 1176, 14, 5754, 14, 5508, 14, 20342, 6608, 297, 267, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 2156, 272, 16547, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 885, 297, 272, 377, 9358, 16601, 1524, 91, 267, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 1176, 14, 9323, 17969, 297, 267, 283, 14455, 356, 359, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 384, 1619, 3460, 493, 22159, 283, 5876, 2665, 267, 283, 8808, 356, 469, 288, 283, 1100, 63, 10547, 356, 359, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 73, 1085, 78, 297, 288, 2156, 267, 1660, 272, 19971, 199, 9, 199, 533, 2851, 1746, 1563, 8, 17968, 304, 272, 408, 272, 7640, 1300, 13, 533, 367, 314, 2851, 2295, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 327, 4155, 3238, 314, 2581, 365, 2701, 2544, 781, 787, 9689, 4154, 2295, 14, 267, 5436, 63, 633, 63, 17595, 342, 339, 347, 6766, 8, 277, 304, 267, 327, 4155, 3238, 781, 911, 10137, 376, 2701, 2581, 367, 1163, 511, 9403, 14, 267, 5436, 63, 633, 63, 17595, 342, 421, 199, 533, 2851, 4793, 2925, 8, 2632, 1746, 1563, 304, 272, 408, 272, 6496, 340, 314, 658, 73, 1085, 78, 63, 7435, 64, 365, 7791, 314, 2403, 6657, 14, 272, 408, 272, 347, 511, 63, 1397, 63, 27833, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 659, 1994, 1397, 13, 27833, 6217, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 13, 12409, 13, 633, 659, 1994, 1397, 13, 27833, 13, 2613, 15, 1421, 6217, 267, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 659, 1994, 1397, 13, 27833, 6217, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 13, 12409, 13, 633, 659, 1994, 1397, 13, 27833, 13, 2613, 15, 1421, 6217, 339, 347, 511, 63, 27833, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 287, 15, 27833, 6217, 267, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 7530, 15, 27833, 6217, 339, 768, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 10603, 358, 272, 347, 511, 63, 3197, 63, 1861, 63, 1180, 8, 277, 304, 267, 291, 14, 1855, 8, 8499, 10951, 12, 2400, 26, 3837, 360, 2048, 26, 2683, 1333, 421, 199, 32, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 7011, 358, 199, 533, 2851, 15049, 2925, 8, 2632, 1746, 1563, 304, 339, 768, 4415, 63, 1751, 8, 4701, 63, 41, 1085, 46, 29, 797, 9, 272, 347, 511, 63, 27833, 63, 73, 1085, 78, 63, 7011, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 27833, 6217, 267, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 27833, 6217, 421, 199, 32, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 515, 63, 8618, 358, 199, 533, 6912, 20782, 2925, 8, 2632, 1746, 1563, 304, 272, 408, 272, 2670, 626, 340, 949, 284, 1085, 78, 63, 7435, 365, 1202, 315, 1738, 30009, 83, 12, 2066, 949, 272, 2637, 10361, 10986, 4079, 641, 1166, 2403, 14, 272, 408, 339, 347, 511, 63, 889, 63, 4159, 63, 8222, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 7530, 15, 1421, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 629, 8, 1310, 459, 1317, 13, 3671, 995, 283, 287, 358, 267, 291, 14, 629, 8, 1310, 14, 1100, 459, 13947, 63, 6012, 995, 283, 287, 358, 421, 199, 533, 2851, 18483, 2925, 8, 2632, 1746, 1563, 304, 272, 408, 272, 6496, 340, 314, 3851, 13, 5465, 787, 14598, 6657, 334, 12541, 314, 272, 658, 73, 1085, 78, 63, 7435, 64, 436, 314, 3293, 658, 7435, 64, 805, 680, 272, 408, 272, 347, 511, 63, 889, 63, 1861, 63, 18065, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 889, 13, 1861, 13, 18065, 659, 1994, 18065, 6217, 288, 291, 14, 629, 8, 4471, 360, 889, 13, 1861, 13, 18065, 13, 5464, 297, 2074, 3713, 5464, 356, 283, 89, 4489, 72, 1604, 1994, 18065, 15, 89, 4489, 72, 6217, 398, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 199, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 1018, 14, 16522, 492, 5436, 63, 633, 63, 17595, 12, 3837, 12, 9028, 63, 633, 199, 504, 1639, 14, 1014, 492, 6183, 31776, 7071, 199, 504, 1639, 14, 5754, 14, 5508, 492, 28298, 6608, 199, 504, 1639, 14, 1160, 492, 9470, 12, 5458, 199, 504, 1639, 14, 396, 492, 24424, 12, 4278, 63, 1751, 199, 504, 1639, 14, 396, 14, 1208, 492, 4278, 63, 1579, 63, 1861, 199, 504, 1639, 14, 1208, 492, 7761, 199, 504, 1639, 14, 1208, 423, 736, 492, 1536, 1619, 421, 199, 533, 3492, 11433, 7071, 20342, 30734, 55, 1530, 8, 20342, 6608, 304, 272, 1177, 63, 4876, 63, 533, 275, 6183, 31776, 7071, 421, 199, 32, 4415, 63, 1751, 8, 272, 4815, 63, 41, 1085, 46, 29, 549, 12, 272, 20639, 37, 63, 20202, 1524, 267, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 384, 1619, 3460, 493, 22159, 283, 5508, 659, 272, 2156, 272, 30508, 2962, 63, 6012, 534, 287, 13, 527, 297, 272, 30508, 5383, 1524, 267, 661, 7530, 297, 283, 36, 337, 335, 659, 267, 661, 287, 297, 283, 19410, 659, 267, 661, 541, 13, 3289, 297, 283, 17171, 90, 1638, 290, 10977, 1518, 310, 261, 659, 272, 2156, 272, 30718, 63, 13748, 1524, 267, 283, 1176, 14, 5754, 14, 5508, 14, 20342, 6608, 297, 267, 283, 1176, 14, 5754, 14, 2330, 14, 7844, 6608, 297, 272, 2156, 272, 16547, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 885, 297, 272, 377, 9358, 16601, 1524, 91, 267, 283, 18145, 356, 283, 1176, 14, 1160, 14, 7765, 14, 1176, 14, 9323, 17969, 297, 267, 283, 14455, 356, 359, 736, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 384, 1619, 3460, 493, 22159, 283, 5876, 2665, 267, 283, 8808, 356, 469, 288, 283, 1100, 63, 10547, 356, 359, 355, 283, 1176, 14, 1160, 14, 1100, 63, 10547, 14, 73, 1085, 78, 297, 288, 2156, 267, 1660, 272, 19971, 199, 9, 199, 533, 2851, 1746, 1563, 8, 17968, 304, 272, 408, 272, 7640, 1300, 13, 533, 367, 314, 2851, 2295, 14, 272, 408, 339, 347, 3613, 8, 277, 304, 267, 327, 4155, 3238, 314, 2581, 365, 2701, 2544, 781, 787, 9689, 4154, 2295, 14, 267, 5436, 63, 633, 63, 17595, 342, 339, 347, 6766, 8, 277, 304, 267, 327, 4155, 3238, 781, 911, 10137, 376, 2701, 2581, 367, 1163, 511, 9403, 14, 267, 5436, 63, 633, 63, 17595, 342, 421, 199, 533, 2851, 4793, 2925, 8, 2632, 1746, 1563, 304, 272, 408, 272, 6496, 340, 314, 658, 73, 1085, 78, 63, 7435, 64, 365, 7791, 314, 2403, 6657, 14, 272, 408, 272, 347, 511, 63, 1397, 63, 27833, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 659, 1994, 1397, 13, 27833, 6217, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 13, 12409, 13, 633, 659, 1994, 1397, 13, 27833, 13, 2613, 15, 1421, 6217, 267, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 659, 1994, 1397, 13, 27833, 6217, 288, 291, 14, 629, 8, 4471, 360, 1397, 13, 27833, 13, 12409, 13, 633, 659, 1994, 1397, 13, 27833, 13, 2613, 15, 1421, 6217, 339, 347, 511, 63, 27833, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 287, 15, 27833, 6217, 267, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 7530, 15, 27833, 6217, 339, 768, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 10603, 358, 272, 347, 511, 63, 3197, 63, 1861, 63, 1180, 8, 277, 304, 267, 291, 14, 1855, 8, 8499, 10951, 12, 2400, 26, 3837, 360, 2048, 26, 2683, 1333, 421, 199, 32, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 7011, 358, 199, 533, 2851, 15049, 2925, 8, 2632, 1746, 1563, 304, 339, 768, 4415, 63, 1751, 8, 4701, 63, 41, 1085, 46, 29, 797, 9, 272, 347, 511, 63, 27833, 63, 73, 1085, 78, 63, 7011, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 27833, 6217, 267, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 4471, 360, 27833, 659, 1994, 27833, 6217, 421, 199, 32, 4415, 63, 1751, 8, 5441, 63, 18125, 534, 73, 1085, 78, 14, 7435, 14, 3603, 14, 515, 63, 8618, 358, 199, 533, 6912, 20782, 2925, 8, 2632, 1746, 1563, 304, 272, 408, 272, 2670, 626, 340, 949, 284, 1085, 78, 63, 7435, 365, 1202, 315, 1738, 30009, 83, 12, 2066, 949, 272, 2637, 10361, 10986, 4079, 641, 1166, 2403, 14, 272, 408, 339, 347, 511, 63, 889, 63, 4159, 63, 8222, 8, 277, 304, 267, 1177, 275, 291, 14, 1258, 14, 362, 2336, 7530, 15, 1421, 6217, 267, 291, 14, 629, 8, 1310, 14, 1205, 63, 600, 12, 1926, 9, 267, 291, 14, 629, 8, 1310, 459, 1317, 13, 3671, 995, 283, 287, 358, 267, 291, 14, 629, 8, 1310, 14, 1100, 459, 13947, 63, 6012, 995, 283, 287, 358, 421, 199, 533, 2851, 18483, 2925, 8, 2632, 1746, 1563, 304, 272, 408, 272, 6496, 340, 314, 3851, 13, 5465, 787, 14598, 6657, 334, 12541, 314, 272, 658, 73, 1085, 78, 63, 7435, 64, 436, 314, 3293, 658, 7435, 64, 805, 680, 272, 408, 272, 347, 511, 63, 889, 63, 1861, 63, 18065, 8, 277, 304, 267, 543, 7761, 14, 4415, 360, 287, 735, 288, 291, 14, 629, 8, 4471, 360, 889, 13, 1861, 13, 18065, 659, 1994, 18065, 6217, 288, 291, 14, 629, 8, 4471, 360, 889, 13, 1861, 13, 18065, 13, 5464, 297, 2074, 3713, 5464, 356, 283, 89, 4489, 72, 1604, 1994, 18065, 15, 89, 4489, 72, 6217, 398, 543, 7761, 14, 4415, 360, 7530, 735, 288, 291, 14, 629, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ageron/tensorflow
tensorflow/python/kernel_tests/svd_op_test.py
5
14092
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for tensorflow.ops.math_ops.matrix_inverse.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.python import tf2 from tensorflow.python.framework import constant_op from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import gradient_checker from tensorflow.python.ops import gradients_impl from tensorflow.python.ops import linalg_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import random_ops from tensorflow.python.platform import test def _AddTest(test_class, op_name, testcase_name, fn): test_name = "_".join(["test", op_name, testcase_name]) if hasattr(test_class, test_name): raise RuntimeError("Test %s defined more than once" % test_name) setattr(test_class, test_name, fn) class SvdOpTest(test.TestCase): @test_util.run_v1_only("b/120545219") def testWrongDimensions(self): # The input to svd should be a tensor of at least rank 2. scalar = constant_op.constant(1.) with self.assertRaisesRegexp(ValueError, "Shape must be at least rank 2 but is rank 0"): linalg_ops.svd(scalar) vector = constant_op.constant([1., 2.]) with self.assertRaisesRegexp(ValueError, "Shape must be at least rank 2 but is rank 1"): linalg_ops.svd(vector) @test_util.run_v1_only("b/120545219") def testConcurrentExecutesWithoutError(self): with self.session(use_gpu=True) as sess: all_ops = [] for compute_uv_ in True, False: for full_matrices_ in True, False: matrix1 = random_ops.random_normal([5, 5], seed=42) matrix2 = random_ops.random_normal([5, 5], seed=42) if compute_uv_: s1, u1, v1 = linalg_ops.svd( matrix1, compute_uv=compute_uv_, full_matrices=full_matrices_) s2, u2, v2 = linalg_ops.svd( matrix2, compute_uv=compute_uv_, full_matrices=full_matrices_) all_ops += [s1, u1, v1, s2, u2, v2] else: s1 = linalg_ops.svd( matrix1, compute_uv=compute_uv_, full_matrices=full_matrices_) s2 = linalg_ops.svd( matrix2, compute_uv=compute_uv_, full_matrices=full_matrices_) all_ops += [s1, s2] val = self.evaluate(all_ops) for i in range(2): s = 6 * i self.assertAllEqual(val[s], val[s + 3]) # s1 == s2 self.assertAllEqual(val[s + 1], val[s + 4]) # u1 == u2 self.assertAllEqual(val[s + 2], val[s + 5]) # v1 == v2 for i in range(2): s = 12 + 2 * i self.assertAllEqual(val[s], val[s + 1]) # s1 == s2 def _GetSvdOpTest(dtype_, shape_, use_static_shape_, compute_uv_, full_matrices_): def CompareSingularValues(self, x, y, tol): self.assertAllClose(x, y, atol=(x[0] + y[0]) * tol) def CompareSingularVectors(self, x, y, rank, tol): # We only compare the first 'rank' singular vectors since the # remainder form an arbitrary orthonormal basis for the # (row- or column-) null space, whose exact value depends on # implementation details. Notice that since we check that the # matrices of singular vectors are unitary elsewhere, we do # implicitly test that the trailing vectors of x and y span the # same space. x = x[..., 0:rank] y = y[..., 0:rank] # Singular vectors are only unique up to sign (complex phase factor for # complex matrices), so we normalize the sign first. sum_of_ratios = np.sum(np.divide(y, x), -2, keepdims=True) phases = np.divide(sum_of_ratios, np.abs(sum_of_ratios)) x *= phases self.assertAllClose(x, y, atol=2 * tol) def CheckApproximation(self, a, u, s, v, full_matrices_, tol): # Tests that a ~= u*diag(s)*transpose(v). batch_shape = a.shape[:-2] m = a.shape[-2] n = a.shape[-1] diag_s = math_ops.cast(array_ops.matrix_diag(s), dtype=dtype_) if full_matrices_: if m > n: zeros = array_ops.zeros(batch_shape + (m - n, n), dtype=dtype_) diag_s = array_ops.concat([diag_s, zeros], a.ndim - 2) elif n > m: zeros = array_ops.zeros(batch_shape + (m, n - m), dtype=dtype_) diag_s = array_ops.concat([diag_s, zeros], a.ndim - 1) a_recon = math_ops.matmul(u, diag_s) a_recon = math_ops.matmul(a_recon, v, adjoint_b=True) self.assertAllClose(a_recon, a, rtol=tol, atol=tol) def CheckUnitary(self, x, tol): # Tests that x[...,:,:]^H * x[...,:,:] is close to the identity. xx = math_ops.matmul(x, x, adjoint_a=True) identity = array_ops.matrix_band_part(array_ops.ones_like(xx), 0, 0) self.assertAllClose(identity, xx, atol=tol) @test_util.run_v1_only("b/120545219") def Test(self): is_complex = dtype_ in (np.complex64, np.complex128) is_single = dtype_ in (np.float32, np.complex64) tol = 3e-4 if is_single else 1e-12 if test.is_gpu_available(): # The gpu version returns results that are much less accurate. tol *= 100 np.random.seed(42) x_np = np.random.uniform( low=-1.0, high=1.0, size=np.prod(shape_)).reshape(shape_).astype(dtype_) if is_complex: x_np += 1j * np.random.uniform( low=-1.0, high=1.0, size=np.prod(shape_)).reshape(shape_).astype(dtype_) with self.session(use_gpu=True) as sess: if use_static_shape_: x_tf = constant_op.constant(x_np) else: x_tf = array_ops.placeholder(dtype_) if compute_uv_: s_tf, u_tf, v_tf = linalg_ops.svd( x_tf, compute_uv=compute_uv_, full_matrices=full_matrices_) if use_static_shape_: s_tf_val, u_tf_val, v_tf_val = self.evaluate([s_tf, u_tf, v_tf]) else: s_tf_val, u_tf_val, v_tf_val = sess.run( [s_tf, u_tf, v_tf], feed_dict={x_tf: x_np}) else: s_tf = linalg_ops.svd( x_tf, compute_uv=compute_uv_, full_matrices=full_matrices_) if use_static_shape_: s_tf_val = self.evaluate(s_tf) else: s_tf_val = sess.run(s_tf, feed_dict={x_tf: x_np}) if compute_uv_: u_np, s_np, v_np = np.linalg.svd( x_np, compute_uv=compute_uv_, full_matrices=full_matrices_) else: s_np = np.linalg.svd( x_np, compute_uv=compute_uv_, full_matrices=full_matrices_) # We explicitly avoid the situation where numpy eliminates a first # dimension that is equal to one. s_np = np.reshape(s_np, s_tf_val.shape) CompareSingularValues(self, s_np, s_tf_val, tol) if compute_uv_: CompareSingularVectors(self, u_np, u_tf_val, min(shape_[-2:]), tol) CompareSingularVectors(self, np.conj(np.swapaxes(v_np, -2, -1)), v_tf_val, min(shape_[-2:]), tol) CheckApproximation(self, x_np, u_tf_val, s_tf_val, v_tf_val, full_matrices_, tol) CheckUnitary(self, u_tf_val, tol) CheckUnitary(self, v_tf_val, tol) return Test class SvdGradOpTest(test.TestCase): pass # Filled in below def _NormalizingSvd(tf_a, full_matrices_): tf_s, tf_u, tf_v = linalg_ops.svd( tf_a, compute_uv=True, full_matrices=full_matrices_) # Singular vectors are only unique up to an arbitrary phase. We normalize # the vectors such that the first component of u (if m >=n) or v (if n > m) # have phase 0. m = tf_a.shape[-2] n = tf_a.shape[-1] if m >= n: top_rows = tf_u[..., 0:1, :] else: top_rows = tf_v[..., 0:1, :] if tf_u.dtype.is_complex: angle = -math_ops.angle(top_rows) phase = math_ops.complex(math_ops.cos(angle), math_ops.sin(angle)) else: phase = math_ops.sign(top_rows) tf_u *= phase[..., :m] tf_v *= phase[..., :n] return tf_s, tf_u, tf_v def _GetSvdGradOpTest(dtype_, shape_, compute_uv_, full_matrices_): @test_util.run_v1_only("b/120545219") def Test(self): np.random.seed(42) a = np.random.uniform(low=-1.0, high=1.0, size=shape_).astype(dtype_) if dtype_ in [np.complex64, np.complex128]: a += 1j * np.random.uniform( low=-1.0, high=1.0, size=shape_).astype(dtype_) # Optimal stepsize for central difference is O(epsilon^{1/3}). # See Equation (21) in: # http://www.karenkopecky.net/Teaching/eco613614/Notes_NumericalDifferentiation.pdf # TODO(rmlarsen): Move step size control to gradient checker. epsilon = np.finfo(dtype_).eps delta = 0.1 * epsilon**(1.0 / 3.0) if dtype_ in [np.float32, np.complex64]: tol = 3e-2 else: tol = 1e-6 with self.session(use_gpu=True): tf_a = constant_op.constant(a) if compute_uv_: tf_s, tf_u, tf_v = _NormalizingSvd(tf_a, full_matrices_) outputs = [tf_s, tf_u, tf_v] else: tf_s = linalg_ops.svd(tf_a, compute_uv=False) outputs = [tf_s] for b in outputs: x_init = np.random.uniform( low=-1.0, high=1.0, size=shape_).astype(dtype_) if dtype_ in [np.complex64, np.complex128]: x_init += 1j * np.random.uniform( low=-1.0, high=1.0, size=shape_).astype(dtype_) theoretical, numerical = gradient_checker.compute_gradient( tf_a, tf_a.get_shape().as_list(), b, b.get_shape().as_list(), x_init_value=x_init, delta=delta) self.assertAllClose(theoretical, numerical, atol=tol, rtol=tol) return Test class SvdGradGradOpTest(test.TestCase): pass # Filled in below def _GetSvdGradGradOpTest(dtype_, shape_, compute_uv_, full_matrices_): @test_util.run_v1_only("b/120545219") def Test(self): np.random.seed(42) a = np.random.uniform(low=-1.0, high=1.0, size=shape_).astype(dtype_) if dtype_ in [np.complex64, np.complex128]: a += 1j * np.random.uniform( low=-1.0, high=1.0, size=shape_).astype(dtype_) # Optimal stepsize for central difference is O(epsilon^{1/3}). # See Equation (21) in: # http://www.karenkopecky.net/Teaching/eco613614/Notes_NumericalDifferentiation.pdf # TODO(rmlarsen): Move step size control to gradient checker. epsilon = np.finfo(dtype_).eps delta = 0.1 * epsilon**(1.0 / 3.0) tol = 1e-5 with self.session(use_gpu=True): tf_a = constant_op.constant(a) if compute_uv_: tf_s, tf_u, tf_v = _NormalizingSvd(tf_a, full_matrices_) outputs = [tf_s, tf_u, tf_v] else: tf_s = linalg_ops.svd(tf_a, compute_uv=False) outputs = [tf_s] outputs_sums = [math_ops.reduce_sum(o) for o in outputs] tf_func_outputs = math_ops.add_n(outputs_sums) grad = gradients_impl.gradients(tf_func_outputs, tf_a)[0] x_init = np.random.uniform( low=-1.0, high=1.0, size=shape_).astype(dtype_) if dtype_ in [np.complex64, np.complex128]: x_init += 1j * np.random.uniform( low=-1.0, high=1.0, size=shape_).astype(dtype_) theoretical, numerical = gradient_checker.compute_gradient( tf_a, tf_a.get_shape().as_list(), grad, grad.get_shape().as_list(), x_init_value=x_init, delta=delta) self.assertAllClose(theoretical, numerical, atol=tol, rtol=tol) return Test if __name__ == "__main__": for compute_uv in False, True: for full_matrices in False, True: for dtype in np.float32, np.float64, np.complex64, np.complex128: for rows in 1, 2, 5, 10, 32, 100: for cols in 1, 2, 5, 10, 32, 100: for batch_dims in [(), (3,)] + [(3, 2)] * (max(rows, cols) < 10): shape = batch_dims + (rows, cols) # TF2 does not support placeholders under eager so we skip it for use_static_shape in set([True, tf2.enabled()]): name = "%s_%s_static_shape_%s__compute_uv_%s_full_%s" % ( dtype.__name__, "_".join(map(str, shape)), use_static_shape, compute_uv, full_matrices) _AddTest(SvdOpTest, "Svd", name, _GetSvdOpTest(dtype, shape, use_static_shape, compute_uv, full_matrices)) for compute_uv in False, True: for full_matrices in False, True: dtypes = ([np.float32, np.float64] + [np.complex64, np.complex128] * (not compute_uv)) for dtype in dtypes: mat_shapes = [(10, 11), (11, 10), (11, 11), (2, 2, 2, 3)] if not full_matrices or not compute_uv: mat_shapes += [(5, 11), (11, 5)] for mat_shape in mat_shapes: for batch_dims in [(), (3,)]: shape = batch_dims + mat_shape name = "%s_%s_compute_uv_%s_full_%s" % ( dtype.__name__, "_".join(map(str, shape)), compute_uv, full_matrices) _AddTest(SvdGradOpTest, "SvdGrad", name, _GetSvdGradOpTest(dtype, shape, compute_uv, full_matrices)) # The results are too inacurate for float32. if dtype == np.float64: _AddTest( SvdGradGradOpTest, "SvdGradGrad", name, _GetSvdGradGradOpTest(dtype, shape, compute_uv, full_matrices)) test.main()
apache-2.0
[ 3, 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 3228, 14, 1483, 14, 3442, 63, 1483, 14, 3642, 63, 11668, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 492, 2833, 18, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 6709, 63, 6743, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 63, 5472, 199, 504, 3228, 14, 1548, 14, 1483, 492, 16727, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 318, 485, 1123, 774, 8, 396, 63, 533, 12, 1687, 63, 354, 12, 16228, 63, 354, 12, 4325, 304, 523, 511, 63, 354, 275, 2668, 1674, 904, 5234, 396, 401, 1687, 63, 354, 12, 16228, 63, 354, 566, 523, 340, 2688, 8, 396, 63, 533, 12, 511, 63, 354, 304, 272, 746, 6064, 480, 774, 450, 83, 3247, 1655, 2419, 5403, 2, 450, 511, 63, 354, 9, 523, 5371, 8, 396, 63, 533, 12, 511, 63, 354, 12, 4325, 9, 421, 199, 533, 428, 11549, 4619, 774, 8, 396, 14, 1746, 304, 819, 768, 396, 63, 1974, 14, 1065, 63, 86, 17, 63, 2118, 480, 66, 15, 6708, 1477, 2528, 1167, 531, 523, 347, 511, 14858, 23370, 8, 277, 304, 272, 327, 710, 1324, 370, 26937, 1077, 506, 282, 2345, 402, 737, 5210, 6915, 499, 14, 272, 6917, 275, 4413, 63, 411, 14, 4083, 8, 17, 4959, 272, 543, 291, 14, 10835, 8, 3393, 12, 639, 298, 7238, 1471, 506, 737, 5210, 6915, 499, 1325, 365, 6915, 378, 2349, 489, 16727, 63, 1483, 14, 18675, 8, 7033, 9, 272, 5477, 275, 4413, 63, 411, 14, 4083, 779, 17, 2020, 499, 14444, 272, 543, 291, 14, 10835, 8, 3393, 12, 639, 298, 7238, 1471, 506, 737, 5210, 6915, 499, 1325, 365, 6915, 413, 2349, 489, 16727, 63, 1483, 14, 18675, 8, 4106, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 86, 17, 63, 2118, 480, 66, 15, 6708, 1477, 2528, 1167, 531, 523, 347, 511, 714, 1818, 4858, 3862, 12450, 547, 8, 277, 304, 272, 543, 291, 14, 1730, 8, 1180, 63, 6477, 29, 549, 9, 465, 4043, 26, 489, 1006, 63, 1483, 275, 942, 489, 367, 4526, 63, 9154, 63, 315, 715, 12, 756, 26, 267, 367, 2615, 63, 19032, 63, 315, 715, 12, 756, 26, 881, 3634, 17, 275, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 21, 12, 959, 467, 6347, 29, 2260, 9, 881, 3634, 18, 275, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 21, 12, 959, 467, 6347, 29, 2260, 9, 881, 340, 4526, 63, 9154, 10388, 288, 308, 17, 12, 399, 17, 12, 373, 17, 275, 16727, 63, 1483, 14, 18675, 8, 355, 3634, 17, 12, 4526, 63, 9154, 29, 3357, 63, 9154, 3131, 2615, 63, 19032, 29, 2861, 63, 19032, 4602, 288, 308, 18, 12, 399, 18, 12, 373, 18, 275, 16727, 63, 1483, 14, 18675, 8, 355, 3634, 18, 12, 4526, 63, 9154, 29, 3357, 63, 9154, 3131, 2615, 63, 19032, 29, 2861, 63, 19032, 4602, 288, 1006, 63, 1483, 847, 359, 83, 17, 12, 399, 17, 12, 373, 17, 12, 308, 18, 12, 399, 18, 12, 373, 18, 61, 881, 587, 26, 288, 308, 17, 275, 16727, 63, 1483, 14, 18675, 8, 355, 3634, 17, 12, 4526, 63, 9154, 29, 3357, 63, 9154, 3131, 2615, 63, 19032, 29, 2861, 63, 19032, 4602, 288, 308, 18, 275, 16727, 63, 1483, 14, 18675, 8, 355, 3634, 18, 12, 4526, 63, 9154, 29, 3357, 63, 9154, 3131, 2615, 63, 19032, 29, 2861, 63, 19032, 4602, 288, 1006, 63, 1483, 847, 359, 83, 17, 12, 308, 18, 61, 489, 1139, 275, 291, 14, 7383, 8, 452, 63, 1483, 9, 489, 367, 284, 315, 1425, 8, 18, 304, 267, 308, 275, 1227, 627, 284, 267, 291, 14, 7069, 8, 637, 59, 83, 467, 1139, 59, 83, 435, 650, 566, 221, 327, 308, 17, 508, 308, 18, 267, 291, 14, 7069, 8, 637, 59, 83, 435, 413, 467, 1139, 59, 83, 435, 841, 566, 221, 327, 399, 17, 508, 399, 18, 267, 291, 14, 7069, 8, 637, 59, 83, 435, 499, 467, 1139, 59, 83, 435, 959, 566, 221, 327, 373, 17, 508, 373, 18, 489, 367, 284, 315, 1425, 8, 18, 304, 267, 308, 275, 3144, 435, 499, 627, 284, 267, 291, 14, 7069, 8, 637, 59, 83, 467, 1139, 59, 83, 435, 413, 566, 221, 327, 308, 17, 508, 308, 18, 421, 199, 318, 485, 17526, 11549, 4619, 774, 8, 2271, 3131, 2215, 3131, 675, 63, 1986, 63, 1392, 3131, 4526, 63, 9154, 3131, 2116, 2615, 63, 19032, 7822, 819, 347, 18955, 51, 14257, 6550, 8, 277, 12, 671, 12, 612, 12, 9561, 304, 272, 291, 14, 7260, 8, 88, 12, 612, 12, 9543, 2687, 88, 59, 16, 61, 435, 612, 59, 16, 566, 627, 9561, 9, 819, 347, 18955, 51, 14257, 31465, 8, 277, 12, 671 ]
[ 1898, 7800, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 3228, 14, 1483, 14, 3442, 63, 1483, 14, 3642, 63, 11668, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 492, 2833, 18, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 6709, 63, 6743, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 63, 5472, 199, 504, 3228, 14, 1548, 14, 1483, 492, 16727, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 318, 485, 1123, 774, 8, 396, 63, 533, 12, 1687, 63, 354, 12, 16228, 63, 354, 12, 4325, 304, 523, 511, 63, 354, 275, 2668, 1674, 904, 5234, 396, 401, 1687, 63, 354, 12, 16228, 63, 354, 566, 523, 340, 2688, 8, 396, 63, 533, 12, 511, 63, 354, 304, 272, 746, 6064, 480, 774, 450, 83, 3247, 1655, 2419, 5403, 2, 450, 511, 63, 354, 9, 523, 5371, 8, 396, 63, 533, 12, 511, 63, 354, 12, 4325, 9, 421, 199, 533, 428, 11549, 4619, 774, 8, 396, 14, 1746, 304, 819, 768, 396, 63, 1974, 14, 1065, 63, 86, 17, 63, 2118, 480, 66, 15, 6708, 1477, 2528, 1167, 531, 523, 347, 511, 14858, 23370, 8, 277, 304, 272, 327, 710, 1324, 370, 26937, 1077, 506, 282, 2345, 402, 737, 5210, 6915, 499, 14, 272, 6917, 275, 4413, 63, 411, 14, 4083, 8, 17, 4959, 272, 543, 291, 14, 10835, 8, 3393, 12, 639, 298, 7238, 1471, 506, 737, 5210, 6915, 499, 1325, 365, 6915, 378, 2349, 489, 16727, 63, 1483, 14, 18675, 8, 7033, 9, 272, 5477, 275, 4413, 63, 411, 14, 4083, 779, 17, 2020, 499, 14444, 272, 543, 291, 14, 10835, 8, 3393, 12, 639, 298, 7238, 1471, 506, 737, 5210, 6915, 499, 1325, 365, 6915, 413, 2349, 489, 16727, 63, 1483, 14, 18675, 8, 4106, 9, 819, 768, 396, 63, 1974, 14, 1065, 63, 86, 17, 63, 2118, 480, 66, 15, 6708, 1477, 2528, 1167, 531, 523, 347, 511, 714, 1818, 4858, 3862, 12450, 547, 8, 277, 304, 272, 543, 291, 14, 1730, 8, 1180, 63, 6477, 29, 549, 9, 465, 4043, 26, 489, 1006, 63, 1483, 275, 942, 489, 367, 4526, 63, 9154, 63, 315, 715, 12, 756, 26, 267, 367, 2615, 63, 19032, 63, 315, 715, 12, 756, 26, 881, 3634, 17, 275, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 21, 12, 959, 467, 6347, 29, 2260, 9, 881, 3634, 18, 275, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 21, 12, 959, 467, 6347, 29, 2260, 9, 881, 340, 4526, 63, 9154, 10388, 288, 308, 17, 12, 399, 17, 12, 373, 17, 275, 16727, 63, 1483, 14, 18675, 8, 355, 3634, 17, 12, 4526, 63, 9154, 29, 3357, 63, 9154, 3131, 2615, 63, 19032, 29, 2861, 63, 19032, 4602, 288, 308, 18, 12, 399, 18, 12, 373, 18, 275, 16727, 63, 1483, 14, 18675, 8, 355, 3634, 18, 12, 4526, 63, 9154, 29, 3357, 63, 9154, 3131, 2615, 63, 19032, 29, 2861, 63, 19032, 4602, 288, 1006, 63, 1483, 847, 359, 83, 17, 12, 399, 17, 12, 373, 17, 12, 308, 18, 12, 399, 18, 12, 373, 18, 61, 881, 587, 26, 288, 308, 17, 275, 16727, 63, 1483, 14, 18675, 8, 355, 3634, 17, 12, 4526, 63, 9154, 29, 3357, 63, 9154, 3131, 2615, 63, 19032, 29, 2861, 63, 19032, 4602, 288, 308, 18, 275, 16727, 63, 1483, 14, 18675, 8, 355, 3634, 18, 12, 4526, 63, 9154, 29, 3357, 63, 9154, 3131, 2615, 63, 19032, 29, 2861, 63, 19032, 4602, 288, 1006, 63, 1483, 847, 359, 83, 17, 12, 308, 18, 61, 489, 1139, 275, 291, 14, 7383, 8, 452, 63, 1483, 9, 489, 367, 284, 315, 1425, 8, 18, 304, 267, 308, 275, 1227, 627, 284, 267, 291, 14, 7069, 8, 637, 59, 83, 467, 1139, 59, 83, 435, 650, 566, 221, 327, 308, 17, 508, 308, 18, 267, 291, 14, 7069, 8, 637, 59, 83, 435, 413, 467, 1139, 59, 83, 435, 841, 566, 221, 327, 399, 17, 508, 399, 18, 267, 291, 14, 7069, 8, 637, 59, 83, 435, 499, 467, 1139, 59, 83, 435, 959, 566, 221, 327, 373, 17, 508, 373, 18, 489, 367, 284, 315, 1425, 8, 18, 304, 267, 308, 275, 3144, 435, 499, 627, 284, 267, 291, 14, 7069, 8, 637, 59, 83, 467, 1139, 59, 83, 435, 413, 566, 221, 327, 308, 17, 508, 308, 18, 421, 199, 318, 485, 17526, 11549, 4619, 774, 8, 2271, 3131, 2215, 3131, 675, 63, 1986, 63, 1392, 3131, 4526, 63, 9154, 3131,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Theer108/invenio
invenio/modules/jsonalchemy/bases.py
17
1636
# -*- coding: utf-8 -*- # # This file is part of Invenio. # Copyright (C) 2014 CERN. # # Invenio is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # Invenio is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Invenio; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. r"""General extensions for JSON objects. JSONAlchemy allows the developer to extend the behavior or capabilities of the JSON objects using `extensions`. For more information about how extensions works check :class:`invenio.modules.jsonalchemy.jsonext.parsers.\ extension_model_parser.ExtensionModelParser`. """ class Versionable(object): """Versionable behavior for JSONAlchemy models.""" def update(self): """Create new revision of the object and saves link to the old one.""" # We need a copy not to modify references to the old object! cls = self.__class__ data = self.dumps() self = cls(data) self['older_version'] = self['_id'] self['_id'] = str(__import__('uuid').uuid4()) # self.set_default_value('_id') # pylint: disable=E1101 return super(Versionable, self).update()
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 12235, 14, 199, 3, 1898, 334, 35, 9, 6927, 24354, 14, 199, 3, 199, 3, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 82, 624, 14109, 5478, 367, 4840, 2251, 14, 199, 199, 6243, 12800, 6127, 314, 15030, 370, 12247, 314, 5953, 503, 14918, 402, 314, 199, 6243, 2251, 1808, 658, 5359, 2313, 2104, 1655, 2556, 3595, 4212, 5478, 199, 12243, 1104, 520, 533, 1705, 30628, 14, 3112, 14, 1001, 6732, 14, 3596, 368, 400, 14, 11531, 3134, 199, 3435, 63, 1238, 63, 2087, 14, 6382, 1685, 2842, 2313, 199, 624, 421, 199, 533, 3394, 461, 8, 785, 304, 339, 408, 3353, 461, 5953, 367, 4840, 12800, 1709, 1041, 339, 347, 1678, 8, 277, 304, 267, 408, 2499, 892, 6974, 402, 314, 909, 436, 23050, 2142, 370, 314, 2269, 1373, 1041, 267, 327, 221, 2136, 1929, 282, 1331, 440, 370, 2811, 6941, 370, 314, 2269, 909, 1, 267, 843, 275, 291, 855, 533, 363, 267, 666, 275, 291, 14, 4180, 342, 267, 291, 275, 843, 8, 576, 9, 267, 291, 459, 2149, 63, 1023, 418, 275, 291, 8680, 344, 418, 267, 291, 8680, 344, 418, 275, 620, 3460, 646, 19734, 2580, 1959, 2580, 20, 1012, 267, 327, 291, 14, 409, 63, 885, 63, 585, 6412, 344, 358, 221, 327, 4287, 26, 3507, 29, 37, 24827, 267, 372, 1613, 8, 3353, 461, 12, 291, 680, 873, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 12235, 14, 199, 3, 1898, 334, 35, 9, 6927, 24354, 14, 199, 3, 199, 3, 12235, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 199, 3, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12235, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 12235, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 2752, 12, 3277, 2020, 199, 3, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 12, 8217, 14, 199, 199, 82, 624, 14109, 5478, 367, 4840, 2251, 14, 199, 199, 6243, 12800, 6127, 314, 15030, 370, 12247, 314, 5953, 503, 14918, 402, 314, 199, 6243, 2251, 1808, 658, 5359, 2313, 2104, 1655, 2556, 3595, 4212, 5478, 199, 12243, 1104, 520, 533, 1705, 30628, 14, 3112, 14, 1001, 6732, 14, 3596, 368, 400, 14, 11531, 3134, 199, 3435, 63, 1238, 63, 2087, 14, 6382, 1685, 2842, 2313, 199, 624, 421, 199, 533, 3394, 461, 8, 785, 304, 339, 408, 3353, 461, 5953, 367, 4840, 12800, 1709, 1041, 339, 347, 1678, 8, 277, 304, 267, 408, 2499, 892, 6974, 402, 314, 909, 436, 23050, 2142, 370, 314, 2269, 1373, 1041, 267, 327, 221, 2136, 1929, 282, 1331, 440, 370, 2811, 6941, 370, 314, 2269, 909, 1, 267, 843, 275, 291, 855, 533, 363, 267, 666, 275, 291, 14, 4180, 342, 267, 291, 275, 843, 8, 576, 9, 267, 291, 459, 2149, 63, 1023, 418, 275, 291, 8680, 344, 418, 267, 291, 8680, 344, 418, 275, 620, 3460, 646, 19734, 2580, 1959, 2580, 20, 1012, 267, 327, 291, 14, 409, 63, 885, 63, 585, 6412, 344, 358, 221, 327, 4287, 26, 3507, 29, 37, 24827, 267, 372, 1613, 8, 3353, 461, 12, 291, 680, 873, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
juliancantillo/royal-films
config/settings/local.py
1
1950
# -*- coding: utf-8 -*- ''' Local settings - Run in Debug mode - Use console backend for emails - Add Django Debug Toolbar - Add django-extensions as app ''' from .common import * # noqa # DEBUG # ------------------------------------------------------------------------------ DEBUG = env.bool('DJANGO_DEBUG', default=True) TEMPLATES[0]['OPTIONS']['debug'] = DEBUG # SECRET CONFIGURATION # ------------------------------------------------------------------------------ # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key # Note: This key only used for development and testing. SECRET_KEY = env("DJANGO_SECRET_KEY", default='t3kohnptyzfb7v@s@4dlm2o1356rz&^oamd-y34qat^^69b+s(') # Mail settings # ------------------------------------------------------------------------------ EMAIL_HOST = 'localhost' EMAIL_PORT = 1025 EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', default='django.core.mail.backends.console.EmailBackend') # CACHING # ------------------------------------------------------------------------------ CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': '' } } # django-debug-toolbar # ------------------------------------------------------------------------------ MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',) INSTALLED_APPS += ('debug_toolbar', ) INTERNAL_IPS = ('127.0.0.1', '10.0.2.2',) DEBUG_TOOLBAR_CONFIG = { 'DISABLE_PANELS': [ 'debug_toolbar.panels.redirects.RedirectsPanel', ], 'SHOW_TEMPLATE_CONTEXT': True, } # django-extensions # ------------------------------------------------------------------------------ INSTALLED_APPS += ('django_extensions', ) # TESTING # ------------------------------------------------------------------------------ TEST_RUNNER = 'django.test.runner.DiscoverRunner' # Your local stuff: Below this line define 3rd party library settings
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 2344, 199, 5339, 2202, 199, 199, 13, 3378, 315, 14245, 818, 199, 13, 3645, 8559, 4865, 367, 14931, 199, 13, 2654, 5634, 14245, 15650, 1700, 199, 13, 2654, 1639, 13, 5359, 465, 1145, 199, 2344, 199, 199, 504, 1275, 2330, 492, 627, 221, 327, 8151, 199, 199, 3, 10990, 199, 3, 5620, 10965, 199, 5287, 275, 2589, 14, 2245, 360, 22848, 63, 5287, 297, 849, 29, 549, 9, 199, 25437, 59, 16, 2733, 8808, 2545, 1757, 418, 275, 10990, 199, 199, 3, 5795, 11771, 15869, 15301, 199, 3, 5620, 10965, 199, 3, 1666, 26, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 1751, 12645, 4731, 13, 498, 199, 3, 3390, 26, 961, 790, 1454, 1202, 367, 16367, 436, 5343, 14, 199, 12961, 63, 3078, 275, 2589, 480, 22848, 63, 12961, 63, 3078, 401, 849, 534, 84, 19, 7697, 72, 1590, 369, 90, 4675, 23, 86, 32, 83, 32, 20, 5030, 77, 18, 79, 969, 1367, 30841, 6, 62, 79, 21778, 13, 89, 1082, 81, 292, 11871, 1876, 66, 11, 83, 15938, 199, 199, 3, 18027, 2202, 199, 3, 5620, 10965, 199, 10089, 63, 5449, 275, 283, 5967, 7, 199, 10089, 63, 3657, 275, 1616, 821, 199, 10089, 63, 18145, 275, 2589, 360, 22848, 63, 10089, 63, 18145, 297, 490, 849, 534, 1176, 14, 1018, 14, 1198, 14, 7765, 14, 6614, 14, 7035, 8447, 358, 199, 199, 3, 7240, 1244, 1206, 199, 3, 5620, 10965, 199, 3263, 1244, 654, 275, 469, 272, 283, 885, 356, 469, 267, 283, 18145, 356, 283, 1176, 14, 1018, 14, 1637, 14, 7765, 14, 2102, 5286, 14, 3040, 14169, 4437, 297, 267, 283, 16575, 356, 2125, 272, 789, 199, 93, 199, 199, 3, 1639, 13, 1757, 13, 13951, 199, 3, 5620, 10965, 199, 19987, 63, 13748, 847, 661, 1757, 63, 13951, 14, 5754, 14, 7084, 29630, 6608, 9538, 199, 15942, 63, 14219, 847, 661, 1757, 63, 13951, 297, 776, 199, 199, 17681, 63, 12346, 275, 661, 4195, 14, 16, 14, 16, 14, 17, 297, 283, 709, 14, 16, 14, 18, 14, 18, 9538, 199, 199, 5287, 63, 9731, 13895, 63, 5569, 275, 469, 272, 283, 13052, 63, 26685, 2901, 51, 356, 359, 267, 283, 1757, 63, 13951, 14, 31929, 14, 13607, 14, 16032, 10185, 297, 272, 2156, 272, 283, 19085, 63, 7433, 63, 9059, 356, 715, 12, 199, 93, 199, 199, 3, 1639, 13, 5359, 199, 3, 5620, 10965, 199, 15942, 63, 14219, 847, 661, 1176, 63, 5359, 297, 776, 199, 199, 3, 7393, 1206, 199, 3, 5620, 10965, 199, 2864, 63, 9390, 15215, 275, 283, 1176, 14, 396, 14, 5933, 14, 2825, 5899, 7446, 7, 199, 199, 3, 19519, 2257, 8292, 26, 6423, 674, 642, 1004, 5627, 650, 6883, 17135, 3555, 2202, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 2344, 199, 5339, 2202, 199, 199, 13, 3378, 315, 14245, 818, 199, 13, 3645, 8559, 4865, 367, 14931, 199, 13, 2654, 5634, 14245, 15650, 1700, 199, 13, 2654, 1639, 13, 5359, 465, 1145, 199, 2344, 199, 199, 504, 1275, 2330, 492, 627, 221, 327, 8151, 199, 199, 3, 10990, 199, 3, 5620, 10965, 199, 5287, 275, 2589, 14, 2245, 360, 22848, 63, 5287, 297, 849, 29, 549, 9, 199, 25437, 59, 16, 2733, 8808, 2545, 1757, 418, 275, 10990, 199, 199, 3, 5795, 11771, 15869, 15301, 199, 3, 5620, 10965, 199, 3, 1666, 26, 4178, 921, 4757, 14, 14013, 14, 957, 15, 287, 15, 2374, 15, 1121, 15, 1751, 12645, 4731, 13, 498, 199, 3, 3390, 26, 961, 790, 1454, 1202, 367, 16367, 436, 5343, 14, 199, 12961, 63, 3078, 275, 2589, 480, 22848, 63, 12961, 63, 3078, 401, 849, 534, 84, 19, 7697, 72, 1590, 369, 90, 4675, 23, 86, 32, 83, 32, 20, 5030, 77, 18, 79, 969, 1367, 30841, 6, 62, 79, 21778, 13, 89, 1082, 81, 292, 11871, 1876, 66, 11, 83, 15938, 199, 199, 3, 18027, 2202, 199, 3, 5620, 10965, 199, 10089, 63, 5449, 275, 283, 5967, 7, 199, 10089, 63, 3657, 275, 1616, 821, 199, 10089, 63, 18145, 275, 2589, 360, 22848, 63, 10089, 63, 18145, 297, 490, 849, 534, 1176, 14, 1018, 14, 1198, 14, 7765, 14, 6614, 14, 7035, 8447, 358, 199, 199, 3, 7240, 1244, 1206, 199, 3, 5620, 10965, 199, 3263, 1244, 654, 275, 469, 272, 283, 885, 356, 469, 267, 283, 18145, 356, 283, 1176, 14, 1018, 14, 1637, 14, 7765, 14, 2102, 5286, 14, 3040, 14169, 4437, 297, 267, 283, 16575, 356, 2125, 272, 789, 199, 93, 199, 199, 3, 1639, 13, 1757, 13, 13951, 199, 3, 5620, 10965, 199, 19987, 63, 13748, 847, 661, 1757, 63, 13951, 14, 5754, 14, 7084, 29630, 6608, 9538, 199, 15942, 63, 14219, 847, 661, 1757, 63, 13951, 297, 776, 199, 199, 17681, 63, 12346, 275, 661, 4195, 14, 16, 14, 16, 14, 17, 297, 283, 709, 14, 16, 14, 18, 14, 18, 9538, 199, 199, 5287, 63, 9731, 13895, 63, 5569, 275, 469, 272, 283, 13052, 63, 26685, 2901, 51, 356, 359, 267, 283, 1757, 63, 13951, 14, 31929, 14, 13607, 14, 16032, 10185, 297, 272, 2156, 272, 283, 19085, 63, 7433, 63, 9059, 356, 715, 12, 199, 93, 199, 199, 3, 1639, 13, 5359, 199, 3, 5620, 10965, 199, 15942, 63, 14219, 847, 661, 1176, 63, 5359, 297, 776, 199, 199, 3, 7393, 1206, 199, 3, 5620, 10965, 199, 2864, 63, 9390, 15215, 275, 283, 1176, 14, 396, 14, 5933, 14, 2825, 5899, 7446, 7, 199, 199, 3, 19519, 2257, 8292, 26, 6423, 674, 642, 1004, 5627, 650, 6883, 17135, 3555, 2202, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
madengr/ham2mon
apps/cursesgui.py
2
20956
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Created on Sun Jul 5 17:16:22 2015 @author: madengr """ import locale locale.setlocale(locale.LC_ALL, '') import curses import time import numpy as np class SpectrumWindow(object): """Curses spectrum display window Args: screen (object): a curses screen object Attributes: max_db (float): Top of window in dB min_db (float): Bottom of window in dB threshold_db (float): Threshold horizontal line """ def __init__(self, screen): self.screen = screen # Set default values self.max_db = 50.0 self.min_db = -20.0 self.threshold_db = 20.0 # Create a window object in top half of the screen, within the border screen_dims = screen.getmaxyx() height = int(screen_dims[0]/2.0) width = screen_dims[1]-2 self.win = curses.newwin(height, width, 1, 1) self.dims = self.win.getmaxyx() # Right end of window resreved for string of N charachters self.chars = 7 def draw_spectrum(self, data): """Scales input spectral data to window dimensions and draws bar graph Args: data (numpy.ndarray): FFT power spectrum data in linear, not dB Test cases for data with min_db=-100 and max_db=0 on 80x24 terminal: 1.0E-10 draws nothing since it is not above -100 dB 1.1E-10 draws one row 1.0E-05 draws 5 rows 1.0E+00 draws 10 rows 1.0E+01 draws 10 rows """ # Keep min_db to 10 dB below max_db if self.min_db > (self.max_db - 10): self.min_db = self.max_db - 10 # Split the data into N window bins # N is window width between border (i.e. self.dims[1]-2 ) # Data must be at least as long as the window width or crash # Use the maximum value from each input data bin for the window bin win_bins = np.array_split(data, self.dims[1]-self.chars) win_bin_max = [] for win_bin in win_bins: win_bin_max.append(np.max(win_bin)) # Convert to dB win_bin_max_db = 10*np.log10(win_bin_max) # The plot windows starts from max_db at the top # and draws DOWNWARD to min_db (remember this is a curses window). # Thus linear scaling goes from min_y=1 at the top # and draws DOWNWARD to max_y=dims[0]-1 at the bottom # The "1" and "-1" is to account for the border at top and bottom min_y = 1 max_y = self.dims[0]-1 # Scaling factor for plot scale = (min_y-max_y)/(self.max_db-self.min_db) # Generate y position, clip to window, and convert to int pos_y = (win_bin_max_db - self.max_db) * scale pos_y = np.clip(pos_y, min_y, max_y) pos_y = pos_y.astype(int) # Clear previous contents, draw border, and title self.win.clear() self.win.border(0) self.win.addnstr(0, self.dims[1]/2-4, "SPECTRUM", 8, curses.color_pair(4)) # Draw the bars for pos_x in range(len(pos_y)): # Invert the y fill since we want bars # Offset x (column) by 1 so it does not start on the border self.win.vline(pos_y[pos_x], pos_x+1, "*", max_y-pos_y[pos_x]) # Draw the max_db and min_db strings string = ">" + "%+03d" % self.max_db self.win.addnstr(0, 1 + self.dims[1] - self.chars, string, self.chars, curses.color_pair(1)) string = ">" + "%+03d" % self.min_db self.win.addnstr(max_y, 1 + self.dims[1] - self.chars, string, self.chars, curses.color_pair(3)) # Generate threshold line, clip to window, and convert to int pos_yt = (self.threshold_db - self.max_db) * scale pos_yt = np.clip(pos_yt, min_y, max_y-1) pos_yt = pos_yt.astype(int) # Draw the theshold line # x=1 start to account for left border self.win.hline(pos_yt, 1, "-", len(pos_y)) # Draw the theshold string string = ">" + "%+03d" % self.threshold_db self.win.addnstr(pos_yt, (1 + self.dims[1] - self.chars), string, self.chars, curses.color_pair(2)) # Hide cursor self.win.leaveok(1) # Update virtual window self.win.noutrefresh() def proc_keyb(self, keyb): """Process keystrokes Args: keyb (int): keystroke in ASCII Returns: bool: True if receiver needs tuning, False if not """ if keyb == ord('t'): self.threshold_db += 5 return True elif keyb == ord('r'): self.threshold_db -= 5 return True elif keyb == ord('T'): self.threshold_db += 1 return True elif keyb == ord('R'): self.threshold_db -= 1 return True elif keyb == ord('p'): self.max_db += 10 elif keyb == ord('o'): self.max_db -= 10 elif keyb == ord('w'): self.min_db += 10 elif keyb == ord('q'): self.min_db -= 10 else: pass return False class ChannelWindow(object): """Curses channel display window Args: screen (object): a curses screen object """ # pylint: disable=too-few-public-methods def __init__(self, screen): self.screen = screen # Create a window object in the bottom half of the screen # Make it about 1/3 the screen width # Place on left side and to the right of the border screen_dims = screen.getmaxyx() height = int(screen_dims[0]/2.0)-2 width = int(screen_dims[1]/3.0)-1 self.win = curses.newwin(height, width, height + 3, 1) self.dims = self.win.getmaxyx() def draw_channels(self, gui_tuned_channels): """Draws tuned channels list Args: rf_channels [string]: List of strings in MHz """ # Clear previous contents, draw border, and title self.win.clear() self.win.border(0) self.win.addnstr(0, self.dims[1]/2-4, "CHANNELS", 8, curses.color_pair(4)) # Limit the displayed channels to no more than two rows max_length = 2*(self.dims[0]-2) if len(gui_tuned_channels) > max_length: gui_tuned_channels = gui_tuned_channels[:max_length] else: pass # Draw the tuned channels prefixed by index in list (demodulator index) for idx, gui_tuned_channel in enumerate(gui_tuned_channels): text = str(idx) + ": " + gui_tuned_channel if idx < self.dims[0]-2: # Display in first column self.win.addnstr(idx+1, 1, text, 11) else: # Display in second column self.win.addnstr(idx-self.dims[0]+3, 13, text, 11) # Hide cursor self.win.leaveok(1) # Update virtual window self.win.noutrefresh() class LockoutWindow(object): """Curses lockout channel display window Args: screen (object): a curses screen object """ # pylint: disable=too-few-public-methods def __init__(self, screen): self.screen = screen # Create a window object in the bottom half of the screen # Make it about 1/4 the screen width # Place on left side and to the right of the border screen_dims = screen.getmaxyx() height = int(screen_dims[0]/2.0)-2 width = int(screen_dims[1]/4.0)-5 self.win = curses.newwin(height, width, height + 3, 26) self.dims = self.win.getmaxyx() def draw_channels(self, gui_lockout_channels): """Draws tuned channels list Args: rf_channels [string]: List of strings in MHz """ # Clear previous contents, draw border, and title self.win.clear() self.win.border(0) self.win.addnstr(0, self.dims[1]/2-3, "LOCKOUT", 7, curses.color_pair(4)) # Draw the lockout channels for idx, gui_lockout_channel in enumerate(gui_lockout_channels): # Don't draw past height of window if idx <= self.dims[0]-3: text = " " + gui_lockout_channel self.win.addnstr(idx+1, 1, text, 11) else: pass # Hide cursor self.win.leaveok(1) # Update virtual window self.win.noutrefresh() def proc_keyb_set_lockout(self, keyb): """Process keystrokes to lock out channels 0 - 9 Args: keyb (int): keystroke in ASCII Returns: bool: True if scanner needs adjusting, False if not """ # pylint: disable=no-self-use # Check if keys 0 - 9 pressed if keyb - 48 in range(10): return True else: return False def proc_keyb_clear_lockout(self, keyb): """Process keystrokes to clear lockout with "l" Args: keyb (int): keystroke in ASCII Returns: bool: True if scanner needs adjusting, False if not """ # pylint: disable=no-self-use # Check if 'l' is pressed if keyb == ord('l'): return True else: return False class RxWindow(object): """Curses receiver paramater window Args: screen (object): a curses screen object Attributes: center_freq (float): Hardware RF center frequency in Hz samp_rate (float): Hardware sample rate in sps (1E6 min) gain_db (int): Hardware RF gain in dB if_gain_db (int): Hardware IF gain in dB bb_gain_db (int): Hardware BB gain in dB squelch_db (int): Squelch in dB volume_dB (int): Volume in dB record (bool): Record audio to file if True lockout_file_name (string): Name of file with channels to lockout priority_file_name (string): Name of file with channels for priority """ # pylint: disable=too-many-instance-attributes def __init__(self, screen): self.screen = screen # Set default values self.center_freq = 146E6 self.samp_rate = 2E6 self.freq_entry = 'None' self.gain_db = 0 self.if_gain_db = 16 self.bb_gain_db = 16 self.squelch_db = -60 self.volume_db = 0 self.type_demod = 0 self.record = True self.lockout_file_name = "" self.priority_file_name = "" # Create a window object in the bottom half of the screen # Make it about 1/3 the screen width # Place on right side and to the left of the border screen_dims = screen.getmaxyx() height = int(screen_dims[0]/2.0)-2 width = int(screen_dims[1]/2.0)-2 self.win = curses.newwin(height, width, height + 3, int(screen_dims[1]-width-1)) self.dims = self.win.getmaxyx() def draw_rx(self): """Draws receiver paramaters """ # Clear previous contents, draw border, and title self.win.clear() self.win.border(0) self.win.addnstr(0, self.dims[1]/2-4, "RECEIVER", 8, curses.color_pair(4)) # Draw the receiver info prefix fields text = "RF Freq (MHz) : " self.win.addnstr(1, 1, text, 15) text = "RF Gain (dB) : " self.win.addnstr(2, 1, text, 15) text = "IF Gain (dB) : " self.win.addnstr(3, 1, text, 15) text = "BB Gain (dB) : " self.win.addnstr(4, 1, text, 15) text = "BB Rate (Msps): " self.win.addnstr(5, 1, text, 15) text = "BB Sql (dB) : " self.win.addnstr(6, 1, text, 15) text = "AF Vol (dB) : " self.win.addnstr(7, 1, text, 15) text = "Record : " self.win.addnstr(8, 1, text, 15) text = "Demod Type : " self.win.addnstr(9, 1, text, 15) text = "Files : " self.win.addnstr(10, 1, text, 15) # Draw the receiver info suffix fields if self.freq_entry <> 'None': text = self.freq_entry else: text = '{:.3f}'.format((self.center_freq)/1E6) self.win.addnstr(1, 17, text, 8, curses.color_pair(5)) text = str(self.gain_db) self.win.addnstr(2, 17, text, 8, curses.color_pair(5)) text = str(self.if_gain_db) self.win.addnstr(3, 17, text, 8, curses.color_pair(5)) text = str(self.bb_gain_db) self.win.addnstr(4, 17, text, 8, curses.color_pair(5)) text = str(self.samp_rate/1E6) self.win.addnstr(5, 17, text, 8) text = str(self.squelch_db) self.win.addnstr(6, 17, text, 8, curses.color_pair(5)) text = str(self.volume_db) self.win.addnstr(7, 17, text, 8, curses.color_pair(5)) text = str(self.record) self.win.addnstr(8, 17, text, 8) text = str(self.type_demod) self.win.addnstr(9, 17, text, 8) text = str(self.lockout_file_name) + " " + str(self.priority_file_name) self.win.addnstr(10, 17, text, 20) # Hide cursor self.win.leaveok(1) # Update virtual window self.win.noutrefresh() def proc_keyb_hard(self, keyb): """Process keystrokes to adjust hard receiver settings Tune center_freq in 100 MHz steps with 'x' and 'c' Tune center_freq in 10 MHz steps with 'v' and 'c' Tune center_freq in 1 MHz steps with 'm' and 'n' Tune center_freq in 100 kHz steps with 'k' and 'j' Args: keyb (int): keystroke in ASCII Returns: bool: True if receiver needs adjusting, False if not """ # pylint: disable=too-many-return-statements # pylint: disable=too-many-branches # Tune self.center_freq in 100 MHz steps with 'x' and 'c' if keyb == ord('x'): self.center_freq += 1E8 return True elif keyb == ord('z'): self.center_freq -= 1E8 return True # Tune self.center_freq in 10 MHz steps with 'v' and 'c' elif keyb == ord('v'): self.center_freq += 1E7 return True elif keyb == ord('c'): self.center_freq -= 1E7 return True # Tune self.center_freq in 1 MHz steps with 'm' and 'n' elif keyb == ord('m'): self.center_freq += 1E6 return True elif keyb == ord('n'): self.center_freq -= 1E6 return True # Tune self.center_freq in 100 kHz steps with 'k' and 'j' elif keyb == ord('k'): self.center_freq += 1E5 return True elif keyb == ord('j'): self.center_freq -= 1E5 return True elif keyb == ord('/'): # set mode to frequency entry self.freq_entry = '' return False elif keyb == 27: # ESC # end frequncy entry mode without seting the frequency self.freq_entry = 'None' return False elif keyb == ord('\n'): # set the frequency from what was entered try: self.center_freq = float(self.freq_entry) * 1E6 except: pass self.freq_entry = 'None' return True elif self.freq_entry <> 'None' and (keyb - 48 in range (10) or keyb == ord('.')): # build up frequency from 1-9 and '.' self.freq_entry = self.freq_entry + chr(keyb) return False elif keyb == 127: # BKSP self.freq_entry = self.freq_entry[:-1] return False else: return False def proc_keyb_soft(self, keyb): """Process keystrokes to adjust soft receiver settings Tune gain_db in 10 dB steps with 'g' and 'f' Tune squelch_db in 1 dB steps with 's' and 'a' Tune volume_db in 1 dB steps with '.' and ',' Args: keyb (int): keystroke in ASCII Returns: bool: True if receiver needs tuning, False if not """ # pylint: disable=too-many-return-statements # pylint: disable=too-many-branches # Tune self.gain_db in 10 dB steps with 'g' and 'f' if keyb == ord('g'): self.gain_db += 10 return True elif keyb == ord('f'): self.gain_db -= 10 return True # Tune self.gain_db in 1 dB steps with 'G' and 'F' if keyb == ord('G'): self.gain_db += 1 return True elif keyb == ord('F'): self.gain_db -= 1 return True # Tune self.if_gain_db in 10 dB steps with 'u' and 'y' if keyb == ord('u'): self.if_gain_db += 10 return True elif keyb == ord('y'): self.if_gain_db -= 10 return True # Tune self.if_gain_db in 1 dB steps with 'U' and 'Y' if keyb == ord('U'): self.if_gain_db += 1 return True elif keyb == ord('Y'): self.if_gain_db -= 1 return True # Tune self.bb_gain_db in 10 dB steps with ']' and '[' if keyb == ord(']'): self.bb_gain_db += 10 return True elif keyb == ord('['): self.bb_gain_db -= 10 return True # Tune self.bb_gain_db in 1 dB steps with '}' and '{' if keyb == ord('}'): self.bb_gain_db += 1 return True elif keyb == ord('{'): self.bb_gain_db -= 1 return True # Tune self.squelch_db in 1 dB steps with 's' and 'a' elif keyb == ord('s'): self.squelch_db += 1 return True elif keyb == ord('a'): self.squelch_db -= 1 return True # Tune self.volume_db in 1 dB steps with '.' and ',' elif keyb == ord('.'): self.volume_db += 1 return True elif keyb == ord(','): self.volume_db -= 1 return True else:# pylint: disable=too-many-return-statements return False def setup_screen(screen): """Sets up screen """ # Set screen to getch() is non-blocking screen.nodelay(1) # Define some colors curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_CYAN, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_MAGENTA, curses.COLOR_BLACK) curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLACK) # Add border screen.border(0) def main(): """Test most of the GUI (except lockout processing) Initialize and set up screen Create windows Generate dummy spectrum data Update windows with dummy values Process keyboard strokes """ # Use the curses.wrapper() to crash cleanly # Note the screen object is passed from the wrapper() # http://stackoverflow.com/questions/9854511/ppos_ython-curses-dilemma # The issue is the debuuger won't work with the wrapper() # So enable the next 2 lines and don't pass screen to main() screen = curses.initscr() curses.start_color() # Setup the screen setup_screen(screen) # Create windows specwin = SpectrumWindow(screen) chanwin = ChannelWindow(screen) lockoutwin = LockoutWindow(screen) rxwin = RxWindow(screen) while 1: # Generate some random spectrum data from -dyanmic_range to 0 dB # then offset_db length = 128 dynamic_range_db = 100 offset_db = 50 data = np.power(10, (-dynamic_range_db*np.random.rand(length)/10)\ + offset_db/10) #data = 1E-5*np.ones(length) specwin.draw_spectrum(data) # Put some dummy values in the channel, lockout, and receiver windows chanwin.draw_channels(['144.100', '142.40', '145.00', '144.10',\ '142.40', '145.00', '144.10', '142.40', '145.00', '144.10', '142.40',\ '145.00', '142.40', '145.00', '144.10', '142.400', '145.00', '145.00']) lockoutwin.draw_channels(['144.100', '142.40', '145.00']) rxwin.draw_rx() # Update physical screen curses.doupdate() # Check for keystrokes and process keyb = screen.getch() specwin.proc_keyb(keyb) rxwin.proc_keyb_hard(keyb) rxwin.proc_keyb_soft(keyb) # Sleep to get about a 10 Hz refresh time.sleep(0.1) if __name__ == '__main__': try: #curses.wrapper(main) main() except KeyboardInterrupt: pass
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 10502, 641, 25625, 1603, 348, 221, 959, 5557, 26, 975, 26, 1081, 6900, 199, 199, 32, 2502, 26, 610, 848, 2587, 199, 624, 199, 646, 5867, 199, 5508, 14, 409, 5508, 8, 5508, 14, 7027, 63, 1761, 12, 4074, 199, 646, 15429, 199, 646, 900, 199, 646, 2680, 465, 980, 421, 199, 533, 428, 9120, 4301, 8, 785, 304, 272, 408, 3864, 874, 20645, 2929, 4353, 339, 3033, 26, 267, 6426, 334, 785, 304, 282, 15429, 6426, 909, 339, 9382, 26, 267, 1390, 63, 697, 334, 1609, 304, 14132, 402, 4353, 315, 366, 34, 267, 1748, 63, 697, 334, 1609, 304, 24896, 3151, 402, 4353, 315, 366, 34, 267, 8765, 63, 697, 334, 1609, 304, 3868, 4480, 17528, 1004, 272, 408, 272, 347, 636, 826, 721, 277, 12, 6426, 304, 267, 291, 14, 5410, 275, 6426, 398, 327, 2494, 849, 1338, 267, 291, 14, 988, 63, 697, 275, 5238, 14, 16, 267, 291, 14, 827, 63, 697, 275, 446, 1165, 14, 16, 267, 291, 14, 7227, 63, 697, 275, 3388, 14, 16, 398, 327, 2790, 282, 4353, 909, 315, 2746, 12995, 402, 314, 6426, 12, 4453, 314, 9162, 267, 6426, 63, 5380, 275, 6426, 14, 362, 988, 20937, 342, 267, 4569, 275, 1109, 8, 5410, 63, 5380, 59, 16, 12978, 18, 14, 16, 9, 267, 3462, 275, 6426, 63, 5380, 59, 17, 11285, 18, 267, 291, 14, 2676, 275, 15429, 14, 1222, 2676, 8, 3333, 12, 3462, 12, 413, 12, 413, 9, 267, 291, 14, 5380, 275, 291, 14, 2676, 14, 362, 988, 20937, 342, 398, 327, 20854, 1284, 402, 4353, 522, 264, 1354, 367, 1059, 402, 653, 1495, 1225, 878, 267, 291, 14, 6574, 275, 1520, 339, 347, 5954, 63, 18142, 8, 277, 12, 666, 304, 267, 408, 9944, 83, 1324, 28397, 666, 370, 4353, 7365, 436, 5954, 83, 4681, 3343, 398, 3033, 26, 288, 666, 334, 4714, 14, 8237, 304, 29484, 7074, 20645, 666, 315, 7798, 12, 440, 366, 34, 398, 1379, 5560, 367, 666, 543, 1748, 63, 697, 4022, 1960, 436, 1390, 63, 697, 29, 16, 641, 5939, 88, 1194, 11167, 26, 288, 413, 14, 16, 37, 13, 709, 5954, 83, 6548, 3967, 652, 365, 440, 3432, 446, 1960, 366, 34, 288, 413, 14, 17, 37, 13, 709, 5954, 83, 1373, 1962, 288, 413, 14, 16, 37, 13, 1717, 5954, 83, 959, 4730, 288, 413, 14, 16, 37, 11, 383, 5954, 83, 1616, 4730, 288, 413, 14, 16, 37, 11, 614, 5954, 83, 1616, 4730, 267, 408, 267, 327, 14797, 1748, 63, 697, 370, 1616, 366, 34, 5084, 1390, 63, 697, 267, 340, 291, 14, 827, 63, 697, 690, 334, 277, 14, 988, 63, 697, 446, 1616, 304, 288, 291, 14, 827, 63, 697, 275, 291, 14, 988, 63, 697, 446, 1616, 398, 327, 11740, 314, 666, 1901, 653, 4353, 13341, 267, 327, 653, 365, 4353, 3462, 3382, 9162, 334, 73, 14, 69, 14, 291, 14, 5380, 59, 17, 11285, 18, 776, 267, 327, 3918, 1471, 506, 737, 5210, 465, 1846, 465, 314, 4353, 3462, 503, 12420, 267, 327, 3645, 314, 5696, 574, 687, 1924, 1324, 666, 2517, 367, 314, 4353, 2517, 267, 4747, 63, 11329, 275, 980, 14, 1144, 63, 1294, 8, 576, 12, 291, 14, 5380, 59, 17, 11285, 277, 14, 6574, 9, 267, 4747, 63, 1393, 63, 988, 275, 942, 267, 367, 4747, 63, 1393, 315, 4747, 63, 11329, 26, 288, 4747, 63, 1393, 63, 988, 14, 740, 8, 1590, 14, 988, 8, 2676, 63, 1393, 430, 398, 327, 7905, 370, 366, 34, 267, 4747, 63, 1393, 63, 988, 63, 697, 275, 1616, 10, 1590, 14, 793, 709, 8, 2676, 63, 1393, 63, 988, 9, 398, 327, 710, 5137, 10061, 9174, 687, 1390, 63, 697, 737, 314, 2746, 267, 327, 436, 5954, 83, 10163, 2982, 36, 370, 1748, 63, 697, 334, 264, 1114, 642, 365, 282, 15429, 4353, 680, 267, 327, 20227, 7798, 13690, 13538, 687, 1748, 63, 89, 29, 17, 737, 314, 2746, 267, 327, 436, 5954, 83, 10163, 2982, 36, 370, 1390, 63, 89, 29, 5380, 59, 16, 11285, 17, 737, 314, 9048, 267, 327, 710, 298, 17, 2, 436, 3905, 17, 2, 365, 370, 2933, 367, 314, 9162, 737, 2746, 436, 9048, 267, 1748, 63, 89, 275, 413, 267, 1390, 63, 89, 275, 291, 14, 5380, 59, 16, 11285, 17, 398, 327, 17619, 316, 6535, 367, 5137, 267, 4666, 275, 334, 827, 63, 89, 13, 988, 63, 89, 15136, 277, 14, 988, 63, 697, 13, 277, 14, 827, 63, 697, 9, 398, 327, 7958, 612, 3421, 12, 11353, 370, 4353, 12, 436, 3957, 370, 1109, 267, 2086, 63, 89, 275, 334, 2676, 63, 1393, 63, 988, 63, 697, 446, 291, 14, 988, 63, 697, 9, 627, 4666, 267, 2086, 63, 89, 275, 980, 14, 7548, 8, 1712, 63, 89, 12, 1748, 63, 89, 12, 1390, 63, 89, 9, 267, 2086, 63, 89, 275, 2086, 63, 89, 14, 6041, 8, 442, 9, 13359, 327, 14836, 4136, 4072, 12, 5954, 9162, 12, 436, 2538, 267, 291, 14, 2676, 14, 3584, 342, 267, 291, 14, 2676, 14, 8665, 8, 16, 9, 267, 291, 14, 2676, 14, 525, 26838, 8, 16, 12, 291, 14, 5380, 59, 17, 12978, 18, 13, 20, 12, 298, 51, 11401, 50, 2639, 401, 1695, 12, 586, 15429, 14, 2326, 63, 3852, 8, 20, 430, 398, 327, 17813, 314, 29130, 267, 367, 2086, 63, 88, 315, 1425, 8, 552, 8, 1712, 63, 89, 2298, 288, 327, 1010, 1884, 314, 612, 5554, 3967, 781, 2934, 29130, 288, 327, 29432, 671, 334, 2301, 9, 701, 413, 880, 652, 1630, 440, 1343, 641, 314, 9162, 288, 291, 14, 2676, 14, 86, 604, 8, 1712, 63, 89, 59, 1712, 63, 88, 467, 2086, 63, 88, 11, 17, 12, 8969, 401, 1390, 63, 89, 13, 1712, 63, 89, 59, 1712, 63, 88, 566, 398, 327, 17813, 314, 1390, 63, 697, 436, 1748, 63, 697, 3326, 267, 1059, 275, 28192, 435, 2071, 11, 1644, 68, 2, 450, 291, 14, 988, 63, 697, 267, 291, 14, 2676, 14, 525, 26838, 8, 16, 12, 413, 435, 291, 14, 5380, 59, 17, 61, 446, 291 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 199, 10502, 641, 25625, 1603, 348, 221, 959, 5557, 26, 975, 26, 1081, 6900, 199, 199, 32, 2502, 26, 610, 848, 2587, 199, 624, 199, 646, 5867, 199, 5508, 14, 409, 5508, 8, 5508, 14, 7027, 63, 1761, 12, 4074, 199, 646, 15429, 199, 646, 900, 199, 646, 2680, 465, 980, 421, 199, 533, 428, 9120, 4301, 8, 785, 304, 272, 408, 3864, 874, 20645, 2929, 4353, 339, 3033, 26, 267, 6426, 334, 785, 304, 282, 15429, 6426, 909, 339, 9382, 26, 267, 1390, 63, 697, 334, 1609, 304, 14132, 402, 4353, 315, 366, 34, 267, 1748, 63, 697, 334, 1609, 304, 24896, 3151, 402, 4353, 315, 366, 34, 267, 8765, 63, 697, 334, 1609, 304, 3868, 4480, 17528, 1004, 272, 408, 272, 347, 636, 826, 721, 277, 12, 6426, 304, 267, 291, 14, 5410, 275, 6426, 398, 327, 2494, 849, 1338, 267, 291, 14, 988, 63, 697, 275, 5238, 14, 16, 267, 291, 14, 827, 63, 697, 275, 446, 1165, 14, 16, 267, 291, 14, 7227, 63, 697, 275, 3388, 14, 16, 398, 327, 2790, 282, 4353, 909, 315, 2746, 12995, 402, 314, 6426, 12, 4453, 314, 9162, 267, 6426, 63, 5380, 275, 6426, 14, 362, 988, 20937, 342, 267, 4569, 275, 1109, 8, 5410, 63, 5380, 59, 16, 12978, 18, 14, 16, 9, 267, 3462, 275, 6426, 63, 5380, 59, 17, 11285, 18, 267, 291, 14, 2676, 275, 15429, 14, 1222, 2676, 8, 3333, 12, 3462, 12, 413, 12, 413, 9, 267, 291, 14, 5380, 275, 291, 14, 2676, 14, 362, 988, 20937, 342, 398, 327, 20854, 1284, 402, 4353, 522, 264, 1354, 367, 1059, 402, 653, 1495, 1225, 878, 267, 291, 14, 6574, 275, 1520, 339, 347, 5954, 63, 18142, 8, 277, 12, 666, 304, 267, 408, 9944, 83, 1324, 28397, 666, 370, 4353, 7365, 436, 5954, 83, 4681, 3343, 398, 3033, 26, 288, 666, 334, 4714, 14, 8237, 304, 29484, 7074, 20645, 666, 315, 7798, 12, 440, 366, 34, 398, 1379, 5560, 367, 666, 543, 1748, 63, 697, 4022, 1960, 436, 1390, 63, 697, 29, 16, 641, 5939, 88, 1194, 11167, 26, 288, 413, 14, 16, 37, 13, 709, 5954, 83, 6548, 3967, 652, 365, 440, 3432, 446, 1960, 366, 34, 288, 413, 14, 17, 37, 13, 709, 5954, 83, 1373, 1962, 288, 413, 14, 16, 37, 13, 1717, 5954, 83, 959, 4730, 288, 413, 14, 16, 37, 11, 383, 5954, 83, 1616, 4730, 288, 413, 14, 16, 37, 11, 614, 5954, 83, 1616, 4730, 267, 408, 267, 327, 14797, 1748, 63, 697, 370, 1616, 366, 34, 5084, 1390, 63, 697, 267, 340, 291, 14, 827, 63, 697, 690, 334, 277, 14, 988, 63, 697, 446, 1616, 304, 288, 291, 14, 827, 63, 697, 275, 291, 14, 988, 63, 697, 446, 1616, 398, 327, 11740, 314, 666, 1901, 653, 4353, 13341, 267, 327, 653, 365, 4353, 3462, 3382, 9162, 334, 73, 14, 69, 14, 291, 14, 5380, 59, 17, 11285, 18, 776, 267, 327, 3918, 1471, 506, 737, 5210, 465, 1846, 465, 314, 4353, 3462, 503, 12420, 267, 327, 3645, 314, 5696, 574, 687, 1924, 1324, 666, 2517, 367, 314, 4353, 2517, 267, 4747, 63, 11329, 275, 980, 14, 1144, 63, 1294, 8, 576, 12, 291, 14, 5380, 59, 17, 11285, 277, 14, 6574, 9, 267, 4747, 63, 1393, 63, 988, 275, 942, 267, 367, 4747, 63, 1393, 315, 4747, 63, 11329, 26, 288, 4747, 63, 1393, 63, 988, 14, 740, 8, 1590, 14, 988, 8, 2676, 63, 1393, 430, 398, 327, 7905, 370, 366, 34, 267, 4747, 63, 1393, 63, 988, 63, 697, 275, 1616, 10, 1590, 14, 793, 709, 8, 2676, 63, 1393, 63, 988, 9, 398, 327, 710, 5137, 10061, 9174, 687, 1390, 63, 697, 737, 314, 2746, 267, 327, 436, 5954, 83, 10163, 2982, 36, 370, 1748, 63, 697, 334, 264, 1114, 642, 365, 282, 15429, 4353, 680, 267, 327, 20227, 7798, 13690, 13538, 687, 1748, 63, 89, 29, 17, 737, 314, 2746, 267, 327, 436, 5954, 83, 10163, 2982, 36, 370, 1390, 63, 89, 29, 5380, 59, 16, 11285, 17, 737, 314, 9048, 267, 327, 710, 298, 17, 2, 436, 3905, 17, 2, 365, 370, 2933, 367, 314, 9162, 737, 2746, 436, 9048, 267, 1748, 63, 89, 275, 413, 267, 1390, 63, 89, 275, 291, 14, 5380, 59, 16, 11285, 17, 398, 327, 17619, 316, 6535, 367, 5137, 267, 4666, 275, 334, 827, 63, 89, 13, 988, 63, 89, 15136, 277, 14, 988, 63, 697, 13, 277, 14, 827, 63, 697, 9, 398, 327, 7958, 612, 3421, 12, 11353, 370, 4353, 12, 436, 3957, 370, 1109, 267, 2086, 63, 89, 275, 334, 2676, 63, 1393, 63, 988, 63, 697, 446, 291, 14, 988, 63, 697, 9, 627, 4666, 267, 2086, 63, 89, 275, 980, 14, 7548, 8, 1712, 63, 89, 12, 1748, 63, 89, 12, 1390, 63, 89, 9, 267, 2086, 63, 89, 275, 2086, 63, 89, 14, 6041, 8, 442, 9, 13359, 327, 14836, 4136, 4072, 12, 5954, 9162, 12, 436, 2538, 267, 291, 14, 2676, 14, 3584, 342, 267, 291, 14, 2676, 14, 8665, 8, 16, 9, 267, 291, 14, 2676, 14, 525, 26838, 8, 16, 12, 291, 14, 5380, 59, 17, 12978, 18, 13, 20, 12, 298, 51, 11401, 50, 2639, 401, 1695, 12, 586, 15429, 14, 2326, 63, 3852, 8, 20, 430, 398, 327, 17813, 314, 29130, 267, 367, 2086, 63, 88, 315, 1425, 8, 552, 8, 1712, 63, 89, 2298, 288, 327, 1010, 1884, 314, 612, 5554, 3967, 781, 2934, 29130, 288, 327, 29432, 671, 334, 2301, 9, 701, 413, 880, 652, 1630, 440, 1343, 641, 314, 9162, 288, 291, 14, 2676, 14, 86, 604, 8, 1712, 63, 89, 59, 1712, 63, 88, 467, 2086, 63, 88, 11, 17, 12, 8969, 401, 1390, 63, 89, 13, 1712, 63, 89, 59, 1712, 63, 88, 566, 398, 327, 17813, 314, 1390, 63, 697, 436, 1748, 63, 697, 3326, 267, 1059, 275, 28192, 435, 2071, 11, 1644, 68, 2, 450, 291, 14, 988, 63, 697, 267, 291, 14, 2676, 14, 525, 26838, 8, 16, 12, 413, 435, 291, 14, 5380, 59, 17, 61, 446, 291, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
idem2lyon/persomov
couchpotato/core/media/movie/providers/trailer/youtube_dl/extractor/ted.py
17
8529
from __future__ import unicode_literals import json import re from .subtitles import SubtitlesInfoExtractor from ..compat import ( compat_str, ) class TEDIE(SubtitlesInfoExtractor): _VALID_URL = r'''(?x) (?P<proto>https?://) (?P<type>www|embed)(?P<urlmain>\.ted\.com/ ( (?P<type_playlist>playlists(?:/\d+)?) # We have a playlist | ((?P<type_talk>talks)) # We have a simple talk | (?P<type_watch>watch)/[^/]+/[^/]+ ) (/lang/(.*?))? # The url may contain the language /(?P<name>[\w-]+) # Here goes the name and then ".html" .*)$ ''' _TESTS = [{ 'url': 'http://www.ted.com/talks/dan_dennett_on_our_consciousness.html', 'md5': 'fc94ac279feebbce69f21c0c6ee82810', 'info_dict': { 'id': '102', 'ext': 'mp4', 'title': 'The illusion of consciousness', 'description': ('Philosopher Dan Dennett makes a compelling ' 'argument that not only don\'t we understand our own ' 'consciousness, but that half the time our brains are ' 'actively fooling us.'), 'uploader': 'Dan Dennett', 'width': 854, 'duration': 1308, } }, { 'url': 'http://www.ted.com/watch/ted-institute/ted-bcg/vishal-sikka-the-beauty-and-power-of-algorithms', 'md5': '226f4fb9c62380d11b7995efa4c87994', 'info_dict': { 'id': 'vishal-sikka-the-beauty-and-power-of-algorithms', 'ext': 'mp4', 'title': 'Vishal Sikka: The beauty and power of algorithms', 'thumbnail': 're:^https?://.+\.jpg', 'description': 'Adaptive, intelligent, and consistent, algorithms are emerging as the ultimate app for everything from matching consumers to products to assessing medical diagnoses. Vishal Sikka shares his appreciation for the algorithm, charting both its inherent beauty and its growing power.', } }, { 'url': 'http://www.ted.com/talks/gabby_giffords_and_mark_kelly_be_passionate_be_courageous_be_your_best', 'info_dict': { 'id': '1972', 'ext': 'mp4', 'title': 'Be passionate. Be courageous. Be your best.', 'uploader': 'Gabby Giffords and Mark Kelly', 'description': 'md5:5174aed4d0f16021b704120360f72b92', 'duration': 1128, }, }, { 'url': 'http://www.ted.com/playlists/who_are_the_hackers', 'info_dict': { 'id': '10', 'title': 'Who are the hackers?', }, 'playlist_mincount': 6, }, { # contains a youtube video 'url': 'https://www.ted.com/talks/douglas_adams_parrots_the_universe_and_everything', 'add_ie': ['Youtube'], 'info_dict': { 'id': '_ZG8HBuDjgc', 'ext': 'mp4', 'title': 'Douglas Adams: Parrots the Universe and Everything', 'description': 'md5:01ad1e199c49ac640cb1196c0e9016af', 'uploader': 'University of California Television (UCTV)', 'uploader_id': 'UCtelevision', 'upload_date': '20080522', }, 'params': { 'skip_download': True, }, }] _NATIVE_FORMATS = { 'low': {'preference': 1, 'width': 320, 'height': 180}, 'medium': {'preference': 2, 'width': 512, 'height': 288}, 'high': {'preference': 3, 'width': 854, 'height': 480}, } def _extract_info(self, webpage): info_json = self._search_regex(r'q\("\w+.init",({.+})\)</script>', webpage, 'info json') return json.loads(info_json) def _real_extract(self, url): m = re.match(self._VALID_URL, url, re.VERBOSE) if m.group('type') == 'embed': desktop_url = m.group('proto') + 'www' + m.group('urlmain') return self.url_result(desktop_url, 'TED') name = m.group('name') if m.group('type_talk'): return self._talk_info(url, name) elif m.group('type_watch'): return self._watch_info(url, name) else: return self._playlist_videos_info(url, name) def _playlist_videos_info(self, url, name): '''Returns the videos of the playlist''' webpage = self._download_webpage(url, name, 'Downloading playlist webpage') info = self._extract_info(webpage) playlist_info = info['playlist'] playlist_entries = [ self.url_result('http://www.ted.com/talks/' + talk['slug'], self.ie_key()) for talk in info['talks'] ] return self.playlist_result( playlist_entries, playlist_id=compat_str(playlist_info['id']), playlist_title=playlist_info['title']) def _talk_info(self, url, video_name): webpage = self._download_webpage(url, video_name) self.report_extraction(video_name) talk_info = self._extract_info(webpage)['talks'][0] if talk_info.get('external') is not None: self.to_screen('Found video from %s' % talk_info['external']['service']) return { '_type': 'url', 'url': talk_info['external']['uri'], } formats = [{ 'url': format_url, 'format_id': format_id, 'format': format_id, } for (format_id, format_url) in talk_info['nativeDownloads'].items() if format_url is not None] if formats: for f in formats: finfo = self._NATIVE_FORMATS.get(f['format_id']) if finfo: f.update(finfo) else: # Use rtmp downloads formats = [{ 'format_id': f['name'], 'url': talk_info['streamer'], 'play_path': f['file'], 'ext': 'flv', 'width': f['width'], 'height': f['height'], 'tbr': f['bitrate'], } for f in talk_info['resources']['rtmp']] self._sort_formats(formats) video_id = compat_str(talk_info['id']) # subtitles video_subtitles = self.extract_subtitles(video_id, talk_info) if self._downloader.params.get('listsubtitles', False): self._list_available_subtitles(video_id, talk_info) return thumbnail = talk_info['thumb'] if not thumbnail.startswith('http'): thumbnail = 'http://' + thumbnail return { 'id': video_id, 'title': talk_info['title'].strip(), 'uploader': talk_info['speaker'], 'thumbnail': thumbnail, 'description': self._og_search_description(webpage), 'subtitles': video_subtitles, 'formats': formats, 'duration': talk_info.get('duration'), } def _get_available_subtitles(self, video_id, talk_info): languages = [lang['languageCode'] for lang in talk_info.get('languages', [])] if languages: sub_lang_list = {} for l in languages: url = 'http://www.ted.com/talks/subtitles/id/%s/lang/%s/format/srt' % (video_id, l) sub_lang_list[l] = url return sub_lang_list else: self._downloader.report_warning('video doesn\'t have subtitles') return {} def _watch_info(self, url, name): webpage = self._download_webpage(url, name) config_json = self._html_search_regex( r'"pages\.jwplayer"\s*,\s*({.+?})\s*\)\s*</script>', webpage, 'config') config = json.loads(config_json)['config'] video_url = config['video']['url'] thumbnail = config.get('image', {}).get('url') title = self._html_search_regex( r"(?s)<h1(?:\s+class='[^']+')?>(.+?)</h1>", webpage, 'title') description = self._html_search_regex( [ r'(?s)<h4 class="[^"]+" id="h3--about-this-talk">.*?</h4>(.*?)</div>', r'(?s)<p><strong>About this talk:</strong>\s+(.*?)</p>', ], webpage, 'description', fatal=False) return { 'id': name, 'url': video_url, 'title': title, 'thumbnail': thumbnail, 'description': description, }
gpl-3.0
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 1275, 16858, 492, 4804, 8916, 18283, 199, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 495, 12, 199, 9, 421, 199, 533, 377, 1149, 4332, 8, 2610, 8916, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 2344, 2229, 88, 9, 267, 7558, 48, 28, 2625, 30, 2859, 14144, 9, 267, 7558, 48, 28, 466, 30, 1544, 92, 6427, 18168, 48, 28, 633, 973, 3072, 14, 471, 4537, 957, 15, 267, 334, 288, 7558, 48, 28, 466, 63, 10411, 30, 2802, 6717, 5169, 6307, 68, 19544, 9, 327, 2136, 1172, 282, 13210, 288, 1204, 288, 334, 2229, 48, 28, 466, 63, 21890, 30, 21890, 83, 430, 327, 2136, 1172, 282, 3486, 22811, 288, 1204, 288, 7558, 48, 28, 466, 63, 6821, 30, 6821, 2447, 26285, 15, 26285, 267, 776, 267, 334, 15, 4159, 7985, 6697, 22119, 327, 710, 1166, 1443, 1395, 314, 2637, 267, 1182, 2229, 48, 28, 354, 24693, 87, 13, 11896, 327, 11842, 13538, 314, 536, 436, 2066, 3680, 1360, 2, 267, 1275, 13278, 4, 267, 1449, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 471, 14, 957, 15, 21890, 83, 15, 24863, 63, 848, 846, 84, 63, 265, 63, 567, 63, 388, 9907, 1785, 4171, 14, 1360, 297, 267, 283, 1064, 21, 356, 283, 3003, 2635, 645, 12987, 11195, 2501, 301, 1876, 70, 2025, 67, 16, 67, 22, 1024, 32043, 709, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 7759, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 1918, 22907, 12444, 402, 406, 9907, 1785, 4171, 297, 288, 283, 1802, 356, 661, 5663, 73, 11560, 411, 2523, 24747, 25187, 846, 84, 7704, 282, 1013, 1697, 316, 283, 1169, 283, 2094, 626, 440, 1454, 2793, 3985, 84, 781, 20647, 4154, 5705, 283, 1169, 283, 388, 9907, 1785, 4171, 12, 1325, 626, 12995, 314, 900, 4154, 11137, 3617, 787, 283, 1169, 283, 5416, 5636, 7090, 393, 316, 2739, 8038, 288, 283, 13671, 356, 283, 29336, 25187, 846, 84, 297, 288, 283, 2063, 356, 1695, 1477, 12, 288, 283, 5553, 356, 413, 12127, 12, 267, 789, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 471, 14, 957, 15, 6821, 15, 471, 13, 3615, 390, 938, 15, 471, 13, 3776, 71, 15, 86, 2453, 279, 13, 338, 75, 7351, 13, 1589, 13, 1235, 6898, 89, 13, 460, 13, 5652, 13, 1618, 13, 24365, 297, 267, 283, 1064, 21, 356, 283, 11085, 70, 20, 4675, 25, 67, 31353, 1257, 68, 845, 66, 23, 14732, 25015, 20, 67, 1555, 14966, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 86, 2453, 279, 13, 338, 75, 7351, 13, 1589, 13, 1235, 6898, 89, 13, 460, 13, 5652, 13, 1618, 13, 24365, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 54, 2453, 279, 428, 3258, 7351, 26, 710, 506, 6898, 89, 436, 7074, 402, 18036, 297, 288, 283, 8311, 356, 283, 264, 23497, 2859, 14144, 6977, 4537, 8476, 297, 288, 283, 1802, 356, 283, 2767, 22430, 12, 4661, 24024, 12, 436, 12137, 12, 18036, 787, 325, 2626, 1540, 465, 314, 221, 1141, 17684, 1145, 367, 8137, 687, 4877, 9451, 2393, 370, 7585, 370, 465, 5480, 316, 25796, 915, 8348, 889, 874, 14, 812, 2453, 279, 428, 3258, 7351, 25616, 17049, 2771, 29804, 367, 314, 5563, 12, 10943, 316, 3865, 2399, 315, 426, 640, 506, 6898, 89, 436, 2399, 20772, 316, 7074, 3130, 267, 789, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 471, 14, 957, 15, 21890, 83, 15, 71, 371, 991, 63, 14513, 509, 795, 63, 460, 63, 1657, 63, 75, 29051, 63, 1235, 63, 15534, 438, 323, 63, 1235, 63, 25715, 474, 1785, 63, 1235, 63, 12695, 63, 7010, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1167, 2819, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 3655, 19099, 438, 323, 14, 6423, 512, 300, 474, 1785, 14, 6423, 2195, 5526, 3130, 288, 283, 13671, 356, 283, 39, 371, 991, 598, 692, 509, 795, 436, 7173, 1804, 29051, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 21, 9892, 65, 379, 20, 68, 16, 70, 975, 15385, 66, 32170, 6708, 11197, 70, 2819, 66, 2942, 297, 288, 283, 5553, 356, 413, 3933, 12, 267, 1660, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 471, 14, 957, 15, 2802, 6717, 15, 11345, 63, 1530, 63, 1589, 63, 20875, 1192, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 709, 297, 288, 283, 1213, 356, 283, 55, 526, 787, 314, 11176, 1192, 7044, 267, 1660, 267, 283, 10411, 63, 827, 835, 356, 1227, 12, 272, 1660, 469, 267, 327, 3509, 282, 22378, 3991, 267, 283, 633, 356, 283, 2859, 921, 1544, 14, 471, 14, 957, 15, 21890, 83, 15, 68, 810, 3528, 305, 63, 350, 19470, 63, 462, 293, 1086, 63, 1589, 63, 30519, 63, 460, 63, 14287, 2127, 297, 267, 283, 525, 63, 1873, 356, 788, 57, 7715, 995, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 2513, 26074, 24, 40, 1713, 36, 74, 9493, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 36, 810, 3528, 305, 4431, 19470, 26, 2235, 293, 1086, 314, 1910, 73, 2077, 436, 18414, 2127, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 614, 350, 17, 69, 7155, 67, 1887, 645, 12021, 2894, 845, 2534, 67, 16, 69, 25, 10882, 2756, 297, 288, 283, 13671, 356, 283, 1358, 14111, 402, 8256, 73, 509, 22042, 23884, 2317, 334, 7996, 54, 3196, 288, 283, 13671, 63, 344, 356, 283, 13371, 15253, 2317, 297, 288, 283, 5064, 63, 602, 356, 283, 1840, 13027, 1081, 297, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 1660, 272, 14877, 339, 485, 46, 14277, 63, 14019, 275, 469, 267, 283, 674, 356, 791, 14994, 356, 413, 12, 283, 2063 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2022, 199, 646, 295, 199, 199, 504, 1275, 16858, 492, 4804, 8916, 18283, 199, 199, 504, 2508, 5819, 492, 334, 272, 8434, 63, 495, 12, 199, 9, 421, 199, 533, 377, 1149, 4332, 8, 2610, 8916, 18283, 304, 272, 485, 5600, 63, 2632, 275, 519, 2344, 2229, 88, 9, 267, 7558, 48, 28, 2625, 30, 2859, 14144, 9, 267, 7558, 48, 28, 466, 30, 1544, 92, 6427, 18168, 48, 28, 633, 973, 3072, 14, 471, 4537, 957, 15, 267, 334, 288, 7558, 48, 28, 466, 63, 10411, 30, 2802, 6717, 5169, 6307, 68, 19544, 9, 327, 2136, 1172, 282, 13210, 288, 1204, 288, 334, 2229, 48, 28, 466, 63, 21890, 30, 21890, 83, 430, 327, 2136, 1172, 282, 3486, 22811, 288, 1204, 288, 7558, 48, 28, 466, 63, 6821, 30, 6821, 2447, 26285, 15, 26285, 267, 776, 267, 334, 15, 4159, 7985, 6697, 22119, 327, 710, 1166, 1443, 1395, 314, 2637, 267, 1182, 2229, 48, 28, 354, 24693, 87, 13, 11896, 327, 11842, 13538, 314, 536, 436, 2066, 3680, 1360, 2, 267, 1275, 13278, 4, 267, 1449, 272, 485, 7569, 275, 8910, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 471, 14, 957, 15, 21890, 83, 15, 24863, 63, 848, 846, 84, 63, 265, 63, 567, 63, 388, 9907, 1785, 4171, 14, 1360, 297, 267, 283, 1064, 21, 356, 283, 3003, 2635, 645, 12987, 11195, 2501, 301, 1876, 70, 2025, 67, 16, 67, 22, 1024, 32043, 709, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 7759, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 1918, 22907, 12444, 402, 406, 9907, 1785, 4171, 297, 288, 283, 1802, 356, 661, 5663, 73, 11560, 411, 2523, 24747, 25187, 846, 84, 7704, 282, 1013, 1697, 316, 283, 1169, 283, 2094, 626, 440, 1454, 2793, 3985, 84, 781, 20647, 4154, 5705, 283, 1169, 283, 388, 9907, 1785, 4171, 12, 1325, 626, 12995, 314, 900, 4154, 11137, 3617, 787, 283, 1169, 283, 5416, 5636, 7090, 393, 316, 2739, 8038, 288, 283, 13671, 356, 283, 29336, 25187, 846, 84, 297, 288, 283, 2063, 356, 1695, 1477, 12, 288, 283, 5553, 356, 413, 12127, 12, 267, 789, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 471, 14, 957, 15, 6821, 15, 471, 13, 3615, 390, 938, 15, 471, 13, 3776, 71, 15, 86, 2453, 279, 13, 338, 75, 7351, 13, 1589, 13, 1235, 6898, 89, 13, 460, 13, 5652, 13, 1618, 13, 24365, 297, 267, 283, 1064, 21, 356, 283, 11085, 70, 20, 4675, 25, 67, 31353, 1257, 68, 845, 66, 23, 14732, 25015, 20, 67, 1555, 14966, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 86, 2453, 279, 13, 338, 75, 7351, 13, 1589, 13, 1235, 6898, 89, 13, 460, 13, 5652, 13, 1618, 13, 24365, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 54, 2453, 279, 428, 3258, 7351, 26, 710, 506, 6898, 89, 436, 7074, 402, 18036, 297, 288, 283, 8311, 356, 283, 264, 23497, 2859, 14144, 6977, 4537, 8476, 297, 288, 283, 1802, 356, 283, 2767, 22430, 12, 4661, 24024, 12, 436, 12137, 12, 18036, 787, 325, 2626, 1540, 465, 314, 221, 1141, 17684, 1145, 367, 8137, 687, 4877, 9451, 2393, 370, 7585, 370, 465, 5480, 316, 25796, 915, 8348, 889, 874, 14, 812, 2453, 279, 428, 3258, 7351, 25616, 17049, 2771, 29804, 367, 314, 5563, 12, 10943, 316, 3865, 2399, 315, 426, 640, 506, 6898, 89, 436, 2399, 20772, 316, 7074, 3130, 267, 789, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 471, 14, 957, 15, 21890, 83, 15, 71, 371, 991, 63, 14513, 509, 795, 63, 460, 63, 1657, 63, 75, 29051, 63, 1235, 63, 15534, 438, 323, 63, 1235, 63, 25715, 474, 1785, 63, 1235, 63, 12695, 63, 7010, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 1167, 2819, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 3655, 19099, 438, 323, 14, 6423, 512, 300, 474, 1785, 14, 6423, 2195, 5526, 3130, 288, 283, 13671, 356, 283, 39, 371, 991, 598, 692, 509, 795, 436, 7173, 1804, 29051, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 21, 9892, 65, 379, 20, 68, 16, 70, 975, 15385, 66, 32170, 6708, 11197, 70, 2819, 66, 2942, 297, 288, 283, 5553, 356, 413, 3933, 12, 267, 1660, 272, 1660, 469, 267, 283, 633, 356, 283, 1014, 921, 1544, 14, 471, 14, 957, 15, 2802, 6717, 15, 11345, 63, 1530, 63, 1589, 63, 20875, 1192, 297, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 283, 709, 297, 288, 283, 1213, 356, 283, 55, 526, 787, 314, 11176, 1192, 7044, 267, 1660, 267, 283, 10411, 63, 827, 835, 356, 1227, 12, 272, 1660, 469, 267, 327, 3509, 282, 22378, 3991, 267, 283, 633, 356, 283, 2859, 921, 1544, 14, 471, 14, 957, 15, 21890, 83, 15, 68, 810, 3528, 305, 63, 350, 19470, 63, 462, 293, 1086, 63, 1589, 63, 30519, 63, 460, 63, 14287, 2127, 297, 267, 283, 525, 63, 1873, 356, 788, 57, 7715, 995, 267, 283, 815, 63, 807, 356, 469, 288, 283, 344, 356, 2513, 26074, 24, 40, 1713, 36, 74, 9493, 297, 288, 283, 832, 356, 283, 311, 20, 297, 288, 283, 1213, 356, 283, 36, 810, 3528, 305, 4431, 19470, 26, 2235, 293, 1086, 314, 1910, 73, 2077, 436, 18414, 2127, 297, 288, 283, 1802, 356, 283, 1064, 21, 26, 614, 350, 17, 69, 7155, 67, 1887, 645, 12021, 2894, 845, 2534, 67, 16, 69, 25, 10882, 2756, 297, 288, 283, 13671, 356, 283, 1358, 14111, 402, 8256, 73, 509, 22042, 23884, 2317, 334, 7996, 54, 3196, 288, 283, 13671, 63, 344, 356, 283, 13371, 15253, 2317, 297, 288, 283, 5064, 63, 602, 356, 283, 1840, 13027, 1081, 297, 267, 1660, 267, 283, 1162, 356, 469, 288, 283, 2759, 63, 4249, 356, 715, 12, 267, 1660, 272, 14877, 339, 485, 46, 14277, 63, 14019, 275, 469, 267, 283, 674, 356, 791, 14994, 356, 413, 12, 283, 2063, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mjjohnson/django-u2f
testproj/testproj/tests.py
1
8549
import json from django.test import TestCase, Client from django.core.urlresolvers import reverse from django.contrib.auth import get_user_model, SESSION_KEY User = get_user_model() class U2FTest(TestCase): def setUp(self): self.client = Client() self.user = User.objects.create_superuser( username='test', email='test@example.com', password='asdfasdf', ) self.login_url = reverse('django_u2f.views.login') def enable_u2f(self): self.user.u2f_keys.create( public_key='BCux01toHSq_5YHfsw3EAqfGGKirLoHnDqAuW5RedtP8dGbJTJ55-QEJ_alPDM06kHw7UOUOCawdHinHVrNbnKw', key_handle='OJiPPVZ6oU-PszwbAAJhbanYvhawFrQi6n3AkcT1k7SeZDo3Ch6BU8i21kp2tcsyQ2BE7nc34RdljU4iS997vA', app_id='http://localhost.com:8000', ) def set_challenge(self): session = self.client.session session['u2f_authentication_challenges'] = [ { "challenge": "jUvsJfqf2FMXkUTTFQ57gqNhVn0K2eJ7ElxnF3EK_M8", "version": "U2F_V2", "keyHandle": "OJiPPVZ6oU-PszwbAAJhbanYvhawFrQi6n3AkcT1k7SeZDo3Ch6BU8i21kp2tcsyQ2BE7nc34RdljU4iS997vA", "appId": "http://localhost.com:8000", } ] session.save() return { "keyHandle": "OJiPPVZ6oU-PszwbAAJhbanYvhawFrQi6n3AkcT1k7SeZDo3Ch6BU8i21kp2tcsyQ2BE7nc34RdljU4iS997vA", "clientData": "eyJ0eXAiOiJuYXZpZ2F0b3IuaWQuZ2V0QXNzZXJ0aW9uIiwiY2hhbGxlbmdlIjoialV2c0pmcWYyRk1Ya1VUVEZRNTdncU5oVm4wSzJlSjdFbHhuRjNFS19NOCIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3QuY29tOjgwMDAiLCJjaWRfcHVia2V5IjoiIn0", "signatureData": "AQAAADcwRQIhALnYwD3DMN3CAhKzhH7hwoJfSSiNMrOHhZq2nQA0WunTAiB2hKEpPn4u0znti-mjC4Xq6Ekv1tfopsapTsJ8EOxmYg", } def set_add_key(self): session = self.client.session session['u2f_registration_challenge'] = { 'challenge': "1C57ZaTxUkXyMJqcfdNc_7Lp34aPgYDNt_nL2wwsLPQ", 'version': "U2F_V2", 'appId': "http://localhost.com:8000", } session.save() return { "registrationData": "BQR-zQiLHRPYDlXEDG_yZ_Y53mLP20BXMUpm-zqH1ntWHr3S1EZtJbFKNkWRwo2BQA-SBRZH4SvA2mZyCK2wP4AZQMF2iVGLM8guW_L2o7tfu9THxhMtOFRC6WICT_Kn2Vn3kxkMLjt4fBYO0ZeatzA5qaBk_O6PIypq0R9oYmHiQYEwggIcMIIBBqADAgECAgQk26tAMAsGCSqGSIb3DQEBCzAuMSwwKgYDVQQDEyNZdWJpY28gVTJGIFJvb3QgQ0EgU2VyaWFsIDQ1NzIwMDYzMTAgFw0xNDA4MDEwMDAwMDBaGA8yMDUwMDkwNDAwMDAwMFowKzEpMCcGA1UEAwwgWXViaWNvIFUyRiBFRSBTZXJpYWwgMTM1MDMyNzc4ODgwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQCsJS-NH1HeUHEd46-xcpN7SpHn6oeb-w5r-veDCBwy1vUvWnJanjjv4dR_rV5G436ysKUAXUcsVe5fAnkORo2oxIwEDAOBgorBgEEAYLECgEBBAAwCwYJKoZIhvcNAQELA4IBAQCjY64OmDrzC7rxLIst81pZvxy7ShsPy2jEhFWEkPaHNFhluNsCacNG5VOITCxWB68OonuQrIzx70MfcqwYnbIcgkkUvxeIpVEaM9B7TI40ZHzp9h4VFqmps26QCkAgYfaapG4SxTK5k_lCPvqqTPmjtlS03d7ykkpUj9WZlVEN1Pf02aTVIZOHPHHJuH6GhT6eLadejwxtKDBTdNTv3V4UlvjDOQYQe9aL1jUNqtLDeBHso8pDvJMLc0CX3vadaI2UVQxM-xip4kuGouXYj0mYmaCbzluBDFNsrzkNyL3elg3zMMrKvAUhoYMjlX_-vKWcqQsgsQ0JtSMcWMJ-umeDMEUCIDmr7y3CyKDwDThdf8MUyp3R_meuSz6pYPavyjt5vDlHAiEApjqut4HuWZzTz9WmjDTAa8_Dn8DmrXfMCbFFsYXU_nU", "challenge": "1C57ZaTxUkXyMJqcfdNc_7Lp34aPgYDNt_nL2wwsLPQ", "version": "U2F_V2", "appId": "http://localhost.com:8000", "clientData": "eyJ0eXAiOiJuYXZpZ2F0b3IuaWQuZmluaXNoRW5yb2xsbWVudCIsImNoYWxsZW5nZSI6IjFDNTdaYVR4VWtYeU1KcWNmZE5jXzdMcDM0YVBnWUROdF9uTDJ3d3NMUFEiLCJvcmlnaW4iOiJodHRwOi8vbG9jYWxob3N0LmNvbTo4MDAwIiwiY2lkX3B1YmtleSI6IiJ9", } class TestU2F(U2FTest): def login(self): return self.client.post(self.login_url, { 'username': 'test', 'password': 'asdfasdf', 'next': '/next/' }) def test_normal_login(self): r = self.login() self.assertTrue(r['location'].endswith('/next/')) self.assertEqual(self.client.session[SESSION_KEY], self.user.id) def test_u2f_login(self): self.enable_u2f() r = self.login() self.assertNotIn(SESSION_KEY, self.client.session) self.assertIn(reverse('django_u2f.views.verify_key'), r['location']) device_response = self.set_challenge() r = self.client.post(r['location'], { 'response': json.dumps(device_response), }) self.assertEqual(self.client.session[SESSION_KEY], self.user.id) def test_failed_u2f_login(self): self.enable_u2f() r = self.login() device_response = self.set_challenge() device_response['signatureData'] = 'a' + device_response['signatureData'][1:] r = self.client.post(r['location'], { 'response': json.dumps(device_response), }) self.assertNotIn(SESSION_KEY, self.client.session) self.assertIn('Challenge signature verification failed!', r.content) def test_verify_when_not_logged_in(self): r = self.client.get(reverse('django_u2f.views.verify_key')) self.assertTrue(r['location'].endswith(self.login_url)) def test_add_key(self): self.login() url = reverse('django_u2f.views.add_key') r = self.client.get(url) self.assertIn('"challenge"', r.content) device_response = self.set_add_key() r = self.client.post(url, { 'response': json.dumps(device_response), }) added_key_obj = self.user.u2f_keys.get() self.assertEqual(added_key_obj.public_key, 'BH7NCIsdE9gOVcQMb_Jn9jneYs_bQFcxSmb7OofWe1YevdLURm0lsUo2RZHCjYFAD5IFFkfhK8DaZnIIrbA_gBk') self.assertEqual(added_key_obj.key_handle, 'wXaJUYszyC5b8vaju1-71MfGEy04VELpYgJP8qfZWfeTGQwuO3h8Fg7Rl5q3MDmpoGT87o8jKmrRH2hiYeJBgQ') self.assertEqual(added_key_obj.app_id, 'http://localhost.com:8000') def test_key_delete(self): other_user = User.objects.create_superuser( username='abc', email='abc@example.com', password='asdfasdf', ) other_user.u2f_keys.create() self.enable_u2f() self.client.login(username='test', password='asdfasdf') r = self.client.post(reverse('django_u2f.views.keys'), { 'key_id': self.user.u2f_keys.get().pk, 'delete': '1', }) self.assertFalse(self.user.u2f_keys.exists()) # cant delete someone else's keys r = self.client.post(reverse('django_u2f.views.keys'), { 'key_id': other_user.u2f_keys.get().pk, 'delete': '1', }) self.assertTrue(other_user.u2f_keys.exists()) self.assertEqual(r.status_code, 404) class TestAdminLogin(U2FTest): def setUp(self): super(TestAdminLogin, self).setUp() self.admin_url = reverse('admin:index') # discover admin login url, different on django 1.6 and django 1.7 r = self.client.get(self.admin_url) if r.status_code == 302: # django 1.7 self.login_url = r['location'] else: # django 1.6 self.login_url = self.admin_url def test_admin_template_rendered(self): r = self.client.get(self.login_url) self.assertEqual(r.templates[0].name, 'admin/login.html') def test_login_with_u2f(self): self.enable_u2f() r = self.client.post(self.login_url, { 'username': 'test', 'password': 'asdfasdf', }) self.assertNotIn(SESSION_KEY, self.client.session) self.assertIn(reverse('django_u2f.views.verify_key'), r['location']) verify_key_response = self.client.get(r['location']) self.assertIn('Django administration', verify_key_response.content) device_response = self.set_challenge() r = self.client.post(r['location'], { 'response': json.dumps(device_response), }) self.assertEqual(self.client.session[SESSION_KEY], self.user.id) self.assertTrue(r['location'].endswith(self.admin_url)) def test_login_without_u2f(self): r = self.client.get(self.admin_url) if r.status_code == 200: # django 1.6 self.assertEqual(r.context['next'], self.admin_url) # else: # django 1.7 r = self.client.post(self.login_url, { 'username': 'test', 'password': 'asdfasdf', 'this_is_the_login_form': 1, 'next': self.admin_url, }) self.assertTrue(r['location'].endswith(self.admin_url)) self.assertEqual(self.client.session[SESSION_KEY], self.user.id)
bsd-2-clause
[ 646, 2022, 199, 199, 504, 1639, 14, 396, 492, 7640, 12, 6810, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 12, 428, 9577, 63, 3078, 199, 199, 1899, 275, 664, 63, 751, 63, 1238, 342, 421, 199, 533, 738, 18, 38, 774, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 1258, 275, 6810, 342, 267, 291, 14, 751, 275, 2876, 14, 1462, 14, 981, 63, 11434, 8, 288, 3434, 534, 396, 297, 288, 3031, 534, 396, 32, 2694, 14, 957, 297, 288, 2505, 534, 18196, 18196, 297, 267, 776, 267, 291, 14, 2886, 63, 633, 275, 3837, 360, 1176, 63, 85, 18, 70, 14, 4196, 14, 2886, 358, 339, 347, 4756, 63, 85, 18, 70, 8, 277, 304, 267, 291, 14, 751, 14, 85, 18, 70, 63, 1612, 14, 981, 8, 288, 4575, 63, 498, 534, 6265, 2521, 614, 475, 15467, 81, 63, 21, 57, 40, 2319, 87, 19, 11765, 31814, 2916, 43, 723, 2041, 40, 78, 36, 81, 15900, 55, 21, 10858, 84, 48, 24, 28929, 66, 42, 52, 42, 1229, 13, 31668, 42, 63, 279, 11435, 45, 1690, 75, 24482, 23, 53, 22050, 47, 3630, 2989, 40, 262, 16566, 82, 46, 10472, 26643, 297, 288, 790, 63, 2479, 534, 47, 16911, 7701, 54, 58, 22, 79, 53, 13, 48, 11803, 6603, 2276, 42, 72, 13206, 57, 86, 2411, 87, 13848, 19910, 22, 78, 19, 33, 75, 67, 52, 17, 75, 23, 1513, 58, 2585, 19, 1049, 22, 2910, 24, 73, 2025, 25017, 18, 84, 1259, 89, 49, 18, 6773, 23, 7966, 1082, 50, 5030, 74, 53, 20, 73, 51, 13218, 86, 33, 297, 288, 1145, 63, 344, 534, 1014, 921, 5967, 14, 957, 26, 15214, 297, 267, 776, 339, 347, 663, 63, 13911, 8, 277, 304, 267, 2351, 275, 291, 14, 1258, 14, 1730, 267, 2351, 459, 85, 18, 70, 63, 11725, 63, 335, 30599, 418, 275, 359, 288, 469, 355, 298, 13911, 582, 298, 74, 53, 3122, 42, 11878, 70, 18, 38, 17401, 75, 934, 6145, 49, 1641, 71, 81, 46, 72, 54, 78, 16, 43, 18, 69, 42, 23, 10420, 5032, 38, 19, 11959, 63, 45, 24, 401, 355, 298, 1023, 582, 298, 53, 18, 38, 63, 54, 18, 401, 355, 298, 498, 5940, 582, 298, 47, 16911, 7701, 54, 58, 22, 79, 53, 13, 48, 11803, 6603, 2276, 42, 72, 13206, 57, 86, 2411, 87, 13848, 19910, 22, 78, 19, 33, 75, 67, 52, 17, 75, 23, 1513, 58, 2585, 19, 1049, 22, 2910, 24, 73, 2025, 25017, 18, 84, 1259, 89, 49, 18, 6773, 23, 7966, 1082, 50, 5030, 74, 53, 20, 73, 51, 13218, 86, 33, 401, 355, 298, 571, 1304, 582, 298, 1014, 921, 5967, 14, 957, 26, 15214, 401, 288, 789, 267, 1622, 267, 2351, 14, 2117, 342, 267, 372, 469, 288, 298, 498, 5940, 582, 298, 47, 16911, 7701, 54, 58, 22, 79, 53, 13, 48, 11803, 6603, 2276, 42, 72, 13206, 57, 86, 2411, 87, 13848, 19910, 22, 78, 19, 33, 75, 67, 52, 17, 75, 23, 1513, 58, 2585, 19, 1049, 22, 2910, 24, 73, 2025, 25017, 18, 84, 1259, 89, 49, 18, 6773, 23, 7966, 1082, 50, 5030, 74, 53, 20, 73, 51, 13218, 86, 33, 401, 288, 298, 1258, 1451, 582, 298, 14655, 42, 16, 69, 56, 28960, 47, 73, 24783, 16936, 58, 80, 58, 18, 38, 16, 66, 19, 41, 1458, 55, 2371, 58, 18, 54, 16, 49, 56, 23406, 15473, 42, 16, 19098, 25, 85, 31105, 14249, 57, 18, 12156, 66, 39, 88, 6374, 1064, 76, 41, 743, 2380, 54, 18, 67, 16, 80, 5466, 55, 30694, 50, 75, 17, 28786, 17, 54, 53, 2524, 58, 50, 12460, 4272, 67, 53, 21, 79, 17402, 20, 87, 51, 90, 31182, 51, 17694, 38, 66, 40, 10616, 50, 74, 46, 7079, 1167, 2826, 35, 1831, 16221, 25, 11552, 55, 68, 3317, 73, 41, 22, 16221, 72, 16, 68, 6294, 22, 27480, 25, 9264, 18, 46, 16168, 39, 72, 6737, 19, 2371, 57, 1398, 84, 47, 74, 8392, 5127, 28960, 7027, 42, 3387, 6524, 3003, 40, 2201, 65, 18, 54, 21, 41, 743, 73, 607, 16, 401, 288, 298, 5233, 1451, 582, 298, 20152, 2276, 1554, 15346, 50, 49, 41, 72, 748, 78, 57, 87, 36, 19, 36, 16237, 19, 3263, 72, 43, 3951, 40, 23, 72, 2027, 42, 70, 2300, 73, 21942, 82, 47, 23626, 58, 81, 18, 78, 14323, 16, 55, 324, 6166, 17587, 18, 72, 2430, 80, 48, 78, 20, 85, 16, 31591, 280, 13, 77, 74, 35, 20, 56, 81, 22, 37, 11475, 17, 3249, 1483, 439, 23433, 42, 24, 15471, 10198, 57, 71, 401, 267, 789, 339, 347, 663, 63, 525, 63, 498, 8, 277, 304, 267, 2351, 275, 291, 14, 1258, 14, 1730, 267, 2351, 459, 85, 18, 70, 63, 8054, 63, 13911, 418, 275, 469, 288, 283, 13911, 356, 298, 17, 35, 1641, 13163, 8052, 53, 75, 56, 89, 30495, 81, 27901, 46, 67, 63, 23, 44, 80, 1082, 65, 31489, 57, 36, 5959, 63, 78, 44, 18, 978, 83, 9257, 49, 401, 288, 283, 1023, 356, 298, 53, 18, 38, 63, 54, 18, 401, 288, 283, 571, 1304, 356, 298, 1014, 921, 5967, 14, 957, 26, 15214, 401, 267, 789, 398, 2351, 14, 2117, 342, 267, 372, 469, 288, 298, 8054, 1451, 582, 298, 34, 26779, 13, 90, 19910, 44, 14784, 4521, 22904, 56, 1149, 39, 63, 89, 58, 63, 57, 2481, 77, 9257, 1165, 7575, 45, 1721, 77, 13, 90, 81, 40, 17, 343, 9792, 82, 19, 51, 17, 37, 58, 84, 42, 66, 21490, 46, 75, 6524, 2027, 18, 34, 14323, 13, 51, 7184, 58, 40, 20, 51, 86, 33, 18, 77, 58, 89, 2504, 18, 87, 48, 20, 17613, 49, 13463, 18, 73, 54, 2226, 45, 24, 6051, 55, 63, 44, 18, 79, 23, 3249, 85, 25, 2080, 29426, 45, 84, 3359, 8205, 22, 55, 6196, 63, 43, 78, 18, 54, 78, 19, 75, 28351, 1698, 26002, 20, 70, 8285, 47, 16, 58, 69, 292, 6353, 21, 7096, 34, 75, 63, 47, 22, 2252, 2279, 81, 16, 50, 25, 79, 57, 77 ]
[ 2022, 199, 199, 504, 1639, 14, 396, 492, 7640, 12, 6810, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 2828, 14, 1178, 492, 664, 63, 751, 63, 1238, 12, 428, 9577, 63, 3078, 199, 199, 1899, 275, 664, 63, 751, 63, 1238, 342, 421, 199, 533, 738, 18, 38, 774, 8, 1746, 304, 272, 347, 3613, 8, 277, 304, 267, 291, 14, 1258, 275, 6810, 342, 267, 291, 14, 751, 275, 2876, 14, 1462, 14, 981, 63, 11434, 8, 288, 3434, 534, 396, 297, 288, 3031, 534, 396, 32, 2694, 14, 957, 297, 288, 2505, 534, 18196, 18196, 297, 267, 776, 267, 291, 14, 2886, 63, 633, 275, 3837, 360, 1176, 63, 85, 18, 70, 14, 4196, 14, 2886, 358, 339, 347, 4756, 63, 85, 18, 70, 8, 277, 304, 267, 291, 14, 751, 14, 85, 18, 70, 63, 1612, 14, 981, 8, 288, 4575, 63, 498, 534, 6265, 2521, 614, 475, 15467, 81, 63, 21, 57, 40, 2319, 87, 19, 11765, 31814, 2916, 43, 723, 2041, 40, 78, 36, 81, 15900, 55, 21, 10858, 84, 48, 24, 28929, 66, 42, 52, 42, 1229, 13, 31668, 42, 63, 279, 11435, 45, 1690, 75, 24482, 23, 53, 22050, 47, 3630, 2989, 40, 262, 16566, 82, 46, 10472, 26643, 297, 288, 790, 63, 2479, 534, 47, 16911, 7701, 54, 58, 22, 79, 53, 13, 48, 11803, 6603, 2276, 42, 72, 13206, 57, 86, 2411, 87, 13848, 19910, 22, 78, 19, 33, 75, 67, 52, 17, 75, 23, 1513, 58, 2585, 19, 1049, 22, 2910, 24, 73, 2025, 25017, 18, 84, 1259, 89, 49, 18, 6773, 23, 7966, 1082, 50, 5030, 74, 53, 20, 73, 51, 13218, 86, 33, 297, 288, 1145, 63, 344, 534, 1014, 921, 5967, 14, 957, 26, 15214, 297, 267, 776, 339, 347, 663, 63, 13911, 8, 277, 304, 267, 2351, 275, 291, 14, 1258, 14, 1730, 267, 2351, 459, 85, 18, 70, 63, 11725, 63, 335, 30599, 418, 275, 359, 288, 469, 355, 298, 13911, 582, 298, 74, 53, 3122, 42, 11878, 70, 18, 38, 17401, 75, 934, 6145, 49, 1641, 71, 81, 46, 72, 54, 78, 16, 43, 18, 69, 42, 23, 10420, 5032, 38, 19, 11959, 63, 45, 24, 401, 355, 298, 1023, 582, 298, 53, 18, 38, 63, 54, 18, 401, 355, 298, 498, 5940, 582, 298, 47, 16911, 7701, 54, 58, 22, 79, 53, 13, 48, 11803, 6603, 2276, 42, 72, 13206, 57, 86, 2411, 87, 13848, 19910, 22, 78, 19, 33, 75, 67, 52, 17, 75, 23, 1513, 58, 2585, 19, 1049, 22, 2910, 24, 73, 2025, 25017, 18, 84, 1259, 89, 49, 18, 6773, 23, 7966, 1082, 50, 5030, 74, 53, 20, 73, 51, 13218, 86, 33, 401, 355, 298, 571, 1304, 582, 298, 1014, 921, 5967, 14, 957, 26, 15214, 401, 288, 789, 267, 1622, 267, 2351, 14, 2117, 342, 267, 372, 469, 288, 298, 498, 5940, 582, 298, 47, 16911, 7701, 54, 58, 22, 79, 53, 13, 48, 11803, 6603, 2276, 42, 72, 13206, 57, 86, 2411, 87, 13848, 19910, 22, 78, 19, 33, 75, 67, 52, 17, 75, 23, 1513, 58, 2585, 19, 1049, 22, 2910, 24, 73, 2025, 25017, 18, 84, 1259, 89, 49, 18, 6773, 23, 7966, 1082, 50, 5030, 74, 53, 20, 73, 51, 13218, 86, 33, 401, 288, 298, 1258, 1451, 582, 298, 14655, 42, 16, 69, 56, 28960, 47, 73, 24783, 16936, 58, 80, 58, 18, 38, 16, 66, 19, 41, 1458, 55, 2371, 58, 18, 54, 16, 49, 56, 23406, 15473, 42, 16, 19098, 25, 85, 31105, 14249, 57, 18, 12156, 66, 39, 88, 6374, 1064, 76, 41, 743, 2380, 54, 18, 67, 16, 80, 5466, 55, 30694, 50, 75, 17, 28786, 17, 54, 53, 2524, 58, 50, 12460, 4272, 67, 53, 21, 79, 17402, 20, 87, 51, 90, 31182, 51, 17694, 38, 66, 40, 10616, 50, 74, 46, 7079, 1167, 2826, 35, 1831, 16221, 25, 11552, 55, 68, 3317, 73, 41, 22, 16221, 72, 16, 68, 6294, 22, 27480, 25, 9264, 18, 46, 16168, 39, 72, 6737, 19, 2371, 57, 1398, 84, 47, 74, 8392, 5127, 28960, 7027, 42, 3387, 6524, 3003, 40, 2201, 65, 18, 54, 21, 41, 743, 73, 607, 16, 401, 288, 298, 5233, 1451, 582, 298, 20152, 2276, 1554, 15346, 50, 49, 41, 72, 748, 78, 57, 87, 36, 19, 36, 16237, 19, 3263, 72, 43, 3951, 40, 23, 72, 2027, 42, 70, 2300, 73, 21942, 82, 47, 23626, 58, 81, 18, 78, 14323, 16, 55, 324, 6166, 17587, 18, 72, 2430, 80, 48, 78, 20, 85, 16, 31591, 280, 13, 77, 74, 35, 20, 56, 81, 22, 37, 11475, 17, 3249, 1483, 439, 23433, 42, 24, 15471, 10198, 57, 71, 401, 267, 789, 339, 347, 663, 63, 525, 63, 498, 8, 277, 304, 267, 2351, 275, 291, 14, 1258, 14, 1730, 267, 2351, 459, 85, 18, 70, 63, 8054, 63, 13911, 418, 275, 469, 288, 283, 13911, 356, 298, 17, 35, 1641, 13163, 8052, 53, 75, 56, 89, 30495, 81, 27901, 46, 67, 63, 23, 44, 80, 1082, 65, 31489, 57, 36, 5959, 63, 78, 44, 18, 978, 83, 9257, 49, 401, 288, 283, 1023, 356, 298, 53, 18, 38, 63, 54, 18, 401, 288, 283, 571, 1304, 356, 298, 1014, 921, 5967, 14, 957, 26, 15214, 401, 267, 789, 398, 2351, 14, 2117, 342, 267, 372, 469, 288, 298, 8054, 1451, 582, 298, 34, 26779, 13, 90, 19910, 44, 14784, 4521, 22904, 56, 1149, 39, 63, 89, 58, 63, 57, 2481, 77, 9257, 1165, 7575, 45, 1721, 77, 13, 90, 81, 40, 17, 343, 9792, 82, 19, 51, 17, 37, 58, 84, 42, 66, 21490, 46, 75, 6524, 2027, 18, 34, 14323, 13, 51, 7184, 58, 40, 20, 51, 86, 33, 18, 77, 58, 89, 2504, 18, 87, 48, 20, 17613, 49, 13463, 18, 73, 54, 2226, 45, 24, 6051, 55, 63, 44, 18, 79, 23, 3249, 85, 25, 2080, 29426, 45, 84, 3359, 8205, 22, 55, 6196, 63, 43, 78, 18, 54, 78, 19, 75, 28351, 1698, 26002, 20, 70, 8285, 47, 16, 58, 69, 292, 6353, 21, 7096, 34, 75, 63, 47, 22, 2252, 2279, 81, 16, 50, 25, 79, 57, 77, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
grimoirelab/GrimoireELK
grimoire_elk/enriched/meetup.py
1
13379
# -*- coding: utf-8 -*- # # Copyright (C) 2015-2019 Bitergia # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # Authors: # Alvaro del Castillo San Felix <acs@bitergia.com> # import copy import logging from grimoirelab_toolkit.datetime import unixtime_to_datetime from .enrich import Enrich, metadata from ..elastic_mapping import Mapping as BaseMapping MAX_SIZE_BULK_ENRICHED_ITEMS = 200 logger = logging.getLogger(__name__) class Mapping(BaseMapping): @staticmethod def get_elastic_mappings(es_major): """Get Elasticsearch mapping. :param es_major: major version of Elasticsearch, as string :returns: dictionary with a key, 'items', with the mapping """ mapping = """ { "properties": { "description_analyzed": { "type": "text", "index": true }, "comment": { "type": "text", "index": true }, "venue_geolocation": { "type": "geo_point" }, "group_geolocation": { "type": "geo_point" } } } """ return {"items": mapping} class MeetupEnrich(Enrich): mapping = Mapping def get_field_author(self): return "author" def get_identities(self, item): ''' Return the identities from an item ''' item = item['data'] # Creators if 'event_hosts' in item: user = self.get_sh_identity(item['event_hosts'][0]) yield user # rsvps rsvps = item.get('rsvps', []) for rsvp in rsvps: user = self.get_sh_identity(rsvp['member']) yield user # Comments for comment in item['comments']: user = self.get_sh_identity(comment['member']) yield user def get_sh_identity(self, item, identity_field=None): identity = {'username': None, 'email': None, 'name': None} if not item: return identity user = item if 'data' in item and type(item) == dict: user = item['data'][identity_field] identity['username'] = str(user["id"]) identity['email'] = None identity['name'] = user["name"] return identity def get_project_repository(self, eitem): return eitem['tag'] @metadata def get_rich_item(self, item): # We need to detect the category of item: activities (report), events or users eitem = {} if 'time' not in item['data']: logger.warning("[meetup] Not processing %s: no time field", item['uuid']) return eitem for f in self.RAW_FIELDS_COPY: if f in item: eitem[f] = item[f] else: eitem[f] = None event = item['data'] # data fields to copy copy_fields = ["id", "how_to_find_us"] for f in copy_fields: if f in event: eitem[f] = event[f] else: eitem[f] = None # Fields which names are translated map_fields = { "link": "url", "rsvp_limit": "rsvps_limit" } for fn in map_fields: if fn in event: eitem[map_fields[fn]] = event[fn] else: eitem[f] = None # event host fields: author of the event if 'event_hosts' in event: host = event['event_hosts'][0] if 'photo' in host: eitem['member_photo_url'] = host['photo']['photo_link'] eitem['member_photo_id'] = host['photo']['id'] eitem['member_photo_type'] = host['photo']['type'] eitem['member_is_host'] = True eitem['member_id'] = host['id'] eitem['member_name'] = host['name'] eitem['member_url'] = "https://www.meetup.com/members/" + str(host['id']) eitem['event_url'] = event['link'] # data fields to copy with meetup`prefix copy_fields = ["description", "plain_text_description", "name", "status", "utc_offset", "visibility", "waitlist_count", "yes_rsvp_count", "duration", "featured", "rsvpable"] copy_fields_time = ["time", "updated", "created"] for f in copy_fields: if f in event: eitem["meetup_" + f] = event[f] else: eitem[f] = None for f in copy_fields_time: if f in event: eitem["meetup_" + f] = unixtime_to_datetime(event[f] / 1000).isoformat() else: eitem[f] = None rsvps = event.get('rsvps', []) eitem['num_rsvps'] = len(rsvps) eitem['num_comments'] = len(event['comments']) try: if 'time' in event: eitem['time_date'] = unixtime_to_datetime(event['time'] / 1000).isoformat() else: logger.warning("time field nof found in event") return {} except ValueError: logger.warning("Wrong datetime for %s: %s", eitem['url'], event['time']) # If no datetime for the enriched item, it is useless for Kibana return {} if 'venue' in event: venue = event['venue'] copy_fields = ["id", "name", "city", "state", "zip", "country", "localized_country_name", "repinned", "address_1"] for f in copy_fields: if f in venue: eitem["venue_" + f] = venue[f] else: eitem[f] = None eitem['venue_geolocation'] = { "lat": event['venue']['lat'], "lon": event['venue']['lon'], } if 'series' in event: eitem['series_id'] = event['series']['id'] eitem['series_description'] = event['series']['description'] eitem['series_start_date'] = event['series']['start_date'] if 'group' in event: group = event['group'] copy_fields = ["id", "created", "join_mode", "name", "url_name", "who"] for f in copy_fields: if f in group: eitem["group_" + f] = group[f] else: eitem[f] = None eitem['group_geolocation'] = { "lat": group['lat'], "lon": group['lon'], } eitem['group_topics'] = [] eitem['group_topics_keys'] = [] if 'topics' in group: group_topics = [topic['name'] for topic in group['topics']] group_topics_keys = [topic['urlkey'] for topic in group['topics']] eitem['group_topics'] = group_topics eitem['group_topics_keys'] = group_topics_keys if len(rsvps) > 0: eitem['group_members'] = rsvps[0]['group']['members'] created = unixtime_to_datetime(event['created'] / 1000).isoformat() eitem['type'] = "meetup" # time_date is when the meetup will take place, the needed one in this index # created is when the meetup entry was created and it is not the interesting date eitem.update(self.get_grimoire_fields(eitem['time_date'], eitem['type'])) if self.sortinghat: eitem.update(self.get_item_sh(event)) if self.prjs_map: eitem.update(self.get_item_project(eitem)) self.add_repository_labels(eitem) self.add_metadata_filter_raw(eitem) return eitem def get_item_sh(self, item): """ Add sorting hat enrichment fields """ sh_fields = {} # Not shared common get_item_sh because it is pretty specific if 'member' in item: # comment and rsvp identity = self.get_sh_identity(item['member']) elif 'event_hosts' in item: # meetup event identity = self.get_sh_identity(item['event_hosts'][0]) else: return sh_fields created = unixtime_to_datetime(item['created'] / 1000) sh_fields = self.get_item_sh_fields(identity, created) return sh_fields def get_rich_item_comments(self, comments, eitem): for comment in comments: ecomment = copy.deepcopy(eitem) created = unixtime_to_datetime(comment['created'] / 1000).isoformat() ecomment['url'] = comment['link'] ecomment['id'] = ecomment['id'] + '_comment_' + str(comment['id']) ecomment['comment'] = comment['comment'] ecomment['like_count'] = comment['like_count'] ecomment['type'] = 'comment' ecomment.update(self.get_grimoire_fields(created, ecomment['type'])) ecomment.pop('is_meetup_meetup') # event host fields: author of the event member = comment['member'] if 'photo' in member: ecomment['member_photo_url'] = member['photo']['photo_link'] ecomment['member_photo_id'] = member['photo']['id'] ecomment['member_photo_type'] = member['photo']['type'] if 'event_context' in member: ecomment['member_is_host'] = member['event_context']['host'] ecomment['member_id'] = member['id'] ecomment['member_name'] = member['name'] ecomment['member_url'] = "https://www.meetup.com/members/" + str(member['id']) if self.sortinghat: ecomment.update(self.get_item_sh(comment)) yield ecomment def get_rich_item_rsvps(self, rsvps, eitem): for rsvp in rsvps: ersvp = copy.deepcopy(eitem) ersvp['type'] = 'rsvp' created = unixtime_to_datetime(rsvp['created'] / 1000).isoformat() ersvp.update(self.get_grimoire_fields(created, ersvp['type'])) ersvp.pop('is_meetup_meetup') # event host fields: author of the event member = rsvp['member'] if 'photo' in member: ersvp['member_photo_url'] = member['photo']['photo_link'] ersvp['member_photo_id'] = member['photo']['id'] ersvp['member_photo_type'] = member['photo']['type'] ersvp['member_is_host'] = member['event_context']['host'] ersvp['member_id'] = member['id'] ersvp['member_name'] = member['name'] ersvp['member_url'] = "https://www.meetup.com/members/" + str(member['id']) ersvp['id'] = ersvp['id'] + '_rsvp_' + str(rsvp['event']['id']) + "_" + str(member['id']) ersvp['url'] = "https://www.meetup.com/members/" + str(member['id']) ersvp['rsvps_guests'] = rsvp['guests'] ersvp['rsvps_updated'] = rsvp['updated'] ersvp['rsvps_response'] = rsvp['response'] if self.sortinghat: ersvp.update(self.get_item_sh(rsvp)) yield ersvp def get_field_unique_id(self): return "id" def enrich_items(self, ocean_backend): items_to_enrich = [] num_items = 0 ins_items = 0 for item in ocean_backend.fetch(): eitem = self.get_rich_item(item) if 'uuid' not in eitem: continue items_to_enrich.append(eitem) if 'comments' in item['data'] and 'id' in eitem: comments = item['data']['comments'] rich_item_comments = self.get_rich_item_comments(comments, eitem) items_to_enrich.extend(rich_item_comments) if 'rsvps' in item['data'] and 'id' in eitem: rsvps = item['data']['rsvps'] rich_item_rsvps = self.get_rich_item_rsvps(rsvps, eitem) items_to_enrich.extend(rich_item_rsvps) if len(items_to_enrich) < MAX_SIZE_BULK_ENRICHED_ITEMS: continue num_items += len(items_to_enrich) ins_items += self.elastic.bulk_upload(items_to_enrich, self.get_field_unique_id()) items_to_enrich = [] if len(items_to_enrich) > 0: num_items += len(items_to_enrich) ins_items += self.elastic.bulk_upload(items_to_enrich, self.get_field_unique_id()) if num_items != ins_items: missing = num_items - ins_items logger.error("%s/%s missing items for Meetup", str(missing), str(num_items)) else: logger.info("%s items inserted for Meetup", str(num_items)) return num_items
gpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6900, 13, 14982, 699, 1661, 71, 4674, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3, 6642, 26, 199, 3, 257, 4580, 1391, 79, 2150, 445, 1810, 382, 320, 29359, 7949, 20528, 665, 645, 83, 32, 66, 1661, 71, 4674, 14, 957, 30, 199, 3, 199, 199, 646, 1331, 199, 646, 2050, 199, 199, 504, 27591, 573, 73, 3369, 371, 63, 31994, 14, 2083, 492, 16572, 521, 63, 475, 63, 2083, 199, 199, 504, 1275, 287, 10399, 492, 3447, 10399, 12, 3341, 199, 504, 2508, 15565, 63, 4745, 492, 12340, 465, 3523, 7674, 421, 199, 4283, 63, 4305, 63, 34, 1293, 43, 63, 742, 14673, 40, 1149, 63, 10439, 51, 275, 1926, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 12340, 8, 1563, 7674, 304, 339, 768, 4639, 272, 347, 664, 63, 15565, 63, 14632, 8, 397, 63, 8452, 304, 267, 408, 1002, 19509, 1733, 4412, 14, 398, 520, 635, 9455, 63, 8452, 26, 12160, 1015, 402, 19509, 1733, 12, 465, 1059, 267, 520, 5808, 26, 263, 2600, 543, 282, 790, 12, 283, 1744, 297, 543, 314, 4412, 267, 408, 398, 4412, 275, 408, 267, 469, 288, 298, 3282, 582, 469, 355, 298, 1802, 63, 4797, 7068, 582, 469, 490, 298, 466, 582, 298, 505, 401, 490, 298, 1080, 582, 2549, 355, 1660, 355, 298, 3349, 582, 469, 490, 298, 466, 582, 298, 505, 401, 490, 298, 1080, 582, 2549, 355, 1660, 355, 298, 24728, 63, 6721, 1985, 582, 469, 490, 298, 466, 582, 298, 6721, 63, 1403, 2, 355, 1660, 355, 298, 923, 63, 6721, 1985, 582, 469, 490, 298, 466, 582, 298, 6721, 63, 1403, 2, 355, 789, 1779, 789, 267, 789, 408, 398, 372, 2420, 1744, 582, 4412, 93, 421, 199, 533, 3194, 386, 384, 1327, 10399, 8, 1327, 10399, 304, 339, 4412, 275, 12340, 339, 347, 664, 63, 698, 63, 2502, 8, 277, 304, 267, 372, 298, 2502, 2, 339, 347, 664, 63, 9281, 5080, 8, 277, 12, 1242, 304, 267, 1449, 1432, 314, 6120, 5080, 687, 376, 1242, 1449, 398, 1242, 275, 1242, 459, 576, 418, 398, 327, 9750, 2750, 267, 340, 283, 1430, 63, 5146, 7, 315, 1242, 26, 288, 922, 275, 291, 14, 362, 63, 609, 63, 5582, 8, 1053, 459, 1430, 63, 5146, 3488, 16, 566, 288, 1995, 922, 398, 327, 30085, 1190, 267, 30085, 1190, 275, 1242, 14, 362, 360, 2393, 86, 1190, 297, 3073, 398, 367, 30085, 80, 315, 30085, 1190, 26, 288, 922, 275, 291, 14, 362, 63, 609, 63, 5582, 8, 2393, 11702, 459, 1114, 1105, 288, 1995, 922, 398, 327, 5429, 1470, 267, 367, 3721, 315, 1242, 459, 6223, 2565, 288, 922, 275, 291, 14, 362, 63, 609, 63, 5582, 8, 3349, 459, 1114, 1105, 288, 1995, 922, 339, 347, 664, 63, 609, 63, 5582, 8, 277, 12, 1242, 12, 8503, 63, 698, 29, 403, 304, 267, 8503, 275, 791, 2473, 356, 488, 12, 283, 2123, 356, 488, 12, 283, 354, 356, 488, 93, 398, 340, 440, 1242, 26, 288, 372, 8503, 398, 922, 275, 1242, 267, 340, 283, 576, 7, 315, 1242, 436, 730, 8, 1053, 9, 508, 1211, 26, 288, 922, 275, 1242, 459, 576, 3488, 5582, 63, 698, 61, 398, 8503, 459, 2473, 418, 275, 620, 8, 751, 905, 344, 3135, 267, 8503, 459, 2123, 418, 275, 488, 267, 8503, 459, 354, 418, 275, 922, 905, 354, 937, 398, 372, 8503, 339, 347, 664, 63, 1715, 63, 8421, 8, 277, 12, 325, 1053, 304, 267, 372, 325, 1053, 459, 1450, 418, 339, 768, 2343, 272, 347, 664, 63, 10399, 63, 1053, 8, 277, 12, 1242, 304, 267, 327, 2136, 1929, 370, 9696, 314, 4637, 402, 1242, 26, 30744, 334, 3070, 395, 4474, 503, 4390, 267, 325, 1053, 275, 1052, 398, 340, 283, 521, 7, 440, 315, 1242, 459, 576, 2565, 288, 2512, 14, 3764, 10994, 278, 386, 384, 61, 2832, 6661, 450, 83, 26, 949, 900, 901, 401, 1242, 459, 2580, 1105, 288, 372, 325, 1053, 398, 367, 289, 315, 291, 14, 4307, 63, 12767, 63, 16188, 26, 288, 340, 289, 315, 1242, 26, 355, 325, 1053, 59, 70, 61, 275, 1242, 59, 70, 61, 288, 587, 26, 355, 325, 1053, 59, 70, 61, 275, 488, 398, 1566, 275, 1242, 459, 576, 418, 398, 327, 666, 1504, 370, 1331, 267, 1331, 63, 955, 275, 2097, 344, 401, 298, 1917, 63, 475, 63, 1623, 63, 527, 937, 267, 367, 289, 315, 1331, 63, 955, 26, 288, 340, 289, 315, 1566, 26, 355, 325, 1053, 59, 70, 61, 275, 1566, 59, 70, 61, 288, 587, 26, 355, 325, 1053, 59, 70, 61, 275, 488, 398, 327, 16424, 1314, 1561, 787, 14598, 267, 2341, 63, 955, 275, 469, 288, 298, 1073, 582, 298, 633, 401, 288, 298, 2393, 11702, 63, 3097, 582, 298, 2393, 86, 1190, 63, 3097, 2, 267, 789, 267, 367, 4325, 315, 2341, 63, 955, 26, 288, 340, 4325, 315, 1566, 26, 355, 325, 1053, 59, 1130, 63, 955, 59, 2324, 2677, 275, 1566, 59, 2324, 61, 288, 587, 26, 355, 325, 1053, 59, 70, 61, 275, 488, 398, 327, 1566, 1591, 1504, 26, 4132, 402, 314, 1566, 267, 340, 283, 1430, 63, 5146, 7, 315, 1566, 26, 288, 1591, 275, 1566, 459 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 35, 9, 6900, 13, 14982, 699, 1661, 71, 4674, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 3, 6642, 26, 199, 3, 257, 4580, 1391, 79, 2150, 445, 1810, 382, 320, 29359, 7949, 20528, 665, 645, 83, 32, 66, 1661, 71, 4674, 14, 957, 30, 199, 3, 199, 199, 646, 1331, 199, 646, 2050, 199, 199, 504, 27591, 573, 73, 3369, 371, 63, 31994, 14, 2083, 492, 16572, 521, 63, 475, 63, 2083, 199, 199, 504, 1275, 287, 10399, 492, 3447, 10399, 12, 3341, 199, 504, 2508, 15565, 63, 4745, 492, 12340, 465, 3523, 7674, 421, 199, 4283, 63, 4305, 63, 34, 1293, 43, 63, 742, 14673, 40, 1149, 63, 10439, 51, 275, 1926, 421, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 12340, 8, 1563, 7674, 304, 339, 768, 4639, 272, 347, 664, 63, 15565, 63, 14632, 8, 397, 63, 8452, 304, 267, 408, 1002, 19509, 1733, 4412, 14, 398, 520, 635, 9455, 63, 8452, 26, 12160, 1015, 402, 19509, 1733, 12, 465, 1059, 267, 520, 5808, 26, 263, 2600, 543, 282, 790, 12, 283, 1744, 297, 543, 314, 4412, 267, 408, 398, 4412, 275, 408, 267, 469, 288, 298, 3282, 582, 469, 355, 298, 1802, 63, 4797, 7068, 582, 469, 490, 298, 466, 582, 298, 505, 401, 490, 298, 1080, 582, 2549, 355, 1660, 355, 298, 3349, 582, 469, 490, 298, 466, 582, 298, 505, 401, 490, 298, 1080, 582, 2549, 355, 1660, 355, 298, 24728, 63, 6721, 1985, 582, 469, 490, 298, 466, 582, 298, 6721, 63, 1403, 2, 355, 1660, 355, 298, 923, 63, 6721, 1985, 582, 469, 490, 298, 466, 582, 298, 6721, 63, 1403, 2, 355, 789, 1779, 789, 267, 789, 408, 398, 372, 2420, 1744, 582, 4412, 93, 421, 199, 533, 3194, 386, 384, 1327, 10399, 8, 1327, 10399, 304, 339, 4412, 275, 12340, 339, 347, 664, 63, 698, 63, 2502, 8, 277, 304, 267, 372, 298, 2502, 2, 339, 347, 664, 63, 9281, 5080, 8, 277, 12, 1242, 304, 267, 1449, 1432, 314, 6120, 5080, 687, 376, 1242, 1449, 398, 1242, 275, 1242, 459, 576, 418, 398, 327, 9750, 2750, 267, 340, 283, 1430, 63, 5146, 7, 315, 1242, 26, 288, 922, 275, 291, 14, 362, 63, 609, 63, 5582, 8, 1053, 459, 1430, 63, 5146, 3488, 16, 566, 288, 1995, 922, 398, 327, 30085, 1190, 267, 30085, 1190, 275, 1242, 14, 362, 360, 2393, 86, 1190, 297, 3073, 398, 367, 30085, 80, 315, 30085, 1190, 26, 288, 922, 275, 291, 14, 362, 63, 609, 63, 5582, 8, 2393, 11702, 459, 1114, 1105, 288, 1995, 922, 398, 327, 5429, 1470, 267, 367, 3721, 315, 1242, 459, 6223, 2565, 288, 922, 275, 291, 14, 362, 63, 609, 63, 5582, 8, 3349, 459, 1114, 1105, 288, 1995, 922, 339, 347, 664, 63, 609, 63, 5582, 8, 277, 12, 1242, 12, 8503, 63, 698, 29, 403, 304, 267, 8503, 275, 791, 2473, 356, 488, 12, 283, 2123, 356, 488, 12, 283, 354, 356, 488, 93, 398, 340, 440, 1242, 26, 288, 372, 8503, 398, 922, 275, 1242, 267, 340, 283, 576, 7, 315, 1242, 436, 730, 8, 1053, 9, 508, 1211, 26, 288, 922, 275, 1242, 459, 576, 3488, 5582, 63, 698, 61, 398, 8503, 459, 2473, 418, 275, 620, 8, 751, 905, 344, 3135, 267, 8503, 459, 2123, 418, 275, 488, 267, 8503, 459, 354, 418, 275, 922, 905, 354, 937, 398, 372, 8503, 339, 347, 664, 63, 1715, 63, 8421, 8, 277, 12, 325, 1053, 304, 267, 372, 325, 1053, 459, 1450, 418, 339, 768, 2343, 272, 347, 664, 63, 10399, 63, 1053, 8, 277, 12, 1242, 304, 267, 327, 2136, 1929, 370, 9696, 314, 4637, 402, 1242, 26, 30744, 334, 3070, 395, 4474, 503, 4390, 267, 325, 1053, 275, 1052, 398, 340, 283, 521, 7, 440, 315, 1242, 459, 576, 2565, 288, 2512, 14, 3764, 10994, 278, 386, 384, 61, 2832, 6661, 450, 83, 26, 949, 900, 901, 401, 1242, 459, 2580, 1105, 288, 372, 325, 1053, 398, 367, 289, 315, 291, 14, 4307, 63, 12767, 63, 16188, 26, 288, 340, 289, 315, 1242, 26, 355, 325, 1053, 59, 70, 61, 275, 1242, 59, 70, 61, 288, 587, 26, 355, 325, 1053, 59, 70, 61, 275, 488, 398, 1566, 275, 1242, 459, 576, 418, 398, 327, 666, 1504, 370, 1331, 267, 1331, 63, 955, 275, 2097, 344, 401, 298, 1917, 63, 475, 63, 1623, 63, 527, 937, 267, 367, 289, 315, 1331, 63, 955, 26, 288, 340, 289, 315, 1566, 26, 355, 325, 1053, 59, 70, 61, 275, 1566, 59, 70, 61, 288, 587, 26, 355, 325, 1053, 59, 70, 61, 275, 488, 398, 327, 16424, 1314, 1561, 787, 14598, 267, 2341, 63, 955, 275, 469, 288, 298, 1073, 582, 298, 633, 401, 288, 298, 2393, 11702, 63, 3097, 582, 298, 2393, 86, 1190, 63, 3097, 2, 267, 789, 267, 367, 4325, 315, 2341, 63, 955, 26, 288, 340, 4325, 315, 1566, 26, 355, 325, 1053, 59, 1130, 63, 955, 59, 2324, 2677, 275, 1566, 59, 2324, 61, 288, 587, 26, 355, 325, 1053, 59, 70, 61, 275, 488, 398, 327, 1566, 1591, 1504, 26, 4132, 402, 314, 1566, 267, 340, 283, 1430, 63, 5146, 7, 315, 1566, 26, 288, 1591, 275, 1566, 459, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ver228/tierpsy-tracker
tierpsy/analysis/ske_create/zebrafishAnalysis/zebrafishAnalysis.py
1
17590
# Zebrafish Analysis import math import numpy as np import cv2 from scipy.signal import savgol_filter class ModelConfig: def __init__(self, num_segments, min_angle, max_angle, num_angles, tail_length, tail_detection, prune_retention, test_width, draw_width, auto_detect_tail_length): self.min_angle = min_angle # Minimum angle for each segment (relative to previous segment) self.max_angle = max_angle # Maximum angle for each segment self.num_models_per_segment = num_angles # Number of angles to try for each segment self.prune_freq = 1 # When constructing the model, segment interval at which the model pruning function is called. Lower numbers are faster self.max_num_models_to_keep = prune_retention # Number of models retained after each round of pruning segment_height = int(tail_length / num_segments) self.segment_heights = [segment_height] * num_segments # Length must match num_segments self.segment_widths = [test_width] * num_segments # Used for constructing and testing straight-line models. Length must match num_segment self.num_segments = num_segments self.smoothed_segment_width = draw_width # Used for drawing the final smoothed version of the tail curve self.tail_offset = 30 # Distance in pixels from the head point to the tail model start point self.rotated_img_size = 200 # Size of the internal image of the rotated fish self.tail_point_detection_algorithm = tail_detection # Auto-detect tail length settings self.auto_detect_tail_length = auto_detect_tail_length if auto_detect_tail_length: # Override number of segments with a high number # Tail end will be detected automatically before this is reached and model generation will be stopped at that point self.num_segments = 20 self.segment_heights = [5] * self.num_segments self.segment_widths = [2] * self.num_segments self.segment_score_improvement_threshold = 250 # Amount by which a segment must improve the model score to be considered valid. If 'num_fail_segments' segments in a row are considered invalid, no further segments are added to that model self.num_fail_segments = 2 # Number of continuous segments which fail to meet the threshold improvement score for model generation to stop self.min_segments = 5 # Minimum number of segments in the model - There will be at least this many segments, even if the failing criteria is reached class MaskCanvas: def __init__(self, canvas_width, canvas_height): self.canvas = np.zeros((canvas_width, canvas_height), np.uint8) self.points = [] self.scores = [0] self.angle_offset = 0 def add_point(self, point): self.points.append(point) def last_point(self): return self.points[-1] if len(self.points) > 0 else None def last_score(self): return self.scores[-1] def score_improvement(self, n): if len(self.scores) < n + 1: return 0 return self.scores[-1 * n] - self.scores[-1 * (n+1)] def getOrientation(frame, config): th_val = 1 ret, binary_img = cv2.threshold(frame, th_val, 255, cv2.THRESH_BINARY) contours, hierarchy = cv2.findContours(binary_img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)[-2:] # Sort contours by area contours.sort(key=lambda ar: cv2.contourArea(ar)) largest_contour = contours[-1] [vx, vy, x, y] = cv2.fitLine(largest_contour, cv2.DIST_L2, 0, 0.01, 0.01) line_angle = math.atan2(vy, vx) line_angle_degrees = math.degrees(line_angle) angle = line_angle_degrees + 90 x, y, w, h = cv2.boundingRect(largest_contour) img_cropped = frame[y:y+h, x:x+w] rotated_img, actual_angle = rotateFishImage(img_cropped, angle, config) return rotated_img, actual_angle def rotateFishImage(img, angle_degrees, config): input_image = np.zeros((config.rotated_img_size, config.rotated_img_size), np.uint8) y_mid = config.rotated_img_size // 2 def _get_range(l): bot = math.floor(y_mid - l/2) top = math.floor(y_mid + l/2) return bot, top h_ran, w_ran = list(map(_get_range, img.shape)) input_image[h_ran[0]:h_ran[1], w_ran[0]:w_ran[1]] = img rows, cols = input_image.shape center = (rows//2, cols//2) M = cv2.getRotationMatrix2D(center, angle_degrees, 1.0) rotated_img = cv2.warpAffine(input_image, M, (cols, rows)) img_top = rotated_img[0:y_mid, 0:config.rotated_img_size] img_bottom = rotated_img[y_mid:config.rotated_img_size, 0:config.rotated_img_size] # Use valid pixel count to determine which half contains the head top_area = len(img_top[img_top != 0]) bottom_area = len(img_bottom[img_bottom != 0]) head_half = img_top if bottom_area < top_area else img_bottom # Find rotation angle again, this time only using the head half contours, hierarchy = cv2.findContours(head_half.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)[-2:] contours.sort(key=lambda ar: ar.size) largest_contour = contours[-1] [vx, vy, x, y] = cv2.fitLine(largest_contour, cv2.DIST_L2, 0, 0.01, 0.01) line_angle = math.atan2(vy, vx) line_angle_degrees = (math.degrees(line_angle) + 90) % 360 final_angle = (angle_degrees + line_angle_degrees) % 360 rows, cols = input_image.shape[:2] center = (rows/2, cols/2) M = cv2.getRotationMatrix2D(center, final_angle, 1.0) rotated_output_img = cv2.warpAffine(input_image, M, (cols, rows)) # Check again whether the image is rotated 180 degrees, and correct if necessary img_top = rotated_output_img[0:y_mid, 0:config.rotated_img_size] img_bottom = rotated_output_img[y_mid:config.rotated_img_size, 0:config.rotated_img_size] top_area = len(img_top[img_top != 0]) bottom_area = len(img_bottom[img_bottom != 0]) if bottom_area > top_area: correction_angle = 180 M = cv2.getRotationMatrix2D(center, correction_angle, 1.0) rotated_output_img = cv2.warpAffine(rotated_output_img, M, (cols, rows)) final_angle = (final_angle + correction_angle) % 360 return rotated_output_img, final_angle def getHeadMask(frame): th_val = 1 ret, img_thresh = cv2.threshold(frame, th_val, 255, cv2.THRESH_BINARY) # Remove excess noise by drawing only the largest contour head_mask = np.zeros((img_thresh.shape[0], img_thresh.shape[1]), np.uint8) contours, hierarchy = cv2.findContours(img_thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)[-2:] contours.sort(key=lambda ar: ar.size) head_contour = contours[-1] cv2.drawContours(head_mask, [head_contour], 0, 255, cv2.FILLED) return head_mask def getHeadPoint(rotated_img, angle): theta = math.radians(- angle) img_binary = np.zeros(rotated_img.shape, np.uint8) contours, hierarchy = cv2.findContours(rotated_img.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)[-2:] contours.sort(key=lambda ar: ar.size) largest_contour = contours[-1] cv2.drawContours(img_binary, [largest_contour], 0, 255, cv2.FILLED) valid_pixels = np.nonzero(img_binary) x = valid_pixels[1] y = valid_pixels[0] head_x = x[np.argmin(y)] head_y = np.min(y) w, h = rotated_img.shape[:2] center_x = w / 2 center_y = h / 2 hypot = math.hypot(center_x - head_x, center_y - head_y) rotated_head_x = center_x - (hypot * math.sin(theta)) rotated_head_y = center_y - (hypot * math.cos(theta)) return rotated_head_x, rotated_head_y def getTailStartPoint(head_mask, head_point, config): # Calculate the angle from the head point to the contour center # Then, 'walk' down the line from the head point to the contour center point a set length contours, hierarchy = cv2.findContours(head_mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)[-2:] contour = contours[-1] # Get contour center contour_moments = cv2.moments(contour) contour_center_x = int(contour_moments['m10'] / contour_moments['m00']) contour_center_y = int(contour_moments['m01'] / contour_moments['m00']) head_x = head_point[0] head_y = head_point[1] head_contour_center_angle = math.atan2(contour_center_y - head_y, contour_center_x - head_x) head_x = head_point[0] head_y = head_point[1] # Calculate tail start point tail_start_x = head_x + config.tail_offset * math.cos(head_contour_center_angle) tail_start_y = head_y + config.tail_offset * math.sin(head_contour_center_angle) return (int(tail_start_x), int(tail_start_y)) def getModelMasks(head_mask, base_angle, frame, head_point, config): # Generate the test image used for scoring models test_image = getTestImage(frame, head_mask, head_point, base_angle, config) # Create starting object initial_canvas = MaskCanvas(head_mask.shape[0], head_mask.shape[1]) # Add tail starting point initial_point = getTailStartPoint(head_mask, head_point, config) initial_canvas.add_point(initial_point) # Set base angle initial_canvas.angle_offset = -base_angle canvas_set = [initial_canvas] output_canvas_set = drawModelSegments(canvas_set, config.num_segments, test_image, config) return output_canvas_set def getTestImage(frame, head_mask, head_point, angle, config): # Remove the head from the test image using a triangular mask, so it doesn't interfere with tail model scoring center_x, center_y = getTailStartPoint(head_mask, head_point, config) triangle_length = 100 t0_angle_radians = math.radians(angle) t0_x = center_x + triangle_length * math.sin(t0_angle_radians) t0_y = center_y - triangle_length * math.cos(t0_angle_radians) t1_angle_radians = math.radians(angle - 90) t1_x = center_x + triangle_length * math.sin(t1_angle_radians) t1_y = center_y - triangle_length * math.cos(t1_angle_radians) t2_angle_radians = math.radians(angle + 90) t2_x = center_x + triangle_length * math.sin(t2_angle_radians) t2_y = center_y - triangle_length * math.cos(t2_angle_radians) triangle_points = np.array([(t0_x, t0_y), (t1_x, t1_y), (t2_x, t2_y)]).astype('int32') test_image = frame.copy() cv2.fillConvexPoly(test_image, triangle_points, 0) return test_image def drawModelSegments(canvas_set, num_segments, test_image, config): angle_increment = (config.max_angle - config.min_angle) / config.num_models_per_segment output_set = [] for canvas in canvas_set: for i in range(0, config.num_models_per_segment + 1): # Calculate segment rotation angle rotation_angle = config.min_angle + (i * angle_increment) # Draw line on canvas new_canvas = MaskCanvas(0, 0) new_canvas.canvas = canvas.canvas.copy() new_canvas.points = list(canvas.points) new_canvas.angle_offset = canvas.angle_offset new_canvas.scores = list(canvas.scores) segment_width = config.segment_widths[-num_segments] segment_height = config.segment_heights[-num_segments] canvas_with_segment = drawSegmentOnCanvas(new_canvas, rotation_angle, segment_width, segment_height) # Add canvas to output set output_set.append(canvas_with_segment) # Prune the models with the lowest scores if num_segments % config.prune_freq == 0: end_generation, output_set = pruneModels(test_image, output_set, config.max_num_models_to_keep, config) # If auto-detect tail length is enabled, check for 'end model generation' flag if config.auto_detect_tail_length: if end_generation is True and num_segments < config.num_segments - config.min_segments: i = len(output_set[0].points) - config.num_fail_segments # Remove the final failing segments output_set[0].points = output_set[0].points[0:i] return output_set # Call the function recursively until all segments have been drawn on the canvases if num_segments > 1: return drawModelSegments(output_set, num_segments - 1, test_image, config) else: return output_set def drawSegmentOnCanvas(canvas, angle, segment_width, segment_height): # Take into account previous angles adjusted_angle = angle + canvas.angle_offset # Convert angle from degrees to radians angle_radians = math.radians(adjusted_angle) # Calculate position of next point pt_x = canvas.last_point()[0] + segment_height * math.sin(angle_radians) pt_y = canvas.last_point()[1] + segment_height * math.cos(angle_radians) pt = (int(pt_x), int(pt_y)) # Draw line connecting points cv2.line(canvas.canvas, canvas.last_point(), pt, 255, thickness=segment_width, lineType=cv2.LINE_AA) # Add the new point to the MaskCanvas object's list of points canvas.add_point(pt) # Update 'angle_offset' on the MaskCanvas object canvas.angle_offset += angle return canvas def pruneModels(test_image, canvas_set, max_num_models_to_keep, config): for canvas in canvas_set: score = scoreModel(canvas, test_image) canvas.scores.append(score) # Order canvas list by scores canvas_set.sort(key=lambda c: c.last_score()) # Remove all masks except the ones with the top scores keep_num = max_num_models_to_keep if len(canvas_set) > max_num_models_to_keep else len(canvas_set) pruned_set = canvas_set[-keep_num:] # Return the pruned set of models if tail length auto-detection is off if config.auto_detect_tail_length == False: return False, pruned_set # Otherwise, decide whether to continue adding segments to the models or not best_canvas = canvas_set[-1] # If the set continuous number of segments fail to meet the threshold improvement score, # signal that the model should stop being generated (ie. no further segments should be added, and the final # failing x segments should be removed from the model) end_generation = False for x in range(1, config.num_fail_segments + 1): if best_canvas.score_improvement(x) > config.segment_score_improvement_threshold: break if x == config.num_fail_segments: end_generation = True return end_generation, pruned_set def scoreModel(canvas, test_image): # Find pixels in the test image which overlap with the model masked_img = cv2.bitwise_and(test_image, test_image, mask=canvas.canvas) # Get non-zero pixels valid_pixels = masked_img[masked_img != 0] # Adjust pixel values so that darker pixels will score higher than lighter pixels (as fish is darker than the background) adjusted_vals = 256 - valid_pixels # Calculate score score = int(cv2.sumElems(adjusted_vals)[0]) return score def smoothMaskModel(mask_canvas, config): points = mask_canvas.points points = np.array(points) points = points.astype(int) x = points[:, 0] y = points[:, 1] window_length = len(y) if window_length % 2 == 0: window_length -= 1 polyorder = 3 yhat = savgol_filter(y, window_length, polyorder) output_points = [] for a, b in zip(x, yhat): new_point = [a, b] output_points.append(new_point) output_points = np.array(output_points) output_points = output_points.astype(int) mask = np.zeros(mask_canvas.canvas.shape, np.uint8) cv2.polylines(mask, [output_points], False, 255, thickness=config.smoothed_segment_width) return mask, output_points def getCombinationMask(head_mask, tail_mask): combination_mask = cv2.add(head_mask, tail_mask) return combination_mask def cleanMask(mask): # Apply closing to smooth the edges of the mask kernel_size = 5 kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (kernel_size, kernel_size)) # Circle mask_closing = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel) return mask_closing def getZebrafishMask(frame, config): # Get orientated image and rotation angle rotated_img, angle = getOrientation(frame, config) # Get head mask head_mask = getHeadMask(frame) # Get head point head_point = getHeadPoint(rotated_img, angle) # Get model masks model_masks = getModelMasks(head_mask, angle, frame, head_point, config) # Get best mask test_image = getTestImage(frame, head_mask, head_point, angle, config) _, mask_set = pruneModels(test_image, model_masks, 1, config) best_mask = mask_set[0] # Smooth the best mask smoothed_mask, smoothed_points = smoothMaskModel(best_mask, config) # Get combination mask combination_mask = getCombinationMask(head_mask, smoothed_mask) # Clean mask cleaned_mask = cleanMask(combination_mask) worm_mask = cleaned_mask.copy() contours, hierarchy = cv2.findContours(cleaned_mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)[-2:] if len(contours) == 0: output = None else: # Remove nesting from contour worm_cnt = contours[0] worm_cnt = np.vstack(worm_cnt).squeeze() # Return None values if contour too small if len(worm_cnt) < 3: output = None else: cnt_area = cv2.contourArea(worm_cnt) output = worm_mask, worm_cnt, cnt_area, \ cleaned_mask, head_point, smoothed_points if output is None: return [None]*6 else: return output
mit
[ 3, 3107, 2871, 345, 16056, 21916, 421, 199, 646, 3473, 199, 646, 2680, 465, 980, 199, 646, 6277, 18, 199, 199, 504, 7026, 14, 4653, 492, 308, 8595, 393, 63, 1541, 199, 199, 533, 5822, 2028, 26, 339, 347, 636, 826, 721, 277, 12, 1967, 63, 13879, 12, 1748, 63, 4593, 12, 1390, 63, 4593, 12, 1967, 63, 13162, 12, 9483, 63, 1267, 12, 9483, 63, 11934, 12, 27619, 63, 28307, 12, 511, 63, 2063, 12, 5954, 63, 2063, 12, 2599, 63, 13552, 63, 1521, 63, 1267, 304, 398, 291, 14, 827, 63, 4593, 275, 1748, 63, 4593, 327, 22466, 9324, 367, 1924, 8135, 334, 6188, 370, 4136, 8135, 9, 267, 291, 14, 988, 63, 4593, 275, 1390, 63, 4593, 327, 14212, 9324, 367, 1924, 8135, 267, 291, 14, 1507, 63, 992, 63, 529, 63, 9255, 275, 1967, 63, 13162, 327, 4860, 402, 22597, 370, 862, 367, 1924, 8135, 398, 291, 14, 22268, 63, 5646, 275, 413, 327, 3979, 22048, 314, 1402, 12, 8135, 6252, 737, 1314, 314, 1402, 29501, 316, 805, 365, 2797, 14, 29893, 5579, 787, 12930, 267, 291, 14, 988, 63, 1507, 63, 992, 63, 475, 63, 3250, 275, 27619, 63, 28307, 327, 4860, 402, 1709, 30403, 2410, 1924, 6168, 402, 29501, 316, 398, 8135, 63, 3333, 275, 1109, 8, 1521, 63, 1267, 1182, 1967, 63, 13879, 9, 267, 291, 14, 9255, 63, 426, 2492, 275, 359, 9255, 63, 3333, 61, 627, 1967, 63, 13879, 327, 19893, 1471, 1336, 1967, 63, 13879, 267, 291, 14, 9255, 63, 22209, 275, 359, 396, 63, 2063, 61, 627, 1967, 63, 13879, 327, 8051, 367, 22048, 436, 5343, 23669, 13, 604, 1709, 14, 19893, 1471, 1336, 1967, 63, 9255, 398, 291, 14, 1507, 63, 13879, 275, 1967, 63, 13879, 398, 291, 14, 19169, 379, 63, 9255, 63, 2063, 275, 5954, 63, 2063, 327, 8051, 367, 17455, 314, 4242, 19608, 379, 1015, 402, 314, 9483, 15318, 398, 291, 14, 1521, 63, 2743, 275, 4233, 327, 21892, 315, 11094, 687, 314, 4854, 2376, 370, 314, 9483, 1402, 1343, 2376, 398, 291, 14, 4571, 972, 63, 4060, 63, 890, 275, 1926, 327, 14579, 402, 314, 5007, 1834, 402, 314, 7513, 972, 289, 2453, 398, 291, 14, 1521, 63, 1403, 63, 11934, 63, 8833, 275, 9483, 63, 11934, 398, 327, 9195, 13, 13552, 9483, 2582, 2202, 267, 291, 14, 2495, 63, 13552, 63, 1521, 63, 1267, 275, 2599, 63, 13552, 63, 1521, 63, 1267, 267, 340, 2599, 63, 13552, 63, 1521, 63, 1267, 26, 288, 327, 11041, 1329, 402, 11998, 543, 282, 4721, 1329, 288, 327, 377, 1054, 1284, 911, 506, 10501, 5847, 2544, 642, 365, 13075, 436, 1402, 10152, 911, 506, 15248, 737, 626, 2376, 288, 291, 14, 1507, 63, 13879, 275, 3388, 288, 291, 14, 9255, 63, 426, 2492, 275, 359, 21, 61, 627, 291, 14, 1507, 63, 13879, 288, 291, 14, 9255, 63, 22209, 221, 275, 359, 18, 61, 627, 291, 14, 1507, 63, 13879, 288, 291, 14, 9255, 63, 3397, 63, 3236, 11750, 434, 63, 7227, 275, 16074, 327, 26701, 701, 1314, 282, 8135, 1471, 19053, 314, 1402, 5396, 370, 506, 8652, 1686, 14, 982, 283, 1507, 63, 1633, 63, 13879, 7, 11998, 315, 282, 1962, 787, 8652, 3866, 12, 949, 9848, 11998, 787, 3483, 370, 626, 1402, 288, 291, 14, 1507, 63, 1633, 63, 13879, 275, 499, 327, 4860, 402, 19922, 11998, 1314, 2449, 370, 26743, 314, 8765, 19053, 434, 5396, 367, 1402, 10152, 370, 3631, 288, 291, 14, 827, 63, 13879, 275, 959, 327, 22466, 1329, 402, 11998, 315, 314, 1402, 446, 6006, 911, 506, 737, 5210, 642, 5002, 11998, 12, 2755, 340, 314, 18648, 15647, 365, 13075, 421, 199, 533, 17581, 15174, 26, 339, 347, 636, 826, 721, 277, 12, 10218, 63, 2063, 12, 10218, 63, 3333, 304, 267, 291, 14, 7682, 275, 980, 14, 4250, 1332, 7682, 63, 2063, 12, 10218, 63, 3333, 395, 980, 14, 1635, 24, 9, 267, 291, 14, 3438, 275, 942, 267, 291, 14, 7107, 275, 359, 16, 61, 267, 291, 14, 4593, 63, 2743, 275, 378, 2378, 347, 1050, 63, 1403, 8, 277, 12, 2376, 304, 267, 291, 14, 3438, 14, 740, 8, 1403, 9, 2378, 347, 2061, 63, 1403, 8, 277, 304, 267, 372, 291, 14, 3438, 1988, 17, 61, 340, 822, 8, 277, 14, 3438, 9, 690, 378, 587, 488, 2378, 347, 2061, 63, 3397, 8, 277, 304, 267, 372, 291, 14, 7107, 1988, 17, 61, 2378, 347, 5396, 63, 3236, 11750, 434, 8, 277, 12, 302, 304, 267, 340, 822, 8, 277, 14, 7107, 9, 665, 302, 435, 413, 26, 288, 372, 378, 267, 372, 291, 14, 7107, 1988, 17, 627, 302, 61, 446, 291, 14, 7107, 1988, 17, 627, 334, 78, 11, 17, 1874, 421, 199, 318, 664, 27536, 8, 1943, 12, 1101, 304, 339, 294, 63, 637, 275, 413, 339, 2203, 12, 3366, 63, 4060, 275, 6277, 18, 14, 7227, 8, 1943, 12, 294, 63, 637, 12, 5450, 12, 6277, 18, 14, 18109, 63, 13246, 9, 272, 23176, 83, 12, 14446, 275, 6277, 18, 14, 1623, 714, 10808, 83, 8, 3008, 63, 4060, 12, 6277, 18, 14, 7341, 50, 63, 21043, 12, 6277, 18, 14, 25256, 63, 1282, 2514, 56, 63, 9185, 15786, 18, 2938, 2378, 327, 16722, 23176, 83, 701, 9150, 272, 23176, 83, 14, 3191, 8, 498, 29, 2734, 601, 26, 6277, 18, 14, 17798, 11043, 8, 285, 430, 339, 17451, 63, 17798, 275, 23176, 83, 1988, 17, 61, 339, 359, 18843, 12, 31766, 12, 671, 12, 612, 61, 275, 6277, 18, 14, 3269, 3049, 8, 9828, 3199, 63, 17798, 12, 6277, 18, 14, 13783, 63, 44, 18, 12, 378, 12, 378, 14, 614, 12, 378, 14, 614, 9, 272, 1004, 63, 4593, 275, 3473, 14, 16080, 18, 8, 16091, 12, 29922, 9, 272, 1004, 63, 4593, 63, 20251, 275, 3473, 14, 20251, 8, 604, 63, 4593, 9, 339, 9324, 275, 1004, 63, 4593, 63, 20251, 435, 9137, 339, 671, 12, 612, 12, 336, 12, 394, 275, 6277, 18, 14, 24511, 8252, 8, 9828, 3199, 63, 17798, 9, 339, 6050, 63, 15816, 1915, 275, 2787, 59, 89, 26, 89, 11, 72, 12, 671, 26, 88, 11, 87, 61, 339, 7513, 972, 63, 4060, 12, 3503, 63, 4593, 275, 20071 ]
[ 3107, 2871, 345, 16056, 21916, 421, 199, 646, 3473, 199, 646, 2680, 465, 980, 199, 646, 6277, 18, 199, 199, 504, 7026, 14, 4653, 492, 308, 8595, 393, 63, 1541, 199, 199, 533, 5822, 2028, 26, 339, 347, 636, 826, 721, 277, 12, 1967, 63, 13879, 12, 1748, 63, 4593, 12, 1390, 63, 4593, 12, 1967, 63, 13162, 12, 9483, 63, 1267, 12, 9483, 63, 11934, 12, 27619, 63, 28307, 12, 511, 63, 2063, 12, 5954, 63, 2063, 12, 2599, 63, 13552, 63, 1521, 63, 1267, 304, 398, 291, 14, 827, 63, 4593, 275, 1748, 63, 4593, 327, 22466, 9324, 367, 1924, 8135, 334, 6188, 370, 4136, 8135, 9, 267, 291, 14, 988, 63, 4593, 275, 1390, 63, 4593, 327, 14212, 9324, 367, 1924, 8135, 267, 291, 14, 1507, 63, 992, 63, 529, 63, 9255, 275, 1967, 63, 13162, 327, 4860, 402, 22597, 370, 862, 367, 1924, 8135, 398, 291, 14, 22268, 63, 5646, 275, 413, 327, 3979, 22048, 314, 1402, 12, 8135, 6252, 737, 1314, 314, 1402, 29501, 316, 805, 365, 2797, 14, 29893, 5579, 787, 12930, 267, 291, 14, 988, 63, 1507, 63, 992, 63, 475, 63, 3250, 275, 27619, 63, 28307, 327, 4860, 402, 1709, 30403, 2410, 1924, 6168, 402, 29501, 316, 398, 8135, 63, 3333, 275, 1109, 8, 1521, 63, 1267, 1182, 1967, 63, 13879, 9, 267, 291, 14, 9255, 63, 426, 2492, 275, 359, 9255, 63, 3333, 61, 627, 1967, 63, 13879, 327, 19893, 1471, 1336, 1967, 63, 13879, 267, 291, 14, 9255, 63, 22209, 275, 359, 396, 63, 2063, 61, 627, 1967, 63, 13879, 327, 8051, 367, 22048, 436, 5343, 23669, 13, 604, 1709, 14, 19893, 1471, 1336, 1967, 63, 9255, 398, 291, 14, 1507, 63, 13879, 275, 1967, 63, 13879, 398, 291, 14, 19169, 379, 63, 9255, 63, 2063, 275, 5954, 63, 2063, 327, 8051, 367, 17455, 314, 4242, 19608, 379, 1015, 402, 314, 9483, 15318, 398, 291, 14, 1521, 63, 2743, 275, 4233, 327, 21892, 315, 11094, 687, 314, 4854, 2376, 370, 314, 9483, 1402, 1343, 2376, 398, 291, 14, 4571, 972, 63, 4060, 63, 890, 275, 1926, 327, 14579, 402, 314, 5007, 1834, 402, 314, 7513, 972, 289, 2453, 398, 291, 14, 1521, 63, 1403, 63, 11934, 63, 8833, 275, 9483, 63, 11934, 398, 327, 9195, 13, 13552, 9483, 2582, 2202, 267, 291, 14, 2495, 63, 13552, 63, 1521, 63, 1267, 275, 2599, 63, 13552, 63, 1521, 63, 1267, 267, 340, 2599, 63, 13552, 63, 1521, 63, 1267, 26, 288, 327, 11041, 1329, 402, 11998, 543, 282, 4721, 1329, 288, 327, 377, 1054, 1284, 911, 506, 10501, 5847, 2544, 642, 365, 13075, 436, 1402, 10152, 911, 506, 15248, 737, 626, 2376, 288, 291, 14, 1507, 63, 13879, 275, 3388, 288, 291, 14, 9255, 63, 426, 2492, 275, 359, 21, 61, 627, 291, 14, 1507, 63, 13879, 288, 291, 14, 9255, 63, 22209, 221, 275, 359, 18, 61, 627, 291, 14, 1507, 63, 13879, 288, 291, 14, 9255, 63, 3397, 63, 3236, 11750, 434, 63, 7227, 275, 16074, 327, 26701, 701, 1314, 282, 8135, 1471, 19053, 314, 1402, 5396, 370, 506, 8652, 1686, 14, 982, 283, 1507, 63, 1633, 63, 13879, 7, 11998, 315, 282, 1962, 787, 8652, 3866, 12, 949, 9848, 11998, 787, 3483, 370, 626, 1402, 288, 291, 14, 1507, 63, 1633, 63, 13879, 275, 499, 327, 4860, 402, 19922, 11998, 1314, 2449, 370, 26743, 314, 8765, 19053, 434, 5396, 367, 1402, 10152, 370, 3631, 288, 291, 14, 827, 63, 13879, 275, 959, 327, 22466, 1329, 402, 11998, 315, 314, 1402, 446, 6006, 911, 506, 737, 5210, 642, 5002, 11998, 12, 2755, 340, 314, 18648, 15647, 365, 13075, 421, 199, 533, 17581, 15174, 26, 339, 347, 636, 826, 721, 277, 12, 10218, 63, 2063, 12, 10218, 63, 3333, 304, 267, 291, 14, 7682, 275, 980, 14, 4250, 1332, 7682, 63, 2063, 12, 10218, 63, 3333, 395, 980, 14, 1635, 24, 9, 267, 291, 14, 3438, 275, 942, 267, 291, 14, 7107, 275, 359, 16, 61, 267, 291, 14, 4593, 63, 2743, 275, 378, 2378, 347, 1050, 63, 1403, 8, 277, 12, 2376, 304, 267, 291, 14, 3438, 14, 740, 8, 1403, 9, 2378, 347, 2061, 63, 1403, 8, 277, 304, 267, 372, 291, 14, 3438, 1988, 17, 61, 340, 822, 8, 277, 14, 3438, 9, 690, 378, 587, 488, 2378, 347, 2061, 63, 3397, 8, 277, 304, 267, 372, 291, 14, 7107, 1988, 17, 61, 2378, 347, 5396, 63, 3236, 11750, 434, 8, 277, 12, 302, 304, 267, 340, 822, 8, 277, 14, 7107, 9, 665, 302, 435, 413, 26, 288, 372, 378, 267, 372, 291, 14, 7107, 1988, 17, 627, 302, 61, 446, 291, 14, 7107, 1988, 17, 627, 334, 78, 11, 17, 1874, 421, 199, 318, 664, 27536, 8, 1943, 12, 1101, 304, 339, 294, 63, 637, 275, 413, 339, 2203, 12, 3366, 63, 4060, 275, 6277, 18, 14, 7227, 8, 1943, 12, 294, 63, 637, 12, 5450, 12, 6277, 18, 14, 18109, 63, 13246, 9, 272, 23176, 83, 12, 14446, 275, 6277, 18, 14, 1623, 714, 10808, 83, 8, 3008, 63, 4060, 12, 6277, 18, 14, 7341, 50, 63, 21043, 12, 6277, 18, 14, 25256, 63, 1282, 2514, 56, 63, 9185, 15786, 18, 2938, 2378, 327, 16722, 23176, 83, 701, 9150, 272, 23176, 83, 14, 3191, 8, 498, 29, 2734, 601, 26, 6277, 18, 14, 17798, 11043, 8, 285, 430, 339, 17451, 63, 17798, 275, 23176, 83, 1988, 17, 61, 339, 359, 18843, 12, 31766, 12, 671, 12, 612, 61, 275, 6277, 18, 14, 3269, 3049, 8, 9828, 3199, 63, 17798, 12, 6277, 18, 14, 13783, 63, 44, 18, 12, 378, 12, 378, 14, 614, 12, 378, 14, 614, 9, 272, 1004, 63, 4593, 275, 3473, 14, 16080, 18, 8, 16091, 12, 29922, 9, 272, 1004, 63, 4593, 63, 20251, 275, 3473, 14, 20251, 8, 604, 63, 4593, 9, 339, 9324, 275, 1004, 63, 4593, 63, 20251, 435, 9137, 339, 671, 12, 612, 12, 336, 12, 394, 275, 6277, 18, 14, 24511, 8252, 8, 9828, 3199, 63, 17798, 9, 339, 6050, 63, 15816, 1915, 275, 2787, 59, 89, 26, 89, 11, 72, 12, 671, 26, 88, 11, 87, 61, 339, 7513, 972, 63, 4060, 12, 3503, 63, 4593, 275, 20071, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
andreaso/ansible
lib/ansible/module_utils/openstack.py
57
4600
# This code is part of Ansible, but is an independent component. # This particular file snippet, and this file snippet only, is BSD licensed. # Modules you write using this snippet, which is embedded dynamically by Ansible # still belong to the author of the module, and may assign their own license # to the complete work. # # Copyright (c) 2014 Hewlett-Packard Development Company, L.P. # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import os from ansible.module_utils.six import iteritems def openstack_argument_spec(): # DEPRECATED: This argument spec is only used for the deprecated old # OpenStack modules. It turns out that modern OpenStack auth is WAY # more complex than this. # Consume standard OpenStack environment variables. # This is mainly only useful for ad-hoc command line operation as # in playbooks one would assume variables would be used appropriately OS_AUTH_URL=os.environ.get('OS_AUTH_URL', 'http://127.0.0.1:35357/v2.0/') OS_PASSWORD=os.environ.get('OS_PASSWORD', None) OS_REGION_NAME=os.environ.get('OS_REGION_NAME', None) OS_USERNAME=os.environ.get('OS_USERNAME', 'admin') OS_TENANT_NAME=os.environ.get('OS_TENANT_NAME', OS_USERNAME) spec = dict( login_username = dict(default=OS_USERNAME), auth_url = dict(default=OS_AUTH_URL), region_name = dict(default=OS_REGION_NAME), availability_zone = dict(default=None), ) if OS_PASSWORD: spec['login_password'] = dict(default=OS_PASSWORD) else: spec['login_password'] = dict(required=True) if OS_TENANT_NAME: spec['login_tenant_name'] = dict(default=OS_TENANT_NAME) else: spec['login_tenant_name'] = dict(required=True) return spec def openstack_find_nova_addresses(addresses, ext_tag, key_name=None): ret = [] for (k, v) in iteritems(addresses): if key_name and k == key_name: ret.extend([addrs['addr'] for addrs in v]) else: for interface_spec in v: if 'OS-EXT-IPS:type' in interface_spec and interface_spec['OS-EXT-IPS:type'] == ext_tag: ret.append(interface_spec['addr']) return ret def openstack_full_argument_spec(**kwargs): spec = dict( cloud=dict(default=None), auth_type=dict(default=None), auth=dict(default=None, type='dict', no_log=True), region_name=dict(default=None), availability_zone=dict(default=None), verify=dict(default=None, type='bool', aliases=['validate_certs']), cacert=dict(default=None), cert=dict(default=None), key=dict(default=None, no_log=True), wait=dict(default=True, type='bool'), timeout=dict(default=180, type='int'), api_timeout=dict(default=None, type='int'), endpoint_type=dict( default='public', choices=['public', 'internal', 'admin'] ) ) spec.update(kwargs) return spec def openstack_module_kwargs(**kwargs): ret = {} for key in ('mutually_exclusive', 'required_together', 'required_one_of'): if key in kwargs: if key in ret: ret[key].extend(kwargs[key]) else: ret[key] = kwargs[key] return ret
gpl-3.0
[ 3, 961, 1233, 365, 1777, 402, 2622, 12, 1325, 365, 376, 12717, 3931, 14, 199, 3, 961, 6770, 570, 17440, 12, 436, 642, 570, 17440, 1454, 12, 365, 6289, 18233, 14, 199, 3, 18167, 1265, 2218, 1808, 642, 17440, 12, 1314, 365, 12169, 18774, 701, 2622, 199, 3, 5139, 13511, 370, 314, 4132, 402, 314, 859, 12, 436, 1443, 5090, 3932, 5705, 4190, 199, 3, 370, 314, 4890, 1736, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 6927, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 199, 3, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 199, 3, 259, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 420, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 259, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 420, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 420, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 199, 3, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 199, 3, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 199, 3, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 199, 3, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 747, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 10849, 199, 199, 318, 13869, 63, 2094, 63, 1650, 837, 272, 327, 31404, 26, 961, 1423, 3158, 365, 1454, 1202, 367, 314, 5906, 2269, 272, 327, 14260, 4621, 14, 2779, 25449, 734, 626, 818, 11641, 14260, 1790, 365, 9683, 272, 327, 1655, 6114, 2419, 642, 14, 272, 327, 1448, 3639, 4465, 14260, 3734, 2860, 14, 272, 327, 961, 365, 27580, 1454, 2997, 367, 1503, 13, 20402, 1414, 1004, 3439, 465, 272, 327, 315, 5232, 8858, 1373, 3955, 5534, 2860, 3955, 506, 1202, 22497, 272, 4403, 63, 5580, 63, 2632, 29, 736, 14, 2314, 14, 362, 360, 3100, 63, 5580, 63, 2632, 297, 283, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 1276, 13155, 15, 86, 18, 14, 16, 6217, 272, 4403, 63, 9032, 29, 736, 14, 2314, 14, 362, 360, 3100, 63, 9032, 297, 488, 9, 272, 4403, 63, 23030, 63, 2339, 29, 736, 14, 2314, 14, 362, 360, 3100, 63, 23030, 63, 2339, 297, 488, 9, 272, 4403, 63, 11958, 29, 736, 14, 2314, 14, 362, 360, 3100, 63, 11958, 297, 283, 2113, 358, 272, 4403, 63, 52, 31718, 63, 2339, 29, 736, 14, 2314, 14, 362, 360, 3100, 63, 52, 31718, 63, 2339, 297, 4403, 63, 11958, 9, 339, 3158, 275, 1211, 8, 267, 4676, 63, 2473, 8295, 275, 1211, 8, 885, 29, 3100, 63, 11958, 395, 267, 1790, 63, 633, 12788, 275, 1211, 8, 885, 29, 3100, 63, 5580, 63, 2632, 395, 267, 4897, 63, 354, 9326, 275, 1211, 8, 885, 29, 3100, 63, 23030, 63, 2339, 395, 267, 14962, 63, 2619, 5185, 275, 1211, 8, 885, 29, 403, 395, 272, 776, 272, 340, 4403, 63, 9032, 26, 267, 3158, 459, 2886, 63, 2060, 418, 275, 1211, 8, 885, 29, 3100, 63, 9032, 9, 272, 587, 26, 267, 3158, 459, 2886, 63, 2060, 418, 275, 1211, 8, 2427, 29, 549, 9, 272, 340, 4403, 63, 52, 31718, 63, 2339, 26, 267, 3158, 459, 2886, 63, 4647, 63, 354, 418, 275, 1211, 8, 885, 29, 3100, 63, 52, 31718, 63, 2339, 9, 272, 587, 26, 267, 3158, 459, 2886, 63, 4647, 63, 354, 418, 275, 1211, 8, 2427, 29, 549, 9, 272, 372, 3158, 199, 199, 318, 13869, 63, 1623, 63, 6765, 63, 7423, 8, 7423, 12, 1599, 63, 1450, 12, 790, 63, 354, 29, 403, 304, 339, 2203, 275, 942, 272, 367, 334, 75, 12, 373, 9, 315, 10849, 8, 7423, 304, 267, 340, 790, 63, 354, 436, 1022, 508, 790, 63, 354, 26, 288, 2203, 14, 2880, 779, 18942, 459, 2697, 418, 367, 29259, 315, 373, 566, 267, 587, 26, 288, 367, 3217, 63, 1650, 315, 373, 26, 355, 340, 283, 3100, 13, 2472, 13, 12346, 26, 466, 7, 315, 3217, 63, 1650, 436, 3217, 63, 1650, 459, 3100, 13, 2472, 13, 12346, 26, 466, 418, 508, 1599, 63, 1450, 26, 490, 2203, 14, 740, 8, 3266, 63, 1650, 459, 2697, 1105, 272, 372, 2203, 199, 199, 318, 13869, 63, 2861, 63, 2094, 63, 1650, 3682, 958, 304, 272, 3158, 275, 1211, 8, 267, 8002, 29, 807, 8, 885, 29, 403, 395, 267, 1790, 63, 466, 29, 807, 8, 885, 29, 403, 395, 267, 1790, 29, 807, 8, 885, 29, 403, 12, 730, 534, 807, 297, 949, 63, 793, 29, 549, 395, 267, 4897, 63, 354, 29, 807, 8, 885, 29, 403, 395, 267, 14962, 63, 2619, 29, 807, 8, 885, 29, 403, 395, 267, 4911, 29, 807, 8, 885, 29, 403, 12, 730, 534, 2245, 297, 5481, 2968, 3502, 63, 8356, 3815, 267, 286, 645, 15299, 29, 807, 8, 885, 29, 403, 395, 267, 6250, 29, 807, 8, 885, 29, 403, 395, 267, 790, 29, 807, 8, 885, 29, 403, 12, 949, 63, 793, 29, 549, 395, 267, 3618, 29, 807, 8, 885, 29, 549, 12, 730, 534, 2245, 659, 267, 2653, 29, 807, 8, 885, 29, 7663, 12, 730, 534, 442, 659, 267, 2986, 63, 2593, 29, 807, 8, 885, 29, 403, 12 ]
[ 961, 1233, 365, 1777, 402, 2622, 12, 1325, 365, 376, 12717, 3931, 14, 199, 3, 961, 6770, 570, 17440, 12, 436, 642, 570, 17440, 1454, 12, 365, 6289, 18233, 14, 199, 3, 18167, 1265, 2218, 1808, 642, 17440, 12, 1314, 365, 12169, 18774, 701, 2622, 199, 3, 5139, 13511, 370, 314, 4132, 402, 314, 859, 12, 436, 1443, 5090, 3932, 5705, 4190, 199, 3, 370, 314, 4890, 1736, 14, 199, 3, 199, 3, 1898, 334, 67, 9, 6927, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 2900, 4481, 4644, 14, 199, 3, 199, 3, 10114, 436, 675, 315, 1350, 436, 3366, 4513, 12, 543, 503, 1928, 7100, 12, 199, 3, 787, 8211, 2741, 626, 314, 2569, 3704, 787, 7647, 26, 199, 3, 199, 3, 259, 627, 6823, 402, 1350, 1233, 1471, 8074, 314, 3432, 4248, 199, 3, 420, 4245, 12, 642, 769, 402, 3704, 436, 314, 2569, 6450, 14, 199, 3, 259, 627, 6823, 315, 3366, 1824, 1471, 9172, 314, 3432, 4248, 4245, 12, 199, 3, 420, 642, 769, 402, 3704, 436, 314, 2569, 6450, 315, 314, 3794, 199, 3, 420, 436, 15, 269, 1163, 8418, 2741, 543, 314, 4084, 14, 199, 3, 199, 3, 5749, 4141, 2281, 7049, 6515, 2334, 5877, 8164, 2401, 6483, 298, 1179, 2281, 2, 2401, 199, 3, 1821, 7168, 1549, 5292, 2990, 12, 6931, 12, 5400, 2845, 5471, 2296, 12, 2334, 5292, 199, 3, 2990, 1634, 3169, 2401, 3092, 2381, 437, 3115, 3104, 9315, 9706, 14, 199, 3, 1621, 4825, 6461, 7000, 2334, 5877, 29785, 1549, 6483, 6262, 7024, 2381, 1821, 8703, 12, 9168, 12, 199, 3, 9716, 12, 8820, 12, 9836, 12, 1549, 9110, 6736, 334, 6446, 12, 5400, 2845, 5471, 2296, 12, 199, 3, 9838, 1634, 9103, 9764, 1549, 9714, 27, 9102, 1634, 4815, 12, 7126, 12, 1549, 9206, 27, 1549, 9748, 199, 3, 9831, 9, 9802, 9817, 2401, 5258, 1821, 9815, 1634, 5603, 12, 7061, 1621, 7066, 12, 9644, 199, 3, 5603, 12, 1549, 7056, 334, 6446, 9254, 1549, 7334, 9, 7043, 1621, 1821, 9683, 5738, 1634, 2334, 199, 3, 4815, 1634, 5749, 4141, 12, 9704, 8036, 9691, 1634, 2334, 9726, 1634, 9712, 9784, 14, 199, 199, 646, 747, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4174, 492, 10849, 199, 199, 318, 13869, 63, 2094, 63, 1650, 837, 272, 327, 31404, 26, 961, 1423, 3158, 365, 1454, 1202, 367, 314, 5906, 2269, 272, 327, 14260, 4621, 14, 2779, 25449, 734, 626, 818, 11641, 14260, 1790, 365, 9683, 272, 327, 1655, 6114, 2419, 642, 14, 272, 327, 1448, 3639, 4465, 14260, 3734, 2860, 14, 272, 327, 961, 365, 27580, 1454, 2997, 367, 1503, 13, 20402, 1414, 1004, 3439, 465, 272, 327, 315, 5232, 8858, 1373, 3955, 5534, 2860, 3955, 506, 1202, 22497, 272, 4403, 63, 5580, 63, 2632, 29, 736, 14, 2314, 14, 362, 360, 3100, 63, 5580, 63, 2632, 297, 283, 1014, 921, 4195, 14, 16, 14, 16, 14, 17, 26, 1276, 13155, 15, 86, 18, 14, 16, 6217, 272, 4403, 63, 9032, 29, 736, 14, 2314, 14, 362, 360, 3100, 63, 9032, 297, 488, 9, 272, 4403, 63, 23030, 63, 2339, 29, 736, 14, 2314, 14, 362, 360, 3100, 63, 23030, 63, 2339, 297, 488, 9, 272, 4403, 63, 11958, 29, 736, 14, 2314, 14, 362, 360, 3100, 63, 11958, 297, 283, 2113, 358, 272, 4403, 63, 52, 31718, 63, 2339, 29, 736, 14, 2314, 14, 362, 360, 3100, 63, 52, 31718, 63, 2339, 297, 4403, 63, 11958, 9, 339, 3158, 275, 1211, 8, 267, 4676, 63, 2473, 8295, 275, 1211, 8, 885, 29, 3100, 63, 11958, 395, 267, 1790, 63, 633, 12788, 275, 1211, 8, 885, 29, 3100, 63, 5580, 63, 2632, 395, 267, 4897, 63, 354, 9326, 275, 1211, 8, 885, 29, 3100, 63, 23030, 63, 2339, 395, 267, 14962, 63, 2619, 5185, 275, 1211, 8, 885, 29, 403, 395, 272, 776, 272, 340, 4403, 63, 9032, 26, 267, 3158, 459, 2886, 63, 2060, 418, 275, 1211, 8, 885, 29, 3100, 63, 9032, 9, 272, 587, 26, 267, 3158, 459, 2886, 63, 2060, 418, 275, 1211, 8, 2427, 29, 549, 9, 272, 340, 4403, 63, 52, 31718, 63, 2339, 26, 267, 3158, 459, 2886, 63, 4647, 63, 354, 418, 275, 1211, 8, 885, 29, 3100, 63, 52, 31718, 63, 2339, 9, 272, 587, 26, 267, 3158, 459, 2886, 63, 4647, 63, 354, 418, 275, 1211, 8, 2427, 29, 549, 9, 272, 372, 3158, 199, 199, 318, 13869, 63, 1623, 63, 6765, 63, 7423, 8, 7423, 12, 1599, 63, 1450, 12, 790, 63, 354, 29, 403, 304, 339, 2203, 275, 942, 272, 367, 334, 75, 12, 373, 9, 315, 10849, 8, 7423, 304, 267, 340, 790, 63, 354, 436, 1022, 508, 790, 63, 354, 26, 288, 2203, 14, 2880, 779, 18942, 459, 2697, 418, 367, 29259, 315, 373, 566, 267, 587, 26, 288, 367, 3217, 63, 1650, 315, 373, 26, 355, 340, 283, 3100, 13, 2472, 13, 12346, 26, 466, 7, 315, 3217, 63, 1650, 436, 3217, 63, 1650, 459, 3100, 13, 2472, 13, 12346, 26, 466, 418, 508, 1599, 63, 1450, 26, 490, 2203, 14, 740, 8, 3266, 63, 1650, 459, 2697, 1105, 272, 372, 2203, 199, 199, 318, 13869, 63, 2861, 63, 2094, 63, 1650, 3682, 958, 304, 272, 3158, 275, 1211, 8, 267, 8002, 29, 807, 8, 885, 29, 403, 395, 267, 1790, 63, 466, 29, 807, 8, 885, 29, 403, 395, 267, 1790, 29, 807, 8, 885, 29, 403, 12, 730, 534, 807, 297, 949, 63, 793, 29, 549, 395, 267, 4897, 63, 354, 29, 807, 8, 885, 29, 403, 395, 267, 14962, 63, 2619, 29, 807, 8, 885, 29, 403, 395, 267, 4911, 29, 807, 8, 885, 29, 403, 12, 730, 534, 2245, 297, 5481, 2968, 3502, 63, 8356, 3815, 267, 286, 645, 15299, 29, 807, 8, 885, 29, 403, 395, 267, 6250, 29, 807, 8, 885, 29, 403, 395, 267, 790, 29, 807, 8, 885, 29, 403, 12, 949, 63, 793, 29, 549, 395, 267, 3618, 29, 807, 8, 885, 29, 549, 12, 730, 534, 2245, 659, 267, 2653, 29, 807, 8, 885, 29, 7663, 12, 730, 534, 442, 659, 267, 2986, 63, 2593, 29, 807, 8, 885, 29, 403, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
EVERROCKET/mobile-data
googleapiclient/discovery_cache/file_cache.py
35
4028
# Copyright 2014 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """File based cache for the discovery document. The cache is stored in a single file so that multiple processes can share the same cache. It locks the file whenever accesing to the file. When the cache content is corrupted, it will be initialized with an empty cache. """ from __future__ import division import datetime import json import logging import os import tempfile import threading from oauth2client.locked_file import LockedFile from . import base from ..discovery_cache import DISCOVERY_DOC_MAX_AGE logger = logging.getLogger(__name__) FILENAME = 'google-api-python-client-discovery-doc.cache' EPOCH = datetime.datetime.utcfromtimestamp(0) def _to_timestamp(date): try: return (date - EPOCH).total_seconds() except AttributeError: # The following is the equivalent of total_seconds() in Python2.6. # See also: https://docs.python.org/2/library/datetime.html delta = date - EPOCH return ((delta.microseconds + (delta.seconds + delta.days * 24 * 3600) * 10**6) / 10**6) def _read_or_initialize_cache(f): f.file_handle().seek(0) try: cache = json.load(f.file_handle()) except Exception: # This means it opens the file for the first time, or the cache is # corrupted, so initializing the file with an empty dict. cache = {} f.file_handle().truncate(0) f.file_handle().seek(0) json.dump(cache, f.file_handle()) return cache class Cache(base.Cache): """A file based cache for the discovery documents.""" def __init__(self, max_age): """Constructor. Args: max_age: Cache expiration in seconds. """ self._max_age = max_age self._file = os.path.join(tempfile.gettempdir(), FILENAME) f = LockedFile(self._file, 'a+', 'r') try: f.open_and_lock() if f.is_locked(): _read_or_initialize_cache(f) # If we can not obtain the lock, other process or thread must # have initialized the file. except Exception as e: logging.warning(e, exc_info=True) finally: f.unlock_and_close() def get(self, url): f = LockedFile(self._file, 'r+', 'r') try: f.open_and_lock() if f.is_locked(): cache = _read_or_initialize_cache(f) if url in cache: content, t = cache.get(url, (None, 0)) if _to_timestamp(datetime.datetime.now()) < t + self._max_age: return content return None else: logger.debug('Could not obtain a lock for the cache file.') return None except Exception as e: logger.warning(e, exc_info=True) finally: f.unlock_and_close() def set(self, url, content): f = LockedFile(self._file, 'r+', 'r') try: f.open_and_lock() if f.is_locked(): cache = _read_or_initialize_cache(f) cache[url] = (content, _to_timestamp(datetime.datetime.now())) # Remove stale cache. for k, (_, timestamp) in list(cache.items()): if _to_timestamp(datetime.datetime.now()) >= timestamp + self._max_age: del cache[k] f.file_handle().truncate(0) f.file_handle().seek(0) json.dump(cache, f.file_handle()) else: logger.debug('Could not obtain a lock for the cache file.') except Exception as e: logger.warning(e, exc_info=True) finally: f.unlock_and_close() cache = Cache(max_age=DISCOVERY_DOC_MAX_AGE)
apache-2.0
[ 3, 1898, 6927, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 1173, 4079, 2581, 367, 314, 13172, 2213, 14, 199, 199, 1918, 2581, 365, 5489, 315, 282, 2849, 570, 880, 626, 3663, 10358, 883, 199, 6251, 314, 2011, 2581, 14, 2779, 23340, 314, 570, 18119, 1066, 823, 316, 370, 314, 199, 493, 14, 3979, 314, 2581, 1564, 365, 1970, 15692, 12, 652, 911, 506, 10038, 543, 199, 290, 2701, 2581, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 2197, 199, 646, 2022, 199, 646, 2050, 199, 646, 747, 199, 646, 5549, 199, 646, 5796, 199, 199, 504, 9725, 18, 1258, 14, 9325, 63, 493, 492, 15536, 379, 1173, 199, 199, 504, 1275, 492, 1300, 199, 504, 2508, 14859, 63, 1637, 492, 7587, 19052, 57, 63, 16618, 63, 4283, 63, 2962, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 15440, 275, 283, 3098, 13, 1246, 13, 1548, 13, 1258, 13, 14859, 13, 1301, 14, 1637, 7, 199, 37, 1512, 1244, 275, 2197, 14, 2083, 14, 5834, 18531, 8, 16, 9, 421, 199, 318, 485, 475, 63, 3954, 8, 602, 304, 523, 862, 26, 272, 372, 334, 602, 446, 662, 1512, 1244, 680, 2923, 63, 4515, 342, 523, 871, 4281, 26, 272, 327, 710, 2569, 365, 314, 7353, 402, 3141, 63, 4515, 342, 315, 2018, 18, 14, 22, 14, 272, 327, 1666, 2597, 26, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 2083, 14, 1360, 272, 5762, 275, 1434, 446, 662, 1512, 1244, 272, 372, 3666, 3136, 14, 18144, 435, 334, 3136, 14, 4515, 435, 5762, 14, 4899, 627, 5504, 627, 15751, 9, 1467, 627, 1616, 538, 22, 9, 1182, 1616, 538, 22, 9, 421, 199, 318, 485, 739, 63, 269, 63, 8489, 63, 1637, 8, 70, 304, 523, 289, 14, 493, 63, 2479, 1252, 5507, 8, 16, 9, 523, 862, 26, 272, 2581, 275, 2022, 14, 912, 8, 70, 14, 493, 63, 2479, 1012, 523, 871, 2186, 26, 272, 327, 961, 4910, 652, 30848, 314, 570, 367, 314, 1642, 900, 12, 503, 314, 2581, 365, 272, 327, 1970, 15692, 12, 880, 29141, 314, 570, 543, 376, 2701, 1211, 14, 272, 2581, 275, 1052, 272, 289, 14, 493, 63, 2479, 1252, 12517, 8, 16, 9, 272, 289, 14, 493, 63, 2479, 1252, 5507, 8, 16, 9, 272, 2022, 14, 2724, 8, 1637, 12, 289, 14, 493, 63, 2479, 1012, 523, 372, 2581, 421, 199, 533, 11977, 8, 1095, 14, 4437, 304, 523, 408, 33, 570, 4079, 2581, 367, 314, 13172, 8247, 1041, 819, 347, 636, 826, 721, 277, 12, 1390, 63, 474, 304, 489, 408, 11447, 14, 2541, 3033, 26, 267, 1390, 63, 474, 26, 11977, 15399, 315, 4696, 14, 489, 408, 489, 291, 423, 988, 63, 474, 275, 1390, 63, 474, 489, 291, 423, 493, 275, 747, 14, 515, 14, 904, 8, 17336, 14, 31572, 1062, 16444, 11536, 9, 489, 289, 275, 15536, 379, 1173, 8, 277, 423, 493, 12, 283, 65, 7386, 283, 82, 358, 489, 862, 26, 267, 289, 14, 1490, 63, 460, 63, 831, 342, 267, 340, 289, 14, 374, 63, 9325, 837, 881, 485, 739, 63, 269, 63, 8489, 63, 1637, 8, 70, 9, 267, 327, 982, 781, 883, 440, 3332, 314, 4650, 12, 1163, 2112, 503, 2462, 1471, 267, 327, 1172, 10038, 314, 570, 14, 489, 871, 2186, 465, 325, 26, 267, 2050, 14, 3764, 8, 69, 12, 3178, 63, 815, 29, 549, 9, 489, 3753, 26, 267, 289, 14, 17966, 63, 460, 63, 1600, 342, 819, 347, 664, 8, 277, 12, 1166, 304, 272, 289, 275, 15536, 379, 1173, 8, 277, 423, 493, 12, 283, 82, 7386, 283, 82, 358, 272, 862, 26, 489, 289, 14, 1490, 63, 460, 63, 831, 342, 489, 340, 289, 14, 374, 63, 9325, 837, 267, 2581, 275, 485, 739, 63, 269, 63, 8489, 63, 1637, 8, 70, 9, 267, 340, 1166, 315, 2581, 26, 881, 1564, 12, 307, 275, 2581, 14, 362, 8, 633, 12, 334, 403, 12, 378, 430, 881, 340, 485, 475, 63, 3954, 8, 2083, 14, 2083, 14, 2131, 1012, 665, 307, 435, 291, 423, 988, 63, 474, 26, 288, 372, 1564, 267, 372, 488, 489, 587, 26, 267, 2512, 14, 1757, 360, 6531, 440, 3332, 282, 4650, 367, 314, 2581, 570, 2659, 267, 372, 488, 272, 871, 2186, 465, 325, 26, 489, 2512, 14, 3764, 8, 69, 12, 3178, 63, 815, 29, 549, 9, 272, 3753, 26, 489, 289, 14, 17966, 63, 460, 63, 1600, 342, 819, 347, 663, 8, 277, 12, 1166, 12, 1564, 304, 272, 289, 275, 15536, 379, 1173, 8, 277, 423, 493, 12, 283, 82, 7386, 283, 82, 358, 272, 862, 26, 489, 289, 14, 1490, 63, 460, 63, 831, 342, 489, 340, 289, 14, 374, 63, 9325, 837, 267, 2581, 275, 485, 739, 63, 269, 63, 8489, 63, 1637, 8, 70, 9, 267, 2581, 59, 633, 61, 275, 334, 1317, 12, 485, 475, 63, 3954, 8, 2083, 14, 2083, 14, 2131, 4059, 267, 327, 5852, 20149, 2581, 14, 267, 367, 1022, 12, 27017, 4913, 9, 315, 769, 8, 1637, 14, 1744, 5109, 881, 340, 485, 475, 63, 3954, 8, 2083, 14, 2083, 14, 2131, 1012, 2356, 4913, 435, 291, 423, 988, 63, 474, 26, 288, 2150, 2581, 59, 75, 61, 267, 289, 14, 493, 63, 2479, 1252, 12517, 8, 16, 9, 267, 289, 14, 493, 63, 2479 ]
[ 1898, 6927, 4475, 3277, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 1173, 4079, 2581, 367, 314, 13172, 2213, 14, 199, 199, 1918, 2581, 365, 5489, 315, 282, 2849, 570, 880, 626, 3663, 10358, 883, 199, 6251, 314, 2011, 2581, 14, 2779, 23340, 314, 570, 18119, 1066, 823, 316, 370, 314, 199, 493, 14, 3979, 314, 2581, 1564, 365, 1970, 15692, 12, 652, 911, 506, 10038, 543, 199, 290, 2701, 2581, 14, 199, 624, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 2197, 199, 646, 2022, 199, 646, 2050, 199, 646, 747, 199, 646, 5549, 199, 646, 5796, 199, 199, 504, 9725, 18, 1258, 14, 9325, 63, 493, 492, 15536, 379, 1173, 199, 199, 504, 1275, 492, 1300, 199, 504, 2508, 14859, 63, 1637, 492, 7587, 19052, 57, 63, 16618, 63, 4283, 63, 2962, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 15440, 275, 283, 3098, 13, 1246, 13, 1548, 13, 1258, 13, 14859, 13, 1301, 14, 1637, 7, 199, 37, 1512, 1244, 275, 2197, 14, 2083, 14, 5834, 18531, 8, 16, 9, 421, 199, 318, 485, 475, 63, 3954, 8, 602, 304, 523, 862, 26, 272, 372, 334, 602, 446, 662, 1512, 1244, 680, 2923, 63, 4515, 342, 523, 871, 4281, 26, 272, 327, 710, 2569, 365, 314, 7353, 402, 3141, 63, 4515, 342, 315, 2018, 18, 14, 22, 14, 272, 327, 1666, 2597, 26, 4178, 921, 4757, 14, 1548, 14, 1308, 15, 18, 15, 4342, 15, 2083, 14, 1360, 272, 5762, 275, 1434, 446, 662, 1512, 1244, 272, 372, 3666, 3136, 14, 18144, 435, 334, 3136, 14, 4515, 435, 5762, 14, 4899, 627, 5504, 627, 15751, 9, 1467, 627, 1616, 538, 22, 9, 1182, 1616, 538, 22, 9, 421, 199, 318, 485, 739, 63, 269, 63, 8489, 63, 1637, 8, 70, 304, 523, 289, 14, 493, 63, 2479, 1252, 5507, 8, 16, 9, 523, 862, 26, 272, 2581, 275, 2022, 14, 912, 8, 70, 14, 493, 63, 2479, 1012, 523, 871, 2186, 26, 272, 327, 961, 4910, 652, 30848, 314, 570, 367, 314, 1642, 900, 12, 503, 314, 2581, 365, 272, 327, 1970, 15692, 12, 880, 29141, 314, 570, 543, 376, 2701, 1211, 14, 272, 2581, 275, 1052, 272, 289, 14, 493, 63, 2479, 1252, 12517, 8, 16, 9, 272, 289, 14, 493, 63, 2479, 1252, 5507, 8, 16, 9, 272, 2022, 14, 2724, 8, 1637, 12, 289, 14, 493, 63, 2479, 1012, 523, 372, 2581, 421, 199, 533, 11977, 8, 1095, 14, 4437, 304, 523, 408, 33, 570, 4079, 2581, 367, 314, 13172, 8247, 1041, 819, 347, 636, 826, 721, 277, 12, 1390, 63, 474, 304, 489, 408, 11447, 14, 2541, 3033, 26, 267, 1390, 63, 474, 26, 11977, 15399, 315, 4696, 14, 489, 408, 489, 291, 423, 988, 63, 474, 275, 1390, 63, 474, 489, 291, 423, 493, 275, 747, 14, 515, 14, 904, 8, 17336, 14, 31572, 1062, 16444, 11536, 9, 489, 289, 275, 15536, 379, 1173, 8, 277, 423, 493, 12, 283, 65, 7386, 283, 82, 358, 489, 862, 26, 267, 289, 14, 1490, 63, 460, 63, 831, 342, 267, 340, 289, 14, 374, 63, 9325, 837, 881, 485, 739, 63, 269, 63, 8489, 63, 1637, 8, 70, 9, 267, 327, 982, 781, 883, 440, 3332, 314, 4650, 12, 1163, 2112, 503, 2462, 1471, 267, 327, 1172, 10038, 314, 570, 14, 489, 871, 2186, 465, 325, 26, 267, 2050, 14, 3764, 8, 69, 12, 3178, 63, 815, 29, 549, 9, 489, 3753, 26, 267, 289, 14, 17966, 63, 460, 63, 1600, 342, 819, 347, 664, 8, 277, 12, 1166, 304, 272, 289, 275, 15536, 379, 1173, 8, 277, 423, 493, 12, 283, 82, 7386, 283, 82, 358, 272, 862, 26, 489, 289, 14, 1490, 63, 460, 63, 831, 342, 489, 340, 289, 14, 374, 63, 9325, 837, 267, 2581, 275, 485, 739, 63, 269, 63, 8489, 63, 1637, 8, 70, 9, 267, 340, 1166, 315, 2581, 26, 881, 1564, 12, 307, 275, 2581, 14, 362, 8, 633, 12, 334, 403, 12, 378, 430, 881, 340, 485, 475, 63, 3954, 8, 2083, 14, 2083, 14, 2131, 1012, 665, 307, 435, 291, 423, 988, 63, 474, 26, 288, 372, 1564, 267, 372, 488, 489, 587, 26, 267, 2512, 14, 1757, 360, 6531, 440, 3332, 282, 4650, 367, 314, 2581, 570, 2659, 267, 372, 488, 272, 871, 2186, 465, 325, 26, 489, 2512, 14, 3764, 8, 69, 12, 3178, 63, 815, 29, 549, 9, 272, 3753, 26, 489, 289, 14, 17966, 63, 460, 63, 1600, 342, 819, 347, 663, 8, 277, 12, 1166, 12, 1564, 304, 272, 289, 275, 15536, 379, 1173, 8, 277, 423, 493, 12, 283, 82, 7386, 283, 82, 358, 272, 862, 26, 489, 289, 14, 1490, 63, 460, 63, 831, 342, 489, 340, 289, 14, 374, 63, 9325, 837, 267, 2581, 275, 485, 739, 63, 269, 63, 8489, 63, 1637, 8, 70, 9, 267, 2581, 59, 633, 61, 275, 334, 1317, 12, 485, 475, 63, 3954, 8, 2083, 14, 2083, 14, 2131, 4059, 267, 327, 5852, 20149, 2581, 14, 267, 367, 1022, 12, 27017, 4913, 9, 315, 769, 8, 1637, 14, 1744, 5109, 881, 340, 485, 475, 63, 3954, 8, 2083, 14, 2083, 14, 2131, 1012, 2356, 4913, 435, 291, 423, 988, 63, 474, 26, 288, 2150, 2581, 59, 75, 61, 267, 289, 14, 493, 63, 2479, 1252, 12517, 8, 16, 9, 267, 289, 14, 493, 63, 2479, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
DavidNorman/tensorflow
tensorflow/python/ops/parallel_for/gradients_test.py
9
27916
# Copyright 2018 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for jacobian and batch_jacobian ops.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import functools import os import time import numpy as np from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import dtypes from tensorflow.python.framework import errors from tensorflow.python.framework import ops from tensorflow.python.framework import test_util from tensorflow.python.keras.engine import training as keras_training from tensorflow.python.layers import layers as tf_layers from tensorflow.python.ops import array_ops from tensorflow.python.ops import control_flow_ops as tf_control_flow_ops from tensorflow.python.ops import functional_ops from tensorflow.python.ops import gradients as gradient_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import nn from tensorflow.python.ops import random_ops from tensorflow.python.ops import rnn from tensorflow.python.ops import rnn_cell from tensorflow.python.ops import variables from tensorflow.python.ops.losses import losses from tensorflow.python.ops.parallel_for import control_flow_ops from tensorflow.python.ops.parallel_for import gradients from tensorflow.python.platform import test from tensorflow.python.util import nest class FullyConnectedModel(object): def __init__(self, activation_size, num_layers): self._layers = [ tf_layers.Dense(activation_size, activation=nn.relu) for _ in range(num_layers) ] def __call__(self, inp): activation = inp for layer in self._layers: activation = layer(activation) return activation def fully_connected_model_fn(batch_size, activation_size, num_layers): model = FullyConnectedModel(activation_size, num_layers) inp = random_ops.random_normal([batch_size, activation_size]) return inp, model(inp) def lstm_model_fn(batch_size, state_size, steps, inputs_size=None): inputs_size = inputs_size or state_size inputs = [ random_ops.random_normal([batch_size, inputs_size]) for _ in range(steps) ] cell = rnn_cell.BasicLSTMCell(state_size) init_state = cell.zero_state(batch_size, dtypes.float32) state = init_state for inp in inputs: _, state = cell(inp, state) return init_state.c, state.c def dynamic_lstm_model_fn(batch_size, state_size, max_steps): # We make inputs and sequence_length constant so that multiple session.run # calls produce the same result. inputs = constant_op.constant( np.random.rand(batch_size, max_steps, state_size), dtype=dtypes.float32) sequence_length = constant_op.constant( np.random.randint(0, size=[batch_size], high=max_steps + 1), dtype=dtypes.int32) cell = rnn_cell.BasicLSTMCell(state_size) initial_state = cell.zero_state(batch_size, dtypes.float32) return inputs, rnn.dynamic_rnn( cell, inputs, sequence_length=sequence_length, initial_state=initial_state) def create_fc_batch_jacobian(batch_size, activation_size, num_layers): inp, output = fully_connected_model_fn(batch_size, activation_size, num_layers) pfor_jacobian = gradients.batch_jacobian(output, inp, use_pfor=True) while_jacobian = gradients.batch_jacobian(output, inp, use_pfor=False) return pfor_jacobian, while_jacobian def create_lstm_batch_jacobian(batch_size, state_size, steps, inputs_size=None): inp, output = lstm_model_fn(batch_size, state_size, steps, inputs_size=inputs_size) pfor_jacobian = gradients.batch_jacobian(output, inp, use_pfor=True) while_jacobian = gradients.batch_jacobian(output, inp, use_pfor=False) return pfor_jacobian, while_jacobian def create_dynamic_lstm_batch_jacobian(batch_size, state_size, max_steps): inp, (_, final_state) = dynamic_lstm_model_fn(batch_size, state_size, max_steps) pfor_jacobian = gradients.batch_jacobian(final_state.c, inp, use_pfor=True) # Note that use_pfor=False does not work above given the current limitations # on implementation of while_loop. So we statically unroll the looping in the # jacobian computation. while_gradients = [ gradient_ops.gradients(array_ops.gather(final_state.c, i, axis=1), inp)[0] for i in range(state_size) ] return pfor_jacobian, while_gradients def create_lstm_batch_hessian(batch_size, state_size, steps): inp, output = lstm_model_fn(batch_size, state_size, steps) pfor_jacobian = gradients.batch_jacobian(output, inp, use_pfor=True) pfor_jacobian = array_ops.reshape(pfor_jacobian, [batch_size, -1]) pfor_hessian = gradients.batch_jacobian(pfor_jacobian, inp, use_pfor=True) # TODO(agarwal): using two nested while_loop doesn't seem to work here. # Hence we use pfor_jacobian for computing while_hessian. while_jacobian = pfor_jacobian while_hessian = gradients.batch_jacobian(while_jacobian, inp, use_pfor=False) return pfor_hessian, while_hessian def create_lstm_hessian(batch_size, state_size, steps): _, output = lstm_model_fn(batch_size, state_size, steps) weights = variables.trainable_variables() pfor_jacobians = gradients.jacobian(output, weights, use_pfor=True) pfor_hessians = [ gradients.jacobian(x, weights, use_pfor=True) for x in pfor_jacobians ] # TODO(agarwal): using two nested while_loop doesn't seem to work here. # Hence we use pfor_jacobians for computing while_hessians. while_jacobians = pfor_jacobians while_hessians = [ gradients.jacobian(x, weights, use_pfor=False) for x in while_jacobians ] return pfor_hessians, while_hessians def create_fc_per_eg_grad(batch_size, activation_size, num_layers): inp = random_ops.random_normal([batch_size, activation_size]) layers = [ tf_layers.Dense(activation_size, activation=nn.relu) for _ in range(num_layers) ] projection = tf_layers.Dense(1) def model_fn(activation): for layer in layers: activation = layer(activation) activation = projection(activation) activation = nn.l2_loss(activation) return gradient_ops.gradients(activation, variables.trainable_variables()) def loop_fn(i): return model_fn(array_ops.expand_dims(array_ops.gather(inp, i), 0)) pfor_outputs = control_flow_ops.pfor(loop_fn, batch_size) loop_fn_dtypes = [x.dtype for x in variables.trainable_variables()] while_outputs = control_flow_ops.for_loop(loop_fn, loop_fn_dtypes, batch_size) return pfor_outputs, while_outputs def create_lstm_per_eg_grad(batch_size, state_size, steps, inputs_size=None): inputs_size = inputs_size or state_size inputs = [ random_ops.random_normal([batch_size, inputs_size]) for _ in range(steps) ] cell = rnn_cell.BasicLSTMCell(state_size) init_state = cell.zero_state(batch_size, dtypes.float32) def model_fn(inps, init_state): state = init_state for inp in inps: _, state = cell(inp, state) output = nn.l2_loss(state.c) return gradient_ops.gradients(output, variables.trainable_variables()) def loop_fn(i): loop_inputs = [ array_ops.expand_dims(array_ops.gather(x, i), 0) for x in inputs ] loop_init_state = rnn_cell.LSTMStateTuple( *[array_ops.expand_dims(array_ops.gather(x, i), 0) for x in init_state]) return model_fn(loop_inputs, loop_init_state) pfor_outputs = control_flow_ops.pfor(loop_fn, batch_size) loop_fn_dtypes = [x.dtype for x in variables.trainable_variables()] while_outputs = control_flow_ops.for_loop(loop_fn, loop_fn_dtypes, batch_size) return pfor_outputs, while_outputs # Importing the code from tensorflow_models seems to cause errors. Hence we # duplicate the model definition here. # TODO(agarwal): Use the version in tensorflow_models/official instead. class Mnist(keras_training.Model): def __init__(self, data_format): """Creates a model for classifying a hand-written digit. Args: data_format: Either 'channels_first' or 'channels_last'. """ super(Mnist, self).__init__() if data_format == "channels_first": self._input_shape = [-1, 1, 28, 28] else: assert data_format == "channels_last" self._input_shape = [-1, 28, 28, 1] self.conv1 = tf_layers.Conv2D( 32, 5, padding="same", data_format=data_format, activation=nn.relu) self.conv2 = tf_layers.Conv2D( 64, 5, padding="same", data_format=data_format, activation=nn.relu) self.fc1 = tf_layers.Dense(1024, activation=nn.relu) self.fc2 = tf_layers.Dense(10) self.dropout = tf_layers.Dropout(0.4) self.max_pool2d = tf_layers.MaxPooling2D( (2, 2), (2, 2), padding="same", data_format=data_format) def __call__(self, inputs, training): """Add operations to classify a batch of input images. Args: inputs: A Tensor representing a batch of input images. training: A boolean. Set to True to add operations required only when training the classifier. Returns: A logits Tensor with shape [<batch_size>, 10]. """ y = array_ops.reshape(inputs, self._input_shape) y = self.conv1(y) y = self.max_pool2d(y) y = self.conv2(y) y = self.max_pool2d(y) y = tf_layers.flatten(y) y = self.fc1(y) y = self.dropout(y, training=training) return self.fc2(y) def create_mnist_autobatch(batch_size, data_format, training): images = random_ops.random_uniform([batch_size, 28, 28]) model = Mnist(data_format) manual = model(images, training=training) def loop_fn(i): image = array_ops.gather(images, i) return model(image, training=training) pfor_outputs = control_flow_ops.pfor(loop_fn, batch_size) while_outputs = control_flow_ops.for_loop( loop_fn, dtypes.float32, batch_size) return pfor_outputs, while_outputs, manual def create_mnist_per_eg_grad(batch_size, data_format, training): images = random_ops.random_uniform([batch_size, 28, 28]) sparse_labels = np.random.randint( low=0, high=10, size=[batch_size]).astype(np.int32) labels = np.zeros((batch_size, 10)).astype(np.float32) labels[np.arange(batch_size), sparse_labels] = 1. model = Mnist(data_format) def loop_fn(i): image = array_ops.gather(images, i) label = array_ops.gather(labels, i) logits = array_ops.reshape(model(image, training=training), [-1]) loss = losses.softmax_cross_entropy( logits=logits, onehot_labels=label, reduction=losses.Reduction.NONE) return gradient_ops.gradients(loss, variables.trainable_variables()) pfor_outputs = control_flow_ops.pfor(loop_fn, batch_size) while_outputs = control_flow_ops.for_loop( loop_fn, [dtypes.float32] * len(variables.trainable_variables()), batch_size) return pfor_outputs, while_outputs def create_mnist_batch_jacobian(batch_size, data_format, training): images = random_ops.random_uniform([batch_size, 28, 28]) model = Mnist(data_format) logits = model(images, training=training) pfor_jacobian = gradients.batch_jacobian(logits, images, use_pfor=True) while_jacobian = gradients.batch_jacobian(logits, images, use_pfor=False) return pfor_jacobian, while_jacobian def create_mnist_per_eg_jacobian(batch_size, data_format, training): images = random_ops.random_uniform([batch_size, 28, 28]) model = Mnist(data_format) def loop_fn(i, use_pfor): image = array_ops.gather(images, i) logits = array_ops.reshape(model(image, training=training), [-1]) return gradients.jacobian( logits, variables.trainable_variables(), use_pfor=use_pfor) pfor_outputs = control_flow_ops.pfor( functools.partial(loop_fn, use_pfor=True), batch_size) while_outputs = control_flow_ops.for_loop( functools.partial(loop_fn, use_pfor=False), [dtypes.float32] * len(variables.trainable_variables()), batch_size) return pfor_outputs, while_outputs def create_fc_per_eg_jacobians(batch_size, activation_size, num_layers): model = FullyConnectedModel(activation_size=activation_size, num_layers=num_layers) inp = random_ops.random_normal([batch_size, activation_size]) output = model(inp) jacobians = gradients.jacobian(output, variables.trainable_variables()) def loop_fn(i, use_pfor): inp_i = array_ops.expand_dims(array_ops.gather(inp, i), 0) output = array_ops.reshape(model(inp_i), [-1]) return gradients.jacobian( output, variables.trainable_variables(), use_pfor=use_pfor) per_eg_jacobians_pfor = control_flow_ops.pfor( functools.partial(loop_fn, use_pfor=True), batch_size) per_eg_jacobians_while = control_flow_ops.for_loop( functools.partial(loop_fn, use_pfor=False), [dtypes.float32] * len(variables.trainable_variables()), batch_size) return jacobians, per_eg_jacobians_pfor, per_eg_jacobians_while @test_util.run_v1_only("b/122612051") class GradientsTest(test.TestCase): def run_and_assert_equal(self, targets1, targets2, atol=1e-4, rtol=1e-4): targets1 = nest.flatten(targets1) targets2 = nest.flatten(targets2) assert len(targets1) == len(targets2) init = variables.global_variables_initializer() self.evaluate(init) outputs = self.evaluate(targets1 + targets2) n = len(outputs) // 2 for i in range(n): self.assertAllClose(outputs[i], outputs[i + n], rtol=rtol, atol=atol) def test_no_path(self): for grad_func in [gradients.jacobian, gradients.batch_jacobian]: for use_pfor in [True, False]: x = constant_op.constant([[1.0]]) y = constant_op.constant([[2.0]]) self.assertIsNone(grad_func(y, x, use_pfor=use_pfor)) def test_jacobian_fixed_shape(self): x = random_ops.random_uniform([2, 2]) y = math_ops.matmul(x, x, transpose_a=True) jacobian_pfor = gradients.jacobian(y, x, use_pfor=True) jacobian_while = gradients.jacobian(y, x, use_pfor=False) answer = ops.convert_to_tensor([[ gradient_ops.gradients(y[0][0], x)[0], gradient_ops.gradients(y[0][1], x)[0] ], [ gradient_ops.gradients(y[1][0], x)[0], gradient_ops.gradients(y[1][1], x)[0] ]]) self.run_and_assert_equal(answer, jacobian_pfor) self.run_and_assert_equal(answer, jacobian_while) def test_jacobian_scan_shape(self): # Shape x: [3, 4] x = random_ops.random_uniform([3, 4]) elems = random_ops.random_uniform([6]) # Shape y: [6, 3, 4] y = functional_ops.scan(lambda a, e: a + e, elems, initializer=x) jacobian = gradients.jacobian(y, x) expected_shape = [6, 3, 4, 3, 4] self.assertAllEqual(expected_shape, jacobian.shape.as_list()) def test_jacobian_while_loop_shape(self): # Shape x: [3, 4] x = random_ops.random_uniform([3, 4]) _, y = tf_control_flow_ops.while_loop(lambda i, a: i > 5., lambda i, a: (i + 1, a + i), (constant_op.constant(0.), x)) # Shape y: [2, 3] y = y[:2, :3] jacobian = gradients.jacobian(y, x) expected_shape = [2, 3, 3, 4] self.assertAllEqual(expected_shape, jacobian.shape.as_list()) def test_jacobian_unknown_shape(self): with self.cached_session() as sess: x = array_ops.placeholder(dtypes.float32, shape=[None, None]) y = math_ops.matmul(x, x, transpose_a=True) jacobian_pfor = gradients.jacobian(y, x, use_pfor=True) jacobian_while = gradients.jacobian(y, x, use_pfor=False) answer = ops.convert_to_tensor([[ gradient_ops.gradients(y[0][0], x)[0], gradient_ops.gradients(y[0][1], x)[0] ], [ gradient_ops.gradients(y[1][0], x)[0], gradient_ops.gradients(y[1][1], x)[0] ]]) ans, pfor_value, while_value = sess.run( [answer, jacobian_pfor, jacobian_while], feed_dict={x: [[1, 2], [3, 4]]}) self.assertAllClose(ans, pfor_value) self.assertAllClose(ans, while_value) def test_jacobian_parallel_iterations(self): x = constant_op.constant([[1., 2], [3, 4]]) y = math_ops.matmul(x, x) self.assertAllClose(gradients.jacobian(y, x, parallel_iterations=2), gradients.jacobian(y, x, parallel_iterations=3)) def test_batch_jacobian_bad_shapes(self): x = random_ops.random_uniform([2, 2]) y = random_ops.random_uniform([3, 2]) with self.assertRaisesRegexp(ValueError, "Need first dimension of output"): gradients.batch_jacobian(y, x, use_pfor=True) def test_batch_jacobian_bad_unknown_shapes(self): with self.cached_session() as sess: x = array_ops.placeholder(dtypes.float32) y = array_ops.concat([x, x], axis=0) jacobian = gradients.batch_jacobian(y, x) with self.assertRaisesRegexp(errors.InvalidArgumentError, "assertion failed"): sess.run(jacobian, feed_dict={x: [[1, 2], [3, 4]]}) def test_batch_jacobian_fixed_shape(self): x = random_ops.random_uniform([2, 3, 5]) y = x * x batch_jacobian_pfor = gradients.batch_jacobian(y, x, use_pfor=True) batch_jacobian_while = gradients.batch_jacobian(y, x, use_pfor=False) two_x = 2 * x answer = array_ops.stack( [array_ops.diag(two_x[0]), array_ops.diag(two_x[1])]) self.run_and_assert_equal(answer, batch_jacobian_pfor) self.run_and_assert_equal(answer, batch_jacobian_while) def test_batch_jacobian_unknown_shape(self): with self.cached_session() as sess: x = array_ops.placeholder(dtypes.float32) y = x * x batch_jacobian_pfor = gradients.batch_jacobian(y, x, use_pfor=True) batch_jacobian_while = gradients.batch_jacobian(y, x, use_pfor=False) two_x = 2 * x answer = array_ops.stack( [array_ops.diag(two_x[0]), array_ops.diag(two_x[1])]) ans, pfor_value, while_value = sess.run( [answer, batch_jacobian_pfor, batch_jacobian_while], feed_dict={x: [[1, 2], [3, 4]]}) self.assertAllClose(ans, pfor_value) self.assertAllClose(ans, while_value) def test_batch_jacobian_parallel_iterations(self): x = constant_op.constant([[1., 2], [3, 4]]) w = constant_op.constant([[1., 2, 3, 4], [5, 6, 7, 8]]) y = math_ops.matmul(x, w) self.assertAllClose(gradients.batch_jacobian(y, x, parallel_iterations=2), gradients.batch_jacobian(y, x, parallel_iterations=3)) def test_fc_batch_jacobian(self): pfor_jacobian, while_jacobian = create_fc_batch_jacobian(8, 4, 2) self.run_and_assert_equal(pfor_jacobian, while_jacobian) def test_lstm_batch_jacobian(self): pfor_jacobian, while_jacobian = create_lstm_batch_jacobian(8, 4, 2, inputs_size=128) self.run_and_assert_equal(pfor_jacobian, while_jacobian) @test_util.disable_xla("This test never passed for XLA") def DISABLED_test_dynamic_lstm_batch_jacobian(self): pfor_jacobian, while_gradients = create_dynamic_lstm_batch_jacobian(8, 4, 3) with session.Session() as sess: init = variables.global_variables_initializer() self.evaluate(init) pfor = self.evaluate(pfor_jacobian) for i in range(4): while_i = sess.run(while_gradients[i]) self.assertAllClose(while_i, pfor[:, i, ...]) def test_lstm_hessian(self): pfor_hessian, while_hessian = create_lstm_hessian(2, 2, 2) self.run_and_assert_equal(pfor_hessian, while_hessian) def test_lstm_batch_hessian(self): pfor_hessian, while_hessian = create_lstm_batch_hessian(2, 2, 2) self.run_and_assert_equal(pfor_hessian, while_hessian) def test_fc_per_eg_grad(self): pfor_outputs, while_outputs = create_fc_per_eg_grad(8, 4, 2) self.run_and_assert_equal(pfor_outputs, while_outputs) def test_lstm_per_eg_grad(self): pfor_outputs, while_outputs = create_lstm_per_eg_grad(8, 4, 2) self.run_and_assert_equal(pfor_outputs, while_outputs) def test_mnist_per_eg_grad(self): # It looks like CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED # configuration of Winograd can cause low precision output resulting in # tests failing. So we disable that here. os.environ["TF_ENABLE_WINOGRAD_NONFUSED"] = "0" data_format = ("channels_first" if test.is_gpu_available() else "channels_last") # Note that we we are setting training=False here so that dropout produces # the same result with pfor and with while_loop. pfor_outputs, while_outputs = create_mnist_per_eg_grad( 4, data_format, training=False) self.run_and_assert_equal(pfor_outputs, while_outputs, rtol=1e-3) os.environ.pop("TF_ENABLE_WINOGRAD_NONFUSED", None) def test_mnist_per_eg_jacobian(self): # It looks like CUDNN_CONVOLUTION_BWD_DATA_ALGO_WINOGRAD_NONFUSED # configuration of Winograd can cause low precision output resulting in # tests failing. So we disable that here. os.environ["TF_ENABLE_WINOGRAD_NONFUSED"] = "0" data_format = ("channels_first" if test.is_gpu_available() else "channels_last") # Note that we we are setting training=False here so that dropout produces # the same result with pfor and with while_loop. pfor_outputs, while_outputs = create_mnist_per_eg_jacobian( 2, data_format, training=False) self.run_and_assert_equal(pfor_outputs, while_outputs, rtol=1e-3) os.environ.pop("TF_ENABLE_WINOGRAD_NONFUSED", None) def test_fc_jacobian(self): jacobians, per_eg_jacobians_pfor, per_eg_jacobians_while = ( create_fc_per_eg_jacobians(batch_size=8, activation_size=4, num_layers=2)) self.run_and_assert_equal(jacobians, per_eg_jacobians_pfor, rtol=2e-3, atol=1e-3) self.run_and_assert_equal(jacobians, per_eg_jacobians_while, rtol=2e-3, atol=1e-3) def test_indexed_slice(self): inp = random_ops.random_uniform([3, 2]) output = nn.embedding_lookup(inp, [0, 2]) pfor_jacobian = gradients.jacobian(output, inp, use_pfor=True) while_jacobian = gradients.jacobian(output, inp, use_pfor=False) self.run_and_assert_equal(while_jacobian, pfor_jacobian) class GradientsBenchmarks(test.Benchmark): def _run(self, targets, iters, name=None): def _done(t): # Note that we don't use tf.control_dependencies since that will not make # sure that the computation on GPU has actually finished. So we fetch the # first element of the output, and assume that this will not be called on # empty tensors. return array_ops.gather(array_ops.reshape(t, [-1]), 0) targets = [_done(x) for x in nest.flatten(targets)] sess = session.Session() with sess: init = variables.global_variables_initializer() self.evaluate(init) self.evaluate(targets) begin = time.time() for _ in range(iters): self.evaluate(targets) end = time.time() avg_time_ms = (1000 * (end - begin)) / iters self.report_benchmark(iters=iters, wall_time=avg_time_ms, name=name) return avg_time_ms def benchmark_fc_batch_jacobian(self): with ops.Graph().as_default(): pfor_jacobian, while_jacobian = create_fc_batch_jacobian(100, 32, 20) self._run(pfor_jacobian, 100, name="fc_batch_jacobian_pfor") self._run(while_jacobian, 20, name="fc_batch_jacobian_while") def benchmark_lstm_batch_jacobian(self): with ops.Graph().as_default(): pfor_jacobian, while_jacobian = create_lstm_batch_jacobian( 100, 32, 8, inputs_size=128) self._run(pfor_jacobian, 100, name="lstm_batch_jacobian_pfor") self._run(while_jacobian, 20, name="lstm_batch_jacobian_while") def benchmark_lstm_hessian(self): with ops.Graph().as_default(): pfor_hessian, while_hessian = create_lstm_hessian(2, 2, 10) self._run(pfor_hessian, 20, name="lstm_hessian_pfor") self._run(while_hessian, 3, name="lstm_hessian_while_pfor") def benchmark_lstm_batch_hessian(self): with ops.Graph().as_default(): pfor_hessian, while_hessian = create_lstm_batch_hessian(4, 4, 10) self._run(pfor_hessian, 100, name="lstm_batch_hessian_pfor") self._run(while_hessian, 20, name="lstm_batch_hessian_while_pfor") def benchmark_fc_per_eg_grad(self): with ops.Graph().as_default(): pfor_outputs, while_outputs = create_fc_per_eg_grad(100, 32, 3) self._run(pfor_outputs, 100, name="fc_per_eg_grad_pfor") self._run(while_outputs, 20, name="fc_per_eg_grad_while") def benchmark_lstm_per_eg_grad(self): with ops.Graph().as_default(): pfor_outputs, while_outputs = create_lstm_per_eg_grad(100, 32, 8) self._run(pfor_outputs, 100, name="lstm_per_eg_grad_pfor") self._run(while_outputs, 20, name="lstm_per_eg_grad_while") def benchmark_mnist_autobatch(self): with ops.Graph().as_default(): data_format = ("channels_first" if test.is_gpu_available() else "channels_last") pfor_outputs, while_outputs, manual = create_mnist_autobatch( 100, data_format, training=False) self._run(pfor_outputs, 100, name="mnist_pfor") self._run(while_outputs, 20, name="mnist_while") self._run(manual, 100, name="mnist_manual") def benchmark_mnist_per_eg_grad(self): with ops.Graph().as_default(): data_format = ("channels_first" if test.is_gpu_available() else "channels_last") pfor_outputs, while_outputs = create_mnist_per_eg_grad( 128, data_format, training=True) self._run(pfor_outputs, 20, name="mnist_per_eg_grad_pfor") self._run(while_outputs, 20, name="mnist_per_eg_grad_while") def benchmark_mnist_per_eg_jacobian(self): with ops.Graph().as_default(): if test.is_gpu_available(): data_format = "channels_first" else: data_format = "channels_last" pfor_outputs, while_outputs = create_mnist_per_eg_jacobian( 16, data_format, training=True) self._run(pfor_outputs, 20, name="mnist_per_eg_jacobian_pfor") self._run(while_outputs, 20, name="mnist_per_eg_jacobian_while") def benchmark_mnist_batch_jacobian(self): with ops.Graph().as_default(): if test.is_gpu_available(): data_format = "channels_first" else: data_format = "channels_last" pfor_outputs, while_outputs = create_mnist_batch_jacobian( 128, data_format, training=True) self._run(pfor_outputs, 20, name="mnist_batch_jacobian_pfor") self._run(while_outputs, 20, name="mnist_batch_jacobian_while") def benchmark_fc_per_eg_jacobian(self): with ops.Graph().as_default(): jacobians, per_eg_jacobians_pfor, per_eg_jacobians_while = ( create_fc_per_eg_jacobians(batch_size=128, activation_size=32, num_layers=3)) self._run(jacobians, 30, name="fc_jacobians_pfor") self._run(per_eg_jacobians_pfor, 100, name="fc_per_eg_jacobians_pfor") self._run(per_eg_jacobians_while, 10, name="fc_per_eg_jacobians_while") if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 1335, 22065, 436, 3522, 63, 27342, 4156, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 9143, 199, 646, 747, 199, 646, 900, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2552, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 8811, 14, 3908, 492, 6093, 465, 11708, 63, 7588, 199, 504, 3228, 14, 1548, 14, 4359, 492, 9393, 465, 2833, 63, 4359, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 465, 2833, 63, 2785, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 22380, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 465, 6709, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 19433, 199, 504, 3228, 14, 1548, 14, 1483, 492, 19433, 63, 3890, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 1483, 14, 17865, 492, 21289, 199, 504, 3228, 14, 1548, 14, 1483, 14, 11887, 63, 509, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 14, 11887, 63, 509, 492, 12661, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 504, 3228, 14, 1548, 14, 1974, 492, 10715, 421, 199, 533, 481, 8525, 16382, 1685, 8, 785, 304, 819, 347, 636, 826, 721, 277, 12, 10361, 63, 890, 12, 1967, 63, 4359, 304, 272, 291, 423, 4359, 275, 359, 267, 2833, 63, 4359, 14, 15327, 8, 12312, 63, 890, 12, 10361, 29, 4411, 14, 12833, 9, 267, 367, 485, 315, 1425, 8, 1507, 63, 4359, 9, 272, 1622, 819, 347, 636, 1250, 721, 277, 12, 10702, 304, 272, 10361, 275, 10702, 272, 367, 4045, 315, 291, 423, 4359, 26, 489, 10361, 275, 4045, 8, 12312, 9, 272, 372, 10361, 421, 199, 318, 9999, 63, 7113, 63, 1238, 63, 2324, 8, 2912, 63, 890, 12, 10361, 63, 890, 12, 1967, 63, 4359, 304, 523, 1402, 275, 481, 8525, 16382, 1685, 8, 12312, 63, 890, 12, 1967, 63, 4359, 9, 523, 10702, 275, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 2912, 63, 890, 12, 10361, 63, 890, 566, 523, 372, 10702, 12, 1402, 8, 11416, 9, 421, 199, 318, 9877, 77, 63, 1238, 63, 2324, 8, 2912, 63, 890, 12, 1174, 63, 890, 12, 7124, 12, 4153, 63, 890, 29, 403, 304, 523, 4153, 63, 890, 275, 4153, 63, 890, 503, 1174, 63, 890, 523, 4153, 275, 359, 489, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 2912, 63, 890, 12, 4153, 63, 890, 566, 367, 485, 315, 1425, 8, 5895, 9, 523, 1622, 523, 4917, 275, 19433, 63, 3890, 14, 6845, 29805, 7608, 1697, 8, 929, 63, 890, 9, 523, 4205, 63, 929, 275, 4917, 14, 4262, 63, 929, 8, 2912, 63, 890, 12, 6674, 14, 1609, 708, 9, 523, 1174, 275, 4205, 63, 929, 523, 367, 10702, 315, 4153, 26, 272, 5501, 1174, 275, 4917, 8, 11416, 12, 1174, 9, 523, 372, 4205, 63, 929, 14, 67, 12, 1174, 14, 67, 421, 199, 318, 8336, 63, 26652, 63, 1238, 63, 2324, 8, 2912, 63, 890, 12, 1174, 63, 890, 12, 1390, 63, 5895, 304, 523, 327, 2136, 1852, 4153, 436, 3414, 63, 1267, 4413, 880, 626, 3663, 2351, 14, 1065, 523, 327, 4882, 7389, 314, 2011, 754, 14, 523, 4153, 275, 4413, 63, 411, 14, 4083, 8, 489, 980, 14, 2355, 14, 3759, 8, 2912, 63, 890, 12, 1390, 63, 5895, 12, 1174, 63, 890, 395, 2152, 29, 5717, 14, 1609, 708, 9, 523, 3414, 63, 1267, 275, 4413, 63, 411, 14, 4083, 8, 489, 980, 14, 2355, 14, 8393, 8, 16, 12, 1568, 1524, 2912, 63, 890, 467, 4721, 29, 988, 63, 5895, 435, 413, 395, 489, 2152, 29, 5717, 14, 442, 708, 9, 819, 4917, 275, 19433, 63, 3890, 14, 6845, 29805, 7608, 1697, 8, 929, 63, 890, 9, 523, 2536, 63, 929, 275, 4917, 14, 4262, 63, 929, 8, 2912, 63, 890, 12, 6674, 14, 1609, 708, 9, 523, 372, 4153, 12, 19433, 14, 7764, 63, 12845, 8, 489, 4917, 12, 489, 4153, 12, 489, 3414, 63, 1267, 29, 4041, 63, 1267, 12, 489, 2536, 63, 929, 29, 2747, 63, 929, 9, 421, 199, 318, 1218, 63, 3003, 63, 2912, 63, 27342, 8, 2912, 63, 890, 12, 10361, 63, 890, 12, 1967, 63, 4359, 304, 523, 10702, 12, 1072, 275, 9999, 63, 7113, 63, 1238, 63, 2324, 8, 2912, 63, 890, 12, 10361, 63, 890, 12, 1460, 1967, 63, 4359, 9, 523, 299, 509, 63, 27342, 275, 12661, 14, 2912, 63, 27342, 8, 1199, 12, 10702, 12, 675, 63, 80, 509, 29, 549, 9, 523, 1830, 63 ]
[ 1898, 14894, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 1335, 22065, 436, 3522, 63, 27342, 4156, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 9143, 199, 646, 747, 199, 646, 900, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 6674, 199, 504, 3228, 14, 1548, 14, 4857, 492, 2552, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 4857, 492, 511, 63, 1974, 199, 504, 3228, 14, 1548, 14, 8811, 14, 3908, 492, 6093, 465, 11708, 63, 7588, 199, 504, 3228, 14, 1548, 14, 4359, 492, 9393, 465, 2833, 63, 4359, 199, 504, 3228, 14, 1548, 14, 1483, 492, 1625, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 465, 2833, 63, 2785, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 22380, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 12661, 465, 6709, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 11542, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 19433, 199, 504, 3228, 14, 1548, 14, 1483, 492, 19433, 63, 3890, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 1483, 14, 17865, 492, 21289, 199, 504, 3228, 14, 1548, 14, 1483, 14, 11887, 63, 509, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 14, 11887, 63, 509, 492, 12661, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 199, 504, 3228, 14, 1548, 14, 1974, 492, 10715, 421, 199, 533, 481, 8525, 16382, 1685, 8, 785, 304, 819, 347, 636, 826, 721, 277, 12, 10361, 63, 890, 12, 1967, 63, 4359, 304, 272, 291, 423, 4359, 275, 359, 267, 2833, 63, 4359, 14, 15327, 8, 12312, 63, 890, 12, 10361, 29, 4411, 14, 12833, 9, 267, 367, 485, 315, 1425, 8, 1507, 63, 4359, 9, 272, 1622, 819, 347, 636, 1250, 721, 277, 12, 10702, 304, 272, 10361, 275, 10702, 272, 367, 4045, 315, 291, 423, 4359, 26, 489, 10361, 275, 4045, 8, 12312, 9, 272, 372, 10361, 421, 199, 318, 9999, 63, 7113, 63, 1238, 63, 2324, 8, 2912, 63, 890, 12, 10361, 63, 890, 12, 1967, 63, 4359, 304, 523, 1402, 275, 481, 8525, 16382, 1685, 8, 12312, 63, 890, 12, 1967, 63, 4359, 9, 523, 10702, 275, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 2912, 63, 890, 12, 10361, 63, 890, 566, 523, 372, 10702, 12, 1402, 8, 11416, 9, 421, 199, 318, 9877, 77, 63, 1238, 63, 2324, 8, 2912, 63, 890, 12, 1174, 63, 890, 12, 7124, 12, 4153, 63, 890, 29, 403, 304, 523, 4153, 63, 890, 275, 4153, 63, 890, 503, 1174, 63, 890, 523, 4153, 275, 359, 489, 2196, 63, 1483, 14, 2355, 63, 3302, 779, 2912, 63, 890, 12, 4153, 63, 890, 566, 367, 485, 315, 1425, 8, 5895, 9, 523, 1622, 523, 4917, 275, 19433, 63, 3890, 14, 6845, 29805, 7608, 1697, 8, 929, 63, 890, 9, 523, 4205, 63, 929, 275, 4917, 14, 4262, 63, 929, 8, 2912, 63, 890, 12, 6674, 14, 1609, 708, 9, 523, 1174, 275, 4205, 63, 929, 523, 367, 10702, 315, 4153, 26, 272, 5501, 1174, 275, 4917, 8, 11416, 12, 1174, 9, 523, 372, 4205, 63, 929, 14, 67, 12, 1174, 14, 67, 421, 199, 318, 8336, 63, 26652, 63, 1238, 63, 2324, 8, 2912, 63, 890, 12, 1174, 63, 890, 12, 1390, 63, 5895, 304, 523, 327, 2136, 1852, 4153, 436, 3414, 63, 1267, 4413, 880, 626, 3663, 2351, 14, 1065, 523, 327, 4882, 7389, 314, 2011, 754, 14, 523, 4153, 275, 4413, 63, 411, 14, 4083, 8, 489, 980, 14, 2355, 14, 3759, 8, 2912, 63, 890, 12, 1390, 63, 5895, 12, 1174, 63, 890, 395, 2152, 29, 5717, 14, 1609, 708, 9, 523, 3414, 63, 1267, 275, 4413, 63, 411, 14, 4083, 8, 489, 980, 14, 2355, 14, 8393, 8, 16, 12, 1568, 1524, 2912, 63, 890, 467, 4721, 29, 988, 63, 5895, 435, 413, 395, 489, 2152, 29, 5717, 14, 442, 708, 9, 819, 4917, 275, 19433, 63, 3890, 14, 6845, 29805, 7608, 1697, 8, 929, 63, 890, 9, 523, 2536, 63, 929, 275, 4917, 14, 4262, 63, 929, 8, 2912, 63, 890, 12, 6674, 14, 1609, 708, 9, 523, 372, 4153, 12, 19433, 14, 7764, 63, 12845, 8, 489, 4917, 12, 489, 4153, 12, 489, 3414, 63, 1267, 29, 4041, 63, 1267, 12, 489, 2536, 63, 929, 29, 2747, 63, 929, 9, 421, 199, 318, 1218, 63, 3003, 63, 2912, 63, 27342, 8, 2912, 63, 890, 12, 10361, 63, 890, 12, 1967, 63, 4359, 304, 523, 10702, 12, 1072, 275, 9999, 63, 7113, 63, 1238, 63, 2324, 8, 2912, 63, 890, 12, 10361, 63, 890, 12, 1460, 1967, 63, 4359, 9, 523, 299, 509, 63, 27342, 275, 12661, 14, 2912, 63, 27342, 8, 1199, 12, 10702, 12, 675, 63, 80, 509, 29, 549, 9, 523, 1830, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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inpush/xb/raw/binding_.py # -*- coding: utf-8 -*- # PyXB bindings for NM:0b338ff90207234600b9b9432e9e9a2f47008914 # Generated 2015-04-23 16:42:14.515862 by PyXB version 1.2.4 using Python 3.4.1.final.0 # Namespace http://www.thalesgroup.com/rtti/XmlTimetable/v8 from __future__ import unicode_literals import pyxb import pyxb.binding import pyxb.binding.saxer import io import pyxb.utils.utility import pyxb.utils.domutils import sys import pyxb.utils.six as _six # Unique identifier for bindings created at the same time _GenerationUID = pyxb.utils.utility.UniqueIdentifier('urn:uuid:5049f1de-e9cf-11e4-bb50-a0481ca50ab0') # Version of PyXB used to generate the bindings _PyXBVersion = '1.2.4' # Generated bindings are not compatible across PyXB versions if pyxb.__version__ != _PyXBVersion: raise pyxb.PyXBVersionError(_PyXBVersion) # Import bindings for namespaces imported into schema import pyxb.binding.datatypes import darwinpush.xb.ct as _ImportedBinding_darwinpush_xb_ct # NOTE: All namespace declarations are reserved within the binding Namespace = pyxb.namespace.NamespaceForURI('http://www.thalesgroup.com/rtti/XmlTimetable/v8', create_if_missing=True) Namespace.configureCategories(['typeBinding', 'elementBinding']) def CreateFromDocument (xml_text, default_namespace=None, location_base=None): """Parse the given XML and use the document element to create a Python instance. @param xml_text An XML document. This should be data (Python 2 str or Python 3 bytes), or a text (Python 2 unicode or Python 3 str) in the L{pyxb._InputEncoding} encoding. @keyword default_namespace The L{pyxb.Namespace} instance to use as the default namespace where there is no default namespace in scope. If unspecified or C{None}, the namespace of the module containing this function will be used. @keyword location_base: An object to be recorded as the base of all L{pyxb.utils.utility.Location} instances associated with events and objects handled by the parser. You might pass the URI from which the document was obtained. """ if pyxb.XMLStyle_saxer != pyxb._XMLStyle: dom = pyxb.utils.domutils.StringToDOM(xml_text) return CreateFromDOM(dom.documentElement, default_namespace=default_namespace) if default_namespace is None: default_namespace = Namespace.fallbackNamespace() saxer = pyxb.binding.saxer.make_parser(fallback_namespace=default_namespace, location_base=location_base) handler = saxer.getContentHandler() xmld = xml_text if isinstance(xmld, _six.text_type): xmld = xmld.encode(pyxb._InputEncoding) saxer.parse(io.BytesIO(xmld)) instance = handler.rootObject() return instance def CreateFromDOM (node, default_namespace=None): """Create a Python instance from the given DOM node. The node tag must correspond to an element declaration in this module. @deprecated: Forcing use of DOM interface is unnecessary; use L{CreateFromDocument}.""" if default_namespace is None: default_namespace = Namespace.fallbackNamespace() return pyxb.binding.basis.element.AnyCreateFromDOM(node, default_namespace) # Atomic simple type: {http://www.thalesgroup.com/rtti/XmlTimetable/v8}CategoryType class CategoryType (pyxb.binding.datatypes.string, pyxb.binding.basis.enumeration_mixin): """Association Category Type: JJ=Join, VV=Split, LK=Linked, NP=Next-Working""" _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'CategoryType') _XSDLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 28, 1) _Documentation = 'Association Category Type: JJ=Join, VV=Split, LK=Linked, NP=Next-Working' CategoryType._CF_enumeration = pyxb.binding.facets.CF_enumeration(value_datatype=CategoryType, enum_prefix=None) CategoryType.JJ = CategoryType._CF_enumeration.addEnumeration(unicode_value='JJ', tag='JJ') CategoryType.VV = CategoryType._CF_enumeration.addEnumeration(unicode_value='VV', tag='VV') CategoryType.LK = CategoryType._CF_enumeration.addEnumeration(unicode_value='LK', tag='LK') CategoryType.NP = CategoryType._CF_enumeration.addEnumeration(unicode_value='NP', tag='NP') CategoryType._InitializeFacetMap(CategoryType._CF_enumeration) Namespace.addCategoryObject('typeBinding', 'CategoryType', CategoryType) # Complex type {http://www.thalesgroup.com/rtti/XmlTimetable/v8}AssocService with content type EMPTY class AssocService (pyxb.binding.basis.complexTypeDefinition): """Complex type {http://www.thalesgroup.com/rtti/XmlTimetable/v8}AssocService with content type EMPTY""" _TypeDefinition = None _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_EMPTY _Abstract = False _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'AssocService') _XSDLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 40, 1) _ElementMap = {} _AttributeMap = {} # Base type is pyxb.binding.datatypes.anyType # Attribute wta uses Python identifier wta __wta = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wta'), 'wta', '__httpwww_thalesgroup_comrttiXmlTimetablev8_AssocService_wta', _ImportedBinding_darwinpush_xb_ct.WTimeType) __wta._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiPPTCommonTypes_v1.xsd', 243, 2) __wta._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiPPTCommonTypes_v1.xsd', 243, 2) wta = property(__wta.value, __wta.set, None, 'Working time of arrival.') # Attribute wtd uses Python identifier wtd __wtd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wtd'), 'wtd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_AssocService_wtd', _ImportedBinding_darwinpush_xb_ct.WTimeType) __wtd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiPPTCommonTypes_v1.xsd', 248, 2) __wtd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiPPTCommonTypes_v1.xsd', 248, 2) wtd = property(__wtd.value, __wtd.set, None, 'Working time of departure.') # Attribute wtp uses Python identifier wtp __wtp = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wtp'), 'wtp', '__httpwww_thalesgroup_comrttiXmlTimetablev8_AssocService_wtp', _ImportedBinding_darwinpush_xb_ct.WTimeType) __wtp._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiPPTCommonTypes_v1.xsd', 253, 2) __wtp._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiPPTCommonTypes_v1.xsd', 253, 2) wtp = property(__wtp.value, __wtp.set, None, 'Working time of pass.') # Attribute pta uses Python identifier pta __pta = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'pta'), 'pta', '__httpwww_thalesgroup_comrttiXmlTimetablev8_AssocService_pta', _ImportedBinding_darwinpush_xb_ct.RTTITimeType) __pta._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiPPTCommonTypes_v1.xsd', 258, 2) __pta._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiPPTCommonTypes_v1.xsd', 258, 2) pta = property(__pta.value, __pta.set, None, 'Public time of arrival.') # Attribute ptd uses Python identifier ptd __ptd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'ptd'), 'ptd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_AssocService_ptd', _ImportedBinding_darwinpush_xb_ct.RTTITimeType) __ptd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiPPTCommonTypes_v1.xsd', 263, 2) __ptd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiPPTCommonTypes_v1.xsd', 263, 2) ptd = property(__ptd.value, __ptd.set, None, 'Public time of departure.') # Attribute rid uses Python identifier rid __rid = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'rid'), 'rid', '__httpwww_thalesgroup_comrttiXmlTimetablev8_AssocService_rid', _ImportedBinding_darwinpush_xb_ct.RIDType, required=True) __rid._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 41, 2) __rid._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 41, 2) rid = property(__rid.value, __rid.set, None, 'RTTI Train ID. Note that since this is an RID, the service must already exist within Darwin.') _ElementMap.update({ }) _AttributeMap.update({ __wta.name() : __wta, __wtd.name() : __wtd, __wtp.name() : __wtp, __pta.name() : __pta, __ptd.name() : __ptd, __rid.name() : __rid }) Namespace.addCategoryObject('typeBinding', 'AssocService', AssocService) # Complex type {http://www.thalesgroup.com/rtti/XmlTimetable/v8}Association with content type ELEMENT_ONLY class Association (pyxb.binding.basis.complexTypeDefinition): """Type describing an association between schedules""" _TypeDefinition = None _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_ELEMENT_ONLY _Abstract = False _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'Association') _XSDLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 52, 1) _ElementMap = {} _AttributeMap = {} # Base type is pyxb.binding.datatypes.anyType # Element {http://www.thalesgroup.com/rtti/XmlTimetable/v8}main uses Python identifier main __main = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(Namespace, 'main'), 'main', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Association_httpwww_thalesgroup_comrttiXmlTimetablev8main', False, pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 57, 3), ) main = property(__main.value, __main.set, None, 'The through, previous working or link-to service') # Element {http://www.thalesgroup.com/rtti/XmlTimetable/v8}assoc uses Python identifier assoc __assoc = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(Namespace, 'assoc'), 'assoc', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Association_httpwww_thalesgroup_comrttiXmlTimetablev8assoc', False, pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 62, 3), ) assoc = property(__assoc.value, __assoc.set, None, 'The starting, terminating, subsequent working or link-from service') # Attribute tiploc uses Python identifier tiploc __tiploc = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'tiploc'), 'tiploc', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Association_tiploc', _ImportedBinding_darwinpush_xb_ct.TiplocType, required=True) __tiploc._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 68, 2) __tiploc._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 68, 2) tiploc = property(__tiploc.value, __tiploc.set, None, 'The TIPLOC of the location where the association occurs.') # Attribute category uses Python identifier category __category = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'category'), 'category', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Association_category', CategoryType, required=True) __category._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 73, 2) __category._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 73, 2) category = property(__category.value, __category.set, None, 'Association category') # Attribute isCancelled uses Python identifier isCancelled __isCancelled = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'isCancelled'), 'isCancelled', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Association_isCancelled', pyxb.binding.datatypes.boolean, unicode_default='false') __isCancelled._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 78, 2) __isCancelled._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 78, 2) isCancelled = property(__isCancelled.value, __isCancelled.set, None, 'True if this association is cancelled, i.e. the association exists but will no longer happen.') # Attribute isDeleted uses Python identifier isDeleted __isDeleted = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'isDeleted'), 'isDeleted', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Association_isDeleted', pyxb.binding.datatypes.boolean, unicode_default='false') __isDeleted._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 83, 2) __isDeleted._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 83, 2) isDeleted = property(__isDeleted.value, __isDeleted.set, None, 'True if this association is deleted, i.e. the association no longer exists.') _ElementMap.update({ __main.name() : __main, __assoc.name() : __assoc }) _AttributeMap.update({ __tiploc.name() : __tiploc, __category.name() : __category, __isCancelled.name() : __isCancelled, __isDeleted.name() : __isDeleted }) Namespace.addCategoryObject('typeBinding', 'Association', Association) # Complex type {http://www.thalesgroup.com/rtti/XmlTimetable/v8}OR with content type EMPTY class OR (pyxb.binding.basis.complexTypeDefinition): """Defines a Passenger Origin Calling Point""" _TypeDefinition = None _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_EMPTY _Abstract = False _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'OR') _XSDLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 134, 1) _ElementMap = {} _AttributeMap = {} # Base type is pyxb.binding.datatypes.anyType # Attribute tpl uses Python identifier tpl __tpl = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'tpl'), 'tpl', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OR_tpl', _ImportedBinding_darwinpush_xb_ct.TiplocType, required=True) __tpl._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) __tpl._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) tpl = property(__tpl.value, __tpl.set, None, 'TIPLOC') # Attribute act uses Python identifier act __act = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'act'), 'act', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OR_act', _ImportedBinding_darwinpush_xb_ct.ActivityType, unicode_default=' ') __act._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) __act._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) act = property(__act.value, __act.set, None, 'Current Activity Codes') # Attribute planAct uses Python identifier planAct __planAct = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'planAct'), 'planAct', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OR_planAct', _ImportedBinding_darwinpush_xb_ct.ActivityType) __planAct._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) __planAct._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) planAct = property(__planAct.value, __planAct.set, None, 'Planned Activity Codes (if different to current activities)') # Attribute can uses Python identifier can __can = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'can'), 'can', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OR_can', pyxb.binding.datatypes.boolean, unicode_default='false') __can._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) __can._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) can = property(__can.value, __can.set, None, 'Cancelled') # Attribute plat uses Python identifier plat __plat = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'plat'), 'plat', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OR_plat', _ImportedBinding_darwinpush_xb_ct.PlatformType) __plat._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) __plat._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) plat = property(__plat.value, __plat.set, None, 'Platform number') # Attribute pta uses Python identifier pta __pta = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'pta'), 'pta', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OR_pta', _ImportedBinding_darwinpush_xb_ct.RTTITimeType) __pta._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 123, 2) __pta._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 123, 2) pta = property(__pta.value, __pta.set, None, 'Public Scheduled Time of Arrival') # Attribute ptd uses Python identifier ptd __ptd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'ptd'), 'ptd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OR_ptd', _ImportedBinding_darwinpush_xb_ct.RTTITimeType) __ptd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 128, 2) __ptd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 128, 2) ptd = property(__ptd.value, __ptd.set, None, 'Public Scheduled Time of Departure') # Attribute wta uses Python identifier wta __wta = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wta'), 'wta', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OR_wta', _ImportedBinding_darwinpush_xb_ct.WTimeType) __wta._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 140, 2) __wta._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 140, 2) wta = property(__wta.value, __wta.set, None, 'Working Scheduled Time of Arrival') # Attribute wtd uses Python identifier wtd __wtd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wtd'), 'wtd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OR_wtd', _ImportedBinding_darwinpush_xb_ct.WTimeType, required=True) __wtd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 145, 2) __wtd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 145, 2) wtd = property(__wtd.value, __wtd.set, None, 'Working Scheduled Time of Departure') # Attribute fd uses Python identifier fd __fd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'fd'), 'fd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OR_fd', _ImportedBinding_darwinpush_xb_ct.TiplocType) __fd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 150, 2) __fd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 150, 2) fd = property(__fd.value, __fd.set, None, 'TIPLOC of False Destination to be used at this location') _ElementMap.update({ }) _AttributeMap.update({ __tpl.name() : __tpl, __act.name() : __act, __planAct.name() : __planAct, __can.name() : __can, __plat.name() : __plat, __pta.name() : __pta, __ptd.name() : __ptd, __wta.name() : __wta, __wtd.name() : __wtd, __fd.name() : __fd }) Namespace.addCategoryObject('typeBinding', 'OR', OR) # Complex type {http://www.thalesgroup.com/rtti/XmlTimetable/v8}OPOR with content type EMPTY class OPOR (pyxb.binding.basis.complexTypeDefinition): """Defines an Operational Origin Calling Point""" _TypeDefinition = None _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_EMPTY _Abstract = False _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'OPOR') _XSDLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 156, 1) _ElementMap = {} _AttributeMap = {} # Base type is pyxb.binding.datatypes.anyType # Attribute tpl uses Python identifier tpl __tpl = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'tpl'), 'tpl', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPOR_tpl', _ImportedBinding_darwinpush_xb_ct.TiplocType, required=True) __tpl._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) __tpl._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) tpl = property(__tpl.value, __tpl.set, None, 'TIPLOC') # Attribute act uses Python identifier act __act = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'act'), 'act', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPOR_act', _ImportedBinding_darwinpush_xb_ct.ActivityType, unicode_default=' ') __act._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) __act._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) act = property(__act.value, __act.set, None, 'Current Activity Codes') # Attribute planAct uses Python identifier planAct __planAct = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'planAct'), 'planAct', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPOR_planAct', _ImportedBinding_darwinpush_xb_ct.ActivityType) __planAct._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) __planAct._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) planAct = property(__planAct.value, __planAct.set, None, 'Planned Activity Codes (if different to current activities)') # Attribute can uses Python identifier can __can = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'can'), 'can', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPOR_can', pyxb.binding.datatypes.boolean, unicode_default='false') __can._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) __can._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) can = property(__can.value, __can.set, None, 'Cancelled') # Attribute plat uses Python identifier plat __plat = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'plat'), 'plat', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPOR_plat', _ImportedBinding_darwinpush_xb_ct.PlatformType) __plat._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) __plat._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) plat = property(__plat.value, __plat.set, None, 'Platform number') # Attribute wta uses Python identifier wta __wta = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wta'), 'wta', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPOR_wta', _ImportedBinding_darwinpush_xb_ct.WTimeType) __wta._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 161, 2) __wta._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 161, 2) wta = property(__wta.value, __wta.set, None, 'Working Scheduled Time of Arrival') # Attribute wtd uses Python identifier wtd __wtd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wtd'), 'wtd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPOR_wtd', _ImportedBinding_darwinpush_xb_ct.WTimeType, required=True) __wtd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 166, 2) __wtd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 166, 2) wtd = property(__wtd.value, __wtd.set, None, 'Working Scheduled Time of Departure') _ElementMap.update({ }) _AttributeMap.update({ __tpl.name() : __tpl, __act.name() : __act, __planAct.name() : __planAct, __can.name() : __can, __plat.name() : __plat, __wta.name() : __wta, __wtd.name() : __wtd }) Namespace.addCategoryObject('typeBinding', 'OPOR', OPOR) # Complex type {http://www.thalesgroup.com/rtti/XmlTimetable/v8}IP with content type EMPTY class IP (pyxb.binding.basis.complexTypeDefinition): """Defines aPassenger Intermediate Calling Point""" _TypeDefinition = None _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_EMPTY _Abstract = False _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'IP') _XSDLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 172, 1) _ElementMap = {} _AttributeMap = {} # Base type is pyxb.binding.datatypes.anyType # Attribute tpl uses Python identifier tpl __tpl = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'tpl'), 'tpl', '__httpwww_thalesgroup_comrttiXmlTimetablev8_IP_tpl', _ImportedBinding_darwinpush_xb_ct.TiplocType, required=True) __tpl._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) __tpl._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) tpl = property(__tpl.value, __tpl.set, None, 'TIPLOC') # Attribute act uses Python identifier act __act = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'act'), 'act', '__httpwww_thalesgroup_comrttiXmlTimetablev8_IP_act', _ImportedBinding_darwinpush_xb_ct.ActivityType, unicode_default=' ') __act._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) __act._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) act = property(__act.value, __act.set, None, 'Current Activity Codes') # Attribute planAct uses Python identifier planAct __planAct = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'planAct'), 'planAct', '__httpwww_thalesgroup_comrttiXmlTimetablev8_IP_planAct', _ImportedBinding_darwinpush_xb_ct.ActivityType) __planAct._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) __planAct._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) planAct = property(__planAct.value, __planAct.set, None, 'Planned Activity Codes (if different to current activities)') # Attribute can uses Python identifier can __can = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'can'), 'can', '__httpwww_thalesgroup_comrttiXmlTimetablev8_IP_can', pyxb.binding.datatypes.boolean, unicode_default='false') __can._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) __can._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) can = property(__can.value, __can.set, None, 'Cancelled') # Attribute plat uses Python identifier plat __plat = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'plat'), 'plat', '__httpwww_thalesgroup_comrttiXmlTimetablev8_IP_plat', _ImportedBinding_darwinpush_xb_ct.PlatformType) __plat._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) __plat._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) plat = property(__plat.value, __plat.set, None, 'Platform number') # Attribute pta uses Python identifier pta __pta = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'pta'), 'pta', '__httpwww_thalesgroup_comrttiXmlTimetablev8_IP_pta', _ImportedBinding_darwinpush_xb_ct.RTTITimeType) __pta._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 123, 2) __pta._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 123, 2) pta = property(__pta.value, __pta.set, None, 'Public Scheduled Time of Arrival') # Attribute ptd uses Python identifier ptd __ptd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'ptd'), 'ptd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_IP_ptd', _ImportedBinding_darwinpush_xb_ct.RTTITimeType) __ptd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 128, 2) __ptd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 128, 2) ptd = property(__ptd.value, __ptd.set, None, 'Public Scheduled Time of Departure') # Attribute wta uses Python identifier wta __wta = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wta'), 'wta', '__httpwww_thalesgroup_comrttiXmlTimetablev8_IP_wta', _ImportedBinding_darwinpush_xb_ct.WTimeType, required=True) __wta._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 178, 2) __wta._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 178, 2) wta = property(__wta.value, __wta.set, None, 'Working Scheduled Time of Arrival') # Attribute wtd uses Python identifier wtd __wtd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wtd'), 'wtd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_IP_wtd', _ImportedBinding_darwinpush_xb_ct.WTimeType, required=True) __wtd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 183, 2) __wtd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 183, 2) wtd = property(__wtd.value, __wtd.set, None, 'Working Scheduled Time of Departure') # Attribute rdelay uses Python identifier rdelay __rdelay = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'rdelay'), 'rdelay', '__httpwww_thalesgroup_comrttiXmlTimetablev8_IP_rdelay', _ImportedBinding_darwinpush_xb_ct.DelayValueType, unicode_default='0') __rdelay._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 188, 2) __rdelay._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 188, 2) rdelay = property(__rdelay.value, __rdelay.set, None, "A delay value that is implied by a change to the service's route.") # Attribute fd uses Python identifier fd __fd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'fd'), 'fd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_IP_fd', _ImportedBinding_darwinpush_xb_ct.TiplocType) __fd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 193, 2) __fd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 193, 2) fd = property(__fd.value, __fd.set, None, 'TIPLOC of False Destination to be used at this location') _ElementMap.update({ }) _AttributeMap.update({ __tpl.name() : __tpl, __act.name() : __act, __planAct.name() : __planAct, __can.name() : __can, __plat.name() : __plat, __pta.name() : __pta, __ptd.name() : __ptd, __wta.name() : __wta, __wtd.name() : __wtd, __rdelay.name() : __rdelay, __fd.name() : __fd }) Namespace.addCategoryObject('typeBinding', 'IP', IP) # Complex type {http://www.thalesgroup.com/rtti/XmlTimetable/v8}OPIP with content type EMPTY class OPIP (pyxb.binding.basis.complexTypeDefinition): """Defines an Operational Intermediate Calling Point""" _TypeDefinition = None _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_EMPTY _Abstract = False _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'OPIP') _XSDLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 199, 1) _ElementMap = {} _AttributeMap = {} # Base type is pyxb.binding.datatypes.anyType # Attribute tpl uses Python identifier tpl __tpl = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'tpl'), 'tpl', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPIP_tpl', _ImportedBinding_darwinpush_xb_ct.TiplocType, required=True) __tpl._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) __tpl._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) tpl = property(__tpl.value, __tpl.set, None, 'TIPLOC') # Attribute act uses Python identifier act __act = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'act'), 'act', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPIP_act', _ImportedBinding_darwinpush_xb_ct.ActivityType, unicode_default=' ') __act._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) __act._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) act = property(__act.value, __act.set, None, 'Current Activity Codes') # Attribute planAct uses Python identifier planAct __planAct = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'planAct'), 'planAct', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPIP_planAct', _ImportedBinding_darwinpush_xb_ct.ActivityType) __planAct._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) __planAct._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) planAct = property(__planAct.value, __planAct.set, None, 'Planned Activity Codes (if different to current activities)') # Attribute can uses Python identifier can __can = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'can'), 'can', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPIP_can', pyxb.binding.datatypes.boolean, unicode_default='false') __can._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) __can._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) can = property(__can.value, __can.set, None, 'Cancelled') # Attribute plat uses Python identifier plat __plat = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'plat'), 'plat', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPIP_plat', _ImportedBinding_darwinpush_xb_ct.PlatformType) __plat._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) __plat._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) plat = property(__plat.value, __plat.set, None, 'Platform number') # Attribute wta uses Python identifier wta __wta = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wta'), 'wta', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPIP_wta', _ImportedBinding_darwinpush_xb_ct.WTimeType, required=True) __wta._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 204, 2) __wta._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 204, 2) wta = property(__wta.value, __wta.set, None, 'Working Scheduled Time of Arrival') # Attribute wtd uses Python identifier wtd __wtd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wtd'), 'wtd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPIP_wtd', _ImportedBinding_darwinpush_xb_ct.WTimeType, required=True) __wtd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 209, 2) __wtd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 209, 2) wtd = property(__wtd.value, __wtd.set, None, 'Working Scheduled Time of Departure') # Attribute rdelay uses Python identifier rdelay __rdelay = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'rdelay'), 'rdelay', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPIP_rdelay', _ImportedBinding_darwinpush_xb_ct.DelayValueType, unicode_default='0') __rdelay._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 214, 2) __rdelay._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 214, 2) rdelay = property(__rdelay.value, __rdelay.set, None, "A delay value that is implied by a change to the service's route.") _ElementMap.update({ }) _AttributeMap.update({ __tpl.name() : __tpl, __act.name() : __act, __planAct.name() : __planAct, __can.name() : __can, __plat.name() : __plat, __wta.name() : __wta, __wtd.name() : __wtd, __rdelay.name() : __rdelay }) Namespace.addCategoryObject('typeBinding', 'OPIP', OPIP) # Complex type {http://www.thalesgroup.com/rtti/XmlTimetable/v8}PP with content type EMPTY class PP (pyxb.binding.basis.complexTypeDefinition): """Defines an Intermediate Passing Point""" _TypeDefinition = None _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_EMPTY _Abstract = False _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'PP') _XSDLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 220, 1) _ElementMap = {} _AttributeMap = {} # Base type is pyxb.binding.datatypes.anyType # Attribute tpl uses Python identifier tpl __tpl = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'tpl'), 'tpl', '__httpwww_thalesgroup_comrttiXmlTimetablev8_PP_tpl', _ImportedBinding_darwinpush_xb_ct.TiplocType, required=True) __tpl._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) __tpl._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) tpl = property(__tpl.value, __tpl.set, None, 'TIPLOC') # Attribute act uses Python identifier act __act = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'act'), 'act', '__httpwww_thalesgroup_comrttiXmlTimetablev8_PP_act', _ImportedBinding_darwinpush_xb_ct.ActivityType, unicode_default=' ') __act._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) __act._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) act = property(__act.value, __act.set, None, 'Current Activity Codes') # Attribute planAct uses Python identifier planAct __planAct = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'planAct'), 'planAct', '__httpwww_thalesgroup_comrttiXmlTimetablev8_PP_planAct', _ImportedBinding_darwinpush_xb_ct.ActivityType) __planAct._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) __planAct._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) planAct = property(__planAct.value, __planAct.set, None, 'Planned Activity Codes (if different to current activities)') # Attribute can uses Python identifier can __can = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'can'), 'can', '__httpwww_thalesgroup_comrttiXmlTimetablev8_PP_can', pyxb.binding.datatypes.boolean, unicode_default='false') __can._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) __can._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) can = property(__can.value, __can.set, None, 'Cancelled') # Attribute plat uses Python identifier plat __plat = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'plat'), 'plat', '__httpwww_thalesgroup_comrttiXmlTimetablev8_PP_plat', _ImportedBinding_darwinpush_xb_ct.PlatformType) __plat._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) __plat._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) plat = property(__plat.value, __plat.set, None, 'Platform number') # Attribute wtp uses Python identifier wtp __wtp = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wtp'), 'wtp', '__httpwww_thalesgroup_comrttiXmlTimetablev8_PP_wtp', _ImportedBinding_darwinpush_xb_ct.WTimeType, required=True) __wtp._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 225, 2) __wtp._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 225, 2) wtp = property(__wtp.value, __wtp.set, None, 'Working Scheduled Time of Passing') # Attribute rdelay uses Python identifier rdelay __rdelay = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'rdelay'), 'rdelay', '__httpwww_thalesgroup_comrttiXmlTimetablev8_PP_rdelay', _ImportedBinding_darwinpush_xb_ct.DelayValueType, unicode_default='0') __rdelay._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 230, 2) __rdelay._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 230, 2) rdelay = property(__rdelay.value, __rdelay.set, None, "A delay value that is implied by a change to the service's route.") _ElementMap.update({ }) _AttributeMap.update({ __tpl.name() : __tpl, __act.name() : __act, __planAct.name() : __planAct, __can.name() : __can, __plat.name() : __plat, __wtp.name() : __wtp, __rdelay.name() : __rdelay }) Namespace.addCategoryObject('typeBinding', 'PP', PP) # Complex type {http://www.thalesgroup.com/rtti/XmlTimetable/v8}DT with content type EMPTY class DT (pyxb.binding.basis.complexTypeDefinition): """Defines a Passenger Destination Calling point""" _TypeDefinition = None _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_EMPTY _Abstract = False _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'DT') _XSDLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 236, 1) _ElementMap = {} _AttributeMap = {} # Base type is pyxb.binding.datatypes.anyType # Attribute tpl uses Python identifier tpl __tpl = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'tpl'), 'tpl', '__httpwww_thalesgroup_comrttiXmlTimetablev8_DT_tpl', _ImportedBinding_darwinpush_xb_ct.TiplocType, required=True) __tpl._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) __tpl._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) tpl = property(__tpl.value, __tpl.set, None, 'TIPLOC') # Attribute act uses Python identifier act __act = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'act'), 'act', '__httpwww_thalesgroup_comrttiXmlTimetablev8_DT_act', _ImportedBinding_darwinpush_xb_ct.ActivityType, unicode_default=' ') __act._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) __act._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) act = property(__act.value, __act.set, None, 'Current Activity Codes') # Attribute planAct uses Python identifier planAct __planAct = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'planAct'), 'planAct', '__httpwww_thalesgroup_comrttiXmlTimetablev8_DT_planAct', _ImportedBinding_darwinpush_xb_ct.ActivityType) __planAct._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) __planAct._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) planAct = property(__planAct.value, __planAct.set, None, 'Planned Activity Codes (if different to current activities)') # Attribute can uses Python identifier can __can = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'can'), 'can', '__httpwww_thalesgroup_comrttiXmlTimetablev8_DT_can', pyxb.binding.datatypes.boolean, unicode_default='false') __can._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) __can._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) can = property(__can.value, __can.set, None, 'Cancelled') # Attribute plat uses Python identifier plat __plat = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'plat'), 'plat', '__httpwww_thalesgroup_comrttiXmlTimetablev8_DT_plat', _ImportedBinding_darwinpush_xb_ct.PlatformType) __plat._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) __plat._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) plat = property(__plat.value, __plat.set, None, 'Platform number') # Attribute pta uses Python identifier pta __pta = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'pta'), 'pta', '__httpwww_thalesgroup_comrttiXmlTimetablev8_DT_pta', _ImportedBinding_darwinpush_xb_ct.RTTITimeType) __pta._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 123, 2) __pta._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 123, 2) pta = property(__pta.value, __pta.set, None, 'Public Scheduled Time of Arrival') # Attribute ptd uses Python identifier ptd __ptd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'ptd'), 'ptd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_DT_ptd', _ImportedBinding_darwinpush_xb_ct.RTTITimeType) __ptd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 128, 2) __ptd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 128, 2) ptd = property(__ptd.value, __ptd.set, None, 'Public Scheduled Time of Departure') # Attribute wta uses Python identifier wta __wta = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wta'), 'wta', '__httpwww_thalesgroup_comrttiXmlTimetablev8_DT_wta', _ImportedBinding_darwinpush_xb_ct.WTimeType, required=True) __wta._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 242, 2) __wta._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 242, 2) wta = property(__wta.value, __wta.set, None, 'Working Scheduled Time of Arrival') # Attribute wtd uses Python identifier wtd __wtd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wtd'), 'wtd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_DT_wtd', _ImportedBinding_darwinpush_xb_ct.WTimeType) __wtd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 247, 2) __wtd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 247, 2) wtd = property(__wtd.value, __wtd.set, None, 'Working Scheduled Time of Departure') # Attribute rdelay uses Python identifier rdelay __rdelay = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'rdelay'), 'rdelay', '__httpwww_thalesgroup_comrttiXmlTimetablev8_DT_rdelay', _ImportedBinding_darwinpush_xb_ct.DelayValueType, unicode_default='0') __rdelay._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 252, 2) __rdelay._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 252, 2) rdelay = property(__rdelay.value, __rdelay.set, None, "A delay value that is implied by a change to the service's route.") _ElementMap.update({ }) _AttributeMap.update({ __tpl.name() : __tpl, __act.name() : __act, __planAct.name() : __planAct, __can.name() : __can, __plat.name() : __plat, __pta.name() : __pta, __ptd.name() : __ptd, __wta.name() : __wta, __wtd.name() : __wtd, __rdelay.name() : __rdelay }) Namespace.addCategoryObject('typeBinding', 'DT', DT) # Complex type {http://www.thalesgroup.com/rtti/XmlTimetable/v8}OPDT with content type EMPTY class OPDT (pyxb.binding.basis.complexTypeDefinition): """Defines an Operational Destination Calling point""" _TypeDefinition = None _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_EMPTY _Abstract = False _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'OPDT') _XSDLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 258, 1) _ElementMap = {} _AttributeMap = {} # Base type is pyxb.binding.datatypes.anyType # Attribute tpl uses Python identifier tpl __tpl = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'tpl'), 'tpl', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPDT_tpl', _ImportedBinding_darwinpush_xb_ct.TiplocType, required=True) __tpl._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) __tpl._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 93, 2) tpl = property(__tpl.value, __tpl.set, None, 'TIPLOC') # Attribute act uses Python identifier act __act = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'act'), 'act', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPDT_act', _ImportedBinding_darwinpush_xb_ct.ActivityType, unicode_default=' ') __act._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) __act._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 98, 2) act = property(__act.value, __act.set, None, 'Current Activity Codes') # Attribute planAct uses Python identifier planAct __planAct = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'planAct'), 'planAct', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPDT_planAct', _ImportedBinding_darwinpush_xb_ct.ActivityType) __planAct._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) __planAct._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 103, 2) planAct = property(__planAct.value, __planAct.set, None, 'Planned Activity Codes (if different to current activities)') # Attribute can uses Python identifier can __can = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'can'), 'can', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPDT_can', pyxb.binding.datatypes.boolean, unicode_default='false') __can._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) __can._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 108, 2) can = property(__can.value, __can.set, None, 'Cancelled') # Attribute plat uses Python identifier plat __plat = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'plat'), 'plat', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPDT_plat', _ImportedBinding_darwinpush_xb_ct.PlatformType) __plat._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) __plat._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 113, 2) plat = property(__plat.value, __plat.set, None, 'Platform number') # Attribute wta uses Python identifier wta __wta = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wta'), 'wta', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPDT_wta', _ImportedBinding_darwinpush_xb_ct.WTimeType, required=True) __wta._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 263, 2) __wta._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 263, 2) wta = property(__wta.value, __wta.set, None, 'Working Scheduled Time of Arrival') # Attribute wtd uses Python identifier wtd __wtd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'wtd'), 'wtd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPDT_wtd', _ImportedBinding_darwinpush_xb_ct.WTimeType) __wtd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 268, 2) __wtd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 268, 2) wtd = property(__wtd.value, __wtd.set, None, 'Working Scheduled Time of Departure') # Attribute rdelay uses Python identifier rdelay __rdelay = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'rdelay'), 'rdelay', '__httpwww_thalesgroup_comrttiXmlTimetablev8_OPDT_rdelay', _ImportedBinding_darwinpush_xb_ct.DelayValueType, unicode_default='0') __rdelay._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 273, 2) __rdelay._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 273, 2) rdelay = property(__rdelay.value, __rdelay.set, None, "A delay value that is implied by a change to the service's route.") _ElementMap.update({ }) _AttributeMap.update({ __tpl.name() : __tpl, __act.name() : __act, __planAct.name() : __planAct, __can.name() : __can, __plat.name() : __plat, __wta.name() : __wta, __wtd.name() : __wtd, __rdelay.name() : __rdelay }) Namespace.addCategoryObject('typeBinding', 'OPDT', OPDT) # Complex type {http://www.thalesgroup.com/rtti/XmlTimetable/v8}Schedule with content type ELEMENT_ONLY class Schedule (pyxb.binding.basis.complexTypeDefinition): """Train Schedule""" _TypeDefinition = None _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_ELEMENT_ONLY _Abstract = False _ExpandedName = pyxb.namespace.ExpandedName(Namespace, 'Schedule') _XSDLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 279, 1) _ElementMap = {} _AttributeMap = {} # Base type is pyxb.binding.datatypes.anyType # Element {http://www.thalesgroup.com/rtti/XmlTimetable/v8}OR uses Python identifier OR __OR = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(Namespace, 'OR'), 'OR', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_httpwww_thalesgroup_comrttiXmlTimetablev8OR', True, pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 285, 4), ) OR = property(__OR.value, __OR.set, None, 'Origin location') # Element {http://www.thalesgroup.com/rtti/XmlTimetable/v8}OPOR uses Python identifier OPOR __OPOR = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(Namespace, 'OPOR'), 'OPOR', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_httpwww_thalesgroup_comrttiXmlTimetablev8OPOR', True, pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 290, 4), ) OPOR = property(__OPOR.value, __OPOR.set, None, 'Operational origin location') # Element {http://www.thalesgroup.com/rtti/XmlTimetable/v8}IP uses Python identifier IP __IP = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(Namespace, 'IP'), 'IP', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_httpwww_thalesgroup_comrttiXmlTimetablev8IP', True, pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 295, 4), ) IP = property(__IP.value, __IP.set, None, 'Intermediate calling location') # Element {http://www.thalesgroup.com/rtti/XmlTimetable/v8}OPIP uses Python identifier OPIP __OPIP = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(Namespace, 'OPIP'), 'OPIP', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_httpwww_thalesgroup_comrttiXmlTimetablev8OPIP', True, pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 300, 4), ) OPIP = property(__OPIP.value, __OPIP.set, None, 'Intermediate operational calling location') # Element {http://www.thalesgroup.com/rtti/XmlTimetable/v8}PP uses Python identifier PP __PP = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(Namespace, 'PP'), 'PP', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_httpwww_thalesgroup_comrttiXmlTimetablev8PP', True, pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 305, 4), ) PP = property(__PP.value, __PP.set, None, 'Passing location') # Element {http://www.thalesgroup.com/rtti/XmlTimetable/v8}DT uses Python identifier DT __DT = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(Namespace, 'DT'), 'DT', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_httpwww_thalesgroup_comrttiXmlTimetablev8DT', True, pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 310, 4), ) DT = property(__DT.value, __DT.set, None, 'Destination location') # Element {http://www.thalesgroup.com/rtti/XmlTimetable/v8}OPDT uses Python identifier OPDT __OPDT = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(Namespace, 'OPDT'), 'OPDT', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_httpwww_thalesgroup_comrttiXmlTimetablev8OPDT', True, pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 315, 4), ) OPDT = property(__OPDT.value, __OPDT.set, None, 'Operational destination location') # Element {http://www.thalesgroup.com/rtti/XmlTimetable/v8}cancelReason uses Python identifier cancelReason __cancelReason = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(Namespace, 'cancelReason'), 'cancelReason', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_httpwww_thalesgroup_comrttiXmlTimetablev8cancelReason', False, pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 321, 3), ) cancelReason = property(__cancelReason.value, __cancelReason.set, None, 'Reason for cancellation of service/location') # Attribute rid uses Python identifier rid __rid = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'rid'), 'rid', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_rid', _ImportedBinding_darwinpush_xb_ct.RIDType, required=True) __rid._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 327, 2) __rid._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 327, 2) rid = property(__rid.value, __rid.set, None, 'RTTI unique Train ID') # Attribute uid uses Python identifier uid __uid = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'uid'), 'uid', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_uid', _ImportedBinding_darwinpush_xb_ct.UIDType, required=True) __uid._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 332, 2) __uid._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 332, 2) uid = property(__uid.value, __uid.set, None, 'Train UID') # Attribute trainId uses Python identifier trainId __trainId = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'trainId'), 'trainId', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_trainId', _ImportedBinding_darwinpush_xb_ct.TrainIdType, required=True) __trainId._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 337, 2) __trainId._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 337, 2) trainId = property(__trainId.value, __trainId.set, None, 'Train ID (Headcode)') # Attribute ssd uses Python identifier ssd __ssd = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'ssd'), 'ssd', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_ssd', _ImportedBinding_darwinpush_xb_ct.RTTIDateType, required=True) __ssd._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 342, 2) __ssd._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 342, 2) ssd = property(__ssd.value, __ssd.set, None, 'Scheduled Start Date') # Attribute toc uses Python identifier toc __toc = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'toc'), 'toc', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_toc', _ImportedBinding_darwinpush_xb_ct.TOCType, required=True) __toc._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 347, 2) __toc._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 347, 2) toc = property(__toc.value, __toc.set, None, 'ATOC Code') # Attribute status uses Python identifier status __status = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'status'), 'status', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_status', _ImportedBinding_darwinpush_xb_ct.CIFTrainStatusType, unicode_default='P') __status._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 352, 2) __status._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 352, 2) status = property(__status.value, __status.set, None, 'Type of service, i.e. Train/Bus/Ship.') # Attribute trainCat uses Python identifier trainCat __trainCat = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'trainCat'), 'trainCat', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_trainCat', _ImportedBinding_darwinpush_xb_ct.CIFTrainCategoryType, unicode_default='OO') __trainCat._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 357, 2) __trainCat._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 357, 2) trainCat = property(__trainCat.value, __trainCat.set, None, 'Category of service.') # Attribute isPassengerSvc uses Python identifier isPassengerSvc __isPassengerSvc = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'isPassengerSvc'), 'isPassengerSvc', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_isPassengerSvc', pyxb.binding.datatypes.boolean, unicode_default='true') __isPassengerSvc._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 362, 2) __isPassengerSvc._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 362, 2) isPassengerSvc = property(__isPassengerSvc.value, __isPassengerSvc.set, None, 'True if Darwin classifies the train category as a passenger service.') # Attribute deleted uses Python identifier deleted __deleted = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'deleted'), 'deleted', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_deleted', pyxb.binding.datatypes.boolean, unicode_default='false') __deleted._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 367, 2) __deleted._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 367, 2) deleted = property(__deleted.value, __deleted.set, None, 'Service has been deleted and should not be used/displayed.') # Attribute isCharter uses Python identifier isCharter __isCharter = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'isCharter'), 'isCharter', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_isCharter', pyxb.binding.datatypes.boolean, unicode_default='false') __isCharter._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 372, 2) __isCharter._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 372, 2) isCharter = property(__isCharter.value, __isCharter.set, None, 'Indicates if this service is a charter service.') # Attribute qtrain uses Python identifier qtrain __qtrain = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'qtrain'), 'qtrain', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_qtrain', pyxb.binding.datatypes.boolean, unicode_default='false') __qtrain._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 377, 2) __qtrain._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 377, 2) qtrain = property(__qtrain.value, __qtrain.set, None, 'True if this is a Q Train (runs as required) that has not yet been activated. Note that a Q Train that has been activated before the XML Timetable file has been built will not have this attribute set true.') # Attribute can uses Python identifier can __can = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'can'), 'can', '__httpwww_thalesgroup_comrttiXmlTimetablev8_Schedule_can', pyxb.binding.datatypes.boolean, unicode_default='false') __can._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 382, 2) __can._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 382, 2) can = property(__can.value, __can.set, None, None) _ElementMap.update({ __OR.name() : __OR, __OPOR.name() : __OPOR, __IP.name() : __IP, __OPIP.name() : __OPIP, __PP.name() : __PP, __DT.name() : __DT, __OPDT.name() : __OPDT, __cancelReason.name() : __cancelReason }) _AttributeMap.update({ __rid.name() : __rid, __uid.name() : __uid, __trainId.name() : __trainId, __ssd.name() : __ssd, __toc.name() : __toc, __status.name() : __status, __trainCat.name() : __trainCat, __isPassengerSvc.name() : __isPassengerSvc, __deleted.name() : __deleted, __isCharter.name() : __isCharter, __qtrain.name() : __qtrain, __can.name() : __can }) Namespace.addCategoryObject('typeBinding', 'Schedule', Schedule) # Complex type [anonymous] with content type ELEMENT_ONLY class CTD_ANON (pyxb.binding.basis.complexTypeDefinition): """Push Port Timetable Schema""" _TypeDefinition = None _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_ELEMENT_ONLY _Abstract = False _ExpandedName = None _XSDLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 389, 2) _ElementMap = {} _AttributeMap = {} # Base type is pyxb.binding.datatypes.anyType # Element {http://www.thalesgroup.com/rtti/XmlTimetable/v8}Journey uses Python identifier Journey __Journey = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(Namespace, 'Journey'), 'Journey', '__httpwww_thalesgroup_comrttiXmlTimetablev8_CTD_ANON_httpwww_thalesgroup_comrttiXmlTimetablev8Journey', True, pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 391, 4), ) Journey = property(__Journey.value, __Journey.set, None, 'Schedule of a service that exists in Darwin') # Element {http://www.thalesgroup.com/rtti/XmlTimetable/v8}Association uses Python identifier Association __Association = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(Namespace, 'Association'), 'Association', '__httpwww_thalesgroup_comrttiXmlTimetablev8_CTD_ANON_httpwww_thalesgroup_comrttiXmlTimetablev8Association', True, pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 396, 4), ) Association = property(__Association.value, __Association.set, None, 'An association between two schedules') # Attribute timetableID uses Python identifier timetableID __timetableID = pyxb.binding.content.AttributeUse(pyxb.namespace.ExpandedName(None, 'timetableID'), 'timetableID', '__httpwww_thalesgroup_comrttiXmlTimetablev8_CTD_ANON_timetableID', _ImportedBinding_darwinpush_xb_ct.TimetableIDType, required=True) __timetableID._DeclarationLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 402, 3) __timetableID._UseLocation = pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 402, 3) timetableID = property(__timetableID.value, __timetableID.set, None, 'The ID of the RTTI timetable from which this XML timetable was generated.') _ElementMap.update({ __Journey.name() : __Journey, __Association.name() : __Association }) _AttributeMap.update({ __timetableID.name() : __timetableID }) PportTimetable = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'PportTimetable'), CTD_ANON, documentation='Push Port Timetable Schema', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 385, 1)) Namespace.addCategoryObject('elementBinding', PportTimetable.name().localName(), PportTimetable) Association._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'main'), AssocService, scope=Association, documentation='The through, previous working or link-to service', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 57, 3))) Association._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'assoc'), AssocService, scope=Association, documentation='The starting, terminating, subsequent working or link-from service', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 62, 3))) def _BuildAutomaton (): # Remove this helper function from the namespace after it is invoked global _BuildAutomaton del _BuildAutomaton import pyxb.utils.fac as fac counters = set() states = [] final_update = None symbol = pyxb.binding.content.ElementUse(Association._UseForTag(pyxb.namespace.ExpandedName(Namespace, 'main')), pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 57, 3)) st_0 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False) states.append(st_0) final_update = set() symbol = pyxb.binding.content.ElementUse(Association._UseForTag(pyxb.namespace.ExpandedName(Namespace, 'assoc')), pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 62, 3)) st_1 = fac.State(symbol, is_initial=False, final_update=final_update, is_unordered_catenation=False) states.append(st_1) transitions = [] transitions.append(fac.Transition(st_1, [ ])) st_0._set_transitionSet(transitions) transitions = [] st_1._set_transitionSet(transitions) return fac.Automaton(states, counters, False, containing_state=None) Association._Automaton = _BuildAutomaton() Schedule._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'OR'), OR, scope=Schedule, documentation='Origin location', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 285, 4))) Schedule._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'OPOR'), OPOR, scope=Schedule, documentation='Operational origin location', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 290, 4))) Schedule._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'IP'), IP, scope=Schedule, documentation='Intermediate calling location', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 295, 4))) Schedule._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'OPIP'), OPIP, scope=Schedule, documentation='Intermediate operational calling location', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 300, 4))) Schedule._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'PP'), PP, scope=Schedule, documentation='Passing location', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 305, 4))) Schedule._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'DT'), DT, scope=Schedule, documentation='Destination location', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 310, 4))) Schedule._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'OPDT'), OPDT, scope=Schedule, documentation='Operational destination location', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 315, 4))) Schedule._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'cancelReason'), _ImportedBinding_darwinpush_xb_ct.DisruptionReasonType, scope=Schedule, documentation='Reason for cancellation of service/location', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 321, 3))) def _BuildAutomaton_ (): # Remove this helper function from the namespace after it is invoked global _BuildAutomaton_ del _BuildAutomaton_ import pyxb.utils.fac as fac counters = set() cc_0 = fac.CounterCondition(min=2, max=None, metadata=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 284, 3)) counters.add(cc_0) cc_1 = fac.CounterCondition(min=0, max=1, metadata=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 321, 3)) counters.add(cc_1) states = [] final_update = set() final_update.add(fac.UpdateInstruction(cc_0, False)) symbol = pyxb.binding.content.ElementUse(Schedule._UseForTag(pyxb.namespace.ExpandedName(Namespace, 'OR')), pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 285, 4)) st_0 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False) states.append(st_0) final_update = set() final_update.add(fac.UpdateInstruction(cc_0, False)) symbol = pyxb.binding.content.ElementUse(Schedule._UseForTag(pyxb.namespace.ExpandedName(Namespace, 'OPOR')), pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 290, 4)) st_1 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False) states.append(st_1) final_update = set() final_update.add(fac.UpdateInstruction(cc_0, False)) symbol = pyxb.binding.content.ElementUse(Schedule._UseForTag(pyxb.namespace.ExpandedName(Namespace, 'IP')), pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 295, 4)) st_2 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False) states.append(st_2) final_update = set() final_update.add(fac.UpdateInstruction(cc_0, False)) symbol = pyxb.binding.content.ElementUse(Schedule._UseForTag(pyxb.namespace.ExpandedName(Namespace, 'OPIP')), pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 300, 4)) st_3 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False) states.append(st_3) final_update = set() final_update.add(fac.UpdateInstruction(cc_0, False)) symbol = pyxb.binding.content.ElementUse(Schedule._UseForTag(pyxb.namespace.ExpandedName(Namespace, 'PP')), pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 305, 4)) st_4 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False) states.append(st_4) final_update = set() final_update.add(fac.UpdateInstruction(cc_0, False)) symbol = pyxb.binding.content.ElementUse(Schedule._UseForTag(pyxb.namespace.ExpandedName(Namespace, 'DT')), pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 310, 4)) st_5 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False) states.append(st_5) final_update = set() final_update.add(fac.UpdateInstruction(cc_0, False)) symbol = pyxb.binding.content.ElementUse(Schedule._UseForTag(pyxb.namespace.ExpandedName(Namespace, 'OPDT')), pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 315, 4)) st_6 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False) states.append(st_6) final_update = set() final_update.add(fac.UpdateInstruction(cc_1, False)) symbol = pyxb.binding.content.ElementUse(Schedule._UseForTag(pyxb.namespace.ExpandedName(Namespace, 'cancelReason')), pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 321, 3)) st_7 = fac.State(symbol, is_initial=False, final_update=final_update, is_unordered_catenation=False) states.append(st_7) transitions = [] transitions.append(fac.Transition(st_0, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_1, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_2, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_3, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_4, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_5, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_6, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_7, [ fac.UpdateInstruction(cc_0, False) ])) st_0._set_transitionSet(transitions) transitions = [] transitions.append(fac.Transition(st_0, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_1, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_2, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_3, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_4, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_5, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_6, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_7, [ fac.UpdateInstruction(cc_0, False) ])) st_1._set_transitionSet(transitions) transitions = [] transitions.append(fac.Transition(st_0, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_1, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_2, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_3, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_4, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_5, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_6, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_7, [ fac.UpdateInstruction(cc_0, False) ])) st_2._set_transitionSet(transitions) transitions = [] transitions.append(fac.Transition(st_0, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_1, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_2, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_3, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_4, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_5, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_6, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_7, [ fac.UpdateInstruction(cc_0, False) ])) st_3._set_transitionSet(transitions) transitions = [] transitions.append(fac.Transition(st_0, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_1, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_2, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_3, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_4, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_5, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_6, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_7, [ fac.UpdateInstruction(cc_0, False) ])) st_4._set_transitionSet(transitions) transitions = [] transitions.append(fac.Transition(st_0, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_1, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_2, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_3, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_4, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_5, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_6, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_7, [ fac.UpdateInstruction(cc_0, False) ])) st_5._set_transitionSet(transitions) transitions = [] transitions.append(fac.Transition(st_0, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_1, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_2, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_3, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_4, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_5, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_6, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_7, [ fac.UpdateInstruction(cc_0, False) ])) st_6._set_transitionSet(transitions) transitions = [] transitions.append(fac.Transition(st_7, [ fac.UpdateInstruction(cc_1, True) ])) st_7._set_transitionSet(transitions) return fac.Automaton(states, counters, False, containing_state=None) Schedule._Automaton = _BuildAutomaton_() CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'Journey'), Schedule, scope=CTD_ANON, documentation='Schedule of a service that exists in Darwin', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 391, 4))) CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(Namespace, 'Association'), Association, scope=CTD_ANON, documentation='An association between two schedules', location=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 396, 4))) def _BuildAutomaton_2 (): # Remove this helper function from the namespace after it is invoked global _BuildAutomaton_2 del _BuildAutomaton_2 import pyxb.utils.fac as fac counters = set() cc_0 = fac.CounterCondition(min=0, max=None, metadata=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 391, 4)) counters.add(cc_0) cc_1 = fac.CounterCondition(min=0, max=None, metadata=pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 396, 4)) counters.add(cc_1) states = [] final_update = set() final_update.add(fac.UpdateInstruction(cc_0, False)) symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(Namespace, 'Journey')), pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 391, 4)) st_0 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False) states.append(st_0) final_update = set() final_update.add(fac.UpdateInstruction(cc_1, False)) symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(Namespace, 'Association')), pyxb.utils.utility.Location('/home/gberg/code/src/fstr/darwinpush/xsd/rttiCTTSchema_v8.xsd', 396, 4)) st_1 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False) states.append(st_1) transitions = [] transitions.append(fac.Transition(st_0, [ fac.UpdateInstruction(cc_0, True) ])) transitions.append(fac.Transition(st_1, [ fac.UpdateInstruction(cc_0, False) ])) st_0._set_transitionSet(transitions) transitions = [] transitions.append(fac.Transition(st_1, [ fac.UpdateInstruction(cc_1, True) ])) st_1._set_transitionSet(transitions) return fac.Automaton(states, counters, True, containing_state=None) CTD_ANON._Automaton = _BuildAutomaton_2()
apache-2.0
[ 3, 16605, 13245, 5335, 15, 1774, 15, 1773, 15, 9140, 3754, 647, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1611, 20806, 17792, 367, 653, 45, 26, 16, 66, 13744, 556, 29929, 1780, 5533, 6683, 66, 25, 66, 2635, 708, 69, 25, 69, 25, 65, 18, 70, 2417, 383, 1407, 1079, 199, 3, 17065, 6900, 13, 966, 13, 1789, 3193, 26, 2260, 26, 1079, 14, 28082, 16414, 701, 1611, 20806, 1015, 413, 14, 18, 14, 20, 1808, 2018, 650, 14, 20, 14, 17, 14, 5094, 14, 16, 199, 3, 19317, 1455, 921, 1544, 14, 273, 7098, 923, 14, 957, 15, 2591, 280, 15, 8672, 1366, 1224, 15, 86, 24, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 27049, 199, 646, 27049, 14, 9140, 199, 646, 27049, 14, 9140, 14, 14338, 281, 199, 646, 5890, 199, 646, 27049, 14, 1208, 14, 16877, 199, 646, 27049, 14, 1208, 14, 4556, 1208, 199, 646, 984, 199, 646, 27049, 14, 1208, 14, 4174, 465, 485, 4174, 199, 199, 3, 18276, 5148, 367, 17792, 2737, 737, 314, 2011, 900, 199, 63, 18514, 6685, 275, 27049, 14, 1208, 14, 16877, 14, 11427, 7544, 360, 349, 26, 2580, 26, 21, 12809, 70, 17, 271, 13, 69, 25, 2177, 13, 845, 69, 20, 13, 2501, 1400, 13, 65, 966, 2835, 696, 1400, 371, 16, 358, 199, 199, 3, 3394, 402, 1611, 20806, 1202, 370, 3550, 314, 17792, 199, 63, 2713, 20806, 3353, 275, 283, 17, 14, 18, 14, 20, 7, 199, 3, 17065, 17792, 787, 440, 9025, 9371, 1611, 20806, 5459, 199, 692, 27049, 855, 1023, 363, 1137, 485, 2713, 20806, 3353, 26, 272, 746, 27049, 14, 2713, 20806, 3353, 547, 1547, 2713, 20806, 3353, 9, 199, 199, 3, 3161, 17792, 367, 10747, 8439, 1901, 4177, 199, 646, 27049, 14, 9140, 14, 14184, 83, 199, 646, 366, 22822, 5335, 14, 1774, 14, 319, 465, 485, 8499, 1376, 17490, 63, 13245, 5335, 63, 1774, 63, 319, 199, 199, 3, 6944, 26, 2900, 3231, 18707, 787, 4644, 4453, 314, 11696, 199, 8814, 275, 27049, 14, 3251, 14, 8814, 1858, 7639, 360, 1014, 921, 1544, 14, 273, 7098, 923, 14, 957, 15, 2591, 280, 15, 8672, 1366, 1224, 15, 86, 24, 297, 1218, 63, 692, 63, 4752, 29, 549, 9, 199, 8814, 14, 6472, 28731, 2941, 466, 17490, 297, 283, 2108, 17490, 1105, 199, 199, 318, 2790, 2532, 5564, 334, 1652, 63, 505, 12, 849, 63, 3251, 29, 403, 12, 2909, 63, 1095, 29, 403, 304, 272, 408, 4003, 314, 1627, 4692, 436, 675, 314, 2213, 1819, 370, 1218, 282, 272, 2018, 1256, 14, 339, 768, 635, 2748, 63, 505, 1626, 4692, 2213, 14, 221, 961, 1077, 506, 666, 334, 4718, 499, 272, 620, 503, 2018, 650, 2783, 395, 503, 282, 1318, 334, 4718, 499, 2649, 503, 2018, 650, 272, 620, 9, 315, 314, 491, 91, 647, 1774, 423, 3205, 7630, 93, 2644, 14, 339, 768, 6691, 849, 63, 3251, 710, 491, 91, 647, 1774, 14, 8814, 93, 1256, 370, 675, 465, 314, 272, 849, 3231, 2382, 2337, 365, 949, 849, 3231, 315, 4194, 14, 272, 982, 21994, 503, 445, 91, 403, 1386, 314, 3231, 402, 314, 859, 3035, 272, 642, 805, 911, 506, 1202, 14, 339, 768, 6691, 2909, 63, 1095, 26, 1626, 909, 370, 506, 18894, 465, 314, 1300, 402, 1006, 272, 491, 91, 647, 1774, 14, 1208, 14, 16877, 14, 6592, 93, 4454, 4568, 543, 4474, 436, 272, 2251, 8860, 701, 314, 1798, 14, 221, 2047, 5594, 986, 314, 9022, 687, 1314, 272, 314, 2213, 1990, 15884, 14, 272, 408, 339, 340, 27049, 14, 4317, 6609, 63, 14338, 281, 1137, 27049, 423, 4317, 6609, 26, 267, 8266, 275, 27049, 14, 1208, 14, 4556, 1208, 14, 1558, 1378, 10462, 8, 1652, 63, 505, 9, 267, 372, 2790, 2532, 10462, 8, 4556, 14, 22464, 12, 849, 63, 3251, 29, 885, 63, 3251, 9, 272, 340, 849, 63, 3251, 365, 488, 26, 267, 849, 63, 3251, 275, 19317, 14, 10538, 8814, 342, 272, 308, 1219, 281, 275, 27049, 14, 9140, 14, 14338, 281, 14, 1875, 63, 2087, 8, 10538, 63, 3251, 29, 885, 63, 3251, 12, 2909, 63, 1095, 29, 1985, 63, 1095, 9, 272, 3016, 275, 308, 1219, 281, 14, 362, 2714, 2461, 342, 272, 2748, 68, 275, 2748, 63, 505, 272, 340, 1228, 8, 1652, 68, 12, 485, 4174, 14, 505, 63, 466, 304, 267, 2748, 68, 275, 2748, 68, 14, 2143, 8, 647, 1774, 423, 3205, 7630, 9, 272, 308, 1219, 281, 14, 1122, 8, 2308, 14, 15466, 8, 1652, 68, 430, 272, 1256, 275, 3016, 14, 1231, 1692, 342, 272, 372, 1256, 199, 199, 318, 2790, 2532, 10462, 334, 932, 12, 849, 63, 3251, 29, 403, 304, 272, 408, 2499, 282, 2018, 1256, 687, 314, 1627, 14316, 1031, 14, 272, 710, 1031, 1947, 1471, 17118, 370, 376, 1819, 12560, 315, 642, 859, 14, 339, 768, 6667, 26, 2104, 4477, 675, 402, 14316, 3217, 365, 23361, 27, 675, 491, 91, 2499, 2532, 5564, 93, 1041, 272, 340, 849, 63, 3251, 365, 488, 26, 267, 849, 63, 3251, 275, 19317, 14, 10538, 8814, 342, 272, 372, 27049, 14, 9140, 14, 19220, 14, 2108, 14, 9874, 2499, 2532, 10462, 8, 932, 12, 849, 63, 3251, 9, 421, 199, 3, 18840, 530, 3486, 730, 26, 469, 1014, 921, 1544, 14, 273, 7098, 923, 14, 957, 15, 2591, 280, 15, 8672, 1366, 1224, 15, 86, 24, 93, 7841, 804, 199, 533, 13573, 804, 334, 647, 1774, 14, 9140, 14, 14184, 83, 14, 875, 12, 27049, 14, 9140, 14, 19220, 14, 14130, 63, 20406, 304, 339, 408, 18662, 13573, 2434, 26, 1603, 42, 29, 13005, 12, 812, 54, 29, 8862, 12, 491, 43, 29, 26748, 12, 25413, 29, 5765, 13, 18356, 624, 339, 485, 27136, 985, 275, 27049, 14, 3251, 14, 27136, 985, 8, 8814, 12, 283, 7841, 804, 358, 272, 485, 56, 3693, 6592, 275, 27049, 14, 1208, 14, 16877, 14, 6592, 2336, 4219, 15, 71, 14630, 15, 600, 15, 2164, 15, 70, 495, 15, 13245, 5335, 15, 10515, 15, 2591, 280, 19766, 6700, 63, 86, 24, 14, 10515, 297, 7294, 12, 413, 9, 272, 485, 17763, 275, 283, 18662, 13573, 2434, 26, 1603, 42, 29, 13005, 12, 812 ]
[ 16605, 13245, 5335, 15, 1774, 15, 1773, 15, 9140, 3754, 647, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 1611, 20806, 17792, 367, 653, 45, 26, 16, 66, 13744, 556, 29929, 1780, 5533, 6683, 66, 25, 66, 2635, 708, 69, 25, 69, 25, 65, 18, 70, 2417, 383, 1407, 1079, 199, 3, 17065, 6900, 13, 966, 13, 1789, 3193, 26, 2260, 26, 1079, 14, 28082, 16414, 701, 1611, 20806, 1015, 413, 14, 18, 14, 20, 1808, 2018, 650, 14, 20, 14, 17, 14, 5094, 14, 16, 199, 3, 19317, 1455, 921, 1544, 14, 273, 7098, 923, 14, 957, 15, 2591, 280, 15, 8672, 1366, 1224, 15, 86, 24, 199, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 646, 27049, 199, 646, 27049, 14, 9140, 199, 646, 27049, 14, 9140, 14, 14338, 281, 199, 646, 5890, 199, 646, 27049, 14, 1208, 14, 16877, 199, 646, 27049, 14, 1208, 14, 4556, 1208, 199, 646, 984, 199, 646, 27049, 14, 1208, 14, 4174, 465, 485, 4174, 199, 199, 3, 18276, 5148, 367, 17792, 2737, 737, 314, 2011, 900, 199, 63, 18514, 6685, 275, 27049, 14, 1208, 14, 16877, 14, 11427, 7544, 360, 349, 26, 2580, 26, 21, 12809, 70, 17, 271, 13, 69, 25, 2177, 13, 845, 69, 20, 13, 2501, 1400, 13, 65, 966, 2835, 696, 1400, 371, 16, 358, 199, 199, 3, 3394, 402, 1611, 20806, 1202, 370, 3550, 314, 17792, 199, 63, 2713, 20806, 3353, 275, 283, 17, 14, 18, 14, 20, 7, 199, 3, 17065, 17792, 787, 440, 9025, 9371, 1611, 20806, 5459, 199, 692, 27049, 855, 1023, 363, 1137, 485, 2713, 20806, 3353, 26, 272, 746, 27049, 14, 2713, 20806, 3353, 547, 1547, 2713, 20806, 3353, 9, 199, 199, 3, 3161, 17792, 367, 10747, 8439, 1901, 4177, 199, 646, 27049, 14, 9140, 14, 14184, 83, 199, 646, 366, 22822, 5335, 14, 1774, 14, 319, 465, 485, 8499, 1376, 17490, 63, 13245, 5335, 63, 1774, 63, 319, 199, 199, 3, 6944, 26, 2900, 3231, 18707, 787, 4644, 4453, 314, 11696, 199, 8814, 275, 27049, 14, 3251, 14, 8814, 1858, 7639, 360, 1014, 921, 1544, 14, 273, 7098, 923, 14, 957, 15, 2591, 280, 15, 8672, 1366, 1224, 15, 86, 24, 297, 1218, 63, 692, 63, 4752, 29, 549, 9, 199, 8814, 14, 6472, 28731, 2941, 466, 17490, 297, 283, 2108, 17490, 1105, 199, 199, 318, 2790, 2532, 5564, 334, 1652, 63, 505, 12, 849, 63, 3251, 29, 403, 12, 2909, 63, 1095, 29, 403, 304, 272, 408, 4003, 314, 1627, 4692, 436, 675, 314, 2213, 1819, 370, 1218, 282, 272, 2018, 1256, 14, 339, 768, 635, 2748, 63, 505, 1626, 4692, 2213, 14, 221, 961, 1077, 506, 666, 334, 4718, 499, 272, 620, 503, 2018, 650, 2783, 395, 503, 282, 1318, 334, 4718, 499, 2649, 503, 2018, 650, 272, 620, 9, 315, 314, 491, 91, 647, 1774, 423, 3205, 7630, 93, 2644, 14, 339, 768, 6691, 849, 63, 3251, 710, 491, 91, 647, 1774, 14, 8814, 93, 1256, 370, 675, 465, 314, 272, 849, 3231, 2382, 2337, 365, 949, 849, 3231, 315, 4194, 14, 272, 982, 21994, 503, 445, 91, 403, 1386, 314, 3231, 402, 314, 859, 3035, 272, 642, 805, 911, 506, 1202, 14, 339, 768, 6691, 2909, 63, 1095, 26, 1626, 909, 370, 506, 18894, 465, 314, 1300, 402, 1006, 272, 491, 91, 647, 1774, 14, 1208, 14, 16877, 14, 6592, 93, 4454, 4568, 543, 4474, 436, 272, 2251, 8860, 701, 314, 1798, 14, 221, 2047, 5594, 986, 314, 9022, 687, 1314, 272, 314, 2213, 1990, 15884, 14, 272, 408, 339, 340, 27049, 14, 4317, 6609, 63, 14338, 281, 1137, 27049, 423, 4317, 6609, 26, 267, 8266, 275, 27049, 14, 1208, 14, 4556, 1208, 14, 1558, 1378, 10462, 8, 1652, 63, 505, 9, 267, 372, 2790, 2532, 10462, 8, 4556, 14, 22464, 12, 849, 63, 3251, 29, 885, 63, 3251, 9, 272, 340, 849, 63, 3251, 365, 488, 26, 267, 849, 63, 3251, 275, 19317, 14, 10538, 8814, 342, 272, 308, 1219, 281, 275, 27049, 14, 9140, 14, 14338, 281, 14, 1875, 63, 2087, 8, 10538, 63, 3251, 29, 885, 63, 3251, 12, 2909, 63, 1095, 29, 1985, 63, 1095, 9, 272, 3016, 275, 308, 1219, 281, 14, 362, 2714, 2461, 342, 272, 2748, 68, 275, 2748, 63, 505, 272, 340, 1228, 8, 1652, 68, 12, 485, 4174, 14, 505, 63, 466, 304, 267, 2748, 68, 275, 2748, 68, 14, 2143, 8, 647, 1774, 423, 3205, 7630, 9, 272, 308, 1219, 281, 14, 1122, 8, 2308, 14, 15466, 8, 1652, 68, 430, 272, 1256, 275, 3016, 14, 1231, 1692, 342, 272, 372, 1256, 199, 199, 318, 2790, 2532, 10462, 334, 932, 12, 849, 63, 3251, 29, 403, 304, 272, 408, 2499, 282, 2018, 1256, 687, 314, 1627, 14316, 1031, 14, 272, 710, 1031, 1947, 1471, 17118, 370, 376, 1819, 12560, 315, 642, 859, 14, 339, 768, 6667, 26, 2104, 4477, 675, 402, 14316, 3217, 365, 23361, 27, 675, 491, 91, 2499, 2532, 5564, 93, 1041, 272, 340, 849, 63, 3251, 365, 488, 26, 267, 849, 63, 3251, 275, 19317, 14, 10538, 8814, 342, 272, 372, 27049, 14, 9140, 14, 19220, 14, 2108, 14, 9874, 2499, 2532, 10462, 8, 932, 12, 849, 63, 3251, 9, 421, 199, 3, 18840, 530, 3486, 730, 26, 469, 1014, 921, 1544, 14, 273, 7098, 923, 14, 957, 15, 2591, 280, 15, 8672, 1366, 1224, 15, 86, 24, 93, 7841, 804, 199, 533, 13573, 804, 334, 647, 1774, 14, 9140, 14, 14184, 83, 14, 875, 12, 27049, 14, 9140, 14, 19220, 14, 14130, 63, 20406, 304, 339, 408, 18662, 13573, 2434, 26, 1603, 42, 29, 13005, 12, 812, 54, 29, 8862, 12, 491, 43, 29, 26748, 12, 25413, 29, 5765, 13, 18356, 624, 339, 485, 27136, 985, 275, 27049, 14, 3251, 14, 27136, 985, 8, 8814, 12, 283, 7841, 804, 358, 272, 485, 56, 3693, 6592, 275, 27049, 14, 1208, 14, 16877, 14, 6592, 2336, 4219, 15, 71, 14630, 15, 600, 15, 2164, 15, 70, 495, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
cnexus/kernel_d2spr_tw_422
tools/perf/util/setup.py
4998
1330
#!/usr/bin/python2 from distutils.core import setup, Extension from os import getenv from distutils.command.build_ext import build_ext as _build_ext from distutils.command.install_lib import install_lib as _install_lib class build_ext(_build_ext): def finalize_options(self): _build_ext.finalize_options(self) self.build_lib = build_lib self.build_temp = build_tmp class install_lib(_install_lib): def finalize_options(self): _install_lib.finalize_options(self) self.build_dir = build_lib cflags = ['-fno-strict-aliasing', '-Wno-write-strings'] cflags += getenv('CFLAGS', '').split() build_lib = getenv('PYTHON_EXTBUILD_LIB') build_tmp = getenv('PYTHON_EXTBUILD_TMP') ext_sources = [f.strip() for f in file('util/python-ext-sources') if len(f.strip()) > 0 and f[0] != '#'] perf = Extension('perf', sources = ext_sources, include_dirs = ['util/include'], extra_compile_args = cflags, ) setup(name='perf', version='0.1', description='Interface with the Linux profiling infrastructure', author='Arnaldo Carvalho de Melo', author_email='acme@redhat.com', license='GPLv2', url='http://perf.wiki.kernel.org', ext_modules=[perf], cmdclass={'build_ext': build_ext, 'install_lib': install_lib})
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 18, 199, 199, 504, 7065, 14, 1018, 492, 3272, 12, 13282, 199, 504, 747, 492, 29626, 199, 199, 504, 7065, 14, 1531, 14, 1506, 63, 832, 257, 492, 1900, 63, 832, 257, 465, 485, 1506, 63, 832, 199, 504, 7065, 14, 1531, 14, 3174, 63, 773, 492, 3907, 63, 773, 465, 485, 3174, 63, 773, 199, 199, 533, 1900, 63, 832, 1547, 1506, 63, 832, 304, 272, 347, 17284, 63, 1419, 8, 277, 304, 267, 485, 1506, 63, 832, 14, 14450, 63, 1419, 8, 277, 9, 267, 291, 14, 1506, 63, 773, 221, 275, 1900, 63, 773, 267, 291, 14, 1506, 63, 808, 275, 1900, 63, 2791, 199, 199, 533, 3907, 63, 773, 1547, 3174, 63, 773, 304, 272, 347, 17284, 63, 1419, 8, 277, 304, 267, 485, 3174, 63, 773, 14, 14450, 63, 1419, 8, 277, 9, 267, 291, 14, 1506, 63, 694, 275, 1900, 63, 773, 421, 199, 14002, 275, 11573, 70, 889, 13, 4768, 13, 3620, 316, 297, 2475, 55, 889, 13, 952, 13, 5465, 418, 199, 14002, 847, 29626, 360, 14804, 297, 12548, 1294, 342, 199, 199, 1506, 63, 773, 275, 29626, 360, 11720, 63, 2472, 8248, 63, 5617, 358, 199, 1506, 63, 2791, 275, 29626, 360, 11720, 63, 2472, 8248, 63, 17983, 358, 199, 199, 832, 63, 4553, 275, 359, 70, 14, 1913, 342, 367, 289, 315, 570, 360, 1974, 15, 1548, 13, 832, 13, 4553, 358, 1585, 198, 692, 822, 8, 70, 14, 1913, 1012, 690, 378, 436, 289, 59, 16, 61, 1137, 3943, 418, 199, 199, 9452, 275, 13282, 360, 9452, 297, 29294, 5274, 275, 1599, 63, 4553, 12, 29294, 2387, 63, 3220, 275, 788, 1974, 15, 2613, 995, 29294, 2402, 63, 2014, 63, 589, 275, 13426, 12, 326, 776, 199, 199, 2758, 8, 354, 534, 9452, 297, 489, 1015, 534, 16, 14, 17, 297, 489, 1369, 534, 4267, 543, 314, 10130, 30238, 28890, 6976, 297, 489, 4132, 534, 20498, 279, 1117, 14243, 637, 526, 477, 3194, 320, 297, 489, 4132, 63, 2123, 534, 18107, 32, 17164, 14, 957, 297, 489, 4190, 534, 28863, 18, 297, 489, 1166, 534, 1014, 921, 9452, 14, 6797, 14, 4989, 14, 1308, 297, 489, 1599, 63, 3112, 1524, 9452, 467, 489, 2088, 533, 3713, 1506, 63, 832, 356, 1900, 63, 832, 12, 283, 3174, 63, 773, 356, 3907, 63, 773, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 18, 199, 199, 504, 7065, 14, 1018, 492, 3272, 12, 13282, 199, 504, 747, 492, 29626, 199, 199, 504, 7065, 14, 1531, 14, 1506, 63, 832, 257, 492, 1900, 63, 832, 257, 465, 485, 1506, 63, 832, 199, 504, 7065, 14, 1531, 14, 3174, 63, 773, 492, 3907, 63, 773, 465, 485, 3174, 63, 773, 199, 199, 533, 1900, 63, 832, 1547, 1506, 63, 832, 304, 272, 347, 17284, 63, 1419, 8, 277, 304, 267, 485, 1506, 63, 832, 14, 14450, 63, 1419, 8, 277, 9, 267, 291, 14, 1506, 63, 773, 221, 275, 1900, 63, 773, 267, 291, 14, 1506, 63, 808, 275, 1900, 63, 2791, 199, 199, 533, 3907, 63, 773, 1547, 3174, 63, 773, 304, 272, 347, 17284, 63, 1419, 8, 277, 304, 267, 485, 3174, 63, 773, 14, 14450, 63, 1419, 8, 277, 9, 267, 291, 14, 1506, 63, 694, 275, 1900, 63, 773, 421, 199, 14002, 275, 11573, 70, 889, 13, 4768, 13, 3620, 316, 297, 2475, 55, 889, 13, 952, 13, 5465, 418, 199, 14002, 847, 29626, 360, 14804, 297, 12548, 1294, 342, 199, 199, 1506, 63, 773, 275, 29626, 360, 11720, 63, 2472, 8248, 63, 5617, 358, 199, 1506, 63, 2791, 275, 29626, 360, 11720, 63, 2472, 8248, 63, 17983, 358, 199, 199, 832, 63, 4553, 275, 359, 70, 14, 1913, 342, 367, 289, 315, 570, 360, 1974, 15, 1548, 13, 832, 13, 4553, 358, 1585, 198, 692, 822, 8, 70, 14, 1913, 1012, 690, 378, 436, 289, 59, 16, 61, 1137, 3943, 418, 199, 199, 9452, 275, 13282, 360, 9452, 297, 29294, 5274, 275, 1599, 63, 4553, 12, 29294, 2387, 63, 3220, 275, 788, 1974, 15, 2613, 995, 29294, 2402, 63, 2014, 63, 589, 275, 13426, 12, 326, 776, 199, 199, 2758, 8, 354, 534, 9452, 297, 489, 1015, 534, 16, 14, 17, 297, 489, 1369, 534, 4267, 543, 314, 10130, 30238, 28890, 6976, 297, 489, 4132, 534, 20498, 279, 1117, 14243, 637, 526, 477, 3194, 320, 297, 489, 4132, 63, 2123, 534, 18107, 32, 17164, 14, 957, 297, 489, 4190, 534, 28863, 18, 297, 489, 1166, 534, 1014, 921, 9452, 14, 6797, 14, 4989, 14, 1308, 297, 489, 1599, 63, 3112, 1524, 9452, 467, 489, 2088, 533, 3713, 1506, 63, 832, 356, 1900, 63, 832, 12, 283, 3174, 63, 773, 356, 3907, 63, 773, 1552, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
flake123p/ProjectH
Python/Think01_swampy-2.1.5/Sync.py
2
24407
#!/usr/bin/python """This module is part of Swampy, a suite of programs available from allendowney.com/swampy. Copyright 2011 Allen B. Downey Distributed under the GNU General Public License at gnu.org/licenses/gpl.html. """ import optparse import os import copy import random import sys import string import time # the following definitions can be accessed in the simulator current_thread = None def noop(*args): """A handy function taht does nothing.""" def balk(): """Jumps to the top of the column.""" current_thread.balk() class Semaphore: """Represents a semaphore in the simulator. Maintains a random queue. """ def __init__(self, n=0): self.n = n self.queue = [] def __str__(self): return str(self.n) def wait(self): self.n -= 1 if self.n < 0: self.block() return self.n def block(self): thread = current_thread thread.enqueue() self.queue.append(thread) def signal(self, n=1): for i in range(n): self.n += 1 if self.queue: self.unblock() def unblock(self): """Chooses a random thread and unblocks it.""" thread = random.choice(self.queue) self.queue.remove(thread) thread.dequeue() thread.next_loop() class FifoSemaphore(Semaphore): """Semaphore that implements a FIFO queue.""" def unblock(self): """Chooses the first thread and unblocks it.""" thread = self.queue.pop(0) thread.dequeue() thread.next_loop() class Lightswitch: """Encapsulates the lightswitch pattern.""" def __init__(self): self.counter = 0 self.mutex = Semaphore(1) def lock(self, semaphore): self.mutex.wait() self.counter += 1 if self.counter == 1: semaphore.wait() self.mutex.signal() def unlock(self, semaphore): self.mutex.wait() self.counter -= 1 if self.counter == 0: semaphore.signal() self.mutex.signal() def pid(): """Gets the ID of the current thread.""" return current_thread.name def num_threads(): """Gets the number of threads.""" sync = current_thread.column.p return len(sync.threads) # make globals and locals for the simulator sim_globals = copy.copy(globals()) sim_locals = dict() # anything defined after this point is not available inside the simulator from tkinter import N, S, E, W, TOP, BOTTOM, LEFT, RIGHT, END from Gui import Gui, GuiCanvas # get the version of Python v = sys.version.split()[0].split('.') major = int(v[0]) if major == 2: all_thread_names = string.uppercase + string.lowercase else: all_thread_names = string.ascii_uppercase + string.ascii_lowercase font = ("Courier", 12) FSU = 9 # FSU, the fundamental Sync unit, # determines the size of most things. class Sync(Gui): """Represents the thread simulator.""" def __init__(self, args=['']): Gui.__init__(self) self.parse_args(args) self.namer = Namer() self.locals = sim_locals self.globals = sim_globals self.views = {} self.w = self self.threads = [] self.running = False self.delay = 0.2 self.setup() self.run_init() for col in self.cols: col.create_thread() def parse_args(self, args): parser = optparse.OptionParser() parser.add_option('-w', '--write', dest='write', action='store_true', default=False, help='Write thread code in code subdirectory?') parser.add_option('-s', '--side', dest='initside', action='store_true', default=False, help='Move the initialization code to the left side?') (self.options, args) = parser.parse_args(args) if args: self.filename = args[0] else: self.filename = '' def get_name(self, name=None): return self.namer.next(name) def get_threads(self): return self.threads def set_global(self, **kwds): self.globals.update(kwds) def get_global(self, attr): return self.globals[attr] def destroy(self): """Closes the top window.""" self.running = False Gui.destroy(self) def setup(self): """Makes the GUI.""" if self.filename: self.read_file(self.filename) self.make_columns() if self.options.write: self.write_files(self.filename) return self.topcol = Column(self, n=5) self.colfr = self.fr() self.cols = [Column(self, LEFT, n=5) for i in range(2)] self.bu(side=RIGHT, text='Add\ncolumn', command=self.add_col) self.endfr() self.buttons() def buttons(self): """Makes the buttons.""" self.row([1,1,1,1,1]) self.bu(text='Run', command=self.run) self.bu(text='Random Run', command=self.random_run) self.bu(text='Stop', command=self.stop) self.bu(text='Step', command=self.step) self.bu(text='Random Step', command=self.random_step) self.endfr() def register(self, thread): """Adds a new thread.""" self.threads.append(thread) def unregister(self, thread): """Removes a thread.""" self.threads.remove(thread) def run(self): """Runs the simulator with round-robin scheduling.""" self.run_helper(self.step) def random_run(self): """Runs the simulator with random scheduling.""" self.run_helper(self.random_step) def run_helper(self, step=None): """Runs the threads until someone clears self.running.""" self.running = True while self.running: step() self.update() time.sleep(self.delay) def step(self): """Advances all the threads in order""" for thread in self.threads: thread.step_loop() def random_step(self): """Advances one random thread.""" threads = [thread for thread in self.threads if not thread.queued] if not threads: print('There are currently no threads that can run.') return thread = random.choice(threads) thread.step_loop() def stop(self): """Stops running.""" self.running = False def read_file(self, filename): """Read a file that contains code for the simulator to execute. Lines that start with ## do not appear in the display. A line that starts with "## thread" indicates the beginning of a new column of code. Returns a list of blocks where each block is a list of lines. """ def is_new_thread(line): if line[0:2] != '##': return False words = line.strip('#').split() word = words[0].lower() return word == 'thread' self.blocks = [] block = [] self.blocks.append(block) fp = open(filename) for line in fp: line = line.rstrip() if is_new_thread(line): block = [] self.blocks.append(block) else: block.append(line) fp.close() def make_columns(self): """Adds the code in self.blocks to the GUI.""" if not self.blocks: return side = LEFT if self.options.initside else TOP self.topcol = TopColumn(self, side=side) self.topcol.add_rows(self.blocks[0]) self.colfr = self.fr() self.cols = [] self.endfr() for block in self.blocks[1:]: col = self.add_col(0) col.add_rows(block) self.buttons() def write_files(self, filename, dirname='book_code'): """Writes the code into separate files for the init and threads. filename: name of the file we read dirname: name of the destination subdirectory Destination is a subdirectory of the directory the filename is in. """ path, filename = os.path.split(filename) dest = os.path.join(path, dirname, filename) block = self.blocks[0] self.write_file(block, dest, 0) for i, block in enumerate(self.blocks[1:]): self.write_file(block, dest, i+1) def write_file(self, block, filename, suffix=0): trim_block(block) name = '%s.%s' % (filename, str(suffix)) fp = open(name, 'w') for line in block: fp.write(line + '\n') fp.close() def add_col(self, n=5): """Adds a new column of code to the display.""" self.pushfr(self.colfr) col = Column(self, LEFT, n) self.cols.append(col) self.popfr() return col def run_init(self): """Runs the initialization code in the top column.""" if not self.topcol.num_rows(): return print('running init') self.clear_views() self.views = {} thread = Thread(self.topcol, name='0') while True: thread.step() if thread.row == None: break self.unregister(thread) def update_views(self): """Loops through the views and updates them.""" for key, view in self.views.items(): view.update(self.locals[key]) def clear_views(self): """Loops through the views and clears them.""" for key, view in self.views.items(): view.clear() def qu(self, **options): """Makes a queue.""" return self.widget(QueueCanvas, **options) def subtract(d1, d2): """Subtracts two dictionaries. Returns a new dictionary containing all the keys from d1 that are not in d2. """ d = {} for key in d1: if key not in d2: d[key] = d1[key] return d def diff_dict(d1, d2): """Diffs two dictionaries. Returns two dictionaries: the first contains all the keys from d1 that are not in d2; the second contains all the keys that are in both dictionaries, but which have different values. """ d = {} c = {} for key in d1: if key not in d2: d[key] = d1[key] elif d1[key] is not d2[key]: c[key] = d1[key] return d, c def trim_block(block): """Removes comments from the beginning and empty lines from the end.""" if block and block[0].startswith('#'): block.pop(0) while block and not block[-1].strip(): block.pop(-1) """ The following classes define the composite objects that make up the display: Row, TopRow, Column and TopColumn. They are all subclasses of Widget. """ class Widget: """Superclass of all display objects. Each Widget keeps a reference to its immediate parent Widget (p) and to the top-most thing (w). """ def __init__(self, p, *args, **options): self.p = p self.w = p.w self.setup(*args, **options) class Row(Widget): """A row of code. Each row contains two queues, runnable and queued, and an entry that contains a line of code. """ def setup(self, text=''): self.tag = None self.fr = self.w.row([0,0,1]) self.queued = self.w.qu(side=LEFT, n=3) self.runnable = self.w.qu(side=LEFT, n=3, label='Run') self.en = self.w.en(side=LEFT, font=font) self.en.bind('<Key>', self.keystroke) self.w.endrow() self.put(text) def update(self, val): if self.tag: self.clear() text = str(val) self.tag = self.runnable.display_text(text) def clear(self): self.runnable.delete(self.tag) def keystroke(self, event=None): "resize the entry whenever the user types a character" self.entry_size() def entry_size(self): "resize the entry" text = self.get() width = self.en.cget('width') l = len(text) + 2 if l > width: self.en.configure(width=l) def add_thread(self, thread): self.runnable.add_thread(thread) def remove_thread(self, thread): self.runnable.remove_thread(thread) def enqueue_thread(self, thread): self.queued.add_thread(thread) def dequeue_thread(self, thread): self.queued.remove_thread(thread) def put(self, text): self.en.delete(0, END) self.en.insert(0, text) self.entry_size() def get(self): return self.en.get() class TopRow(Row): """Rows in the initialization code at the top. The top row is special because there is no queue for queued threads, and the "runnable" queue is actually used to display the value of variables. """ def setup(self, text=''): Row.setup(self, text) self.queued.destroy() self.runnable.delete('all') class Column(Widget): """A list of rows and a few buttons.""" def setup(self, side=TOP, n=0, Row=Row): self.fr = self.w.fr(side=side, bd=3) self.Row = Row self.rows = [self.Row(self) for i in range(n)] self.buttons = self.w.row([1,1], side=BOTTOM) self.bu1 = self.w.bu(text='Create thread', command=self.create_thread) self.bu2 = self.w.bu(text='Add row', command=self.add_row) self.w.endrow() self.w.endfr() def num_rows(self): return len(self.rows) def add_rows(self, block, keep_blanks=False): for line in block: if line or keep_blanks: self.add_row(line) def add_row(self, text=''): self.w.pushfr(self.fr) row = self.Row(self, text) self.w.popfr() self.rows.append(row) def create_thread(self): new = Thread(self) return new def next_row(self, row): if row is None: return self.rows[0] index = self.rows.index(row) try: return self.rows[index+1] except IndexError: return None class TopColumn(Column): """The top column where the initialization code is. The top column is different from the other columns in two ways: it has different buttons, and it uses the TopRow constructor to make new rows rather than the Row constructor. """ def setup(self, side=TOP, n=0, Row=TopRow): Column.setup(self, side, n, Row) self.bu1.configure(text='Run initialization', command=self.p.run_init) class QueueCanvas(GuiCanvas): """Displays the runnable and queued threads.""" def __init__(self, w, n=1, label='Queue'): self.n = n self.label = label width = 2 * n * FSU height = 3 * FSU GuiCanvas.__init__(self, w, width=width, height=height, transforms=[]) self.threads = [] self.setup() def setup(self): self.text([3, 15], self.label, font=font, anchor=W, fill='white') def add_thread(self, thread): self.undraw_queue() self.threads.append(thread) self.draw_queue() def remove_thread(self, thread): self.undraw_queue() self.threads.remove(thread) self.draw_queue() def draw_queue(self): x = FSU y = FSU r = 0.9 * FSU for thread in self.threads: self.draw_thread(thread, x, y, r) x += 1.5*r if x > self.get_width(): x = FSU y += 1.5*r def undraw_queue(self): for thread in self.threads: self.delete(thread.tag) def draw_thread(self, thread, x=FSU, y=FSU, r=0.9*FSU): thread.tag = 'Thread' + thread.name self.circle([x, y], r, fill=thread.color, tags=thread.tag) font=('Courier', int(r+3)) self.text([x, y], thread.name, font=font, tags=thread.tag) self.tag_bind(thread.tag, '<Button-1>', thread.step_loop) def undraw_thread(self, thread): self.delete(thread.tag) def display_text(self, text): tag = self.text([15, 15], text, font=font) return tag class Namer(object): def __init__(self): self.names = all_thread_names self.next_name = 0 self.colors = ['red', 'orange', 'yellow', 'greenyellow', 'green', 'mediumseagreen', 'skyblue', 'violet', 'magenta'] self.next_color = 0 def next(self, name=None): if name == None: name = self.names[self.next_name] self.next_name += 1 self.next_name %= len(self.names) color = self.colors[self.next_color] self.next_color += 1 self.next_color %= len(self.colors) return name, color else: return name, 'white' class Namespace: """Used to store thread-local variables. Inside the simulator, self refers to the thread's namespace. """ class Thread: """Represents simulated threads.""" def __init__(self, column, name=None): self.column = column self.sync = column.p self.name, self.color = self.sync.get_name(name) self.namespace = Namespace() self.flag_map = {} self.while_stack = [] self.sync.register(self) self.start() def __str__(self): return '<' + self.name + '>' def enqueue(self): """Puts this thread into queue.""" self.queued = True self.row.remove_thread(self) self.row.enqueue_thread(self) def dequeue(self): """Removes this thread from queue.""" self.queued = False self.row.dequeue_thread(self) self.row.add_thread(self) def jump_to(self, row): """Removes this thread from its current row and moves it to row.""" if self.row: self.row.remove_thread(self) self.row = row if self.row: self.row.add_thread(self) def balk(self): self.row.remove_thread(self) self.row = None def start(self): """Moves this thread to the top of the column.""" self.queued = False self.row = None self.next_loop() def next_loop(self): """Moves to the next row, looping to the top if necessary.""" self.next_row() if self.row == None: self.start() def next_row(self): """Moves this thread to the next row in the column.""" if self.queued: return row = self.column.next_row(self.row) self.jump_to(row) def skip_body(self): """Skips the body of a conditional.""" # get the current line # get the next line # compute the change in indent # find the outdent source = self.row.get() head_indent = self.count_spaces(source) self.next_row() source = self.row.get() body_indent = self.count_spaces(source) indent = body_indent - head_indent if indent <= 0: raise SyntaxError('Body of compound statement must be indented.') while True: self.next_row() if self.row == None: break source = self.row.get() line_indent = self.count_spaces(source) if line_indent <= head_indent: break def count_spaces(self, source): """Returns the number of leading spaces after expanding tabs.""" s = source.expandtabs(4) t = s.lstrip(' ') return len(s) - len(t) def step(self, event=None): """Executes the current line of code, then moves to the next row. The current limitation of this simulator is that each row has to contain a complete Python statement. Also, each line of code is executed atomically. Args: event: unused, provided so that this method can be used as a binding callback Returns: line of code that executed or None """ if self.queued: return None if self.row == None: return None self.check_end_while() source = self.row.get() print(self, source) before = copy.copy(self.sync.locals) flag = self.exec_line(source, self.sync) # see if any variables were defined or changed after = self.sync.locals defined, changed = diff_dict(after, before) for key in defined: self.sync.views[key] = self.row if defined or changed: self.sync.update_views() # either skip to the next line or to the end of a false conditional if flag: self.next_row() else: self.skip_body() return source def exec_line(self, source, sync): """Runs a line of source code in the context of the given Sync. Args: source: source code from a Row sync: Sync object Returns: if the line is an if statement, returns the result of evaluating the condition """ global current_thread current_thread = self sync.globals['self'] = self.namespace try: s = source.strip() code = compile(s, '<user-provided code>', 'exec') exec(code, sync.globals, sync.locals) return True except SyntaxError as error: # check whether it's a conditional statement keyword = s.split()[0] if keyword in ['if', 'else:', 'while']: flag = self.handle_conditional(keyword, source, sync) return flag else: raise error def handle_conditional(self, keyword, source, sync): """Evaluates the condition part of an if statement. Args: keyword: if, else or while source: source code from a Row sync: Sync object Returns: if the line is an if statement, returns the result of evaluating the condition; otherwise raises a SyntaxError """ s = source.strip() if not s.endswith(':'): raise SyntaxError('Header must end with :') if keyword in ['if']: # evaluate the condition n = len(keyword) condition = s[n:-1].strip() flag = eval(condition, sync.globals, sync.locals) # store the flag indent = self.count_spaces(source) self.flag_map[indent] = flag return flag elif keyword in ['while']: # evaluate the condition n = len(keyword) condition = s[n:-1].strip() flag = eval(condition, sync.globals, sync.locals) if flag: indent = self.count_spaces(source) self.while_stack.append((indent, self.row)) return flag else: assert keyword == 'else:' # see whether the condition was true indent = self.count_spaces(source) try: flag = self.flag_map[indent] return not flag except KeyError: raise SyntaxError('else does not match if') def check_end_while(self): """Check if we are at the end of a while loop. If so, jump to the top. """ if not self.while_stack: return indent, row = self.while_stack[-1] source = self.row.get() if self.count_spaces(source) <= indent: self.while_stack.pop() self.jump_to(row) def step_loop(self, event=None): self.step() if self.row == None: self.start() def run(self): while True: self.step() if self.row == None: break def main(): sync = Sync(sys.argv[1:]) sync.mainloop() if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 199, 624, 2765, 859, 365, 1777, 402, 428, 758, 5086, 12, 282, 5241, 402, 18572, 2808, 687, 199, 7670, 68, 583, 23263, 14, 957, 15, 24262, 5086, 14, 199, 199, 7384, 7760, 4580, 552, 699, 14, 577, 583, 23263, 199, 27398, 1334, 314, 1664, 1696, 1684, 844, 737, 486, 4850, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 14, 199, 624, 199, 199, 646, 8691, 199, 646, 747, 199, 646, 1331, 199, 646, 2196, 199, 646, 984, 199, 646, 1059, 199, 646, 900, 199, 199, 3, 314, 2569, 10269, 883, 506, 13810, 315, 314, 15797, 199, 199, 1818, 63, 2671, 275, 488, 199, 199, 318, 29689, 2031, 589, 304, 272, 408, 33, 4926, 89, 805, 3052, 517, 1630, 6548, 1041, 9948, 199, 318, 330, 4878, 837, 272, 408, 42, 1220, 83, 370, 314, 2746, 402, 314, 2763, 1041, 272, 1453, 63, 2671, 14, 66, 4878, 342, 199, 199, 533, 3240, 17185, 26, 272, 408, 18089, 282, 542, 17185, 315, 314, 15797, 14, 339, 16593, 8368, 83, 282, 2196, 4126, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 302, 29, 16, 304, 267, 291, 14, 78, 275, 302, 267, 291, 14, 1825, 275, 942, 339, 347, 636, 495, 721, 277, 304, 372, 620, 8, 277, 14, 78, 9, 339, 347, 3618, 8, 277, 304, 267, 291, 14, 78, 4862, 413, 267, 340, 291, 14, 78, 665, 378, 26, 288, 291, 14, 1457, 342, 267, 372, 291, 14, 78, 339, 347, 1853, 8, 277, 304, 267, 2462, 275, 1453, 63, 2671, 267, 2462, 14, 12456, 342, 267, 291, 14, 1825, 14, 740, 8, 2671, 9, 339, 347, 4673, 8, 277, 12, 302, 29, 17, 304, 267, 367, 284, 315, 1425, 8, 78, 304, 288, 291, 14, 78, 847, 413, 288, 340, 291, 14, 1825, 26, 355, 291, 14, 324, 1457, 342, 339, 347, 625, 1457, 8, 277, 304, 267, 408, 6209, 32128, 282, 2196, 2462, 436, 625, 4166, 652, 1041, 267, 2462, 275, 2196, 14, 5095, 8, 277, 14, 1825, 9, 267, 291, 14, 1825, 14, 2168, 8, 2671, 9, 267, 2462, 14, 18522, 342, 267, 2462, 14, 2184, 63, 3813, 342, 421, 199, 533, 31574, 545, 26574, 8, 26574, 304, 272, 408, 26574, 626, 9031, 282, 15435, 3230, 4126, 1041, 339, 347, 625, 1457, 8, 277, 304, 267, 408, 6209, 32128, 314, 1642, 2462, 436, 625, 4166, 652, 1041, 267, 2462, 275, 291, 14, 1825, 14, 1935, 8, 16, 9, 267, 2462, 14, 18522, 342, 267, 2462, 14, 2184, 63, 3813, 342, 421, 199, 533, 491, 2492, 3111, 26, 272, 408, 1327, 12029, 15409, 314, 10540, 5656, 3851, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 5337, 275, 378, 267, 291, 14, 19078, 275, 3240, 17185, 8, 17, 9, 339, 347, 4650, 8, 277, 12, 542, 17185, 304, 267, 291, 14, 19078, 14, 2573, 342, 267, 291, 14, 5337, 847, 413, 267, 340, 291, 14, 5337, 508, 413, 26, 288, 542, 17185, 14, 2573, 342, 267, 291, 14, 19078, 14, 4653, 342, 339, 347, 28451, 8, 277, 12, 542, 17185, 304, 267, 291, 14, 19078, 14, 2573, 342, 267, 291, 14, 5337, 4862, 413, 267, 340, 291, 14, 5337, 508, 378, 26, 288, 542, 17185, 14, 4653, 342, 267, 291, 14, 19078, 14, 4653, 342, 421, 199, 318, 4422, 837, 272, 408, 14426, 314, 2870, 402, 314, 1453, 2462, 1041, 272, 372, 1453, 63, 2671, 14, 354, 421, 199, 318, 1967, 63, 6962, 837, 272, 408, 14426, 314, 1329, 402, 7183, 1041, 272, 7604, 275, 1453, 63, 2671, 14, 2301, 14, 80, 272, 372, 822, 8, 5186, 14, 6962, 9, 4388, 199, 3, 1852, 7992, 436, 9480, 367, 314, 15797, 199, 199, 5206, 63, 8473, 275, 1331, 14, 1574, 8, 8473, 1012, 199, 5206, 63, 9350, 275, 1211, 342, 199, 199, 3, 7003, 3247, 2410, 642, 2376, 365, 440, 2808, 6272, 314, 15797, 199, 199, 504, 22171, 492, 653, 12, 428, 12, 662, 12, 644, 12, 32582, 12, 699, 1387, 19731, 12, 6578, 12, 7052, 12, 7729, 199, 504, 14425, 492, 14425, 12, 14425, 15174, 421, 199, 3, 664, 314, 1015, 402, 2018, 199, 86, 275, 984, 14, 1023, 14, 1294, 3430, 16, 1055, 1294, 7563, 199, 8452, 275, 1109, 8, 86, 59, 16, 566, 199, 199, 692, 12160, 508, 499, 26, 272, 1006, 63, 2671, 63, 1247, 275, 1059, 14, 26831, 435, 1059, 14, 21636, 199, 2836, 26, 272, 1006, 63, 2671, 63, 1247, 275, 1059, 14, 4371, 63, 26831, 435, 1059, 14, 4371, 63, 21636, 421, 199, 4246, 275, 1689, 35, 567, 4446, 401, 3144, 9, 199, 38, 6195, 275, 1749, 9326, 327, 481, 6195, 12, 314, 27440, 14040, 279, 22407, 4137, 12, 1169, 327, 16756, 314, 1568, 402, 4750, 7645, 14, 199, 199, 533, 22407, 8, 4324, 304, 272, 408, 18089, 314, 2462, 15797, 1041, 339, 347, 636, 826, 721, 277, 12, 1249, 2968, 9090, 267, 14425, 855, 826, 721, 277, 9, 267, 291, 14, 1122, 63, 589, 8, 589, 9, 267, 291, 14, 354, 82, 275, 2812, 82, 342, 398, 291, 14, 9350, 275, 4389, 63, 9350, 267, 291, 14, 8473, 275, 4389, 63, 8473, 2728, 291, 14, 4196, 275, 1052, 267, 291, 14, 87, 275, 291, 267, 291, 14, 6962, 275, 942, 267, 291, 14, 5720, 275, 756, 267, 291, 14, 5814, 275, 378, 14, 18, 267, 291, 14, 2758, 342, 267, 291, 14, 1065, 63, 826, 342, 267, 367, 1048, 315, 291, 14, 4574, 26, 288, 1048, 14, 981, 63, 2671, 342, 339, 347, 2198, 63, 589, 8, 277, 12, 1249, 304, 267, 1798, 275, 8691, 14, 14553, 342, 267, 1798, 14, 525, 63, 1422, 3654, 87, 297, 2850, 952, 297, 2053, 534, 952, 297, 2079, 1595, 534, 1617, 63, 2052, 297, 849, 29, 797, 12, 2079, 1720, 534, 3534, 2462, 1233, 315, 1233, 25094, 18478, 267, 1798, 14, 525, 63, 1422, 3654, 83, 297, 2850, 2441, 297, 2053, 534, 826, 2441, 297, 2079, 1595, 534, 1617, 63, 2052, 297, 849, 29, 797, 12, 2079, 1720, 534, 10370, 314, 11097, 1233, 370, 314, 3602, 5366, 18478, 398, 334, 277, 14, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 8, 589, 9, 398, 340, 1249, 26 ]
[ 2647, 15, 1393, 15, 1548, 199, 199, 624, 2765, 859, 365, 1777, 402, 428, 758, 5086, 12, 282, 5241, 402, 18572, 2808, 687, 199, 7670, 68, 583, 23263, 14, 957, 15, 24262, 5086, 14, 199, 199, 7384, 7760, 4580, 552, 699, 14, 577, 583, 23263, 199, 27398, 1334, 314, 1664, 1696, 1684, 844, 737, 486, 4850, 14, 1308, 15, 2383, 15, 11692, 14, 1360, 14, 199, 624, 199, 199, 646, 8691, 199, 646, 747, 199, 646, 1331, 199, 646, 2196, 199, 646, 984, 199, 646, 1059, 199, 646, 900, 199, 199, 3, 314, 2569, 10269, 883, 506, 13810, 315, 314, 15797, 199, 199, 1818, 63, 2671, 275, 488, 199, 199, 318, 29689, 2031, 589, 304, 272, 408, 33, 4926, 89, 805, 3052, 517, 1630, 6548, 1041, 9948, 199, 318, 330, 4878, 837, 272, 408, 42, 1220, 83, 370, 314, 2746, 402, 314, 2763, 1041, 272, 1453, 63, 2671, 14, 66, 4878, 342, 199, 199, 533, 3240, 17185, 26, 272, 408, 18089, 282, 542, 17185, 315, 314, 15797, 14, 339, 16593, 8368, 83, 282, 2196, 4126, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 302, 29, 16, 304, 267, 291, 14, 78, 275, 302, 267, 291, 14, 1825, 275, 942, 339, 347, 636, 495, 721, 277, 304, 372, 620, 8, 277, 14, 78, 9, 339, 347, 3618, 8, 277, 304, 267, 291, 14, 78, 4862, 413, 267, 340, 291, 14, 78, 665, 378, 26, 288, 291, 14, 1457, 342, 267, 372, 291, 14, 78, 339, 347, 1853, 8, 277, 304, 267, 2462, 275, 1453, 63, 2671, 267, 2462, 14, 12456, 342, 267, 291, 14, 1825, 14, 740, 8, 2671, 9, 339, 347, 4673, 8, 277, 12, 302, 29, 17, 304, 267, 367, 284, 315, 1425, 8, 78, 304, 288, 291, 14, 78, 847, 413, 288, 340, 291, 14, 1825, 26, 355, 291, 14, 324, 1457, 342, 339, 347, 625, 1457, 8, 277, 304, 267, 408, 6209, 32128, 282, 2196, 2462, 436, 625, 4166, 652, 1041, 267, 2462, 275, 2196, 14, 5095, 8, 277, 14, 1825, 9, 267, 291, 14, 1825, 14, 2168, 8, 2671, 9, 267, 2462, 14, 18522, 342, 267, 2462, 14, 2184, 63, 3813, 342, 421, 199, 533, 31574, 545, 26574, 8, 26574, 304, 272, 408, 26574, 626, 9031, 282, 15435, 3230, 4126, 1041, 339, 347, 625, 1457, 8, 277, 304, 267, 408, 6209, 32128, 314, 1642, 2462, 436, 625, 4166, 652, 1041, 267, 2462, 275, 291, 14, 1825, 14, 1935, 8, 16, 9, 267, 2462, 14, 18522, 342, 267, 2462, 14, 2184, 63, 3813, 342, 421, 199, 533, 491, 2492, 3111, 26, 272, 408, 1327, 12029, 15409, 314, 10540, 5656, 3851, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 14, 5337, 275, 378, 267, 291, 14, 19078, 275, 3240, 17185, 8, 17, 9, 339, 347, 4650, 8, 277, 12, 542, 17185, 304, 267, 291, 14, 19078, 14, 2573, 342, 267, 291, 14, 5337, 847, 413, 267, 340, 291, 14, 5337, 508, 413, 26, 288, 542, 17185, 14, 2573, 342, 267, 291, 14, 19078, 14, 4653, 342, 339, 347, 28451, 8, 277, 12, 542, 17185, 304, 267, 291, 14, 19078, 14, 2573, 342, 267, 291, 14, 5337, 4862, 413, 267, 340, 291, 14, 5337, 508, 378, 26, 288, 542, 17185, 14, 4653, 342, 267, 291, 14, 19078, 14, 4653, 342, 421, 199, 318, 4422, 837, 272, 408, 14426, 314, 2870, 402, 314, 1453, 2462, 1041, 272, 372, 1453, 63, 2671, 14, 354, 421, 199, 318, 1967, 63, 6962, 837, 272, 408, 14426, 314, 1329, 402, 7183, 1041, 272, 7604, 275, 1453, 63, 2671, 14, 2301, 14, 80, 272, 372, 822, 8, 5186, 14, 6962, 9, 4388, 199, 3, 1852, 7992, 436, 9480, 367, 314, 15797, 199, 199, 5206, 63, 8473, 275, 1331, 14, 1574, 8, 8473, 1012, 199, 5206, 63, 9350, 275, 1211, 342, 199, 199, 3, 7003, 3247, 2410, 642, 2376, 365, 440, 2808, 6272, 314, 15797, 199, 199, 504, 22171, 492, 653, 12, 428, 12, 662, 12, 644, 12, 32582, 12, 699, 1387, 19731, 12, 6578, 12, 7052, 12, 7729, 199, 504, 14425, 492, 14425, 12, 14425, 15174, 421, 199, 3, 664, 314, 1015, 402, 2018, 199, 86, 275, 984, 14, 1023, 14, 1294, 3430, 16, 1055, 1294, 7563, 199, 8452, 275, 1109, 8, 86, 59, 16, 566, 199, 199, 692, 12160, 508, 499, 26, 272, 1006, 63, 2671, 63, 1247, 275, 1059, 14, 26831, 435, 1059, 14, 21636, 199, 2836, 26, 272, 1006, 63, 2671, 63, 1247, 275, 1059, 14, 4371, 63, 26831, 435, 1059, 14, 4371, 63, 21636, 421, 199, 4246, 275, 1689, 35, 567, 4446, 401, 3144, 9, 199, 38, 6195, 275, 1749, 9326, 327, 481, 6195, 12, 314, 27440, 14040, 279, 22407, 4137, 12, 1169, 327, 16756, 314, 1568, 402, 4750, 7645, 14, 199, 199, 533, 22407, 8, 4324, 304, 272, 408, 18089, 314, 2462, 15797, 1041, 339, 347, 636, 826, 721, 277, 12, 1249, 2968, 9090, 267, 14425, 855, 826, 721, 277, 9, 267, 291, 14, 1122, 63, 589, 8, 589, 9, 267, 291, 14, 354, 82, 275, 2812, 82, 342, 398, 291, 14, 9350, 275, 4389, 63, 9350, 267, 291, 14, 8473, 275, 4389, 63, 8473, 2728, 291, 14, 4196, 275, 1052, 267, 291, 14, 87, 275, 291, 267, 291, 14, 6962, 275, 942, 267, 291, 14, 5720, 275, 756, 267, 291, 14, 5814, 275, 378, 14, 18, 267, 291, 14, 2758, 342, 267, 291, 14, 1065, 63, 826, 342, 267, 367, 1048, 315, 291, 14, 4574, 26, 288, 1048, 14, 981, 63, 2671, 342, 339, 347, 2198, 63, 589, 8, 277, 12, 1249, 304, 267, 1798, 275, 8691, 14, 14553, 342, 267, 1798, 14, 525, 63, 1422, 3654, 87, 297, 2850, 952, 297, 2053, 534, 952, 297, 2079, 1595, 534, 1617, 63, 2052, 297, 849, 29, 797, 12, 2079, 1720, 534, 3534, 2462, 1233, 315, 1233, 25094, 18478, 267, 1798, 14, 525, 63, 1422, 3654, 83, 297, 2850, 2441, 297, 2053, 534, 826, 2441, 297, 2079, 1595, 534, 1617, 63, 2052, 297, 849, 29, 797, 12, 2079, 1720, 534, 10370, 314, 11097, 1233, 370, 314, 3602, 5366, 18478, 398, 334, 277, 14, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 8, 589, 9, 398, 340, 1249, 26, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mavit/ansible
lib/ansible/modules/cloud/google/gce_lb.py
50
11807
#!/usr/bin/python # Copyright 2013 Google Inc. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: gce_lb version_added: "1.5" short_description: create/destroy GCE load-balancer resources description: - This module can create and destroy Google Compute Engine C(loadbalancer) and C(httphealthcheck) resources. The primary LB resource is the C(load_balancer) resource and the health check parameters are all prefixed with I(httphealthcheck). The full documentation for Google Compute Engine load balancing is at U(https://developers.google.com/compute/docs/load-balancing/). However, the ansible module simplifies the configuration by following the libcloud model. Full install/configuration instructions for the gce* modules can be found in the comments of ansible/test/gce_tests.py. options: httphealthcheck_name: description: - the name identifier for the HTTP health check httphealthcheck_port: description: - the TCP port to use for HTTP health checking default: 80 httphealthcheck_path: description: - the url path to use for HTTP health checking default: "/" httphealthcheck_interval: description: - the duration in seconds between each health check request default: 5 httphealthcheck_timeout: description: - the timeout in seconds before a request is considered a failed check default: 5 httphealthcheck_unhealthy_count: description: - number of consecutive failed checks before marking a node unhealthy default: 2 httphealthcheck_healthy_count: description: - number of consecutive successful checks before marking a node healthy default: 2 httphealthcheck_host: description: - host header to pass through on HTTP check requests name: description: - name of the load-balancer resource protocol: description: - the protocol used for the load-balancer packet forwarding, tcp or udp default: "tcp" choices: ['tcp', 'udp'] region: description: - the GCE region where the load-balancer is defined external_ip: description: - the external static IPv4 (or auto-assigned) address for the LB port_range: description: - the port (range) to forward, e.g. 80 or 8000-8888 defaults to all ports members: description: - a list of zone/nodename pairs, e.g ['us-central1-a/www-a', ...] aliases: ['nodes'] state: description: - desired state of the LB default: "present" choices: ["active", "present", "absent", "deleted"] service_account_email: version_added: "1.6" description: - service account email pem_file: version_added: "1.6" description: - path to the pem file associated with the service account email This option is deprecated. Use 'credentials_file'. credentials_file: version_added: "2.1.0" description: - path to the JSON file associated with the service account email project_id: version_added: "1.6" description: - your GCE project ID requirements: - "python >= 2.6" - "apache-libcloud >= 0.13.3, >= 0.17.0 if using JSON credentials" author: "Eric Johnson (@erjohnso) <erjohnso@google.com>" ''' EXAMPLES = ''' # Simple example of creating a new LB, adding members, and a health check - local_action: module: gce_lb name: testlb region: us-central1 members: ["us-central1-a/www-a", "us-central1-b/www-b"] httphealthcheck_name: hc httphealthcheck_port: 80 httphealthcheck_path: "/up" ''' try: from libcloud.compute.types import Provider from libcloud.compute.providers import get_driver from libcloud.loadbalancer.types import Provider as Provider_lb from libcloud.loadbalancer.providers import get_driver as get_driver_lb from libcloud.common.google import GoogleBaseError, QuotaExceededError, ResourceExistsError, ResourceNotFoundError _ = Provider.GCE HAS_LIBCLOUD = True except ImportError: HAS_LIBCLOUD = False from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.gce import USER_AGENT_PRODUCT, USER_AGENT_VERSION, gce_connect, unexpected_error_msg def main(): module = AnsibleModule( argument_spec=dict( httphealthcheck_name=dict(), httphealthcheck_port=dict(default=80), httphealthcheck_path=dict(default='/'), httphealthcheck_interval=dict(default=5), httphealthcheck_timeout=dict(default=5), httphealthcheck_unhealthy_count=dict(default=2), httphealthcheck_healthy_count=dict(default=2), httphealthcheck_host=dict(), name=dict(), protocol=dict(default='tcp'), region=dict(), external_ip=dict(), port_range=dict(), members=dict(type='list'), state=dict(default='present'), service_account_email=dict(), pem_file=dict(type='path'), credentials_file=dict(type='path'), project_id=dict(), ) ) if not HAS_LIBCLOUD: module.fail_json(msg='libcloud with GCE support (0.13.3+) required for this module.') gce = gce_connect(module) httphealthcheck_name = module.params.get('httphealthcheck_name') httphealthcheck_port = module.params.get('httphealthcheck_port') httphealthcheck_path = module.params.get('httphealthcheck_path') httphealthcheck_interval = module.params.get('httphealthcheck_interval') httphealthcheck_timeout = module.params.get('httphealthcheck_timeout') httphealthcheck_unhealthy_count = module.params.get('httphealthcheck_unhealthy_count') httphealthcheck_healthy_count = module.params.get('httphealthcheck_healthy_count') httphealthcheck_host = module.params.get('httphealthcheck_host') name = module.params.get('name') protocol = module.params.get('protocol') region = module.params.get('region') external_ip = module.params.get('external_ip') port_range = module.params.get('port_range') members = module.params.get('members') state = module.params.get('state') try: gcelb = get_driver_lb(Provider_lb.GCE)(gce_driver=gce) gcelb.connection.user_agent_append("%s/%s" % ( USER_AGENT_PRODUCT, USER_AGENT_VERSION)) except Exception as e: module.fail_json(msg=unexpected_error_msg(e), changed=False) changed = False json_output = {'name': name, 'state': state} if not name and not httphealthcheck_name: module.fail_json(msg='Nothing to do, please specify a "name" ' + 'or "httphealthcheck_name" parameter', changed=False) if state in ['active', 'present']: # first, create the httphealthcheck if requested hc = None if httphealthcheck_name: json_output['httphealthcheck_name'] = httphealthcheck_name try: hc = gcelb.ex_create_healthcheck(httphealthcheck_name, host=httphealthcheck_host, path=httphealthcheck_path, port=httphealthcheck_port, interval=httphealthcheck_interval, timeout=httphealthcheck_timeout, unhealthy_threshold=httphealthcheck_unhealthy_count, healthy_threshold=httphealthcheck_healthy_count) changed = True except ResourceExistsError: hc = gce.ex_get_healthcheck(httphealthcheck_name) except Exception as e: module.fail_json(msg=unexpected_error_msg(e), changed=False) if hc is not None: json_output['httphealthcheck_host'] = hc.extra['host'] json_output['httphealthcheck_path'] = hc.path json_output['httphealthcheck_port'] = hc.port json_output['httphealthcheck_interval'] = hc.interval json_output['httphealthcheck_timeout'] = hc.timeout json_output['httphealthcheck_unhealthy_count'] = hc.unhealthy_threshold json_output['httphealthcheck_healthy_count'] = hc.healthy_threshold # create the forwarding rule (and target pool under the hood) lb = None if name: if not region: module.fail_json(msg='Missing required region name', changed=False) nodes = [] output_nodes = [] json_output['name'] = name # members is a python list of 'zone/inst' strings if members: for node in members: try: zone, node_name = node.split('/') nodes.append(gce.ex_get_node(node_name, zone)) output_nodes.append(node) except: # skip nodes that are badly formatted or don't exist pass try: if hc is not None: lb = gcelb.create_balancer(name, port_range, protocol, None, nodes, ex_region=region, ex_healthchecks=[hc], ex_address=external_ip) else: lb = gcelb.create_balancer(name, port_range, protocol, None, nodes, ex_region=region, ex_address=external_ip) changed = True except ResourceExistsError: lb = gcelb.get_balancer(name) except Exception as e: module.fail_json(msg=unexpected_error_msg(e), changed=False) if lb is not None: json_output['members'] = output_nodes json_output['protocol'] = protocol json_output['region'] = region json_output['external_ip'] = lb.ip json_output['port_range'] = lb.port hc_names = [] if 'healthchecks' in lb.extra: for hc in lb.extra['healthchecks']: hc_names.append(hc.name) json_output['httphealthchecks'] = hc_names if state in ['absent', 'deleted']: # first, delete the load balancer (forwarding rule and target pool) # if specified. if name: json_output['name'] = name try: lb = gcelb.get_balancer(name) gcelb.destroy_balancer(lb) changed = True except ResourceNotFoundError: pass except Exception as e: module.fail_json(msg=unexpected_error_msg(e), changed=False) # destroy the health check if specified if httphealthcheck_name: json_output['httphealthcheck_name'] = httphealthcheck_name try: hc = gce.ex_get_healthcheck(httphealthcheck_name) gce.ex_destroy_healthcheck(hc) changed = True except ResourceNotFoundError: pass except Exception as e: module.fail_json(msg=unexpected_error_msg(e), changed=False) json_output['changed'] = changed module.exit_json(**json_output) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 6171, 4475, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 21319, 63, 6374, 199, 1023, 63, 3270, 26, 298, 17, 14, 21, 2, 199, 3612, 63, 1802, 26, 1218, 15, 7237, 31556, 2248, 13, 11841, 5944, 199, 1802, 26, 272, 446, 961, 859, 883, 1218, 436, 11972, 4475, 8354, 12580, 445, 8, 26615, 9, 489, 436, 445, 8, 1014, 27941, 9, 5944, 14, 221, 710, 5062, 491, 34, 2073, 365, 314, 489, 445, 8, 912, 63, 11841, 9, 2073, 436, 314, 13822, 1104, 2633, 787, 1006, 489, 18239, 543, 473, 8, 1014, 27941, 680, 489, 710, 2615, 3794, 367, 4475, 8354, 12580, 2248, 29300, 365, 737, 489, 738, 8, 2859, 921, 23826, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 912, 13, 30260, 15, 680, 221, 9738, 12, 489, 314, 3242, 859, 17553, 5604, 314, 2897, 701, 2569, 314, 489, 17069, 1402, 14, 489, 16579, 3907, 15, 4758, 15794, 367, 314, 21319, 10, 4621, 883, 489, 506, 1911, 315, 314, 6786, 402, 3242, 15, 396, 15, 22833, 63, 2219, 14, 647, 14, 199, 1419, 26, 523, 1455, 27941, 63, 354, 26, 272, 1369, 26, 489, 446, 314, 536, 5148, 367, 314, 3101, 13822, 1104, 523, 1455, 27941, 63, 719, 26, 272, 1369, 26, 489, 446, 314, 13488, 1844, 370, 675, 367, 3101, 13822, 7907, 272, 849, 26, 5939, 523, 1455, 27941, 63, 515, 26, 272, 1369, 26, 489, 446, 314, 1166, 931, 370, 675, 367, 3101, 13822, 7907, 272, 849, 26, 10609, 523, 1455, 27941, 63, 4284, 26, 272, 1369, 26, 489, 446, 314, 7373, 315, 4696, 3382, 1924, 13822, 1104, 1056, 272, 849, 26, 959, 523, 1455, 27941, 63, 2593, 26, 272, 1369, 26, 489, 446, 314, 2653, 315, 4696, 2544, 282, 1056, 365, 8652, 282, 3405, 1104, 272, 849, 26, 959, 523, 1455, 27941, 63, 324, 29584, 63, 835, 26, 272, 1369, 26, 489, 446, 1329, 402, 23376, 3405, 5920, 2544, 31318, 282, 1031, 625, 29584, 272, 849, 26, 499, 523, 1455, 27941, 63, 29584, 63, 835, 26, 272, 1369, 26, 489, 446, 1329, 402, 23376, 9512, 5920, 2544, 31318, 282, 1031, 13822, 89, 272, 849, 26, 499, 523, 1455, 27941, 63, 1102, 26, 272, 1369, 26, 489, 446, 1591, 1406, 370, 986, 4012, 641, 3101, 1104, 4145, 523, 536, 26, 272, 1369, 26, 489, 446, 536, 402, 314, 2248, 13, 11841, 2073, 523, 4113, 26, 272, 1369, 26, 489, 446, 314, 4113, 1202, 367, 314, 2248, 13, 11841, 3644, 24119, 12, 14719, 503, 18419, 272, 849, 26, 298, 8815, 2, 272, 3415, 26, 788, 8815, 297, 283, 15036, 418, 523, 4897, 26, 272, 1369, 26, 489, 446, 314, 31556, 4897, 2382, 314, 2248, 13, 11841, 365, 3247, 523, 5957, 63, 711, 26, 272, 1369, 26, 489, 446, 314, 5957, 2955, 6509, 20, 334, 269, 2599, 13, 12941, 9, 2287, 367, 314, 491, 34, 523, 1844, 63, 1842, 26, 272, 1369, 26, 489, 446, 314, 1844, 334, 1842, 9, 370, 7568, 12, 325, 14, 71, 14, 5939, 503, 29855, 13, 14871, 4243, 370, 1006, 8873, 523, 7556, 26, 272, 1369, 26, 489, 446, 282, 769, 402, 5718, 15, 932, 354, 6342, 12, 325, 14, 71, 788, 527, 13, 16067, 17, 13, 65, 15, 1544, 13, 65, 297, 21214, 272, 5481, 26, 788, 2415, 418, 523, 1174, 26, 272, 1369, 26, 489, 446, 6387, 1174, 402, 314, 491, 34, 272, 849, 26, 298, 1881, 2, 272, 3415, 26, 2097, 2682, 401, 298, 1881, 401, 298, 5575, 401, 298, 6062, 937, 523, 2435, 63, 2048, 63, 2123, 26, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 272, 1369, 26, 489, 446, 2435, 2933, 3031, 523, 4837, 77, 63, 493, 26, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 272, 1369, 26, 489, 446, 931, 370, 314, 4837, 77, 570, 4568, 543, 314, 2435, 2933, 3031, 267, 961, 945, 365, 5906, 14, 3645, 283, 6942, 63, 493, 1370, 523, 6235, 63, 493, 26, 272, 1015, 63, 3270, 26, 298, 18, 14, 17, 14, 16, 2, 272, 1369, 26, 489, 446, 931, 370, 314, 4840, 570, 4568, 543, 314, 2435, 2933, 3031, 523, 2199, 63, 344, 26, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 272, 1369, 26, 489, 446, 2195, 31556, 2199, 2870, 199, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 298, 3796, 13, 30651, 2356, 378, 14, 969, 14, 19, 12, 2356, 378, 14, 1196, 14, 16, 340, 1808, 4840, 6235, 2, 199, 2502, 26, 298, 37, 1567, 7135, 25338, 265, 8593, 281, 743, 25338, 79, 9, 665, 281, 743, 25338, 79, 32, 3098, 14, 957, 4335, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5870, 2893, 402, 6425, 282, 892, 491, 34, 12, 7791, 7556, 12, 436, 282, 13822, 1104, 199, 13, 2257, 63, 1287, 26, 272, 859, 26, 21319, 63, 6374, 272, 536, 26, 511, 6374, 272, 4897, 26, 2739, 13, 16067, 17, 272, 7556, 26, 2097, 527, 13, 16067, 17, 13, 65, 15, 1544, 13, 65, 401, 298, 527, 13, 16067, 17, 13, 66, 15, 1544, 13, 66, 937, 272, 1455, 27941, 63, 354, 26, 394, 67, 272, 1455, 27941, 63, 719, 26, 5939, 272, 1455, 27941, 63, 515, 26, 3286, 384, 2, 199, 2344, 199, 199, 893, 26, 272, 687, 17069, 14, 3357, 14, 1313, 492, 18489, 272, 687, 17069, 14, 3357, 14, 9710, 492, 664, 63, 3090, 272, 687, 17069, 14, 26615, 14, 1313, 492, 18489, 465, 18489, 63, 6374, 272, 687, 17069, 14, 26615, 14, 9710, 492, 664, 63, 3090, 465, 664, 63, 3090, 63, 6374, 272, 687, 17069, 14, 2330, 14, 3098 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 6171, 4475, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 21319, 63, 6374, 199, 1023, 63, 3270, 26, 298, 17, 14, 21, 2, 199, 3612, 63, 1802, 26, 1218, 15, 7237, 31556, 2248, 13, 11841, 5944, 199, 1802, 26, 272, 446, 961, 859, 883, 1218, 436, 11972, 4475, 8354, 12580, 445, 8, 26615, 9, 489, 436, 445, 8, 1014, 27941, 9, 5944, 14, 221, 710, 5062, 491, 34, 2073, 365, 314, 489, 445, 8, 912, 63, 11841, 9, 2073, 436, 314, 13822, 1104, 2633, 787, 1006, 489, 18239, 543, 473, 8, 1014, 27941, 680, 489, 710, 2615, 3794, 367, 4475, 8354, 12580, 2248, 29300, 365, 737, 489, 738, 8, 2859, 921, 23826, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 912, 13, 30260, 15, 680, 221, 9738, 12, 489, 314, 3242, 859, 17553, 5604, 314, 2897, 701, 2569, 314, 489, 17069, 1402, 14, 489, 16579, 3907, 15, 4758, 15794, 367, 314, 21319, 10, 4621, 883, 489, 506, 1911, 315, 314, 6786, 402, 3242, 15, 396, 15, 22833, 63, 2219, 14, 647, 14, 199, 1419, 26, 523, 1455, 27941, 63, 354, 26, 272, 1369, 26, 489, 446, 314, 536, 5148, 367, 314, 3101, 13822, 1104, 523, 1455, 27941, 63, 719, 26, 272, 1369, 26, 489, 446, 314, 13488, 1844, 370, 675, 367, 3101, 13822, 7907, 272, 849, 26, 5939, 523, 1455, 27941, 63, 515, 26, 272, 1369, 26, 489, 446, 314, 1166, 931, 370, 675, 367, 3101, 13822, 7907, 272, 849, 26, 10609, 523, 1455, 27941, 63, 4284, 26, 272, 1369, 26, 489, 446, 314, 7373, 315, 4696, 3382, 1924, 13822, 1104, 1056, 272, 849, 26, 959, 523, 1455, 27941, 63, 2593, 26, 272, 1369, 26, 489, 446, 314, 2653, 315, 4696, 2544, 282, 1056, 365, 8652, 282, 3405, 1104, 272, 849, 26, 959, 523, 1455, 27941, 63, 324, 29584, 63, 835, 26, 272, 1369, 26, 489, 446, 1329, 402, 23376, 3405, 5920, 2544, 31318, 282, 1031, 625, 29584, 272, 849, 26, 499, 523, 1455, 27941, 63, 29584, 63, 835, 26, 272, 1369, 26, 489, 446, 1329, 402, 23376, 9512, 5920, 2544, 31318, 282, 1031, 13822, 89, 272, 849, 26, 499, 523, 1455, 27941, 63, 1102, 26, 272, 1369, 26, 489, 446, 1591, 1406, 370, 986, 4012, 641, 3101, 1104, 4145, 523, 536, 26, 272, 1369, 26, 489, 446, 536, 402, 314, 2248, 13, 11841, 2073, 523, 4113, 26, 272, 1369, 26, 489, 446, 314, 4113, 1202, 367, 314, 2248, 13, 11841, 3644, 24119, 12, 14719, 503, 18419, 272, 849, 26, 298, 8815, 2, 272, 3415, 26, 788, 8815, 297, 283, 15036, 418, 523, 4897, 26, 272, 1369, 26, 489, 446, 314, 31556, 4897, 2382, 314, 2248, 13, 11841, 365, 3247, 523, 5957, 63, 711, 26, 272, 1369, 26, 489, 446, 314, 5957, 2955, 6509, 20, 334, 269, 2599, 13, 12941, 9, 2287, 367, 314, 491, 34, 523, 1844, 63, 1842, 26, 272, 1369, 26, 489, 446, 314, 1844, 334, 1842, 9, 370, 7568, 12, 325, 14, 71, 14, 5939, 503, 29855, 13, 14871, 4243, 370, 1006, 8873, 523, 7556, 26, 272, 1369, 26, 489, 446, 282, 769, 402, 5718, 15, 932, 354, 6342, 12, 325, 14, 71, 788, 527, 13, 16067, 17, 13, 65, 15, 1544, 13, 65, 297, 21214, 272, 5481, 26, 788, 2415, 418, 523, 1174, 26, 272, 1369, 26, 489, 446, 6387, 1174, 402, 314, 491, 34, 272, 849, 26, 298, 1881, 2, 272, 3415, 26, 2097, 2682, 401, 298, 1881, 401, 298, 5575, 401, 298, 6062, 937, 523, 2435, 63, 2048, 63, 2123, 26, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 272, 1369, 26, 489, 446, 2435, 2933, 3031, 523, 4837, 77, 63, 493, 26, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 272, 1369, 26, 489, 446, 931, 370, 314, 4837, 77, 570, 4568, 543, 314, 2435, 2933, 3031, 267, 961, 945, 365, 5906, 14, 3645, 283, 6942, 63, 493, 1370, 523, 6235, 63, 493, 26, 272, 1015, 63, 3270, 26, 298, 18, 14, 17, 14, 16, 2, 272, 1369, 26, 489, 446, 931, 370, 314, 4840, 570, 4568, 543, 314, 2435, 2933, 3031, 523, 2199, 63, 344, 26, 272, 1015, 63, 3270, 26, 298, 17, 14, 22, 2, 272, 1369, 26, 489, 446, 2195, 31556, 2199, 2870, 199, 199, 7538, 26, 272, 446, 298, 1548, 2356, 499, 14, 22, 2, 272, 446, 298, 3796, 13, 30651, 2356, 378, 14, 969, 14, 19, 12, 2356, 378, 14, 1196, 14, 16, 340, 1808, 4840, 6235, 2, 199, 2502, 26, 298, 37, 1567, 7135, 25338, 265, 8593, 281, 743, 25338, 79, 9, 665, 281, 743, 25338, 79, 32, 3098, 14, 957, 4335, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 5870, 2893, 402, 6425, 282, 892, 491, 34, 12, 7791, 7556, 12, 436, 282, 13822, 1104, 199, 13, 2257, 63, 1287, 26, 272, 859, 26, 21319, 63, 6374, 272, 536, 26, 511, 6374, 272, 4897, 26, 2739, 13, 16067, 17, 272, 7556, 26, 2097, 527, 13, 16067, 17, 13, 65, 15, 1544, 13, 65, 401, 298, 527, 13, 16067, 17, 13, 66, 15, 1544, 13, 66, 937, 272, 1455, 27941, 63, 354, 26, 394, 67, 272, 1455, 27941, 63, 719, 26, 5939, 272, 1455, 27941, 63, 515, 26, 3286, 384, 2, 199, 2344, 199, 199, 893, 26, 272, 687, 17069, 14, 3357, 14, 1313, 492, 18489, 272, 687, 17069, 14, 3357, 14, 9710, 492, 664, 63, 3090, 272, 687, 17069, 14, 26615, 14, 1313, 492, 18489, 465, 18489, 63,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
coxmediagroup/django-threadedcomments
legacy_threadedcomments/templatetags/threadedcommentstags.py
14
18507
import re from django import template from django.contrib.contenttypes.models import ContentType from django.core.urlresolvers import reverse from django.utils.encoding import force_unicode from django.utils.safestring import mark_safe from threadedcomments.models import ThreadedComment, FreeThreadedComment from threadedcomments.forms import ThreadedCommentForm, FreeThreadedCommentForm # Regular expressions for getting rid of newlines and witespace inbetween = re.compile('>[ \r\n]+<') newlines = re.compile('\r|\n') def get_contenttype_kwargs(content_object): """ Gets the basic kwargs necessary for almost all of the following tags. """ kwargs = { 'content_type' : ContentType.objects.get_for_model(content_object).id, 'object_id' : getattr(content_object, 'pk', getattr(content_object, 'id')), } return kwargs def get_comment_url(content_object, parent=None): """ Given an object and an optional parent, this tag gets the URL to POST to for the creation of new ``ThreadedComment`` objects. """ kwargs = get_contenttype_kwargs(content_object) if parent: if not isinstance(parent, ThreadedComment): raise template.TemplateSyntaxError, "get_comment_url requires its parent object to be of type ThreadedComment" kwargs.update({'parent_id' : getattr(parent, 'pk', getattr(parent, 'id'))}) return reverse('tc_comment_parent', kwargs=kwargs) else: return reverse('tc_comment', kwargs=kwargs) def get_comment_url_ajax(content_object, parent=None, ajax_type='json'): """ Given an object and an optional parent, this tag gets the URL to POST to for the creation of new ``ThreadedComment`` objects. It returns the latest created object in the AJAX form of the user's choosing (json or xml). """ kwargs = get_contenttype_kwargs(content_object) kwargs.update({'ajax' : ajax_type}) if parent: if not isinstance(parent, ThreadedComment): raise template.TemplateSyntaxError, "get_comment_url_ajax requires its parent object to be of type ThreadedComment" kwargs.update({'parent_id' : getattr(parent, 'pk', getattr(parent, 'id'))}) return reverse('tc_comment_parent_ajax', kwargs=kwargs) else: return reverse('tc_comment_ajax', kwargs=kwargs) def get_comment_url_json(content_object, parent=None): """ Wraps ``get_comment_url_ajax`` with ``ajax_type='json'`` """ try: return get_comment_url_ajax(content_object, parent, ajax_type="json") except template.TemplateSyntaxError: raise template.TemplateSyntaxError, "get_comment_url_json requires its parent object to be of type ThreadedComment" return '' def get_comment_url_xml(content_object, parent=None): """ Wraps ``get_comment_url_ajax`` with ``ajax_type='xml'`` """ try: return get_comment_url_ajax(content_object, parent, ajax_type="xml") except template.TemplateSyntaxError: raise template.TemplateSyntaxError, "get_comment_url_xml requires its parent object to be of type ThreadedComment" return '' def get_free_comment_url(content_object, parent=None): """ Given an object and an optional parent, this tag gets the URL to POST to for the creation of new ``FreeThreadedComment`` objects. """ kwargs = get_contenttype_kwargs(content_object) if parent: if not isinstance(parent, FreeThreadedComment): raise template.TemplateSyntaxError, "get_free_comment_url requires its parent object to be of type FreeThreadedComment" kwargs.update({'parent_id' : getattr(parent, 'pk', getattr(parent, 'id'))}) return reverse('tc_free_comment_parent', kwargs=kwargs) else: return reverse('tc_free_comment', kwargs=kwargs) def get_free_comment_url_ajax(content_object, parent=None, ajax_type='json'): """ Given an object and an optional parent, this tag gets the URL to POST to for the creation of new ``FreeThreadedComment`` objects. It returns the latest created object in the AJAX form of the user's choosing (json or xml). """ kwargs = get_contenttype_kwargs(content_object) kwargs.update({'ajax' : ajax_type}) if parent: if not isinstance(parent, FreeThreadedComment): raise template.TemplateSyntaxError, "get_free_comment_url_ajax requires its parent object to be of type FreeThreadedComment" kwargs.update({'parent_id' : getattr(parent, 'pk', getattr(parent, 'id'))}) return reverse('tc_free_comment_parent_ajax', kwargs=kwargs) else: return reverse('tc_free_comment_ajax', kwargs=kwargs) def get_free_comment_url_json(content_object, parent=None): """ Wraps ``get_free_comment_url_ajax`` with ``ajax_type='json'`` """ try: return get_free_comment_url_ajax(content_object, parent, ajax_type="json") except template.TemplateSyntaxError: raise template.TemplateSyntaxError, "get_free_comment_url_json requires its parent object to be of type FreeThreadedComment" return '' def get_free_comment_url_xml(content_object, parent=None): """ Wraps ``get_free_comment_url_ajax`` with ``ajax_type='xml'`` """ try: return get_free_comment_url_ajax(content_object, parent, ajax_type="xml") except template.TemplateSyntaxError: raise template.TemplateSyntaxError, "get_free_comment_url_xml requires its parent object to be of type FreeThreadedComment" return '' def auto_transform_markup(comment): """ Given a comment (``ThreadedComment`` or ``FreeThreadedComment``), this tag looks up the markup type of the comment and formats the output accordingly. It can also output the formatted content to a context variable, if a context name is specified. """ try: from django.utils.html import escape from threadedcomments.models import MARKDOWN, TEXTILE, REST, PLAINTEXT if comment.markup == MARKDOWN: from django.contrib.markup.templatetags.markup import markdown return markdown(comment.comment) elif comment.markup == TEXTILE: from django.contrib.markup.templatetags.markup import textile return textile(comment.comment) elif comment.markup == REST: from django.contrib.markup.templatetags.markup import restructuredtext return restructuredtext(comment.comment) # elif comment.markup == HTML: # return mark_safe(force_unicode(comment.comment)) elif comment.markup == PLAINTEXT: return escape(comment.comment) except ImportError: # Not marking safe, in case tag fails and users input malicious code. return force_unicode(comment.comment) def do_auto_transform_markup(parser, token): try: split = token.split_contents() except ValueError: raise template.TemplateSyntaxError, "%r tag must be of format {%% %r COMMENT %%} or of format {%% %r COMMENT as CONTEXT_VARIABLE %%}" % (token.contents.split()[0], token.contents.split()[0], token.contents.split()[0]) if len(split) == 2: return AutoTransformMarkupNode(split[1]) elif len(split) == 4: return AutoTransformMarkupNode(split[1], context_name=split[3]) else: raise template.TemplateSyntaxError, "Invalid number of arguments for tag %r" % split[0] class AutoTransformMarkupNode(template.Node): def __init__(self, comment, context_name=None): self.comment = template.Variable(comment) self.context_name = context_name def render(self, context): comment = self.comment.resolve(context) if self.context_name: context[self.context_name] = auto_transform_markup(comment) return '' else: return auto_transform_markup(comment) def do_get_threaded_comment_tree(parser, token): """ Gets a tree (list of objects ordered by preorder tree traversal, and with an additional ``depth`` integer attribute annotated onto each ``ThreadedComment``. """ error_string = "%r tag must be of format {%% get_threaded_comment_tree for OBJECT [TREE_ROOT] as CONTEXT_VARIABLE %%}" % token.contents.split()[0] try: split = token.split_contents() except ValueError: raise template.TemplateSyntaxError(error_string) if len(split) == 5: return CommentTreeNode(split[2], split[4], split[3]) elif len(split) == 6: return CommentTreeNode(split[2], split[5], split[3]) else: raise template.TemplateSyntaxError(error_string) def do_get_free_threaded_comment_tree(parser, token): """ Gets a tree (list of objects ordered by traversing tree in preorder, and with an additional ``depth`` integer attribute annotated onto each ``FreeThreadedComment.`` """ error_string = "%r tag must be of format {%% get_free_threaded_comment_tree for OBJECT [TREE_ROOT] as CONTEXT_VARIABLE %%}" % token.contents.split()[0] try: split = token.split_contents() except ValueError: raise template.TemplateSyntaxError(error_string) if len(split) == 5: return FreeCommentTreeNode(split[2], split[4], split[3]) elif len(split) == 6: return FreeCommentTreeNode(split[2], split[5], split[3]) else: raise template.TemplateSyntaxError(error_string) class CommentTreeNode(template.Node): def __init__(self, content_object, context_name, tree_root): self.content_object = template.Variable(content_object) self.tree_root = template.Variable(tree_root) self.tree_root_str = tree_root self.context_name = context_name def render(self, context): content_object = self.content_object.resolve(context) try: tree_root = self.tree_root.resolve(context) except template.VariableDoesNotExist: if self.tree_root_str == 'as': tree_root = None else: try: tree_root = int(self.tree_root_str) except ValueError: tree_root = self.tree_root_str context[self.context_name] = ThreadedComment.public.get_tree(content_object, root=tree_root) return '' class FreeCommentTreeNode(template.Node): def __init__(self, content_object, context_name, tree_root): self.content_object = template.Variable(content_object) self.tree_root = template.Variable(tree_root) self.tree_root_str = tree_root self.context_name = context_name def render(self, context): content_object = self.content_object.resolve(context) try: tree_root = self.tree_root.resolve(context) except template.VariableDoesNotExist: if self.tree_root_str == 'as': tree_root = None else: try: tree_root = int(self.tree_root_str) except ValueError: tree_root = self.tree_root_str context[self.context_name] = FreeThreadedComment.public.get_tree(content_object, root=tree_root) return '' def do_get_comment_count(parser, token): """ Gets a count of how many ThreadedComment objects are attached to the given object. """ error_message = "%r tag must be of format {%% %r for OBJECT as CONTEXT_VARIABLE %%}" % (token.contents.split()[0], token.contents.split()[0]) try: split = token.split_contents() except ValueError: raise template.TemplateSyntaxError, error_message if split[1] != 'for' or split[3] != 'as': raise template.TemplateSyntaxError, error_message return ThreadedCommentCountNode(split[2], split[4]) class ThreadedCommentCountNode(template.Node): def __init__(self, content_object, context_name): self.content_object = template.Variable(content_object) self.context_name = context_name def render(self, context): content_object = self.content_object.resolve(context) context[self.context_name] = ThreadedComment.public.all_for_object(content_object).count() return '' def do_get_free_comment_count(parser, token): """ Gets a count of how many FreeThreadedComment objects are attached to the given object. """ error_message = "%r tag must be of format {%% %r for OBJECT as CONTEXT_VARIABLE %%}" % (token.contents.split()[0], token.contents.split()[0]) try: split = token.split_contents() except ValueError: raise template.TemplateSyntaxError, error_message if split[1] != 'for' or split[3] != 'as': raise template.TemplateSyntaxError, error_message return FreeThreadedCommentCountNode(split[2], split[4]) class FreeThreadedCommentCountNode(template.Node): def __init__(self, content_object, context_name): self.content_object = template.Variable(content_object) self.context_name = context_name def render(self, context): content_object = self.content_object.resolve(context) context[self.context_name] = FreeThreadedComment.public.all_for_object(content_object).count() return '' def oneline(value): """ Takes some HTML and gets rid of newlines and spaces between tags, rendering the result all on one line. """ try: return mark_safe(newlines.sub('', inbetween.sub('><', value))) except: return value def do_get_threaded_comment_form(parser, token): """ Gets a FreeThreadedCommentForm and inserts it into the context. """ error_message = "%r tag must be of format {%% %r as CONTEXT_VARIABLE %%}" % (token.contents.split()[0], token.contents.split()[0]) try: split = token.split_contents() except ValueError: raise template.TemplateSyntaxError, error_message if split[1] != 'as': raise template.TemplateSyntaxError, error_message if len(split) != 3: raise template.TemplateSyntaxError, error_message if "free" in split[0]: is_free = True else: is_free = False return ThreadedCommentFormNode(split[2], free=is_free) class ThreadedCommentFormNode(template.Node): def __init__(self, context_name, free=False): self.context_name = context_name self.free = free def render(self, context): if self.free: form = FreeThreadedCommentForm() else: form = ThreadedCommentForm() context[self.context_name] = form return '' def do_get_latest_comments(parser, token): """ Gets the latest comments by date_submitted. """ error_message = "%r tag must be of format {%% %r NUM_TO_GET as CONTEXT_VARIABLE %%}" % (token.contents.split()[0], token.contents.split()[0]) try: split = token.split_contents() except ValueError: raise template.TemplateSyntaxError, error_message if len(split) != 4: raise template.TemplateSyntaxError, error_message if split[2] != 'as': raise template.TemplateSyntaxError, error_message if "free" in split[0]: is_free = True else: is_free = False return LatestCommentsNode(split[1], split[3], free=is_free) class LatestCommentsNode(template.Node): def __init__(self, num, context_name, free=False): self.num = num self.context_name = context_name self.free = free def render(self, context): if self.free: comments = FreeThreadedComment.objects.order_by('-date_submitted')[:self.num] else: comments = ThreadedComment.objects.order_by('-date_submitted')[:self.num] context[self.context_name] = comments return '' def do_get_user_comments(parser, token): """ Gets all comments submitted by a particular user. """ error_message = "%r tag must be of format {%% %r for OBJECT as CONTEXT_VARIABLE %%}" % (token.contents.split()[0], token.contents.split()[0]) try: split = token.split_contents() except ValueError: raise template.TemplateSyntaxError, error_message if len(split) != 5: raise template.TemplateSyntaxError, error_message return UserCommentsNode(split[2], split[4]) class UserCommentsNode(template.Node): def __init__(self, user, context_name): self.user = template.Variable(user) self.context_name = context_name def render(self, context): user = self.user.resolve(context) context[self.context_name] = user.threadedcomment_set.all() return '' def do_get_user_comment_count(parser, token): """ Gets the count of all comments submitted by a particular user. """ error_message = "%r tag must be of format {%% %r for OBJECT as CONTEXT_VARIABLE %%}" % (token.contents.split()[0], token.contents.split()[0]) try: split = token.split_contents() except ValueError: raise template.TemplateSyntaxError, error_message if len(split) != 5: raise template.TemplateSyntaxError, error_message return UserCommentCountNode(split[2], split[4]) class UserCommentCountNode(template.Node): def __init__(self, user, context_name): self.user = template.Variable(user) self.context_name = context_name def render(self, context): user = self.user.resolve(context) context[self.context_name] = user.threadedcomment_set.all().count() return '' register = template.Library() register.simple_tag(get_comment_url) register.simple_tag(get_comment_url_json) register.simple_tag(get_comment_url_xml) register.simple_tag(get_free_comment_url) register.simple_tag(get_free_comment_url_json) register.simple_tag(get_free_comment_url_xml) register.filter('oneline', oneline) register.tag('auto_transform_markup', do_auto_transform_markup) register.tag('get_threaded_comment_tree', do_get_threaded_comment_tree) register.tag('get_free_threaded_comment_tree', do_get_free_threaded_comment_tree) register.tag('get_comment_count', do_get_comment_count) register.tag('get_free_comment_count', do_get_free_comment_count) register.tag('get_free_threaded_comment_form', do_get_threaded_comment_form) register.tag('get_threaded_comment_form', do_get_threaded_comment_form) register.tag('get_latest_comments', do_get_latest_comments) register.tag('get_latest_free_comments', do_get_latest_comments) register.tag('get_user_comments', do_get_user_comments) register.tag('get_user_comment_count', do_get_user_comment_count)
bsd-3-clause
[ 646, 295, 199, 504, 1639, 492, 1978, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2975, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 504, 25396, 6223, 14, 992, 492, 3868, 11698, 7488, 12, 2868, 31699, 7488, 199, 504, 25396, 6223, 14, 3351, 492, 3868, 11698, 7488, 2821, 12, 2868, 31699, 7488, 2821, 199, 199, 3, 18528, 8455, 367, 10232, 16146, 402, 14930, 436, 336, 4820, 199, 262, 13007, 275, 295, 14, 2014, 360, 9514, 971, 82, 60, 78, 2807, 28, 358, 199, 13839, 275, 295, 14, 2014, 2258, 82, 6113, 78, 358, 199, 199, 318, 664, 63, 20735, 63, 958, 8, 1317, 63, 785, 304, 272, 408, 272, 14509, 314, 5678, 2074, 5784, 367, 18871, 1006, 402, 314, 2569, 3762, 14, 272, 408, 272, 2074, 275, 469, 267, 283, 1317, 63, 466, 7, 520, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1317, 63, 785, 680, 344, 12, 267, 283, 785, 63, 344, 7, 520, 2519, 8, 1317, 63, 785, 12, 283, 2051, 297, 2519, 8, 1317, 63, 785, 12, 283, 344, 3855, 272, 789, 272, 372, 2074, 199, 199, 318, 664, 63, 3349, 63, 633, 8, 1317, 63, 785, 12, 1676, 29, 403, 304, 272, 408, 272, 9138, 376, 909, 436, 376, 2716, 1676, 12, 642, 1947, 7545, 314, 2851, 370, 8761, 370, 367, 314, 272, 7143, 402, 892, 1124, 31699, 7488, 1040, 2251, 14, 272, 408, 272, 2074, 275, 664, 63, 20735, 63, 958, 8, 1317, 63, 785, 9, 272, 340, 1676, 26, 267, 340, 440, 1228, 8, 1708, 12, 3868, 11698, 7488, 304, 288, 746, 1978, 14, 20837, 12, 298, 362, 63, 3349, 63, 633, 5074, 2399, 1676, 909, 370, 506, 402, 730, 3868, 11698, 7488, 2, 267, 2074, 14, 873, 3252, 1708, 63, 344, 7, 520, 2519, 8, 1708, 12, 283, 2051, 297, 2519, 8, 1708, 12, 283, 344, 1333, 1552, 267, 372, 3837, 360, 3641, 63, 3349, 63, 1708, 297, 2074, 29, 958, 9, 272, 587, 26, 267, 372, 3837, 360, 3641, 63, 3349, 297, 2074, 29, 958, 9, 199, 199, 318, 664, 63, 3349, 63, 633, 63, 12774, 8, 1317, 63, 785, 12, 1676, 29, 403, 12, 25930, 63, 466, 534, 1001, 735, 272, 408, 272, 9138, 376, 909, 436, 376, 2716, 1676, 12, 642, 1947, 7545, 314, 2851, 370, 8761, 370, 367, 314, 272, 7143, 402, 892, 1124, 31699, 7488, 1040, 2251, 14, 221, 2779, 2529, 314, 8839, 2737, 909, 272, 315, 314, 437, 42, 9839, 1824, 402, 314, 922, 1159, 2468, 26056, 334, 1001, 503, 2748, 680, 272, 408, 272, 2074, 275, 664, 63, 20735, 63, 958, 8, 1317, 63, 785, 9, 272, 2074, 14, 873, 3252, 12774, 7, 520, 25930, 63, 466, 1552, 272, 340, 1676, 26, 267, 340, 440, 1228, 8, 1708, 12, 3868, 11698, 7488, 304, 288, 746, 1978, 14, 20837, 12, 298, 362, 63, 3349, 63, 633, 63, 12774, 5074, 2399, 1676, 909, 370, 506, 402, 730, 3868, 11698, 7488, 2, 267, 2074, 14, 873, 3252, 1708, 63, 344, 7, 520, 2519, 8, 1708, 12, 283, 2051, 297, 2519, 8, 1708, 12, 283, 344, 1333, 1552, 267, 372, 3837, 360, 3641, 63, 3349, 63, 1708, 63, 12774, 297, 2074, 29, 958, 9, 272, 587, 26, 267, 372, 3837, 360, 3641, 63, 3349, 63, 12774, 297, 2074, 29, 958, 9, 199, 199, 318, 664, 63, 3349, 63, 633, 63, 1001, 8, 1317, 63, 785, 12, 1676, 29, 403, 304, 272, 408, 272, 644, 8146, 1124, 362, 63, 3349, 63, 633, 63, 12774, 1040, 543, 1124, 12774, 63, 466, 534, 1001, 14700, 272, 408, 272, 862, 26, 267, 372, 664, 63, 3349, 63, 633, 63, 12774, 8, 1317, 63, 785, 12, 1676, 12, 25930, 63, 466, 628, 1001, 531, 272, 871, 1978, 14, 20837, 26, 267, 746, 1978, 14, 20837, 12, 298, 362, 63, 3349, 63, 633, 63, 1001, 5074, 2399, 1676, 909, 370, 506, 402, 730, 3868, 11698, 7488, 2, 272, 372, 2125, 199, 199, 318, 664, 63, 3349, 63, 633, 63, 1652, 8, 1317, 63, 785, 12, 1676, 29, 403, 304, 272, 408, 272, 644, 8146, 1124, 362, 63, 3349, 63, 633, 63, 12774, 1040, 543, 1124, 12774, 63, 466, 534, 1652, 14700, 272, 408, 272, 862, 26, 267, 372, 664, 63, 3349, 63, 633, 63, 12774, 8, 1317, 63, 785, 12, 1676, 12, 25930, 63, 466, 628, 1652, 531, 272, 871, 1978, 14, 20837, 26, 267, 746, 1978, 14, 20837, 12, 298, 362, 63, 3349, 63, 633, 63, 1652, 5074, 2399, 1676, 909, 370, 506, 402, 730, 3868, 11698, 7488, 2, 272, 372, 2125, 199, 199, 318, 664, 63, 4624, 63, 3349, 63, 633, 8, 1317, 63, 785, 12, 1676, 29, 403, 304, 272, 408, 272, 9138, 376, 909, 436, 376, 2716, 1676, 12, 642, 1947, 7545, 314, 2851, 370, 8761, 370, 367, 314, 272, 7143, 402, 892, 1124, 10146, 31699, 7488, 1040, 2251, 14, 272, 408, 272, 2074, 275, 664, 63, 20735, 63, 958, 8, 1317, 63, 785, 9, 272, 340, 1676, 26, 267, 340, 440, 1228, 8, 1708, 12, 2868, 31699, 7488, 304, 288, 746, 1978, 14, 20837, 12, 298, 362, 63, 4624, 63, 3349, 63, 633, 5074, 2399, 1676, 909, 370, 506, 402, 730, 2868, 31699, 7488, 2, 267, 2074, 14, 873, 3252, 1708, 63, 344, 7, 520, 2519, 8, 1708, 12, 283, 2051, 297, 2519, 8, 1708, 12, 283, 344, 1333, 1552, 267, 372, 3837, 360, 3641, 63, 4624, 63, 3349, 63, 1708, 297, 2074, 29, 958, 9, 272, 587, 26, 267, 372, 3837, 360, 3641, 63, 4624, 63, 3349, 297, 2074, 29, 958, 9, 199, 199, 318, 664, 63, 4624, 63, 3349, 63, 633, 63, 12774, 8, 1317, 63, 785, 12, 1676, 29, 403, 12, 25930, 63, 466, 534, 1001, 735, 272, 408, 272, 9138, 376, 909, 436, 376, 2716, 1676, 12, 642, 1947, 7545, 314, 2851, 370, 8761, 370, 367, 314, 272, 7143, 402, 892, 1124, 10146, 31699, 7488, 1040, 2251, 14, 221, 2779, 2529, 314, 8839, 2737, 909, 272, 315, 314, 437, 42, 9839, 1824, 402, 314, 922, 1159, 2468, 26056, 334, 1001, 503, 2748 ]
[ 295, 199, 504, 1639, 492, 1978, 199, 504, 1639, 14, 2828, 14, 10778, 14, 992, 492, 14501, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 199, 504, 1639, 14, 1208, 14, 2991, 492, 3542, 63, 2975, 199, 504, 1639, 14, 1208, 14, 28389, 492, 2216, 63, 3489, 199, 504, 25396, 6223, 14, 992, 492, 3868, 11698, 7488, 12, 2868, 31699, 7488, 199, 504, 25396, 6223, 14, 3351, 492, 3868, 11698, 7488, 2821, 12, 2868, 31699, 7488, 2821, 199, 199, 3, 18528, 8455, 367, 10232, 16146, 402, 14930, 436, 336, 4820, 199, 262, 13007, 275, 295, 14, 2014, 360, 9514, 971, 82, 60, 78, 2807, 28, 358, 199, 13839, 275, 295, 14, 2014, 2258, 82, 6113, 78, 358, 199, 199, 318, 664, 63, 20735, 63, 958, 8, 1317, 63, 785, 304, 272, 408, 272, 14509, 314, 5678, 2074, 5784, 367, 18871, 1006, 402, 314, 2569, 3762, 14, 272, 408, 272, 2074, 275, 469, 267, 283, 1317, 63, 466, 7, 520, 14501, 14, 1462, 14, 362, 63, 509, 63, 1238, 8, 1317, 63, 785, 680, 344, 12, 267, 283, 785, 63, 344, 7, 520, 2519, 8, 1317, 63, 785, 12, 283, 2051, 297, 2519, 8, 1317, 63, 785, 12, 283, 344, 3855, 272, 789, 272, 372, 2074, 199, 199, 318, 664, 63, 3349, 63, 633, 8, 1317, 63, 785, 12, 1676, 29, 403, 304, 272, 408, 272, 9138, 376, 909, 436, 376, 2716, 1676, 12, 642, 1947, 7545, 314, 2851, 370, 8761, 370, 367, 314, 272, 7143, 402, 892, 1124, 31699, 7488, 1040, 2251, 14, 272, 408, 272, 2074, 275, 664, 63, 20735, 63, 958, 8, 1317, 63, 785, 9, 272, 340, 1676, 26, 267, 340, 440, 1228, 8, 1708, 12, 3868, 11698, 7488, 304, 288, 746, 1978, 14, 20837, 12, 298, 362, 63, 3349, 63, 633, 5074, 2399, 1676, 909, 370, 506, 402, 730, 3868, 11698, 7488, 2, 267, 2074, 14, 873, 3252, 1708, 63, 344, 7, 520, 2519, 8, 1708, 12, 283, 2051, 297, 2519, 8, 1708, 12, 283, 344, 1333, 1552, 267, 372, 3837, 360, 3641, 63, 3349, 63, 1708, 297, 2074, 29, 958, 9, 272, 587, 26, 267, 372, 3837, 360, 3641, 63, 3349, 297, 2074, 29, 958, 9, 199, 199, 318, 664, 63, 3349, 63, 633, 63, 12774, 8, 1317, 63, 785, 12, 1676, 29, 403, 12, 25930, 63, 466, 534, 1001, 735, 272, 408, 272, 9138, 376, 909, 436, 376, 2716, 1676, 12, 642, 1947, 7545, 314, 2851, 370, 8761, 370, 367, 314, 272, 7143, 402, 892, 1124, 31699, 7488, 1040, 2251, 14, 221, 2779, 2529, 314, 8839, 2737, 909, 272, 315, 314, 437, 42, 9839, 1824, 402, 314, 922, 1159, 2468, 26056, 334, 1001, 503, 2748, 680, 272, 408, 272, 2074, 275, 664, 63, 20735, 63, 958, 8, 1317, 63, 785, 9, 272, 2074, 14, 873, 3252, 12774, 7, 520, 25930, 63, 466, 1552, 272, 340, 1676, 26, 267, 340, 440, 1228, 8, 1708, 12, 3868, 11698, 7488, 304, 288, 746, 1978, 14, 20837, 12, 298, 362, 63, 3349, 63, 633, 63, 12774, 5074, 2399, 1676, 909, 370, 506, 402, 730, 3868, 11698, 7488, 2, 267, 2074, 14, 873, 3252, 1708, 63, 344, 7, 520, 2519, 8, 1708, 12, 283, 2051, 297, 2519, 8, 1708, 12, 283, 344, 1333, 1552, 267, 372, 3837, 360, 3641, 63, 3349, 63, 1708, 63, 12774, 297, 2074, 29, 958, 9, 272, 587, 26, 267, 372, 3837, 360, 3641, 63, 3349, 63, 12774, 297, 2074, 29, 958, 9, 199, 199, 318, 664, 63, 3349, 63, 633, 63, 1001, 8, 1317, 63, 785, 12, 1676, 29, 403, 304, 272, 408, 272, 644, 8146, 1124, 362, 63, 3349, 63, 633, 63, 12774, 1040, 543, 1124, 12774, 63, 466, 534, 1001, 14700, 272, 408, 272, 862, 26, 267, 372, 664, 63, 3349, 63, 633, 63, 12774, 8, 1317, 63, 785, 12, 1676, 12, 25930, 63, 466, 628, 1001, 531, 272, 871, 1978, 14, 20837, 26, 267, 746, 1978, 14, 20837, 12, 298, 362, 63, 3349, 63, 633, 63, 1001, 5074, 2399, 1676, 909, 370, 506, 402, 730, 3868, 11698, 7488, 2, 272, 372, 2125, 199, 199, 318, 664, 63, 3349, 63, 633, 63, 1652, 8, 1317, 63, 785, 12, 1676, 29, 403, 304, 272, 408, 272, 644, 8146, 1124, 362, 63, 3349, 63, 633, 63, 12774, 1040, 543, 1124, 12774, 63, 466, 534, 1652, 14700, 272, 408, 272, 862, 26, 267, 372, 664, 63, 3349, 63, 633, 63, 12774, 8, 1317, 63, 785, 12, 1676, 12, 25930, 63, 466, 628, 1652, 531, 272, 871, 1978, 14, 20837, 26, 267, 746, 1978, 14, 20837, 12, 298, 362, 63, 3349, 63, 633, 63, 1652, 5074, 2399, 1676, 909, 370, 506, 402, 730, 3868, 11698, 7488, 2, 272, 372, 2125, 199, 199, 318, 664, 63, 4624, 63, 3349, 63, 633, 8, 1317, 63, 785, 12, 1676, 29, 403, 304, 272, 408, 272, 9138, 376, 909, 436, 376, 2716, 1676, 12, 642, 1947, 7545, 314, 2851, 370, 8761, 370, 367, 314, 272, 7143, 402, 892, 1124, 10146, 31699, 7488, 1040, 2251, 14, 272, 408, 272, 2074, 275, 664, 63, 20735, 63, 958, 8, 1317, 63, 785, 9, 272, 340, 1676, 26, 267, 340, 440, 1228, 8, 1708, 12, 2868, 31699, 7488, 304, 288, 746, 1978, 14, 20837, 12, 298, 362, 63, 4624, 63, 3349, 63, 633, 5074, 2399, 1676, 909, 370, 506, 402, 730, 2868, 31699, 7488, 2, 267, 2074, 14, 873, 3252, 1708, 63, 344, 7, 520, 2519, 8, 1708, 12, 283, 2051, 297, 2519, 8, 1708, 12, 283, 344, 1333, 1552, 267, 372, 3837, 360, 3641, 63, 4624, 63, 3349, 63, 1708, 297, 2074, 29, 958, 9, 272, 587, 26, 267, 372, 3837, 360, 3641, 63, 4624, 63, 3349, 297, 2074, 29, 958, 9, 199, 199, 318, 664, 63, 4624, 63, 3349, 63, 633, 63, 12774, 8, 1317, 63, 785, 12, 1676, 29, 403, 12, 25930, 63, 466, 534, 1001, 735, 272, 408, 272, 9138, 376, 909, 436, 376, 2716, 1676, 12, 642, 1947, 7545, 314, 2851, 370, 8761, 370, 367, 314, 272, 7143, 402, 892, 1124, 10146, 31699, 7488, 1040, 2251, 14, 221, 2779, 2529, 314, 8839, 2737, 909, 272, 315, 314, 437, 42, 9839, 1824, 402, 314, 922, 1159, 2468, 26056, 334, 1001, 503, 2748, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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py
4
7203
# coding: utf-8 """ Functions for Kodi plugins """ SORT_METHOD_ALBUM = 13 SORT_METHOD_ALBUM_IGNORE_THE = 14 SORT_METHOD_ARTIST = 11 SORT_METHOD_ARTIST_IGNORE_THE = 12 SORT_METHOD_BITRATE = 40 SORT_METHOD_CHANNEL = 38 SORT_METHOD_COUNTRY = 16 SORT_METHOD_DATE = 3 SORT_METHOD_DATEADDED = 19 SORT_METHOD_DATE_TAKEN = 41 SORT_METHOD_DRIVE_TYPE = 6 SORT_METHOD_DURATION = 8 SORT_METHOD_EPISODE = 22 SORT_METHOD_FILE = 5 SORT_METHOD_FULLPATH = 32 SORT_METHOD_GENRE = 15 SORT_METHOD_LABEL = 1 SORT_METHOD_LABEL_IGNORE_FOLDERS = 33 SORT_METHOD_LABEL_IGNORE_THE = 2 SORT_METHOD_LASTPLAYED = 34 SORT_METHOD_LISTENERS = 36 SORT_METHOD_MPAA_RATING = 28 SORT_METHOD_NONE = 0 SORT_METHOD_PLAYCOUNT = 35 SORT_METHOD_PLAYLIST_ORDER = 21 SORT_METHOD_PRODUCTIONCODE = 26 SORT_METHOD_PROGRAM_COUNT = 20 SORT_METHOD_SIZE = 4 SORT_METHOD_SONG_RATING = 27 SORT_METHOD_STUDIO = 30 SORT_METHOD_STUDIO_IGNORE_THE = 31 SORT_METHOD_TITLE = 9 SORT_METHOD_TITLE_IGNORE_THE = 10 SORT_METHOD_TRACKNUM = 7 SORT_METHOD_UNSORTED = 37 SORT_METHOD_VIDEO_RATING = 18 SORT_METHOD_VIDEO_RUNTIME = 29 SORT_METHOD_VIDEO_SORT_TITLE = 24 SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE = 25 SORT_METHOD_VIDEO_TITLE = 23 SORT_METHOD_VIDEO_YEAR = 17 __author__ = 'Team Kodi <http://kodi.tv>' __credits__ = 'Team Kodi' __date__ = 'Fri May 01 16:22:19 BST 2015' __platform__ = 'ALL' __version__ = '2.20.0' def addDirectoryItem(handle, url, listitem, isFolder=False, totalItems=0): """Callback function to pass directory contents back to XBMC. Returns a bool for successful completion. :param handle: integer - handle the plugin was started with. :param url: string - url of the entry. would be plugin:// for another virtual directory. :param listitem: ListItem - item to add. :param isFolder: bool - True=folder / False=not a folder. :param totalItems: integer - total number of items that will be passed. (used for progressbar) Example:: if not xbmcplugin.addDirectoryItem(int(sys.argv[1]), 'F:\\Trailers\\300.mov', listitem, totalItems=50): break """ return bool(1) def addDirectoryItems(handle, items, totalItems=0): """Callback function to pass directory contents back to XBMC as a list. Returns a bool for successful completion. :param handle: integer - handle the plugin was started with. :param items: List - list of (url, listitem[, isFolder]) as a tuple to add. :param totalItems: integer - total number of items that will be passed. (used for progressbar) .. note:: Large lists benefit over using the standard addDirectoryItem(). You may call this more than once to add items in chunks. Example:: if not xbmcplugin.addDirectoryItems(int(sys.argv[1]), [(url, listitem, False,)]: raise """ return bool(1) def endOfDirectory(handle, succeeded=True, updateListing=False, cacheToDisc=True): """Callback function to tell XBMC that the end of the directory listing in a virtualPythonFolder module is reached. :param handle: integer - handle the plugin was started with. :param succeeded: bool - True=script completed successfully/False=Script did not. :param updateListing: bool - True=this folder should update the current listing/False=Folder is a subfolder. :param cacheToDisc: bool - True=Folder will cache if extended time/False=this folder will never cache to disc. Example:: xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc=False) """ pass def setResolvedUrl(handle, succeeded, listitem): """Callback function to tell XBMC that the file plugin has been resolved to a url :param handle: integer - handle the plugin was started with. :param succeeded: bool - True=script completed successfully/False=Script did not. :param listitem: ListItem - item the file plugin resolved to for playback. Example:: xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem) """ pass def addSortMethod(handle, sortMethod, label2Mask=''): """Adds a sorting method for the media list. :param handle: integer - handle the plugin was started with. :param sortMethod: integer - number for sortmethod see FileItem.h. :param label2Mask: string - the label mask to use for the second label. Defaults to '%D' applies to: ``SORT_METHOD_NONE``, ``SORT_METHOD_UNSORTED``, ``SORT_METHOD_VIDEO_TITLE``, ``SORT_METHOD_TRACKNUM``, ``SORT_METHOD_FILE``, ``SORT_METHOD_TITLE``, ``SORT_METHOD_TITLE_IGNORE_THE``, ``SORT_METHOD_LABEL``, ``SORT_METHOD_LABEL_IGNORE_THE`` Example:: xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_TITLE) """ pass def getSetting(handle, id): """Returns the value of a setting as a string. :param handle: integer - handle the plugin was started with. :param id: string - id of the setting that the module needs to access. Example:: apikey = xbmcplugin.getSetting(int(sys.argv[1]), 'apikey') """ return str() def setSetting(handle, id, value): """Sets a plugin setting for the current running plugin. :param handle: integer - handle the plugin was started with. :param id: string - id of the setting that the module needs to access. :param value: string or unicode - value of the setting. Example:: xbmcplugin.setSetting(int(sys.argv[1]), id='username', value='teamxbmc') """ pass def setContent(handle, content): """Sets the plugins content. :param handle: integer - handle the plugin was started with. :param content: string - content type (eg. movies). .. note:: Possible values for content: files, songs, artists, albums, movies, tvshows, episodes, musicvideos Example:: xbmcplugin.setContent(int(sys.argv[1]), 'movies') """ pass def setPluginCategory(handle, category): """Sets the plugins name for skins to display. :param handle: integer - handle the plugin was started with. :param category: string or unicode - plugins sub category. Example:: xbmcplugin.setPluginCategory(int(sys.argv[1]), 'Comedy') """ pass def setPluginFanart(handle, image=None, color1=None, color2=None, color3=None): """Sets the plugins fanart and color for skins to display. :param handle: integer - handle the plugin was started with. :param image: string - path to fanart image. :param color1: hexstring - color1. (e.g. '0xFFFFFFFF') :param color2: hexstring - color2. (e.g. '0xFFFF3300') :param color3: hexstring - color3. (e.g. '0xFF000000') Example:: xbmcplugin.setPluginFanart(int(sys.argv[1]), 'special://home/addons/plugins/video/Apple movie trailers II/fanart.png', color2='0xFFFF3300') """ pass def setProperty(handle, key, value): """Sets a container property for this plugin. :param handle: integer - handle the plugin was started with. :param key: string - property name. :param value: string or unicode - value of property. .. note:: Key is NOT case sensitive. Example:: xbmcplugin.setProperty(int(sys.argv[1]), 'Emulator', 'M.A.M.E.') """ pass
apache-2.0
[ 3, 2803, 26, 2774, 13, 24, 199, 624, 199, 13967, 367, 1804, 79, 328, 8963, 199, 624, 199, 199, 23447, 63, 9977, 63, 748, 34, 2639, 275, 4944, 199, 23447, 63, 9977, 63, 748, 34, 2639, 63, 11209, 63, 18061, 275, 4329, 199, 23447, 63, 9977, 63, 2294, 6225, 275, 4119, 199, 23447, 63, 9977, 63, 2294, 6225, 63, 11209, 63, 18061, 275, 3144, 199, 23447, 63, 9977, 63, 11970, 16553, 275, 6335, 199, 23447, 63, 9977, 63, 14833, 275, 10448, 199, 23447, 63, 9977, 63, 30263, 275, 3193, 199, 23447, 63, 9977, 63, 5390, 275, 650, 199, 23447, 63, 9977, 63, 5390, 1554, 8280, 275, 5851, 199, 23447, 63, 9977, 63, 5390, 63, 6166, 6945, 275, 13385, 199, 23447, 63, 9977, 63, 4564, 5399, 63, 2711, 275, 1227, 199, 23447, 63, 9977, 63, 36, 15301, 275, 1695, 199, 23447, 63, 9977, 63, 6102, 7336, 1093, 275, 6928, 199, 23447, 63, 9977, 63, 3817, 275, 959, 199, 23447, 63, 9977, 63, 14742, 3243, 275, 4337, 199, 23447, 63, 9977, 63, 9289, 907, 275, 4114, 199, 23447, 63, 9977, 63, 13837, 275, 413, 199, 23447, 63, 9977, 63, 13837, 63, 11209, 63, 38, 5104, 3960, 275, 9404, 199, 23447, 63, 9977, 63, 13837, 63, 11209, 63, 18061, 275, 499, 199, 23447, 63, 9977, 63, 16901, 11625, 1149, 275, 8177, 199, 23447, 63, 9977, 63, 4924, 742, 3960, 275, 8780, 199, 23447, 63, 9977, 63, 1658, 2276, 63, 21047, 1206, 275, 7294, 199, 23447, 63, 9977, 63, 9185, 275, 378, 199, 23447, 63, 9977, 63, 11625, 8760, 275, 8685, 199, 23447, 63, 9977, 63, 11625, 4924, 63, 12125, 275, 7829, 199, 23447, 63, 9977, 63, 2514, 4980, 5430, 6012, 275, 7875, 199, 23447, 63, 9977, 63, 15605, 63, 8760, 275, 3388, 199, 23447, 63, 9977, 63, 4305, 275, 841, 199, 23447, 63, 9977, 63, 3377, 39, 63, 21047, 1206, 275, 8087, 199, 23447, 63, 9977, 63, 840, 53, 19283, 275, 4233, 199, 23447, 63, 9977, 63, 840, 53, 19283, 63, 11209, 63, 18061, 275, 7105, 199, 23447, 63, 9977, 63, 19091, 275, 1749, 199, 23447, 63, 9977, 63, 19091, 63, 11209, 63, 18061, 275, 1616, 199, 23447, 63, 9977, 63, 19755, 7125, 275, 1520, 199, 23447, 63, 9977, 63, 1734, 23447, 1149, 275, 6877, 199, 23447, 63, 9977, 63, 20142, 63, 21047, 1206, 275, 6155, 199, 23447, 63, 9977, 63, 20142, 63, 9390, 4961, 275, 7349, 199, 23447, 63, 9977, 63, 20142, 63, 23447, 63, 19091, 275, 5504, 199, 23447, 63, 9977, 63, 20142, 63, 23447, 63, 19091, 63, 11209, 63, 18061, 275, 5661, 199, 23447, 63, 9977, 63, 20142, 63, 19091, 275, 6546, 199, 23447, 63, 9977, 63, 20142, 63, 19216, 275, 5557, 199, 363, 2502, 363, 275, 283, 13126, 1804, 79, 328, 665, 1014, 921, 7697, 328, 14, 6993, 3524, 199, 363, 22461, 363, 275, 283, 13126, 1804, 79, 328, 7, 199, 363, 602, 363, 275, 283, 22533, 10162, 17163, 3193, 26, 1081, 26, 1167, 699, 840, 6900, 7, 199, 363, 3246, 363, 275, 283, 1761, 7, 199, 363, 1023, 363, 275, 283, 18, 14, 1165, 14, 16, 7, 421, 199, 318, 1050, 6231, 2081, 8, 2479, 12, 1166, 12, 769, 1053, 12, 365, 7850, 29, 797, 12, 3141, 7412, 29, 16, 304, 272, 408, 2806, 805, 370, 986, 2082, 4072, 1771, 370, 1323, 28994, 14, 339, 1803, 282, 2155, 367, 9512, 13659, 14, 339, 520, 635, 2429, 26, 3000, 446, 2429, 314, 3589, 1990, 8239, 543, 14, 272, 520, 635, 1166, 26, 1059, 446, 1166, 402, 314, 2397, 14, 3955, 506, 3589, 921, 367, 4573, 5791, 2082, 14, 272, 520, 635, 769, 1053, 26, 3820, 2081, 446, 1242, 370, 1050, 14, 272, 520, 635, 365, 7850, 26, 2155, 446, 715, 29, 3741, 1182, 756, 29, 1397, 282, 4922, 14, 272, 520, 635, 3141, 7412, 26, 3000, 446, 3141, 1329, 402, 2974, 626, 911, 506, 3032, 14, 334, 2972, 367, 6696, 1700, 9, 339, 5679, 447, 398, 340, 440, 11709, 2718, 14, 525, 6231, 2081, 8, 442, 8, 1274, 14, 3020, 59, 17, 2522, 283, 38, 18589, 2437, 441, 2393, 1103, 5863, 14, 14469, 297, 769, 1053, 12, 3141, 7412, 29, 1400, 304, 288, 2059, 272, 408, 272, 372, 2155, 8, 17, 9, 421, 199, 318, 1050, 6231, 7412, 8, 2479, 12, 2974, 12, 3141, 7412, 29, 16, 304, 272, 408, 2806, 805, 370, 986, 2082, 4072, 1771, 370, 1323, 28994, 465, 282, 769, 14, 339, 1803, 282, 2155, 367, 9512, 13659, 14, 339, 520, 635, 2429, 26, 3000, 446, 2429, 314, 3589, 1990, 8239, 543, 14, 272, 520, 635, 2974, 26, 3820, 446, 769, 402, 334, 633, 12, 769, 1053, 14675, 365, 7850, 566, 465, 282, 2008, 370, 1050, 14, 272, 520, 635, 3141, 7412, 26, 3000, 446, 3141, 1329, 402, 2974, 626, 911, 506, 3032, 14, 334, 2972, 367, 6696, 1700, 9, 339, 2508, 5317, 447, 267, 29095, 5548, 22477, 3269, 1806, 1808, 314, 4465, 1050, 6231, 2081, 1252, 267, 2047, 1443, 1240, 642, 1655, 2419, 5403, 370, 1050, 2974, 315, 8291, 14, 339, 5679, 447, 398, 340, 440, 11709, 2718, 14, 525, 6231, 7412, 8, 442, 8, 1274, 14, 3020, 59, 17, 2522, 3842, 633, 12, 769, 1053, 12, 756, 12, 19532, 288, 746, 272, 408, 272, 372, 2155, 8, 17, 9, 421, 199, 318, 1284, 3466, 6231, 8, 2479, 12, 19268, 29, 549, 12, 1678, 26138, 29, 797, 12, 2581, 1378, 18230, 29, 549, 304, 272, 408, 2806, 805, 370, 11480, 1323, 28994, 626, 314, 1284, 402, 314, 2082, 13778, 315, 282, 5791, 4718, 7850, 859, 365, 13075, 14, 339, 520, 635, 2429, 26, 3000, 446, 2429, 314, 3589, 1990, 8239, 543, 14, 272, 520, 635, 19268, 26, 2155, 446, 715, 29, 1579, 9709, 8792, 15, 797, 29, 5229, 8103, 440, 14, 272, 520, 635, 1678, 26138, 26, 2155, 446, 715, 29, 3749, 4922, 1077, 1678, 314, 1453, 13778, 15, 797, 29, 7850, 365, 282, 1007, 3741, 14, 272, 520, 635, 2581, 1378, 18230, 26, 2155, 446, 715, 29, 7850, 911, 2581, 340, 9243, 900, 15, 797, 29, 3749, 4922, 911, 7078, 2581, 370, 4339, 14, 339, 5679, 447, 398, 11709, 2718, 14, 500, 3466, 6231, 8, 442, 8, 1274, 14, 3020, 59, 17, 2522, 2581, 1378, 18230, 29, 797 ]
[ 2803, 26, 2774, 13, 24, 199, 624, 199, 13967, 367, 1804, 79, 328, 8963, 199, 624, 199, 199, 23447, 63, 9977, 63, 748, 34, 2639, 275, 4944, 199, 23447, 63, 9977, 63, 748, 34, 2639, 63, 11209, 63, 18061, 275, 4329, 199, 23447, 63, 9977, 63, 2294, 6225, 275, 4119, 199, 23447, 63, 9977, 63, 2294, 6225, 63, 11209, 63, 18061, 275, 3144, 199, 23447, 63, 9977, 63, 11970, 16553, 275, 6335, 199, 23447, 63, 9977, 63, 14833, 275, 10448, 199, 23447, 63, 9977, 63, 30263, 275, 3193, 199, 23447, 63, 9977, 63, 5390, 275, 650, 199, 23447, 63, 9977, 63, 5390, 1554, 8280, 275, 5851, 199, 23447, 63, 9977, 63, 5390, 63, 6166, 6945, 275, 13385, 199, 23447, 63, 9977, 63, 4564, 5399, 63, 2711, 275, 1227, 199, 23447, 63, 9977, 63, 36, 15301, 275, 1695, 199, 23447, 63, 9977, 63, 6102, 7336, 1093, 275, 6928, 199, 23447, 63, 9977, 63, 3817, 275, 959, 199, 23447, 63, 9977, 63, 14742, 3243, 275, 4337, 199, 23447, 63, 9977, 63, 9289, 907, 275, 4114, 199, 23447, 63, 9977, 63, 13837, 275, 413, 199, 23447, 63, 9977, 63, 13837, 63, 11209, 63, 38, 5104, 3960, 275, 9404, 199, 23447, 63, 9977, 63, 13837, 63, 11209, 63, 18061, 275, 499, 199, 23447, 63, 9977, 63, 16901, 11625, 1149, 275, 8177, 199, 23447, 63, 9977, 63, 4924, 742, 3960, 275, 8780, 199, 23447, 63, 9977, 63, 1658, 2276, 63, 21047, 1206, 275, 7294, 199, 23447, 63, 9977, 63, 9185, 275, 378, 199, 23447, 63, 9977, 63, 11625, 8760, 275, 8685, 199, 23447, 63, 9977, 63, 11625, 4924, 63, 12125, 275, 7829, 199, 23447, 63, 9977, 63, 2514, 4980, 5430, 6012, 275, 7875, 199, 23447, 63, 9977, 63, 15605, 63, 8760, 275, 3388, 199, 23447, 63, 9977, 63, 4305, 275, 841, 199, 23447, 63, 9977, 63, 3377, 39, 63, 21047, 1206, 275, 8087, 199, 23447, 63, 9977, 63, 840, 53, 19283, 275, 4233, 199, 23447, 63, 9977, 63, 840, 53, 19283, 63, 11209, 63, 18061, 275, 7105, 199, 23447, 63, 9977, 63, 19091, 275, 1749, 199, 23447, 63, 9977, 63, 19091, 63, 11209, 63, 18061, 275, 1616, 199, 23447, 63, 9977, 63, 19755, 7125, 275, 1520, 199, 23447, 63, 9977, 63, 1734, 23447, 1149, 275, 6877, 199, 23447, 63, 9977, 63, 20142, 63, 21047, 1206, 275, 6155, 199, 23447, 63, 9977, 63, 20142, 63, 9390, 4961, 275, 7349, 199, 23447, 63, 9977, 63, 20142, 63, 23447, 63, 19091, 275, 5504, 199, 23447, 63, 9977, 63, 20142, 63, 23447, 63, 19091, 63, 11209, 63, 18061, 275, 5661, 199, 23447, 63, 9977, 63, 20142, 63, 19091, 275, 6546, 199, 23447, 63, 9977, 63, 20142, 63, 19216, 275, 5557, 199, 363, 2502, 363, 275, 283, 13126, 1804, 79, 328, 665, 1014, 921, 7697, 328, 14, 6993, 3524, 199, 363, 22461, 363, 275, 283, 13126, 1804, 79, 328, 7, 199, 363, 602, 363, 275, 283, 22533, 10162, 17163, 3193, 26, 1081, 26, 1167, 699, 840, 6900, 7, 199, 363, 3246, 363, 275, 283, 1761, 7, 199, 363, 1023, 363, 275, 283, 18, 14, 1165, 14, 16, 7, 421, 199, 318, 1050, 6231, 2081, 8, 2479, 12, 1166, 12, 769, 1053, 12, 365, 7850, 29, 797, 12, 3141, 7412, 29, 16, 304, 272, 408, 2806, 805, 370, 986, 2082, 4072, 1771, 370, 1323, 28994, 14, 339, 1803, 282, 2155, 367, 9512, 13659, 14, 339, 520, 635, 2429, 26, 3000, 446, 2429, 314, 3589, 1990, 8239, 543, 14, 272, 520, 635, 1166, 26, 1059, 446, 1166, 402, 314, 2397, 14, 3955, 506, 3589, 921, 367, 4573, 5791, 2082, 14, 272, 520, 635, 769, 1053, 26, 3820, 2081, 446, 1242, 370, 1050, 14, 272, 520, 635, 365, 7850, 26, 2155, 446, 715, 29, 3741, 1182, 756, 29, 1397, 282, 4922, 14, 272, 520, 635, 3141, 7412, 26, 3000, 446, 3141, 1329, 402, 2974, 626, 911, 506, 3032, 14, 334, 2972, 367, 6696, 1700, 9, 339, 5679, 447, 398, 340, 440, 11709, 2718, 14, 525, 6231, 2081, 8, 442, 8, 1274, 14, 3020, 59, 17, 2522, 283, 38, 18589, 2437, 441, 2393, 1103, 5863, 14, 14469, 297, 769, 1053, 12, 3141, 7412, 29, 1400, 304, 288, 2059, 272, 408, 272, 372, 2155, 8, 17, 9, 421, 199, 318, 1050, 6231, 7412, 8, 2479, 12, 2974, 12, 3141, 7412, 29, 16, 304, 272, 408, 2806, 805, 370, 986, 2082, 4072, 1771, 370, 1323, 28994, 465, 282, 769, 14, 339, 1803, 282, 2155, 367, 9512, 13659, 14, 339, 520, 635, 2429, 26, 3000, 446, 2429, 314, 3589, 1990, 8239, 543, 14, 272, 520, 635, 2974, 26, 3820, 446, 769, 402, 334, 633, 12, 769, 1053, 14675, 365, 7850, 566, 465, 282, 2008, 370, 1050, 14, 272, 520, 635, 3141, 7412, 26, 3000, 446, 3141, 1329, 402, 2974, 626, 911, 506, 3032, 14, 334, 2972, 367, 6696, 1700, 9, 339, 2508, 5317, 447, 267, 29095, 5548, 22477, 3269, 1806, 1808, 314, 4465, 1050, 6231, 2081, 1252, 267, 2047, 1443, 1240, 642, 1655, 2419, 5403, 370, 1050, 2974, 315, 8291, 14, 339, 5679, 447, 398, 340, 440, 11709, 2718, 14, 525, 6231, 7412, 8, 442, 8, 1274, 14, 3020, 59, 17, 2522, 3842, 633, 12, 769, 1053, 12, 756, 12, 19532, 288, 746, 272, 408, 272, 372, 2155, 8, 17, 9, 421, 199, 318, 1284, 3466, 6231, 8, 2479, 12, 19268, 29, 549, 12, 1678, 26138, 29, 797, 12, 2581, 1378, 18230, 29, 549, 304, 272, 408, 2806, 805, 370, 11480, 1323, 28994, 626, 314, 1284, 402, 314, 2082, 13778, 315, 282, 5791, 4718, 7850, 859, 365, 13075, 14, 339, 520, 635, 2429, 26, 3000, 446, 2429, 314, 3589, 1990, 8239, 543, 14, 272, 520, 635, 19268, 26, 2155, 446, 715, 29, 1579, 9709, 8792, 15, 797, 29, 5229, 8103, 440, 14, 272, 520, 635, 1678, 26138, 26, 2155, 446, 715, 29, 3749, 4922, 1077, 1678, 314, 1453, 13778, 15, 797, 29, 7850, 365, 282, 1007, 3741, 14, 272, 520, 635, 2581, 1378, 18230, 26, 2155, 446, 715, 29, 7850, 911, 2581, 340, 9243, 900, 15, 797, 29, 3749, 4922, 911, 7078, 2581, 370, 4339, 14, 339, 5679, 447, 398, 11709, 2718, 14, 500, 3466, 6231, 8, 442, 8, 1274, 14, 3020, 59, 17, 2522, 2581, 1378, 18230, 29, 797, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
breznak/nupic
examples/opf/experiments/multistep/hotgym_best_tp_16K/description.py
32
2789
# ---------------------------------------------------------------------- # Numenta Platform for Intelligent Computing (NuPIC) # Copyright (C) 2013, Numenta, Inc. Unless you have an agreement # with Numenta, Inc., for a separate license for this software code, the # following terms and conditions apply: # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU Affero Public License for more details. # # You should have received a copy of the GNU Affero Public License # along with this program. If not, see http://www.gnu.org/licenses. # # http://numenta.org/licenses/ # ---------------------------------------------------------------------- ## This file defines parameters for a prediction experiment. import os from nupic.frameworks.opf.expdescriptionhelpers import importBaseDescription # the sub-experiment configuration config = \ { 'modelParams': { 'clParams': { 'clVerbosity': 0}, 'sensorParams': { 'encoders': { 'consumption': { 'clipInput': True, 'fieldname': u'consumption', 'n': 28, 'name': u'consumption', 'type': 'AdaptiveScalarEncoder', 'w': 21}, 'timestamp_dayOfWeek': None, 'timestamp_timeOfDay': { 'fieldname': u'timestamp', 'name': u'timestamp_timeOfDay', 'timeOfDay': ( 21, 8), 'type': 'DateEncoder'}, 'timestamp_weekend': None}, 'verbosity': 0}, 'spParams': { }, 'tpParams': { 'activationThreshold': 14, 'minThreshold': 12, 'verbosity': 0}}, 'numRecords': 16000} mod = importBaseDescription('../hotgym/description.py', config) locals().update(mod.__dict__)
agpl-3.0
[ 3, 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6171, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 4265, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 309, 961, 570, 7890, 2633, 367, 282, 12044, 11805, 14, 199, 199, 646, 747, 199, 504, 26084, 14, 32037, 14, 16893, 14, 1474, 1802, 7546, 492, 492, 1563, 5831, 199, 199, 3, 314, 1007, 13, 10873, 2897, 199, 888, 275, 971, 199, 91, 283, 1238, 6007, 356, 469, 283, 429, 6007, 356, 469, 283, 429, 3673, 5947, 356, 378, 1386, 673, 283, 8956, 6007, 356, 469, 283, 9347, 83, 356, 469, 283, 8704, 15052, 356, 469, 283, 7548, 3205, 356, 715, 12, 25405, 283, 13646, 356, 399, 7, 8704, 15052, 297, 25405, 283, 78, 356, 7294, 12, 25405, 283, 354, 356, 399, 7, 8704, 15052, 297, 25405, 283, 466, 356, 283, 2767, 22430, 13090, 6679, 297, 25405, 283, 87, 356, 7829, 1386, 8962, 283, 3954, 63, 2977, 3466, 20995, 356, 488, 12, 8962, 283, 3954, 63, 521, 3466, 12631, 356, 469, 283, 13646, 356, 399, 1133, 1036, 2359, 297, 6684, 3322, 283, 354, 356, 399, 1133, 1036, 2359, 63, 521, 3466, 12631, 297, 6684, 3322, 283, 521, 3466, 12631, 356, 334, 7829, 12, 12268, 3698, 1695, 395, 6684, 3322, 283, 466, 356, 283, 2506, 6679, 2267, 8962, 283, 3954, 63, 6419, 500, 356, 488, 1386, 3660, 283, 9833, 356, 378, 1386, 673, 283, 681, 6007, 356, 469, 1660, 673, 283, 683, 6007, 356, 469, 283, 12312, 12109, 356, 4329, 12, 639, 283, 827, 12109, 356, 3144, 12, 639, 283, 9833, 356, 378, 13459, 523, 283, 1507, 14941, 356, 3193, 1493, 93, 199, 199, 1494, 275, 492, 1563, 5831, 24592, 8885, 4312, 77, 15, 1802, 14, 647, 297, 1101, 9, 199, 9350, 1252, 873, 8, 1494, 855, 807, 3368, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 20359, 199, 3, 22783, 16078, 367, 8883, 24024, 27799, 334, 21988, 26769, 9, 199, 3, 1898, 334, 35, 9, 6171, 12, 22783, 12, 3277, 14, 221, 4158, 1265, 1172, 376, 25025, 199, 3, 543, 22783, 12, 3277, 2020, 367, 282, 7396, 4190, 367, 642, 2032, 1233, 12, 314, 199, 3, 2569, 2895, 436, 3704, 4838, 26, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1684, 844, 1015, 650, 465, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 199, 3, 1666, 314, 1664, 4265, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1684, 844, 199, 3, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 14, 199, 3, 199, 3, 1455, 921, 78, 18952, 14, 1308, 15, 2383, 15, 199, 3, 20359, 199, 199, 309, 961, 570, 7890, 2633, 367, 282, 12044, 11805, 14, 199, 199, 646, 747, 199, 504, 26084, 14, 32037, 14, 16893, 14, 1474, 1802, 7546, 492, 492, 1563, 5831, 199, 199, 3, 314, 1007, 13, 10873, 2897, 199, 888, 275, 971, 199, 91, 283, 1238, 6007, 356, 469, 283, 429, 6007, 356, 469, 283, 429, 3673, 5947, 356, 378, 1386, 673, 283, 8956, 6007, 356, 469, 283, 9347, 83, 356, 469, 283, 8704, 15052, 356, 469, 283, 7548, 3205, 356, 715, 12, 25405, 283, 13646, 356, 399, 7, 8704, 15052, 297, 25405, 283, 78, 356, 7294, 12, 25405, 283, 354, 356, 399, 7, 8704, 15052, 297, 25405, 283, 466, 356, 283, 2767, 22430, 13090, 6679, 297, 25405, 283, 87, 356, 7829, 1386, 8962, 283, 3954, 63, 2977, 3466, 20995, 356, 488, 12, 8962, 283, 3954, 63, 521, 3466, 12631, 356, 469, 283, 13646, 356, 399, 1133, 1036, 2359, 297, 6684, 3322, 283, 354, 356, 399, 1133, 1036, 2359, 63, 521, 3466, 12631, 297, 6684, 3322, 283, 521, 3466, 12631, 356, 334, 7829, 12, 12268, 3698, 1695, 395, 6684, 3322, 283, 466, 356, 283, 2506, 6679, 2267, 8962, 283, 3954, 63, 6419, 500, 356, 488, 1386, 3660, 283, 9833, 356, 378, 1386, 673, 283, 681, 6007, 356, 469, 1660, 673, 283, 683, 6007, 356, 469, 283, 12312, 12109, 356, 4329, 12, 639, 283, 827, 12109, 356, 3144, 12, 639, 283, 9833, 356, 378, 13459, 523, 283, 1507, 14941, 356, 3193, 1493, 93, 199, 199, 1494, 275, 492, 1563, 5831, 24592, 8885, 4312, 77, 15, 1802, 14, 647, 297, 1101, 9, 199, 9350, 1252, 873, 8, 1494, 855, 807, 3368, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
nextgis/NextGIS_QGIS_open
tests/src/python/test_qgspallabeling_server.py
6
7614
# -*- coding: utf-8 -*- """QGIS unit tests for QgsPalLabeling: label rendering output via QGIS Server From build dir, run: ctest -R PyQgsPalLabelingServer -V See <qgis-src-dir>/tests/testdata/labeling/README.rst for description. .. note:: This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. """ __author__ = 'Larry Shaffer' __date__ = '07/12/2013' __copyright__ = 'Copyright 2013, The QGIS Project' # This will get replaced with a git SHA1 when you do a git archive __revision__ = '$Format:%H$' import qgis import sys import os import glob import shutil from PyQt4.QtCore import QSettings, qDebug from qgis.core import QgsProject, QgsApplication, QgsPalLabeling from utilities import mapSettingsString from qgis_local_server import getLocalServer from test_qgspallabeling_base import TestQgsPalLabeling, runSuite from test_qgspallabeling_tests import ( TestPointBase, suiteTests ) MAPSERV = getLocalServer() class TestServerBase(TestQgsPalLabeling): _TestProj = None """:type: QgsProject""" _TestProjName = '' layer = None """:type: QgsVectorLayer""" params = dict() @classmethod def setUpClass(cls): if not cls._BaseSetup: TestQgsPalLabeling.setUpClass() MAPSERV.startup() MAPSERV.web_dir_install(glob.glob(cls._PalDataDir + os.sep + '*.qml')) # noinspection PyArgumentList cls._TestProj = QgsProject.instance() cls._TestProjName = 'pal_test.qgs' cls._TestProj.setFileName( os.path.join(MAPSERV.web_dir(), cls._TestProjName)) # the blue background (set via layer style) to match renderchecker's TestQgsPalLabeling.loadFeatureLayer('background', True) settings = QSettings() # noinspection PyArgumentList cls._CacheDir = settings.value( "cache/directory", os.path.join(unicode(QgsApplication.qgisSettingsDirPath()), "cache"), type=unicode) @classmethod def tearDownClass(cls): """Run after all tests""" TestQgsPalLabeling.tearDownClass() cls.removeMapLayer(cls.layer) cls.layer = None # layers removed, save empty project file cls._TestProj.write() if "PAL_SERVER_TEMP" in os.environ: MAPSERV.stop_processes() MAPSERV.open_temp_dir() else: MAPSERV.shutdown() def setUp(self): """Run before each test.""" # web server stays up across all tests # MAPSERV.fcgi_server_process().stop() # self.deleteCache() super(TestServerBase, self).setUp() self._TestImage = '' # ensure per test map settings stay encapsulated self._TestMapSettings = self.cloneMapSettings(self._MapSettings) self._Mismatch = 0 self._ColorTol = 0 self._Mismatches.clear() self._ColorTols.clear() # noinspection PyPep8Naming def delete_cache(self): for item in os.listdir(self._CacheDir): shutil.rmtree(os.path.join(self._CacheDir, item), ignore_errors=True) # noinspection PyPep8Naming def get_request_params(self): # TODO: support other types of servers, besides WMS ms = self._TestMapSettings osize = ms.outputSize() dpi = str(ms.outputDpi()) lyrs = [str(self._MapRegistry.mapLayer(i).name()) for i in ms.layers()] lyrs.reverse() params = { 'SERVICE': 'WMS', 'VERSION': '1.3.0', 'REQUEST': 'GetMap', 'MAP': self._TestProjName, # layer stacking order for rendering: bottom,to,top 'LAYERS': lyrs, # or 'name,name' 'STYLES': ',', # authid str or QgsCoordinateReferenceSystem obj 'CRS': str(ms.destinationCrs().authid()), # self.aoiExtent(), 'BBOX': str(ms.extent().toString(True).replace(' : ', ',')), 'FORMAT': 'image/png', # or: 'image/png; mode=8bit' 'WIDTH': str(osize.width()), 'HEIGHT': str(osize.height()), 'DPI': dpi, 'MAP_RESOLUTION': dpi, 'FORMAT_OPTIONS': 'dpi:{0}'.format(dpi), 'TRANSPARENT': 'FALSE', 'IgnoreGetMapUrl': '1' } # print params return params def sync_map_settings(self): """ Sync custom test QgsMapSettings to Project file """ pal = QgsPalLabeling() pal.loadEngineSettings() pal.init(self._TestMapSettings) pal.saveEngineSettings() def checkTest(self, **kwargs): self.sync_map_settings() self.lyr.writeToLayer(self.layer) # save project file self._TestProj.write() # always restart FCGI before tests, so settings can be applied # MAPSERV.fcgi_server_process().start() # get server results # print self.params.__repr__() ms = self._MapSettings # class settings settings_type = 'Class' if self._TestMapSettings is not None: ms = self._TestMapSettings # per test settings settings_type = 'Test' if 'PAL_VERBOSE' in os.environ: qDebug('MapSettings type: {0}'.format(settings_type)) qDebug(mapSettingsString(ms)) res_m, self._TestImage, url = MAPSERV.get_map(self.get_request_params(), False) # print self._TestImage.__repr__() if 'PAL_VERBOSE' in os.environ: qDebug('GetMap request:\n {0}\n'.format(url)) self.saveControlImage(self._TestImage) self.assertTrue(res_m, 'Failed to retrieve/save image from test server') mismatch = 0 if 'PAL_NO_MISMATCH' not in os.environ: # some mismatch expected mismatch = self._Mismatch if self._Mismatch else 20 if self._TestGroup in self._Mismatches: mismatch = self._Mismatches[self._TestGroup] colortol = 0 if 'PAL_NO_COLORTOL' not in os.environ: # some mismatch expected # colortol = self._ColorTol if self._ColorTol else 10 if self._TestGroup in self._ColorTols: colortol = self._ColorTols[self._TestGroup] self.assertTrue(*self.renderCheck(mismatch=mismatch, colortol=colortol, imgpath=self._TestImage)) class TestServerBasePoint(TestServerBase): @classmethod def setUpClass(cls): TestServerBase.setUpClass() cls.layer = TestQgsPalLabeling.loadFeatureLayer('point') class TestServerPoint(TestServerBasePoint, TestPointBase): def setUp(self): super(TestServerPoint, self).setUp() self.configTest('pal_server', 'sp') class TestServerVsCanvasPoint(TestServerBasePoint, TestPointBase): def setUp(self): super(TestServerVsCanvasPoint, self).setUp() self.configTest('pal_canvas', 'sp') if __name__ == '__main__': # NOTE: unless PAL_SUITE env var is set all test class methods will be run # SEE: test_qgspallabeling_tests.suiteTests() to define suite suite = ( ['TestServerPoint.' + t for t in suiteTests()['sp_suite']] + ['TestServerVsCanvasPoint.' + t for t in suiteTests()['sp_vs_suite']] ) res = runSuite(sys.modules[__name__], suite) sys.exit(not res.wasSuccessful())
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 31329, 4137, 2295, 367, 4888, 24666, 4314, 316, 26, 1768, 14066, 1072, 4799, 27024, 7146, 199, 199, 2532, 1900, 2935, 12, 1255, 26, 286, 396, 446, 50, 1611, 7350, 24666, 4314, 316, 3120, 446, 54, 199, 199, 9295, 665, 25325, 13, 2164, 13, 694, 12202, 2219, 15, 18481, 15, 1302, 316, 15, 18195, 14, 8332, 367, 1369, 14, 199, 199, 703, 5317, 447, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 44, 285, 651, 428, 2411, 1260, 7, 199, 363, 602, 363, 275, 283, 1780, 15, 713, 15, 6965, 7, 199, 363, 7307, 363, 275, 283, 7384, 6171, 12, 710, 27024, 7290, 7, 199, 3, 961, 911, 664, 8717, 543, 282, 6135, 12002, 17, 1380, 1265, 886, 282, 6135, 6359, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 199, 199, 646, 15640, 199, 646, 984, 199, 646, 747, 199, 646, 5739, 199, 646, 5145, 199, 199, 504, 14084, 20, 14, 10901, 492, 1413, 5268, 12, 1894, 7084, 199, 199, 504, 15640, 14, 1018, 492, 4888, 4761, 12, 4888, 5039, 12, 4888, 24666, 4314, 316, 199, 199, 504, 15841, 492, 2341, 5268, 1558, 199, 199, 504, 15640, 63, 1832, 63, 1000, 492, 664, 5339, 3120, 199, 199, 504, 511, 63, 81, 458, 80, 452, 902, 316, 63, 1095, 492, 1379, 7350, 24666, 4314, 316, 12, 1255, 6207, 199, 504, 511, 63, 81, 458, 80, 452, 902, 316, 63, 2219, 492, 334, 272, 1379, 3428, 1563, 12, 272, 5241, 2925, 199, 9, 199, 199, 5443, 3279, 54, 275, 664, 5339, 3120, 342, 421, 199, 533, 1379, 3120, 1563, 8, 774, 7350, 24666, 4314, 316, 304, 339, 485, 774, 23657, 275, 488, 272, 408, 26, 466, 26, 4888, 4761, 624, 272, 485, 774, 23657, 985, 275, 2125, 272, 4045, 275, 488, 272, 408, 26, 466, 26, 22507, 624, 272, 1862, 275, 1211, 342, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 340, 440, 843, 423, 1563, 8555, 26, 288, 1379, 7350, 24666, 4314, 316, 14, 27777, 342, 267, 603, 1282, 3279, 54, 14, 16480, 342, 267, 603, 1282, 3279, 54, 14, 2520, 63, 694, 63, 3174, 8, 6463, 14, 6463, 8, 1886, 423, 24666, 1451, 3567, 435, 747, 14, 4127, 435, 11937, 81, 757, 1333, 398, 327, 30870, 1611, 5201, 1296, 267, 843, 423, 774, 23657, 275, 4888, 4761, 14, 842, 342, 267, 843, 423, 774, 23657, 985, 275, 283, 21516, 63, 396, 14, 81, 458, 7, 267, 843, 423, 774, 23657, 14, 409, 7733, 8, 288, 747, 14, 515, 14, 904, 8, 5443, 3279, 54, 14, 2520, 63, 694, 1062, 843, 423, 774, 23657, 985, 430, 398, 327, 314, 10030, 8020, 334, 409, 4799, 4045, 3449, 9, 370, 1336, 3795, 6743, 1159, 267, 1379, 7350, 24666, 4314, 316, 14, 912, 5968, 5003, 360, 7451, 297, 715, 9, 398, 2202, 275, 1413, 5268, 342, 267, 327, 30870, 1611, 5201, 1296, 267, 843, 423, 4437, 3567, 275, 2202, 14, 585, 8, 288, 298, 1637, 15, 3619, 401, 288, 747, 14, 515, 14, 904, 8, 2975, 8, 7350, 5039, 14, 25325, 5268, 3567, 2042, 4000, 586, 298, 1637, 1288, 288, 730, 29, 2975, 9, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 408, 2540, 2410, 1006, 2295, 624, 267, 1379, 7350, 24666, 4314, 316, 14, 12336, 2543, 342, 267, 843, 14, 2168, 2956, 5003, 8, 1886, 14, 1897, 9, 267, 843, 14, 1897, 275, 488, 267, 327, 9393, 4829, 12, 3354, 2701, 2199, 570, 267, 843, 423, 774, 23657, 14, 952, 342, 267, 340, 298, 20990, 63, 6613, 63, 12510, 2, 315, 747, 14, 2314, 26, 288, 603, 1282, 3279, 54, 14, 2379, 63, 11816, 342, 288, 603, 1282, 3279, 54, 14, 1490, 63, 808, 63, 694, 342, 267, 587, 26, 288, 603, 1282, 3279, 54, 14, 8831, 342, 339, 347, 3613, 8, 277, 304, 267, 408, 2540, 2544, 1924, 511, 1041, 267, 327, 3330, 1654, 2612, 588, 1536, 9371, 1006, 2295, 267, 327, 603, 1282, 3279, 54, 14, 30076, 63, 1000, 63, 1412, 1252, 2379, 342, 267, 327, 291, 14, 1807, 4437, 342, 267, 1613, 8, 774, 3120, 1563, 12, 291, 680, 5996, 342, 267, 291, 423, 774, 3491, 275, 2125, 267, 327, 4868, 1126, 511, 2341, 2202, 25578, 22667, 8097, 267, 291, 423, 774, 2956, 5268, 275, 291, 14, 6311, 2956, 5268, 8, 277, 423, 2956, 5268, 9, 267, 291, 423, 23055, 275, 378, 267, 291, 423, 4117, 52, 393, 275, 378, 267, 291, 423, 5829, 6742, 14, 3584, 342, 267, 291, 423, 4117, 52, 1446, 14, 3584, 342, 339, 327, 30870, 1611, 48, 1545, 24, 46, 9568, 272, 347, 3145, 63, 1637, 8, 277, 304, 267, 367, 1242, 315, 747, 14, 7374, 8, 277, 423, 4437, 3567, 304, 288, 5145, 14, 9242, 8, 736, 14, 515, 14, 904, 8, 277, 423, 4437, 3567, 12, 1242, 395, 2079, 3686, 63, 2550, 29, 549, 9, 339, 327, 30870, 1611, 48, 1545, 24, 46, 9568, 272, 347, 664, 63, 1069, 63, 1162, 8, 277, 304, 267, 327, 3254, 26, 2291, 1163, 2943, 402, 8037, 12, 506, 19564, 644, 3053, 267, 6605, 275, 291, 423, 774, 2956, 5268, 267, 312, 890, 275, 6605, 14, 1199, 2320, 342, 267, 26910, 275, 620, 8, 706, 14, 1199, 36, 1038, 1012, 267, 21559, 2393, 275, 359, 495, 8, 277, 423, 2956, 10899, 14, 1130, 5003, 8, 73, 680, 354, 1012, 367, 284, 315, 6605, 14, 4359, 5106, 267, 21559, 2393, 14, 4471, 342, 267, 1862, 275, 469, 288, 283, 10486, 356, 283, 55, 3053, 297, 288, 283, 4612, 356, 283, 17, 14, 19, 14, 16, 297, 288, 283, 6780, 356, 283, 1002, 2956, 297, 288, 283, 5443, 356, 291, 423, 774, 23657, 985, 12, 288, 327, 4045, 3464, 316, 1865, 367, 14066, 26, 9048, 12, 475, 12, 2119, 288, 283, 16897, 3960, 356, 21559, 2393, 12, 221, 327, 503, 283, 354, 12, 354, 7 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 31329, 4137, 2295, 367, 4888, 24666, 4314, 316, 26, 1768, 14066, 1072, 4799, 27024, 7146, 199, 199, 2532, 1900, 2935, 12, 1255, 26, 286, 396, 446, 50, 1611, 7350, 24666, 4314, 316, 3120, 446, 54, 199, 199, 9295, 665, 25325, 13, 2164, 13, 694, 12202, 2219, 15, 18481, 15, 1302, 316, 15, 18195, 14, 8332, 367, 1369, 14, 199, 199, 703, 5317, 447, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 44, 285, 651, 428, 2411, 1260, 7, 199, 363, 602, 363, 275, 283, 1780, 15, 713, 15, 6965, 7, 199, 363, 7307, 363, 275, 283, 7384, 6171, 12, 710, 27024, 7290, 7, 199, 3, 961, 911, 664, 8717, 543, 282, 6135, 12002, 17, 1380, 1265, 886, 282, 6135, 6359, 199, 363, 5792, 363, 275, 4505, 3484, 2689, 40, 12913, 199, 199, 646, 15640, 199, 646, 984, 199, 646, 747, 199, 646, 5739, 199, 646, 5145, 199, 199, 504, 14084, 20, 14, 10901, 492, 1413, 5268, 12, 1894, 7084, 199, 199, 504, 15640, 14, 1018, 492, 4888, 4761, 12, 4888, 5039, 12, 4888, 24666, 4314, 316, 199, 199, 504, 15841, 492, 2341, 5268, 1558, 199, 199, 504, 15640, 63, 1832, 63, 1000, 492, 664, 5339, 3120, 199, 199, 504, 511, 63, 81, 458, 80, 452, 902, 316, 63, 1095, 492, 1379, 7350, 24666, 4314, 316, 12, 1255, 6207, 199, 504, 511, 63, 81, 458, 80, 452, 902, 316, 63, 2219, 492, 334, 272, 1379, 3428, 1563, 12, 272, 5241, 2925, 199, 9, 199, 199, 5443, 3279, 54, 275, 664, 5339, 3120, 342, 421, 199, 533, 1379, 3120, 1563, 8, 774, 7350, 24666, 4314, 316, 304, 339, 485, 774, 23657, 275, 488, 272, 408, 26, 466, 26, 4888, 4761, 624, 272, 485, 774, 23657, 985, 275, 2125, 272, 4045, 275, 488, 272, 408, 26, 466, 26, 22507, 624, 272, 1862, 275, 1211, 342, 339, 768, 3744, 272, 347, 18561, 8, 1886, 304, 267, 340, 440, 843, 423, 1563, 8555, 26, 288, 1379, 7350, 24666, 4314, 316, 14, 27777, 342, 267, 603, 1282, 3279, 54, 14, 16480, 342, 267, 603, 1282, 3279, 54, 14, 2520, 63, 694, 63, 3174, 8, 6463, 14, 6463, 8, 1886, 423, 24666, 1451, 3567, 435, 747, 14, 4127, 435, 11937, 81, 757, 1333, 398, 327, 30870, 1611, 5201, 1296, 267, 843, 423, 774, 23657, 275, 4888, 4761, 14, 842, 342, 267, 843, 423, 774, 23657, 985, 275, 283, 21516, 63, 396, 14, 81, 458, 7, 267, 843, 423, 774, 23657, 14, 409, 7733, 8, 288, 747, 14, 515, 14, 904, 8, 5443, 3279, 54, 14, 2520, 63, 694, 1062, 843, 423, 774, 23657, 985, 430, 398, 327, 314, 10030, 8020, 334, 409, 4799, 4045, 3449, 9, 370, 1336, 3795, 6743, 1159, 267, 1379, 7350, 24666, 4314, 316, 14, 912, 5968, 5003, 360, 7451, 297, 715, 9, 398, 2202, 275, 1413, 5268, 342, 267, 327, 30870, 1611, 5201, 1296, 267, 843, 423, 4437, 3567, 275, 2202, 14, 585, 8, 288, 298, 1637, 15, 3619, 401, 288, 747, 14, 515, 14, 904, 8, 2975, 8, 7350, 5039, 14, 25325, 5268, 3567, 2042, 4000, 586, 298, 1637, 1288, 288, 730, 29, 2975, 9, 339, 768, 3744, 272, 347, 24468, 8, 1886, 304, 267, 408, 2540, 2410, 1006, 2295, 624, 267, 1379, 7350, 24666, 4314, 316, 14, 12336, 2543, 342, 267, 843, 14, 2168, 2956, 5003, 8, 1886, 14, 1897, 9, 267, 843, 14, 1897, 275, 488, 267, 327, 9393, 4829, 12, 3354, 2701, 2199, 570, 267, 843, 423, 774, 23657, 14, 952, 342, 267, 340, 298, 20990, 63, 6613, 63, 12510, 2, 315, 747, 14, 2314, 26, 288, 603, 1282, 3279, 54, 14, 2379, 63, 11816, 342, 288, 603, 1282, 3279, 54, 14, 1490, 63, 808, 63, 694, 342, 267, 587, 26, 288, 603, 1282, 3279, 54, 14, 8831, 342, 339, 347, 3613, 8, 277, 304, 267, 408, 2540, 2544, 1924, 511, 1041, 267, 327, 3330, 1654, 2612, 588, 1536, 9371, 1006, 2295, 267, 327, 603, 1282, 3279, 54, 14, 30076, 63, 1000, 63, 1412, 1252, 2379, 342, 267, 327, 291, 14, 1807, 4437, 342, 267, 1613, 8, 774, 3120, 1563, 12, 291, 680, 5996, 342, 267, 291, 423, 774, 3491, 275, 2125, 267, 327, 4868, 1126, 511, 2341, 2202, 25578, 22667, 8097, 267, 291, 423, 774, 2956, 5268, 275, 291, 14, 6311, 2956, 5268, 8, 277, 423, 2956, 5268, 9, 267, 291, 423, 23055, 275, 378, 267, 291, 423, 4117, 52, 393, 275, 378, 267, 291, 423, 5829, 6742, 14, 3584, 342, 267, 291, 423, 4117, 52, 1446, 14, 3584, 342, 339, 327, 30870, 1611, 48, 1545, 24, 46, 9568, 272, 347, 3145, 63, 1637, 8, 277, 304, 267, 367, 1242, 315, 747, 14, 7374, 8, 277, 423, 4437, 3567, 304, 288, 5145, 14, 9242, 8, 736, 14, 515, 14, 904, 8, 277, 423, 4437, 3567, 12, 1242, 395, 2079, 3686, 63, 2550, 29, 549, 9, 339, 327, 30870, 1611, 48, 1545, 24, 46, 9568, 272, 347, 664, 63, 1069, 63, 1162, 8, 277, 304, 267, 327, 3254, 26, 2291, 1163, 2943, 402, 8037, 12, 506, 19564, 644, 3053, 267, 6605, 275, 291, 423, 774, 2956, 5268, 267, 312, 890, 275, 6605, 14, 1199, 2320, 342, 267, 26910, 275, 620, 8, 706, 14, 1199, 36, 1038, 1012, 267, 21559, 2393, 275, 359, 495, 8, 277, 423, 2956, 10899, 14, 1130, 5003, 8, 73, 680, 354, 1012, 367, 284, 315, 6605, 14, 4359, 5106, 267, 21559, 2393, 14, 4471, 342, 267, 1862, 275, 469, 288, 283, 10486, 356, 283, 55, 3053, 297, 288, 283, 4612, 356, 283, 17, 14, 19, 14, 16, 297, 288, 283, 6780, 356, 283, 1002, 2956, 297, 288, 283, 5443, 356, 291, 423, 774, 23657, 985, 12, 288, 327, 4045, 3464, 316, 1865, 367, 14066, 26, 9048, 12, 475, 12, 2119, 288, 283, 16897, 3960, 356, 21559, 2393, 12, 221, 327, 503, 283, 354, 12, 354, 7, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
TathagataChakraborti/resource-conflicts
PLANROB-2015/seq-sat-lama/Python-2.5.2/Tools/bgen/bgen/bgenHeapBuffer.py
44
4201
# Buffers allocated on the heap from bgenOutput import * from bgenType import OutputOnlyMixIn from bgenBuffer import FixedInputOutputBufferType class HeapInputOutputBufferType(FixedInputOutputBufferType): """Input-output buffer allocated on the heap -- passed as (inbuffer, outbuffer, size). Instantiate without parameters. Call from Python with input buffer. """ def __init__(self, datatype = 'char', sizetype = 'int', sizeformat = None): FixedInputOutputBufferType.__init__(self, "0", datatype, sizetype, sizeformat) def getOutputBufferDeclarations(self, name, constmode=False, outmode=False): if constmode: raise RuntimeError, "Cannot use const output buffer" if outmode: out = "*" else: out = "" return ["%s%s *%s__out__" % (self.datatype, out, name)] def getargsCheck(self, name): Output("if ((%s__out__ = malloc(%s__in_len__)) == NULL)", name, name) OutLbrace() Output('PyErr_NoMemory();') Output("goto %s__error__;", name) self.label_needed = 1 OutRbrace() Output("%s__len__ = %s__in_len__;", name, name) def passOutput(self, name): return "%s__in__, %s__out__, (%s)%s__len__" % \ (name, name, self.sizetype, name) def mkvalueArgs(self, name): return "%s__out__, (int)%s__len__" % (name, name) def cleanup(self, name): Output("free(%s__out__);", name) FixedInputOutputBufferType.cleanup(self, name) class VarHeapInputOutputBufferType(HeapInputOutputBufferType): """same as base class, but passed as (inbuffer, outbuffer, &size)""" def passOutput(self, name): return "%s__in__, %s__out__, &%s__len__" % (name, name, name) class HeapCombinedInputOutputBufferType(HeapInputOutputBufferType): """same as base class, but passed as (inoutbuffer, size)""" def passOutput(self, name): return "(%s *)memcpy(%s__out__, %s__in__, %s__len__)" % \ (self.datatype, name, name, name) class VarHeapCombinedInputOutputBufferType(HeapInputOutputBufferType): """same as base class, but passed as (inoutbuffer, &size)""" def passOutput(self, name): return "(%s *)memcpy(%s__out__, %s__in__, &%s__len__)" % \ (self.datatype, name, name, name) class HeapOutputBufferType(OutputOnlyMixIn, HeapInputOutputBufferType): """Output buffer allocated on the heap -- passed as (buffer, size). Instantiate without parameters. Call from Python with buffer size. """ def getInputBufferDeclarations(self, name, constmode=False): return [] def getargsFormat(self): return "i" def getargsArgs(self, name): return "&%s__in_len__" % name def passOutput(self, name): return "%s__out__, %s__len__" % (name, name) class VarHeapOutputBufferType(HeapOutputBufferType): """Output buffer allocated on the heap -- passed as (buffer, &size). Instantiate without parameters. Call from Python with buffer size. """ def passOutput(self, name): return "%s__out__, &%s__len__" % (name, name) class VarVarHeapOutputBufferType(VarHeapOutputBufferType): """Output buffer allocated on the heap -- passed as (buffer, size, &size). Instantiate without parameters. Call from Python with buffer size. """ def passOutput(self, name): return "%s__out__, %s__len__, &%s__len__" % (name, name, name) class MallocHeapOutputBufferType(HeapOutputBufferType): """Output buffer allocated by the called function -- passed as (&buffer, &size). Instantiate without parameters. Call from Python without parameters. """ def getargsCheck(self, name): Output("%s__out__ = NULL;", name) def getAuxDeclarations(self, name): return [] def passOutput(self, name): return "&%s__out__, &%s__len__" % (name, name) def getargsFormat(self): return "" def getargsArgs(self, name): return None def mkvalueFormat(self): return "z#" def cleanup(self, name): Output("if( %s__out__ ) free(%s__out__);", name, name)
mit
[ 3, 699, 3043, 1192, 17659, 641, 314, 13295, 199, 199, 504, 330, 2268, 2959, 492, 627, 199, 504, 330, 2268, 804, 492, 7242, 5903, 26527, 199, 504, 330, 2268, 3299, 492, 18659, 3205, 2959, 3299, 804, 421, 199, 533, 5311, 439, 3205, 2959, 3299, 804, 8, 9515, 3205, 2959, 3299, 804, 304, 339, 408, 3205, 13, 1199, 3335, 17659, 641, 314, 13295, 1553, 3032, 465, 334, 262, 2738, 12, 734, 2738, 12, 1568, 680, 339, 32092, 1928, 2633, 14, 272, 6523, 687, 2018, 543, 1324, 3335, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 16048, 275, 283, 1560, 297, 1568, 466, 275, 283, 442, 297, 1568, 908, 275, 488, 304, 267, 18659, 3205, 2959, 3299, 804, 855, 826, 721, 277, 12, 298, 16, 401, 16048, 12, 1568, 466, 12, 1568, 908, 9, 339, 347, 664, 2959, 3299, 31963, 1298, 8, 277, 12, 536, 12, 950, 632, 29, 797, 12, 734, 632, 29, 797, 304, 267, 340, 950, 632, 26, 288, 746, 6064, 12, 298, 6612, 675, 950, 1072, 3335, 2, 267, 340, 734, 632, 26, 288, 734, 275, 22423, 267, 587, 26, 288, 734, 275, 3087, 267, 372, 28585, 83, 5, 83, 627, 5, 83, 363, 548, 16526, 450, 334, 277, 14, 14184, 12, 734, 12, 536, 1874, 339, 347, 31677, 1799, 8, 277, 12, 536, 304, 267, 7242, 480, 692, 3666, 5, 83, 363, 548, 363, 275, 333, 9373, 4042, 83, 363, 262, 63, 552, 8964, 508, 5962, 4186, 536, 12, 536, 9, 267, 6219, 44, 22359, 342, 267, 7242, 360, 2713, 5432, 63, 1944, 8628, 7303, 358, 267, 7242, 480, 14867, 450, 83, 363, 705, 363, 17259, 536, 9, 267, 291, 14, 1302, 63, 11368, 275, 413, 267, 6219, 50, 22359, 342, 267, 7242, 3647, 83, 363, 552, 363, 275, 450, 83, 363, 262, 63, 552, 363, 17259, 536, 12, 536, 9, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 2071, 83, 363, 262, 3108, 450, 83, 363, 548, 3108, 4366, 83, 19656, 83, 363, 552, 16526, 450, 971, 288, 334, 354, 12, 536, 12, 291, 14, 890, 466, 12, 536, 9, 339, 347, 9199, 585, 6213, 8, 277, 12, 536, 304, 267, 372, 2071, 83, 363, 548, 3108, 334, 442, 19656, 83, 363, 552, 16526, 450, 334, 354, 12, 536, 9, 339, 347, 9058, 8, 277, 12, 536, 304, 267, 7242, 480, 4624, 4042, 83, 363, 548, 363, 2736, 401, 536, 9, 267, 18659, 3205, 2959, 3299, 804, 14, 7661, 8, 277, 12, 536, 9, 421, 199, 533, 21084, 19777, 3205, 2959, 3299, 804, 8, 19777, 3205, 2959, 3299, 804, 304, 339, 408, 7191, 465, 1300, 1021, 12, 1325, 3032, 465, 334, 262, 2738, 12, 734, 2738, 12, 1253, 890, 9471, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 2071, 83, 363, 262, 3108, 450, 83, 363, 548, 3108, 1253, 5, 83, 363, 552, 16526, 450, 334, 354, 12, 536, 12, 536, 9, 421, 199, 533, 5311, 439, 26444, 3205, 2959, 3299, 804, 8, 19777, 3205, 2959, 3299, 804, 304, 339, 408, 7191, 465, 1300, 1021, 12, 1325, 3032, 465, 334, 262, 548, 2738, 12, 1568, 9471, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 26448, 83, 24104, 5286, 25644, 4042, 83, 363, 548, 3108, 450, 83, 363, 262, 3108, 450, 83, 363, 552, 363, 2924, 450, 971, 288, 334, 277, 14, 14184, 12, 536, 12, 257, 536, 12, 258, 536, 9, 421, 199, 533, 21084, 19777, 26444, 3205, 2959, 3299, 804, 8, 19777, 3205, 2959, 3299, 804, 304, 339, 408, 7191, 465, 1300, 1021, 12, 1325, 3032, 465, 334, 262, 548, 2738, 12, 1253, 890, 9471, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 26448, 83, 24104, 5286, 25644, 4042, 83, 363, 548, 3108, 450, 83, 363, 262, 3108, 1253, 5, 83, 363, 552, 363, 2924, 450, 971, 288, 334, 277, 14, 14184, 12, 536, 12, 257, 536, 12, 420, 536, 9, 421, 199, 533, 5311, 439, 2959, 3299, 804, 8, 2959, 5903, 26527, 12, 5311, 439, 3205, 2959, 3299, 804, 304, 339, 408, 2959, 3335, 17659, 641, 314, 13295, 1553, 3032, 465, 334, 2738, 12, 1568, 680, 339, 32092, 1928, 2633, 14, 272, 6523, 687, 2018, 543, 3335, 1568, 14, 272, 408, 339, 347, 664, 3205, 3299, 31963, 1298, 8, 277, 12, 536, 12, 950, 632, 29, 797, 304, 267, 372, 942, 339, 347, 31677, 3484, 8, 277, 304, 267, 372, 298, 73, 2, 339, 347, 31677, 6213, 8, 277, 12, 536, 304, 267, 372, 11746, 5, 83, 363, 262, 63, 552, 16526, 450, 536, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 2071, 83, 363, 548, 3108, 450, 83, 363, 552, 16526, 450, 334, 354, 12, 536, 9, 421, 199, 533, 21084, 19777, 2959, 3299, 804, 8, 19777, 2959, 3299, 804, 304, 339, 408, 2959, 3335, 17659, 641, 314, 13295, 1553, 3032, 465, 334, 2738, 12, 1253, 890, 680, 339, 32092, 1928, 2633, 14, 272, 6523, 687, 2018, 543, 3335, 1568, 14, 272, 408, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 2071, 83, 363, 548, 3108, 1253, 5, 83, 363, 552, 16526, 450, 334, 354, 12, 536, 9, 421, 199, 533, 21084, 5894, 19777, 2959, 3299, 804, 8, 5894, 19777, 2959, 3299, 804, 304, 339, 408, 2959, 3335, 17659, 641, 314, 13295, 1553, 3032, 465, 334, 2738, 12, 1568, 12, 1253, 890, 680, 339, 32092, 1928, 2633, 14, 272, 6523, 687, 2018, 543, 3335, 1568, 14, 272, 408, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 2071, 83, 363, 548, 3108, 450, 83, 363, 552, 3108, 1253, 5, 83, 363, 552, 16526, 450, 334, 354, 12, 536, 12, 536, 9, 199, 199, 533, 603, 9373, 19777, 2959, 3299, 804, 8, 19777, 2959, 3299, 804, 304, 272, 408, 2959, 3335, 17659, 701, 314, 2797, 805, 1553, 3032, 465, 334, 6, 2738, 12, 1253, 890, 680, 339, 32092, 1928, 2633, 14, 272, 6523, 687, 2018, 1928, 2633, 14, 272, 408, 339, 347, 31677, 1799, 8, 277, 12, 536, 304, 267, 7242, 3647, 83, 363, 548, 363, 275, 5962, 17259, 536, 9, 339, 347, 664, 30731, 31963, 1298, 8, 277, 12, 536, 304, 267, 372, 942, 339 ]
[ 699, 3043, 1192, 17659, 641, 314, 13295, 199, 199, 504, 330, 2268, 2959, 492, 627, 199, 504, 330, 2268, 804, 492, 7242, 5903, 26527, 199, 504, 330, 2268, 3299, 492, 18659, 3205, 2959, 3299, 804, 421, 199, 533, 5311, 439, 3205, 2959, 3299, 804, 8, 9515, 3205, 2959, 3299, 804, 304, 339, 408, 3205, 13, 1199, 3335, 17659, 641, 314, 13295, 1553, 3032, 465, 334, 262, 2738, 12, 734, 2738, 12, 1568, 680, 339, 32092, 1928, 2633, 14, 272, 6523, 687, 2018, 543, 1324, 3335, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 16048, 275, 283, 1560, 297, 1568, 466, 275, 283, 442, 297, 1568, 908, 275, 488, 304, 267, 18659, 3205, 2959, 3299, 804, 855, 826, 721, 277, 12, 298, 16, 401, 16048, 12, 1568, 466, 12, 1568, 908, 9, 339, 347, 664, 2959, 3299, 31963, 1298, 8, 277, 12, 536, 12, 950, 632, 29, 797, 12, 734, 632, 29, 797, 304, 267, 340, 950, 632, 26, 288, 746, 6064, 12, 298, 6612, 675, 950, 1072, 3335, 2, 267, 340, 734, 632, 26, 288, 734, 275, 22423, 267, 587, 26, 288, 734, 275, 3087, 267, 372, 28585, 83, 5, 83, 627, 5, 83, 363, 548, 16526, 450, 334, 277, 14, 14184, 12, 734, 12, 536, 1874, 339, 347, 31677, 1799, 8, 277, 12, 536, 304, 267, 7242, 480, 692, 3666, 5, 83, 363, 548, 363, 275, 333, 9373, 4042, 83, 363, 262, 63, 552, 8964, 508, 5962, 4186, 536, 12, 536, 9, 267, 6219, 44, 22359, 342, 267, 7242, 360, 2713, 5432, 63, 1944, 8628, 7303, 358, 267, 7242, 480, 14867, 450, 83, 363, 705, 363, 17259, 536, 9, 267, 291, 14, 1302, 63, 11368, 275, 413, 267, 6219, 50, 22359, 342, 267, 7242, 3647, 83, 363, 552, 363, 275, 450, 83, 363, 262, 63, 552, 363, 17259, 536, 12, 536, 9, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 2071, 83, 363, 262, 3108, 450, 83, 363, 548, 3108, 4366, 83, 19656, 83, 363, 552, 16526, 450, 971, 288, 334, 354, 12, 536, 12, 291, 14, 890, 466, 12, 536, 9, 339, 347, 9199, 585, 6213, 8, 277, 12, 536, 304, 267, 372, 2071, 83, 363, 548, 3108, 334, 442, 19656, 83, 363, 552, 16526, 450, 334, 354, 12, 536, 9, 339, 347, 9058, 8, 277, 12, 536, 304, 267, 7242, 480, 4624, 4042, 83, 363, 548, 363, 2736, 401, 536, 9, 267, 18659, 3205, 2959, 3299, 804, 14, 7661, 8, 277, 12, 536, 9, 421, 199, 533, 21084, 19777, 3205, 2959, 3299, 804, 8, 19777, 3205, 2959, 3299, 804, 304, 339, 408, 7191, 465, 1300, 1021, 12, 1325, 3032, 465, 334, 262, 2738, 12, 734, 2738, 12, 1253, 890, 9471, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 2071, 83, 363, 262, 3108, 450, 83, 363, 548, 3108, 1253, 5, 83, 363, 552, 16526, 450, 334, 354, 12, 536, 12, 536, 9, 421, 199, 533, 5311, 439, 26444, 3205, 2959, 3299, 804, 8, 19777, 3205, 2959, 3299, 804, 304, 339, 408, 7191, 465, 1300, 1021, 12, 1325, 3032, 465, 334, 262, 548, 2738, 12, 1568, 9471, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 26448, 83, 24104, 5286, 25644, 4042, 83, 363, 548, 3108, 450, 83, 363, 262, 3108, 450, 83, 363, 552, 363, 2924, 450, 971, 288, 334, 277, 14, 14184, 12, 536, 12, 257, 536, 12, 258, 536, 9, 421, 199, 533, 21084, 19777, 26444, 3205, 2959, 3299, 804, 8, 19777, 3205, 2959, 3299, 804, 304, 339, 408, 7191, 465, 1300, 1021, 12, 1325, 3032, 465, 334, 262, 548, 2738, 12, 1253, 890, 9471, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 26448, 83, 24104, 5286, 25644, 4042, 83, 363, 548, 3108, 450, 83, 363, 262, 3108, 1253, 5, 83, 363, 552, 363, 2924, 450, 971, 288, 334, 277, 14, 14184, 12, 536, 12, 257, 536, 12, 420, 536, 9, 421, 199, 533, 5311, 439, 2959, 3299, 804, 8, 2959, 5903, 26527, 12, 5311, 439, 3205, 2959, 3299, 804, 304, 339, 408, 2959, 3335, 17659, 641, 314, 13295, 1553, 3032, 465, 334, 2738, 12, 1568, 680, 339, 32092, 1928, 2633, 14, 272, 6523, 687, 2018, 543, 3335, 1568, 14, 272, 408, 339, 347, 664, 3205, 3299, 31963, 1298, 8, 277, 12, 536, 12, 950, 632, 29, 797, 304, 267, 372, 942, 339, 347, 31677, 3484, 8, 277, 304, 267, 372, 298, 73, 2, 339, 347, 31677, 6213, 8, 277, 12, 536, 304, 267, 372, 11746, 5, 83, 363, 262, 63, 552, 16526, 450, 536, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 2071, 83, 363, 548, 3108, 450, 83, 363, 552, 16526, 450, 334, 354, 12, 536, 9, 421, 199, 533, 21084, 19777, 2959, 3299, 804, 8, 19777, 2959, 3299, 804, 304, 339, 408, 2959, 3335, 17659, 641, 314, 13295, 1553, 3032, 465, 334, 2738, 12, 1253, 890, 680, 339, 32092, 1928, 2633, 14, 272, 6523, 687, 2018, 543, 3335, 1568, 14, 272, 408, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 2071, 83, 363, 548, 3108, 1253, 5, 83, 363, 552, 16526, 450, 334, 354, 12, 536, 9, 421, 199, 533, 21084, 5894, 19777, 2959, 3299, 804, 8, 5894, 19777, 2959, 3299, 804, 304, 339, 408, 2959, 3335, 17659, 641, 314, 13295, 1553, 3032, 465, 334, 2738, 12, 1568, 12, 1253, 890, 680, 339, 32092, 1928, 2633, 14, 272, 6523, 687, 2018, 543, 3335, 1568, 14, 272, 408, 339, 347, 986, 2959, 8, 277, 12, 536, 304, 267, 372, 2071, 83, 363, 548, 3108, 450, 83, 363, 552, 3108, 1253, 5, 83, 363, 552, 16526, 450, 334, 354, 12, 536, 12, 536, 9, 199, 199, 533, 603, 9373, 19777, 2959, 3299, 804, 8, 19777, 2959, 3299, 804, 304, 272, 408, 2959, 3335, 17659, 701, 314, 2797, 805, 1553, 3032, 465, 334, 6, 2738, 12, 1253, 890, 680, 339, 32092, 1928, 2633, 14, 272, 6523, 687, 2018, 1928, 2633, 14, 272, 408, 339, 347, 31677, 1799, 8, 277, 12, 536, 304, 267, 7242, 3647, 83, 363, 548, 363, 275, 5962, 17259, 536, 9, 339, 347, 664, 30731, 31963, 1298, 8, 277, 12, 536, 304, 267, 372, 942, 339, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ratschlab/ASP
applications/msplicer/content_sensors.py
1
2271
# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Written (W) 2006-2007 Soeren Sonnenburg # Written (W) 2007 Gunnar Raetsch # Copyright (C) 2007-2008 Fraunhofer Institute FIRST and Max-Planck-Society # import numpy class content_sensors: def __init__(self, model): self.dict_weights_intron=numpy.array(model.dict_weights_intron, dtype=numpy.float64) self.dict_weights_coding=numpy.array(model.dict_weights_coding, dtype=numpy.float64) self.dicts=numpy.concatenate((self.dict_weights_coding,self.dict_weights_intron, self.dict_weights_coding, self.dict_weights_intron, self.dict_weights_coding,self.dict_weights_intron, self.dict_weights_coding, self.dict_weights_intron), axis=0) self.dicts[0, 64:] = 0 # only order 3 info self.dicts[1, 64:] = 0 # only order 3 info self.dicts[2, 0:64] = 0 # only order 4 info self.dicts[2, 320:] = 0 self.dicts[3, 0:64] = 0 # only order 4 info self.dicts[3, 320:] = 0 self.dicts[4, 0:320] = 0 # only order 5 info self.dicts[4, 1344:] = 0 self.dicts[5, 0:320] = 0 # only order 5 info self.dicts[5, 1344:] = 0 self.dicts[6, 0:1344] = 0 # only order 6 info self.dicts[7, 0:1344] = 0 # only order 6 info self.model = model def get_dict_weights(self): return self.dicts.T def initialize_content(self, dyn): dyn.init_svm_arrays(len(self.model.word_degree), len(self.model.mod_words)) word_degree = numpy.array(self.model.word_degree, numpy.int32) dyn.init_word_degree_array(word_degree) mod_words = numpy.array(4**word_degree, numpy.int32) dyn.init_num_words_array(mod_words) cum_mod_words=numpy.zeros(len(mod_words)+1, numpy.int32) cum_mod_words[1:] = numpy.cumsum(mod_words) dyn.init_cum_num_words_array(cum_mod_words) dyn.init_mod_words_array(numpy.array(self.model.mod_words, numpy.int32)) dyn.init_sign_words_array(numpy.array(self.model.sign_words, numpy.bool)) dyn.init_string_words_array(numpy.zeros(len(self.model.sign_words), numpy.int32)) assert(dyn.check_svm_arrays())
gpl-2.0
[ 3, 221, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 27694, 334, 55, 9, 8315, 13, 9488, 2002, 69, 828, 428, 265, 78, 287, 29291, 199, 3, 27694, 334, 55, 9, 10219, 598, 324, 78, 285, 3898, 8716, 335, 199, 3, 1898, 334, 35, 9, 10219, 13, 9300, 481, 345, 324, 526, 2412, 1010, 25585, 28137, 840, 436, 8228, 13, 13375, 346, 13, 51, 3095, 23364, 199, 3, 9948, 199, 646, 2680, 199, 199, 533, 1564, 63, 22675, 26, 199, 198, 318, 636, 826, 721, 277, 12, 1402, 304, 507, 198, 277, 14, 807, 63, 4916, 63, 442, 2641, 29, 4714, 14, 1144, 8, 1238, 14, 807, 63, 4916, 63, 442, 2641, 12, 2152, 29, 4714, 14, 1609, 772, 9, 507, 198, 277, 14, 807, 63, 4916, 63, 1523, 29, 4714, 14, 1144, 8, 1238, 14, 807, 63, 4916, 63, 1523, 12, 2152, 29, 4714, 14, 1609, 772, 9, 2742, 198, 277, 14, 7892, 29, 4714, 14, 13433, 1332, 277, 14, 807, 63, 4916, 63, 1523, 12, 277, 14, 807, 63, 4916, 63, 442, 2641, 12, 291, 14, 807, 63, 4916, 63, 1523, 12, 291, 14, 807, 63, 4916, 63, 442, 2641, 12, 291, 14, 807, 63, 4916, 63, 1523, 12, 277, 14, 807, 63, 4916, 63, 442, 2641, 12, 291, 14, 807, 63, 4916, 63, 1523, 12, 291, 14, 807, 63, 4916, 63, 442, 2641, 395, 3114, 29, 16, 9, 9068, 198, 277, 14, 7892, 59, 16, 12, 5049, 2938, 275, 378, 420, 327, 1454, 1865, 650, 2256, 507, 198, 277, 14, 7892, 59, 17, 12, 5049, 2938, 275, 378, 420, 327, 1454, 1865, 650, 2256, 507, 198, 277, 14, 7892, 59, 18, 12, 378, 26, 772, 61, 275, 378, 258, 327, 1454, 1865, 841, 2256, 507, 198, 277, 14, 7892, 59, 18, 12, 25611, 2938, 275, 378, 3322, 507, 198, 277, 14, 7892, 59, 19, 12, 378, 26, 772, 61, 275, 378, 258, 327, 1454, 1865, 841, 2256, 507, 198, 277, 14, 7892, 59, 19, 12, 25611, 2938, 275, 378, 3777, 507, 198, 277, 14, 7892, 59, 20, 12, 378, 26, 12122, 61, 275, 378, 259, 327, 1454, 1865, 959, 2256, 507, 198, 277, 14, 7892, 59, 20, 12, 413, 10875, 2938, 275, 378, 4519, 507, 198, 277, 14, 7892, 59, 21, 12, 378, 26, 12122, 61, 275, 378, 259, 327, 1454, 1865, 959, 2256, 507, 198, 277, 14, 7892, 59, 21, 12, 413, 10875, 2938, 275, 378, 3777, 507, 198, 277, 14, 7892, 59, 22, 12, 378, 26, 969, 1602, 61, 275, 378, 257, 327, 1454, 1865, 1227, 2256, 507, 198, 277, 14, 7892, 59, 23, 12, 378, 26, 969, 1602, 61, 275, 378, 257, 327, 1454, 1865, 1227, 2256, 2742, 198, 277, 14, 1238, 275, 1402, 18118, 198, 318, 664, 63, 807, 63, 4916, 8, 277, 304, 507, 198, 1107, 291, 14, 7892, 14, 52, 421, 198, 318, 8265, 63, 1317, 8, 277, 12, 25653, 304, 507, 198, 17883, 14, 826, 63, 16820, 63, 10095, 8, 552, 8, 277, 14, 1238, 14, 1027, 63, 10956, 395, 822, 8, 277, 14, 1238, 14, 1494, 63, 3148, 430, 2742, 198, 1027, 63, 10956, 275, 2680, 14, 1144, 8, 277, 14, 1238, 14, 1027, 63, 10956, 12, 2680, 14, 442, 708, 9, 507, 198, 17883, 14, 826, 63, 1027, 63, 10956, 63, 1144, 8, 1027, 63, 10956, 9, 2742, 198, 1494, 63, 3148, 275, 2680, 14, 1144, 8, 20, 538, 1027, 63, 10956, 12, 2680, 14, 442, 708, 9, 507, 198, 17883, 14, 826, 63, 1507, 63, 3148, 63, 1144, 8, 1494, 63, 3148, 9, 2742, 198, 11898, 63, 1494, 63, 3148, 29, 4714, 14, 4250, 8, 552, 8, 1494, 63, 3148, 6393, 17, 12, 2680, 14, 442, 708, 9, 507, 198, 11898, 63, 1494, 63, 3148, 59, 17, 2938, 275, 2680, 14, 23916, 8, 1494, 63, 3148, 9, 507, 198, 17883, 14, 826, 63, 11898, 63, 1507, 63, 3148, 63, 1144, 8, 11898, 63, 1494, 63, 3148, 9, 9068, 198, 17883, 14, 826, 63, 1494, 63, 3148, 63, 1144, 8, 4714, 14, 1144, 8, 277, 14, 1238, 14, 1494, 63, 3148, 12, 2680, 14, 442, 708, 430, 507, 198, 17883, 14, 826, 63, 1037, 63, 3148, 63, 1144, 8, 4714, 14, 1144, 8, 277, 14, 1238, 14, 1037, 63, 3148, 12, 2680, 14, 2245, 430, 507, 198, 17883, 14, 826, 63, 875, 63, 3148, 63, 1144, 8, 4714, 14, 4250, 8, 552, 8, 277, 14, 1238, 14, 1037, 63, 3148, 395, 2680, 14, 442, 708, 430, 2742, 198, 479, 8, 17883, 14, 1074, 63, 16820, 63, 10095, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 221, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 221, 199, 3, 27694, 334, 55, 9, 8315, 13, 9488, 2002, 69, 828, 428, 265, 78, 287, 29291, 199, 3, 27694, 334, 55, 9, 10219, 598, 324, 78, 285, 3898, 8716, 335, 199, 3, 1898, 334, 35, 9, 10219, 13, 9300, 481, 345, 324, 526, 2412, 1010, 25585, 28137, 840, 436, 8228, 13, 13375, 346, 13, 51, 3095, 23364, 199, 3, 9948, 199, 646, 2680, 199, 199, 533, 1564, 63, 22675, 26, 199, 198, 318, 636, 826, 721, 277, 12, 1402, 304, 507, 198, 277, 14, 807, 63, 4916, 63, 442, 2641, 29, 4714, 14, 1144, 8, 1238, 14, 807, 63, 4916, 63, 442, 2641, 12, 2152, 29, 4714, 14, 1609, 772, 9, 507, 198, 277, 14, 807, 63, 4916, 63, 1523, 29, 4714, 14, 1144, 8, 1238, 14, 807, 63, 4916, 63, 1523, 12, 2152, 29, 4714, 14, 1609, 772, 9, 2742, 198, 277, 14, 7892, 29, 4714, 14, 13433, 1332, 277, 14, 807, 63, 4916, 63, 1523, 12, 277, 14, 807, 63, 4916, 63, 442, 2641, 12, 291, 14, 807, 63, 4916, 63, 1523, 12, 291, 14, 807, 63, 4916, 63, 442, 2641, 12, 291, 14, 807, 63, 4916, 63, 1523, 12, 277, 14, 807, 63, 4916, 63, 442, 2641, 12, 291, 14, 807, 63, 4916, 63, 1523, 12, 291, 14, 807, 63, 4916, 63, 442, 2641, 395, 3114, 29, 16, 9, 9068, 198, 277, 14, 7892, 59, 16, 12, 5049, 2938, 275, 378, 420, 327, 1454, 1865, 650, 2256, 507, 198, 277, 14, 7892, 59, 17, 12, 5049, 2938, 275, 378, 420, 327, 1454, 1865, 650, 2256, 507, 198, 277, 14, 7892, 59, 18, 12, 378, 26, 772, 61, 275, 378, 258, 327, 1454, 1865, 841, 2256, 507, 198, 277, 14, 7892, 59, 18, 12, 25611, 2938, 275, 378, 3322, 507, 198, 277, 14, 7892, 59, 19, 12, 378, 26, 772, 61, 275, 378, 258, 327, 1454, 1865, 841, 2256, 507, 198, 277, 14, 7892, 59, 19, 12, 25611, 2938, 275, 378, 3777, 507, 198, 277, 14, 7892, 59, 20, 12, 378, 26, 12122, 61, 275, 378, 259, 327, 1454, 1865, 959, 2256, 507, 198, 277, 14, 7892, 59, 20, 12, 413, 10875, 2938, 275, 378, 4519, 507, 198, 277, 14, 7892, 59, 21, 12, 378, 26, 12122, 61, 275, 378, 259, 327, 1454, 1865, 959, 2256, 507, 198, 277, 14, 7892, 59, 21, 12, 413, 10875, 2938, 275, 378, 3777, 507, 198, 277, 14, 7892, 59, 22, 12, 378, 26, 969, 1602, 61, 275, 378, 257, 327, 1454, 1865, 1227, 2256, 507, 198, 277, 14, 7892, 59, 23, 12, 378, 26, 969, 1602, 61, 275, 378, 257, 327, 1454, 1865, 1227, 2256, 2742, 198, 277, 14, 1238, 275, 1402, 18118, 198, 318, 664, 63, 807, 63, 4916, 8, 277, 304, 507, 198, 1107, 291, 14, 7892, 14, 52, 421, 198, 318, 8265, 63, 1317, 8, 277, 12, 25653, 304, 507, 198, 17883, 14, 826, 63, 16820, 63, 10095, 8, 552, 8, 277, 14, 1238, 14, 1027, 63, 10956, 395, 822, 8, 277, 14, 1238, 14, 1494, 63, 3148, 430, 2742, 198, 1027, 63, 10956, 275, 2680, 14, 1144, 8, 277, 14, 1238, 14, 1027, 63, 10956, 12, 2680, 14, 442, 708, 9, 507, 198, 17883, 14, 826, 63, 1027, 63, 10956, 63, 1144, 8, 1027, 63, 10956, 9, 2742, 198, 1494, 63, 3148, 275, 2680, 14, 1144, 8, 20, 538, 1027, 63, 10956, 12, 2680, 14, 442, 708, 9, 507, 198, 17883, 14, 826, 63, 1507, 63, 3148, 63, 1144, 8, 1494, 63, 3148, 9, 2742, 198, 11898, 63, 1494, 63, 3148, 29, 4714, 14, 4250, 8, 552, 8, 1494, 63, 3148, 6393, 17, 12, 2680, 14, 442, 708, 9, 507, 198, 11898, 63, 1494, 63, 3148, 59, 17, 2938, 275, 2680, 14, 23916, 8, 1494, 63, 3148, 9, 507, 198, 17883, 14, 826, 63, 11898, 63, 1507, 63, 3148, 63, 1144, 8, 11898, 63, 1494, 63, 3148, 9, 9068, 198, 17883, 14, 826, 63, 1494, 63, 3148, 63, 1144, 8, 4714, 14, 1144, 8, 277, 14, 1238, 14, 1494, 63, 3148, 12, 2680, 14, 442, 708, 430, 507, 198, 17883, 14, 826, 63, 1037, 63, 3148, 63, 1144, 8, 4714, 14, 1144, 8, 277, 14, 1238, 14, 1037, 63, 3148, 12, 2680, 14, 2245, 430, 507, 198, 17883, 14, 826, 63, 875, 63, 3148, 63, 1144, 8, 4714, 14, 4250, 8, 552, 8, 277, 14, 1238, 14, 1037, 63, 3148, 395, 2680, 14, 442, 708, 430, 2742, 198, 479, 8, 17883, 14, 1074, 63, 16820, 63, 10095, 1012, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
gnu-sandhi/gnuradio
gnuradio-core/src/python/gnuradio/gr/benchmark_filters.py
18
2663
#!/usr/bin/env python # # Copyright 2005,2006,2007 Free Software Foundation, Inc. # # This file is part of GNU Radio # # GNU Radio is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. # # GNU Radio is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Radio; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. # import time import random from optparse import OptionParser from gnuradio import gr from gnuradio.eng_option import eng_option def make_random_complex_tuple(L): result = [] for x in range(L): result.append(complex(random.uniform(-1000,1000), random.uniform(-1000,1000))) return tuple(result) def benchmark(name, creator, dec, ntaps, total_test_size, block_size): block_size = 32768 tb = gr.top_block() taps = make_random_complex_tuple(ntaps) src = gr.vector_source_c(make_random_complex_tuple(block_size), True) head = gr.head(gr.sizeof_gr_complex, int(total_test_size)) op = creator(dec, taps) dst = gr.null_sink(gr.sizeof_gr_complex) tb.connect(src, head, op, dst) start = time.time() tb.run() stop = time.time() delta = stop - start print "%16s: taps: %4d input: %4g, time: %6.3f taps/sec: %10.4g" % ( name, ntaps, total_test_size, delta, ntaps*total_test_size/delta) def main(): parser = OptionParser(option_class=eng_option) parser.add_option("-n", "--ntaps", type="int", default=256) parser.add_option("-t", "--total-input-size", type="eng_float", default=40e6) parser.add_option("-b", "--block-size", type="intx", default=50000) parser.add_option("-d", "--decimation", type="int", default=1) (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) ntaps = options.ntaps total_input_size = options.total_input_size block_size = options.block_size dec = options.decimation benchmark("gr.fir_filter_ccc", gr.fir_filter_ccc, dec, ntaps, total_input_size, block_size) benchmark("gr.fft_filter_ccc", gr.fft_filter_ccc, dec, ntaps, total_input_size, block_size) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 11811, 12, 7968, 12, 9488, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 13514, 199, 3, 199, 3, 1664, 13514, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 13514, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 1664, 13514, 27, 1937, 314, 570, 9685, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 646, 900, 199, 646, 2196, 199, 504, 8691, 492, 13491, 199, 504, 24526, 492, 7192, 199, 504, 24526, 14, 7420, 63, 1422, 492, 20171, 63, 1422, 199, 199, 318, 1852, 63, 2355, 63, 5254, 63, 2960, 8, 44, 304, 272, 754, 275, 942, 272, 367, 671, 315, 1425, 8, 44, 304, 267, 754, 14, 740, 8, 5254, 8, 2355, 14, 8830, 2801, 5279, 12, 5279, 395, 2892, 2196, 14, 8830, 2801, 5279, 12, 5279, 1724, 272, 372, 2008, 8, 1099, 9, 199, 199, 318, 12338, 8, 354, 12, 14875, 12, 9700, 12, 13377, 7461, 12, 3141, 63, 396, 63, 890, 12, 1853, 63, 890, 304, 272, 1853, 63, 890, 275, 20939, 2333, 339, 7070, 275, 7192, 14, 2119, 63, 1457, 342, 272, 307, 7461, 275, 1852, 63, 2355, 63, 5254, 63, 2960, 8, 343, 7461, 9, 272, 2928, 275, 7192, 14, 4106, 63, 1365, 63, 67, 8, 1875, 63, 2355, 63, 5254, 63, 2960, 8, 1457, 63, 890, 395, 715, 9, 272, 4854, 275, 7192, 14, 2993, 8, 2587, 14, 12590, 63, 2587, 63, 5254, 12, 1109, 8, 2923, 63, 396, 63, 890, 430, 272, 1687, 275, 14875, 8, 7778, 12, 307, 7461, 9, 272, 5042, 275, 7192, 14, 2307, 63, 11279, 8, 2587, 14, 12590, 63, 2587, 63, 5254, 9, 272, 7070, 14, 2242, 8, 2164, 12, 4854, 12, 1687, 12, 5042, 9, 272, 1343, 275, 900, 14, 521, 342, 272, 7070, 14, 1065, 342, 272, 3631, 275, 900, 14, 521, 342, 272, 5762, 275, 3631, 446, 1343, 272, 870, 2071, 975, 83, 26, 307, 7461, 26, 450, 20, 68, 221, 1324, 26, 450, 20, 71, 12, 900, 26, 450, 22, 14, 19, 70, 221, 307, 7461, 15, 3321, 26, 450, 709, 14, 20, 71, 2, 450, 334, 267, 536, 12, 13377, 7461, 12, 3141, 63, 396, 63, 890, 12, 5762, 12, 13377, 7461, 10, 2923, 63, 396, 63, 890, 15, 3136, 9, 199, 199, 318, 2446, 837, 272, 1798, 275, 13491, 8, 1422, 63, 533, 29, 7420, 63, 1422, 9, 272, 1798, 14, 525, 63, 1422, 6096, 78, 401, 4320, 343, 7461, 401, 730, 628, 442, 401, 849, 29, 3912, 9, 272, 1798, 14, 525, 63, 1422, 6096, 84, 401, 4320, 2923, 13, 1210, 13, 890, 401, 730, 628, 7420, 63, 1609, 401, 849, 29, 2167, 69, 22, 9, 272, 1798, 14, 525, 63, 1422, 6096, 66, 401, 4320, 1457, 13, 890, 401, 730, 628, 442, 88, 401, 849, 29, 21, 993, 9, 272, 1798, 14, 525, 63, 1422, 6096, 68, 401, 4320, 22612, 1615, 401, 730, 628, 442, 401, 849, 29, 17, 9, 272, 334, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 272, 340, 822, 8, 589, 9, 1137, 378, 26, 267, 1798, 14, 1361, 63, 3437, 342, 267, 984, 14, 2224, 8, 17, 9, 339, 13377, 7461, 275, 1511, 14, 343, 7461, 272, 3141, 63, 1210, 63, 890, 275, 1511, 14, 2923, 63, 1210, 63, 890, 272, 1853, 63, 890, 275, 1511, 14, 1457, 63, 890, 272, 9700, 275, 1511, 14, 22612, 1615, 339, 12338, 480, 2587, 14, 1795, 63, 1541, 63, 19504, 401, 7192, 14, 1795, 63, 1541, 63, 19504, 12, 1598, 9700, 12, 13377, 7461, 12, 3141, 63, 1210, 63, 890, 12, 1853, 63, 890, 9, 272, 12338, 480, 2587, 14, 9996, 63, 1541, 63, 19504, 401, 7192, 14, 9996, 63, 1541, 63, 19504, 12, 1598, 9700, 12, 13377, 7461, 12, 3141, 63, 1210, 63, 890, 12, 1853, 63, 890, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 11811, 12, 7968, 12, 9488, 2868, 2290, 2752, 12, 3277, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 1664, 13514, 199, 3, 199, 3, 1664, 13514, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 650, 12, 503, 334, 292, 2195, 945, 9, 199, 3, 1263, 2945, 1015, 14, 199, 3, 199, 3, 1664, 13514, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 1664, 13514, 27, 1937, 314, 570, 9685, 14, 221, 982, 440, 12, 2218, 370, 199, 3, 314, 2868, 2290, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 199, 3, 8226, 12, 4828, 11315, 13, 10067, 12, 8217, 14, 199, 3, 199, 199, 646, 900, 199, 646, 2196, 199, 504, 8691, 492, 13491, 199, 504, 24526, 492, 7192, 199, 504, 24526, 14, 7420, 63, 1422, 492, 20171, 63, 1422, 199, 199, 318, 1852, 63, 2355, 63, 5254, 63, 2960, 8, 44, 304, 272, 754, 275, 942, 272, 367, 671, 315, 1425, 8, 44, 304, 267, 754, 14, 740, 8, 5254, 8, 2355, 14, 8830, 2801, 5279, 12, 5279, 395, 2892, 2196, 14, 8830, 2801, 5279, 12, 5279, 1724, 272, 372, 2008, 8, 1099, 9, 199, 199, 318, 12338, 8, 354, 12, 14875, 12, 9700, 12, 13377, 7461, 12, 3141, 63, 396, 63, 890, 12, 1853, 63, 890, 304, 272, 1853, 63, 890, 275, 20939, 2333, 339, 7070, 275, 7192, 14, 2119, 63, 1457, 342, 272, 307, 7461, 275, 1852, 63, 2355, 63, 5254, 63, 2960, 8, 343, 7461, 9, 272, 2928, 275, 7192, 14, 4106, 63, 1365, 63, 67, 8, 1875, 63, 2355, 63, 5254, 63, 2960, 8, 1457, 63, 890, 395, 715, 9, 272, 4854, 275, 7192, 14, 2993, 8, 2587, 14, 12590, 63, 2587, 63, 5254, 12, 1109, 8, 2923, 63, 396, 63, 890, 430, 272, 1687, 275, 14875, 8, 7778, 12, 307, 7461, 9, 272, 5042, 275, 7192, 14, 2307, 63, 11279, 8, 2587, 14, 12590, 63, 2587, 63, 5254, 9, 272, 7070, 14, 2242, 8, 2164, 12, 4854, 12, 1687, 12, 5042, 9, 272, 1343, 275, 900, 14, 521, 342, 272, 7070, 14, 1065, 342, 272, 3631, 275, 900, 14, 521, 342, 272, 5762, 275, 3631, 446, 1343, 272, 870, 2071, 975, 83, 26, 307, 7461, 26, 450, 20, 68, 221, 1324, 26, 450, 20, 71, 12, 900, 26, 450, 22, 14, 19, 70, 221, 307, 7461, 15, 3321, 26, 450, 709, 14, 20, 71, 2, 450, 334, 267, 536, 12, 13377, 7461, 12, 3141, 63, 396, 63, 890, 12, 5762, 12, 13377, 7461, 10, 2923, 63, 396, 63, 890, 15, 3136, 9, 199, 199, 318, 2446, 837, 272, 1798, 275, 13491, 8, 1422, 63, 533, 29, 7420, 63, 1422, 9, 272, 1798, 14, 525, 63, 1422, 6096, 78, 401, 4320, 343, 7461, 401, 730, 628, 442, 401, 849, 29, 3912, 9, 272, 1798, 14, 525, 63, 1422, 6096, 84, 401, 4320, 2923, 13, 1210, 13, 890, 401, 730, 628, 7420, 63, 1609, 401, 849, 29, 2167, 69, 22, 9, 272, 1798, 14, 525, 63, 1422, 6096, 66, 401, 4320, 1457, 13, 890, 401, 730, 628, 442, 88, 401, 849, 29, 21, 993, 9, 272, 1798, 14, 525, 63, 1422, 6096, 68, 401, 4320, 22612, 1615, 401, 730, 628, 442, 401, 849, 29, 17, 9, 272, 334, 1419, 12, 1249, 9, 275, 1798, 14, 1122, 63, 589, 342, 272, 340, 822, 8, 589, 9, 1137, 378, 26, 267, 1798, 14, 1361, 63, 3437, 342, 267, 984, 14, 2224, 8, 17, 9, 339, 13377, 7461, 275, 1511, 14, 343, 7461, 272, 3141, 63, 1210, 63, 890, 275, 1511, 14, 2923, 63, 1210, 63, 890, 272, 1853, 63, 890, 275, 1511, 14, 1457, 63, 890, 272, 9700, 275, 1511, 14, 22612, 1615, 339, 12338, 480, 2587, 14, 1795, 63, 1541, 63, 19504, 401, 7192, 14, 1795, 63, 1541, 63, 19504, 12, 1598, 9700, 12, 13377, 7461, 12, 3141, 63, 1210, 63, 890, 12, 1853, 63, 890, 9, 272, 12338, 480, 2587, 14, 9996, 63, 1541, 63, 19504, 401, 7192, 14, 9996, 63, 1541, 63, 19504, 12, 1598, 9700, 12, 13377, 7461, 12, 3141, 63, 1210, 63, 890, 12, 1853, 63, 890, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 2446, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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defined.""" # (c) 2014 Valentin Rothberg <valentinrothberg@gmail.com> # (c) 2014 Stefan Hengelein <stefan.hengelein@fau.de> # # Licensed under the terms of the GNU GPL License version 2 import os import re from subprocess import Popen, PIPE, STDOUT # regex expressions OPERATORS = r"&|\(|\)|\||\!" FEATURE = r"(?:\w*[A-Z0-9]\w*){2,}" DEF = r"^\s*(?:menu){,1}config\s+(" + FEATURE + r")\s*" EXPR = r"(?:" + OPERATORS + r"|\s|" + FEATURE + r")+" STMT = r"^\s*(?:if|select|depends\s+on)\s+" + EXPR SOURCE_FEATURE = r"(?:\W|\b)+[D]{,1}CONFIG_(" + FEATURE + r")" # regex objects REGEX_FILE_KCONFIG = re.compile(r".*Kconfig[\.\w+\-]*$") REGEX_FEATURE = re.compile(r"(" + FEATURE + r")") REGEX_SOURCE_FEATURE = re.compile(SOURCE_FEATURE) REGEX_KCONFIG_DEF = re.compile(DEF) REGEX_KCONFIG_EXPR = re.compile(EXPR) REGEX_KCONFIG_STMT = re.compile(STMT) REGEX_KCONFIG_HELP = re.compile(r"^\s+(help|---help---)\s*$") REGEX_FILTER_FEATURES = re.compile(r"[A-Za-z0-9]$") def main(): """Main function of this module.""" source_files = [] kconfig_files = [] defined_features = set() referenced_features = dict() # {feature: [files]} # use 'git ls-files' to get the worklist pop = Popen("git ls-files", stdout=PIPE, stderr=STDOUT, shell=True) (stdout, _) = pop.communicate() # wait until finished if len(stdout) > 0 and stdout[-1] == "\n": stdout = stdout[:-1] for gitfile in stdout.rsplit("\n"): if ".git" in gitfile or "ChangeLog" in gitfile or \ ".log" in gitfile or os.path.isdir(gitfile): continue if REGEX_FILE_KCONFIG.match(gitfile): kconfig_files.append(gitfile) else: # all non-Kconfig files are checked for consistency source_files.append(gitfile) for sfile in source_files: parse_source_file(sfile, referenced_features) for kfile in kconfig_files: parse_kconfig_file(kfile, defined_features, referenced_features) print "Undefined symbol used\tFile list" for feature in sorted(referenced_features): # filter some false positives if feature == "FOO" or feature == "BAR" or \ feature == "FOO_BAR" or feature == "XXX": continue if feature not in defined_features: if feature.endswith("_MODULE"): # avoid false positives for kernel modules if feature[:-len("_MODULE")] in defined_features: continue files = referenced_features.get(feature) print "%s\t%s" % (feature, ", ".join(files)) def parse_source_file(sfile, referenced_features): """Parse @sfile for referenced Kconfig features.""" lines = [] with open(sfile, "r") as stream: lines = stream.readlines() for line in lines: if not "CONFIG_" in line: continue features = REGEX_SOURCE_FEATURE.findall(line) for feature in features: if not REGEX_FILTER_FEATURES.search(feature): continue sfiles = referenced_features.get(feature, set()) sfiles.add(sfile) referenced_features[feature] = sfiles def get_features_in_line(line): """Return mentioned Kconfig features in @line.""" return REGEX_FEATURE.findall(line) def parse_kconfig_file(kfile, defined_features, referenced_features): """Parse @kfile and update feature definitions and references.""" lines = [] skip = False with open(kfile, "r") as stream: lines = stream.readlines() for i in range(len(lines)): line = lines[i] line = line.strip('\n') line = line.split("#")[0] # ignore comments if REGEX_KCONFIG_DEF.match(line): feature_def = REGEX_KCONFIG_DEF.findall(line) defined_features.add(feature_def[0]) skip = False elif REGEX_KCONFIG_HELP.match(line): skip = True elif skip: # ignore content of help messages pass elif REGEX_KCONFIG_STMT.match(line): features = get_features_in_line(line) # multi-line statements while line.endswith("\\"): i += 1 line = lines[i] line = line.strip('\n') features.extend(get_features_in_line(line)) for feature in set(features): paths = referenced_features.get(feature, set()) paths.add(kfile) referenced_features[feature] = paths if __name__ == "__main__": main()
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 6591, 28637, 14154, 626, 787, 11812, 1325, 440, 3247, 1041, 199, 199, 3, 334, 67, 9, 6927, 812, 6078, 262, 6848, 273, 14630, 665, 86, 6078, 262, 293, 273, 14630, 32, 6799, 14, 957, 30, 199, 3, 334, 67, 9, 6927, 17854, 12269, 20855, 303, 274, 262, 665, 1597, 12269, 14, 16800, 303, 274, 262, 32, 667, 85, 14, 271, 30, 199, 3, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 421, 199, 646, 747, 199, 646, 295, 199, 504, 3873, 492, 13995, 12, 22773, 12, 4384, 12619, 421, 199, 3, 5163, 8455, 199, 15598, 19033, 275, 519, 2, 6, 6113, 8, 6113, 9, 6113, 92, 6113, 9539, 199, 22884, 275, 519, 2, 15840, 87, 23033, 33, 13, 58, 16, 13, 25, 7272, 87, 10, 11224, 18, 12, 7063, 199, 5638, 275, 519, 2, 12773, 83, 10, 5169, 4470, 11224, 12, 17, 93, 888, 60, 83, 11, 480, 435, 16012, 13214, 435, 519, 27681, 83, 12469, 199, 1438, 3311, 275, 519, 2, 5169, 2, 435, 29771, 19033, 435, 519, 2, 6113, 83, 25576, 435, 16012, 13214, 435, 519, 531, 5207, 199, 840, 5747, 275, 519, 2, 12773, 83, 10, 5169, 692, 92, 2416, 92, 8912, 60, 83, 11, 265, 2862, 83, 5207, 435, 3651, 3311, 199, 10187, 63, 22884, 275, 519, 2, 15840, 55, 6113, 66, 6393, 59, 36, 8194, 12, 17, 93, 5569, 14332, 435, 16012, 13214, 435, 519, 531, 2, 199, 199, 3, 5163, 2251, 199, 10710, 63, 3817, 63, 43, 5569, 275, 295, 14, 2014, 8, 82, 1674, 10, 28033, 7023, 3134, 87, 7896, 13, 3672, 22550, 199, 10710, 63, 22884, 275, 295, 14, 2014, 8, 82, 2, 480, 435, 16012, 13214, 435, 519, 531, 531, 199, 10710, 63, 10187, 63, 22884, 275, 295, 14, 2014, 8, 10187, 63, 22884, 9, 199, 10710, 63, 43, 5569, 63, 5638, 275, 295, 14, 2014, 8, 5638, 9, 199, 10710, 63, 43, 5569, 63, 1438, 3311, 275, 295, 14, 2014, 8, 1438, 3311, 9, 199, 10710, 63, 43, 5569, 63, 840, 5747, 275, 295, 14, 2014, 8, 840, 5747, 9, 199, 10710, 63, 43, 5569, 63, 17930, 275, 295, 14, 2014, 8, 82, 2, 12773, 83, 15622, 3437, 92, 2595, 3437, 2595, 2862, 83, 10, 22550, 199, 10710, 63, 9905, 63, 13313, 275, 295, 14, 2014, 8, 82, 22774, 33, 13, 13163, 13, 90, 16, 13, 25, 61, 22550, 421, 199, 318, 2446, 837, 272, 408, 6756, 805, 402, 642, 859, 1041, 272, 1350, 63, 1725, 275, 942, 272, 1022, 888, 63, 1725, 275, 942, 272, 3247, 63, 3179, 275, 663, 342, 272, 11812, 63, 3179, 275, 1211, 342, 221, 327, 469, 4445, 26, 359, 1725, 9420, 339, 327, 675, 283, 3187, 9100, 13, 1725, 7, 370, 664, 314, 1736, 513, 272, 4560, 275, 13995, 480, 3187, 9100, 13, 1725, 401, 3839, 29, 6089, 12, 4635, 29, 13850, 12, 5218, 29, 549, 9, 272, 334, 2703, 12, 20795, 275, 4560, 14, 10664, 342, 221, 327, 3618, 5133, 9158, 272, 340, 822, 8, 2703, 9, 690, 378, 436, 3839, 1988, 17, 61, 508, 1867, 78, 582, 267, 3839, 275, 3839, 4439, 17, 61, 339, 367, 6135, 493, 315, 3839, 14, 13490, 4582, 78, 2349, 267, 340, 3680, 3187, 2, 315, 6135, 493, 503, 298, 4001, 2445, 2, 315, 6135, 493, 503, 971, 355, 3680, 793, 2, 315, 6135, 493, 503, 747, 14, 515, 14, 6027, 8, 3187, 493, 304, 288, 1980, 267, 340, 14142, 1438, 63, 3817, 63, 43, 5569, 14, 1431, 8, 3187, 493, 304, 288, 1022, 888, 63, 1725, 14, 740, 8, 3187, 493, 9, 267, 587, 26, 288, 327, 1006, 2222, 13, 28033, 1584, 787, 7923, 367, 17754, 288, 1350, 63, 1725, 14, 740, 8, 3187, 493, 9, 339, 367, 308, 493, 315, 1350, 63, 1725, 26, 267, 2198, 63, 1365, 63, 493, 8, 83, 493, 12, 11812, 63, 3179, 9, 339, 367, 1022, 493, 315, 1022, 888, 63, 1725, 26, 267, 2198, 63, 24069, 63, 493, 8, 75, 493, 12, 3247, 63, 3179, 12, 11812, 63, 3179, 9, 339, 870, 298, 16283, 5272, 1202, 60, 84, 1173, 769, 2, 272, 367, 3878, 315, 3355, 8, 22355, 63, 3179, 304, 267, 327, 2457, 2005, 3055, 27609, 267, 340, 3878, 508, 298, 13046, 2, 503, 3878, 508, 298, 13895, 2, 503, 971, 355, 3878, 508, 298, 13046, 63, 13895, 2, 503, 3878, 508, 298, 13933, 582, 288, 1980, 267, 340, 3878, 440, 315, 3247, 63, 3179, 26, 288, 340, 3878, 14, 4130, 11008, 10001, 2349, 355, 327, 5126, 3055, 27609, 367, 5114, 4621, 355, 340, 3878, 4439, 552, 11008, 10001, 11323, 315, 3247, 63, 3179, 26, 490, 1980, 288, 1584, 275, 11812, 63, 3179, 14, 362, 8, 4445, 9, 288, 870, 2071, 83, 60, 84, 5, 83, 2, 450, 334, 4445, 12, 3872, 3680, 904, 8, 1725, 430, 421, 199, 318, 2198, 63, 1365, 63, 493, 8, 83, 493, 12, 11812, 63, 3179, 304, 272, 408, 4003, 768, 83, 493, 367, 11812, 28637, 4534, 1041, 272, 2385, 275, 942, 272, 543, 1551, 8, 83, 493, 12, 298, 82, 531, 465, 2547, 26, 267, 2385, 275, 2547, 14, 9684, 342, 339, 367, 1004, 315, 2385, 26, 267, 340, 440, 298, 5569, 12172, 315, 1004, 26, 288, 1980, 267, 4534, 275, 14142, 1438, 63, 10187, 63, 22884, 14, 6452, 8, 604, 9, 267, 367, 3878, 315, 4534, 26, 288, 340, 440, 14142, 1438, 63, 9905, 63, 13313, 14, 1733, 8, 4445, 304, 355, 1980, 288, 308, 1725, 275, 11812, 63, 3179, 14, 362, 8, 4445, 12, 663, 1012, 288, 308, 1725, 14, 525, 8, 83, 493, 9, 288, 11812, 63, 3179, 59, 4445, 61, 275, 308, 1725, 421, 199, 318, 664, 63, 3179, 63, 262, 63, 604, 8, 604, 304, 272, 408, 1767, 26239, 28637, 4534, 315, 768, 604, 1041, 272, 372, 14142, 1438, 63, 22884, 14, 6452, 8, 604, 9, 421, 199, 318, 2198, 63, 24069, 63, 493, 8, 75, 493, 12, 3247, 63, 3179, 12, 11812, 63, 3179, 304, 272, 408, 4003, 768, 75, 493, 436, 1678, 3878, 10269, 436, 6941, 1041, 272, 2385, 275, 942, 272, 3372, 275, 756, 339, 543, 1551, 8, 75, 493, 12, 298 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 199, 624, 6591, 28637, 14154, 626, 787, 11812, 1325, 440, 3247, 1041, 199, 199, 3, 334, 67, 9, 6927, 812, 6078, 262, 6848, 273, 14630, 665, 86, 6078, 262, 293, 273, 14630, 32, 6799, 14, 957, 30, 199, 3, 334, 67, 9, 6927, 17854, 12269, 20855, 303, 274, 262, 665, 1597, 12269, 14, 16800, 303, 274, 262, 32, 667, 85, 14, 271, 30, 199, 3, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 421, 199, 646, 747, 199, 646, 295, 199, 504, 3873, 492, 13995, 12, 22773, 12, 4384, 12619, 421, 199, 3, 5163, 8455, 199, 15598, 19033, 275, 519, 2, 6, 6113, 8, 6113, 9, 6113, 92, 6113, 9539, 199, 22884, 275, 519, 2, 15840, 87, 23033, 33, 13, 58, 16, 13, 25, 7272, 87, 10, 11224, 18, 12, 7063, 199, 5638, 275, 519, 2, 12773, 83, 10, 5169, 4470, 11224, 12, 17, 93, 888, 60, 83, 11, 480, 435, 16012, 13214, 435, 519, 27681, 83, 12469, 199, 1438, 3311, 275, 519, 2, 5169, 2, 435, 29771, 19033, 435, 519, 2, 6113, 83, 25576, 435, 16012, 13214, 435, 519, 531, 5207, 199, 840, 5747, 275, 519, 2, 12773, 83, 10, 5169, 692, 92, 2416, 92, 8912, 60, 83, 11, 265, 2862, 83, 5207, 435, 3651, 3311, 199, 10187, 63, 22884, 275, 519, 2, 15840, 55, 6113, 66, 6393, 59, 36, 8194, 12, 17, 93, 5569, 14332, 435, 16012, 13214, 435, 519, 531, 2, 199, 199, 3, 5163, 2251, 199, 10710, 63, 3817, 63, 43, 5569, 275, 295, 14, 2014, 8, 82, 1674, 10, 28033, 7023, 3134, 87, 7896, 13, 3672, 22550, 199, 10710, 63, 22884, 275, 295, 14, 2014, 8, 82, 2, 480, 435, 16012, 13214, 435, 519, 531, 531, 199, 10710, 63, 10187, 63, 22884, 275, 295, 14, 2014, 8, 10187, 63, 22884, 9, 199, 10710, 63, 43, 5569, 63, 5638, 275, 295, 14, 2014, 8, 5638, 9, 199, 10710, 63, 43, 5569, 63, 1438, 3311, 275, 295, 14, 2014, 8, 1438, 3311, 9, 199, 10710, 63, 43, 5569, 63, 840, 5747, 275, 295, 14, 2014, 8, 840, 5747, 9, 199, 10710, 63, 43, 5569, 63, 17930, 275, 295, 14, 2014, 8, 82, 2, 12773, 83, 15622, 3437, 92, 2595, 3437, 2595, 2862, 83, 10, 22550, 199, 10710, 63, 9905, 63, 13313, 275, 295, 14, 2014, 8, 82, 22774, 33, 13, 13163, 13, 90, 16, 13, 25, 61, 22550, 421, 199, 318, 2446, 837, 272, 408, 6756, 805, 402, 642, 859, 1041, 272, 1350, 63, 1725, 275, 942, 272, 1022, 888, 63, 1725, 275, 942, 272, 3247, 63, 3179, 275, 663, 342, 272, 11812, 63, 3179, 275, 1211, 342, 221, 327, 469, 4445, 26, 359, 1725, 9420, 339, 327, 675, 283, 3187, 9100, 13, 1725, 7, 370, 664, 314, 1736, 513, 272, 4560, 275, 13995, 480, 3187, 9100, 13, 1725, 401, 3839, 29, 6089, 12, 4635, 29, 13850, 12, 5218, 29, 549, 9, 272, 334, 2703, 12, 20795, 275, 4560, 14, 10664, 342, 221, 327, 3618, 5133, 9158, 272, 340, 822, 8, 2703, 9, 690, 378, 436, 3839, 1988, 17, 61, 508, 1867, 78, 582, 267, 3839, 275, 3839, 4439, 17, 61, 339, 367, 6135, 493, 315, 3839, 14, 13490, 4582, 78, 2349, 267, 340, 3680, 3187, 2, 315, 6135, 493, 503, 298, 4001, 2445, 2, 315, 6135, 493, 503, 971, 355, 3680, 793, 2, 315, 6135, 493, 503, 747, 14, 515, 14, 6027, 8, 3187, 493, 304, 288, 1980, 267, 340, 14142, 1438, 63, 3817, 63, 43, 5569, 14, 1431, 8, 3187, 493, 304, 288, 1022, 888, 63, 1725, 14, 740, 8, 3187, 493, 9, 267, 587, 26, 288, 327, 1006, 2222, 13, 28033, 1584, 787, 7923, 367, 17754, 288, 1350, 63, 1725, 14, 740, 8, 3187, 493, 9, 339, 367, 308, 493, 315, 1350, 63, 1725, 26, 267, 2198, 63, 1365, 63, 493, 8, 83, 493, 12, 11812, 63, 3179, 9, 339, 367, 1022, 493, 315, 1022, 888, 63, 1725, 26, 267, 2198, 63, 24069, 63, 493, 8, 75, 493, 12, 3247, 63, 3179, 12, 11812, 63, 3179, 9, 339, 870, 298, 16283, 5272, 1202, 60, 84, 1173, 769, 2, 272, 367, 3878, 315, 3355, 8, 22355, 63, 3179, 304, 267, 327, 2457, 2005, 3055, 27609, 267, 340, 3878, 508, 298, 13046, 2, 503, 3878, 508, 298, 13895, 2, 503, 971, 355, 3878, 508, 298, 13046, 63, 13895, 2, 503, 3878, 508, 298, 13933, 582, 288, 1980, 267, 340, 3878, 440, 315, 3247, 63, 3179, 26, 288, 340, 3878, 14, 4130, 11008, 10001, 2349, 355, 327, 5126, 3055, 27609, 367, 5114, 4621, 355, 340, 3878, 4439, 552, 11008, 10001, 11323, 315, 3247, 63, 3179, 26, 490, 1980, 288, 1584, 275, 11812, 63, 3179, 14, 362, 8, 4445, 9, 288, 870, 2071, 83, 60, 84, 5, 83, 2, 450, 334, 4445, 12, 3872, 3680, 904, 8, 1725, 430, 421, 199, 318, 2198, 63, 1365, 63, 493, 8, 83, 493, 12, 11812, 63, 3179, 304, 272, 408, 4003, 768, 83, 493, 367, 11812, 28637, 4534, 1041, 272, 2385, 275, 942, 272, 543, 1551, 8, 83, 493, 12, 298, 82, 531, 465, 2547, 26, 267, 2385, 275, 2547, 14, 9684, 342, 339, 367, 1004, 315, 2385, 26, 267, 340, 440, 298, 5569, 12172, 315, 1004, 26, 288, 1980, 267, 4534, 275, 14142, 1438, 63, 10187, 63, 22884, 14, 6452, 8, 604, 9, 267, 367, 3878, 315, 4534, 26, 288, 340, 440, 14142, 1438, 63, 9905, 63, 13313, 14, 1733, 8, 4445, 304, 355, 1980, 288, 308, 1725, 275, 11812, 63, 3179, 14, 362, 8, 4445, 12, 663, 1012, 288, 308, 1725, 14, 525, 8, 83, 493, 9, 288, 11812, 63, 3179, 59, 4445, 61, 275, 308, 1725, 421, 199, 318, 664, 63, 3179, 63, 262, 63, 604, 8, 604, 304, 272, 408, 1767, 26239, 28637, 4534, 315, 768, 604, 1041, 272, 372, 14142, 1438, 63, 22884, 14, 6452, 8, 604, 9, 421, 199, 318, 2198, 63, 24069, 63, 493, 8, 75, 493, 12, 3247, 63, 3179, 12, 11812, 63, 3179, 304, 272, 408, 4003, 768, 75, 493, 436, 1678, 3878, 10269, 436, 6941, 1041, 272, 2385, 275, 942, 272, 3372, 275, 756, 339, 543, 1551, 8, 75, 493, 12, 298, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
bswartz/manila
manila/api/views/share_groups.py
2
3724
# Copyright 2015 Alex Meade # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from manila.api import common class ShareGroupViewBuilder(common.ViewBuilder): """Model a share group API response as a python dictionary.""" _collection_name = 'share_groups' _detail_version_modifiers = [ "add_consistent_snapshot_support_and_az_id_fields_to_sg", ] def summary_list(self, request, share_groups): """Show a list of share groups without many details.""" return self._list_view(self.summary, request, share_groups) def detail_list(self, request, share_groups): """Detailed view of a list of share groups.""" return self._list_view(self.detail, request, share_groups) def summary(self, request, share_group): """Generic, non-detailed view of a share group.""" return { 'share_group': { 'id': share_group.get('id'), 'name': share_group.get('name'), 'links': self._get_links(request, share_group['id']) } } def detail(self, request, share_group): """Detailed view of a single share group.""" context = request.environ['manila.context'] share_group_dict = { 'id': share_group.get('id'), 'name': share_group.get('name'), 'created_at': share_group.get('created_at'), 'status': share_group.get('status'), 'description': share_group.get('description'), 'project_id': share_group.get('project_id'), 'host': share_group.get('host'), 'share_group_type_id': share_group.get('share_group_type_id'), 'source_share_group_snapshot_id': share_group.get( 'source_share_group_snapshot_id'), 'share_network_id': share_group.get('share_network_id'), 'share_types': [st['share_type_id'] for st in share_group.get( 'share_types')], 'links': self._get_links(request, share_group['id']), } self.update_versioned_resource_dict( request, share_group_dict, share_group) if context.is_admin: share_group_dict['share_server_id'] = share_group.get( 'share_server_id') return {'share_group': share_group_dict} @common.ViewBuilder.versioned_method("2.34") def add_consistent_snapshot_support_and_az_id_fields_to_sg( self, context, sg_dict, sg): sg_dict['availability_zone'] = sg.get('availability_zone') sg_dict['consistent_snapshot_support'] = sg.get( 'consistent_snapshot_support') def _list_view(self, func, request, shares): """Provide a view for a list of share groups.""" share_group_list = [ func(request, share)['share_group'] for share in shares ] share_groups_links = self._get_collection_links( request, shares, self._collection_name) share_groups_dict = {"share_groups": share_group_list} if share_groups_links: share_groups_dict['share_groups_links'] = share_groups_links return share_groups_dict
apache-2.0
[ 3, 1898, 6900, 22986, 3194, 9587, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 2169, 25330, 14, 1246, 492, 2863, 421, 199, 533, 5244, 1530, 2448, 2768, 6437, 8, 2330, 14, 2768, 6437, 304, 272, 408, 1685, 282, 8663, 1572, 3261, 1177, 465, 282, 2366, 2600, 1041, 339, 485, 3627, 63, 354, 275, 283, 6251, 63, 2634, 7, 272, 485, 5506, 63, 1023, 63, 17431, 275, 359, 267, 298, 525, 63, 15478, 63, 4753, 63, 4058, 63, 460, 63, 4651, 63, 344, 63, 955, 63, 475, 63, 1226, 401, 272, 1622, 339, 347, 6212, 63, 513, 8, 277, 12, 1056, 12, 8663, 63, 2634, 304, 267, 408, 6824, 282, 769, 402, 8663, 4652, 1928, 5002, 2436, 1041, 267, 372, 291, 423, 513, 63, 1345, 8, 277, 14, 4705, 12, 1056, 12, 8663, 63, 2634, 9, 339, 347, 10093, 63, 513, 8, 277, 12, 1056, 12, 8663, 63, 2634, 304, 267, 408, 36, 1841, 1672, 2455, 402, 282, 769, 402, 8663, 4652, 1041, 267, 372, 291, 423, 513, 63, 1345, 8, 277, 14, 5506, 12, 1056, 12, 8663, 63, 2634, 9, 339, 347, 6212, 8, 277, 12, 1056, 12, 8663, 63, 923, 304, 267, 408, 9417, 12, 2222, 13, 19170, 2455, 402, 282, 8663, 1572, 1041, 267, 372, 469, 288, 283, 6251, 63, 923, 356, 469, 355, 283, 344, 356, 8663, 63, 923, 14, 362, 360, 344, 659, 355, 283, 354, 356, 8663, 63, 923, 14, 362, 360, 354, 659, 355, 283, 4614, 356, 291, 423, 362, 63, 4614, 8, 1069, 12, 8663, 63, 923, 459, 344, 1105, 288, 789, 267, 789, 339, 347, 10093, 8, 277, 12, 1056, 12, 8663, 63, 923, 304, 267, 408, 36, 1841, 1672, 2455, 402, 282, 2849, 8663, 1572, 1041, 267, 1067, 275, 1056, 14, 2314, 459, 1237, 25330, 14, 1100, 418, 267, 8663, 63, 923, 63, 807, 275, 469, 288, 283, 344, 356, 8663, 63, 923, 14, 362, 360, 344, 659, 288, 283, 354, 356, 8663, 63, 923, 14, 362, 360, 354, 659, 288, 283, 3966, 63, 292, 356, 8663, 63, 923, 14, 362, 360, 3966, 63, 292, 659, 288, 283, 1205, 356, 8663, 63, 923, 14, 362, 360, 1205, 659, 288, 283, 1802, 356, 8663, 63, 923, 14, 362, 360, 1802, 659, 288, 283, 1715, 63, 344, 356, 8663, 63, 923, 14, 362, 360, 1715, 63, 344, 659, 288, 283, 1102, 356, 8663, 63, 923, 14, 362, 360, 1102, 659, 288, 283, 6251, 63, 923, 63, 466, 63, 344, 356, 8663, 63, 923, 14, 362, 360, 6251, 63, 923, 63, 466, 63, 344, 659, 288, 283, 1365, 63, 6251, 63, 923, 63, 4753, 63, 344, 356, 8663, 63, 923, 14, 362, 8, 355, 283, 1365, 63, 6251, 63, 923, 63, 4753, 63, 344, 659, 288, 283, 6251, 63, 1200, 63, 344, 356, 8663, 63, 923, 14, 362, 360, 6251, 63, 1200, 63, 344, 659, 288, 283, 6251, 63, 1313, 356, 359, 270, 459, 6251, 63, 466, 63, 344, 418, 367, 410, 315, 8663, 63, 923, 14, 362, 8, 355, 283, 6251, 63, 1313, 2665, 288, 283, 4614, 356, 291, 423, 362, 63, 4614, 8, 1069, 12, 8663, 63, 923, 459, 344, 3815, 267, 789, 267, 291, 14, 873, 63, 24155, 63, 1927, 63, 807, 8, 288, 1056, 12, 8663, 63, 923, 63, 807, 12, 8663, 63, 923, 9, 267, 340, 1067, 14, 374, 63, 2113, 26, 288, 8663, 63, 923, 63, 807, 459, 6251, 63, 1000, 63, 344, 418, 275, 8663, 63, 923, 14, 362, 8, 355, 283, 6251, 63, 1000, 63, 344, 358, 267, 372, 791, 6251, 63, 923, 356, 8663, 63, 923, 63, 807, 93, 339, 768, 2330, 14, 2768, 6437, 14, 24155, 63, 765, 480, 18, 14, 1082, 531, 272, 347, 1050, 63, 15478, 63, 4753, 63, 4058, 63, 460, 63, 4651, 63, 344, 63, 955, 63, 475, 63, 1226, 8, 288, 291, 12, 1067, 12, 12578, 63, 807, 12, 12578, 304, 267, 12578, 63, 807, 459, 11856, 63, 2619, 418, 275, 12578, 14, 362, 360, 11856, 63, 2619, 358, 267, 12578, 63, 807, 459, 15478, 63, 4753, 63, 4058, 418, 275, 12578, 14, 362, 8, 288, 283, 15478, 63, 4753, 63, 4058, 358, 339, 347, 485, 513, 63, 1345, 8, 277, 12, 2562, 12, 1056, 12, 25616, 304, 267, 408, 25107, 282, 2455, 367, 282, 769, 402, 8663, 4652, 1041, 267, 8663, 63, 923, 63, 513, 275, 359, 288, 2562, 8, 1069, 12, 8663, 11820, 6251, 63, 923, 418, 288, 367, 8663, 315, 25616, 267, 1622, 267, 8663, 63, 2634, 63, 4614, 275, 291, 423, 362, 63, 3627, 63, 4614, 8, 288, 1056, 12, 25616, 12, 291, 423, 3627, 63, 354, 9, 267, 8663, 63, 2634, 63, 807, 275, 2420, 6251, 63, 2634, 582, 8663, 63, 923, 63, 513, 93, 398, 340, 8663, 63, 2634, 63, 4614, 26, 288, 8663, 63, 2634, 63, 807, 459, 6251, 63, 2634, 63, 4614, 418, 275, 8663, 63, 2634, 63, 4614, 398, 372, 8663, 63, 2634, 63, 807, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 6900, 22986, 3194, 9587, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 504, 2169, 25330, 14, 1246, 492, 2863, 421, 199, 533, 5244, 1530, 2448, 2768, 6437, 8, 2330, 14, 2768, 6437, 304, 272, 408, 1685, 282, 8663, 1572, 3261, 1177, 465, 282, 2366, 2600, 1041, 339, 485, 3627, 63, 354, 275, 283, 6251, 63, 2634, 7, 272, 485, 5506, 63, 1023, 63, 17431, 275, 359, 267, 298, 525, 63, 15478, 63, 4753, 63, 4058, 63, 460, 63, 4651, 63, 344, 63, 955, 63, 475, 63, 1226, 401, 272, 1622, 339, 347, 6212, 63, 513, 8, 277, 12, 1056, 12, 8663, 63, 2634, 304, 267, 408, 6824, 282, 769, 402, 8663, 4652, 1928, 5002, 2436, 1041, 267, 372, 291, 423, 513, 63, 1345, 8, 277, 14, 4705, 12, 1056, 12, 8663, 63, 2634, 9, 339, 347, 10093, 63, 513, 8, 277, 12, 1056, 12, 8663, 63, 2634, 304, 267, 408, 36, 1841, 1672, 2455, 402, 282, 769, 402, 8663, 4652, 1041, 267, 372, 291, 423, 513, 63, 1345, 8, 277, 14, 5506, 12, 1056, 12, 8663, 63, 2634, 9, 339, 347, 6212, 8, 277, 12, 1056, 12, 8663, 63, 923, 304, 267, 408, 9417, 12, 2222, 13, 19170, 2455, 402, 282, 8663, 1572, 1041, 267, 372, 469, 288, 283, 6251, 63, 923, 356, 469, 355, 283, 344, 356, 8663, 63, 923, 14, 362, 360, 344, 659, 355, 283, 354, 356, 8663, 63, 923, 14, 362, 360, 354, 659, 355, 283, 4614, 356, 291, 423, 362, 63, 4614, 8, 1069, 12, 8663, 63, 923, 459, 344, 1105, 288, 789, 267, 789, 339, 347, 10093, 8, 277, 12, 1056, 12, 8663, 63, 923, 304, 267, 408, 36, 1841, 1672, 2455, 402, 282, 2849, 8663, 1572, 1041, 267, 1067, 275, 1056, 14, 2314, 459, 1237, 25330, 14, 1100, 418, 267, 8663, 63, 923, 63, 807, 275, 469, 288, 283, 344, 356, 8663, 63, 923, 14, 362, 360, 344, 659, 288, 283, 354, 356, 8663, 63, 923, 14, 362, 360, 354, 659, 288, 283, 3966, 63, 292, 356, 8663, 63, 923, 14, 362, 360, 3966, 63, 292, 659, 288, 283, 1205, 356, 8663, 63, 923, 14, 362, 360, 1205, 659, 288, 283, 1802, 356, 8663, 63, 923, 14, 362, 360, 1802, 659, 288, 283, 1715, 63, 344, 356, 8663, 63, 923, 14, 362, 360, 1715, 63, 344, 659, 288, 283, 1102, 356, 8663, 63, 923, 14, 362, 360, 1102, 659, 288, 283, 6251, 63, 923, 63, 466, 63, 344, 356, 8663, 63, 923, 14, 362, 360, 6251, 63, 923, 63, 466, 63, 344, 659, 288, 283, 1365, 63, 6251, 63, 923, 63, 4753, 63, 344, 356, 8663, 63, 923, 14, 362, 8, 355, 283, 1365, 63, 6251, 63, 923, 63, 4753, 63, 344, 659, 288, 283, 6251, 63, 1200, 63, 344, 356, 8663, 63, 923, 14, 362, 360, 6251, 63, 1200, 63, 344, 659, 288, 283, 6251, 63, 1313, 356, 359, 270, 459, 6251, 63, 466, 63, 344, 418, 367, 410, 315, 8663, 63, 923, 14, 362, 8, 355, 283, 6251, 63, 1313, 2665, 288, 283, 4614, 356, 291, 423, 362, 63, 4614, 8, 1069, 12, 8663, 63, 923, 459, 344, 3815, 267, 789, 267, 291, 14, 873, 63, 24155, 63, 1927, 63, 807, 8, 288, 1056, 12, 8663, 63, 923, 63, 807, 12, 8663, 63, 923, 9, 267, 340, 1067, 14, 374, 63, 2113, 26, 288, 8663, 63, 923, 63, 807, 459, 6251, 63, 1000, 63, 344, 418, 275, 8663, 63, 923, 14, 362, 8, 355, 283, 6251, 63, 1000, 63, 344, 358, 267, 372, 791, 6251, 63, 923, 356, 8663, 63, 923, 63, 807, 93, 339, 768, 2330, 14, 2768, 6437, 14, 24155, 63, 765, 480, 18, 14, 1082, 531, 272, 347, 1050, 63, 15478, 63, 4753, 63, 4058, 63, 460, 63, 4651, 63, 344, 63, 955, 63, 475, 63, 1226, 8, 288, 291, 12, 1067, 12, 12578, 63, 807, 12, 12578, 304, 267, 12578, 63, 807, 459, 11856, 63, 2619, 418, 275, 12578, 14, 362, 360, 11856, 63, 2619, 358, 267, 12578, 63, 807, 459, 15478, 63, 4753, 63, 4058, 418, 275, 12578, 14, 362, 8, 288, 283, 15478, 63, 4753, 63, 4058, 358, 339, 347, 485, 513, 63, 1345, 8, 277, 12, 2562, 12, 1056, 12, 25616, 304, 267, 408, 25107, 282, 2455, 367, 282, 769, 402, 8663, 4652, 1041, 267, 8663, 63, 923, 63, 513, 275, 359, 288, 2562, 8, 1069, 12, 8663, 11820, 6251, 63, 923, 418, 288, 367, 8663, 315, 25616, 267, 1622, 267, 8663, 63, 2634, 63, 4614, 275, 291, 423, 362, 63, 3627, 63, 4614, 8, 288, 1056, 12, 25616, 12, 291, 423, 3627, 63, 354, 9, 267, 8663, 63, 2634, 63, 807, 275, 2420, 6251, 63, 2634, 582, 8663, 63, 923, 63, 513, 93, 398, 340, 8663, 63, 2634, 63, 4614, 26, 288, 8663, 63, 2634, 63, 807, 459, 6251, 63, 2634, 63, 4614, 418, 275, 8663, 63, 2634, 63, 4614, 398, 372, 8663, 63, 2634, 63, 807, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
hsuantien/scikit-learn
sklearn/metrics/regression.py
23
16771
"""Metrics to assess performance on regression task Functions named as ``*_score`` return a scalar value to maximize: the higher the better Function named as ``*_error`` or ``*_loss`` return a scalar value to minimize: the lower the better """ # Authors: Alexandre Gramfort <alexandre.gramfort@inria.fr> # Mathieu Blondel <mathieu@mblondel.org> # Olivier Grisel <olivier.grisel@ensta.org> # Arnaud Joly <a.joly@ulg.ac.be> # Jochen Wersdorfer <jochen@wersdoerfer.de> # Lars Buitinck <L.J.Buitinck@uva.nl> # Joel Nothman <joel.nothman@gmail.com> # Noel Dawe <noel@dawe.me> # Manoj Kumar <manojkumarsivaraj334@gmail.com> # Michael Eickenberg <michael.eickenberg@gmail.com> # Konstantin Shmelkov <konstantin.shmelkov@polytechnique.edu> # License: BSD 3 clause from __future__ import division import numpy as np from ..utils.validation import check_array, check_consistent_length from ..utils.validation import column_or_1d import warnings __ALL__ = [ "mean_absolute_error", "mean_squared_error", "median_absolute_error", "r2_score", "explained_variance_score" ] def _check_reg_targets(y_true, y_pred, multioutput): """Check that y_true and y_pred belong to the same regression task Parameters ---------- y_true : array-like, y_pred : array-like, multioutput : array-like or string in ['raw_values', uniform_average', 'variance_weighted'] or None None is accepted due to backward compatibility of r2_score(). Returns ------- type_true : one of {'continuous', continuous-multioutput'} The type of the true target data, as output by 'utils.multiclass.type_of_target' y_true : array-like of shape = (n_samples, n_outputs) Ground truth (correct) target values. y_pred : array-like of shape = (n_samples, n_outputs) Estimated target values. multioutput : array-like of shape = (n_outputs) or string in ['raw_values', uniform_average', 'variance_weighted'] or None Custom output weights if ``multioutput`` is array-like or just the corresponding argument if ``multioutput`` is a correct keyword. """ check_consistent_length(y_true, y_pred) y_true = check_array(y_true, ensure_2d=False) y_pred = check_array(y_pred, ensure_2d=False) if y_true.ndim == 1: y_true = y_true.reshape((-1, 1)) if y_pred.ndim == 1: y_pred = y_pred.reshape((-1, 1)) if y_true.shape[1] != y_pred.shape[1]: raise ValueError("y_true and y_pred have different number of output " "({0}!={1})".format(y_true.shape[1], y_pred.shape[1])) n_outputs = y_true.shape[1] multioutput_options = (None, 'raw_values', 'uniform_average', 'variance_weighted') if multioutput not in multioutput_options: multioutput = check_array(multioutput, ensure_2d=False) if n_outputs == 1: raise ValueError("Custom weights are useful only in " "multi-output cases.") elif n_outputs != len(multioutput): raise ValueError(("There must be equally many custom weights " "(%d) as outputs (%d).") % (len(multioutput), n_outputs)) y_type = 'continuous' if n_outputs == 1 else 'continuous-multioutput' return y_type, y_true, y_pred, multioutput def mean_absolute_error(y_true, y_pred, sample_weight=None, multioutput='uniform_average'): """Mean absolute error regression loss Read more in the :ref:`User Guide <mean_absolute_error>`. Parameters ---------- y_true : array-like of shape = (n_samples) or (n_samples, n_outputs) Ground truth (correct) target values. y_pred : array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values. sample_weight : array-like of shape = (n_samples), optional Sample weights. multioutput : string in ['raw_values', 'uniform_average'] or array-like of shape (n_outputs) Defines aggregating of multiple output values. Array-like value defines weights used to average errors. 'raw_values' : Returns a full set of errors in case of multioutput input. 'uniform_average' : Errors of all outputs are averaged with uniform weight. Returns ------- loss : float or ndarray of floats If multioutput is 'raw_values', then mean absolute error is returned for each output separately. If multioutput is 'uniform_average' or an ndarray of weights, then the weighted average of all output errors is returned. MAE output is non-negative floating point. The best value is 0.0. Examples -------- >>> from sklearn.metrics import mean_absolute_error >>> y_true = [3, -0.5, 2, 7] >>> y_pred = [2.5, 0.0, 2, 8] >>> mean_absolute_error(y_true, y_pred) 0.5 >>> y_true = [[0.5, 1], [-1, 1], [7, -6]] >>> y_pred = [[0, 2], [-1, 2], [8, -5]] >>> mean_absolute_error(y_true, y_pred) 0.75 >>> mean_absolute_error(y_true, y_pred, multioutput='raw_values') array([ 0.5, 1. ]) >>> mean_absolute_error(y_true, y_pred, multioutput=[0.3, 0.7]) ... # doctest: +ELLIPSIS 0.849... """ y_type, y_true, y_pred, multioutput = _check_reg_targets( y_true, y_pred, multioutput) output_errors = np.average(np.abs(y_pred - y_true), weights=sample_weight, axis=0) if multioutput == 'raw_values': return output_errors elif multioutput == 'uniform_average': # pass None as weights to np.average: uniform mean multioutput = None return np.average(output_errors, weights=multioutput) def mean_squared_error(y_true, y_pred, sample_weight=None, multioutput='uniform_average'): """Mean squared error regression loss Read more in the :ref:`User Guide <mean_squared_error>`. Parameters ---------- y_true : array-like of shape = (n_samples) or (n_samples, n_outputs) Ground truth (correct) target values. y_pred : array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values. sample_weight : array-like of shape = (n_samples), optional Sample weights. multioutput : string in ['raw_values', 'uniform_average'] or array-like of shape (n_outputs) Defines aggregating of multiple output values. Array-like value defines weights used to average errors. 'raw_values' : Returns a full set of errors in case of multioutput input. 'uniform_average' : Errors of all outputs are averaged with uniform weight. Returns ------- loss : float or ndarray of floats A non-negative floating point value (the best value is 0.0), or an array of floating point values, one for each individual target. Examples -------- >>> from sklearn.metrics import mean_squared_error >>> y_true = [3, -0.5, 2, 7] >>> y_pred = [2.5, 0.0, 2, 8] >>> mean_squared_error(y_true, y_pred) 0.375 >>> y_true = [[0.5, 1],[-1, 1],[7, -6]] >>> y_pred = [[0, 2],[-1, 2],[8, -5]] >>> mean_squared_error(y_true, y_pred) # doctest: +ELLIPSIS 0.708... >>> mean_squared_error(y_true, y_pred, multioutput='raw_values') ... # doctest: +ELLIPSIS array([ 0.416..., 1. ]) >>> mean_squared_error(y_true, y_pred, multioutput=[0.3, 0.7]) ... # doctest: +ELLIPSIS 0.824... """ y_type, y_true, y_pred, multioutput = _check_reg_targets( y_true, y_pred, multioutput) output_errors = np.average((y_true - y_pred) ** 2, axis=0, weights=sample_weight) if multioutput == 'raw_values': return output_errors elif multioutput == 'uniform_average': # pass None as weights to np.average: uniform mean multioutput = None return np.average(output_errors, weights=multioutput) def median_absolute_error(y_true, y_pred): """Median absolute error regression loss Read more in the :ref:`User Guide <median_absolute_error>`. Parameters ---------- y_true : array-like of shape = (n_samples) Ground truth (correct) target values. y_pred : array-like of shape = (n_samples) Estimated target values. Returns ------- loss : float A positive floating point value (the best value is 0.0). Examples -------- >>> from sklearn.metrics import median_absolute_error >>> y_true = [3, -0.5, 2, 7] >>> y_pred = [2.5, 0.0, 2, 8] >>> median_absolute_error(y_true, y_pred) 0.5 """ y_type, y_true, y_pred, _ = _check_reg_targets(y_true, y_pred, 'uniform_average') if y_type == 'continuous-multioutput': raise ValueError("Multioutput not supported in median_absolute_error") return np.median(np.abs(y_pred - y_true)) def explained_variance_score(y_true, y_pred, sample_weight=None, multioutput='uniform_average'): """Explained variance regression score function Best possible score is 1.0, lower values are worse. Read more in the :ref:`User Guide <explained_variance_score>`. Parameters ---------- y_true : array-like of shape = (n_samples) or (n_samples, n_outputs) Ground truth (correct) target values. y_pred : array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values. sample_weight : array-like of shape = (n_samples), optional Sample weights. multioutput : string in ['raw_values', 'uniform_average', \ 'variance_weighted'] or array-like of shape (n_outputs) Defines aggregating of multiple output scores. Array-like value defines weights used to average scores. 'raw_values' : Returns a full set of scores in case of multioutput input. 'uniform_average' : Scores of all outputs are averaged with uniform weight. 'variance_weighted' : Scores of all outputs are averaged, weighted by the variances of each individual output. Returns ------- score : float or ndarray of floats The explained variance or ndarray if 'multioutput' is 'raw_values'. Notes ----- This is not a symmetric function. Examples -------- >>> from sklearn.metrics import explained_variance_score >>> y_true = [3, -0.5, 2, 7] >>> y_pred = [2.5, 0.0, 2, 8] >>> explained_variance_score(y_true, y_pred) # doctest: +ELLIPSIS 0.957... >>> y_true = [[0.5, 1], [-1, 1], [7, -6]] >>> y_pred = [[0, 2], [-1, 2], [8, -5]] >>> explained_variance_score(y_true, y_pred, multioutput='uniform_average') ... # doctest: +ELLIPSIS 0.983... """ y_type, y_true, y_pred, multioutput = _check_reg_targets( y_true, y_pred, multioutput) y_diff_avg = np.average(y_true - y_pred, weights=sample_weight, axis=0) numerator = np.average((y_true - y_pred - y_diff_avg) ** 2, weights=sample_weight, axis=0) y_true_avg = np.average(y_true, weights=sample_weight, axis=0) denominator = np.average((y_true - y_true_avg) ** 2, weights=sample_weight, axis=0) nonzero_numerator = numerator != 0 nonzero_denominator = denominator != 0 valid_score = nonzero_numerator & nonzero_denominator output_scores = np.ones(y_true.shape[1]) output_scores[valid_score] = 1 - (numerator[valid_score] / denominator[valid_score]) output_scores[nonzero_numerator & ~nonzero_denominator] = 0. if multioutput == 'raw_values': # return scores individually return output_scores elif multioutput == 'uniform_average': # passing to np.average() None as weights results is uniform mean avg_weights = None elif multioutput == 'variance_weighted': avg_weights = denominator else: avg_weights = multioutput return np.average(output_scores, weights=avg_weights) def r2_score(y_true, y_pred, sample_weight=None, multioutput=None): """R^2 (coefficient of determination) regression score function. Best possible score is 1.0, lower values are worse. Read more in the :ref:`User Guide <r2_score>`. Parameters ---------- y_true : array-like of shape = (n_samples) or (n_samples, n_outputs) Ground truth (correct) target values. y_pred : array-like of shape = (n_samples) or (n_samples, n_outputs) Estimated target values. sample_weight : array-like of shape = (n_samples), optional Sample weights. multioutput : string in ['raw_values', 'uniform_average', 'variance_weighted'] or None or array-like of shape (n_outputs) Defines aggregating of multiple output scores. Array-like value defines weights used to average scores. Default value correponds to 'variance_weighted', but will be changed to 'uniform_average' in next versions. 'raw_values' : Returns a full set of scores in case of multioutput input. 'uniform_average' : Scores of all outputs are averaged with uniform weight. 'variance_weighted' : Scores of all outputs are averaged, weighted by the variances of each individual output. Returns ------- z : float or ndarray of floats The R^2 score or ndarray of scores if 'multioutput' is 'raw_values'. Notes ----- This is not a symmetric function. Unlike most other scores, R^2 score may be negative (it need not actually be the square of a quantity R). References ---------- .. [1] `Wikipedia entry on the Coefficient of determination <http://en.wikipedia.org/wiki/Coefficient_of_determination>`_ Examples -------- >>> from sklearn.metrics import r2_score >>> y_true = [3, -0.5, 2, 7] >>> y_pred = [2.5, 0.0, 2, 8] >>> r2_score(y_true, y_pred) # doctest: +ELLIPSIS 0.948... >>> y_true = [[0.5, 1], [-1, 1], [7, -6]] >>> y_pred = [[0, 2], [-1, 2], [8, -5]] >>> r2_score(y_true, y_pred, multioutput='variance_weighted') # doctest: +ELLIPSIS 0.938... """ y_type, y_true, y_pred, multioutput = _check_reg_targets( y_true, y_pred, multioutput) if sample_weight is not None: sample_weight = column_or_1d(sample_weight) weight = sample_weight[:, np.newaxis] else: weight = 1. numerator = (weight * (y_true - y_pred) ** 2).sum(axis=0, dtype=np.float64) denominator = (weight * (y_true - np.average( y_true, axis=0, weights=sample_weight)) ** 2).sum(axis=0, dtype=np.float64) nonzero_denominator = denominator != 0 nonzero_numerator = numerator != 0 valid_score = nonzero_denominator & nonzero_numerator output_scores = np.ones([y_true.shape[1]]) output_scores[valid_score] = 1 - (numerator[valid_score] / denominator[valid_score]) # arbitrary set to zero to avoid -inf scores, having a constant # y_true is not interesting for scoring a regression anyway output_scores[nonzero_numerator & ~nonzero_denominator] = 0. if multioutput is None and y_true.shape[1] != 1: # @FIXME change in 0.18 warnings.warn("Default 'multioutput' behavior now corresponds to " "'variance_weighted' value, it will be changed " "to 'uniform_average' in 0.18.", DeprecationWarning) multioutput = 'variance_weighted' if multioutput == 'raw_values': # return scores individually return output_scores elif multioutput == 'uniform_average': # passing None as weights results is uniform mean avg_weights = None elif multioutput == 'variance_weighted': avg_weights = denominator # avoid fail on constant y or one-element arrays if not np.any(nonzero_denominator): if not np.any(nonzero_numerator): return 1.0 else: return 0.0 else: avg_weights = multioutput return np.average(output_scores, weights=avg_weights)
bsd-3-clause
[ 624, 17213, 370, 465, 5480, 10238, 641, 10864, 2120, 199, 199, 13967, 4310, 465, 1124, 10, 63, 3397, 1040, 372, 282, 6917, 574, 370, 1390, 11807, 26, 314, 10948, 199, 1589, 8034, 199, 199, 3481, 4310, 465, 1124, 10, 63, 705, 1040, 503, 1124, 10, 63, 4358, 1040, 372, 282, 6917, 574, 370, 24720, 26, 199, 1589, 5117, 314, 8034, 199, 624, 199, 199, 3, 6642, 26, 22986, 28547, 27211, 10279, 665, 24421, 28547, 14, 1679, 10279, 32, 262, 23714, 14, 4391, 30, 199, 3, 3515, 21066, 29364, 699, 5298, 2264, 665, 3442, 29364, 32, 887, 5298, 2264, 14, 1308, 30, 199, 3, 3515, 593, 317, 26645, 598, 322, 5891, 665, 23711, 26645, 14, 7928, 5891, 32, 287, 1207, 14, 1308, 30, 199, 3, 3515, 1952, 3540, 1181, 1603, 16242, 665, 65, 14, 74, 16242, 32, 27092, 14, 645, 14, 1235, 30, 199, 3, 3515, 7135, 24604, 644, 1192, 68, 269, 2412, 665, 743, 24604, 32, 12203, 1117, 281, 2412, 14, 271, 30, 199, 3, 3515, 491, 4291, 4779, 390, 262, 346, 665, 44, 14, 42, 14, 1713, 390, 262, 346, 32, 85, 3042, 14, 7530, 30, 199, 3, 3515, 7135, 352, 3091, 273, 1237, 665, 743, 352, 14, 889, 273, 1237, 32, 6799, 14, 957, 30, 199, 3, 3515, 3091, 352, 577, 65, 1129, 665, 889, 352, 32, 983, 1129, 14, 278, 30, 199, 3, 3515, 4688, 79, 74, 1804, 453, 285, 665, 1237, 79, 17421, 453, 285, 338, 1391, 9091, 8425, 32, 6799, 14, 957, 30, 199, 3, 3515, 16922, 662, 2000, 287, 14630, 665, 22333, 14, 69, 2000, 287, 14630, 32, 6799, 14, 957, 30, 199, 3, 3515, 1804, 265, 4715, 262, 5244, 26908, 7697, 86, 665, 75, 265, 4715, 262, 14, 609, 26908, 7697, 86, 32, 6023, 266, 11019, 2029, 14, 8654, 30, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 2508, 1208, 14, 6136, 492, 1104, 63, 1144, 12, 1104, 63, 15478, 63, 1267, 199, 504, 2508, 1208, 14, 6136, 492, 2763, 63, 269, 63, 17, 68, 199, 199, 646, 3598, 199, 199, 363, 1761, 363, 275, 359, 272, 298, 3670, 63, 6116, 63, 705, 401, 272, 298, 3670, 63, 12973, 63, 705, 401, 272, 298, 13106, 63, 6116, 63, 705, 401, 272, 298, 82, 18, 63, 3397, 401, 272, 298, 1474, 23918, 63, 6221, 63, 3397, 2, 199, 61, 421, 199, 318, 485, 1074, 63, 1135, 63, 4684, 8, 89, 63, 2052, 12, 612, 63, 5991, 12, 3510, 1199, 304, 272, 408, 1799, 626, 612, 63, 2052, 436, 612, 63, 5991, 13511, 370, 314, 2011, 10864, 2120, 339, 3897, 272, 4143, 272, 612, 63, 2052, 520, 1625, 13, 2930, 12, 339, 612, 63, 5991, 520, 1625, 13, 2930, 12, 339, 3510, 1199, 520, 1625, 13, 2930, 503, 1059, 315, 788, 1773, 63, 1459, 297, 14818, 63, 8536, 297, 267, 283, 6221, 63, 13522, 418, 503, 488, 267, 488, 365, 10226, 7037, 370, 13388, 7163, 402, 519, 18, 63, 3397, 1252, 339, 1803, 272, 5514, 272, 730, 63, 2052, 520, 1373, 402, 791, 23458, 297, 19922, 13, 3029, 1199, 936, 267, 710, 730, 402, 314, 2549, 1347, 666, 12, 465, 1072, 701, 267, 283, 1208, 14, 30016, 14, 466, 63, 1618, 63, 1375, 7, 339, 612, 63, 2052, 520, 1625, 13, 2930, 402, 2215, 275, 334, 78, 63, 3356, 12, 302, 63, 4467, 9, 267, 598, 2363, 16865, 334, 4525, 9, 1347, 1338, 14, 339, 612, 63, 5991, 520, 1625, 13, 2930, 402, 2215, 275, 334, 78, 63, 3356, 12, 302, 63, 4467, 9, 267, 15896, 12754, 1347, 1338, 14, 339, 3510, 1199, 520, 1625, 13, 2930, 402, 2215, 275, 334, 78, 63, 4467, 9, 503, 1059, 315, 788, 1773, 63, 1459, 297, 267, 14818, 63, 8536, 297, 283, 6221, 63, 13522, 418, 503, 488, 267, 8388, 1072, 4931, 340, 1124, 3029, 1199, 1040, 365, 1625, 13, 2930, 503, 267, 2951, 314, 5226, 1423, 340, 1124, 3029, 1199, 1040, 365, 282, 267, 3211, 4252, 14, 339, 408, 272, 1104, 63, 15478, 63, 1267, 8, 89, 63, 2052, 12, 612, 63, 5991, 9, 272, 612, 63, 2052, 275, 1104, 63, 1144, 8, 89, 63, 2052, 12, 4868, 63, 18, 68, 29, 797, 9, 272, 612, 63, 5991, 275, 1104, 63, 1144, 8, 89, 63, 5991, 12, 4868, 63, 18, 68, 29, 797, 9, 339, 340, 612, 63, 2052, 14, 8322, 508, 413, 26, 267, 612, 63, 2052, 275, 612, 63, 2052, 14, 5217, 18138, 17, 12, 413, 430, 339, 340, 612, 63, 5991, 14, 8322, 508, 413, 26, 267, 612, 63, 5991, 275, 612, 63, 5991, 14, 5217, 18138, 17, 12, 413, 430, 339, 340, 612, 63, 2052, 14, 1392, 59, 17, 61, 1137, 612, 63, 5991, 14, 1392, 59, 17, 2189, 267, 746, 1722, 480, 89, 63, 2052, 436, 612, 63, 5991, 1172, 3365, 1329, 402, 1072, 298, 586, 298, 2561, 16, 93, 1111, 91, 17, 25974, 908, 8, 89, 63, 2052, 14, 1392, 59, 17, 467, 612, 63, 5991, 14, 1392, 59, 17, 2459, 339, 302, 63, 4467, 275, 612, 63, 2052, 14, 1392, 59, 17, 61, 272, 3510, 1199, 63, 1419, 275, 334, 403, 12, 283, 1773, 63, 1459, 297, 283, 8830, 63, 8536, 297, 2574, 283, 6221, 63, 13522, 358, 272, 340, 3510, 1199, 440, 315, 3510, 1199, 63, 1419, 26, 267, 3510, 1199, 275, 1104, 63, 1144, 8, 3029, 1199, 12, 4868, 63, 18, 68, 29, 797, 9, 267, 340, 302, 63, 4467, 508, 413, 26, 288, 746, 1722, 480, 7223, 4931, 787, 2997, 1454, 315, 298, 2490, 298, 3029, 13, 1199, 5560, 2685, 267, 916, 302, 63, 4467, 1137, 822, 8, 3029, 1199, 304, 288, 746, 1722, 9313, 10924, 1471, 506, 11960, 1183, 5002, 3537, 4931, 298, 2892, 26448, 68, 9, 465, 4704, 4366, 68, 26744, 450, 2490, 334, 552, 8, 3029, 1199, 395, 302, 63, 4467, 430, 272, 612, 63, 466, 275, 283, 23458, 7, 340, 302, 63, 4467, 508, 413, 587, 283, 23458, 13, 3029, 1199, 7, 339, 372, 612, 63, 466, 12, 612, 63, 2052, 12, 612, 63, 5991, 12, 3510, 1199, 421, 199, 318, 4615, 63, 6116, 63, 705, 8, 89, 63, 2052, 12 ]
[ 17213, 370, 465, 5480, 10238, 641, 10864, 2120, 199, 199, 13967, 4310, 465, 1124, 10, 63, 3397, 1040, 372, 282, 6917, 574, 370, 1390, 11807, 26, 314, 10948, 199, 1589, 8034, 199, 199, 3481, 4310, 465, 1124, 10, 63, 705, 1040, 503, 1124, 10, 63, 4358, 1040, 372, 282, 6917, 574, 370, 24720, 26, 199, 1589, 5117, 314, 8034, 199, 624, 199, 199, 3, 6642, 26, 22986, 28547, 27211, 10279, 665, 24421, 28547, 14, 1679, 10279, 32, 262, 23714, 14, 4391, 30, 199, 3, 3515, 21066, 29364, 699, 5298, 2264, 665, 3442, 29364, 32, 887, 5298, 2264, 14, 1308, 30, 199, 3, 3515, 593, 317, 26645, 598, 322, 5891, 665, 23711, 26645, 14, 7928, 5891, 32, 287, 1207, 14, 1308, 30, 199, 3, 3515, 1952, 3540, 1181, 1603, 16242, 665, 65, 14, 74, 16242, 32, 27092, 14, 645, 14, 1235, 30, 199, 3, 3515, 7135, 24604, 644, 1192, 68, 269, 2412, 665, 743, 24604, 32, 12203, 1117, 281, 2412, 14, 271, 30, 199, 3, 3515, 491, 4291, 4779, 390, 262, 346, 665, 44, 14, 42, 14, 1713, 390, 262, 346, 32, 85, 3042, 14, 7530, 30, 199, 3, 3515, 7135, 352, 3091, 273, 1237, 665, 743, 352, 14, 889, 273, 1237, 32, 6799, 14, 957, 30, 199, 3, 3515, 3091, 352, 577, 65, 1129, 665, 889, 352, 32, 983, 1129, 14, 278, 30, 199, 3, 3515, 4688, 79, 74, 1804, 453, 285, 665, 1237, 79, 17421, 453, 285, 338, 1391, 9091, 8425, 32, 6799, 14, 957, 30, 199, 3, 3515, 16922, 662, 2000, 287, 14630, 665, 22333, 14, 69, 2000, 287, 14630, 32, 6799, 14, 957, 30, 199, 3, 3515, 1804, 265, 4715, 262, 5244, 26908, 7697, 86, 665, 75, 265, 4715, 262, 14, 609, 26908, 7697, 86, 32, 6023, 266, 11019, 2029, 14, 8654, 30, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 504, 636, 2443, 363, 492, 4629, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 2508, 1208, 14, 6136, 492, 1104, 63, 1144, 12, 1104, 63, 15478, 63, 1267, 199, 504, 2508, 1208, 14, 6136, 492, 2763, 63, 269, 63, 17, 68, 199, 199, 646, 3598, 199, 199, 363, 1761, 363, 275, 359, 272, 298, 3670, 63, 6116, 63, 705, 401, 272, 298, 3670, 63, 12973, 63, 705, 401, 272, 298, 13106, 63, 6116, 63, 705, 401, 272, 298, 82, 18, 63, 3397, 401, 272, 298, 1474, 23918, 63, 6221, 63, 3397, 2, 199, 61, 421, 199, 318, 485, 1074, 63, 1135, 63, 4684, 8, 89, 63, 2052, 12, 612, 63, 5991, 12, 3510, 1199, 304, 272, 408, 1799, 626, 612, 63, 2052, 436, 612, 63, 5991, 13511, 370, 314, 2011, 10864, 2120, 339, 3897, 272, 4143, 272, 612, 63, 2052, 520, 1625, 13, 2930, 12, 339, 612, 63, 5991, 520, 1625, 13, 2930, 12, 339, 3510, 1199, 520, 1625, 13, 2930, 503, 1059, 315, 788, 1773, 63, 1459, 297, 14818, 63, 8536, 297, 267, 283, 6221, 63, 13522, 418, 503, 488, 267, 488, 365, 10226, 7037, 370, 13388, 7163, 402, 519, 18, 63, 3397, 1252, 339, 1803, 272, 5514, 272, 730, 63, 2052, 520, 1373, 402, 791, 23458, 297, 19922, 13, 3029, 1199, 936, 267, 710, 730, 402, 314, 2549, 1347, 666, 12, 465, 1072, 701, 267, 283, 1208, 14, 30016, 14, 466, 63, 1618, 63, 1375, 7, 339, 612, 63, 2052, 520, 1625, 13, 2930, 402, 2215, 275, 334, 78, 63, 3356, 12, 302, 63, 4467, 9, 267, 598, 2363, 16865, 334, 4525, 9, 1347, 1338, 14, 339, 612, 63, 5991, 520, 1625, 13, 2930, 402, 2215, 275, 334, 78, 63, 3356, 12, 302, 63, 4467, 9, 267, 15896, 12754, 1347, 1338, 14, 339, 3510, 1199, 520, 1625, 13, 2930, 402, 2215, 275, 334, 78, 63, 4467, 9, 503, 1059, 315, 788, 1773, 63, 1459, 297, 267, 14818, 63, 8536, 297, 283, 6221, 63, 13522, 418, 503, 488, 267, 8388, 1072, 4931, 340, 1124, 3029, 1199, 1040, 365, 1625, 13, 2930, 503, 267, 2951, 314, 5226, 1423, 340, 1124, 3029, 1199, 1040, 365, 282, 267, 3211, 4252, 14, 339, 408, 272, 1104, 63, 15478, 63, 1267, 8, 89, 63, 2052, 12, 612, 63, 5991, 9, 272, 612, 63, 2052, 275, 1104, 63, 1144, 8, 89, 63, 2052, 12, 4868, 63, 18, 68, 29, 797, 9, 272, 612, 63, 5991, 275, 1104, 63, 1144, 8, 89, 63, 5991, 12, 4868, 63, 18, 68, 29, 797, 9, 339, 340, 612, 63, 2052, 14, 8322, 508, 413, 26, 267, 612, 63, 2052, 275, 612, 63, 2052, 14, 5217, 18138, 17, 12, 413, 430, 339, 340, 612, 63, 5991, 14, 8322, 508, 413, 26, 267, 612, 63, 5991, 275, 612, 63, 5991, 14, 5217, 18138, 17, 12, 413, 430, 339, 340, 612, 63, 2052, 14, 1392, 59, 17, 61, 1137, 612, 63, 5991, 14, 1392, 59, 17, 2189, 267, 746, 1722, 480, 89, 63, 2052, 436, 612, 63, 5991, 1172, 3365, 1329, 402, 1072, 298, 586, 298, 2561, 16, 93, 1111, 91, 17, 25974, 908, 8, 89, 63, 2052, 14, 1392, 59, 17, 467, 612, 63, 5991, 14, 1392, 59, 17, 2459, 339, 302, 63, 4467, 275, 612, 63, 2052, 14, 1392, 59, 17, 61, 272, 3510, 1199, 63, 1419, 275, 334, 403, 12, 283, 1773, 63, 1459, 297, 283, 8830, 63, 8536, 297, 2574, 283, 6221, 63, 13522, 358, 272, 340, 3510, 1199, 440, 315, 3510, 1199, 63, 1419, 26, 267, 3510, 1199, 275, 1104, 63, 1144, 8, 3029, 1199, 12, 4868, 63, 18, 68, 29, 797, 9, 267, 340, 302, 63, 4467, 508, 413, 26, 288, 746, 1722, 480, 7223, 4931, 787, 2997, 1454, 315, 298, 2490, 298, 3029, 13, 1199, 5560, 2685, 267, 916, 302, 63, 4467, 1137, 822, 8, 3029, 1199, 304, 288, 746, 1722, 9313, 10924, 1471, 506, 11960, 1183, 5002, 3537, 4931, 298, 2892, 26448, 68, 9, 465, 4704, 4366, 68, 26744, 450, 2490, 334, 552, 8, 3029, 1199, 395, 302, 63, 4467, 430, 272, 612, 63, 466, 275, 283, 23458, 7, 340, 302, 63, 4467, 508, 413, 587, 283, 23458, 13, 3029, 1199, 7, 339, 372, 612, 63, 466, 12, 612, 63, 2052, 12, 612, 63, 5991, 12, 3510, 1199, 421, 199, 318, 4615, 63, 6116, 63, 705, 8, 89, 63, 2052, 12, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dkodnik/arp
addons/sale_journal/__openerp__.py
119
2670
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## { 'name': 'Invoicing Journals', 'version': '1.0', 'category': 'Sales Management', 'description': """ The sales journal modules allows you to categorise your sales and deliveries (picking lists) between different journals. ======================================================================================================================== This module is very helpful for bigger companies that works by departments. You can use journal for different purposes, some examples: ---------------------------------------------------------- * isolate sales of different departments * journals for deliveries by truck or by UPS Journals have a responsible and evolves between different status: ----------------------------------------------------------------- * draft, open, cancel, done. Batch operations can be processed on the different journals to confirm all sales at once, to validate or invoice packing. It also supports batch invoicing methods that can be configured by partners and sales orders, examples: ------------------------------------------------------------------------------------------------------- * daily invoicing * monthly invoicing Some statistics by journals are provided. """, 'author': 'OpenERP SA', 'website': 'http://www.openerp.com', 'images': ['images/invoice_type.jpeg'], 'depends': ['sale_stock'], 'data': [ 'security/ir.model.access.csv', 'sale_journal_view.xml', 'sale_journal_data.xml' ], 'demo': ['sale_journal_demo.xml'], 'test': [ ], 'installable': True, 'auto_install': False, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 91, 272, 283, 354, 356, 283, 607, 2392, 31713, 7135, 31212, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 18220, 8259, 297, 272, 283, 1802, 356, 408, 199, 1918, 21702, 9605, 4621, 6127, 1265, 370, 7737, 269, 572, 2195, 21702, 436, 28503, 1500, 334, 11463, 5548, 9, 3382, 3365, 5225, 31212, 14, 199, 5695, 12813, 763, 199, 199, 2765, 859, 365, 7437, 24606, 367, 29416, 1013, 23461, 626, 5419, 701, 21124, 1470, 14, 199, 199, 5556, 883, 675, 9605, 367, 3365, 12901, 12, 2005, 7251, 26, 199, 6489, 9460, 272, 627, 365, 16288, 21702, 402, 3365, 21124, 1470, 272, 627, 5225, 31212, 367, 28503, 1500, 701, 5651, 10112, 503, 701, 738, 5067, 199, 199, 5691, 31212, 1172, 282, 17845, 436, 325, 5650, 2310, 3382, 3365, 2004, 26, 199, 3606, 13, 272, 627, 11872, 12, 1551, 12, 9311, 12, 4224, 14, 199, 199, 8842, 5331, 883, 506, 7686, 641, 314, 3365, 5225, 31212, 370, 12679, 1006, 21702, 199, 292, 5403, 12, 370, 4107, 503, 8485, 1706, 316, 14, 199, 199, 7940, 2597, 5171, 3522, 315, 2392, 31713, 3102, 626, 883, 506, 7526, 701, 18943, 436, 21702, 15460, 12, 7251, 26, 199, 3606, 1444, 12797, 272, 627, 26122, 315, 2392, 31713, 272, 627, 5794, 590, 315, 2392, 31713, 199, 199, 7700, 11076, 701, 5225, 31212, 787, 2741, 14, 272, 10327, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 4782, 356, 788, 4782, 15, 5404, 63, 466, 14, 14230, 995, 272, 283, 8912, 356, 788, 8515, 63, 6088, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 8515, 63, 7067, 63, 1345, 14, 1652, 297, 267, 283, 8515, 63, 7067, 63, 576, 14, 1652, 7, 272, 2156, 272, 283, 8768, 356, 788, 8515, 63, 7067, 63, 8768, 14, 1652, 995, 272, 283, 396, 356, 359, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 91, 272, 283, 354, 356, 283, 607, 2392, 31713, 7135, 31212, 297, 272, 283, 1023, 356, 283, 17, 14, 16, 297, 272, 283, 3710, 356, 283, 18220, 8259, 297, 272, 283, 1802, 356, 408, 199, 1918, 21702, 9605, 4621, 6127, 1265, 370, 7737, 269, 572, 2195, 21702, 436, 28503, 1500, 334, 11463, 5548, 9, 3382, 3365, 5225, 31212, 14, 199, 5695, 12813, 763, 199, 199, 2765, 859, 365, 7437, 24606, 367, 29416, 1013, 23461, 626, 5419, 701, 21124, 1470, 14, 199, 199, 5556, 883, 675, 9605, 367, 3365, 12901, 12, 2005, 7251, 26, 199, 6489, 9460, 272, 627, 365, 16288, 21702, 402, 3365, 21124, 1470, 272, 627, 5225, 31212, 367, 28503, 1500, 701, 5651, 10112, 503, 701, 738, 5067, 199, 199, 5691, 31212, 1172, 282, 17845, 436, 325, 5650, 2310, 3382, 3365, 2004, 26, 199, 3606, 13, 272, 627, 11872, 12, 1551, 12, 9311, 12, 4224, 14, 199, 199, 8842, 5331, 883, 506, 7686, 641, 314, 3365, 5225, 31212, 370, 12679, 1006, 21702, 199, 292, 5403, 12, 370, 4107, 503, 8485, 1706, 316, 14, 199, 199, 7940, 2597, 5171, 3522, 315, 2392, 31713, 3102, 626, 883, 506, 7526, 701, 18943, 436, 21702, 15460, 12, 7251, 26, 199, 3606, 1444, 12797, 272, 627, 26122, 315, 2392, 31713, 272, 627, 5794, 590, 315, 2392, 31713, 199, 199, 7700, 11076, 701, 5225, 31212, 787, 2741, 14, 272, 10327, 272, 283, 2502, 356, 283, 25347, 13950, 297, 272, 283, 7360, 356, 283, 1014, 921, 1544, 14, 11267, 14, 957, 297, 272, 283, 4782, 356, 788, 4782, 15, 5404, 63, 466, 14, 14230, 995, 272, 283, 8912, 356, 788, 8515, 63, 6088, 995, 272, 283, 576, 356, 359, 267, 283, 4416, 15, 723, 14, 1238, 14, 2732, 14, 4737, 297, 267, 283, 8515, 63, 7067, 63, 1345, 14, 1652, 297, 267, 283, 8515, 63, 7067, 63, 576, 14, 1652, 7, 272, 2156, 272, 283, 8768, 356, 788, 8515, 63, 7067, 63, 8768, 14, 1652, 995, 272, 283, 396, 356, 359, 2156, 272, 283, 21762, 356, 715, 12, 272, 283, 2495, 63, 3174, 356, 756, 12, 199, 93, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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if_equal.py
368
9892
from django.test import SimpleTestCase from ..utils import setup class IfEqualTagTests(SimpleTestCase): @setup({'ifequal01': '{% ifequal a b %}yes{% endifequal %}'}) def test_ifequal01(self): output = self.engine.render_to_string('ifequal01', {'a': 1, 'b': 2}) self.assertEqual(output, '') @setup({'ifequal02': '{% ifequal a b %}yes{% endifequal %}'}) def test_ifequal02(self): output = self.engine.render_to_string('ifequal02', {'a': 1, 'b': 1}) self.assertEqual(output, 'yes') @setup({'ifequal03': '{% ifequal a b %}yes{% else %}no{% endifequal %}'}) def test_ifequal03(self): output = self.engine.render_to_string('ifequal03', {'a': 1, 'b': 2}) self.assertEqual(output, 'no') @setup({'ifequal04': '{% ifequal a b %}yes{% else %}no{% endifequal %}'}) def test_ifequal04(self): output = self.engine.render_to_string('ifequal04', {'a': 1, 'b': 1}) self.assertEqual(output, 'yes') @setup({'ifequal05': '{% ifequal a \'test\' %}yes{% else %}no{% endifequal %}'}) def test_ifequal05(self): output = self.engine.render_to_string('ifequal05', {'a': 'test'}) self.assertEqual(output, 'yes') @setup({'ifequal06': '{% ifequal a \'test\' %}yes{% else %}no{% endifequal %}'}) def test_ifequal06(self): output = self.engine.render_to_string('ifequal06', {'a': 'no'}) self.assertEqual(output, 'no') @setup({'ifequal07': '{% ifequal a "test" %}yes{% else %}no{% endifequal %}'}) def test_ifequal07(self): output = self.engine.render_to_string('ifequal07', {'a': 'test'}) self.assertEqual(output, 'yes') @setup({'ifequal08': '{% ifequal a "test" %}yes{% else %}no{% endifequal %}'}) def test_ifequal08(self): output = self.engine.render_to_string('ifequal08', {'a': 'no'}) self.assertEqual(output, 'no') @setup({'ifequal09': '{% ifequal a "test" %}yes{% else %}no{% endifequal %}'}) def test_ifequal09(self): output = self.engine.render_to_string('ifequal09') self.assertEqual(output, 'no') @setup({'ifequal10': '{% ifequal a b %}yes{% else %}no{% endifequal %}'}) def test_ifequal10(self): output = self.engine.render_to_string('ifequal10') self.assertEqual(output, 'yes') # SMART SPLITTING @setup({'ifequal-split01': '{% ifequal a "test man" %}yes{% else %}no{% endifequal %}'}) def test_ifequal_split01(self): output = self.engine.render_to_string('ifequal-split01') self.assertEqual(output, 'no') @setup({'ifequal-split02': '{% ifequal a "test man" %}yes{% else %}no{% endifequal %}'}) def test_ifequal_split02(self): output = self.engine.render_to_string('ifequal-split02', {'a': 'foo'}) self.assertEqual(output, 'no') @setup({'ifequal-split03': '{% ifequal a "test man" %}yes{% else %}no{% endifequal %}'}) def test_ifequal_split03(self): output = self.engine.render_to_string('ifequal-split03', {'a': 'test man'}) self.assertEqual(output, 'yes') @setup({'ifequal-split04': '{% ifequal a \'test man\' %}yes{% else %}no{% endifequal %}'}) def test_ifequal_split04(self): output = self.engine.render_to_string('ifequal-split04', {'a': 'test man'}) self.assertEqual(output, 'yes') @setup({'ifequal-split05': '{% ifequal a \'i "love" you\' %}yes{% else %}no{% endifequal %}'}) def test_ifequal_split05(self): output = self.engine.render_to_string('ifequal-split05', {'a': ''}) self.assertEqual(output, 'no') @setup({'ifequal-split06': '{% ifequal a \'i "love" you\' %}yes{% else %}no{% endifequal %}'}) def test_ifequal_split06(self): output = self.engine.render_to_string('ifequal-split06', {'a': 'i "love" you'}) self.assertEqual(output, 'yes') @setup({'ifequal-split07': '{% ifequal a \'i "love" you\' %}yes{% else %}no{% endifequal %}'}) def test_ifequal_split07(self): output = self.engine.render_to_string('ifequal-split07', {'a': 'i love you'}) self.assertEqual(output, 'no') @setup({'ifequal-split08': r"{% ifequal a 'I\'m happy' %}yes{% else %}no{% endifequal %}"}) def test_ifequal_split08(self): output = self.engine.render_to_string('ifequal-split08', {'a': "I'm happy"}) self.assertEqual(output, 'yes') @setup({'ifequal-split09': r"{% ifequal a 'slash\man' %}yes{% else %}no{% endifequal %}"}) def test_ifequal_split09(self): output = self.engine.render_to_string('ifequal-split09', {'a': 'slash\man'}) self.assertEqual(output, 'yes') @setup({'ifequal-split10': r"{% ifequal a 'slash\man' %}yes{% else %}no{% endifequal %}"}) def test_ifequal_split10(self): output = self.engine.render_to_string('ifequal-split10', {'a': 'slashman'}) self.assertEqual(output, 'no') # NUMERIC RESOLUTION @setup({'ifequal-numeric01': '{% ifequal x 5 %}yes{% endifequal %}'}) def test_ifequal_numeric01(self): output = self.engine.render_to_string('ifequal-numeric01', {'x': '5'}) self.assertEqual(output, '') @setup({'ifequal-numeric02': '{% ifequal x 5 %}yes{% endifequal %}'}) def test_ifequal_numeric02(self): output = self.engine.render_to_string('ifequal-numeric02', {'x': 5}) self.assertEqual(output, 'yes') @setup({'ifequal-numeric03': '{% ifequal x 5.2 %}yes{% endifequal %}'}) def test_ifequal_numeric03(self): output = self.engine.render_to_string('ifequal-numeric03', {'x': 5}) self.assertEqual(output, '') @setup({'ifequal-numeric04': '{% ifequal x 5.2 %}yes{% endifequal %}'}) def test_ifequal_numeric04(self): output = self.engine.render_to_string('ifequal-numeric04', {'x': 5.2}) self.assertEqual(output, 'yes') @setup({'ifequal-numeric05': '{% ifequal x 0.2 %}yes{% endifequal %}'}) def test_ifequal_numeric05(self): output = self.engine.render_to_string('ifequal-numeric05', {'x': 0.2}) self.assertEqual(output, 'yes') @setup({'ifequal-numeric06': '{% ifequal x .2 %}yes{% endifequal %}'}) def test_ifequal_numeric06(self): output = self.engine.render_to_string('ifequal-numeric06', {'x': 0.2}) self.assertEqual(output, 'yes') @setup({'ifequal-numeric07': '{% ifequal x 2. %}yes{% endifequal %}'}) def test_ifequal_numeric07(self): output = self.engine.render_to_string('ifequal-numeric07', {'x': 2}) self.assertEqual(output, '') @setup({'ifequal-numeric08': '{% ifequal x "5" %}yes{% endifequal %}'}) def test_ifequal_numeric08(self): output = self.engine.render_to_string('ifequal-numeric08', {'x': 5}) self.assertEqual(output, '') @setup({'ifequal-numeric09': '{% ifequal x "5" %}yes{% endifequal %}'}) def test_ifequal_numeric09(self): output = self.engine.render_to_string('ifequal-numeric09', {'x': '5'}) self.assertEqual(output, 'yes') @setup({'ifequal-numeric10': '{% ifequal x -5 %}yes{% endifequal %}'}) def test_ifequal_numeric10(self): output = self.engine.render_to_string('ifequal-numeric10', {'x': -5}) self.assertEqual(output, 'yes') @setup({'ifequal-numeric11': '{% ifequal x -5.2 %}yes{% endifequal %}'}) def test_ifequal_numeric11(self): output = self.engine.render_to_string('ifequal-numeric11', {'x': -5.2}) self.assertEqual(output, 'yes') @setup({'ifequal-numeric12': '{% ifequal x +5 %}yes{% endifequal %}'}) def test_ifequal_numeric12(self): output = self.engine.render_to_string('ifequal-numeric12', {'x': 5}) self.assertEqual(output, 'yes') # FILTER EXPRESSIONS AS ARGUMENTS @setup({'ifequal-filter01': '{% ifequal a|upper "A" %}x{% endifequal %}'}) def test_ifequal_filter01(self): output = self.engine.render_to_string('ifequal-filter01', {'a': 'a'}) self.assertEqual(output, 'x') @setup({'ifequal-filter02': '{% ifequal "A" a|upper %}x{% endifequal %}'}) def test_ifequal_filter02(self): output = self.engine.render_to_string('ifequal-filter02', {'a': 'a'}) self.assertEqual(output, 'x') @setup({'ifequal-filter03': '{% ifequal a|upper b|upper %}x{% endifequal %}'}) def test_ifequal_filter03(self): output = self.engine.render_to_string('ifequal-filter03', {'a': 'x', 'b': 'X'}) self.assertEqual(output, 'x') @setup({'ifequal-filter04': '{% ifequal x|slice:"1" "a" %}x{% endifequal %}'}) def test_ifequal_filter04(self): output = self.engine.render_to_string('ifequal-filter04', {'x': 'aaa'}) self.assertEqual(output, 'x') @setup({'ifequal-filter05': '{% ifequal x|slice:"1"|upper "A" %}x{% endifequal %}'}) def test_ifequal_filter05(self): output = self.engine.render_to_string('ifequal-filter05', {'x': 'aaa'}) self.assertEqual(output, 'x') class IfNotEqualTagTests(SimpleTestCase): @setup({'ifnotequal01': '{% ifnotequal a b %}yes{% endifnotequal %}'}) def test_ifnotequal01(self): output = self.engine.render_to_string('ifnotequal01', {'a': 1, 'b': 2}) self.assertEqual(output, 'yes') @setup({'ifnotequal02': '{% ifnotequal a b %}yes{% endifnotequal %}'}) def test_ifnotequal02(self): output = self.engine.render_to_string('ifnotequal02', {'a': 1, 'b': 1}) self.assertEqual(output, '') @setup({'ifnotequal03': '{% ifnotequal a b %}yes{% else %}no{% endifnotequal %}'}) def test_ifnotequal03(self): output = self.engine.render_to_string('ifnotequal03', {'a': 1, 'b': 2}) self.assertEqual(output, 'yes') @setup({'ifnotequal04': '{% ifnotequal a b %}yes{% else %}no{% endifnotequal %}'}) def test_ifnotequal04(self): output = self.engine.render_to_string('ifnotequal04', {'a': 1, 'b': 1}) self.assertEqual(output, 'no')
bsd-3-clause
[ 504, 1639, 14, 396, 492, 24424, 199, 199, 504, 2508, 1208, 492, 3272, 421, 199, 533, 982, 591, 1931, 2925, 8, 17968, 304, 339, 768, 2758, 3252, 692, 1452, 614, 356, 12100, 340, 1452, 282, 330, 3674, 5066, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 614, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 614, 297, 791, 65, 356, 413, 12, 283, 66, 356, 499, 1552, 267, 291, 14, 629, 8, 1199, 12, 4074, 339, 768, 2758, 3252, 692, 1452, 996, 356, 12100, 340, 1452, 282, 330, 3674, 5066, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 996, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 996, 297, 791, 65, 356, 413, 12, 283, 66, 356, 413, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 768, 2758, 3252, 692, 1452, 1644, 356, 12100, 340, 1452, 282, 330, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 1644, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 1644, 297, 791, 65, 356, 413, 12, 283, 66, 356, 499, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 889, 358, 339, 768, 2758, 3252, 692, 1452, 966, 356, 12100, 340, 1452, 282, 330, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 966, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 966, 297, 791, 65, 356, 413, 12, 283, 66, 356, 413, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 768, 2758, 3252, 692, 1452, 1717, 356, 12100, 340, 1452, 282, 8891, 396, 3985, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 1717, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 1717, 297, 791, 65, 356, 283, 396, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 768, 2758, 3252, 692, 1452, 1690, 356, 12100, 340, 1452, 282, 8891, 396, 3985, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 1690, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 1690, 297, 791, 65, 356, 283, 889, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 889, 358, 339, 768, 2758, 3252, 692, 1452, 1780, 356, 12100, 340, 1452, 282, 298, 396, 2, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 1780, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 1780, 297, 791, 65, 356, 283, 396, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 768, 2758, 3252, 692, 1452, 2036, 356, 12100, 340, 1452, 282, 298, 396, 2, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 2036, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 2036, 297, 791, 65, 356, 283, 889, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 889, 358, 339, 768, 2758, 3252, 692, 1452, 1643, 356, 12100, 340, 1452, 282, 298, 396, 2, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 1643, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 1643, 358, 267, 291, 14, 629, 8, 1199, 12, 283, 889, 358, 339, 768, 2758, 3252, 692, 1452, 709, 356, 12100, 340, 1452, 282, 330, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 709, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 709, 358, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 327, 2389, 2294, 428, 2749, 20779, 1206, 272, 768, 2758, 3252, 692, 1452, 13, 1294, 614, 356, 12100, 340, 1452, 282, 298, 396, 2169, 2, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 63, 1294, 614, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 13, 1294, 614, 358, 267, 291, 14, 629, 8, 1199, 12, 283, 889, 358, 339, 768, 2758, 3252, 692, 1452, 13, 1294, 996, 356, 12100, 340, 1452, 282, 298, 396, 2169, 2, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 63, 1294, 996, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 13, 1294, 996, 297, 791, 65, 356, 283, 1421, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 889, 358, 339, 768, 2758, 3252, 692, 1452, 13, 1294, 1644, 356, 12100, 340, 1452, 282, 298, 396, 2169, 2, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 63, 1294, 1644, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 13, 1294, 1644, 297, 791, 65, 356, 283, 396, 2169, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 768, 2758, 3252, 692, 1452, 13, 1294, 966, 356, 12100, 340, 1452, 282, 8891, 396, 2169, 3985, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 63, 1294, 966, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 13, 1294, 966, 297, 791, 65, 356, 283, 396, 2169, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 768, 2758, 3252, 692 ]
[ 1639, 14, 396, 492, 24424, 199, 199, 504, 2508, 1208, 492, 3272, 421, 199, 533, 982, 591, 1931, 2925, 8, 17968, 304, 339, 768, 2758, 3252, 692, 1452, 614, 356, 12100, 340, 1452, 282, 330, 3674, 5066, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 614, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 614, 297, 791, 65, 356, 413, 12, 283, 66, 356, 499, 1552, 267, 291, 14, 629, 8, 1199, 12, 4074, 339, 768, 2758, 3252, 692, 1452, 996, 356, 12100, 340, 1452, 282, 330, 3674, 5066, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 996, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 996, 297, 791, 65, 356, 413, 12, 283, 66, 356, 413, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 768, 2758, 3252, 692, 1452, 1644, 356, 12100, 340, 1452, 282, 330, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 1644, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 1644, 297, 791, 65, 356, 413, 12, 283, 66, 356, 499, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 889, 358, 339, 768, 2758, 3252, 692, 1452, 966, 356, 12100, 340, 1452, 282, 330, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 966, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 966, 297, 791, 65, 356, 413, 12, 283, 66, 356, 413, 1552, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 768, 2758, 3252, 692, 1452, 1717, 356, 12100, 340, 1452, 282, 8891, 396, 3985, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 1717, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 1717, 297, 791, 65, 356, 283, 396, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 768, 2758, 3252, 692, 1452, 1690, 356, 12100, 340, 1452, 282, 8891, 396, 3985, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 1690, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 1690, 297, 791, 65, 356, 283, 889, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 889, 358, 339, 768, 2758, 3252, 692, 1452, 1780, 356, 12100, 340, 1452, 282, 298, 396, 2, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 1780, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 1780, 297, 791, 65, 356, 283, 396, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 768, 2758, 3252, 692, 1452, 2036, 356, 12100, 340, 1452, 282, 298, 396, 2, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 2036, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 2036, 297, 791, 65, 356, 283, 889, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 889, 358, 339, 768, 2758, 3252, 692, 1452, 1643, 356, 12100, 340, 1452, 282, 298, 396, 2, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 1643, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 1643, 358, 267, 291, 14, 629, 8, 1199, 12, 283, 889, 358, 339, 768, 2758, 3252, 692, 1452, 709, 356, 12100, 340, 1452, 282, 330, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 709, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 709, 358, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 327, 2389, 2294, 428, 2749, 20779, 1206, 272, 768, 2758, 3252, 692, 1452, 13, 1294, 614, 356, 12100, 340, 1452, 282, 298, 396, 2169, 2, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 63, 1294, 614, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 13, 1294, 614, 358, 267, 291, 14, 629, 8, 1199, 12, 283, 889, 358, 339, 768, 2758, 3252, 692, 1452, 13, 1294, 996, 356, 12100, 340, 1452, 282, 298, 396, 2169, 2, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 63, 1294, 996, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 13, 1294, 996, 297, 791, 65, 356, 283, 1421, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 889, 358, 339, 768, 2758, 3252, 692, 1452, 13, 1294, 1644, 356, 12100, 340, 1452, 282, 298, 396, 2169, 2, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 63, 1294, 1644, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 13, 1294, 1644, 297, 791, 65, 356, 283, 396, 2169, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 768, 2758, 3252, 692, 1452, 13, 1294, 966, 356, 12100, 340, 1452, 282, 8891, 396, 2169, 3985, 3674, 5066, 3996, 587, 3674, 889, 3996, 655, 328, 771, 537, 17776, 272, 347, 511, 63, 692, 1452, 63, 1294, 966, 8, 277, 304, 267, 1072, 275, 291, 14, 3908, 14, 3352, 63, 475, 63, 875, 360, 692, 1452, 13, 1294, 966, 297, 791, 65, 356, 283, 396, 2169, 3071, 267, 291, 14, 629, 8, 1199, 12, 283, 5066, 358, 339, 768, 2758, 3252, 692, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
kanagasabapathi/python-for-android
python3-alpha/python3-src/Lib/test/test_unicode.py
46
70367
""" Test script for the Unicode implementation. Written by Marc-Andre Lemburg (mal@lemburg.com). (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. """#" import codecs import struct import sys import unittest import warnings from test import support, string_tests import _string # Error handling (bad decoder return) def search_function(encoding): def decode1(input, errors="strict"): return 42 # not a tuple def encode1(input, errors="strict"): return 42 # not a tuple def encode2(input, errors="strict"): return (42, 42) # no unicode def decode2(input, errors="strict"): return (42, 42) # no unicode if encoding=="test.unicode1": return (encode1, decode1, None, None) elif encoding=="test.unicode2": return (encode2, decode2, None, None) else: return None codecs.register(search_function) class UnicodeTest(string_tests.CommonTest, string_tests.MixinStrUnicodeUserStringTest, string_tests.MixinStrUnicodeTest): type2test = str def checkequalnofix(self, result, object, methodname, *args): method = getattr(object, methodname) realresult = method(*args) self.assertEqual(realresult, result) self.assertTrue(type(realresult) is type(result)) # if the original is returned make sure that # this doesn't happen with subclasses if realresult is object: class usub(str): def __repr__(self): return 'usub(%r)' % str.__repr__(self) object = usub(object) method = getattr(object, methodname) realresult = method(*args) self.assertEqual(realresult, result) self.assertTrue(object is not realresult) def test_literals(self): self.assertEqual('\xff', '\u00ff') self.assertEqual('\uffff', '\U0000ffff') self.assertRaises(SyntaxError, eval, '\'\\Ufffffffe\'') self.assertRaises(SyntaxError, eval, '\'\\Uffffffff\'') self.assertRaises(SyntaxError, eval, '\'\\U%08x\'' % 0x110000) # raw strings should not have unicode escapes self.assertNotEqual(r"\u0020", " ") def test_ascii(self): if not sys.platform.startswith('java'): # Test basic sanity of repr() self.assertEqual(ascii('abc'), "'abc'") self.assertEqual(ascii('ab\\c'), "'ab\\\\c'") self.assertEqual(ascii('ab\\'), "'ab\\\\'") self.assertEqual(ascii('\\c'), "'\\\\c'") self.assertEqual(ascii('\\'), "'\\\\'") self.assertEqual(ascii('\n'), "'\\n'") self.assertEqual(ascii('\r'), "'\\r'") self.assertEqual(ascii('\t'), "'\\t'") self.assertEqual(ascii('\b'), "'\\x08'") self.assertEqual(ascii("'\""), """'\\'"'""") self.assertEqual(ascii("'\""), """'\\'"'""") self.assertEqual(ascii("'"), '''"'"''') self.assertEqual(ascii('"'), """'"'""") latin1repr = ( "'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r" "\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a" "\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&\\'()*+,-./0123456789:;<=>?@ABCDEFGHI" "JKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x7f" "\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d" "\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b" "\\x9c\\x9d\\x9e\\x9f\\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9" "\\xaa\\xab\\xac\\xad\\xae\\xaf\\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7" "\\xb8\\xb9\\xba\\xbb\\xbc\\xbd\\xbe\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5" "\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3" "\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1" "\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef" "\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd" "\\xfe\\xff'") testrepr = ascii(''.join(map(chr, range(256)))) self.assertEqual(testrepr, latin1repr) # Test ascii works on wide unicode escapes without overflow. self.assertEqual(ascii("\U00010000" * 39 + "\uffff" * 4096), ascii("\U00010000" * 39 + "\uffff" * 4096)) class WrongRepr: def __repr__(self): return b'byte-repr' self.assertRaises(TypeError, ascii, WrongRepr()) def test_repr(self): if not sys.platform.startswith('java'): # Test basic sanity of repr() self.assertEqual(repr('abc'), "'abc'") self.assertEqual(repr('ab\\c'), "'ab\\\\c'") self.assertEqual(repr('ab\\'), "'ab\\\\'") self.assertEqual(repr('\\c'), "'\\\\c'") self.assertEqual(repr('\\'), "'\\\\'") self.assertEqual(repr('\n'), "'\\n'") self.assertEqual(repr('\r'), "'\\r'") self.assertEqual(repr('\t'), "'\\t'") self.assertEqual(repr('\b'), "'\\x08'") self.assertEqual(repr("'\""), """'\\'"'""") self.assertEqual(repr("'\""), """'\\'"'""") self.assertEqual(repr("'"), '''"'"''') self.assertEqual(repr('"'), """'"'""") latin1repr = ( "'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r" "\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a" "\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&\\'()*+,-./0123456789:;<=>?@ABCDEFGHI" "JKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x7f" "\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d" "\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b" "\\x9c\\x9d\\x9e\\x9f\\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9" "\xaa\xab\xac\\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7" "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5" "\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3" "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1" "\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef" "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd" "\xfe\xff'") testrepr = repr(''.join(map(chr, range(256)))) self.assertEqual(testrepr, latin1repr) # Test repr works on wide unicode escapes without overflow. self.assertEqual(repr("\U00010000" * 39 + "\uffff" * 4096), repr("\U00010000" * 39 + "\uffff" * 4096)) class WrongRepr: def __repr__(self): return b'byte-repr' self.assertRaises(TypeError, repr, WrongRepr()) def test_iterators(self): # Make sure unicode objects have an __iter__ method it = "\u1111\u2222\u3333".__iter__() self.assertEqual(next(it), "\u1111") self.assertEqual(next(it), "\u2222") self.assertEqual(next(it), "\u3333") self.assertRaises(StopIteration, next, it) def test_count(self): string_tests.CommonTest.test_count(self) # check mixed argument types self.checkequalnofix(3, 'aaa', 'count', 'a') self.checkequalnofix(0, 'aaa', 'count', 'b') self.checkequalnofix(3, 'aaa', 'count', 'a') self.checkequalnofix(0, 'aaa', 'count', 'b') self.checkequalnofix(0, 'aaa', 'count', 'b') self.checkequalnofix(1, 'aaa', 'count', 'a', -1) self.checkequalnofix(3, 'aaa', 'count', 'a', -10) self.checkequalnofix(2, 'aaa', 'count', 'a', 0, -1) self.checkequalnofix(0, 'aaa', 'count', 'a', 0, -10) def test_find(self): self.checkequalnofix(0, 'abcdefghiabc', 'find', 'abc') self.checkequalnofix(9, 'abcdefghiabc', 'find', 'abc', 1) self.checkequalnofix(-1, 'abcdefghiabc', 'find', 'def', 4) self.assertRaises(TypeError, 'hello'.find) self.assertRaises(TypeError, 'hello'.find, 42) def test_rfind(self): string_tests.CommonTest.test_rfind(self) # check mixed argument types self.checkequalnofix(9, 'abcdefghiabc', 'rfind', 'abc') self.checkequalnofix(12, 'abcdefghiabc', 'rfind', '') self.checkequalnofix(12, 'abcdefghiabc', 'rfind', '') def test_index(self): string_tests.CommonTest.test_index(self) self.checkequalnofix(0, 'abcdefghiabc', 'index', '') self.checkequalnofix(3, 'abcdefghiabc', 'index', 'def') self.checkequalnofix(0, 'abcdefghiabc', 'index', 'abc') self.checkequalnofix(9, 'abcdefghiabc', 'index', 'abc', 1) self.assertRaises(ValueError, 'abcdefghiabc'.index, 'hib') self.assertRaises(ValueError, 'abcdefghiab'.index, 'abc', 1) self.assertRaises(ValueError, 'abcdefghi'.index, 'ghi', 8) self.assertRaises(ValueError, 'abcdefghi'.index, 'ghi', -1) def test_rindex(self): string_tests.CommonTest.test_rindex(self) self.checkequalnofix(12, 'abcdefghiabc', 'rindex', '') self.checkequalnofix(3, 'abcdefghiabc', 'rindex', 'def') self.checkequalnofix(9, 'abcdefghiabc', 'rindex', 'abc') self.checkequalnofix(0, 'abcdefghiabc', 'rindex', 'abc', 0, -1) self.assertRaises(ValueError, 'abcdefghiabc'.rindex, 'hib') self.assertRaises(ValueError, 'defghiabc'.rindex, 'def', 1) self.assertRaises(ValueError, 'defghiabc'.rindex, 'abc', 0, -1) self.assertRaises(ValueError, 'abcdefghi'.rindex, 'ghi', 0, 8) self.assertRaises(ValueError, 'abcdefghi'.rindex, 'ghi', 0, -1) def test_maketrans_translate(self): # these work with plain translate() self.checkequalnofix('bbbc', 'abababc', 'translate', {ord('a'): None}) self.checkequalnofix('iiic', 'abababc', 'translate', {ord('a'): None, ord('b'): ord('i')}) self.checkequalnofix('iiix', 'abababc', 'translate', {ord('a'): None, ord('b'): ord('i'), ord('c'): 'x'}) self.checkequalnofix('c', 'abababc', 'translate', {ord('a'): None, ord('b'): ''}) self.checkequalnofix('xyyx', 'xzx', 'translate', {ord('z'): 'yy'}) # this needs maketrans() self.checkequalnofix('abababc', 'abababc', 'translate', {'b': '<i>'}) tbl = self.type2test.maketrans({'a': None, 'b': '<i>'}) self.checkequalnofix('<i><i><i>c', 'abababc', 'translate', tbl) # test alternative way of calling maketrans() tbl = self.type2test.maketrans('abc', 'xyz', 'd') self.checkequalnofix('xyzzy', 'abdcdcbdddd', 'translate', tbl) self.assertRaises(TypeError, self.type2test.maketrans) self.assertRaises(ValueError, self.type2test.maketrans, 'abc', 'defg') self.assertRaises(TypeError, self.type2test.maketrans, 2, 'def') self.assertRaises(TypeError, self.type2test.maketrans, 'abc', 2) self.assertRaises(TypeError, self.type2test.maketrans, 'abc', 'def', 2) self.assertRaises(ValueError, self.type2test.maketrans, {'xy': 2}) self.assertRaises(TypeError, self.type2test.maketrans, {(1,): 2}) self.assertRaises(TypeError, 'hello'.translate) self.assertRaises(TypeError, 'abababc'.translate, 'abc', 'xyz') def test_split(self): string_tests.CommonTest.test_split(self) # Mixed arguments self.checkequalnofix(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//') self.checkequalnofix(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//') self.checkequalnofix(['endcase ', ''], 'endcase test', 'split', 'test') def test_join(self): string_tests.MixinStrUnicodeUserStringTest.test_join(self) class MyWrapper: def __init__(self, sval): self.sval = sval def __str__(self): return self.sval # mixed arguments self.checkequalnofix('a b c d', ' ', 'join', ['a', 'b', 'c', 'd']) self.checkequalnofix('abcd', '', 'join', ('a', 'b', 'c', 'd')) self.checkequalnofix('w x y z', ' ', 'join', string_tests.Sequence('wxyz')) self.checkequalnofix('a b c d', ' ', 'join', ['a', 'b', 'c', 'd']) self.checkequalnofix('a b c d', ' ', 'join', ['a', 'b', 'c', 'd']) self.checkequalnofix('abcd', '', 'join', ('a', 'b', 'c', 'd')) self.checkequalnofix('w x y z', ' ', 'join', string_tests.Sequence('wxyz')) self.checkraises(TypeError, ' ', 'join', ['1', '2', MyWrapper('foo')]) self.checkraises(TypeError, ' ', 'join', ['1', '2', '3', bytes()]) self.checkraises(TypeError, ' ', 'join', [1, 2, 3]) self.checkraises(TypeError, ' ', 'join', ['1', '2', 3]) def test_replace(self): string_tests.CommonTest.test_replace(self) # method call forwarded from str implementation because of unicode argument self.checkequalnofix('one@two!three!', 'one!two!three!', 'replace', '!', '@', 1) self.assertRaises(TypeError, 'replace'.replace, "r", 42) def test_bytes_comparison(self): with support.check_warnings(): warnings.simplefilter('ignore', BytesWarning) self.assertEqual('abc' == b'abc', False) self.assertEqual('abc' != b'abc', True) self.assertEqual('abc' == bytearray(b'abc'), False) self.assertEqual('abc' != bytearray(b'abc'), True) def test_comparison(self): # Comparisons: self.assertEqual('abc', 'abc') self.assertTrue('abcd' > 'abc') self.assertTrue('abc' < 'abcd') if 0: # Move these tests to a Unicode collation module test... # Testing UTF-16 code point order comparisons... # No surrogates, no fixup required. self.assertTrue('\u0061' < '\u20ac') # Non surrogate below surrogate value, no fixup required self.assertTrue('\u0061' < '\ud800\udc02') # Non surrogate above surrogate value, fixup required def test_lecmp(s, s2): self.assertTrue(s < s2) def test_fixup(s): s2 = '\ud800\udc01' test_lecmp(s, s2) s2 = '\ud900\udc01' test_lecmp(s, s2) s2 = '\uda00\udc01' test_lecmp(s, s2) s2 = '\udb00\udc01' test_lecmp(s, s2) s2 = '\ud800\udd01' test_lecmp(s, s2) s2 = '\ud900\udd01' test_lecmp(s, s2) s2 = '\uda00\udd01' test_lecmp(s, s2) s2 = '\udb00\udd01' test_lecmp(s, s2) s2 = '\ud800\ude01' test_lecmp(s, s2) s2 = '\ud900\ude01' test_lecmp(s, s2) s2 = '\uda00\ude01' test_lecmp(s, s2) s2 = '\udb00\ude01' test_lecmp(s, s2) s2 = '\ud800\udfff' test_lecmp(s, s2) s2 = '\ud900\udfff' test_lecmp(s, s2) s2 = '\uda00\udfff' test_lecmp(s, s2) s2 = '\udb00\udfff' test_lecmp(s, s2) test_fixup('\ue000') test_fixup('\uff61') # Surrogates on both sides, no fixup required self.assertTrue('\ud800\udc02' < '\ud84d\udc56') def test_islower(self): string_tests.MixinStrUnicodeUserStringTest.test_islower(self) self.checkequalnofix(False, '\u1FFc', 'islower') def test_isupper(self): string_tests.MixinStrUnicodeUserStringTest.test_isupper(self) if not sys.platform.startswith('java'): self.checkequalnofix(False, '\u1FFc', 'isupper') def test_istitle(self): string_tests.MixinStrUnicodeUserStringTest.test_title(self) self.checkequalnofix(True, '\u1FFc', 'istitle') self.checkequalnofix(True, 'Greek \u1FFcitlecases ...', 'istitle') def test_isspace(self): string_tests.MixinStrUnicodeUserStringTest.test_isspace(self) self.checkequalnofix(True, '\u2000', 'isspace') self.checkequalnofix(True, '\u200a', 'isspace') self.checkequalnofix(False, '\u2014', 'isspace') def test_isalpha(self): string_tests.MixinStrUnicodeUserStringTest.test_isalpha(self) self.checkequalnofix(True, '\u1FFc', 'isalpha') def test_isdecimal(self): self.checkequalnofix(False, '', 'isdecimal') self.checkequalnofix(False, 'a', 'isdecimal') self.checkequalnofix(True, '0', 'isdecimal') self.checkequalnofix(False, '\u2460', 'isdecimal') # CIRCLED DIGIT ONE self.checkequalnofix(False, '\xbc', 'isdecimal') # VULGAR FRACTION ONE QUARTER self.checkequalnofix(True, '\u0660', 'isdecimal') # ARABIC-INDIC DIGIT ZERO self.checkequalnofix(True, '0123456789', 'isdecimal') self.checkequalnofix(False, '0123456789a', 'isdecimal') self.checkraises(TypeError, 'abc', 'isdecimal', 42) def test_isdigit(self): string_tests.MixinStrUnicodeUserStringTest.test_isdigit(self) self.checkequalnofix(True, '\u2460', 'isdigit') self.checkequalnofix(False, '\xbc', 'isdigit') self.checkequalnofix(True, '\u0660', 'isdigit') def test_isnumeric(self): self.checkequalnofix(False, '', 'isnumeric') self.checkequalnofix(False, 'a', 'isnumeric') self.checkequalnofix(True, '0', 'isnumeric') self.checkequalnofix(True, '\u2460', 'isnumeric') self.checkequalnofix(True, '\xbc', 'isnumeric') self.checkequalnofix(True, '\u0660', 'isnumeric') self.checkequalnofix(True, '0123456789', 'isnumeric') self.checkequalnofix(False, '0123456789a', 'isnumeric') self.assertRaises(TypeError, "abc".isnumeric, 42) def test_isidentifier(self): self.assertTrue("a".isidentifier()) self.assertTrue("Z".isidentifier()) self.assertTrue("_".isidentifier()) self.assertTrue("b0".isidentifier()) self.assertTrue("bc".isidentifier()) self.assertTrue("b_".isidentifier()) self.assertTrue("µ".isidentifier()) self.assertTrue("𝔘𝔫𝔦𝔠𝔬𝔡𝔢".isidentifier()) self.assertFalse(" ".isidentifier()) self.assertFalse("[".isidentifier()) self.assertFalse("©".isidentifier()) self.assertFalse("0".isidentifier()) def test_isprintable(self): self.assertTrue("".isprintable()) self.assertTrue(" ".isprintable()) self.assertTrue("abcdefg".isprintable()) self.assertFalse("abcdefg\n".isprintable()) # some defined Unicode character self.assertTrue("\u0374".isprintable()) # undefined character self.assertFalse("\u0378".isprintable()) # single surrogate character self.assertFalse("\ud800".isprintable()) def test_contains(self): # Testing Unicode contains method self.assertIn('a', 'abdb') self.assertIn('a', 'bdab') self.assertIn('a', 'bdaba') self.assertIn('a', 'bdba') self.assertNotIn('a', 'bdb') self.assertIn('a', 'bdba') self.assertIn('a', ('a',1,None)) self.assertIn('a', (1,None,'a')) self.assertIn('a', ('a',1,None)) self.assertIn('a', (1,None,'a')) self.assertNotIn('a', ('x',1,'y')) self.assertNotIn('a', ('x',1,None)) self.assertNotIn('abcd', 'abcxxxx') self.assertIn('ab', 'abcd') self.assertIn('ab', 'abc') self.assertIn('ab', (1,None,'ab')) self.assertIn('', 'abc') self.assertIn('', '') self.assertIn('', 'abc') self.assertNotIn('\0', 'abc') self.assertIn('\0', '\0abc') self.assertIn('\0', 'abc\0') self.assertIn('a', '\0abc') self.assertIn('asdf', 'asdf') self.assertNotIn('asdf', 'asd') self.assertNotIn('asdf', '') self.assertRaises(TypeError, "abc".__contains__) def test_format(self): self.assertEqual(''.format(), '') self.assertEqual('a'.format(), 'a') self.assertEqual('ab'.format(), 'ab') self.assertEqual('a{{'.format(), 'a{') self.assertEqual('a}}'.format(), 'a}') self.assertEqual('{{b'.format(), '{b') self.assertEqual('}}b'.format(), '}b') self.assertEqual('a{{b'.format(), 'a{b') # examples from the PEP: import datetime self.assertEqual("My name is {0}".format('Fred'), "My name is Fred") self.assertEqual("My name is {0[name]}".format(dict(name='Fred')), "My name is Fred") self.assertEqual("My name is {0} :-{{}}".format('Fred'), "My name is Fred :-{}") d = datetime.date(2007, 8, 18) self.assertEqual("The year is {0.year}".format(d), "The year is 2007") # classes we'll use for testing class C: def __init__(self, x=100): self._x = x def __format__(self, spec): return spec class D: def __init__(self, x): self.x = x def __format__(self, spec): return str(self.x) # class with __str__, but no __format__ class E: def __init__(self, x): self.x = x def __str__(self): return 'E(' + self.x + ')' # class with __repr__, but no __format__ or __str__ class F: def __init__(self, x): self.x = x def __repr__(self): return 'F(' + self.x + ')' # class with __format__ that forwards to string, for some format_spec's class G: def __init__(self, x): self.x = x def __str__(self): return "string is " + self.x def __format__(self, format_spec): if format_spec == 'd': return 'G(' + self.x + ')' return object.__format__(self, format_spec) class I(datetime.date): def __format__(self, format_spec): return self.strftime(format_spec) class J(int): def __format__(self, format_spec): return int.__format__(self * 2, format_spec) self.assertEqual(''.format(), '') self.assertEqual('abc'.format(), 'abc') self.assertEqual('{0}'.format('abc'), 'abc') self.assertEqual('{0:}'.format('abc'), 'abc') # self.assertEqual('{ 0 }'.format('abc'), 'abc') self.assertEqual('X{0}'.format('abc'), 'Xabc') self.assertEqual('{0}X'.format('abc'), 'abcX') self.assertEqual('X{0}Y'.format('abc'), 'XabcY') self.assertEqual('{1}'.format(1, 'abc'), 'abc') self.assertEqual('X{1}'.format(1, 'abc'), 'Xabc') self.assertEqual('{1}X'.format(1, 'abc'), 'abcX') self.assertEqual('X{1}Y'.format(1, 'abc'), 'XabcY') self.assertEqual('{0}'.format(-15), '-15') self.assertEqual('{0}{1}'.format(-15, 'abc'), '-15abc') self.assertEqual('{0}X{1}'.format(-15, 'abc'), '-15Xabc') self.assertEqual('{{'.format(), '{') self.assertEqual('}}'.format(), '}') self.assertEqual('{{}}'.format(), '{}') self.assertEqual('{{x}}'.format(), '{x}') self.assertEqual('{{{0}}}'.format(123), '{123}') self.assertEqual('{{{{0}}}}'.format(), '{{0}}') self.assertEqual('}}{{'.format(), '}{') self.assertEqual('}}x{{'.format(), '}x{') # weird field names self.assertEqual("{0[foo-bar]}".format({'foo-bar':'baz'}), 'baz') self.assertEqual("{0[foo bar]}".format({'foo bar':'baz'}), 'baz') self.assertEqual("{0[ ]}".format({' ':3}), '3') self.assertEqual('{foo._x}'.format(foo=C(20)), '20') self.assertEqual('{1}{0}'.format(D(10), D(20)), '2010') self.assertEqual('{0._x.x}'.format(C(D('abc'))), 'abc') self.assertEqual('{0[0]}'.format(['abc', 'def']), 'abc') self.assertEqual('{0[1]}'.format(['abc', 'def']), 'def') self.assertEqual('{0[1][0]}'.format(['abc', ['def']]), 'def') self.assertEqual('{0[1][0].x}'.format(['abc', [D('def')]]), 'def') # strings self.assertEqual('{0:.3s}'.format('abc'), 'abc') self.assertEqual('{0:.3s}'.format('ab'), 'ab') self.assertEqual('{0:.3s}'.format('abcdef'), 'abc') self.assertEqual('{0:.0s}'.format('abcdef'), '') self.assertEqual('{0:3.3s}'.format('abc'), 'abc') self.assertEqual('{0:2.3s}'.format('abc'), 'abc') self.assertEqual('{0:2.2s}'.format('abc'), 'ab') self.assertEqual('{0:3.2s}'.format('abc'), 'ab ') self.assertEqual('{0:x<0s}'.format('result'), 'result') self.assertEqual('{0:x<5s}'.format('result'), 'result') self.assertEqual('{0:x<6s}'.format('result'), 'result') self.assertEqual('{0:x<7s}'.format('result'), 'resultx') self.assertEqual('{0:x<8s}'.format('result'), 'resultxx') self.assertEqual('{0: <7s}'.format('result'), 'result ') self.assertEqual('{0:<7s}'.format('result'), 'result ') self.assertEqual('{0:>7s}'.format('result'), ' result') self.assertEqual('{0:>8s}'.format('result'), ' result') self.assertEqual('{0:^8s}'.format('result'), ' result ') self.assertEqual('{0:^9s}'.format('result'), ' result ') self.assertEqual('{0:^10s}'.format('result'), ' result ') self.assertEqual('{0:10000}'.format('a'), 'a' + ' ' * 9999) self.assertEqual('{0:10000}'.format(''), ' ' * 10000) self.assertEqual('{0:10000000}'.format(''), ' ' * 10000000) # format specifiers for user defined type self.assertEqual('{0:abc}'.format(C()), 'abc') # !r, !s and !a coercions self.assertEqual('{0!s}'.format('Hello'), 'Hello') self.assertEqual('{0!s:}'.format('Hello'), 'Hello') self.assertEqual('{0!s:15}'.format('Hello'), 'Hello ') self.assertEqual('{0!s:15s}'.format('Hello'), 'Hello ') self.assertEqual('{0!r}'.format('Hello'), "'Hello'") self.assertEqual('{0!r:}'.format('Hello'), "'Hello'") self.assertEqual('{0!r}'.format(F('Hello')), 'F(Hello)') self.assertEqual('{0!r}'.format('\u0378'), "'\\u0378'") # nonprintable self.assertEqual('{0!r}'.format('\u0374'), "'\u0374'") # printable self.assertEqual('{0!r}'.format(F('\u0374')), 'F(\u0374)') self.assertEqual('{0!a}'.format('Hello'), "'Hello'") self.assertEqual('{0!a}'.format('\u0378'), "'\\u0378'") # nonprintable self.assertEqual('{0!a}'.format('\u0374'), "'\\u0374'") # printable self.assertEqual('{0!a:}'.format('Hello'), "'Hello'") self.assertEqual('{0!a}'.format(F('Hello')), 'F(Hello)') self.assertEqual('{0!a}'.format(F('\u0374')), 'F(\\u0374)') # test fallback to object.__format__ self.assertEqual('{0}'.format({}), '{}') self.assertEqual('{0}'.format([]), '[]') self.assertEqual('{0}'.format([1]), '[1]') self.assertEqual('{0:d}'.format(G('data')), 'G(data)') self.assertEqual('{0!s}'.format(G('data')), 'string is data') msg = 'object.__format__ with a non-empty format string is deprecated' with support.check_warnings((msg, PendingDeprecationWarning)): self.assertEqual('{0:^10}'.format(E('data')), ' E(data) ') self.assertEqual('{0:^10s}'.format(E('data')), ' E(data) ') self.assertEqual('{0:>15s}'.format(G('data')), ' string is data') self.assertEqual("{0:date: %Y-%m-%d}".format(I(year=2007, month=8, day=27)), "date: 2007-08-27") # test deriving from a builtin type and overriding __format__ self.assertEqual("{0}".format(J(10)), "20") # string format specifiers self.assertEqual('{0:}'.format('a'), 'a') # computed format specifiers self.assertEqual("{0:.{1}}".format('hello world', 5), 'hello') self.assertEqual("{0:.{1}s}".format('hello world', 5), 'hello') self.assertEqual("{0:.{precision}s}".format('hello world', precision=5), 'hello') self.assertEqual("{0:{width}.{precision}s}".format('hello world', width=10, precision=5), 'hello ') self.assertEqual("{0:{width}.{precision}s}".format('hello world', width='10', precision='5'), 'hello ') # test various errors self.assertRaises(ValueError, '{'.format) self.assertRaises(ValueError, '}'.format) self.assertRaises(ValueError, 'a{'.format) self.assertRaises(ValueError, 'a}'.format) self.assertRaises(ValueError, '{a'.format) self.assertRaises(ValueError, '}a'.format) self.assertRaises(IndexError, '{0}'.format) self.assertRaises(IndexError, '{1}'.format, 'abc') self.assertRaises(KeyError, '{x}'.format) self.assertRaises(ValueError, "}{".format) self.assertRaises(ValueError, "abc{0:{}".format) self.assertRaises(ValueError, "{0".format) self.assertRaises(IndexError, "{0.}".format) self.assertRaises(ValueError, "{0.}".format, 0) self.assertRaises(IndexError, "{0[}".format) self.assertRaises(ValueError, "{0[}".format, []) self.assertRaises(KeyError, "{0]}".format) self.assertRaises(ValueError, "{0.[]}".format, 0) self.assertRaises(ValueError, "{0..foo}".format, 0) self.assertRaises(ValueError, "{0[0}".format, 0) self.assertRaises(ValueError, "{0[0:foo}".format, 0) self.assertRaises(KeyError, "{c]}".format) self.assertRaises(ValueError, "{{ {{{0}}".format, 0) self.assertRaises(ValueError, "{0}}".format, 0) self.assertRaises(KeyError, "{foo}".format, bar=3) self.assertRaises(ValueError, "{0!x}".format, 3) self.assertRaises(ValueError, "{0!}".format, 0) self.assertRaises(ValueError, "{0!rs}".format, 0) self.assertRaises(ValueError, "{!}".format) self.assertRaises(IndexError, "{:}".format) self.assertRaises(IndexError, "{:s}".format) self.assertRaises(IndexError, "{}".format) big = "23098475029384702983476098230754973209482573" self.assertRaises(ValueError, ("{" + big + "}").format) self.assertRaises(ValueError, ("{[" + big + "]}").format, [0]) # issue 6089 self.assertRaises(ValueError, "{0[0]x}".format, [None]) self.assertRaises(ValueError, "{0[0](10)}".format, [None]) # can't have a replacement on the field name portion self.assertRaises(TypeError, '{0[{1}]}'.format, 'abcdefg', 4) # exceed maximum recursion depth self.assertRaises(ValueError, "{0:{1:{2}}}".format, 'abc', 's', '') self.assertRaises(ValueError, "{0:{1:{2:{3:{4:{5:{6}}}}}}}".format, 0, 1, 2, 3, 4, 5, 6, 7) # string format spec errors self.assertRaises(ValueError, "{0:-s}".format, '') self.assertRaises(ValueError, format, "", "-") self.assertRaises(ValueError, "{0:=s}".format, '') # Alternate formatting is not supported self.assertRaises(ValueError, format, '', '#') self.assertRaises(ValueError, format, '', '#20') def test_format_map(self): self.assertEqual(''.format_map({}), '') self.assertEqual('a'.format_map({}), 'a') self.assertEqual('ab'.format_map({}), 'ab') self.assertEqual('a{{'.format_map({}), 'a{') self.assertEqual('a}}'.format_map({}), 'a}') self.assertEqual('{{b'.format_map({}), '{b') self.assertEqual('}}b'.format_map({}), '}b') self.assertEqual('a{{b'.format_map({}), 'a{b') # using mappings class Mapping(dict): def __missing__(self, key): return key self.assertEqual('{hello}'.format_map(Mapping()), 'hello') self.assertEqual('{a} {world}'.format_map(Mapping(a='hello')), 'hello world') class InternalMapping: def __init__(self): self.mapping = {'a': 'hello'} def __getitem__(self, key): return self.mapping[key] self.assertEqual('{a}'.format_map(InternalMapping()), 'hello') class C: def __init__(self, x=100): self._x = x def __format__(self, spec): return spec self.assertEqual('{foo._x}'.format_map({'foo': C(20)}), '20') # test various errors self.assertRaises(TypeError, '{'.format_map) self.assertRaises(TypeError, '}'.format_map) self.assertRaises(TypeError, 'a{'.format_map) self.assertRaises(TypeError, 'a}'.format_map) self.assertRaises(TypeError, '{a'.format_map) self.assertRaises(TypeError, '}a'.format_map) # issue #12579: can't supply positional params to format_map self.assertRaises(ValueError, '{}'.format_map, {'a' : 2}) self.assertRaises(ValueError, '{}'.format_map, 'a') self.assertRaises(ValueError, '{a} {}'.format_map, {"a" : 2, "b" : 1}) def test_format_auto_numbering(self): class C: def __init__(self, x=100): self._x = x def __format__(self, spec): return spec self.assertEqual('{}'.format(10), '10') self.assertEqual('{:5}'.format('s'), 's ') self.assertEqual('{!r}'.format('s'), "'s'") self.assertEqual('{._x}'.format(C(10)), '10') self.assertEqual('{[1]}'.format([1, 2]), '2') self.assertEqual('{[a]}'.format({'a':4, 'b':2}), '4') self.assertEqual('a{}b{}c'.format(0, 1), 'a0b1c') self.assertEqual('a{:{}}b'.format('x', '^10'), 'a x b') self.assertEqual('a{:{}x}b'.format(20, '#'), 'a0x14b') # can't mix and match numbering and auto-numbering self.assertRaises(ValueError, '{}{1}'.format, 1, 2) self.assertRaises(ValueError, '{1}{}'.format, 1, 2) self.assertRaises(ValueError, '{:{1}}'.format, 1, 2) self.assertRaises(ValueError, '{0:{}}'.format, 1, 2) # can mix and match auto-numbering and named self.assertEqual('{f}{}'.format(4, f='test'), 'test4') self.assertEqual('{}{f}'.format(4, f='test'), '4test') self.assertEqual('{:{f}}{g}{}'.format(1, 3, g='g', f=2), ' 1g3') self.assertEqual('{f:{}}{}{g}'.format(2, 4, f=1, g='g'), ' 14g') def test_formatting(self): string_tests.MixinStrUnicodeUserStringTest.test_formatting(self) # Testing Unicode formatting strings... self.assertEqual("%s, %s" % ("abc", "abc"), 'abc, abc') self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", 1, 2, 3), 'abc, abc, 1, 2.000000, 3.00') self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", 1, -2, 3), 'abc, abc, 1, -2.000000, 3.00') self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", -1, -2, 3.5), 'abc, abc, -1, -2.000000, 3.50') self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", -1, -2, 3.57), 'abc, abc, -1, -2.000000, 3.57') self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", -1, -2, 1003.57), 'abc, abc, -1, -2.000000, 1003.57') if not sys.platform.startswith('java'): self.assertEqual("%r, %r" % (b"abc", "abc"), "b'abc', 'abc'") self.assertEqual("%r" % ("\u1234",), "'\u1234'") self.assertEqual("%a" % ("\u1234",), "'\\u1234'") self.assertEqual("%(x)s, %(y)s" % {'x':"abc", 'y':"def"}, 'abc, def') self.assertEqual("%(x)s, %(\xfc)s" % {'x':"abc", '\xfc':"def"}, 'abc, def') self.assertEqual('%c' % 0x1234, '\u1234') self.assertEqual('%c' % 0x21483, '\U00021483') self.assertRaises(OverflowError, "%c".__mod__, (0x110000,)) self.assertEqual('%c' % '\U00021483', '\U00021483') self.assertRaises(TypeError, "%c".__mod__, "aa") self.assertRaises(ValueError, "%.1\u1032f".__mod__, (1.0/3)) self.assertRaises(TypeError, "%i".__mod__, "aa") # formatting jobs delegated from the string implementation: self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...') self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...') self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...') self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...') self.assertEqual('...%(foo)s...' % {'foo':"abc",'def':123}, '...abc...') self.assertEqual('...%(foo)s...' % {'foo':"abc",'def':123}, '...abc...') self.assertEqual('...%s...%s...%s...%s...' % (1,2,3,"abc"), '...1...2...3...abc...') self.assertEqual('...%%...%%s...%s...%s...%s...%s...' % (1,2,3,"abc"), '...%...%s...1...2...3...abc...') self.assertEqual('...%s...' % "abc", '...abc...') self.assertEqual('%*s' % (5,'abc',), ' abc') self.assertEqual('%*s' % (-5,'abc',), 'abc ') self.assertEqual('%*.*s' % (5,2,'abc',), ' ab') self.assertEqual('%*.*s' % (5,3,'abc',), ' abc') self.assertEqual('%i %*.*s' % (10, 5,3,'abc',), '10 abc') self.assertEqual('%i%s %*.*s' % (10, 3, 5, 3, 'abc',), '103 abc') self.assertEqual('%c' % 'a', 'a') class Wrapper: def __str__(self): return '\u1234' self.assertEqual('%s' % Wrapper(), '\u1234') # issue 3382 NAN = float('nan') INF = float('inf') self.assertEqual('%f' % NAN, 'nan') self.assertEqual('%F' % NAN, 'NAN') self.assertEqual('%f' % INF, 'inf') self.assertEqual('%F' % INF, 'INF') def test_startswith_endswith_errors(self): for meth in ('foo'.startswith, 'foo'.endswith): with self.assertRaises(TypeError) as cm: meth(['f']) exc = str(cm.exception) self.assertIn('str', exc) self.assertIn('tuple', exc) @support.run_with_locale('LC_ALL', 'de_DE', 'fr_FR') def test_format_float(self): # should not format with a comma, but always with C locale self.assertEqual('1.0', '%.1f' % 1.0) def test_constructor(self): # unicode(obj) tests (this maps to PyObject_Unicode() at C level) self.assertEqual( str('unicode remains unicode'), 'unicode remains unicode' ) class UnicodeSubclass(str): pass self.assertEqual( str(UnicodeSubclass('unicode subclass becomes unicode')), 'unicode subclass becomes unicode' ) self.assertEqual( str('strings are converted to unicode'), 'strings are converted to unicode' ) class StringCompat: def __init__(self, x): self.x = x def __str__(self): return self.x self.assertEqual( str(StringCompat('__str__ compatible objects are recognized')), '__str__ compatible objects are recognized' ) # unicode(obj) is compatible to str(): o = StringCompat('unicode(obj) is compatible to str()') self.assertEqual(str(o), 'unicode(obj) is compatible to str()') self.assertEqual(str(o), 'unicode(obj) is compatible to str()') for obj in (123, 123.45, 123): self.assertEqual(str(obj), str(str(obj))) # unicode(obj, encoding, error) tests (this maps to # PyUnicode_FromEncodedObject() at C level) if not sys.platform.startswith('java'): self.assertRaises( TypeError, str, 'decoding unicode is not supported', 'utf-8', 'strict' ) self.assertEqual( str(b'strings are decoded to unicode', 'utf-8', 'strict'), 'strings are decoded to unicode' ) if not sys.platform.startswith('java'): self.assertEqual( str( memoryview(b'character buffers are decoded to unicode'), 'utf-8', 'strict' ), 'character buffers are decoded to unicode' ) self.assertRaises(TypeError, str, 42, 42, 42) def test_codecs_utf7(self): utfTests = [ ('A\u2262\u0391.', b'A+ImIDkQ.'), # RFC2152 example ('Hi Mom -\u263a-!', b'Hi Mom -+Jjo--!'), # RFC2152 example ('\u65E5\u672C\u8A9E', b'+ZeVnLIqe-'), # RFC2152 example ('Item 3 is \u00a31.', b'Item 3 is +AKM-1.'), # RFC2152 example ('+', b'+-'), ('+-', b'+--'), ('+?', b'+-?'), ('\?', b'+AFw?'), ('+?', b'+-?'), (r'\\?', b'+AFwAXA?'), (r'\\\?', b'+AFwAXABc?'), (r'++--', b'+-+---'), ('\U000abcde', b'+2m/c3g-'), # surrogate pairs ('/', b'/'), ] for (x, y) in utfTests: self.assertEqual(x.encode('utf-7'), y) # Unpaired surrogates not supported self.assertRaises(UnicodeError, str, b'+3ADYAA-', 'utf-7') self.assertEqual(str(b'+3ADYAA-', 'utf-7', 'replace'), '\ufffd\ufffd') # Issue #2242: crash on some Windows/MSVC versions self.assertEqual(b'+\xc1'.decode('utf-7'), '\xc1') # Direct encoded characters set_d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'(),-./:?" # Optional direct characters set_o = '!"#$%&*;<=>@[]^_`{|}' for c in set_d: self.assertEqual(c.encode('utf7'), c.encode('ascii')) self.assertEqual(c.encode('ascii').decode('utf7'), c) for c in set_o: self.assertEqual(c.encode('ascii').decode('utf7'), c) def test_codecs_utf8(self): self.assertEqual(''.encode('utf-8'), b'') self.assertEqual('\u20ac'.encode('utf-8'), b'\xe2\x82\xac') if sys.maxunicode == 65535: self.assertEqual('\ud800\udc02'.encode('utf-8'), b'\xf0\x90\x80\x82') self.assertEqual('\ud84d\udc56'.encode('utf-8'), b'\xf0\xa3\x91\x96') self.assertEqual('\ud800'.encode('utf-8', 'surrogatepass'), b'\xed\xa0\x80') self.assertEqual('\udc00'.encode('utf-8', 'surrogatepass'), b'\xed\xb0\x80') if sys.maxunicode == 65535: self.assertEqual( ('\ud800\udc02'*1000).encode('utf-8'), b'\xf0\x90\x80\x82'*1000) self.assertEqual( '\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f' '\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00' '\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c' '\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067' '\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das' ' Nunstuck git und'.encode('utf-8'), b'\xe6\xad\xa3\xe7\xa2\xba\xe3\x81\xab\xe8\xa8\x80\xe3\x81' b'\x86\xe3\x81\xa8\xe7\xbf\xbb\xe8\xa8\xb3\xe3\x81\xaf\xe3' b'\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3\x81\xbe' b'\xe3\x81\x9b\xe3\x82\x93\xe3\x80\x82\xe4\xb8\x80\xe9\x83' b'\xa8\xe3\x81\xaf\xe3\x83\x89\xe3\x82\xa4\xe3\x83\x84\xe8' b'\xaa\x9e\xe3\x81\xa7\xe3\x81\x99\xe3\x81\x8c\xe3\x80\x81' b'\xe3\x81\x82\xe3\x81\xa8\xe3\x81\xaf\xe3\x81\xa7\xe3\x81' b'\x9f\xe3\x82\x89\xe3\x82\x81\xe3\x81\xa7\xe3\x81\x99\xe3' b'\x80\x82\xe5\xae\x9f\xe9\x9a\x9b\xe3\x81\xab\xe3\x81\xaf' b'\xe3\x80\x8cWenn ist das Nunstuck git und' ) # UTF-8 specific decoding tests self.assertEqual(str(b'\xf0\xa3\x91\x96', 'utf-8'), '\U00023456' ) self.assertEqual(str(b'\xf0\x90\x80\x82', 'utf-8'), '\U00010002' ) self.assertEqual(str(b'\xe2\x82\xac', 'utf-8'), '\u20ac' ) # Other possible utf-8 test cases: # * strict decoding testing for all of the # UTF8_ERROR cases in PyUnicode_DecodeUTF8 def test_utf8_decode_valid_sequences(self): sequences = [ # single byte (b'\x00', '\x00'), (b'a', 'a'), (b'\x7f', '\x7f'), # 2 bytes (b'\xc2\x80', '\x80'), (b'\xdf\xbf', '\u07ff'), # 3 bytes (b'\xe0\xa0\x80', '\u0800'), (b'\xed\x9f\xbf', '\ud7ff'), (b'\xee\x80\x80', '\uE000'), (b'\xef\xbf\xbf', '\uffff'), # 4 bytes (b'\xF0\x90\x80\x80', '\U00010000'), (b'\xf4\x8f\xbf\xbf', '\U0010FFFF') ] for seq, res in sequences: self.assertEqual(seq.decode('utf-8'), res) def test_utf8_decode_invalid_sequences(self): # continuation bytes in a sequence of 2, 3, or 4 bytes continuation_bytes = [bytes([x]) for x in range(0x80, 0xC0)] # start bytes of a 2-byte sequence equivalent to codepoints < 0x7F invalid_2B_seq_start_bytes = [bytes([x]) for x in range(0xC0, 0xC2)] # start bytes of a 4-byte sequence equivalent to codepoints > 0x10FFFF invalid_4B_seq_start_bytes = [bytes([x]) for x in range(0xF5, 0xF8)] invalid_start_bytes = ( continuation_bytes + invalid_2B_seq_start_bytes + invalid_4B_seq_start_bytes + [bytes([x]) for x in range(0xF7, 0x100)] ) for byte in invalid_start_bytes: self.assertRaises(UnicodeDecodeError, byte.decode, 'utf-8') for sb in invalid_2B_seq_start_bytes: for cb in continuation_bytes: self.assertRaises(UnicodeDecodeError, (sb+cb).decode, 'utf-8') for sb in invalid_4B_seq_start_bytes: for cb1 in continuation_bytes[:3]: for cb3 in continuation_bytes[:3]: self.assertRaises(UnicodeDecodeError, (sb+cb1+b'\x80'+cb3).decode, 'utf-8') for cb in [bytes([x]) for x in range(0x80, 0xA0)]: self.assertRaises(UnicodeDecodeError, (b'\xE0'+cb+b'\x80').decode, 'utf-8') self.assertRaises(UnicodeDecodeError, (b'\xE0'+cb+b'\xBF').decode, 'utf-8') # surrogates for cb in [bytes([x]) for x in range(0xA0, 0xC0)]: self.assertRaises(UnicodeDecodeError, (b'\xED'+cb+b'\x80').decode, 'utf-8') self.assertRaises(UnicodeDecodeError, (b'\xED'+cb+b'\xBF').decode, 'utf-8') for cb in [bytes([x]) for x in range(0x80, 0x90)]: self.assertRaises(UnicodeDecodeError, (b'\xF0'+cb+b'\x80\x80').decode, 'utf-8') self.assertRaises(UnicodeDecodeError, (b'\xF0'+cb+b'\xBF\xBF').decode, 'utf-8') for cb in [bytes([x]) for x in range(0x90, 0xC0)]: self.assertRaises(UnicodeDecodeError, (b'\xF4'+cb+b'\x80\x80').decode, 'utf-8') self.assertRaises(UnicodeDecodeError, (b'\xF4'+cb+b'\xBF\xBF').decode, 'utf-8') def test_issue8271(self): # Issue #8271: during the decoding of an invalid UTF-8 byte sequence, # only the start byte and the continuation byte(s) are now considered # invalid, instead of the number of bytes specified by the start byte. # See http://www.unicode.org/versions/Unicode5.2.0/ch03.pdf (page 95, # table 3-8, Row 2) for more information about the algorithm used. FFFD = '\ufffd' sequences = [ # invalid start bytes (b'\x80', FFFD), # continuation byte (b'\x80\x80', FFFD*2), # 2 continuation bytes (b'\xc0', FFFD), (b'\xc0\xc0', FFFD*2), (b'\xc1', FFFD), (b'\xc1\xc0', FFFD*2), (b'\xc0\xc1', FFFD*2), # with start byte of a 2-byte sequence (b'\xc2', FFFD), # only the start byte (b'\xc2\xc2', FFFD*2), # 2 start bytes (b'\xc2\xc2\xc2', FFFD*3), # 2 start bytes (b'\xc2\x41', FFFD+'A'), # invalid continuation byte # with start byte of a 3-byte sequence (b'\xe1', FFFD), # only the start byte (b'\xe1\xe1', FFFD*2), # 2 start bytes (b'\xe1\xe1\xe1', FFFD*3), # 3 start bytes (b'\xe1\xe1\xe1\xe1', FFFD*4), # 4 start bytes (b'\xe1\x80', FFFD), # only 1 continuation byte (b'\xe1\x41', FFFD+'A'), # invalid continuation byte (b'\xe1\x41\x80', FFFD+'A'+FFFD), # invalid cb followed by valid cb (b'\xe1\x41\x41', FFFD+'AA'), # 2 invalid continuation bytes (b'\xe1\x80\x41', FFFD+'A'), # only 1 valid continuation byte (b'\xe1\x80\xe1\x41', FFFD*2+'A'), # 1 valid and the other invalid (b'\xe1\x41\xe1\x80', FFFD+'A'+FFFD), # 1 invalid and the other valid # with start byte of a 4-byte sequence (b'\xf1', FFFD), # only the start byte (b'\xf1\xf1', FFFD*2), # 2 start bytes (b'\xf1\xf1\xf1', FFFD*3), # 3 start bytes (b'\xf1\xf1\xf1\xf1', FFFD*4), # 4 start bytes (b'\xf1\xf1\xf1\xf1\xf1', FFFD*5), # 5 start bytes (b'\xf1\x80', FFFD), # only 1 continuation bytes (b'\xf1\x80\x80', FFFD), # only 2 continuation bytes (b'\xf1\x80\x41', FFFD+'A'), # 1 valid cb and 1 invalid (b'\xf1\x80\x41\x41', FFFD+'AA'), # 1 valid cb and 1 invalid (b'\xf1\x80\x80\x41', FFFD+'A'), # 2 valid cb and 1 invalid (b'\xf1\x41\x80', FFFD+'A'+FFFD), # 1 invalid cv and 1 valid (b'\xf1\x41\x80\x80', FFFD+'A'+FFFD*2), # 1 invalid cb and 2 invalid (b'\xf1\x41\x80\x41', FFFD+'A'+FFFD+'A'), # 2 invalid cb and 1 invalid (b'\xf1\x41\x41\x80', FFFD+'AA'+FFFD), # 1 valid cb and 1 invalid (b'\xf1\x41\xf1\x80', FFFD+'A'+FFFD), (b'\xf1\x41\x80\xf1', FFFD+'A'+FFFD*2), (b'\xf1\xf1\x80\x41', FFFD*2+'A'), (b'\xf1\x41\xf1\xf1', FFFD+'A'+FFFD*2), # with invalid start byte of a 4-byte sequence (rfc2279) (b'\xf5', FFFD), # only the start byte (b'\xf5\xf5', FFFD*2), # 2 start bytes (b'\xf5\x80', FFFD*2), # only 1 continuation byte (b'\xf5\x80\x80', FFFD*3), # only 2 continuation byte (b'\xf5\x80\x80\x80', FFFD*4), # 3 continuation bytes (b'\xf5\x80\x41', FFFD*2+'A'), # 1 valid cb and 1 invalid (b'\xf5\x80\x41\xf5', FFFD*2+'A'+FFFD), (b'\xf5\x41\x80\x80\x41', FFFD+'A'+FFFD*2+'A'), # with invalid start byte of a 5-byte sequence (rfc2279) (b'\xf8', FFFD), # only the start byte (b'\xf8\xf8', FFFD*2), # 2 start bytes (b'\xf8\x80', FFFD*2), # only one continuation byte (b'\xf8\x80\x41', FFFD*2 + 'A'), # 1 valid cb and 1 invalid (b'\xf8\x80\x80\x80\x80', FFFD*5), # invalid 5 bytes seq with 5 bytes # with invalid start byte of a 6-byte sequence (rfc2279) (b'\xfc', FFFD), # only the start byte (b'\xfc\xfc', FFFD*2), # 2 start bytes (b'\xfc\x80\x80', FFFD*3), # only 2 continuation bytes (b'\xfc\x80\x80\x80\x80\x80', FFFD*6), # 6 continuation bytes # invalid start byte (b'\xfe', FFFD), (b'\xfe\x80\x80', FFFD*3), # other sequences (b'\xf1\x80\x41\x42\x43', '\ufffd\x41\x42\x43'), (b'\xf1\x80\xff\x42\x43', '\ufffd\ufffd\x42\x43'), (b'\xf1\x80\xc2\x81\x43', '\ufffd\x81\x43'), (b'\x61\xF1\x80\x80\xE1\x80\xC2\x62\x80\x63\x80\xBF\x64', '\x61\uFFFD\uFFFD\uFFFD\x62\uFFFD\x63\uFFFD\uFFFD\x64'), ] for n, (seq, res) in enumerate(sequences): self.assertRaises(UnicodeDecodeError, seq.decode, 'utf-8', 'strict') self.assertEqual(seq.decode('utf-8', 'replace'), res) self.assertEqual((seq+b'b').decode('utf-8', 'replace'), res+'b') self.assertEqual(seq.decode('utf-8', 'ignore'), res.replace('\uFFFD', '')) def test_codecs_idna(self): # Test whether trailing dot is preserved self.assertEqual("www.python.org.".encode("idna"), b"www.python.org.") def test_codecs_errors(self): # Error handling (encoding) self.assertRaises(UnicodeError, 'Andr\202 x'.encode, 'ascii') self.assertRaises(UnicodeError, 'Andr\202 x'.encode, 'ascii','strict') self.assertEqual('Andr\202 x'.encode('ascii','ignore'), b"Andr x") self.assertEqual('Andr\202 x'.encode('ascii','replace'), b"Andr? x") self.assertEqual('Andr\202 x'.encode('ascii', 'replace'), 'Andr\202 x'.encode('ascii', errors='replace')) self.assertEqual('Andr\202 x'.encode('ascii', 'ignore'), 'Andr\202 x'.encode(encoding='ascii', errors='ignore')) # Error handling (decoding) self.assertRaises(UnicodeError, str, b'Andr\202 x', 'ascii') self.assertRaises(UnicodeError, str, b'Andr\202 x', 'ascii', 'strict') self.assertEqual(str(b'Andr\202 x', 'ascii', 'ignore'), "Andr x") self.assertEqual(str(b'Andr\202 x', 'ascii', 'replace'), 'Andr\uFFFD x') # Error handling (unknown character names) self.assertEqual(b"\\N{foo}xx".decode("unicode-escape", "ignore"), "xx") # Error handling (truncated escape sequence) self.assertRaises(UnicodeError, b"\\".decode, "unicode-escape") self.assertRaises(TypeError, b"hello".decode, "test.unicode1") self.assertRaises(TypeError, str, b"hello", "test.unicode2") self.assertRaises(TypeError, "hello".encode, "test.unicode1") self.assertRaises(TypeError, "hello".encode, "test.unicode2") # executes PyUnicode_Encode() import imp self.assertRaises( ImportError, imp.find_module, "non-existing module", ["non-existing dir"] ) # Error handling (wrong arguments) self.assertRaises(TypeError, "hello".encode, 42, 42, 42) # Error handling (lone surrogate in PyUnicode_TransformDecimalToASCII()) self.assertRaises(UnicodeError, int, "\ud800") self.assertRaises(UnicodeError, int, "\udf00") self.assertRaises(UnicodeError, float, "\ud800") self.assertRaises(UnicodeError, float, "\udf00") self.assertRaises(UnicodeError, complex, "\ud800") self.assertRaises(UnicodeError, complex, "\udf00") def test_codecs(self): # Encoding self.assertEqual('hello'.encode('ascii'), b'hello') self.assertEqual('hello'.encode('utf-7'), b'hello') self.assertEqual('hello'.encode('utf-8'), b'hello') self.assertEqual('hello'.encode('utf8'), b'hello') self.assertEqual('hello'.encode('utf-16-le'), b'h\000e\000l\000l\000o\000') self.assertEqual('hello'.encode('utf-16-be'), b'\000h\000e\000l\000l\000o') self.assertEqual('hello'.encode('latin-1'), b'hello') # Roundtrip safety for BMP (just the first 1024 chars) for c in range(1024): u = chr(c) for encoding in ('utf-7', 'utf-8', 'utf-16', 'utf-16-le', 'utf-16-be', 'raw_unicode_escape', 'unicode_escape', 'unicode_internal'): self.assertEqual(str(u.encode(encoding),encoding), u) # Roundtrip safety for BMP (just the first 256 chars) for c in range(256): u = chr(c) for encoding in ('latin-1',): self.assertEqual(str(u.encode(encoding),encoding), u) # Roundtrip safety for BMP (just the first 128 chars) for c in range(128): u = chr(c) for encoding in ('ascii',): self.assertEqual(str(u.encode(encoding),encoding), u) # Roundtrip safety for non-BMP (just a few chars) u = '\U00010001\U00020002\U00030003\U00040004\U00050005' for encoding in ('utf-8', 'utf-16', 'utf-16-le', 'utf-16-be', #'raw_unicode_escape', 'unicode_escape', 'unicode_internal'): self.assertEqual(str(u.encode(encoding),encoding), u) # UTF-8 must be roundtrip safe for all UCS-2 code points # This excludes surrogates: in the full range, there would be # a surrogate pair (\udbff\udc00), which gets converted back # to a non-BMP character (\U0010fc00) u = ''.join(map(chr, list(range(0,0xd800)) + list(range(0xe000,0x10000)))) for encoding in ('utf-8',): self.assertEqual(str(u.encode(encoding),encoding), u) def test_codecs_charmap(self): # 0-127 s = bytes(range(128)) for encoding in ( 'cp037', 'cp1026', 'cp437', 'cp500', 'cp720', 'cp737', 'cp775', 'cp850', 'cp852', 'cp855', 'cp858', 'cp860', 'cp861', 'cp862', 'cp863', 'cp865', 'cp866', 'iso8859_10', 'iso8859_13', 'iso8859_14', 'iso8859_15', 'iso8859_2', 'iso8859_3', 'iso8859_4', 'iso8859_5', 'iso8859_6', 'iso8859_7', 'iso8859_9', 'koi8_r', 'latin_1', 'mac_cyrillic', 'mac_latin2', 'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', 'cp1256', 'cp1257', 'cp1258', 'cp856', 'cp857', 'cp864', 'cp869', 'cp874', 'mac_greek', 'mac_iceland','mac_roman', 'mac_turkish', 'cp1006', 'iso8859_8', ### These have undefined mappings: #'cp424', ### These fail the round-trip: #'cp875' ): self.assertEqual(str(s, encoding).encode(encoding), s) # 128-255 s = bytes(range(128, 256)) for encoding in ( 'cp037', 'cp1026', 'cp437', 'cp500', 'cp720', 'cp737', 'cp775', 'cp850', 'cp852', 'cp855', 'cp858', 'cp860', 'cp861', 'cp862', 'cp863', 'cp865', 'cp866', 'iso8859_10', 'iso8859_13', 'iso8859_14', 'iso8859_15', 'iso8859_2', 'iso8859_4', 'iso8859_5', 'iso8859_9', 'koi8_r', 'latin_1', 'mac_cyrillic', 'mac_latin2', ### These have undefined mappings: #'cp1250', 'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', #'cp1256', 'cp1257', 'cp1258', #'cp424', 'cp856', 'cp857', 'cp864', 'cp869', 'cp874', #'iso8859_3', 'iso8859_6', 'iso8859_7', #'mac_greek', 'mac_iceland','mac_roman', 'mac_turkish', ### These fail the round-trip: #'cp1006', 'cp875', 'iso8859_8', ): self.assertEqual(str(s, encoding).encode(encoding), s) def test_concatenation(self): self.assertEqual(("abc" "def"), "abcdef") self.assertEqual(("abc" "def"), "abcdef") self.assertEqual(("abc" "def"), "abcdef") self.assertEqual(("abc" "def" "ghi"), "abcdefghi") self.assertEqual(("abc" "def" "ghi"), "abcdefghi") def test_printing(self): class BitBucket: def write(self, text): pass out = BitBucket() print('abc', file=out) print('abc', 'def', file=out) print('abc', 'def', file=out) print('abc', 'def', file=out) print('abc\n', file=out) print('abc\n', end=' ', file=out) print('abc\n', end=' ', file=out) print('def\n', file=out) print('def\n', file=out) def test_ucs4(self): x = '\U00100000' y = x.encode("raw-unicode-escape").decode("raw-unicode-escape") self.assertEqual(x, y) y = br'\U00100000' x = y.decode("raw-unicode-escape").encode("raw-unicode-escape") self.assertEqual(x, y) y = br'\U00010000' x = y.decode("raw-unicode-escape").encode("raw-unicode-escape") self.assertEqual(x, y) try: br'\U11111111'.decode("raw-unicode-escape") except UnicodeDecodeError as e: self.assertEqual(e.start, 0) self.assertEqual(e.end, 10) else: self.fail("Should have raised UnicodeDecodeError") def test_conversion(self): # Make sure __unicode__() works properly class Foo0: def __str__(self): return "foo" class Foo1: def __str__(self): return "foo" class Foo2(object): def __str__(self): return "foo" class Foo3(object): def __str__(self): return "foo" class Foo4(str): def __str__(self): return "foo" class Foo5(str): def __str__(self): return "foo" class Foo6(str): def __str__(self): return "foos" def __str__(self): return "foou" class Foo7(str): def __str__(self): return "foos" def __str__(self): return "foou" class Foo8(str): def __new__(cls, content=""): return str.__new__(cls, 2*content) def __str__(self): return self class Foo9(str): def __str__(self): return "not unicode" self.assertEqual(str(Foo0()), "foo") self.assertEqual(str(Foo1()), "foo") self.assertEqual(str(Foo2()), "foo") self.assertEqual(str(Foo3()), "foo") self.assertEqual(str(Foo4("bar")), "foo") self.assertEqual(str(Foo5("bar")), "foo") self.assertEqual(str(Foo6("bar")), "foou") self.assertEqual(str(Foo7("bar")), "foou") self.assertEqual(str(Foo8("foo")), "foofoo") self.assertEqual(str(Foo9("foo")), "not unicode") def test_unicode_repr(self): class s1: def __repr__(self): return '\\n' class s2: def __repr__(self): return '\\n' self.assertEqual(repr(s1()), '\\n') self.assertEqual(repr(s2()), '\\n') def test_printable_repr(self): self.assertEqual(repr('\U00010000'), "'%c'" % (0x10000,)) # printable self.assertEqual(repr('\U00014000'), "'\\U00014000'") # nonprintable def test_expandtabs_overflows_gracefully(self): # This test only affects 32-bit platforms because expandtabs can only take # an int as the max value, not a 64-bit C long. If expandtabs is changed # to take a 64-bit long, this test should apply to all platforms. if sys.maxsize > (1 << 32) or struct.calcsize('P') != 4: return self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxsize) def test_raiseMemError(self): # Ensure that the freelist contains a consistent object, even # when a string allocation fails with a MemoryError. # This used to crash the interpreter, # or leak references when the number was smaller. charwidth = 4 if sys.maxunicode >= 0x10000 else 2 # Note: sys.maxsize is half of the actual max allocation because of # the signedness of Py_ssize_t. alloc = lambda: "a" * (sys.maxsize // charwidth * 2) self.assertRaises(MemoryError, alloc) self.assertRaises(MemoryError, alloc) def test_format_subclass(self): class S(str): def __str__(self): return '__str__ overridden' s = S('xxx') self.assertEqual("%s" % s, '__str__ overridden') self.assertEqual("{}".format(s), '__str__ overridden') # Test PyUnicode_FromFormat() def test_from_format(self): support.import_module('ctypes') from ctypes import pythonapi, py_object, c_int if sys.maxunicode == 65535: name = "PyUnicodeUCS2_FromFormat" else: name = "PyUnicodeUCS4_FromFormat" _PyUnicode_FromFormat = getattr(pythonapi, name) _PyUnicode_FromFormat.restype = py_object def PyUnicode_FromFormat(format, *args): cargs = tuple( py_object(arg) if isinstance(arg, str) else arg for arg in args) return _PyUnicode_FromFormat(format, *cargs) # ascii format, non-ascii argument text = PyUnicode_FromFormat(b'ascii\x7f=%U', 'unicode\xe9') self.assertEqual(text, 'ascii\x7f=unicode\xe9') # non-ascii format, ascii argument: ensure that PyUnicode_FromFormatV() # raises an error self.assertRaisesRegex(ValueError, '^PyUnicode_FromFormatV\(\) expects an ASCII-encoded format ' 'string, got a non-ASCII byte: 0xe9$', PyUnicode_FromFormat, b'unicode\xe9=%s', 'ascii') self.assertEqual(PyUnicode_FromFormat(b'%c', c_int(0xabcd)), '\uabcd') self.assertEqual(PyUnicode_FromFormat(b'%c', c_int(0x10ffff)), '\U0010ffff') # other tests text = PyUnicode_FromFormat(b'%%A:%A', 'abc\xe9\uabcd\U0010ffff') self.assertEqual(text, r"%A:'abc\xe9\uabcd\U0010ffff'") text = PyUnicode_FromFormat(b'repr=%V', 'abc', b'xyz') self.assertEqual(text, 'repr=abc') # Test string decode from parameter of %s using utf-8. # b'\xe4\xba\xba\xe6\xb0\x91' is utf-8 encoded byte sequence of # '\u4eba\u6c11' text = PyUnicode_FromFormat(b'repr=%V', None, b'\xe4\xba\xba\xe6\xb0\x91') self.assertEqual(text, 'repr=\u4eba\u6c11') #Test replace error handler. text = PyUnicode_FromFormat(b'repr=%V', None, b'abc\xff') self.assertEqual(text, 'repr=abc\ufffd') # Test PyUnicode_AsWideChar() def test_aswidechar(self): from _testcapi import unicode_aswidechar support.import_module('ctypes') from ctypes import c_wchar, sizeof wchar, size = unicode_aswidechar('abcdef', 2) self.assertEqual(size, 2) self.assertEqual(wchar, 'ab') wchar, size = unicode_aswidechar('abc', 3) self.assertEqual(size, 3) self.assertEqual(wchar, 'abc') wchar, size = unicode_aswidechar('abc', 4) self.assertEqual(size, 3) self.assertEqual(wchar, 'abc\0') wchar, size = unicode_aswidechar('abc', 10) self.assertEqual(size, 3) self.assertEqual(wchar, 'abc\0') wchar, size = unicode_aswidechar('abc\0def', 20) self.assertEqual(size, 7) self.assertEqual(wchar, 'abc\0def\0') nonbmp = chr(0x10ffff) if sizeof(c_wchar) == 2: buflen = 3 nchar = 2 else: # sizeof(c_wchar) == 4 buflen = 2 nchar = 1 wchar, size = unicode_aswidechar(nonbmp, buflen) self.assertEqual(size, nchar) self.assertEqual(wchar, nonbmp + '\0') # Test PyUnicode_AsWideCharString() def test_aswidecharstring(self): from _testcapi import unicode_aswidecharstring support.import_module('ctypes') from ctypes import c_wchar, sizeof wchar, size = unicode_aswidecharstring('abc') self.assertEqual(size, 3) self.assertEqual(wchar, 'abc\0') wchar, size = unicode_aswidecharstring('abc\0def') self.assertEqual(size, 7) self.assertEqual(wchar, 'abc\0def\0') nonbmp = chr(0x10ffff) if sizeof(c_wchar) == 2: nchar = 2 else: # sizeof(c_wchar) == 4 nchar = 1 wchar, size = unicode_aswidecharstring(nonbmp) self.assertEqual(size, nchar) self.assertEqual(wchar, nonbmp + '\0') class StringModuleTest(unittest.TestCase): def test_formatter_parser(self): def parse(format): return list(_string.formatter_parser(format)) formatter = parse("prefix {2!s}xxx{0:^+10.3f}{obj.attr!s} {z[0]!s:10}") self.assertEqual(formatter, [ ('prefix ', '2', '', 's'), ('xxx', '0', '^+10.3f', None), ('', 'obj.attr', '', 's'), (' ', 'z[0]', '10', 's'), ]) formatter = parse("prefix {} suffix") self.assertEqual(formatter, [ ('prefix ', '', '', None), (' suffix', None, None, None), ]) formatter = parse("str") self.assertEqual(formatter, [ ('str', None, None, None), ]) formatter = parse("") self.assertEqual(formatter, []) formatter = parse("{0}") self.assertEqual(formatter, [ ('', '0', '', None), ]) self.assertRaises(TypeError, _string.formatter_parser, 1) def test_formatter_field_name_split(self): def split(name): items = list(_string.formatter_field_name_split(name)) items[1] = list(items[1]) return items self.assertEqual(split("obj"), ["obj", []]) self.assertEqual(split("obj.arg"), ["obj", [(True, 'arg')]]) self.assertEqual(split("obj[key]"), ["obj", [(False, 'key')]]) self.assertEqual(split("obj.arg[key1][key2]"), [ "obj", [(True, 'arg'), (False, 'key1'), (False, 'key2'), ]]) self.assertRaises(TypeError, _string.formatter_field_name_split, 1) def test_main(): support.run_unittest(__name__) if __name__ == "__main__": test_main()
apache-2.0
[ 624, 1379, 2884, 367, 314, 6140, 4514, 14, 199, 199, 32329, 701, 603, 9912, 13, 3325, 264, 7005, 32649, 334, 2174, 32, 274, 32649, 14, 957, 680, 199, 199, 8, 67, 9, 1898, 445, 46, 6129, 12, 2900, 5924, 5702, 14, 4825, 3408, 14, 199, 199, 624, 23662, 199, 646, 6010, 199, 646, 2702, 199, 646, 984, 199, 646, 2882, 199, 646, 3598, 199, 504, 511, 492, 2291, 12, 1059, 63, 2219, 199, 646, 485, 875, 199, 199, 3, 4520, 7252, 334, 4087, 10334, 372, 9, 199, 318, 2754, 63, 1593, 8, 2991, 304, 272, 347, 4849, 17, 8, 1210, 12, 2552, 628, 4768, 2349, 267, 372, 5685, 327, 440, 282, 2008, 272, 347, 3752, 17, 8, 1210, 12, 2552, 628, 4768, 2349, 267, 372, 5685, 327, 440, 282, 2008, 272, 347, 3752, 18, 8, 1210, 12, 2552, 628, 4768, 2349, 267, 372, 334, 2260, 12, 5685, 9, 327, 949, 2649, 272, 347, 4849, 18, 8, 1210, 12, 2552, 628, 4768, 2349, 267, 372, 334, 2260, 12, 5685, 9, 327, 949, 2649, 272, 340, 2644, 11800, 396, 14, 2975, 17, 582, 267, 372, 334, 2143, 17, 12, 4849, 17, 12, 488, 12, 488, 9, 272, 916, 2644, 11800, 396, 14, 2975, 18, 582, 267, 372, 334, 2143, 18, 12, 4849, 18, 12, 488, 12, 488, 9, 272, 587, 26, 267, 372, 488, 199, 8933, 14, 2683, 8, 1733, 63, 1593, 9, 199, 199, 533, 6140, 774, 8, 875, 63, 2219, 14, 7844, 774, 12, 267, 1059, 63, 2219, 14, 4256, 2848, 7087, 1899, 1558, 774, 12, 267, 1059, 63, 2219, 14, 4256, 2848, 7087, 774, 304, 339, 730, 18, 396, 275, 620, 339, 347, 1104, 1452, 889, 970, 8, 277, 12, 754, 12, 909, 12, 28009, 12, 627, 589, 304, 267, 1083, 275, 2519, 8, 785, 12, 28009, 9, 267, 3363, 1099, 275, 1083, 2031, 589, 9, 267, 291, 14, 629, 8, 3093, 1099, 12, 754, 9, 267, 291, 14, 1815, 8, 466, 8, 3093, 1099, 9, 365, 730, 8, 1099, 430, 398, 327, 340, 314, 3379, 365, 2138, 1852, 3238, 626, 267, 327, 642, 3181, 1133, 5992, 543, 9180, 267, 340, 3363, 1099, 365, 909, 26, 288, 1021, 399, 954, 8, 495, 304, 355, 347, 636, 2722, 721, 277, 304, 490, 372, 283, 527, 456, 4042, 82, 3171, 450, 620, 855, 2722, 721, 277, 9, 288, 909, 275, 399, 954, 8, 785, 9, 288, 1083, 275, 2519, 8, 785, 12, 28009, 9, 288, 3363, 1099, 275, 1083, 2031, 589, 9, 288, 291, 14, 629, 8, 3093, 1099, 12, 754, 9, 288, 291, 14, 1815, 8, 785, 365, 440, 3363, 1099, 9, 339, 347, 511, 63, 5955, 8, 277, 304, 267, 291, 14, 629, 2258, 3581, 297, 1557, 85, 383, 556, 358, 267, 291, 14, 629, 2258, 3043, 556, 297, 1557, 53, 993, 4717, 358, 267, 291, 14, 1855, 8, 9294, 12, 3468, 12, 1557, 8124, 53, 12596, 771, 3985, 358, 267, 291, 14, 1855, 8, 9294, 12, 3468, 12, 1557, 8124, 53, 15798, 3985, 358, 267, 291, 14, 1855, 8, 9294, 12, 3468, 12, 1557, 8124, 53, 5, 2036, 88, 60, 891, 450, 378, 88, 845, 993, 9, 267, 327, 3066, 3326, 1077, 440, 1172, 2649, 24644, 267, 291, 14, 7418, 8, 82, 3212, 85, 20734, 401, 298, 6099, 339, 347, 511, 63, 4371, 8, 277, 304, 267, 340, 440, 984, 14, 3246, 14, 2460, 360, 6138, 735, 288, 327, 1379, 5678, 16740, 402, 4700, 342, 288, 291, 14, 629, 8, 4371, 360, 3175, 659, 3546, 3175, 9859, 288, 291, 14, 629, 8, 4371, 360, 371, 1103, 67, 659, 3546, 371, 8712, 67, 9859, 288, 291, 14, 629, 8, 4371, 360, 371, 1103, 659, 3546, 371, 8712, 9859, 288, 291, 14, 629, 8, 4371, 11671, 67, 659, 3546, 8712, 67, 9859, 288, 291, 14, 629, 8, 4371, 11671, 659, 3546, 8712, 9859, 288, 291, 14, 629, 8, 4371, 2258, 78, 659, 3546, 1103, 78, 9859, 288, 291, 14, 629, 8, 4371, 2258, 82, 659, 3546, 1103, 82, 9859, 288, 291, 14, 629, 8, 4371, 2258, 84, 659, 3546, 1103, 84, 9859, 288, 291, 14, 629, 8, 4371, 2258, 66, 659, 3546, 1103, 88, 2036, 9859, 288, 291, 14, 629, 8, 4371, 480, 1154, 341, 395, 408, 8124, 30385, 6141, 288, 291, 14, 629, 8, 4371, 480, 1154, 341, 395, 408, 8124, 30385, 6141, 288, 291, 14, 629, 8, 4371, 15587, 1288, 1449, 2, 4065, 12310, 288, 291, 14, 629, 8, 4371, 14088, 659, 408, 30385, 6141, 288, 16899, 17, 2722, 275, 334, 355, 3546, 1103, 88, 383, 1103, 88, 614, 1103, 88, 996, 1103, 88, 1644, 1103, 88, 966, 1103, 88, 1717, 1103, 88, 1690, 1103, 88, 1780, 1103, 88, 2036, 1103, 84, 1103, 78, 1103, 88, 16, 66, 1103, 88, 16, 67, 1103, 82, 2, 355, 9926, 88, 16, 69, 1103, 88, 16, 70, 1103, 88, 709, 1103, 88, 845, 1103, 88, 713, 1103, 88, 969, 1103, 88, 1079, 1103, 88, 1046, 1103, 88, 975, 1103, 88, 1196, 1103, 88, 1085, 1103, 88, 1167, 1103, 88, 17, 65, 2, 355, 9926, 88, 17, 66, 1103, 88, 17, 67, 1103, 88, 17, 68, 1103, 88, 17, 69, 1103, 88, 17, 70, 8546, 4451, 3, 22074, 6, 1103, 7, 25608, 11, 3057, 13186, 11371, 26, 27, 12932, 30, 31, 32, 25694, 2, 355, 298, 26490, 26018, 59, 8712, 61, 62, 28116, 23459, 91, 92, 93, 94, 1103, 88, 23, 70, 2, 355, 9926, 88, 1257, 1103, 88, 2835, 1103, 88, 2564, 1103, 88, 2658, 1103, 88, 1349, 1103, 88, 2426, 1103, 88, 1184, 1103, 88, 1555, 1103, 88, 1299, 1103, 88, 1407, 1103, 88, 24, 65, 1103, 88, 24, 66, 1103, 88, 24, 67, 1103, 88, 24, 68, 2, 355, 9926, 88, 24, 69, 1103, 88, 24, 70, 1103, 88, 2710, 1103, 88, 3328, 1103, 88, 2942, 1103, 88, 3129, 1103, 88, 2635, 1103, 88, 2720, 1103, 88, 2534, 1103, 88, 2576, 1103, 88, 2905, 1103, 88, 1020, 1103, 88, 25, 65, 1103, 88, 25, 66, 2, 355, 9926, 88, 25, 67, 1103, 88, 25, 68, 1103, 88, 25, 69, 1103, 88, 25, 70, 1103, 1800, 16, 1103, 1800, 17, 1103, 1800, 18, 1103, 1800, 19, 1103, 1800, 20, 1103, 1800, 21, 1103, 1800 ]
[ 1379, 2884, 367, 314, 6140, 4514, 14, 199, 199, 32329, 701, 603, 9912, 13, 3325, 264, 7005, 32649, 334, 2174, 32, 274, 32649, 14, 957, 680, 199, 199, 8, 67, 9, 1898, 445, 46, 6129, 12, 2900, 5924, 5702, 14, 4825, 3408, 14, 199, 199, 624, 23662, 199, 646, 6010, 199, 646, 2702, 199, 646, 984, 199, 646, 2882, 199, 646, 3598, 199, 504, 511, 492, 2291, 12, 1059, 63, 2219, 199, 646, 485, 875, 199, 199, 3, 4520, 7252, 334, 4087, 10334, 372, 9, 199, 318, 2754, 63, 1593, 8, 2991, 304, 272, 347, 4849, 17, 8, 1210, 12, 2552, 628, 4768, 2349, 267, 372, 5685, 327, 440, 282, 2008, 272, 347, 3752, 17, 8, 1210, 12, 2552, 628, 4768, 2349, 267, 372, 5685, 327, 440, 282, 2008, 272, 347, 3752, 18, 8, 1210, 12, 2552, 628, 4768, 2349, 267, 372, 334, 2260, 12, 5685, 9, 327, 949, 2649, 272, 347, 4849, 18, 8, 1210, 12, 2552, 628, 4768, 2349, 267, 372, 334, 2260, 12, 5685, 9, 327, 949, 2649, 272, 340, 2644, 11800, 396, 14, 2975, 17, 582, 267, 372, 334, 2143, 17, 12, 4849, 17, 12, 488, 12, 488, 9, 272, 916, 2644, 11800, 396, 14, 2975, 18, 582, 267, 372, 334, 2143, 18, 12, 4849, 18, 12, 488, 12, 488, 9, 272, 587, 26, 267, 372, 488, 199, 8933, 14, 2683, 8, 1733, 63, 1593, 9, 199, 199, 533, 6140, 774, 8, 875, 63, 2219, 14, 7844, 774, 12, 267, 1059, 63, 2219, 14, 4256, 2848, 7087, 1899, 1558, 774, 12, 267, 1059, 63, 2219, 14, 4256, 2848, 7087, 774, 304, 339, 730, 18, 396, 275, 620, 339, 347, 1104, 1452, 889, 970, 8, 277, 12, 754, 12, 909, 12, 28009, 12, 627, 589, 304, 267, 1083, 275, 2519, 8, 785, 12, 28009, 9, 267, 3363, 1099, 275, 1083, 2031, 589, 9, 267, 291, 14, 629, 8, 3093, 1099, 12, 754, 9, 267, 291, 14, 1815, 8, 466, 8, 3093, 1099, 9, 365, 730, 8, 1099, 430, 398, 327, 340, 314, 3379, 365, 2138, 1852, 3238, 626, 267, 327, 642, 3181, 1133, 5992, 543, 9180, 267, 340, 3363, 1099, 365, 909, 26, 288, 1021, 399, 954, 8, 495, 304, 355, 347, 636, 2722, 721, 277, 304, 490, 372, 283, 527, 456, 4042, 82, 3171, 450, 620, 855, 2722, 721, 277, 9, 288, 909, 275, 399, 954, 8, 785, 9, 288, 1083, 275, 2519, 8, 785, 12, 28009, 9, 288, 3363, 1099, 275, 1083, 2031, 589, 9, 288, 291, 14, 629, 8, 3093, 1099, 12, 754, 9, 288, 291, 14, 1815, 8, 785, 365, 440, 3363, 1099, 9, 339, 347, 511, 63, 5955, 8, 277, 304, 267, 291, 14, 629, 2258, 3581, 297, 1557, 85, 383, 556, 358, 267, 291, 14, 629, 2258, 3043, 556, 297, 1557, 53, 993, 4717, 358, 267, 291, 14, 1855, 8, 9294, 12, 3468, 12, 1557, 8124, 53, 12596, 771, 3985, 358, 267, 291, 14, 1855, 8, 9294, 12, 3468, 12, 1557, 8124, 53, 15798, 3985, 358, 267, 291, 14, 1855, 8, 9294, 12, 3468, 12, 1557, 8124, 53, 5, 2036, 88, 60, 891, 450, 378, 88, 845, 993, 9, 267, 327, 3066, 3326, 1077, 440, 1172, 2649, 24644, 267, 291, 14, 7418, 8, 82, 3212, 85, 20734, 401, 298, 6099, 339, 347, 511, 63, 4371, 8, 277, 304, 267, 340, 440, 984, 14, 3246, 14, 2460, 360, 6138, 735, 288, 327, 1379, 5678, 16740, 402, 4700, 342, 288, 291, 14, 629, 8, 4371, 360, 3175, 659, 3546, 3175, 9859, 288, 291, 14, 629, 8, 4371, 360, 371, 1103, 67, 659, 3546, 371, 8712, 67, 9859, 288, 291, 14, 629, 8, 4371, 360, 371, 1103, 659, 3546, 371, 8712, 9859, 288, 291, 14, 629, 8, 4371, 11671, 67, 659, 3546, 8712, 67, 9859, 288, 291, 14, 629, 8, 4371, 11671, 659, 3546, 8712, 9859, 288, 291, 14, 629, 8, 4371, 2258, 78, 659, 3546, 1103, 78, 9859, 288, 291, 14, 629, 8, 4371, 2258, 82, 659, 3546, 1103, 82, 9859, 288, 291, 14, 629, 8, 4371, 2258, 84, 659, 3546, 1103, 84, 9859, 288, 291, 14, 629, 8, 4371, 2258, 66, 659, 3546, 1103, 88, 2036, 9859, 288, 291, 14, 629, 8, 4371, 480, 1154, 341, 395, 408, 8124, 30385, 6141, 288, 291, 14, 629, 8, 4371, 480, 1154, 341, 395, 408, 8124, 30385, 6141, 288, 291, 14, 629, 8, 4371, 15587, 1288, 1449, 2, 4065, 12310, 288, 291, 14, 629, 8, 4371, 14088, 659, 408, 30385, 6141, 288, 16899, 17, 2722, 275, 334, 355, 3546, 1103, 88, 383, 1103, 88, 614, 1103, 88, 996, 1103, 88, 1644, 1103, 88, 966, 1103, 88, 1717, 1103, 88, 1690, 1103, 88, 1780, 1103, 88, 2036, 1103, 84, 1103, 78, 1103, 88, 16, 66, 1103, 88, 16, 67, 1103, 82, 2, 355, 9926, 88, 16, 69, 1103, 88, 16, 70, 1103, 88, 709, 1103, 88, 845, 1103, 88, 713, 1103, 88, 969, 1103, 88, 1079, 1103, 88, 1046, 1103, 88, 975, 1103, 88, 1196, 1103, 88, 1085, 1103, 88, 1167, 1103, 88, 17, 65, 2, 355, 9926, 88, 17, 66, 1103, 88, 17, 67, 1103, 88, 17, 68, 1103, 88, 17, 69, 1103, 88, 17, 70, 8546, 4451, 3, 22074, 6, 1103, 7, 25608, 11, 3057, 13186, 11371, 26, 27, 12932, 30, 31, 32, 25694, 2, 355, 298, 26490, 26018, 59, 8712, 61, 62, 28116, 23459, 91, 92, 93, 94, 1103, 88, 23, 70, 2, 355, 9926, 88, 1257, 1103, 88, 2835, 1103, 88, 2564, 1103, 88, 2658, 1103, 88, 1349, 1103, 88, 2426, 1103, 88, 1184, 1103, 88, 1555, 1103, 88, 1299, 1103, 88, 1407, 1103, 88, 24, 65, 1103, 88, 24, 66, 1103, 88, 24, 67, 1103, 88, 24, 68, 2, 355, 9926, 88, 24, 69, 1103, 88, 24, 70, 1103, 88, 2710, 1103, 88, 3328, 1103, 88, 2942, 1103, 88, 3129, 1103, 88, 2635, 1103, 88, 2720, 1103, 88, 2534, 1103, 88, 2576, 1103, 88, 2905, 1103, 88, 1020, 1103, 88, 25, 65, 1103, 88, 25, 66, 2, 355, 9926, 88, 25, 67, 1103, 88, 25, 68, 1103, 88, 25, 69, 1103, 88, 25, 70, 1103, 1800, 16, 1103, 1800, 17, 1103, 1800, 18, 1103, 1800, 19, 1103, 1800, 20, 1103, 1800, 21, 1103, 1800, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Stackato-Apps/pinry
pinry/core/migrations/0001_initial.py
3
1615
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations import taggit.managers class Migration(migrations.Migration): dependencies = [ ('taggit', '0002_auto_20150616_2121'), ('users', '__first__'), ('django_images', '__first__'), ] operations = [ migrations.CreateModel( name='Pin', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('url', models.URLField(null=True)), ('origin', models.URLField(null=True)), ('description', models.TextField(null=True, blank=True)), ('published', models.DateTimeField(auto_now_add=True)), ], ), migrations.CreateModel( name='Image', fields=[ ], options={ 'proxy': True, }, bases=('django_images.image',), ), migrations.AddField( model_name='pin', name='image', field=models.ForeignKey(related_name='pin', to='core.Image'), ), migrations.AddField( model_name='pin', name='submitter', field=models.ForeignKey(to='users.User'), ), migrations.AddField( model_name='pin', name='tags', field=taggit.managers.TaggableManager(to='taggit.Tag', through='taggit.TaggedItem', help_text='A comma-separated list of tags.', verbose_name='Tags'), ), ]
bsd-2-clause
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 199, 646, 1947, 3187, 14, 16259, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 1450, 3187, 297, 283, 9425, 63, 2495, 63, 1797, 13725, 975, 63, 18, 10753, 659, 267, 661, 3707, 297, 2560, 2246, 363, 659, 267, 661, 1176, 63, 4782, 297, 2560, 2246, 363, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 19909, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 8437, 29, 797, 12, 2599, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 633, 297, 1709, 14, 17363, 8, 2307, 29, 549, 1826, 355, 661, 6493, 297, 1709, 14, 17363, 8, 2307, 29, 549, 1826, 355, 661, 1802, 297, 1709, 14, 6254, 8, 2307, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 8987, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 1826, 288, 2156, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 3491, 297, 288, 1504, 1524, 288, 2156, 288, 1511, 3126, 355, 283, 3280, 356, 715, 12, 288, 1660, 288, 9768, 7782, 1176, 63, 4782, 14, 1569, 5529, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7751, 297, 288, 536, 534, 1569, 297, 288, 901, 29, 992, 14, 3190, 8, 2407, 63, 354, 534, 7751, 297, 370, 534, 1018, 14, 3491, 659, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7751, 297, 288, 536, 534, 7275, 351, 297, 288, 901, 29, 992, 14, 3190, 8, 475, 534, 3707, 14, 1899, 659, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7751, 297, 288, 536, 534, 2969, 297, 288, 901, 29, 1450, 3187, 14, 16259, 14, 1931, 16725, 2988, 8, 475, 534, 1450, 3187, 14, 1931, 297, 4012, 534, 1450, 3187, 14, 26403, 2081, 297, 1720, 63, 505, 534, 33, 10029, 13, 12794, 769, 402, 3762, 3130, 3376, 63, 354, 534, 9440, 659, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 504, 1639, 14, 697, 492, 1709, 12, 6180, 199, 646, 1947, 3187, 14, 16259, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 661, 1450, 3187, 297, 283, 9425, 63, 2495, 63, 1797, 13725, 975, 63, 18, 10753, 659, 267, 661, 3707, 297, 2560, 2246, 363, 659, 267, 661, 1176, 63, 4782, 297, 2560, 2246, 363, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 14907, 8, 288, 536, 534, 19909, 297, 288, 1504, 1524, 355, 661, 344, 297, 1709, 14, 4378, 8, 3832, 63, 354, 534, 998, 297, 8437, 29, 797, 12, 2599, 63, 3966, 29, 549, 12, 5062, 63, 498, 29, 549, 1826, 355, 661, 633, 297, 1709, 14, 17363, 8, 2307, 29, 549, 1826, 355, 661, 6493, 297, 1709, 14, 17363, 8, 2307, 29, 549, 1826, 355, 661, 1802, 297, 1709, 14, 6254, 8, 2307, 29, 549, 12, 4596, 29, 549, 1826, 355, 661, 8987, 297, 1709, 14, 4626, 8, 2495, 63, 2131, 63, 525, 29, 549, 1826, 288, 2156, 267, 2318, 267, 6180, 14, 14907, 8, 288, 536, 534, 3491, 297, 288, 1504, 1524, 288, 2156, 288, 1511, 3126, 355, 283, 3280, 356, 715, 12, 288, 1660, 288, 9768, 7782, 1176, 63, 4782, 14, 1569, 5529, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7751, 297, 288, 536, 534, 1569, 297, 288, 901, 29, 992, 14, 3190, 8, 2407, 63, 354, 534, 7751, 297, 370, 534, 1018, 14, 3491, 659, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7751, 297, 288, 536, 534, 7275, 351, 297, 288, 901, 29, 992, 14, 3190, 8, 475, 534, 3707, 14, 1899, 659, 267, 2318, 267, 6180, 14, 18381, 8, 288, 1402, 63, 354, 534, 7751, 297, 288, 536, 534, 2969, 297, 288, 901, 29, 1450, 3187, 14, 16259, 14, 1931, 16725, 2988, 8, 475, 534, 1450, 3187, 14, 1931, 297, 4012, 534, 1450, 3187, 14, 26403, 2081, 297, 1720, 63, 505, 534, 33, 10029, 13, 12794, 769, 402, 3762, 3130, 3376, 63, 354, 534, 9440, 659, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
bravo-zhang/spark
examples/src/main/python/mllib/sampled_rdds.py
51
3224
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # """ Randomly sampled RDDs. """ from __future__ import print_function import sys from pyspark import SparkContext from pyspark.mllib.util import MLUtils if __name__ == "__main__": if len(sys.argv) not in [1, 2]: print("Usage: sampled_rdds <libsvm data file>", file=sys.stderr) sys.exit(-1) if len(sys.argv) == 2: datapath = sys.argv[1] else: datapath = 'data/mllib/sample_binary_classification_data.txt' sc = SparkContext(appName="PythonSampledRDDs") fraction = 0.1 # fraction of data to sample examples = MLUtils.loadLibSVMFile(sc, datapath) numExamples = examples.count() if numExamples == 0: print("Error: Data file had no samples to load.", file=sys.stderr) sys.exit(1) print('Loaded data with %d examples from file: %s' % (numExamples, datapath)) # Example: RDD.sample() and RDD.takeSample() expectedSampleSize = int(numExamples * fraction) print('Sampling RDD using fraction %g. Expected sample size = %d.' % (fraction, expectedSampleSize)) sampledRDD = examples.sample(withReplacement=True, fraction=fraction) print(' RDD.sample(): sample has %d examples' % sampledRDD.count()) sampledArray = examples.takeSample(withReplacement=True, num=expectedSampleSize) print(' RDD.takeSample(): sample has %d examples' % len(sampledArray)) print() # Example: RDD.sampleByKey() keyedRDD = examples.map(lambda lp: (int(lp.label), lp.features)) print(' Keyed data using label (Int) as key ==> Orig') # Count examples per label in original data. keyCountsA = keyedRDD.countByKey() # Subsample, and count examples per label in sampled data. fractions = {} for k in keyCountsA.keys(): fractions[k] = fraction sampledByKeyRDD = keyedRDD.sampleByKey(withReplacement=True, fractions=fractions) keyCountsB = sampledByKeyRDD.countByKey() sizeB = sum(keyCountsB.values()) print(' Sampled %d examples using approximate stratified sampling (by label). ==> Sample' % sizeB) # Compare samples print(' \tFractions of examples with key') print('Key\tOrig\tSample') for k in sorted(keyCountsA.keys()): fracA = keyCountsA[k] / float(numExamples) if sizeB != 0: fracB = keyCountsB.get(k, 0) / float(sizeB) else: fracB = 0 print('%d\t%g\t%g' % (k, fracA, fracB)) sc.stop()
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 199, 3883, 590, 24914, 21310, 83, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 984, 199, 199, 504, 15847, 492, 21769, 199, 504, 15847, 14, 25598, 14, 1974, 492, 28007, 7535, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 340, 822, 8, 1274, 14, 3020, 9, 440, 315, 359, 17, 12, 499, 2189, 267, 870, 480, 7692, 26, 24914, 63, 20533, 83, 665, 8450, 2611, 666, 570, 7166, 570, 29, 1274, 14, 3083, 9, 267, 984, 14, 2224, 2801, 17, 9, 272, 340, 822, 8, 1274, 14, 3020, 9, 508, 499, 26, 267, 24991, 275, 984, 14, 3020, 59, 17, 61, 272, 587, 26, 267, 24991, 275, 283, 576, 15, 25598, 15, 3271, 63, 3008, 63, 14368, 63, 576, 14, 2424, 7, 339, 4061, 275, 21769, 8, 571, 985, 628, 4718, 8176, 68, 24378, 83, 531, 339, 12347, 275, 378, 14, 17, 221, 327, 12347, 402, 666, 370, 2690, 339, 7251, 275, 28007, 7535, 14, 912, 4728, 29389, 1173, 8, 551, 12, 24991, 9, 272, 1967, 22787, 275, 7251, 14, 835, 342, 272, 340, 1967, 22787, 508, 378, 26, 267, 870, 480, 547, 26, 3918, 570, 10530, 949, 5845, 370, 2248, 4765, 570, 29, 1274, 14, 3083, 9, 267, 984, 14, 2224, 8, 17, 9, 272, 870, 360, 19757, 666, 543, 450, 68, 7251, 687, 570, 26, 450, 83, 7, 450, 334, 1507, 22787, 12, 24991, 430, 339, 327, 5679, 26, 21310, 14, 3271, 342, 436, 21310, 14, 11066, 8176, 342, 272, 1420, 8176, 2320, 275, 1109, 8, 1507, 22787, 627, 12347, 9, 272, 870, 360, 12226, 8922, 21310, 1808, 12347, 450, 71, 14, 221, 13796, 2690, 1568, 275, 450, 68, 3530, 881, 450, 334, 13054, 12, 1420, 8176, 2320, 430, 272, 24914, 24378, 275, 7251, 14, 3271, 8, 1045, 29475, 29, 549, 12, 12347, 29, 13054, 9, 272, 870, 360, 221, 21310, 14, 3271, 837, 2690, 965, 450, 68, 7251, 7, 450, 24914, 24378, 14, 835, 1012, 272, 24914, 3836, 275, 7251, 14, 11066, 8176, 8, 1045, 29475, 29, 549, 12, 1967, 29, 2062, 8176, 2320, 9, 272, 870, 360, 221, 21310, 14, 11066, 8176, 837, 2690, 965, 450, 68, 7251, 7, 450, 822, 8, 25042, 3836, 430, 339, 870, 342, 339, 327, 5679, 26, 21310, 14, 3271, 2175, 1197, 342, 272, 19272, 24378, 275, 7251, 14, 1130, 8, 2734, 13204, 26, 334, 442, 8, 10343, 14, 1302, 395, 13204, 14, 3179, 430, 272, 870, 360, 221, 2606, 379, 666, 1808, 1768, 334, 3241, 9, 465, 790, 25375, 593, 322, 71, 358, 272, 327, 221, 14826, 7251, 1126, 1768, 315, 3379, 666, 14, 272, 790, 23209, 33, 275, 19272, 24378, 14, 835, 2175, 1197, 342, 339, 327, 221, 4804, 3271, 12, 436, 2338, 7251, 1126, 1768, 315, 24914, 666, 14, 272, 28213, 2452, 275, 1052, 272, 367, 1022, 315, 790, 23209, 33, 14, 1612, 837, 267, 28213, 2452, 59, 75, 61, 275, 12347, 272, 24914, 2175, 1197, 24378, 275, 19272, 24378, 14, 3271, 2175, 1197, 8, 1045, 29475, 29, 549, 12, 28213, 2452, 29, 21844, 2452, 9, 272, 790, 23209, 34, 275, 24914, 2175, 1197, 24378, 14, 835, 2175, 1197, 342, 272, 1568, 34, 275, 3089, 8, 498, 23209, 34, 14, 1459, 1012, 272, 870, 360, 221, 15227, 68, 450, 68, 7251, 1808, 19917, 20370, 8981, 15877, 334, 991, 1768, 680, 25375, 15227, 7, 881, 450, 1568, 34, 9, 339, 327, 221, 18955, 5845, 272, 870, 360, 257, 971, 84, 38, 345, 2452, 402, 7251, 543, 790, 358, 272, 870, 360, 1197, 60, 84, 29698, 60, 84, 8176, 358, 272, 367, 1022, 315, 3355, 8, 498, 23209, 33, 14, 1612, 5109, 267, 25028, 33, 275, 790, 23209, 33, 59, 75, 61, 1182, 2069, 8, 1507, 22787, 9, 267, 340, 1568, 34, 1137, 378, 26, 288, 25028, 34, 275, 790, 23209, 34, 14, 362, 8, 75, 12, 378, 9, 1182, 2069, 8, 890, 34, 9, 267, 587, 26, 288, 25028, 34, 275, 378, 267, 870, 3508, 68, 60, 84, 5, 71, 60, 84, 5, 71, 7, 450, 334, 75, 12, 25028, 33, 12, 25028, 34, 430, 339, 4061, 14, 2379, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 624, 199, 3883, 590, 24914, 21310, 83, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 984, 199, 199, 504, 15847, 492, 21769, 199, 504, 15847, 14, 25598, 14, 1974, 492, 28007, 7535, 421, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 340, 822, 8, 1274, 14, 3020, 9, 440, 315, 359, 17, 12, 499, 2189, 267, 870, 480, 7692, 26, 24914, 63, 20533, 83, 665, 8450, 2611, 666, 570, 7166, 570, 29, 1274, 14, 3083, 9, 267, 984, 14, 2224, 2801, 17, 9, 272, 340, 822, 8, 1274, 14, 3020, 9, 508, 499, 26, 267, 24991, 275, 984, 14, 3020, 59, 17, 61, 272, 587, 26, 267, 24991, 275, 283, 576, 15, 25598, 15, 3271, 63, 3008, 63, 14368, 63, 576, 14, 2424, 7, 339, 4061, 275, 21769, 8, 571, 985, 628, 4718, 8176, 68, 24378, 83, 531, 339, 12347, 275, 378, 14, 17, 221, 327, 12347, 402, 666, 370, 2690, 339, 7251, 275, 28007, 7535, 14, 912, 4728, 29389, 1173, 8, 551, 12, 24991, 9, 272, 1967, 22787, 275, 7251, 14, 835, 342, 272, 340, 1967, 22787, 508, 378, 26, 267, 870, 480, 547, 26, 3918, 570, 10530, 949, 5845, 370, 2248, 4765, 570, 29, 1274, 14, 3083, 9, 267, 984, 14, 2224, 8, 17, 9, 272, 870, 360, 19757, 666, 543, 450, 68, 7251, 687, 570, 26, 450, 83, 7, 450, 334, 1507, 22787, 12, 24991, 430, 339, 327, 5679, 26, 21310, 14, 3271, 342, 436, 21310, 14, 11066, 8176, 342, 272, 1420, 8176, 2320, 275, 1109, 8, 1507, 22787, 627, 12347, 9, 272, 870, 360, 12226, 8922, 21310, 1808, 12347, 450, 71, 14, 221, 13796, 2690, 1568, 275, 450, 68, 3530, 881, 450, 334, 13054, 12, 1420, 8176, 2320, 430, 272, 24914, 24378, 275, 7251, 14, 3271, 8, 1045, 29475, 29, 549, 12, 12347, 29, 13054, 9, 272, 870, 360, 221, 21310, 14, 3271, 837, 2690, 965, 450, 68, 7251, 7, 450, 24914, 24378, 14, 835, 1012, 272, 24914, 3836, 275, 7251, 14, 11066, 8176, 8, 1045, 29475, 29, 549, 12, 1967, 29, 2062, 8176, 2320, 9, 272, 870, 360, 221, 21310, 14, 11066, 8176, 837, 2690, 965, 450, 68, 7251, 7, 450, 822, 8, 25042, 3836, 430, 339, 870, 342, 339, 327, 5679, 26, 21310, 14, 3271, 2175, 1197, 342, 272, 19272, 24378, 275, 7251, 14, 1130, 8, 2734, 13204, 26, 334, 442, 8, 10343, 14, 1302, 395, 13204, 14, 3179, 430, 272, 870, 360, 221, 2606, 379, 666, 1808, 1768, 334, 3241, 9, 465, 790, 25375, 593, 322, 71, 358, 272, 327, 221, 14826, 7251, 1126, 1768, 315, 3379, 666, 14, 272, 790, 23209, 33, 275, 19272, 24378, 14, 835, 2175, 1197, 342, 339, 327, 221, 4804, 3271, 12, 436, 2338, 7251, 1126, 1768, 315, 24914, 666, 14, 272, 28213, 2452, 275, 1052, 272, 367, 1022, 315, 790, 23209, 33, 14, 1612, 837, 267, 28213, 2452, 59, 75, 61, 275, 12347, 272, 24914, 2175, 1197, 24378, 275, 19272, 24378, 14, 3271, 2175, 1197, 8, 1045, 29475, 29, 549, 12, 28213, 2452, 29, 21844, 2452, 9, 272, 790, 23209, 34, 275, 24914, 2175, 1197, 24378, 14, 835, 2175, 1197, 342, 272, 1568, 34, 275, 3089, 8, 498, 23209, 34, 14, 1459, 1012, 272, 870, 360, 221, 15227, 68, 450, 68, 7251, 1808, 19917, 20370, 8981, 15877, 334, 991, 1768, 680, 25375, 15227, 7, 881, 450, 1568, 34, 9, 339, 327, 221, 18955, 5845, 272, 870, 360, 257, 971, 84, 38, 345, 2452, 402, 7251, 543, 790, 358, 272, 870, 360, 1197, 60, 84, 29698, 60, 84, 8176, 358, 272, 367, 1022, 315, 3355, 8, 498, 23209, 33, 14, 1612, 5109, 267, 25028, 33, 275, 790, 23209, 33, 59, 75, 61, 1182, 2069, 8, 1507, 22787, 9, 267, 340, 1568, 34, 1137, 378, 26, 288, 25028, 34, 275, 790, 23209, 34, 14, 362, 8, 75, 12, 378, 9, 1182, 2069, 8, 890, 34, 9, 267, 587, 26, 288, 25028, 34, 275, 378, 267, 870, 3508, 68, 60, 84, 5, 71, 60, 84, 5, 71, 7, 450, 334, 75, 12, 25028, 33, 12, 25028, 34, 430, 339, 4061, 14, 2379, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1,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unbie/NS3-
src/mesh/bindings/callbacks_list.py
16
2441
callback_classes = [ ['void', 'ns3::Mac48Address', 'ns3::Mac48Address', 'unsigned int', 'bool', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'unsigned int', 'ns3::Mac48Address', 'ns3::Mac48Address', 'ns3::dot11s::PeerLink::PeerState', 'ns3::dot11s::PeerLink::PeerState', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['std::vector<ns3::Mac48Address, std::allocator<ns3::Mac48Address> >', 'unsigned int', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'bool', 'ns3::Ptr<ns3::Packet>', 'ns3::Mac48Address', 'ns3::Mac48Address', 'unsigned short', 'unsigned int', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['unsigned int', 'ns3::Mac48Address', 'ns3::Ptr<ns3::MeshWifiInterfaceMac>', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::WifiMacHeader const&', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr<ns3::Packet>', 'ns3::Mac48Address', 'ns3::Mac48Address', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Mac48Address', 'unsigned char', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Mac48Address', 'unsigned char', 'bool', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['void', 'ns3::Ptr<ns3::NetDevice>', 'ns3::Ptr<ns3::Packet const>', 'unsigned short', 'ns3::Address const&', 'ns3::Address const&', 'ns3::NetDevice::PacketType', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['bool', 'ns3::Ptr<ns3::NetDevice>', 'ns3::Ptr<ns3::Packet const>', 'unsigned short', 'ns3::Address const&', 'ns3::Address const&', 'ns3::NetDevice::PacketType', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['bool', 'ns3::Ptr<ns3::NetDevice>', 'ns3::Ptr<ns3::Packet const>', 'unsigned short', 'ns3::Address const&', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ['unsigned char', 'ns3::Ptr<ns3::QueueItem>', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'], ]
gpl-2.0
[ 3058, 63, 2888, 275, 359, 272, 788, 1647, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 2244, 1109, 297, 283, 2245, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 2244, 1109, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 3287, 845, 83, 447, 12566, 3834, 447, 12566, 2223, 297, 283, 561, 19, 447, 3287, 845, 83, 447, 12566, 3834, 447, 12566, 2223, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1516, 447, 4106, 28, 561, 19, 447, 3399, 2006, 1476, 12, 2418, 447, 14228, 28, 561, 19, 447, 3399, 2006, 1476, 30, 3445, 283, 2244, 1109, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 2245, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 2726, 4206, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 2244, 3974, 297, 283, 2244, 1109, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 2244, 1109, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 12241, 3848, 4267, 3399, 4206, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 561, 19, 447, 13194, 950, 16749, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 2726, 4206, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 2244, 1495, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 2244, 1495, 297, 283, 2245, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 4351, 4206, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 2726, 950, 4206, 283, 2244, 3974, 297, 283, 561, 19, 447, 1476, 950, 16749, 283, 561, 19, 447, 1476, 950, 16749, 283, 561, 19, 447, 4351, 447, 22327, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 2245, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 4351, 4206, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 2726, 950, 4206, 283, 2244, 3974, 297, 283, 561, 19, 447, 1476, 950, 16749, 283, 561, 19, 447, 1476, 950, 16749, 283, 561, 19, 447, 4351, 447, 22327, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 2245, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 4351, 4206, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 2726, 950, 4206, 283, 2244, 3974, 297, 283, 561, 19, 447, 1476, 950, 16749, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 2244, 1495, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 20729, 4206, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 199, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 63, 2888, 275, 359, 272, 788, 1647, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 2244, 1109, 297, 283, 2245, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 2244, 1109, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 3287, 845, 83, 447, 12566, 3834, 447, 12566, 2223, 297, 283, 561, 19, 447, 3287, 845, 83, 447, 12566, 3834, 447, 12566, 2223, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1516, 447, 4106, 28, 561, 19, 447, 3399, 2006, 1476, 12, 2418, 447, 14228, 28, 561, 19, 447, 3399, 2006, 1476, 30, 3445, 283, 2244, 1109, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 2245, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 2726, 4206, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 2244, 3974, 297, 283, 2244, 1109, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 2244, 1109, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 12241, 3848, 4267, 3399, 4206, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 561, 19, 447, 13194, 950, 16749, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 2726, 4206, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 2244, 1495, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 561, 19, 447, 3399, 2006, 1476, 297, 283, 2244, 1495, 297, 283, 2245, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 1647, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 4351, 4206, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 2726, 950, 4206, 283, 2244, 3974, 297, 283, 561, 19, 447, 1476, 950, 16749, 283, 561, 19, 447, 1476, 950, 16749, 283, 561, 19, 447, 4351, 447, 22327, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 2245, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 4351, 4206, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 2726, 950, 4206, 283, 2244, 3974, 297, 283, 561, 19, 447, 1476, 950, 16749, 283, 561, 19, 447, 1476, 950, 16749, 283, 561, 19, 447, 4351, 447, 22327, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 2245, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 4351, 4206, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 2726, 950, 4206, 283, 2244, 3974, 297, 283, 561, 19, 447, 1476, 950, 16749, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 272, 788, 2244, 1495, 297, 283, 561, 19, 447, 2115, 28, 561, 19, 447, 20729, 4206, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 297, 283, 561, 19, 447, 1667, 995, 199, 61, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
swails/mdtraj
mdtraj/tests/test_lprmsd.py
9
3770
from __future__ import print_function import numpy as np import mdtraj as md from mdtraj.testing import eq, get_fn from mdtraj import Trajectory, lprmsd from mdtraj._lprmsd import _munkres from mdtraj.utils import rotation_matrix_from_quaternion, uniform_quaternion random = np.random.RandomState(0) def test_munkres_0(): result = _munkres(np.array([[7, 4, 3], [6, 8, 5], [9, 4, 4]], dtype=np.double)) true = np.array([[0, 0, 1], [1, 0, 0], [0, 1, 0]], dtype=np.int32) eq(result, true) def test_lprmsd_0(): # remap a permutation of all the atoms with no rotation ref = random.randn(1, 10, 3).astype(np.float32) mapping = random.permutation(10) print('true mapping', mapping) new = ref[:, mapping] value = lprmsd(Trajectory(xyz=new, topology=None), Trajectory(xyz=ref, topology=None)) eq(value, np.array([0.0], dtype=np.float32), decimal=3) def test_lprmsd_1(): # resolve a random rotation with no permutation ref = random.randn(1, 50, 3).astype(np.float32) mapping = np.arange(50) rot = rotation_matrix_from_quaternion(uniform_quaternion()) new = ref[:, mapping].dot(rot) value = lprmsd(Trajectory(xyz=new, topology=None), Trajectory(xyz=ref, topology=None), permute_groups=[[]]) assert value[0] < 1e-2 def test_lprmsd_2(): # resolve a random rotation with some permutation ref = random.randn(1, 50, 3).astype(np.float32) # first half of the atoms can permute, last 10 are fixed permutation mapping = np.concatenate((random.permutation(10), 10 + np.arange(40))) rot = rotation_matrix_from_quaternion(uniform_quaternion()) new = ref[:, mapping].dot(rot) value = lprmsd(Trajectory(xyz=new, topology=None), Trajectory(xyz=ref, topology=None), permute_groups=[np.arange(10)]) assert value[0] < 1e-2 def test_lprmsd_3(): # resolve rotation and permutation togetehr t1 = md.load(get_fn('alanine-dipeptide-explicit.pdb'))[0] t2 = md.load(get_fn('alanine-dipeptide-explicit.pdb'))[0] h2o_o_indices = [a.index for a in t1.topology.atoms if a.residue.name == 'HOH' and a.element.symbol == 'O'][0:20] h2o_h_indices = [a.index for a in t1.topology.atoms if a.residue.name == 'HOH' and a.element.symbol == 'H'][0:20] backbone_indices = [a.index for a in t1.topology.atoms if a.element.symbol in ['C', 'N']][:5] # scramble two groups of indices t2.xyz[:, random.permutation(h2o_o_indices)] = t2.xyz[:, h2o_o_indices] t2.xyz[:, random.permutation(h2o_h_indices)] = t2.xyz[:, h2o_h_indices] # offset the backbone indices slightly t2.xyz[:, backbone_indices] += 0.001 * random.randn(len(backbone_indices), 3) # rotate everything rot = rotation_matrix_from_quaternion(uniform_quaternion()) t2.xyz[0].dot(rot) print('raw distinguishable indices', backbone_indices) atom_indices = np.concatenate((h2o_o_indices, backbone_indices)) value = md.lprmsd(t2, t1, atom_indices=atom_indices, permute_groups=[h2o_o_indices]) t1.xyz[:, h2o_o_indices] += random.randn(len(h2o_o_indices), 3) print('final value', value) assert value[0] < 1e-2 def test_lprmsd_4(): t1 = md.load(get_fn('1bpi.pdb')) t1.xyz += 0.05 * random.randn(t1.n_frames, t1.n_atoms, 3) t2 = md.load(get_fn('1bpi.pdb')) # some random indices indices = random.permutation(t1.n_atoms)[:t1.n_atoms-5] got = md.lprmsd(t2, t1, atom_indices=indices, permute_groups=[[]]) ref = md.rmsd(t2, t1, atom_indices=indices) eq(got, ref, decimal=3) def test_lprmsd_5(): t = md.load(get_fn('frame0.h5')) t1 = md.load(get_fn('frame0.h5')) r = md.rmsd(t, t1, 0) a = md.lprmsd(t, t1, 0, permute_groups=[[]], superpose=True) eq(a, r, decimal=3)
lgpl-2.1
[ 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 2680, 465, 980, 199, 199, 646, 6128, 22788, 465, 6128, 199, 504, 6128, 22788, 14, 4776, 492, 3850, 12, 664, 63, 2324, 199, 504, 6128, 22788, 492, 12643, 17928, 12, 634, 2700, 28982, 199, 504, 6128, 22788, 423, 76, 2700, 28982, 492, 485, 77, 1778, 470, 199, 504, 6128, 22788, 14, 1208, 492, 13038, 63, 3642, 63, 504, 63, 392, 28945, 12, 14818, 63, 392, 28945, 199, 2355, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 421, 199, 318, 511, 63, 77, 1778, 470, 63, 16, 837, 272, 754, 275, 485, 77, 1778, 470, 8, 1590, 14, 1144, 4038, 23, 12, 841, 12, 650, 467, 359, 22, 12, 1695, 12, 959, 467, 359, 25, 12, 841, 12, 841, 2365, 2152, 29, 1590, 14, 3157, 430, 272, 2549, 275, 980, 14, 1144, 4038, 16, 12, 378, 12, 413, 467, 2151, 359, 17, 12, 378, 12, 378, 467, 2151, 359, 16, 12, 413, 12, 378, 2365, 2152, 29, 1590, 14, 442, 708, 9, 272, 3850, 8, 1099, 12, 2549, 9, 421, 199, 318, 511, 63, 76, 2700, 28982, 63, 16, 837, 272, 327, 295, 1130, 282, 22966, 402, 1006, 314, 14503, 543, 949, 13038, 272, 2984, 275, 2196, 14, 10843, 8, 17, 12, 1616, 12, 650, 680, 6041, 8, 1590, 14, 1609, 708, 9, 272, 4412, 275, 2196, 14, 23832, 8, 709, 9, 272, 870, 360, 2052, 4412, 297, 4412, 9, 272, 892, 275, 2984, 3981, 4412, 61, 339, 574, 275, 634, 2700, 28982, 8, 2437, 17928, 8, 8568, 29, 1222, 12, 14611, 29, 403, 395, 12643, 17928, 8, 8568, 29, 1121, 12, 14611, 29, 403, 430, 272, 3850, 8, 585, 12, 980, 14, 1144, 779, 16, 14, 16, 467, 2152, 29, 1590, 14, 1609, 708, 395, 6107, 29, 19, 9, 421, 199, 318, 511, 63, 76, 2700, 28982, 63, 17, 837, 272, 327, 7512, 282, 2196, 13038, 543, 949, 22966, 272, 2984, 275, 2196, 14, 10843, 8, 17, 12, 5238, 12, 650, 680, 6041, 8, 1590, 14, 1609, 708, 9, 272, 4412, 275, 980, 14, 5605, 8, 1400, 9, 272, 7513, 275, 13038, 63, 3642, 63, 504, 63, 392, 28945, 8, 8830, 63, 392, 28945, 1012, 272, 892, 275, 2984, 3981, 4412, 1055, 3287, 8, 4571, 9, 2286, 574, 275, 634, 2700, 28982, 8, 2437, 17928, 8, 8568, 29, 1222, 12, 14611, 29, 403, 395, 12643, 17928, 8, 8568, 29, 1121, 12, 14611, 29, 403, 395, 10869, 938, 63, 2634, 16025, 3934, 272, 702, 574, 59, 16, 61, 665, 413, 69, 13, 18, 421, 199, 318, 511, 63, 76, 2700, 28982, 63, 18, 837, 272, 327, 7512, 282, 2196, 13038, 543, 2005, 22966, 272, 2984, 275, 2196, 14, 10843, 8, 17, 12, 5238, 12, 650, 680, 6041, 8, 1590, 14, 1609, 708, 9, 272, 327, 1642, 12995, 402, 314, 14503, 883, 10869, 938, 12, 2061, 1616, 787, 6317, 22966, 272, 4412, 275, 980, 14, 13433, 1332, 2355, 14, 23832, 8, 709, 395, 1616, 435, 980, 14, 5605, 8, 2167, 1724, 272, 7513, 275, 13038, 63, 3642, 63, 504, 63, 392, 28945, 8, 8830, 63, 392, 28945, 1012, 272, 892, 275, 2984, 3981, 4412, 1055, 3287, 8, 4571, 9, 2286, 574, 275, 634, 2700, 28982, 8, 2437, 17928, 8, 8568, 29, 1222, 12, 14611, 29, 403, 395, 12643, 17928, 8, 8568, 29, 1121, 12, 14611, 29, 403, 395, 10869, 938, 63, 2634, 1524, 1590, 14, 5605, 8, 709, 3948, 272, 702, 574, 59, 16, 61, 665, 413, 69, 13, 18, 421, 199, 318, 511, 63, 76, 2700, 28982, 63, 19, 837, 272, 327, 7512, 13038, 436, 22966, 370, 31508, 6271, 272, 307, 17, 275, 6128, 14, 912, 8, 362, 63, 2324, 360, 279, 290, 1132, 13, 328, 12636, 280, 271, 13, 10306, 14, 10511, 1333, 59, 16, 61, 272, 307, 18, 275, 6128, 14, 912, 8, 362, 63, 2324, 360, 279, 290, 1132, 13, 328, 12636, 280, 271, 13, 10306, 14, 10511, 1333, 59, 16, 61, 339, 394, 18, 79, 63, 79, 63, 4108, 275, 359, 65, 14, 1080, 367, 282, 315, 307, 17, 14, 10775, 14, 11521, 340, 282, 14, 19581, 310, 14, 354, 508, 283, 2979, 40, 7, 436, 282, 14, 2108, 14, 5155, 508, 283, 47, 3488, 16, 26, 1165, 61, 272, 394, 18, 79, 63, 72, 63, 4108, 275, 359, 65, 14, 1080, 367, 282, 315, 307, 17, 14, 10775, 14, 11521, 340, 282, 14, 19581, 310, 14, 354, 508, 283, 2979, 40, 7, 436, 282, 14, 2108, 14, 5155, 508, 283, 40, 3488, 16, 26, 1165, 61, 272, 1771, 21134, 63, 4108, 275, 359, 65, 14, 1080, 367, 282, 315, 307, 17, 14, 10775, 14, 11521, 340, 282, 14, 2108, 14, 5155, 315, 788, 35, 297, 283, 46, 6538, 1491, 21, 61, 339, 327, 4061, 5975, 830, 2877, 4652, 402, 4918, 272, 307, 18, 14, 8568, 3981, 2196, 14, 23832, 8, 72, 18, 79, 63, 79, 63, 4108, 1874, 275, 307, 18, 14, 8568, 3981, 394, 18, 79, 63, 79, 63, 4108, 61, 272, 307, 18, 14, 8568, 3981, 2196, 14, 23832, 8, 72, 18, 79, 63, 72, 63, 4108, 1874, 275, 307, 18, 14, 8568, 3981, 394, 18, 79, 63, 72, 63, 4108, 61, 339, 327, 3268, 314, 1771, 21134, 4918, 18023, 272, 307, 18, 14, 8568, 3981, 1771, 21134, 63, 4108, 61, 847, 378, 14, 4587, 627, 2196, 14, 10843, 8, 552, 8, 894, 21134, 63, 4108, 395, 650, 9, 339, 327, 20071, 8137, 272, 7513, 275, 13038, 63, 3642, 63, 504, 63, 392, 28945, 8, 8830, 63, 392, 28945, 1012, 272, 307, 18, 14, 8568, 59, 16, 1055, 3287, 8, 4571, 9, 339, 870, 360, 1773, 22237, 461, 4918, 297, 1771, 21134, 63, 4108, 9, 272, 6222, 63, 4108, 275, 980, 14, 13433, 1332, 72, 18, 79, 63, 79, 63, 4108, 12, 1771, 21134, 63, 4108, 430, 272, 574, 275, 6128, 14, 76, 2700, 28982, 8, 84, 18, 12, 307, 17, 12, 6222, 63, 4108, 29, 4188, 63, 4108, 12, 10869, 938, 63, 2634, 1524, 72, 18, 79, 63, 79, 63, 4108, 566, 272, 307, 17, 14, 8568, 3981, 394, 18, 79, 63, 79, 63, 4108, 61, 847, 2196, 14, 10843, 8, 552, 8, 72, 18, 79 ]
[ 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 2680, 465, 980, 199, 199, 646, 6128, 22788, 465, 6128, 199, 504, 6128, 22788, 14, 4776, 492, 3850, 12, 664, 63, 2324, 199, 504, 6128, 22788, 492, 12643, 17928, 12, 634, 2700, 28982, 199, 504, 6128, 22788, 423, 76, 2700, 28982, 492, 485, 77, 1778, 470, 199, 504, 6128, 22788, 14, 1208, 492, 13038, 63, 3642, 63, 504, 63, 392, 28945, 12, 14818, 63, 392, 28945, 199, 2355, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 421, 199, 318, 511, 63, 77, 1778, 470, 63, 16, 837, 272, 754, 275, 485, 77, 1778, 470, 8, 1590, 14, 1144, 4038, 23, 12, 841, 12, 650, 467, 359, 22, 12, 1695, 12, 959, 467, 359, 25, 12, 841, 12, 841, 2365, 2152, 29, 1590, 14, 3157, 430, 272, 2549, 275, 980, 14, 1144, 4038, 16, 12, 378, 12, 413, 467, 2151, 359, 17, 12, 378, 12, 378, 467, 2151, 359, 16, 12, 413, 12, 378, 2365, 2152, 29, 1590, 14, 442, 708, 9, 272, 3850, 8, 1099, 12, 2549, 9, 421, 199, 318, 511, 63, 76, 2700, 28982, 63, 16, 837, 272, 327, 295, 1130, 282, 22966, 402, 1006, 314, 14503, 543, 949, 13038, 272, 2984, 275, 2196, 14, 10843, 8, 17, 12, 1616, 12, 650, 680, 6041, 8, 1590, 14, 1609, 708, 9, 272, 4412, 275, 2196, 14, 23832, 8, 709, 9, 272, 870, 360, 2052, 4412, 297, 4412, 9, 272, 892, 275, 2984, 3981, 4412, 61, 339, 574, 275, 634, 2700, 28982, 8, 2437, 17928, 8, 8568, 29, 1222, 12, 14611, 29, 403, 395, 12643, 17928, 8, 8568, 29, 1121, 12, 14611, 29, 403, 430, 272, 3850, 8, 585, 12, 980, 14, 1144, 779, 16, 14, 16, 467, 2152, 29, 1590, 14, 1609, 708, 395, 6107, 29, 19, 9, 421, 199, 318, 511, 63, 76, 2700, 28982, 63, 17, 837, 272, 327, 7512, 282, 2196, 13038, 543, 949, 22966, 272, 2984, 275, 2196, 14, 10843, 8, 17, 12, 5238, 12, 650, 680, 6041, 8, 1590, 14, 1609, 708, 9, 272, 4412, 275, 980, 14, 5605, 8, 1400, 9, 272, 7513, 275, 13038, 63, 3642, 63, 504, 63, 392, 28945, 8, 8830, 63, 392, 28945, 1012, 272, 892, 275, 2984, 3981, 4412, 1055, 3287, 8, 4571, 9, 2286, 574, 275, 634, 2700, 28982, 8, 2437, 17928, 8, 8568, 29, 1222, 12, 14611, 29, 403, 395, 12643, 17928, 8, 8568, 29, 1121, 12, 14611, 29, 403, 395, 10869, 938, 63, 2634, 16025, 3934, 272, 702, 574, 59, 16, 61, 665, 413, 69, 13, 18, 421, 199, 318, 511, 63, 76, 2700, 28982, 63, 18, 837, 272, 327, 7512, 282, 2196, 13038, 543, 2005, 22966, 272, 2984, 275, 2196, 14, 10843, 8, 17, 12, 5238, 12, 650, 680, 6041, 8, 1590, 14, 1609, 708, 9, 272, 327, 1642, 12995, 402, 314, 14503, 883, 10869, 938, 12, 2061, 1616, 787, 6317, 22966, 272, 4412, 275, 980, 14, 13433, 1332, 2355, 14, 23832, 8, 709, 395, 1616, 435, 980, 14, 5605, 8, 2167, 1724, 272, 7513, 275, 13038, 63, 3642, 63, 504, 63, 392, 28945, 8, 8830, 63, 392, 28945, 1012, 272, 892, 275, 2984, 3981, 4412, 1055, 3287, 8, 4571, 9, 2286, 574, 275, 634, 2700, 28982, 8, 2437, 17928, 8, 8568, 29, 1222, 12, 14611, 29, 403, 395, 12643, 17928, 8, 8568, 29, 1121, 12, 14611, 29, 403, 395, 10869, 938, 63, 2634, 1524, 1590, 14, 5605, 8, 709, 3948, 272, 702, 574, 59, 16, 61, 665, 413, 69, 13, 18, 421, 199, 318, 511, 63, 76, 2700, 28982, 63, 19, 837, 272, 327, 7512, 13038, 436, 22966, 370, 31508, 6271, 272, 307, 17, 275, 6128, 14, 912, 8, 362, 63, 2324, 360, 279, 290, 1132, 13, 328, 12636, 280, 271, 13, 10306, 14, 10511, 1333, 59, 16, 61, 272, 307, 18, 275, 6128, 14, 912, 8, 362, 63, 2324, 360, 279, 290, 1132, 13, 328, 12636, 280, 271, 13, 10306, 14, 10511, 1333, 59, 16, 61, 339, 394, 18, 79, 63, 79, 63, 4108, 275, 359, 65, 14, 1080, 367, 282, 315, 307, 17, 14, 10775, 14, 11521, 340, 282, 14, 19581, 310, 14, 354, 508, 283, 2979, 40, 7, 436, 282, 14, 2108, 14, 5155, 508, 283, 47, 3488, 16, 26, 1165, 61, 272, 394, 18, 79, 63, 72, 63, 4108, 275, 359, 65, 14, 1080, 367, 282, 315, 307, 17, 14, 10775, 14, 11521, 340, 282, 14, 19581, 310, 14, 354, 508, 283, 2979, 40, 7, 436, 282, 14, 2108, 14, 5155, 508, 283, 40, 3488, 16, 26, 1165, 61, 272, 1771, 21134, 63, 4108, 275, 359, 65, 14, 1080, 367, 282, 315, 307, 17, 14, 10775, 14, 11521, 340, 282, 14, 2108, 14, 5155, 315, 788, 35, 297, 283, 46, 6538, 1491, 21, 61, 339, 327, 4061, 5975, 830, 2877, 4652, 402, 4918, 272, 307, 18, 14, 8568, 3981, 2196, 14, 23832, 8, 72, 18, 79, 63, 79, 63, 4108, 1874, 275, 307, 18, 14, 8568, 3981, 394, 18, 79, 63, 79, 63, 4108, 61, 272, 307, 18, 14, 8568, 3981, 2196, 14, 23832, 8, 72, 18, 79, 63, 72, 63, 4108, 1874, 275, 307, 18, 14, 8568, 3981, 394, 18, 79, 63, 72, 63, 4108, 61, 339, 327, 3268, 314, 1771, 21134, 4918, 18023, 272, 307, 18, 14, 8568, 3981, 1771, 21134, 63, 4108, 61, 847, 378, 14, 4587, 627, 2196, 14, 10843, 8, 552, 8, 894, 21134, 63, 4108, 395, 650, 9, 339, 327, 20071, 8137, 272, 7513, 275, 13038, 63, 3642, 63, 504, 63, 392, 28945, 8, 8830, 63, 392, 28945, 1012, 272, 307, 18, 14, 8568, 59, 16, 1055, 3287, 8, 4571, 9, 339, 870, 360, 1773, 22237, 461, 4918, 297, 1771, 21134, 63, 4108, 9, 272, 6222, 63, 4108, 275, 980, 14, 13433, 1332, 72, 18, 79, 63, 79, 63, 4108, 12, 1771, 21134, 63, 4108, 430, 272, 574, 275, 6128, 14, 76, 2700, 28982, 8, 84, 18, 12, 307, 17, 12, 6222, 63, 4108, 29, 4188, 63, 4108, 12, 10869, 938, 63, 2634, 1524, 72, 18, 79, 63, 79, 63, 4108, 566, 272, 307, 17, 14, 8568, 3981, 394, 18, 79, 63, 79, 63, 4108, 61, 847, 2196, 14, 10843, 8, 552, 8, 72, 18, 79, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
MichaelNedzelsky/intellij-community
python/lib/Lib/site-packages/django/contrib/gis/utils/layermapping.py
157
27065
# LayerMapping -- A Django Model/OGR Layer Mapping Utility """ The LayerMapping class provides a way to map the contents of OGR vector files (e.g. SHP files) to Geographic-enabled Django models. For more information, please consult the GeoDjango documentation: http://geodjango.org/docs/layermapping.html """ import sys from datetime import date, datetime from decimal import Decimal from django.core.exceptions import ObjectDoesNotExist from django.db import connections, DEFAULT_DB_ALIAS from django.contrib.gis.db.models import GeometryField from django.contrib.gis.gdal import CoordTransform, DataSource, \ OGRException, OGRGeometry, OGRGeomType, SpatialReference from django.contrib.gis.gdal.field import \ OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime from django.db import models, transaction from django.contrib.localflavor.us.models import USStateField # LayerMapping exceptions. class LayerMapError(Exception): pass class InvalidString(LayerMapError): pass class InvalidDecimal(LayerMapError): pass class InvalidInteger(LayerMapError): pass class MissingForeignKey(LayerMapError): pass class LayerMapping(object): "A class that maps OGR Layers to GeoDjango Models." # Acceptable 'base' types for a multi-geometry type. MULTI_TYPES = {1 : OGRGeomType('MultiPoint'), 2 : OGRGeomType('MultiLineString'), 3 : OGRGeomType('MultiPolygon'), OGRGeomType('Point25D').num : OGRGeomType('MultiPoint25D'), OGRGeomType('LineString25D').num : OGRGeomType('MultiLineString25D'), OGRGeomType('Polygon25D').num : OGRGeomType('MultiPolygon25D'), } # Acceptable Django field types and corresponding acceptable OGR # counterparts. FIELD_TYPES = { models.AutoField : OFTInteger, models.IntegerField : (OFTInteger, OFTReal, OFTString), models.FloatField : (OFTInteger, OFTReal), models.DateField : OFTDate, models.DateTimeField : OFTDateTime, models.EmailField : OFTString, models.TimeField : OFTTime, models.DecimalField : (OFTInteger, OFTReal), models.CharField : OFTString, models.SlugField : OFTString, models.TextField : OFTString, models.URLField : OFTString, USStateField : OFTString, models.XMLField : OFTString, models.SmallIntegerField : (OFTInteger, OFTReal, OFTString), models.PositiveSmallIntegerField : (OFTInteger, OFTReal, OFTString), } # The acceptable transaction modes. TRANSACTION_MODES = {'autocommit' : transaction.autocommit, 'commit_on_success' : transaction.commit_on_success, } def __init__(self, model, data, mapping, layer=0, source_srs=None, encoding=None, transaction_mode='commit_on_success', transform=True, unique=None, using=DEFAULT_DB_ALIAS): """ A LayerMapping object is initialized using the given Model (not an instance), a DataSource (or string path to an OGR-supported data file), and a mapping dictionary. See the module level docstring for more details and keyword argument usage. """ # Getting the DataSource and the associated Layer. if isinstance(data, basestring): self.ds = DataSource(data) else: self.ds = data self.layer = self.ds[layer] self.using = using self.spatial_backend = connections[using].ops # Setting the mapping & model attributes. self.mapping = mapping self.model = model # Checking the layer -- intitialization of the object will fail if # things don't check out before hand. self.check_layer() # Getting the geometry column associated with the model (an # exception will be raised if there is no geometry column). if self.spatial_backend.mysql: transform = False else: self.geo_field = self.geometry_field() # Checking the source spatial reference system, and getting # the coordinate transformation object (unless the `transform` # keyword is set to False) if transform: self.source_srs = self.check_srs(source_srs) self.transform = self.coord_transform() else: self.transform = transform # Setting the encoding for OFTString fields, if specified. if encoding: # Making sure the encoding exists, if not a LookupError # exception will be thrown. from codecs import lookup lookup(encoding) self.encoding = encoding else: self.encoding = None if unique: self.check_unique(unique) transaction_mode = 'autocommit' # Has to be set to autocommit. self.unique = unique else: self.unique = None # Setting the transaction decorator with the function in the # transaction modes dictionary. if transaction_mode in self.TRANSACTION_MODES: self.transaction_decorator = self.TRANSACTION_MODES[transaction_mode] self.transaction_mode = transaction_mode else: raise LayerMapError('Unrecognized transaction mode: %s' % transaction_mode) if using is None: pass #### Checking routines used during initialization #### def check_fid_range(self, fid_range): "This checks the `fid_range` keyword." if fid_range: if isinstance(fid_range, (tuple, list)): return slice(*fid_range) elif isinstance(fid_range, slice): return fid_range else: raise TypeError else: return None def check_layer(self): """ This checks the Layer metadata, and ensures that it is compatible with the mapping information and model. Unlike previous revisions, there is no need to increment through each feature in the Layer. """ # The geometry field of the model is set here. # TODO: Support more than one geometry field / model. However, this # depends on the GDAL Driver in use. self.geom_field = False self.fields = {} # Getting lists of the field names and the field types available in # the OGR Layer. ogr_fields = self.layer.fields ogr_field_types = self.layer.field_types # Function for determining if the OGR mapping field is in the Layer. def check_ogr_fld(ogr_map_fld): try: idx = ogr_fields.index(ogr_map_fld) except ValueError: raise LayerMapError('Given mapping OGR field "%s" not found in OGR Layer.' % ogr_map_fld) return idx # No need to increment through each feature in the model, simply check # the Layer metadata against what was given in the mapping dictionary. for field_name, ogr_name in self.mapping.items(): # Ensuring that a corresponding field exists in the model # for the given field name in the mapping. try: model_field = self.model._meta.get_field(field_name) except models.fields.FieldDoesNotExist: raise LayerMapError('Given mapping field "%s" not in given Model fields.' % field_name) # Getting the string name for the Django field class (e.g., 'PointField'). fld_name = model_field.__class__.__name__ if isinstance(model_field, GeometryField): if self.geom_field: raise LayerMapError('LayerMapping does not support more than one GeometryField per model.') # Getting the coordinate dimension of the geometry field. coord_dim = model_field.dim try: if coord_dim == 3: gtype = OGRGeomType(ogr_name + '25D') else: gtype = OGRGeomType(ogr_name) except OGRException: raise LayerMapError('Invalid mapping for GeometryField "%s".' % field_name) # Making sure that the OGR Layer's Geometry is compatible. ltype = self.layer.geom_type if not (ltype.name.startswith(gtype.name) or self.make_multi(ltype, model_field)): raise LayerMapError('Invalid mapping geometry; model has %s%s, ' 'layer geometry type is %s.' % (fld_name, (coord_dim == 3 and '(dim=3)') or '', ltype)) # Setting the `geom_field` attribute w/the name of the model field # that is a Geometry. Also setting the coordinate dimension # attribute. self.geom_field = field_name self.coord_dim = coord_dim fields_val = model_field elif isinstance(model_field, models.ForeignKey): if isinstance(ogr_name, dict): # Is every given related model mapping field in the Layer? rel_model = model_field.rel.to for rel_name, ogr_field in ogr_name.items(): idx = check_ogr_fld(ogr_field) try: rel_field = rel_model._meta.get_field(rel_name) except models.fields.FieldDoesNotExist: raise LayerMapError('ForeignKey mapping field "%s" not in %s fields.' % (rel_name, rel_model.__class__.__name__)) fields_val = rel_model else: raise TypeError('ForeignKey mapping must be of dictionary type.') else: # Is the model field type supported by LayerMapping? if not model_field.__class__ in self.FIELD_TYPES: raise LayerMapError('Django field type "%s" has no OGR mapping (yet).' % fld_name) # Is the OGR field in the Layer? idx = check_ogr_fld(ogr_name) ogr_field = ogr_field_types[idx] # Can the OGR field type be mapped to the Django field type? if not issubclass(ogr_field, self.FIELD_TYPES[model_field.__class__]): raise LayerMapError('OGR field "%s" (of type %s) cannot be mapped to Django %s.' % (ogr_field, ogr_field.__name__, fld_name)) fields_val = model_field self.fields[field_name] = fields_val def check_srs(self, source_srs): "Checks the compatibility of the given spatial reference object." if isinstance(source_srs, SpatialReference): sr = source_srs elif isinstance(source_srs, self.spatial_backend.spatial_ref_sys()): sr = source_srs.srs elif isinstance(source_srs, (int, basestring)): sr = SpatialReference(source_srs) else: # Otherwise just pulling the SpatialReference from the layer sr = self.layer.srs if not sr: raise LayerMapError('No source reference system defined.') else: return sr def check_unique(self, unique): "Checks the `unique` keyword parameter -- may be a sequence or string." if isinstance(unique, (list, tuple)): # List of fields to determine uniqueness with for attr in unique: if not attr in self.mapping: raise ValueError elif isinstance(unique, basestring): # Only a single field passed in. if unique not in self.mapping: raise ValueError else: raise TypeError('Unique keyword argument must be set with a tuple, list, or string.') #### Keyword argument retrieval routines #### def feature_kwargs(self, feat): """ Given an OGR Feature, this will return a dictionary of keyword arguments for constructing the mapped model. """ # The keyword arguments for model construction. kwargs = {} # Incrementing through each model field and OGR field in the # dictionary mapping. for field_name, ogr_name in self.mapping.items(): model_field = self.fields[field_name] if isinstance(model_field, GeometryField): # Verify OGR geometry. val = self.verify_geom(feat.geom, model_field) elif isinstance(model_field, models.base.ModelBase): # The related _model_, not a field was passed in -- indicating # another mapping for the related Model. val = self.verify_fk(feat, model_field, ogr_name) else: # Otherwise, verify OGR Field type. val = self.verify_ogr_field(feat[ogr_name], model_field) # Setting the keyword arguments for the field name with the # value obtained above. kwargs[field_name] = val return kwargs def unique_kwargs(self, kwargs): """ Given the feature keyword arguments (from `feature_kwargs`) this routine will construct and return the uniqueness keyword arguments -- a subset of the feature kwargs. """ if isinstance(self.unique, basestring): return {self.unique : kwargs[self.unique]} else: return dict((fld, kwargs[fld]) for fld in self.unique) #### Verification routines used in constructing model keyword arguments. #### def verify_ogr_field(self, ogr_field, model_field): """ Verifies if the OGR Field contents are acceptable to the Django model field. If they are, the verified value is returned, otherwise the proper exception is raised. """ if (isinstance(ogr_field, OFTString) and isinstance(model_field, (models.CharField, models.TextField))): if self.encoding: # The encoding for OGR data sources may be specified here # (e.g., 'cp437' for Census Bureau boundary files). val = unicode(ogr_field.value, self.encoding) else: val = ogr_field.value if len(val) > model_field.max_length: raise InvalidString('%s model field maximum string length is %s, given %s characters.' % (model_field.name, model_field.max_length, len(val))) elif isinstance(ogr_field, OFTReal) and isinstance(model_field, models.DecimalField): try: # Creating an instance of the Decimal value to use. d = Decimal(str(ogr_field.value)) except: raise InvalidDecimal('Could not construct decimal from: %s' % ogr_field.value) # Getting the decimal value as a tuple. dtup = d.as_tuple() digits = dtup[1] d_idx = dtup[2] # index where the decimal is # Maximum amount of precision, or digits to the left of the decimal. max_prec = model_field.max_digits - model_field.decimal_places # Getting the digits to the left of the decimal place for the # given decimal. if d_idx < 0: n_prec = len(digits[:d_idx]) else: n_prec = len(digits) + d_idx # If we have more than the maximum digits allowed, then throw an # InvalidDecimal exception. if n_prec > max_prec: raise InvalidDecimal('A DecimalField with max_digits %d, decimal_places %d must round to an absolute value less than 10^%d.' % (model_field.max_digits, model_field.decimal_places, max_prec)) val = d elif isinstance(ogr_field, (OFTReal, OFTString)) and isinstance(model_field, models.IntegerField): # Attempt to convert any OFTReal and OFTString value to an OFTInteger. try: val = int(ogr_field.value) except: raise InvalidInteger('Could not construct integer from: %s' % ogr_field.value) else: val = ogr_field.value return val def verify_fk(self, feat, rel_model, rel_mapping): """ Given an OGR Feature, the related model and its dictionary mapping, this routine will retrieve the related model for the ForeignKey mapping. """ # TODO: It is expensive to retrieve a model for every record -- # explore if an efficient mechanism exists for caching related # ForeignKey models. # Constructing and verifying the related model keyword arguments. fk_kwargs = {} for field_name, ogr_name in rel_mapping.items(): fk_kwargs[field_name] = self.verify_ogr_field(feat[ogr_name], rel_model._meta.get_field(field_name)) # Attempting to retrieve and return the related model. try: return rel_model.objects.get(**fk_kwargs) except ObjectDoesNotExist: raise MissingForeignKey('No ForeignKey %s model found with keyword arguments: %s' % (rel_model.__name__, fk_kwargs)) def verify_geom(self, geom, model_field): """ Verifies the geometry -- will construct and return a GeometryCollection if necessary (for example if the model field is MultiPolygonField while the mapped shapefile only contains Polygons). """ # Downgrade a 3D geom to a 2D one, if necessary. if self.coord_dim != geom.coord_dim: geom.coord_dim = self.coord_dim if self.make_multi(geom.geom_type, model_field): # Constructing a multi-geometry type to contain the single geometry multi_type = self.MULTI_TYPES[geom.geom_type.num] g = OGRGeometry(multi_type) g.add(geom) else: g = geom # Transforming the geometry with our Coordinate Transformation object, # but only if the class variable `transform` is set w/a CoordTransform # object. if self.transform: g.transform(self.transform) # Returning the WKT of the geometry. return g.wkt #### Other model methods #### def coord_transform(self): "Returns the coordinate transformation object." SpatialRefSys = self.spatial_backend.spatial_ref_sys() try: # Getting the target spatial reference system target_srs = SpatialRefSys.objects.get(srid=self.geo_field.srid).srs # Creating the CoordTransform object return CoordTransform(self.source_srs, target_srs) except Exception, msg: raise LayerMapError('Could not translate between the data source and model geometry: %s' % msg) def geometry_field(self): "Returns the GeometryField instance associated with the geographic column." # Use the `get_field_by_name` on the model's options so that we # get the correct field instance if there's model inheritance. opts = self.model._meta fld, model, direct, m2m = opts.get_field_by_name(self.geom_field) return fld def make_multi(self, geom_type, model_field): """ Given the OGRGeomType for a geometry and its associated GeometryField, determine whether the geometry should be turned into a GeometryCollection. """ return (geom_type.num in self.MULTI_TYPES and model_field.__class__.__name__ == 'Multi%s' % geom_type.django) def save(self, verbose=False, fid_range=False, step=False, progress=False, silent=False, stream=sys.stdout, strict=False): """ Saves the contents from the OGR DataSource Layer into the database according to the mapping dictionary given at initialization. Keyword Parameters: verbose: If set, information will be printed subsequent to each model save executed on the database. fid_range: May be set with a slice or tuple of (begin, end) feature ID's to map from the data source. In other words, this keyword enables the user to selectively import a subset range of features in the geographic data source. step: If set with an integer, transactions will occur at every step interval. For example, if step=1000, a commit would occur after the 1,000th feature, the 2,000th feature etc. progress: When this keyword is set, status information will be printed giving the number of features processed and sucessfully saved. By default, progress information will pe printed every 1000 features processed, however, this default may be overridden by setting this keyword with an integer for the desired interval. stream: Status information will be written to this file handle. Defaults to using `sys.stdout`, but any object with a `write` method is supported. silent: By default, non-fatal error notifications are printed to stdout, but this keyword may be set to disable these notifications. strict: Execution of the model mapping will cease upon the first error encountered. The default behavior is to attempt to continue. """ # Getting the default Feature ID range. default_range = self.check_fid_range(fid_range) # Setting the progress interval, if requested. if progress: if progress is True or not isinstance(progress, int): progress_interval = 1000 else: progress_interval = progress # Defining the 'real' save method, utilizing the transaction # decorator created during initialization. @self.transaction_decorator def _save(feat_range=default_range, num_feat=0, num_saved=0): if feat_range: layer_iter = self.layer[feat_range] else: layer_iter = self.layer for feat in layer_iter: num_feat += 1 # Getting the keyword arguments try: kwargs = self.feature_kwargs(feat) except LayerMapError, msg: # Something borked the validation if strict: raise elif not silent: stream.write('Ignoring Feature ID %s because: %s\n' % (feat.fid, msg)) else: # Constructing the model using the keyword args is_update = False if self.unique: # If we want unique models on a particular field, handle the # geometry appropriately. try: # Getting the keyword arguments and retrieving # the unique model. u_kwargs = self.unique_kwargs(kwargs) m = self.model.objects.using(self.using).get(**u_kwargs) is_update = True # Getting the geometry (in OGR form), creating # one from the kwargs WKT, adding in additional # geometries, and update the attribute with the # just-updated geometry WKT. geom = getattr(m, self.geom_field).ogr new = OGRGeometry(kwargs[self.geom_field]) for g in new: geom.add(g) setattr(m, self.geom_field, geom.wkt) except ObjectDoesNotExist: # No unique model exists yet, create. m = self.model(**kwargs) else: m = self.model(**kwargs) try: # Attempting to save. m.save(using=self.using) num_saved += 1 if verbose: stream.write('%s: %s\n' % (is_update and 'Updated' or 'Saved', m)) except SystemExit: raise except Exception, msg: if self.transaction_mode == 'autocommit': # Rolling back the transaction so that other model saves # will work. transaction.rollback_unless_managed() if strict: # Bailing out if the `strict` keyword is set. if not silent: stream.write('Failed to save the feature (id: %s) into the model with the keyword arguments:\n' % feat.fid) stream.write('%s\n' % kwargs) raise elif not silent: stream.write('Failed to save %s:\n %s\nContinuing\n' % (kwargs, msg)) # Printing progress information, if requested. if progress and num_feat % progress_interval == 0: stream.write('Processed %d features, saved %d ...\n' % (num_feat, num_saved)) # Only used for status output purposes -- incremental saving uses the # values returned here. return num_saved, num_feat nfeat = self.layer.num_feat if step and isinstance(step, int) and step < nfeat: # Incremental saving is requested at the given interval (step) if default_range: raise LayerMapError('The `step` keyword may not be used in conjunction with the `fid_range` keyword.') beg, num_feat, num_saved = (0, 0, 0) indices = range(step, nfeat, step) n_i = len(indices) for i, end in enumerate(indices): # Constructing the slice to use for this step; the last slice is # special (e.g, [100:] instead of [90:100]). if i+1 == n_i: step_slice = slice(beg, None) else: step_slice = slice(beg, end) try: num_feat, num_saved = _save(step_slice, num_feat, num_saved) beg = end except: stream.write('%s\nFailed to save slice: %s\n' % ('=-' * 20, step_slice)) raise else: # Otherwise, just calling the previously defined _save() function. _save()
apache-2.0
[ 3, 11915, 7674, 1553, 437, 5634, 5822, 15, 17275, 11915, 12340, 20511, 199, 624, 199, 710, 11915, 7674, 1021, 6571, 282, 4340, 370, 2341, 314, 4072, 402, 10904, 199, 5477, 1584, 334, 69, 14, 71, 14, 4410, 48, 1584, 9, 370, 8875, 9770, 13, 3827, 5634, 1709, 14, 421, 2104, 1655, 2556, 12, 8749, 13447, 427, 314, 8875, 9323, 3794, 26, 2043, 1455, 921, 303, 364, 858, 14, 1308, 15, 4757, 15, 1897, 4745, 14, 1360, 199, 624, 199, 646, 984, 199, 504, 2197, 492, 1434, 12, 2197, 199, 504, 6107, 492, 6345, 199, 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 504, 1639, 14, 697, 492, 6947, 12, 6186, 63, 2846, 63, 12644, 199, 504, 1639, 14, 2828, 14, 5668, 14, 697, 14, 992, 492, 30490, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 492, 1849, 2181, 6939, 12, 24300, 12, 971, 272, 19746, 907, 16010, 12, 24220, 12, 25756, 12, 24324, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 698, 492, 971, 272, 20025, 2506, 12, 20025, 3926, 12, 20025, 2674, 12, 20025, 10099, 12, 20025, 1558, 12, 20025, 1366, 199, 504, 1639, 14, 697, 492, 1709, 12, 6008, 199, 504, 1639, 14, 2828, 14, 320, 696, 276, 4271, 14, 527, 14, 992, 492, 19635, 2223, 792, 199, 199, 3, 11915, 7674, 4967, 14, 199, 533, 11915, 2956, 547, 8, 1726, 304, 986, 199, 533, 6378, 1558, 8, 5003, 2956, 547, 304, 986, 199, 533, 6378, 6745, 8, 5003, 2956, 547, 304, 986, 199, 533, 6378, 2674, 8, 5003, 2956, 547, 304, 986, 199, 533, 15626, 3190, 8, 5003, 2956, 547, 304, 986, 199, 199, 533, 11915, 7674, 8, 785, 304, 272, 298, 33, 1021, 626, 9033, 10904, 9366, 1192, 370, 8875, 9323, 29941, 2122, 339, 327, 15506, 461, 283, 1095, 7, 2943, 367, 282, 3510, 13, 7660, 730, 14, 272, 24895, 41, 63, 7893, 275, 469, 17, 520, 25756, 360, 3947, 3428, 659, 673, 499, 520, 25756, 360, 3947, 22134, 659, 673, 650, 520, 25756, 360, 3947, 12367, 659, 673, 25756, 360, 3428, 821, 36, 1959, 1507, 520, 25756, 360, 3947, 3428, 821, 36, 659, 673, 25756, 360, 22134, 821, 36, 1959, 1507, 520, 25756, 360, 3947, 22134, 821, 36, 659, 673, 25756, 360, 12367, 821, 36, 1959, 1507, 520, 25756, 360, 3947, 12367, 821, 36, 659, 673, 789, 339, 327, 15506, 461, 5634, 901, 2943, 436, 5226, 14712, 10904, 272, 327, 7055, 4181, 14, 272, 26130, 63, 7893, 275, 469, 267, 1709, 14, 4378, 520, 20025, 2674, 12, 267, 1709, 14, 3901, 520, 334, 47, 2161, 2674, 12, 20025, 10099, 12, 20025, 1558, 395, 267, 1709, 14, 13019, 520, 334, 47, 2161, 2674, 12, 20025, 10099, 395, 267, 1709, 14, 14071, 520, 20025, 2506, 12, 267, 1709, 14, 4626, 520, 20025, 3926, 12, 267, 1709, 14, 16577, 520, 20025, 1558, 12, 267, 1709, 14, 27115, 520, 20025, 1366, 12, 267, 1709, 14, 15975, 520, 334, 47, 2161, 2674, 12, 20025, 10099, 395, 267, 1709, 14, 2183, 520, 20025, 1558, 12, 267, 1709, 14, 17315, 520, 20025, 1558, 12, 267, 1709, 14, 6254, 520, 20025, 1558, 12, 267, 1709, 14, 17363, 520, 20025, 1558, 12, 267, 19635, 2223, 792, 520, 20025, 1558, 12, 267, 1709, 14, 4317, 792, 520, 20025, 1558, 12, 267, 1709, 14, 14640, 520, 334, 47, 2161, 2674, 12, 20025, 10099, 12, 20025, 1558, 395, 267, 1709, 14, 25197, 520, 334, 47, 2161, 2674, 12, 20025, 10099, 12, 20025, 1558, 395, 267, 789, 339, 327, 710, 14712, 6008, 12404, 14, 272, 9074, 5622, 10052, 63, 31095, 275, 791, 17881, 7, 520, 6008, 14, 17881, 12, 586, 283, 3543, 63, 265, 63, 3742, 7, 520, 6008, 14, 3543, 63, 265, 63, 3742, 12, 586, 789, 339, 347, 636, 826, 721, 277, 12, 1402, 12, 666, 12, 4412, 12, 4045, 29, 16, 12, 326, 1350, 63, 12722, 29, 403, 12, 2644, 29, 403, 12, 326, 6008, 63, 632, 534, 3543, 63, 265, 63, 3742, 297, 326, 5793, 29, 549, 12, 3747, 29, 403, 12, 1808, 29, 3472, 63, 2846, 63, 12644, 304, 267, 408, 267, 437, 11915, 7674, 909, 365, 10038, 1808, 314, 1627, 5822, 334, 1397, 376, 1256, 395, 267, 282, 24300, 334, 269, 1059, 931, 370, 376, 10904, 13, 4946, 666, 570, 395, 436, 282, 4412, 267, 2600, 14, 221, 1666, 314, 859, 2166, 9214, 367, 1655, 2436, 436, 4252, 267, 1423, 4503, 14, 267, 408, 267, 327, 20703, 314, 24300, 436, 314, 4568, 11915, 14, 267, 340, 1228, 8, 576, 12, 7116, 304, 288, 291, 14, 795, 275, 24300, 8, 576, 9, 267, 587, 26, 288, 291, 14, 795, 275, 666, 267, 291, 14, 1897, 275, 291, 14, 795, 59, 1897, 61, 398, 291, 14, 4941, 275, 1808, 267, 291, 14, 11679, 63, 4620, 275, 6947, 59, 4941, 1055, 1483, 398, 327, 13510, 314, 4412, 1253, 1402, 3004, 14, 267, 291, 14, 4745, 275, 4412, 267, 291, 14, 1238, 275, 1402, 398, 327, 25109, 314, 4045, 1553, 315, 280, 1009, 2072, 402, 314, 909, 911, 2449, 340, 267, 327, 7645, 2793, 1133, 1104, 734, 2544, 4926, 14, 267, 291, 14, 1074, 63, 1897, 342, 398, 327, 20703, 314, 3400, 2763, 4568, 543, 314, 1402, 334, 290, 267, 327, 1919, 911, 506, 4915, 340, 2337, 365, 949, 3400, 2763, 680, 267, 340, 291, 14, 11679, 63, 4620, 14, 8644, 26, 288, 5793, 275, 756, 267, 587, 26, 288, 291, 14, 6721, 63, 698, 275, 291, 14, 7660, 63, 698, 342, 398, 327, 25109, 314, 1350, 11469, 3659, 2656, 12, 436, 10232, 267, 327, 314, 10021, 13315, 909, 334, 18447, 314, 658, 4711, 64, 267, 327, 4252, 365, 663, 370, 756, 9, 267, 340, 5793, 26, 288, 291, 14, 1365, 63, 12722, 275, 291, 14, 1074, 63, 12722, 8, 1365, 63, 12722, 9, 288, 291, 14, 4711, 275, 291, 14, 7988, 63, 4711, 342, 267, 587, 26, 288, 291, 14, 4711, 275, 5793, 398, 327, 13510, 314, 2644, 367, 20025, 1558, 1504, 12, 340, 2013, 14, 267, 340, 2644, 26, 288, 327, 32269, 3238, 314, 2644, 3495, 12, 340, 440, 282, 19021, 288, 327, 1919, 911, 506, 14031, 14, 288, 687, 6010, 492, 4237, 288, 4237, 8, 2991, 9, 288, 291, 14, 2991, 275, 2644 ]
[ 11915, 7674, 1553, 437, 5634, 5822, 15, 17275, 11915, 12340, 20511, 199, 624, 199, 710, 11915, 7674, 1021, 6571, 282, 4340, 370, 2341, 314, 4072, 402, 10904, 199, 5477, 1584, 334, 69, 14, 71, 14, 4410, 48, 1584, 9, 370, 8875, 9770, 13, 3827, 5634, 1709, 14, 421, 2104, 1655, 2556, 12, 8749, 13447, 427, 314, 8875, 9323, 3794, 26, 2043, 1455, 921, 303, 364, 858, 14, 1308, 15, 4757, 15, 1897, 4745, 14, 1360, 199, 624, 199, 646, 984, 199, 504, 2197, 492, 1434, 12, 2197, 199, 504, 6107, 492, 6345, 199, 504, 1639, 14, 1018, 14, 3924, 492, 24803, 199, 504, 1639, 14, 697, 492, 6947, 12, 6186, 63, 2846, 63, 12644, 199, 504, 1639, 14, 2828, 14, 5668, 14, 697, 14, 992, 492, 30490, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 492, 1849, 2181, 6939, 12, 24300, 12, 971, 272, 19746, 907, 16010, 12, 24220, 12, 25756, 12, 24324, 199, 504, 1639, 14, 2828, 14, 5668, 14, 11600, 14, 698, 492, 971, 272, 20025, 2506, 12, 20025, 3926, 12, 20025, 2674, 12, 20025, 10099, 12, 20025, 1558, 12, 20025, 1366, 199, 504, 1639, 14, 697, 492, 1709, 12, 6008, 199, 504, 1639, 14, 2828, 14, 320, 696, 276, 4271, 14, 527, 14, 992, 492, 19635, 2223, 792, 199, 199, 3, 11915, 7674, 4967, 14, 199, 533, 11915, 2956, 547, 8, 1726, 304, 986, 199, 533, 6378, 1558, 8, 5003, 2956, 547, 304, 986, 199, 533, 6378, 6745, 8, 5003, 2956, 547, 304, 986, 199, 533, 6378, 2674, 8, 5003, 2956, 547, 304, 986, 199, 533, 15626, 3190, 8, 5003, 2956, 547, 304, 986, 199, 199, 533, 11915, 7674, 8, 785, 304, 272, 298, 33, 1021, 626, 9033, 10904, 9366, 1192, 370, 8875, 9323, 29941, 2122, 339, 327, 15506, 461, 283, 1095, 7, 2943, 367, 282, 3510, 13, 7660, 730, 14, 272, 24895, 41, 63, 7893, 275, 469, 17, 520, 25756, 360, 3947, 3428, 659, 673, 499, 520, 25756, 360, 3947, 22134, 659, 673, 650, 520, 25756, 360, 3947, 12367, 659, 673, 25756, 360, 3428, 821, 36, 1959, 1507, 520, 25756, 360, 3947, 3428, 821, 36, 659, 673, 25756, 360, 22134, 821, 36, 1959, 1507, 520, 25756, 360, 3947, 22134, 821, 36, 659, 673, 25756, 360, 12367, 821, 36, 1959, 1507, 520, 25756, 360, 3947, 12367, 821, 36, 659, 673, 789, 339, 327, 15506, 461, 5634, 901, 2943, 436, 5226, 14712, 10904, 272, 327, 7055, 4181, 14, 272, 26130, 63, 7893, 275, 469, 267, 1709, 14, 4378, 520, 20025, 2674, 12, 267, 1709, 14, 3901, 520, 334, 47, 2161, 2674, 12, 20025, 10099, 12, 20025, 1558, 395, 267, 1709, 14, 13019, 520, 334, 47, 2161, 2674, 12, 20025, 10099, 395, 267, 1709, 14, 14071, 520, 20025, 2506, 12, 267, 1709, 14, 4626, 520, 20025, 3926, 12, 267, 1709, 14, 16577, 520, 20025, 1558, 12, 267, 1709, 14, 27115, 520, 20025, 1366, 12, 267, 1709, 14, 15975, 520, 334, 47, 2161, 2674, 12, 20025, 10099, 395, 267, 1709, 14, 2183, 520, 20025, 1558, 12, 267, 1709, 14, 17315, 520, 20025, 1558, 12, 267, 1709, 14, 6254, 520, 20025, 1558, 12, 267, 1709, 14, 17363, 520, 20025, 1558, 12, 267, 19635, 2223, 792, 520, 20025, 1558, 12, 267, 1709, 14, 4317, 792, 520, 20025, 1558, 12, 267, 1709, 14, 14640, 520, 334, 47, 2161, 2674, 12, 20025, 10099, 12, 20025, 1558, 395, 267, 1709, 14, 25197, 520, 334, 47, 2161, 2674, 12, 20025, 10099, 12, 20025, 1558, 395, 267, 789, 339, 327, 710, 14712, 6008, 12404, 14, 272, 9074, 5622, 10052, 63, 31095, 275, 791, 17881, 7, 520, 6008, 14, 17881, 12, 586, 283, 3543, 63, 265, 63, 3742, 7, 520, 6008, 14, 3543, 63, 265, 63, 3742, 12, 586, 789, 339, 347, 636, 826, 721, 277, 12, 1402, 12, 666, 12, 4412, 12, 4045, 29, 16, 12, 326, 1350, 63, 12722, 29, 403, 12, 2644, 29, 403, 12, 326, 6008, 63, 632, 534, 3543, 63, 265, 63, 3742, 297, 326, 5793, 29, 549, 12, 3747, 29, 403, 12, 1808, 29, 3472, 63, 2846, 63, 12644, 304, 267, 408, 267, 437, 11915, 7674, 909, 365, 10038, 1808, 314, 1627, 5822, 334, 1397, 376, 1256, 395, 267, 282, 24300, 334, 269, 1059, 931, 370, 376, 10904, 13, 4946, 666, 570, 395, 436, 282, 4412, 267, 2600, 14, 221, 1666, 314, 859, 2166, 9214, 367, 1655, 2436, 436, 4252, 267, 1423, 4503, 14, 267, 408, 267, 327, 20703, 314, 24300, 436, 314, 4568, 11915, 14, 267, 340, 1228, 8, 576, 12, 7116, 304, 288, 291, 14, 795, 275, 24300, 8, 576, 9, 267, 587, 26, 288, 291, 14, 795, 275, 666, 267, 291, 14, 1897, 275, 291, 14, 795, 59, 1897, 61, 398, 291, 14, 4941, 275, 1808, 267, 291, 14, 11679, 63, 4620, 275, 6947, 59, 4941, 1055, 1483, 398, 327, 13510, 314, 4412, 1253, 1402, 3004, 14, 267, 291, 14, 4745, 275, 4412, 267, 291, 14, 1238, 275, 1402, 398, 327, 25109, 314, 4045, 1553, 315, 280, 1009, 2072, 402, 314, 909, 911, 2449, 340, 267, 327, 7645, 2793, 1133, 1104, 734, 2544, 4926, 14, 267, 291, 14, 1074, 63, 1897, 342, 398, 327, 20703, 314, 3400, 2763, 4568, 543, 314, 1402, 334, 290, 267, 327, 1919, 911, 506, 4915, 340, 2337, 365, 949, 3400, 2763, 680, 267, 340, 291, 14, 11679, 63, 4620, 14, 8644, 26, 288, 5793, 275, 756, 267, 587, 26, 288, 291, 14, 6721, 63, 698, 275, 291, 14, 7660, 63, 698, 342, 398, 327, 25109, 314, 1350, 11469, 3659, 2656, 12, 436, 10232, 267, 327, 314, 10021, 13315, 909, 334, 18447, 314, 658, 4711, 64, 267, 327, 4252, 365, 663, 370, 756, 9, 267, 340, 5793, 26, 288, 291, 14, 1365, 63, 12722, 275, 291, 14, 1074, 63, 12722, 8, 1365, 63, 12722, 9, 288, 291, 14, 4711, 275, 291, 14, 7988, 63, 4711, 342, 267, 587, 26, 288, 291, 14, 4711, 275, 5793, 398, 327, 13510, 314, 2644, 367, 20025, 1558, 1504, 12, 340, 2013, 14, 267, 340, 2644, 26, 288, 327, 32269, 3238, 314, 2644, 3495, 12, 340, 440, 282, 19021, 288, 327, 1919, 911, 506, 14031, 14, 288, 687, 6010, 492, 4237, 288, 4237, 8, 2991, 9, 288, 291, 14, 2991, 275, 2644, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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3/__init__.py
7
1041
# pysqlite2/__init__.py: the pysqlite2 package. # # Copyright (C) 2005 Gerhard Häring <gh@ghaering.de> # # This file is part of pysqlite. # # This software is provided 'as-is', without any express or implied # warranty. In no event will the authors be held liable for any damages # arising from the use of this software. # # Permission is granted to anyone to use this software for any purpose, # including commercial applications, and to alter it and redistribute it # freely, subject to the following restrictions: # # 1. The origin of this software must not be misrepresented; you must not # claim that you wrote the original software. If you use this software # in a product, an acknowledgment in the product documentation would be # appreciated but is not required. # 2. Altered source versions must be plainly marked as such, and must not be # misrepresented as being the original software. # 3. This notice may not be removed or altered from any source distribution. from sqlite3.dbapi2 import *
lgpl-3.0
[ 3, 10382, 29498, 18, 22128, 826, 4343, 647, 26, 314, 10382, 29498, 18, 2559, 14, 202, 199, 3, 202, 199, 3, 1898, 334, 35, 9, 11811, 22261, 8726, 869, 13733, 5985, 665, 3561, 32, 71, 2411, 15663, 14, 271, 30, 202, 199, 3, 202, 199, 3, 961, 570, 365, 1777, 402, 10382, 29498, 14, 202, 199, 3, 202, 199, 3, 961, 2032, 365, 2741, 283, 305, 13, 374, 297, 1928, 1263, 4056, 503, 2478, 202, 199, 3, 3750, 14, 221, 1010, 949, 1566, 911, 314, 11462, 506, 23608, 1212, 461, 367, 1263, 12927, 960, 83, 202, 199, 3, 14554, 1044, 687, 314, 675, 402, 642, 2032, 14, 202, 199, 3, 202, 199, 3, 8779, 365, 10009, 370, 29165, 370, 675, 642, 2032, 367, 1263, 12016, 12, 202, 199, 3, 5893, 2414, 23012, 13103, 12, 436, 370, 17355, 652, 436, 3604, 652, 202, 199, 3, 20673, 7742, 12, 5420, 370, 314, 2569, 24488, 26, 202, 199, 3, 202, 199, 3, 413, 14, 710, 6330, 402, 642, 2032, 1471, 440, 506, 3201, 264, 10317, 27, 1265, 1471, 440, 202, 199, 3, 259, 22498, 626, 1265, 336, 22665, 314, 3379, 2032, 14, 982, 1265, 675, 642, 2032, 202, 199, 3, 259, 315, 282, 3336, 12, 376, 19807, 28609, 4740, 315, 314, 3336, 3794, 3955, 506, 202, 199, 3, 259, 2771, 20940, 972, 1325, 365, 440, 1415, 14, 202, 199, 3, 499, 14, 4580, 3014, 1350, 5459, 1471, 506, 8971, 590, 11584, 465, 4066, 12, 436, 1471, 440, 506, 202, 199, 3, 259, 3201, 264, 10317, 465, 3769, 314, 3379, 2032, 14, 202, 199, 3, 650, 14, 961, 4245, 1443, 440, 506, 4829, 503, 29815, 687, 1263, 1350, 4084, 14, 2999, 199, 504, 11723, 19, 14, 22103, 18, 492, 627, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 10382, 29498, 18, 22128, 826, 4343, 647, 26, 314, 10382, 29498, 18, 2559, 14, 202, 199, 3, 202, 199, 3, 1898, 334, 35, 9, 11811, 22261, 8726, 869, 13733, 5985, 665, 3561, 32, 71, 2411, 15663, 14, 271, 30, 202, 199, 3, 202, 199, 3, 961, 570, 365, 1777, 402, 10382, 29498, 14, 202, 199, 3, 202, 199, 3, 961, 2032, 365, 2741, 283, 305, 13, 374, 297, 1928, 1263, 4056, 503, 2478, 202, 199, 3, 3750, 14, 221, 1010, 949, 1566, 911, 314, 11462, 506, 23608, 1212, 461, 367, 1263, 12927, 960, 83, 202, 199, 3, 14554, 1044, 687, 314, 675, 402, 642, 2032, 14, 202, 199, 3, 202, 199, 3, 8779, 365, 10009, 370, 29165, 370, 675, 642, 2032, 367, 1263, 12016, 12, 202, 199, 3, 5893, 2414, 23012, 13103, 12, 436, 370, 17355, 652, 436, 3604, 652, 202, 199, 3, 20673, 7742, 12, 5420, 370, 314, 2569, 24488, 26, 202, 199, 3, 202, 199, 3, 413, 14, 710, 6330, 402, 642, 2032, 1471, 440, 506, 3201, 264, 10317, 27, 1265, 1471, 440, 202, 199, 3, 259, 22498, 626, 1265, 336, 22665, 314, 3379, 2032, 14, 982, 1265, 675, 642, 2032, 202, 199, 3, 259, 315, 282, 3336, 12, 376, 19807, 28609, 4740, 315, 314, 3336, 3794, 3955, 506, 202, 199, 3, 259, 2771, 20940, 972, 1325, 365, 440, 1415, 14, 202, 199, 3, 499, 14, 4580, 3014, 1350, 5459, 1471, 506, 8971, 590, 11584, 465, 4066, 12, 436, 1471, 440, 506, 202, 199, 3, 259, 3201, 264, 10317, 465, 3769, 314, 3379, 2032, 14, 202, 199, 3, 650, 14, 961, 4245, 1443, 440, 506, 4829, 503, 29815, 687, 1263, 1350, 4084, 14, 2999, 199, 504, 11723, 19, 14, 22103, 18, 492, 627, 1223, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1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unit/scheduler/filters/test_core_filters.py
17
4514
# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import mock from nova.scheduler.filters import core_filter from nova import test from nova.tests.unit.scheduler import fakes class TestCoreFilter(test.NoDBTestCase): def test_core_filter_passes(self): self.filt_cls = core_filter.CoreFilter() filter_properties = {'instance_type': {'vcpus': 1}} host = fakes.FakeHostState('host1', 'node1', {'vcpus_total': 4, 'vcpus_used': 7, 'cpu_allocation_ratio': 2}) self.assertTrue(self.filt_cls.host_passes(host, filter_properties)) def test_core_filter_fails_safe(self): self.filt_cls = core_filter.CoreFilter() filter_properties = {'instance_type': {'vcpus': 1}} host = fakes.FakeHostState('host1', 'node1', {}) self.assertTrue(self.filt_cls.host_passes(host, filter_properties)) def test_core_filter_fails(self): self.filt_cls = core_filter.CoreFilter() filter_properties = {'instance_type': {'vcpus': 1}} host = fakes.FakeHostState('host1', 'node1', {'vcpus_total': 4, 'vcpus_used': 8, 'cpu_allocation_ratio': 2}) self.assertFalse(self.filt_cls.host_passes(host, filter_properties)) def test_core_filter_single_instance_overcommit_fails(self): self.filt_cls = core_filter.CoreFilter() filter_properties = {'instance_type': {'vcpus': 2}} host = fakes.FakeHostState('host1', 'node1', {'vcpus_total': 1, 'vcpus_used': 0, 'cpu_allocation_ratio': 2}) self.assertFalse(self.filt_cls.host_passes(host, filter_properties)) @mock.patch('nova.scheduler.filters.utils.aggregate_values_from_key') def test_aggregate_core_filter_value_error(self, agg_mock): self.filt_cls = core_filter.AggregateCoreFilter() filter_properties = {'context': mock.sentinel.ctx, 'instance_type': {'vcpus': 1}} host = fakes.FakeHostState('host1', 'node1', {'vcpus_total': 4, 'vcpus_used': 7, 'cpu_allocation_ratio': 2}) agg_mock.return_value = set(['XXX']) self.assertTrue(self.filt_cls.host_passes(host, filter_properties)) agg_mock.assert_called_once_with(host, 'cpu_allocation_ratio') self.assertEqual(4 * 2, host.limits['vcpu']) @mock.patch('nova.scheduler.filters.utils.aggregate_values_from_key') def test_aggregate_core_filter_default_value(self, agg_mock): self.filt_cls = core_filter.AggregateCoreFilter() filter_properties = {'context': mock.sentinel.ctx, 'instance_type': {'vcpus': 1}} host = fakes.FakeHostState('host1', 'node1', {'vcpus_total': 4, 'vcpus_used': 8, 'cpu_allocation_ratio': 2}) agg_mock.return_value = set([]) # False: fallback to default flag w/o aggregates self.assertFalse(self.filt_cls.host_passes(host, filter_properties)) agg_mock.assert_called_once_with(host, 'cpu_allocation_ratio') # True: use ratio from aggregates agg_mock.return_value = set(['3']) self.assertTrue(self.filt_cls.host_passes(host, filter_properties)) self.assertEqual(4 * 3, host.limits['vcpu']) @mock.patch('nova.scheduler.filters.utils.aggregate_values_from_key') def test_aggregate_core_filter_conflict_values(self, agg_mock): self.filt_cls = core_filter.AggregateCoreFilter() filter_properties = {'context': mock.sentinel.ctx, 'instance_type': {'vcpus': 1}} host = fakes.FakeHostState('host1', 'node1', {'vcpus_total': 4, 'vcpus_used': 8, 'cpu_allocation_ratio': 1}) agg_mock.return_value = set(['2', '3']) # use the minimum ratio from aggregates self.assertFalse(self.filt_cls.host_passes(host, filter_properties)) self.assertEqual(4 * 2, host.limits['vcpu'])
apache-2.0
[ 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 1683, 199, 199, 504, 5913, 14, 8874, 14, 4273, 492, 6170, 63, 1541, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 2219, 14, 3248, 14, 8874, 492, 14063, 421, 199, 533, 1379, 5402, 4131, 8, 396, 14, 32437, 304, 339, 347, 511, 63, 1018, 63, 1541, 63, 16027, 8, 277, 304, 267, 291, 14, 18872, 63, 1886, 275, 6170, 63, 1541, 14, 5402, 4131, 342, 267, 2457, 63, 3282, 275, 791, 842, 63, 466, 356, 791, 19685, 356, 413, 4863, 267, 1591, 275, 14063, 14, 8249, 4965, 2223, 360, 1102, 17, 297, 283, 932, 17, 297, 355, 791, 19685, 63, 2923, 356, 841, 12, 283, 19685, 63, 2972, 356, 1520, 12, 326, 283, 3541, 63, 14940, 63, 6884, 356, 499, 1552, 267, 291, 14, 1815, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 339, 347, 511, 63, 1018, 63, 1541, 63, 15762, 63, 3489, 8, 277, 304, 267, 291, 14, 18872, 63, 1886, 275, 6170, 63, 1541, 14, 5402, 4131, 342, 267, 2457, 63, 3282, 275, 791, 842, 63, 466, 356, 791, 19685, 356, 413, 4863, 267, 1591, 275, 14063, 14, 8249, 4965, 2223, 360, 1102, 17, 297, 283, 932, 17, 297, 5009, 267, 291, 14, 1815, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 339, 347, 511, 63, 1018, 63, 1541, 63, 15762, 8, 277, 304, 267, 291, 14, 18872, 63, 1886, 275, 6170, 63, 1541, 14, 5402, 4131, 342, 267, 2457, 63, 3282, 275, 791, 842, 63, 466, 356, 791, 19685, 356, 413, 4863, 267, 1591, 275, 14063, 14, 8249, 4965, 2223, 360, 1102, 17, 297, 283, 932, 17, 297, 355, 791, 19685, 63, 2923, 356, 841, 12, 283, 19685, 63, 2972, 356, 1695, 12, 326, 283, 3541, 63, 14940, 63, 6884, 356, 499, 1552, 267, 291, 14, 3334, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 339, 347, 511, 63, 1018, 63, 1541, 63, 4780, 63, 842, 63, 1883, 3543, 63, 15762, 8, 277, 304, 267, 291, 14, 18872, 63, 1886, 275, 6170, 63, 1541, 14, 5402, 4131, 342, 267, 2457, 63, 3282, 275, 791, 842, 63, 466, 356, 791, 19685, 356, 499, 4863, 267, 1591, 275, 14063, 14, 8249, 4965, 2223, 360, 1102, 17, 297, 283, 932, 17, 297, 355, 791, 19685, 63, 2923, 356, 413, 12, 283, 19685, 63, 2972, 356, 378, 12, 326, 283, 3541, 63, 14940, 63, 6884, 356, 499, 1552, 267, 291, 14, 3334, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 339, 768, 1805, 14, 2068, 360, 6765, 14, 8874, 14, 4273, 14, 1208, 14, 7516, 63, 1459, 63, 504, 63, 498, 358, 272, 347, 511, 63, 7516, 63, 1018, 63, 1541, 63, 585, 63, 705, 8, 277, 12, 19408, 63, 1805, 304, 267, 291, 14, 18872, 63, 1886, 275, 6170, 63, 1541, 14, 10170, 5402, 4131, 342, 267, 2457, 63, 3282, 275, 791, 1100, 356, 1683, 14, 13400, 14, 3799, 12, 2490, 283, 842, 63, 466, 356, 791, 19685, 356, 413, 4863, 267, 1591, 275, 14063, 14, 8249, 4965, 2223, 360, 1102, 17, 297, 283, 932, 17, 297, 355, 791, 19685, 63, 2923, 356, 841, 12, 283, 19685, 63, 2972, 356, 1520, 12, 326, 283, 3541, 63, 14940, 63, 6884, 356, 499, 1552, 267, 19408, 63, 1805, 14, 1107, 63, 585, 275, 663, 2941, 13933, 1105, 267, 291, 14, 1815, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 267, 19408, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 1102, 12, 283, 3541, 63, 14940, 63, 6884, 358, 267, 291, 14, 629, 8, 20, 627, 499, 12, 1591, 14, 9368, 459, 30863, 1105, 339, 768, 1805, 14, 2068, 360, 6765, 14, 8874, 14, 4273, 14, 1208, 14, 7516, 63, 1459, 63, 504, 63, 498, 358, 272, 347, 511, 63, 7516, 63, 1018, 63, 1541, 63, 885, 63, 585, 8, 277, 12, 19408, 63, 1805, 304, 267, 291, 14, 18872, 63, 1886, 275, 6170, 63, 1541, 14, 10170, 5402, 4131, 342, 267, 2457, 63, 3282, 275, 791, 1100, 356, 1683, 14, 13400, 14, 3799, 12, 2490, 283, 842, 63, 466, 356, 791, 19685, 356, 413, 4863, 267, 1591, 275, 14063, 14, 8249, 4965, 2223, 360, 1102, 17, 297, 283, 932, 17, 297, 355, 791, 19685, 63, 2923, 356, 841, 12, 283, 19685, 63, 2972, 356, 1695, 12, 326, 283, 3541, 63, 14940, 63, 6884, 356, 499, 1552, 267, 19408, 63, 1805, 14, 1107, 63, 585, 275, 663, 4157, 267, 327, 756, 26, 9567, 370, 849, 3305, 336, 15, 79, 27535, 267, 291, 14, 3334, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 267, 19408, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 1102, 12, 283, 3541, 63, 14940, 63, 6884, 358, 267, 327, 715, 26, 675, 10463, 687, 27535, 267, 19408, 63, 1805, 14, 1107, 63, 585, 275, 663, 2941, 19, 1105, 267, 291, 14, 1815, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 267, 291, 14, 629, 8, 20, 627, 650, 12, 1591, 14, 9368, 459, 30863, 1105, 339, 768, 1805, 14, 2068, 360, 6765, 14 ]
[ 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 1683, 199, 199, 504, 5913, 14, 8874, 14, 4273, 492, 6170, 63, 1541, 199, 504, 5913, 492, 511, 199, 504, 5913, 14, 2219, 14, 3248, 14, 8874, 492, 14063, 421, 199, 533, 1379, 5402, 4131, 8, 396, 14, 32437, 304, 339, 347, 511, 63, 1018, 63, 1541, 63, 16027, 8, 277, 304, 267, 291, 14, 18872, 63, 1886, 275, 6170, 63, 1541, 14, 5402, 4131, 342, 267, 2457, 63, 3282, 275, 791, 842, 63, 466, 356, 791, 19685, 356, 413, 4863, 267, 1591, 275, 14063, 14, 8249, 4965, 2223, 360, 1102, 17, 297, 283, 932, 17, 297, 355, 791, 19685, 63, 2923, 356, 841, 12, 283, 19685, 63, 2972, 356, 1520, 12, 326, 283, 3541, 63, 14940, 63, 6884, 356, 499, 1552, 267, 291, 14, 1815, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 339, 347, 511, 63, 1018, 63, 1541, 63, 15762, 63, 3489, 8, 277, 304, 267, 291, 14, 18872, 63, 1886, 275, 6170, 63, 1541, 14, 5402, 4131, 342, 267, 2457, 63, 3282, 275, 791, 842, 63, 466, 356, 791, 19685, 356, 413, 4863, 267, 1591, 275, 14063, 14, 8249, 4965, 2223, 360, 1102, 17, 297, 283, 932, 17, 297, 5009, 267, 291, 14, 1815, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 339, 347, 511, 63, 1018, 63, 1541, 63, 15762, 8, 277, 304, 267, 291, 14, 18872, 63, 1886, 275, 6170, 63, 1541, 14, 5402, 4131, 342, 267, 2457, 63, 3282, 275, 791, 842, 63, 466, 356, 791, 19685, 356, 413, 4863, 267, 1591, 275, 14063, 14, 8249, 4965, 2223, 360, 1102, 17, 297, 283, 932, 17, 297, 355, 791, 19685, 63, 2923, 356, 841, 12, 283, 19685, 63, 2972, 356, 1695, 12, 326, 283, 3541, 63, 14940, 63, 6884, 356, 499, 1552, 267, 291, 14, 3334, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 339, 347, 511, 63, 1018, 63, 1541, 63, 4780, 63, 842, 63, 1883, 3543, 63, 15762, 8, 277, 304, 267, 291, 14, 18872, 63, 1886, 275, 6170, 63, 1541, 14, 5402, 4131, 342, 267, 2457, 63, 3282, 275, 791, 842, 63, 466, 356, 791, 19685, 356, 499, 4863, 267, 1591, 275, 14063, 14, 8249, 4965, 2223, 360, 1102, 17, 297, 283, 932, 17, 297, 355, 791, 19685, 63, 2923, 356, 413, 12, 283, 19685, 63, 2972, 356, 378, 12, 326, 283, 3541, 63, 14940, 63, 6884, 356, 499, 1552, 267, 291, 14, 3334, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 339, 768, 1805, 14, 2068, 360, 6765, 14, 8874, 14, 4273, 14, 1208, 14, 7516, 63, 1459, 63, 504, 63, 498, 358, 272, 347, 511, 63, 7516, 63, 1018, 63, 1541, 63, 585, 63, 705, 8, 277, 12, 19408, 63, 1805, 304, 267, 291, 14, 18872, 63, 1886, 275, 6170, 63, 1541, 14, 10170, 5402, 4131, 342, 267, 2457, 63, 3282, 275, 791, 1100, 356, 1683, 14, 13400, 14, 3799, 12, 2490, 283, 842, 63, 466, 356, 791, 19685, 356, 413, 4863, 267, 1591, 275, 14063, 14, 8249, 4965, 2223, 360, 1102, 17, 297, 283, 932, 17, 297, 355, 791, 19685, 63, 2923, 356, 841, 12, 283, 19685, 63, 2972, 356, 1520, 12, 326, 283, 3541, 63, 14940, 63, 6884, 356, 499, 1552, 267, 19408, 63, 1805, 14, 1107, 63, 585, 275, 663, 2941, 13933, 1105, 267, 291, 14, 1815, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 267, 19408, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 1102, 12, 283, 3541, 63, 14940, 63, 6884, 358, 267, 291, 14, 629, 8, 20, 627, 499, 12, 1591, 14, 9368, 459, 30863, 1105, 339, 768, 1805, 14, 2068, 360, 6765, 14, 8874, 14, 4273, 14, 1208, 14, 7516, 63, 1459, 63, 504, 63, 498, 358, 272, 347, 511, 63, 7516, 63, 1018, 63, 1541, 63, 885, 63, 585, 8, 277, 12, 19408, 63, 1805, 304, 267, 291, 14, 18872, 63, 1886, 275, 6170, 63, 1541, 14, 10170, 5402, 4131, 342, 267, 2457, 63, 3282, 275, 791, 1100, 356, 1683, 14, 13400, 14, 3799, 12, 2490, 283, 842, 63, 466, 356, 791, 19685, 356, 413, 4863, 267, 1591, 275, 14063, 14, 8249, 4965, 2223, 360, 1102, 17, 297, 283, 932, 17, 297, 355, 791, 19685, 63, 2923, 356, 841, 12, 283, 19685, 63, 2972, 356, 1695, 12, 326, 283, 3541, 63, 14940, 63, 6884, 356, 499, 1552, 267, 19408, 63, 1805, 14, 1107, 63, 585, 275, 663, 4157, 267, 327, 756, 26, 9567, 370, 849, 3305, 336, 15, 79, 27535, 267, 291, 14, 3334, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 267, 19408, 63, 1805, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 1102, 12, 283, 3541, 63, 14940, 63, 6884, 358, 267, 327, 715, 26, 675, 10463, 687, 27535, 267, 19408, 63, 1805, 14, 1107, 63, 585, 275, 663, 2941, 19, 1105, 267, 291, 14, 1815, 8, 277, 14, 18872, 63, 1886, 14, 1102, 63, 16027, 8, 1102, 12, 2457, 63, 3282, 430, 267, 291, 14, 629, 8, 20, 627, 650, 12, 1591, 14, 9368, 459, 30863, 1105, 339, 768, 1805, 14, 2068, 360, 6765, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
skirsdeda/django
tests/validation/test_unique.py
62
7105
from __future__ import unicode_literals import datetime import unittest from django.apps.registry import Apps from django.core.exceptions import ValidationError from django.db import models from django.test import TestCase from .models import (CustomPKModel, UniqueTogetherModel, UniqueFieldsModel, UniqueForDateModel, ModelToValidate, Post, FlexibleDatePost, UniqueErrorsModel) class GetUniqueCheckTests(unittest.TestCase): def test_unique_fields_get_collected(self): m = UniqueFieldsModel() self.assertEqual( ([(UniqueFieldsModel, ('id',)), (UniqueFieldsModel, ('unique_charfield',)), (UniqueFieldsModel, ('unique_integerfield',))], []), m._get_unique_checks() ) def test_unique_together_gets_picked_up_and_converted_to_tuple(self): m = UniqueTogetherModel() self.assertEqual( ([(UniqueTogetherModel, ('ifield', 'cfield')), (UniqueTogetherModel, ('ifield', 'efield')), (UniqueTogetherModel, ('id',)), ], []), m._get_unique_checks() ) def test_unique_together_normalization(self): """ Test the Meta.unique_together normalization with different sorts of objects. """ data = { '2-tuple': (('foo', 'bar'), (('foo', 'bar'),)), 'list': (['foo', 'bar'], (('foo', 'bar'),)), 'already normalized': ((('foo', 'bar'), ('bar', 'baz')), (('foo', 'bar'), ('bar', 'baz'))), 'set': ({('foo', 'bar'), ('bar', 'baz')}, # Ref #21469 (('foo', 'bar'), ('bar', 'baz'))), } for test_name, (unique_together, normalized) in data.items(): class M(models.Model): foo = models.IntegerField() bar = models.IntegerField() baz = models.IntegerField() Meta = type(str('Meta'), (), { 'unique_together': unique_together, 'apps': Apps() }) checks, _ = M()._get_unique_checks() for t in normalized: check = (M, t) self.assertIn(check, checks) def test_primary_key_is_considered_unique(self): m = CustomPKModel() self.assertEqual(([(CustomPKModel, ('my_pk_field',))], []), m._get_unique_checks()) def test_unique_for_date_gets_picked_up(self): m = UniqueForDateModel() self.assertEqual(( [(UniqueForDateModel, ('id',))], [(UniqueForDateModel, 'date', 'count', 'start_date'), (UniqueForDateModel, 'year', 'count', 'end_date'), (UniqueForDateModel, 'month', 'order', 'end_date')] ), m._get_unique_checks() ) def test_unique_for_date_exclusion(self): m = UniqueForDateModel() self.assertEqual(( [(UniqueForDateModel, ('id',))], [(UniqueForDateModel, 'year', 'count', 'end_date'), (UniqueForDateModel, 'month', 'order', 'end_date')] ), m._get_unique_checks(exclude='start_date') ) class PerformUniqueChecksTest(TestCase): def test_primary_key_unique_check_not_performed_when_adding_and_pk_not_specified(self): # Regression test for #12560 with self.assertNumQueries(0): mtv = ModelToValidate(number=10, name='Some Name') setattr(mtv, '_adding', True) mtv.full_clean() def test_primary_key_unique_check_performed_when_adding_and_pk_specified(self): # Regression test for #12560 with self.assertNumQueries(1): mtv = ModelToValidate(number=10, name='Some Name', id=123) setattr(mtv, '_adding', True) mtv.full_clean() def test_primary_key_unique_check_not_performed_when_not_adding(self): # Regression test for #12132 with self.assertNumQueries(0): mtv = ModelToValidate(number=10, name='Some Name') mtv.full_clean() def test_unique_for_date(self): Post.objects.create(title="Django 1.0 is released", slug="Django 1.0", subtitle="Finally", posted=datetime.date(2008, 9, 3)) p = Post(title="Django 1.0 is released", posted=datetime.date(2008, 9, 3)) with self.assertRaises(ValidationError) as cm: p.full_clean() self.assertEqual(cm.exception.message_dict, {'title': ['Title must be unique for Posted date.']}) # Should work without errors p = Post(title="Work on Django 1.1 begins", posted=datetime.date(2008, 9, 3)) p.full_clean() # Should work without errors p = Post(title="Django 1.0 is released", posted=datetime.datetime(2008, 9, 4)) p.full_clean() p = Post(slug="Django 1.0", posted=datetime.datetime(2008, 1, 1)) with self.assertRaises(ValidationError) as cm: p.full_clean() self.assertEqual(cm.exception.message_dict, {'slug': ['Slug must be unique for Posted year.']}) p = Post(subtitle="Finally", posted=datetime.datetime(2008, 9, 30)) with self.assertRaises(ValidationError) as cm: p.full_clean() self.assertEqual(cm.exception.message_dict, {'subtitle': ['Subtitle must be unique for Posted month.']}) p = Post(title="Django 1.0 is released") with self.assertRaises(ValidationError) as cm: p.full_clean() self.assertEqual(cm.exception.message_dict, {'posted': ['This field cannot be null.']}) def test_unique_for_date_with_nullable_date(self): FlexibleDatePost.objects.create(title="Django 1.0 is released", slug="Django 1.0", subtitle="Finally", posted=datetime.date(2008, 9, 3)) p = FlexibleDatePost(title="Django 1.0 is released") try: p.full_clean() except ValidationError: self.fail("unique_for_date checks shouldn't trigger when the associated DateField is None.") p = FlexibleDatePost(slug="Django 1.0") try: p.full_clean() except ValidationError: self.fail("unique_for_year checks shouldn't trigger when the associated DateField is None.") p = FlexibleDatePost(subtitle="Finally") try: p.full_clean() except ValidationError: self.fail("unique_for_month checks shouldn't trigger when the associated DateField is None.") def test_unique_errors(self): UniqueErrorsModel.objects.create(name='Some Name', no=10) m = UniqueErrorsModel(name='Some Name', no=11) with self.assertRaises(ValidationError) as cm: m.full_clean() self.assertEqual(cm.exception.message_dict, {'name': ['Custom unique name message.']}) m = UniqueErrorsModel(name='Some Other Name', no=10) with self.assertRaises(ValidationError) as cm: m.full_clean() self.assertEqual(cm.exception.message_dict, {'no': ['Custom unique number message.']})
bsd-3-clause
[ 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 2882, 199, 199, 504, 1639, 14, 5181, 14, 5189, 492, 4693, 83, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 334, 7223, 8884, 1685, 12, 18276, 1378, 4920, 1685, 12, 18276, 7304, 1685, 12, 272, 18276, 1858, 2506, 1685, 12, 5822, 1378, 12584, 12, 7711, 12, 481, 8196, 2506, 6564, 12, 272, 18276, 9298, 1685, 9, 421, 199, 533, 2372, 11427, 1799, 2925, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 3235, 63, 955, 63, 362, 63, 22766, 8, 277, 304, 267, 333, 275, 18276, 7304, 1685, 342, 267, 291, 14, 629, 8, 288, 7287, 8, 11427, 7304, 1685, 12, 661, 344, 16256, 1598, 334, 11427, 7304, 1685, 12, 661, 3235, 63, 1560, 698, 16256, 1598, 334, 11427, 7304, 1685, 12, 661, 3235, 63, 4115, 698, 16829, 467, 1467, 14431, 288, 333, 423, 362, 63, 3235, 63, 8625, 342, 267, 776, 339, 347, 511, 63, 3235, 63, 6314, 63, 24894, 63, 4510, 379, 63, 384, 63, 460, 63, 22818, 63, 475, 63, 2960, 8, 277, 304, 267, 333, 275, 18276, 1378, 4920, 1685, 342, 267, 291, 14, 629, 8, 288, 7287, 8, 11427, 1378, 4920, 1685, 12, 661, 73, 698, 297, 283, 67, 698, 3855, 1598, 334, 11427, 1378, 4920, 1685, 12, 661, 73, 698, 297, 283, 69, 698, 3855, 1598, 334, 11427, 1378, 4920, 1685, 12, 661, 344, 16256, 2156, 1467, 14431, 288, 333, 423, 362, 63, 3235, 63, 8625, 342, 267, 776, 339, 347, 511, 63, 3235, 63, 6314, 63, 22384, 8, 277, 304, 267, 408, 267, 1379, 314, 6288, 14, 3235, 63, 6314, 16973, 543, 3365, 30313, 402, 267, 2251, 14, 267, 408, 267, 666, 275, 469, 288, 283, 18, 13, 2960, 356, 13636, 1421, 297, 283, 1700, 659, 717, 13636, 1421, 297, 283, 1700, 659, 1826, 288, 283, 513, 356, 21022, 1421, 297, 283, 1700, 995, 2151, 13636, 1421, 297, 283, 1700, 659, 1826, 288, 283, 14039, 9657, 356, 3666, 360, 1421, 297, 283, 1700, 659, 661, 1700, 297, 283, 6185, 3855, 3521, 13636, 1421, 297, 283, 1700, 659, 661, 1700, 297, 283, 6185, 22645, 288, 283, 409, 356, 11459, 360, 1421, 297, 283, 1700, 659, 661, 1700, 297, 283, 6185, 3904, 221, 327, 15397, 327, 6886, 1876, 490, 13636, 1421, 297, 283, 1700, 659, 661, 1700, 297, 283, 6185, 22645, 267, 789, 398, 367, 511, 63, 354, 12, 334, 3235, 63, 6314, 12, 9657, 9, 315, 666, 14, 1744, 837, 288, 1021, 603, 8, 992, 14, 1685, 304, 355, 3925, 275, 1709, 14, 3901, 342, 355, 4681, 275, 1709, 14, 3901, 342, 355, 15507, 275, 1709, 14, 3901, 342, 2234, 6288, 275, 730, 8, 495, 360, 3396, 659, 11969, 469, 490, 283, 3235, 63, 6314, 356, 3747, 63, 6314, 12, 490, 283, 5181, 356, 4693, 83, 342, 355, 3828, 953, 5920, 12, 485, 275, 603, 19050, 362, 63, 3235, 63, 8625, 342, 288, 367, 307, 315, 9657, 26, 355, 1104, 275, 334, 45, 12, 307, 9, 355, 291, 14, 4080, 8, 1074, 12, 5920, 9, 339, 347, 511, 63, 3327, 63, 498, 63, 374, 63, 388, 2441, 581, 63, 3235, 8, 277, 304, 267, 333, 275, 8388, 8884, 1685, 342, 267, 291, 14, 629, 8, 7694, 7223, 8884, 1685, 12, 661, 1662, 63, 2051, 63, 698, 16829, 467, 14431, 333, 423, 362, 63, 3235, 63, 8625, 1012, 339, 347, 511, 63, 3235, 63, 509, 63, 602, 63, 24894, 63, 4510, 379, 63, 384, 8, 277, 304, 267, 333, 275, 18276, 1858, 2506, 1685, 342, 267, 291, 14, 629, 1332, 288, 3842, 11427, 1858, 2506, 1685, 12, 661, 344, 16829, 467, 288, 3842, 11427, 1858, 2506, 1685, 12, 283, 602, 297, 283, 835, 297, 283, 928, 63, 602, 659, 1467, 334, 11427, 1858, 2506, 1685, 12, 283, 3403, 297, 283, 835, 297, 283, 500, 63, 602, 659, 1467, 334, 11427, 1858, 2506, 1685, 12, 283, 4482, 297, 283, 1648, 297, 283, 500, 63, 602, 5440, 267, 2318, 333, 423, 362, 63, 3235, 63, 8625, 342, 267, 776, 339, 347, 511, 63, 3235, 63, 509, 63, 602, 63, 476, 10248, 8, 277, 304, 267, 333, 275, 18276, 1858, 2506, 1685, 342, 267, 291, 14, 629, 1332, 288, 3842, 11427, 1858, 2506, 1685, 12, 661, 344, 16829, 467, 288, 3842, 11427, 1858, 2506, 1685, 12, 283, 3403, 297, 283, 835, 297, 283, 500, 63, 602, 659, 1467, 334, 11427, 1858, 2506, 1685, 12, 283, 4482, 297, 283, 1648, 297, 283, 500, 63, 602, 5440, 267, 2318, 333, 423, 362, 63, 3235, 63, 8625, 8, 5473, 534, 928, 63, 602, 358, 267, 776, 421, 199, 533, 14795, 11427, 11834, 774, 8, 1746, 304, 272, 347, 511, 63, 3327, 63, 498, 63, 3235, 63, 1074, 63, 1397, 63, 31652, 63, 6526, 63, 4095, 63, 460, 63, 2051, 63, 1397, 63, 10085, 8, 277, 304, 267, 327, 13262, 511, 367, 327, 713, 15789, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 333, 6993, 275, 5822, 1378, 12584, 8, 1955, 29, 709, 12, 536, 534, 7700, 2812, 358, 288, 5371, 8, 2037, 86, 12, 2513, 4095, 297, 715, 9, 288, 333, 6993, 14, 2861, 63, 3118, 342, 339, 347, 511, 63, 3327, 63, 498, 63, 3235, 63, 1074, 63, 31652, 63, 6526, 63, 4095, 63, 460, 63, 2051, 63, 10085, 8, 277, 304, 267, 327, 13262, 511, 367, 327, 713, 15789, 267, 543, 291, 14, 16463, 8, 17, 304, 288, 333, 6993, 275, 5822, 1378, 12584, 8, 1955, 29, 709, 12, 536, 534, 7700, 2812, 297, 1305, 29, 4288, 9, 288, 5371, 8, 2037, 86, 12, 2513, 4095, 297, 715, 9, 288, 333, 6993, 14, 2861, 63, 3118, 342, 339, 347, 511, 63, 3327, 63, 498, 63, 3235, 63, 1074, 63, 1397, 63, 31652, 63, 6526, 63, 1397, 63, 4095, 8, 277, 304, 267, 327, 13262, 511, 367, 327, 713, 6557, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 333, 6993, 275, 5822, 1378, 12584, 8, 1955, 29, 709, 12, 536, 534, 7700, 2812, 358, 288, 333, 6993, 14, 2861, 63, 3118, 342, 339, 347, 511, 63, 3235 ]
[ 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 2197, 199, 646, 2882, 199, 199, 504, 1639, 14, 5181, 14, 5189, 492, 4693, 83, 199, 504, 1639, 14, 1018, 14, 3924, 492, 8505, 199, 504, 1639, 14, 697, 492, 1709, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1275, 992, 492, 334, 7223, 8884, 1685, 12, 18276, 1378, 4920, 1685, 12, 18276, 7304, 1685, 12, 272, 18276, 1858, 2506, 1685, 12, 5822, 1378, 12584, 12, 7711, 12, 481, 8196, 2506, 6564, 12, 272, 18276, 9298, 1685, 9, 421, 199, 533, 2372, 11427, 1799, 2925, 8, 2796, 14, 1746, 304, 272, 347, 511, 63, 3235, 63, 955, 63, 362, 63, 22766, 8, 277, 304, 267, 333, 275, 18276, 7304, 1685, 342, 267, 291, 14, 629, 8, 288, 7287, 8, 11427, 7304, 1685, 12, 661, 344, 16256, 1598, 334, 11427, 7304, 1685, 12, 661, 3235, 63, 1560, 698, 16256, 1598, 334, 11427, 7304, 1685, 12, 661, 3235, 63, 4115, 698, 16829, 467, 1467, 14431, 288, 333, 423, 362, 63, 3235, 63, 8625, 342, 267, 776, 339, 347, 511, 63, 3235, 63, 6314, 63, 24894, 63, 4510, 379, 63, 384, 63, 460, 63, 22818, 63, 475, 63, 2960, 8, 277, 304, 267, 333, 275, 18276, 1378, 4920, 1685, 342, 267, 291, 14, 629, 8, 288, 7287, 8, 11427, 1378, 4920, 1685, 12, 661, 73, 698, 297, 283, 67, 698, 3855, 1598, 334, 11427, 1378, 4920, 1685, 12, 661, 73, 698, 297, 283, 69, 698, 3855, 1598, 334, 11427, 1378, 4920, 1685, 12, 661, 344, 16256, 2156, 1467, 14431, 288, 333, 423, 362, 63, 3235, 63, 8625, 342, 267, 776, 339, 347, 511, 63, 3235, 63, 6314, 63, 22384, 8, 277, 304, 267, 408, 267, 1379, 314, 6288, 14, 3235, 63, 6314, 16973, 543, 3365, 30313, 402, 267, 2251, 14, 267, 408, 267, 666, 275, 469, 288, 283, 18, 13, 2960, 356, 13636, 1421, 297, 283, 1700, 659, 717, 13636, 1421, 297, 283, 1700, 659, 1826, 288, 283, 513, 356, 21022, 1421, 297, 283, 1700, 995, 2151, 13636, 1421, 297, 283, 1700, 659, 1826, 288, 283, 14039, 9657, 356, 3666, 360, 1421, 297, 283, 1700, 659, 661, 1700, 297, 283, 6185, 3855, 3521, 13636, 1421, 297, 283, 1700, 659, 661, 1700, 297, 283, 6185, 22645, 288, 283, 409, 356, 11459, 360, 1421, 297, 283, 1700, 659, 661, 1700, 297, 283, 6185, 3904, 221, 327, 15397, 327, 6886, 1876, 490, 13636, 1421, 297, 283, 1700, 659, 661, 1700, 297, 283, 6185, 22645, 267, 789, 398, 367, 511, 63, 354, 12, 334, 3235, 63, 6314, 12, 9657, 9, 315, 666, 14, 1744, 837, 288, 1021, 603, 8, 992, 14, 1685, 304, 355, 3925, 275, 1709, 14, 3901, 342, 355, 4681, 275, 1709, 14, 3901, 342, 355, 15507, 275, 1709, 14, 3901, 342, 2234, 6288, 275, 730, 8, 495, 360, 3396, 659, 11969, 469, 490, 283, 3235, 63, 6314, 356, 3747, 63, 6314, 12, 490, 283, 5181, 356, 4693, 83, 342, 355, 3828, 953, 5920, 12, 485, 275, 603, 19050, 362, 63, 3235, 63, 8625, 342, 288, 367, 307, 315, 9657, 26, 355, 1104, 275, 334, 45, 12, 307, 9, 355, 291, 14, 4080, 8, 1074, 12, 5920, 9, 339, 347, 511, 63, 3327, 63, 498, 63, 374, 63, 388, 2441, 581, 63, 3235, 8, 277, 304, 267, 333, 275, 8388, 8884, 1685, 342, 267, 291, 14, 629, 8, 7694, 7223, 8884, 1685, 12, 661, 1662, 63, 2051, 63, 698, 16829, 467, 14431, 333, 423, 362, 63, 3235, 63, 8625, 1012, 339, 347, 511, 63, 3235, 63, 509, 63, 602, 63, 24894, 63, 4510, 379, 63, 384, 8, 277, 304, 267, 333, 275, 18276, 1858, 2506, 1685, 342, 267, 291, 14, 629, 1332, 288, 3842, 11427, 1858, 2506, 1685, 12, 661, 344, 16829, 467, 288, 3842, 11427, 1858, 2506, 1685, 12, 283, 602, 297, 283, 835, 297, 283, 928, 63, 602, 659, 1467, 334, 11427, 1858, 2506, 1685, 12, 283, 3403, 297, 283, 835, 297, 283, 500, 63, 602, 659, 1467, 334, 11427, 1858, 2506, 1685, 12, 283, 4482, 297, 283, 1648, 297, 283, 500, 63, 602, 5440, 267, 2318, 333, 423, 362, 63, 3235, 63, 8625, 342, 267, 776, 339, 347, 511, 63, 3235, 63, 509, 63, 602, 63, 476, 10248, 8, 277, 304, 267, 333, 275, 18276, 1858, 2506, 1685, 342, 267, 291, 14, 629, 1332, 288, 3842, 11427, 1858, 2506, 1685, 12, 661, 344, 16829, 467, 288, 3842, 11427, 1858, 2506, 1685, 12, 283, 3403, 297, 283, 835, 297, 283, 500, 63, 602, 659, 1467, 334, 11427, 1858, 2506, 1685, 12, 283, 4482, 297, 283, 1648, 297, 283, 500, 63, 602, 5440, 267, 2318, 333, 423, 362, 63, 3235, 63, 8625, 8, 5473, 534, 928, 63, 602, 358, 267, 776, 421, 199, 533, 14795, 11427, 11834, 774, 8, 1746, 304, 272, 347, 511, 63, 3327, 63, 498, 63, 3235, 63, 1074, 63, 1397, 63, 31652, 63, 6526, 63, 4095, 63, 460, 63, 2051, 63, 1397, 63, 10085, 8, 277, 304, 267, 327, 13262, 511, 367, 327, 713, 15789, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 333, 6993, 275, 5822, 1378, 12584, 8, 1955, 29, 709, 12, 536, 534, 7700, 2812, 358, 288, 5371, 8, 2037, 86, 12, 2513, 4095, 297, 715, 9, 288, 333, 6993, 14, 2861, 63, 3118, 342, 339, 347, 511, 63, 3327, 63, 498, 63, 3235, 63, 1074, 63, 31652, 63, 6526, 63, 4095, 63, 460, 63, 2051, 63, 10085, 8, 277, 304, 267, 327, 13262, 511, 367, 327, 713, 15789, 267, 543, 291, 14, 16463, 8, 17, 304, 288, 333, 6993, 275, 5822, 1378, 12584, 8, 1955, 29, 709, 12, 536, 534, 7700, 2812, 297, 1305, 29, 4288, 9, 288, 5371, 8, 2037, 86, 12, 2513, 4095, 297, 715, 9, 288, 333, 6993, 14, 2861, 63, 3118, 342, 339, 347, 511, 63, 3327, 63, 498, 63, 3235, 63, 1074, 63, 1397, 63, 31652, 63, 6526, 63, 1397, 63, 4095, 8, 277, 304, 267, 327, 13262, 511, 367, 327, 713, 6557, 267, 543, 291, 14, 16463, 8, 16, 304, 288, 333, 6993, 275, 5822, 1378, 12584, 8, 1955, 29, 709, 12, 536, 534, 7700, 2812, 358, 288, 333, 6993, 14, 2861, 63, 3118, 342, 339, 347, 511, 63, 3235, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
BIDXOM/buildroot
support/scripts/gen-manual-lists.py
77
20371
## gen-manual-lists.py ## ## This script generates the following Buildroot manual appendices: ## - the package tables (one for the target, the other for host tools); ## - the deprecated items. ## ## Author(s): ## - Samuel Martin <s.martin49@gmail.com> ## ## Copyright (C) 2013 Samuel Martin ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## from __future__ import print_function from __future__ import unicode_literals import os import re import sys import datetime from argparse import ArgumentParser try: import kconfiglib except ImportError: message = """ Could not find the module 'kconfiglib' in the PYTHONPATH: """ message += "\n".join([" {0}".format(path) for path in sys.path]) message += """ Make sure the Kconfiglib directory is in the PYTHONPATH, then relaunch the script. You can get kconfiglib from: https://github.com/ulfalizer/Kconfiglib """ sys.stderr.write(message) raise def get_symbol_subset(root, filter_func): """ Return a generator of kconfig items. :param root_item: Root item of the generated subset of items :param filter_func: Filter function """ if hasattr(root, "get_items"): get_items = root.get_items elif hasattr(root, "get_top_level_items"): get_items = root.get_top_level_items else: message = "The symbol does not contain any subset of symbols" raise Exception(message) for item in get_items(): if item.is_symbol(): if not filter_func(item): continue yield item elif item.is_menu() or item.is_choice(): for i in get_symbol_subset(item, filter_func): yield i def get_symbol_parents(item, root=None, enable_choice=False): """ Return the list of the item's parents. The last item of the list is the closest parent, the first the furthest. :param item: Item from which the parent list is generated :param root: Root item stopping the search (not included in the parent list) :param enable_choice: Flag enabling choices to appear in the parent list """ parent = item.get_parent() parents = [] while parent and parent != root: if parent.is_menu(): parents.append(parent.get_title()) elif enable_choice and parent.is_choice(): parents.append(parent.get_prompts()[0]) parent = parent.get_parent() if isinstance(root, kconfiglib.Menu) or \ (enable_choice and isinstance(root, kconfiglib.Choice)): parents.append("") # Dummy empty parent to get a leading arrow -> parents.reverse() return parents def format_asciidoc_table(root, get_label_func, filter_func=lambda x: True, format_func=lambda x: x, enable_choice=False, sorted=True, item_label=None): """ Return the asciidoc formatted table of the items and their location. :param root: Root item of the item subset :param get_label_func: Item's label getter function :param filter_func: Filter function to apply on the item subset :param format_func: Function to format a symbol and the table header :param enable_choice: Enable choices to appear as part of the item's location :param sorted: Flag to alphabetically sort the table """ lines = [] for item in get_symbol_subset(root, filter_func): lines.append(format_func(what="symbol", symbol=item, root=root, get_label_func=get_label_func, enable_choice=enable_choice)) if sorted: lines.sort(key=lambda x: x.lower()) table = ":halign: center\n\n" width, columns = format_func(what="layout") table = "[width=\"{0}\",cols=\"{1}\",options=\"header\"]\n".format(width, columns) table += "|===================================================\n" table += format_func(what="header", header=item_label, root=root) table += "\n" + "".join(lines) + "\n" table += "|===================================================\n" return table class Buildroot: """ Buildroot configuration object. """ root_config = "Config.in" package_dirname = "package" package_prefixes = ["BR2_PACKAGE_", "BR2_PACKAGE_HOST_"] re_pkg_prefix = re.compile(r"^(" + "|".join(package_prefixes) + ").*") deprecated_symbol = "BR2_DEPRECATED" list_in = """\ // // Automatically generated list for Buildroot manual. // {table} """ list_info = { 'target-packages': { 'filename': "package-list", 'root_menu': "Target packages", 'filter': "_is_real_package", 'format': "_format_symbol_prompt_location", 'sorted': True, }, 'host-packages': { 'filename': "host-package-list", 'root_menu': "Host utilities", 'filter': "_is_real_package", 'format': "_format_symbol_prompt", 'sorted': True, }, 'virtual-packages': { 'filename': "virtual-package-list", 'root_menu': "Target packages", 'filter': "_is_virtual_package", 'format': "_format_symbol_virtual", 'sorted': True, }, 'deprecated': { 'filename': "deprecated-list", 'root_menu': None, 'filter': "_is_deprecated_feature", 'format': "_format_symbol_prompt_location", 'sorted': False, }, } def __init__(self): self.base_dir = os.environ.get("TOPDIR") self.output_dir = os.environ.get("O") self.package_dir = os.path.join(self.base_dir, self.package_dirname) self.config = kconfiglib.Config(os.path.join(self.base_dir, self.root_config), self.base_dir) self._deprecated = self.config.get_symbol(self.deprecated_symbol) self.gen_date = datetime.datetime.utcnow() self.br_version_full = os.environ.get("BR2_VERSION_FULL") if self.br_version_full and self.br_version_full.endswith("-git"): self.br_version_full = self.br_version_full[:-4] if not self.br_version_full: self.br_version_full = "undefined" def _get_package_symbols(self, package_name): """ Return a tuple containing the target and host package symbol. """ symbols = re.sub("[-+.]", "_", package_name) symbols = symbols.upper() symbols = tuple([prefix + symbols for prefix in self.package_prefixes]) return symbols def _is_deprecated(self, symbol): """ Return True if the symbol is marked as deprecated, otherwise False. """ # This also catches BR2_DEPRECATED_SINCE_xxxx_xx return bool([ symbol for x in symbol.get_referenced_symbols() if x.get_name().startswith(self._deprecated.get_name()) ]) def _is_package(self, symbol, type='real'): """ Return True if the symbol is a package or a host package, otherwise False. :param symbol: The symbol to check :param type: Limit to 'real' or 'virtual' types of packages, with 'real' being the default. Note: only 'real' is (implictly) handled for now """ if not symbol.is_symbol(): return False if type == 'real' and not symbol.get_prompts(): return False if type == 'virtual' and symbol.get_prompts(): return False if not self.re_pkg_prefix.match(symbol.get_name()): return False pkg_name = self._get_pkg_name(symbol) pattern = "^(HOST_)?" + pkg_name + "$" pattern = re.sub("_", ".", pattern) pattern = re.compile(pattern, re.IGNORECASE) # Here, we cannot just check for the location of the Config.in because # of the "virtual" package. # # So, to check that a symbol is a package (not a package option or # anything else), we check for the existence of the package *.mk file. # # By the way, to actually check for a package, we should grep all *.mk # files for the following regex: # "\$\(eval \$\((host-)?(generic|autotools|cmake)-package\)\)" # # Implementation details: # # * The package list is generated from the *.mk file existence, the # first time this function is called. Despite the memory consumption, # this list is stored because the execution time of this script is # noticeably shorter than rescanning the package sub-tree for each # symbol. if not hasattr(self, "_package_list"): pkg_list = [] for _, _, files in os.walk(self.package_dir): for file_ in (f for f in files if f.endswith(".mk")): pkg_list.append(re.sub(r"(.*?)\.mk", r"\1", file_)) setattr(self, "_package_list", pkg_list) for pkg in getattr(self, "_package_list"): if type == 'real': if pattern.match(pkg) and not self._exists_virt_symbol(pkg): return True if type == 'virtual': if pattern.match('has_' + pkg): return True return False def _is_real_package(self, symbol): return self._is_package(symbol, 'real') def _is_virtual_package(self, symbol): return self._is_package(symbol, 'virtual') def _is_deprecated_feature(self, symbol): return symbol.get_prompts() and self._is_deprecated(symbol) def _exists_virt_symbol(self, pkg_name): """ Return True if a symbol exists that defines the package as a virtual package, False otherwise :param pkg_name: The name of the package, for which to check if a symbol exists defining it as a virtual package """ virt_pattern = "BR2_PACKAGE_HAS_" + pkg_name + "$" virt_pattern = re.sub("_", ".", virt_pattern) virt_pattern = re.compile(virt_pattern, re.IGNORECASE) for sym in self.config: if virt_pattern.match(sym.get_name()): return True return False def _get_pkg_name(self, symbol): """ Return the package name of the specified symbol. :param symbol: The symbol to get the package name of """ return re.sub("BR2_PACKAGE_(HOST_)?(.*)", r"\2", symbol.get_name()) def _get_symbol_label(self, symbol, mark_deprecated=True): """ Return the label (a.k.a. prompt text) of the symbol. :param symbol: The symbol :param mark_deprecated: Append a 'deprecated' to the label """ label = symbol.get_prompts()[0] if self._is_deprecated(symbol) and mark_deprecated: label += " *(deprecated)*" return label def _format_symbol_prompt(self, what=None, symbol=None, root=None, enable_choice=False, header=None, get_label_func=lambda x: x): if what == "layout": return ( "30%", "^1" ) if what == "header": return "| {0:<40}\n".format(header) if what == "symbol": return "| {0:<40}\n".format(get_label_func(symbol)) message = "Invalid argument 'what': '%s'\n" % str(what) message += "Allowed values are: 'layout', 'header' and 'symbol'" raise Exception(message) def _format_symbol_prompt_location(self, what=None, symbol=None, root=None, enable_choice=False, header=None, get_label_func=lambda x: x): if what == "layout": return ( "100%", "^1,4" ) if what == "header": if hasattr(root, "get_title"): loc_label = get_symbol_parents(root, None, enable_choice=enable_choice) loc_label += [root.get_title(), "..."] else: loc_label = ["Location"] return "| {0:<40} <| {1}\n".format(header, " -> ".join(loc_label)) if what == "symbol": parents = get_symbol_parents(symbol, root, enable_choice) return "| {0:<40} <| {1}\n".format(get_label_func(symbol), " -> ".join(parents)) message = "Invalid argument 'what': '%s'\n" % str(what) message += "Allowed values are: 'layout', 'header' and 'symbol'" raise Exception(message) def _format_symbol_virtual(self, what=None, symbol=None, root=None, enable_choice=False, header=None, get_label_func=lambda x: "?"): def _symbol_is_legacy(symbol): selects = [ s.get_name() for s in symbol.get_selected_symbols() ] return ("BR2_LEGACY" in selects) def _get_parent_package(sym): if self._is_real_package(sym): return None # Trim the symbol name from its last component (separated with # underscores), until we either find a symbol which is a real # package, or until we have no component (i.e. just 'BR2') name = sym.get_name() while name != "BR2": name = name.rsplit("_", 1)[0] s = self.config.get_symbol(name) if s is None: continue if self._is_real_package(s): return s return None def _get_providers(symbol): providers = list() for sym in self.config: if not sym.is_symbol(): continue if _symbol_is_legacy(sym): continue selects = sym.get_selected_symbols() if not selects: continue for s in selects: if s == symbol: if sym.get_prompts(): l = self._get_symbol_label(sym,False) parent_pkg = _get_parent_package(sym) if parent_pkg is not None: l = self._get_symbol_label(parent_pkg, False) \ + " (w/ " + l + ")" providers.append(l) else: providers.extend(_get_providers(sym)) return providers if what == "layout": return ( "100%", "^1,4,4" ) if what == "header": return "| {0:<20} <| {1:<32} <| Providers\n".format("Virtual packages", "Symbols") if what == "symbol": pkg = re.sub(r"^BR2_PACKAGE_HAS_(.+)$", r"\1", symbol.get_name()) providers = _get_providers(symbol) return "| {0:<20} <| {1:<32} <| {2}\n".format(pkg.lower(), '+' + symbol.get_name() + '+', ", ".join(providers)) message = "Invalid argument 'what': '%s'\n" % str(what) message += "Allowed values are: 'layout', 'header' and 'symbol'" raise Exception(message) def print_list(self, list_type, enable_choice=True, enable_deprecated=True, dry_run=False, output=None): """ Print the requested list. If not dry run, then the list is automatically written in its own file. :param list_type: The list type to be generated :param enable_choice: Flag enabling choices to appear in the list :param enable_deprecated: Flag enabling deprecated items to appear in the package lists :param dry_run: Dry run (print the list in stdout instead of writing the list file """ def _get_menu(title): """ Return the first symbol menu matching the given title. """ menus = self.config.get_menus() menu = [m for m in menus if m.get_title().lower() == title.lower()] if not menu: message = "No such menu: '{0}'".format(title) raise Exception(message) return menu[0] list_config = self.list_info[list_type] root_title = list_config.get('root_menu') if root_title: root_item = _get_menu(root_title) else: root_item = self.config filter_ = getattr(self, list_config.get('filter')) filter_func = lambda x: filter_(x) format_func = getattr(self, list_config.get('format')) if not enable_deprecated and list_type != "deprecated": filter_func = lambda x: filter_(x) and not self._is_deprecated(x) mark_depr = list_type != "deprecated" get_label = lambda x: self._get_symbol_label(x, mark_depr) item_label = "Features" if list_type == "deprecated" else "Packages" table = format_asciidoc_table(root_item, get_label, filter_func=filter_func, format_func=format_func, enable_choice=enable_choice, sorted=list_config.get('sorted'), item_label=item_label) content = self.list_in.format(table=table) if dry_run: print(content) return if not output: output_dir = self.output_dir if not output_dir: print("Warning: Undefined output directory.") print("\tUse source directory as output location.") output_dir = self.base_dir output = os.path.join(output_dir, list_config.get('filename') + ".txt") if not os.path.exists(os.path.dirname(output)): os.makedirs(os.path.dirname(output)) print("Writing the {0} list in:\n\t{1}".format(list_type, output)) with open(output, 'w') as fout: fout.write(content) if __name__ == '__main__': list_types = ['target-packages', 'host-packages', 'virtual-packages', 'deprecated'] parser = ArgumentParser() parser.add_argument("list_type", nargs="?", choices=list_types, help="""\ Generate the given list (generate all lists if unspecified)""") parser.add_argument("-n", "--dry-run", dest="dry_run", action='store_true', help="Output the generated list to stdout") parser.add_argument("--output-target", dest="output_target", help="Output target package file") parser.add_argument("--output-host", dest="output_host", help="Output host package file") parser.add_argument("--output-virtual", dest="output_virtual", help="Output virtual package file") parser.add_argument("--output-deprecated", dest="output_deprecated", help="Output deprecated file") args = parser.parse_args() lists = [args.list_type] if args.list_type else list_types buildroot = Buildroot() for list_name in lists: output = getattr(args, "output_" + list_name.split("-", 1)[0]) buildroot.print_list(list_name, dry_run=args.dry_run, output=output)
gpl-2.0
[ 309, 3805, 13, 9285, 13, 6717, 14, 647, 199, 309, 199, 309, 961, 2884, 12821, 314, 2569, 6516, 1231, 8722, 1145, 287, 12503, 26, 199, 309, 221, 446, 314, 2559, 6716, 334, 368, 367, 314, 1347, 12, 314, 1163, 367, 1591, 7249, 2736, 199, 309, 221, 446, 314, 5906, 2974, 14, 199, 309, 199, 309, 6529, 8, 83, 304, 199, 309, 221, 446, 428, 455, 13086, 603, 26788, 665, 83, 14, 77, 26788, 1887, 32, 6799, 14, 957, 30, 199, 309, 199, 309, 1898, 334, 35, 9, 6171, 428, 455, 13086, 603, 26788, 199, 309, 199, 309, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 309, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 309, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 309, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 309, 199, 309, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 309, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 309, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 309, 199, 309, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 309, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 309, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 309, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 2197, 199, 504, 7534, 492, 27615, 199, 199, 893, 26, 272, 492, 1022, 888, 773, 199, 2590, 3545, 26, 272, 1245, 275, 408, 199, 6531, 440, 2342, 314, 859, 283, 24069, 773, 7, 315, 314, 31176, 26, 199, 624, 272, 1245, 847, 1867, 78, 1674, 904, 5234, 221, 469, 16, 5469, 908, 8, 515, 9, 367, 931, 315, 984, 14, 515, 566, 272, 1245, 847, 408, 199, 199, 5483, 3238, 314, 28637, 773, 2082, 365, 315, 314, 31176, 12, 2066, 295, 9850, 314, 199, 1579, 14, 199, 199, 5556, 883, 664, 1022, 888, 773, 687, 26, 523, 4178, 921, 5031, 14, 957, 15, 85, 276, 279, 1793, 15, 28033, 773, 421, 199, 624, 272, 984, 14, 3083, 14, 952, 8, 1188, 9, 272, 746, 421, 199, 318, 664, 63, 5155, 63, 9401, 8, 1231, 12, 2457, 63, 1532, 304, 272, 408, 1432, 282, 4306, 402, 1022, 888, 2974, 14, 339, 520, 635, 1738, 63, 1053, 26, 257, 12826, 1242, 402, 314, 4046, 10026, 402, 2974, 272, 520, 635, 2457, 63, 1532, 26, 9388, 805, 339, 408, 272, 340, 2688, 8, 1231, 12, 298, 362, 63, 1744, 2349, 267, 664, 63, 1744, 275, 1738, 14, 362, 63, 1744, 272, 916, 2688, 8, 1231, 12, 298, 362, 63, 2119, 63, 1896, 63, 1744, 2349, 267, 664, 63, 1744, 275, 1738, 14, 362, 63, 2119, 63, 1896, 63, 1744, 272, 587, 26, 267, 1245, 275, 298, 1918, 5272, 1630, 440, 1395, 1263, 10026, 402, 6698, 2, 267, 746, 2186, 8, 1188, 9, 272, 367, 1242, 315, 664, 63, 1744, 837, 267, 340, 1242, 14, 374, 63, 5155, 837, 288, 340, 440, 2457, 63, 1532, 8, 1053, 304, 355, 1980, 288, 1995, 1242, 267, 916, 1242, 14, 374, 63, 4470, 342, 503, 1242, 14, 374, 63, 5095, 837, 288, 367, 284, 315, 664, 63, 5155, 63, 9401, 8, 1053, 12, 2457, 63, 1532, 304, 355, 1995, 284, 421, 199, 318, 664, 63, 5155, 63, 8859, 8, 1053, 12, 1738, 29, 403, 12, 4756, 63, 5095, 29, 797, 304, 272, 408, 1432, 314, 769, 402, 314, 1242, 1159, 8623, 14, 710, 2061, 1242, 402, 314, 769, 365, 272, 314, 18284, 1676, 12, 314, 1642, 314, 289, 300, 273, 597, 14, 339, 520, 635, 1242, 26, 3515, 7020, 687, 1314, 314, 1676, 769, 365, 4046, 272, 520, 635, 1738, 26, 3515, 12826, 1242, 23599, 314, 2754, 334, 1397, 5120, 315, 314, 2079, 1676, 769, 9, 272, 520, 635, 4756, 63, 5095, 26, 18241, 29310, 3415, 370, 7468, 315, 314, 1676, 769, 339, 408, 272, 1676, 275, 1242, 14, 362, 63, 1708, 342, 272, 8623, 275, 942, 272, 1830, 1676, 436, 1676, 1137, 1738, 26, 267, 340, 1676, 14, 374, 63, 4470, 837, 288, 8623, 14, 740, 8, 1708, 14, 362, 63, 1213, 1012, 267, 916, 4756, 63, 5095, 436, 1676, 14, 374, 63, 5095, 837, 288, 8623, 14, 740, 8, 1708, 14, 362, 63, 496, 311, 1086, 3430, 16, 566, 267, 1676, 275, 1676, 14, 362, 63, 1708, 342, 272, 340, 1228, 8, 1231, 12, 1022, 888, 773, 14, 5977, 9, 503, 971, 288, 334, 4296, 63, 5095, 436, 1228, 8, 1231, 12, 1022, 888, 773, 14, 9054, 2298, 267, 8623, 14, 740, 10804, 327, 9762, 2701, 1676, 370, 664, 282, 9186, 18800, 1035, 272, 8623, 14, 4471, 342, 272, 372, 8623, 421, 199, 318, 1475, 63, 305, 559, 344, 679, 63, 1224, 8, 1231, 12, 664, 63, 1302, 63, 1532, 12, 2457, 63, 1532, 29, 2734, 671, 26, 715, 12, 2079, 1475, 63, 1532, 29, 2734, 671, 26, 671, 12, 2079, 4756, 63, 5095, 29, 797, 12, 3355, 29, 549, 12, 2079, 1242, 63, 1302, 29, 403, 304, 272, 408, 1432, 314, 465, 559, 344, 679, 7871, 1817, 402, 314, 2974, 436, 3932, 2909, 14, 339, 520, 635, 1738, 26, 3698, 12826, 1242, 402, 314, 1242, 10026, 272, 520, 635, 664, 63, 1302, 63, 1532, 26, 7020, 1159, 1768, 15917, 805, 272, 520, 635, 2457, 63, 1532, 26, 259, 9388, 805, 370, 4838, 641, 314, 1242, 10026, 272, 520, 635, 1475, 63, 1532, 26, 259, 6801, 370, 1475, 282, 5272, 436, 314, 1817, 1406, 272, 520, 635, 4756, 63, 5095, 26, 221, 12030, 3415, 370, 7468, 465, 1777, 402, 314, 1242, 1159, 2574, 2909, 272, 520, 635, 3355, 26, 260, 18241, 370, 23331, 17269, 4069, 314, 1817, 339, 408, 339, 2385, 275, 942, 272, 367, 1242, 315, 664, 63, 5155, 63, 9401, 8, 1231, 12, 2457, 63, 1532, 304, 267 ]
[ 3805, 13, 9285, 13, 6717, 14, 647, 199, 309, 199, 309, 961, 2884, 12821, 314, 2569, 6516, 1231, 8722, 1145, 287, 12503, 26, 199, 309, 221, 446, 314, 2559, 6716, 334, 368, 367, 314, 1347, 12, 314, 1163, 367, 1591, 7249, 2736, 199, 309, 221, 446, 314, 5906, 2974, 14, 199, 309, 199, 309, 6529, 8, 83, 304, 199, 309, 221, 446, 428, 455, 13086, 603, 26788, 665, 83, 14, 77, 26788, 1887, 32, 6799, 14, 957, 30, 199, 309, 199, 309, 1898, 334, 35, 9, 6171, 428, 455, 13086, 603, 26788, 199, 309, 199, 309, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 309, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 309, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 309, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 309, 199, 309, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 309, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 309, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 309, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 309, 199, 309, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 309, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 309, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 309, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 199, 199, 646, 747, 199, 646, 295, 199, 646, 984, 199, 646, 2197, 199, 504, 7534, 492, 27615, 199, 199, 893, 26, 272, 492, 1022, 888, 773, 199, 2590, 3545, 26, 272, 1245, 275, 408, 199, 6531, 440, 2342, 314, 859, 283, 24069, 773, 7, 315, 314, 31176, 26, 199, 624, 272, 1245, 847, 1867, 78, 1674, 904, 5234, 221, 469, 16, 5469, 908, 8, 515, 9, 367, 931, 315, 984, 14, 515, 566, 272, 1245, 847, 408, 199, 199, 5483, 3238, 314, 28637, 773, 2082, 365, 315, 314, 31176, 12, 2066, 295, 9850, 314, 199, 1579, 14, 199, 199, 5556, 883, 664, 1022, 888, 773, 687, 26, 523, 4178, 921, 5031, 14, 957, 15, 85, 276, 279, 1793, 15, 28033, 773, 421, 199, 624, 272, 984, 14, 3083, 14, 952, 8, 1188, 9, 272, 746, 421, 199, 318, 664, 63, 5155, 63, 9401, 8, 1231, 12, 2457, 63, 1532, 304, 272, 408, 1432, 282, 4306, 402, 1022, 888, 2974, 14, 339, 520, 635, 1738, 63, 1053, 26, 257, 12826, 1242, 402, 314, 4046, 10026, 402, 2974, 272, 520, 635, 2457, 63, 1532, 26, 9388, 805, 339, 408, 272, 340, 2688, 8, 1231, 12, 298, 362, 63, 1744, 2349, 267, 664, 63, 1744, 275, 1738, 14, 362, 63, 1744, 272, 916, 2688, 8, 1231, 12, 298, 362, 63, 2119, 63, 1896, 63, 1744, 2349, 267, 664, 63, 1744, 275, 1738, 14, 362, 63, 2119, 63, 1896, 63, 1744, 272, 587, 26, 267, 1245, 275, 298, 1918, 5272, 1630, 440, 1395, 1263, 10026, 402, 6698, 2, 267, 746, 2186, 8, 1188, 9, 272, 367, 1242, 315, 664, 63, 1744, 837, 267, 340, 1242, 14, 374, 63, 5155, 837, 288, 340, 440, 2457, 63, 1532, 8, 1053, 304, 355, 1980, 288, 1995, 1242, 267, 916, 1242, 14, 374, 63, 4470, 342, 503, 1242, 14, 374, 63, 5095, 837, 288, 367, 284, 315, 664, 63, 5155, 63, 9401, 8, 1053, 12, 2457, 63, 1532, 304, 355, 1995, 284, 421, 199, 318, 664, 63, 5155, 63, 8859, 8, 1053, 12, 1738, 29, 403, 12, 4756, 63, 5095, 29, 797, 304, 272, 408, 1432, 314, 769, 402, 314, 1242, 1159, 8623, 14, 710, 2061, 1242, 402, 314, 769, 365, 272, 314, 18284, 1676, 12, 314, 1642, 314, 289, 300, 273, 597, 14, 339, 520, 635, 1242, 26, 3515, 7020, 687, 1314, 314, 1676, 769, 365, 4046, 272, 520, 635, 1738, 26, 3515, 12826, 1242, 23599, 314, 2754, 334, 1397, 5120, 315, 314, 2079, 1676, 769, 9, 272, 520, 635, 4756, 63, 5095, 26, 18241, 29310, 3415, 370, 7468, 315, 314, 1676, 769, 339, 408, 272, 1676, 275, 1242, 14, 362, 63, 1708, 342, 272, 8623, 275, 942, 272, 1830, 1676, 436, 1676, 1137, 1738, 26, 267, 340, 1676, 14, 374, 63, 4470, 837, 288, 8623, 14, 740, 8, 1708, 14, 362, 63, 1213, 1012, 267, 916, 4756, 63, 5095, 436, 1676, 14, 374, 63, 5095, 837, 288, 8623, 14, 740, 8, 1708, 14, 362, 63, 496, 311, 1086, 3430, 16, 566, 267, 1676, 275, 1676, 14, 362, 63, 1708, 342, 272, 340, 1228, 8, 1231, 12, 1022, 888, 773, 14, 5977, 9, 503, 971, 288, 334, 4296, 63, 5095, 436, 1228, 8, 1231, 12, 1022, 888, 773, 14, 9054, 2298, 267, 8623, 14, 740, 10804, 327, 9762, 2701, 1676, 370, 664, 282, 9186, 18800, 1035, 272, 8623, 14, 4471, 342, 272, 372, 8623, 421, 199, 318, 1475, 63, 305, 559, 344, 679, 63, 1224, 8, 1231, 12, 664, 63, 1302, 63, 1532, 12, 2457, 63, 1532, 29, 2734, 671, 26, 715, 12, 2079, 1475, 63, 1532, 29, 2734, 671, 26, 671, 12, 2079, 4756, 63, 5095, 29, 797, 12, 3355, 29, 549, 12, 2079, 1242, 63, 1302, 29, 403, 304, 272, 408, 1432, 314, 465, 559, 344, 679, 7871, 1817, 402, 314, 2974, 436, 3932, 2909, 14, 339, 520, 635, 1738, 26, 3698, 12826, 1242, 402, 314, 1242, 10026, 272, 520, 635, 664, 63, 1302, 63, 1532, 26, 7020, 1159, 1768, 15917, 805, 272, 520, 635, 2457, 63, 1532, 26, 259, 9388, 805, 370, 4838, 641, 314, 1242, 10026, 272, 520, 635, 1475, 63, 1532, 26, 259, 6801, 370, 1475, 282, 5272, 436, 314, 1817, 1406, 272, 520, 635, 4756, 63, 5095, 26, 221, 12030, 3415, 370, 7468, 465, 1777, 402, 314, 1242, 1159, 2574, 2909, 272, 520, 635, 3355, 26, 260, 18241, 370, 23331, 17269, 4069, 314, 1817, 339, 408, 339, 2385, 275, 942, 272, 367, 1242, 315, 664, 63, 5155, 63, 9401, 8, 1231, 12, 2457, 63, 1532, 304, 267, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
disqus/django-old
tests/regressiontests/admin_validation/tests.py
1
9982
from django import forms from django.core.exceptions import ImproperlyConfigured from django.test import TestCase from django.contrib import admin from django.contrib.admin.validation import validate, validate_inline from models import Song, Book, Album, TwoAlbumFKAndAnE, State, City class SongForm(forms.ModelForm): pass class ValidFields(admin.ModelAdmin): form = SongForm fields = ['title'] class InvalidFields(admin.ModelAdmin): form = SongForm fields = ['spam'] class ValidationTestCase(TestCase): def test_readonly_and_editable(self): class SongAdmin(admin.ModelAdmin): readonly_fields = ["original_release"] fieldsets = [ (None, { "fields": ["title", "original_release"], }), ] validate(SongAdmin, Song) def test_custom_modelforms_with_fields_fieldsets(self): """ # Regression test for #8027: custom ModelForms with fields/fieldsets """ validate(ValidFields, Song) self.assertRaisesMessage(ImproperlyConfigured, "'InvalidFields.fields' refers to field 'spam' that is missing from the form.", validate, InvalidFields, Song) def test_exclude_values(self): """ Tests for basic validation of 'exclude' option values (#12689) """ class ExcludedFields1(admin.ModelAdmin): exclude = ('foo') self.assertRaisesMessage(ImproperlyConfigured, "'ExcludedFields1.exclude' must be a list or tuple.", validate, ExcludedFields1, Book) def test_exclude_duplicate_values(self): class ExcludedFields2(admin.ModelAdmin): exclude = ('name', 'name') self.assertRaisesMessage(ImproperlyConfigured, "There are duplicate field(s) in ExcludedFields2.exclude", validate, ExcludedFields2, Book) def test_exclude_in_inline(self): class ExcludedFieldsInline(admin.TabularInline): model = Song exclude = ('foo') class ExcludedFieldsAlbumAdmin(admin.ModelAdmin): model = Album inlines = [ExcludedFieldsInline] self.assertRaisesMessage(ImproperlyConfigured, "'ExcludedFieldsInline.exclude' must be a list or tuple.", validate, ExcludedFieldsAlbumAdmin, Album) def test_exclude_inline_model_admin(self): """ # Regression test for #9932 - exclude in InlineModelAdmin # should not contain the ForeignKey field used in ModelAdmin.model """ class SongInline(admin.StackedInline): model = Song exclude = ['album'] class AlbumAdmin(admin.ModelAdmin): model = Album inlines = [SongInline] self.assertRaisesMessage(ImproperlyConfigured, "SongInline cannot exclude the field 'album' - this is the foreign key to the parent model admin_validation.Album.", validate, AlbumAdmin, Album) def test_app_label_in_admin_validation(self): """ Regression test for #15669 - Include app label in admin validation messages """ class RawIdNonexistingAdmin(admin.ModelAdmin): raw_id_fields = ('nonexisting',) self.assertRaisesMessage(ImproperlyConfigured, "'RawIdNonexistingAdmin.raw_id_fields' refers to field 'nonexisting' that is missing from model 'admin_validation.Album'.", validate, RawIdNonexistingAdmin, Album) def test_fk_exclusion(self): """ Regression test for #11709 - when testing for fk excluding (when exclude is given) make sure fk_name is honored or things blow up when there is more than one fk to the parent model. """ class TwoAlbumFKAndAnEInline(admin.TabularInline): model = TwoAlbumFKAndAnE exclude = ("e",) fk_name = "album1" validate_inline(TwoAlbumFKAndAnEInline, None, Album) def test_inline_self_validation(self): class TwoAlbumFKAndAnEInline(admin.TabularInline): model = TwoAlbumFKAndAnE self.assertRaisesMessage(Exception, "<class 'regressiontests.admin_validation.models.TwoAlbumFKAndAnE'> has more than 1 ForeignKey to <class 'regressiontests.admin_validation.models.Album'>", validate_inline, TwoAlbumFKAndAnEInline, None, Album) def test_inline_with_specified(self): class TwoAlbumFKAndAnEInline(admin.TabularInline): model = TwoAlbumFKAndAnE fk_name = "album1" validate_inline(TwoAlbumFKAndAnEInline, None, Album) def test_readonly(self): class SongAdmin(admin.ModelAdmin): readonly_fields = ("title",) validate(SongAdmin, Song) def test_readonly_on_method(self): def my_function(obj): pass class SongAdmin(admin.ModelAdmin): readonly_fields = (my_function,) validate(SongAdmin, Song) def test_readonly_on_modeladmin(self): class SongAdmin(admin.ModelAdmin): readonly_fields = ("readonly_method_on_modeladmin",) def readonly_method_on_modeladmin(self, obj): pass validate(SongAdmin, Song) def test_readonly_method_on_model(self): class SongAdmin(admin.ModelAdmin): readonly_fields = ("readonly_method_on_model",) validate(SongAdmin, Song) def test_nonexistant_field(self): class SongAdmin(admin.ModelAdmin): readonly_fields = ("title", "nonexistant") self.assertRaisesMessage(ImproperlyConfigured, "SongAdmin.readonly_fields[1], 'nonexistant' is not a callable or an attribute of 'SongAdmin' or found in the model 'Song'.", validate, SongAdmin, Song) def test_nonexistant_field_on_inline(self): class CityInline(admin.TabularInline): model = City readonly_fields=['i_dont_exist'] # Missing attribute self.assertRaisesMessage(ImproperlyConfigured, "CityInline.readonly_fields[0], 'i_dont_exist' is not a callable or an attribute of 'CityInline' or found in the model 'City'.", validate_inline, CityInline, None, State) def test_extra(self): class SongAdmin(admin.ModelAdmin): def awesome_song(self, instance): if instance.title == "Born to Run": return "Best Ever!" return "Status unknown." validate(SongAdmin, Song) def test_readonly_lambda(self): class SongAdmin(admin.ModelAdmin): readonly_fields = (lambda obj: "test",) validate(SongAdmin, Song) def test_graceful_m2m_fail(self): """ Regression test for #12203/#12237 - Fail more gracefully when a M2M field that specifies the 'through' option is included in the 'fields' or the 'fieldsets' ModelAdmin options. """ class BookAdmin(admin.ModelAdmin): fields = ['authors'] self.assertRaisesMessage(ImproperlyConfigured, "'BookAdmin.fields' can't include the ManyToManyField field 'authors' because 'authors' manually specifies a 'through' model.", validate, BookAdmin, Book) def test_cannot_include_through(self): class FieldsetBookAdmin(admin.ModelAdmin): fieldsets = ( ('Header 1', {'fields': ('name',)}), ('Header 2', {'fields': ('authors',)}), ) self.assertRaisesMessage(ImproperlyConfigured, "'FieldsetBookAdmin.fieldsets[1][1]['fields']' can't include the ManyToManyField field 'authors' because 'authors' manually specifies a 'through' model.", validate, FieldsetBookAdmin, Book) def test_nested_fields(self): class NestedFieldsAdmin(admin.ModelAdmin): fields = ('price', ('name', 'subtitle')) validate(NestedFieldsAdmin, Book) def test_nested_fieldsets(self): class NestedFieldsetAdmin(admin.ModelAdmin): fieldsets = ( ('Main', {'fields': ('price', ('name', 'subtitle'))}), ) validate(NestedFieldsetAdmin, Book) def test_explicit_through_override(self): """ Regression test for #12209 -- If the explicitly provided through model is specified as a string, the admin should still be able use Model.m2m_field.through """ class AuthorsInline(admin.TabularInline): model = Book.authors.through class BookAdmin(admin.ModelAdmin): inlines = [AuthorsInline] # If the through model is still a string (and hasn't been resolved to a model) # the validation will fail. validate(BookAdmin, Book) def test_non_model_fields(self): """ Regression for ensuring ModelAdmin.fields can contain non-model fields that broke with r11737 """ class SongForm(forms.ModelForm): extra_data = forms.CharField() class Meta: model = Song class FieldsOnFormOnlyAdmin(admin.ModelAdmin): form = SongForm fields = ['title', 'extra_data'] validate(FieldsOnFormOnlyAdmin, Song) def test_non_model_first_field(self): """ Regression for ensuring ModelAdmin.field can handle first elem being a non-model field (test fix for UnboundLocalError introduced with r16225). """ class SongForm(forms.ModelForm): extra_data = forms.CharField() class Meta: model = Song class FieldsOnFormOnlyAdmin(admin.ModelAdmin): form = SongForm fields = ['extra_data', 'title'] validate(FieldsOnFormOnlyAdmin, Song)
bsd-3-clause
[ 504, 1639, 492, 4513, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1639, 14, 2828, 492, 4628, 199, 504, 1639, 14, 2828, 14, 2113, 14, 6136, 492, 4107, 12, 4107, 63, 6460, 199, 199, 504, 1709, 492, 29405, 12, 8944, 12, 4580, 7767, 12, 16853, 26369, 21490, 3325, 2493, 37, 12, 8511, 12, 14753, 199, 199, 533, 29405, 2821, 8, 3351, 14, 15937, 304, 272, 986, 199, 199, 533, 4821, 7304, 8, 2113, 14, 12976, 304, 272, 1824, 275, 29405, 2821, 272, 1504, 275, 788, 1213, 418, 199, 199, 533, 6378, 7304, 8, 2113, 14, 12976, 304, 272, 1824, 275, 29405, 2821, 272, 1504, 275, 788, 8283, 418, 199, 199, 533, 19381, 1746, 8, 1746, 304, 339, 347, 511, 63, 6753, 63, 460, 63, 10820, 8, 277, 304, 267, 1021, 29405, 4880, 8, 2113, 14, 12976, 304, 288, 6863, 63, 955, 275, 2097, 5043, 63, 3221, 937, 288, 901, 2193, 275, 359, 355, 334, 403, 12, 469, 490, 298, 955, 582, 2097, 1213, 401, 298, 5043, 63, 3221, 2255, 355, 9998, 288, 1622, 267, 4107, 8, 51, 951, 4880, 12, 29405, 9, 339, 347, 511, 63, 4229, 63, 632, 276, 269, 706, 63, 1045, 63, 955, 63, 23501, 8, 277, 304, 267, 408, 267, 327, 13262, 511, 367, 327, 11366, 23, 26, 3537, 5822, 26028, 543, 1504, 15, 23501, 267, 408, 267, 4107, 8, 3490, 7304, 12, 29405, 9, 267, 291, 14, 14638, 8, 8499, 10951, 12, 288, 3546, 3364, 7304, 14, 955, 7, 15724, 370, 901, 283, 8283, 7, 626, 365, 4124, 687, 314, 1824, 4765, 288, 4107, 12, 288, 6378, 7304, 12, 29405, 9, 339, 347, 511, 63, 5473, 63, 1459, 8, 277, 304, 267, 408, 267, 6496, 367, 5678, 6411, 402, 283, 5473, 7, 945, 1338, 15196, 7957, 1407, 9, 267, 408, 267, 1021, 1316, 3331, 7304, 17, 8, 2113, 14, 12976, 304, 288, 5760, 275, 661, 1421, 358, 267, 291, 14, 14638, 8, 8499, 10951, 12, 288, 3546, 920, 3331, 7304, 17, 14, 5473, 7, 1471, 506, 282, 769, 503, 2008, 4765, 288, 4107, 12, 288, 1316, 3331, 7304, 17, 12, 8944, 9, 339, 347, 511, 63, 5473, 63, 11081, 63, 1459, 8, 277, 304, 267, 1021, 1316, 3331, 7304, 18, 8, 2113, 14, 12976, 304, 288, 5760, 275, 661, 354, 297, 283, 354, 358, 267, 291, 14, 14638, 8, 8499, 10951, 12, 288, 298, 10924, 787, 9250, 901, 8, 83, 9, 315, 1316, 3331, 7304, 18, 14, 5473, 401, 288, 4107, 12, 288, 1316, 3331, 7304, 18, 12, 8944, 9, 339, 347, 511, 63, 5473, 63, 262, 63, 6460, 8, 277, 304, 267, 1021, 1316, 3331, 7304, 10307, 8, 2113, 14, 30187, 10307, 304, 288, 1402, 275, 29405, 288, 5760, 275, 661, 1421, 358, 398, 1021, 1316, 3331, 7304, 26369, 4880, 8, 2113, 14, 12976, 304, 288, 1402, 275, 4580, 7767, 288, 29177, 275, 359, 920, 3331, 7304, 10307, 61, 398, 291, 14, 14638, 8, 8499, 10951, 12, 288, 3546, 920, 3331, 7304, 10307, 14, 5473, 7, 1471, 506, 282, 769, 503, 2008, 4765, 288, 4107, 12, 288, 1316, 3331, 7304, 26369, 4880, 12, 4580, 7767, 9, 339, 347, 511, 63, 5473, 63, 6460, 63, 1238, 63, 2113, 8, 277, 304, 267, 408, 267, 327, 13262, 511, 367, 327, 1020, 708, 446, 5760, 315, 24789, 12976, 267, 327, 1077, 440, 1395, 314, 12718, 901, 1202, 315, 30093, 14, 1238, 267, 408, 267, 1021, 29405, 10307, 8, 2113, 14, 4851, 379, 10307, 304, 288, 1402, 275, 29405, 288, 5760, 275, 788, 12110, 418, 398, 1021, 4580, 7767, 4880, 8, 2113, 14, 12976, 304, 288, 1402, 275, 4580, 7767, 288, 29177, 275, 359, 51, 951, 10307, 61, 398, 291, 14, 14638, 8, 8499, 10951, 12, 288, 298, 51, 951, 10307, 3913, 5760, 314, 901, 283, 12110, 7, 446, 642, 365, 314, 11608, 790, 370, 314, 1676, 1402, 4628, 63, 6136, 14, 26369, 4765, 288, 4107, 12, 288, 4580, 7767, 4880, 12, 4580, 7767, 9, 339, 347, 511, 63, 571, 63, 1302, 63, 262, 63, 2113, 63, 6136, 8, 277, 304, 267, 408, 267, 13262, 511, 367, 327, 1046, 15014, 446, 15783, 1145, 1768, 315, 4628, 6411, 3788, 267, 408, 267, 1021, 13480, 1304, 403, 88, 26958, 4880, 8, 2113, 14, 12976, 304, 288, 3066, 63, 344, 63, 955, 275, 661, 3592, 88, 26958, 9538, 398, 291, 14, 14638, 8, 8499, 10951, 12, 288, 3546, 7963, 1304, 403, 88, 26958, 4880, 14, 1773, 63, 344, 63, 955, 7, 15724, 370, 901, 283, 3592, 88, 26958, 7, 626, 365, 4124, 687, 1402, 283, 2113, 63, 6136, 14, 26369, 30532, 288, 4107, 12, 288, 13480, 1304, 403, 88, 26958, 4880, 12, 4580, 7767, 9, 339, 347, 511, 63, 9010, 63, 476, 10248, 8, 277, 304, 267, 408, 267, 13262, 511, 367, 327, 7362, 1643, 446, 1380, 5343, 367, 14830, 28529, 334, 6526, 5760, 365, 267, 1627, 9, 1852, 3238, 14830, 63, 354, 365, 394, 265, 2908, 503, 7645, 28511, 1536, 1380, 2337, 365, 1655, 267, 2419, 1373, 14830, 370, 314, 1676, 1402, 14, 267, 408, 267, 1021, 16853, 26369, 21490, 3325, 2493, 37, 10307, 8, 2113, 14, 30187, 10307, 304, 288, 1402, 275, 16853, 26369, 21490, 3325, 2493, 37, 288, 5760, 275, 1689, 69, 26360, 288, 14830, 63, 354, 275, 298, 12110, 17, 2, 267, 4107, 63, 6460, 8, 11467, 26369, 21490, 3325, 2493, 37, 10307, 12, 488, 12, 4580, 7767, 9, 339, 347, 511, 63, 6460, 63, 277, 63, 6136, 8, 277, 304, 267, 1021, 16853, 26369, 21490, 3325, 2493, 37, 10307, 8, 2113, 14, 30187, 10307, 304, 288, 1402, 275, 16853, 26369, 21490, 3325, 2493, 37, 398, 291, 14, 14638, 8, 1726, 12, 288, 3886, 533, 283, 12513, 2219, 14, 2113, 63, 6136, 14, 992, 14, 11467, 26369, 21490, 3325, 2493, 37, 8423, 965, 1655, 2419, 413, 12718, 370, 665, 533, 283, 12513, 2219, 14, 2113, 63, 6136, 14, 992, 14, 26369, 7, 7166, 288, 4107, 63, 6460, 12, 288, 16853, 26369, 21490, 3325, 2493, 37, 10307, 12, 488, 12, 4580, 7767, 9, 339, 347, 511, 63, 6460, 63, 1045, 63, 10085, 8, 277, 304, 267, 1021, 16853, 26369, 21490, 3325, 2493, 37, 10307, 8, 2113, 14, 30187, 10307, 304, 288 ]
[ 1639, 492, 4513, 199, 504, 1639, 14, 1018, 14, 3924, 492, 11897, 199, 504, 1639, 14, 396, 492, 7640, 199, 199, 504, 1639, 14, 2828, 492, 4628, 199, 504, 1639, 14, 2828, 14, 2113, 14, 6136, 492, 4107, 12, 4107, 63, 6460, 199, 199, 504, 1709, 492, 29405, 12, 8944, 12, 4580, 7767, 12, 16853, 26369, 21490, 3325, 2493, 37, 12, 8511, 12, 14753, 199, 199, 533, 29405, 2821, 8, 3351, 14, 15937, 304, 272, 986, 199, 199, 533, 4821, 7304, 8, 2113, 14, 12976, 304, 272, 1824, 275, 29405, 2821, 272, 1504, 275, 788, 1213, 418, 199, 199, 533, 6378, 7304, 8, 2113, 14, 12976, 304, 272, 1824, 275, 29405, 2821, 272, 1504, 275, 788, 8283, 418, 199, 199, 533, 19381, 1746, 8, 1746, 304, 339, 347, 511, 63, 6753, 63, 460, 63, 10820, 8, 277, 304, 267, 1021, 29405, 4880, 8, 2113, 14, 12976, 304, 288, 6863, 63, 955, 275, 2097, 5043, 63, 3221, 937, 288, 901, 2193, 275, 359, 355, 334, 403, 12, 469, 490, 298, 955, 582, 2097, 1213, 401, 298, 5043, 63, 3221, 2255, 355, 9998, 288, 1622, 267, 4107, 8, 51, 951, 4880, 12, 29405, 9, 339, 347, 511, 63, 4229, 63, 632, 276, 269, 706, 63, 1045, 63, 955, 63, 23501, 8, 277, 304, 267, 408, 267, 327, 13262, 511, 367, 327, 11366, 23, 26, 3537, 5822, 26028, 543, 1504, 15, 23501, 267, 408, 267, 4107, 8, 3490, 7304, 12, 29405, 9, 267, 291, 14, 14638, 8, 8499, 10951, 12, 288, 3546, 3364, 7304, 14, 955, 7, 15724, 370, 901, 283, 8283, 7, 626, 365, 4124, 687, 314, 1824, 4765, 288, 4107, 12, 288, 6378, 7304, 12, 29405, 9, 339, 347, 511, 63, 5473, 63, 1459, 8, 277, 304, 267, 408, 267, 6496, 367, 5678, 6411, 402, 283, 5473, 7, 945, 1338, 15196, 7957, 1407, 9, 267, 408, 267, 1021, 1316, 3331, 7304, 17, 8, 2113, 14, 12976, 304, 288, 5760, 275, 661, 1421, 358, 267, 291, 14, 14638, 8, 8499, 10951, 12, 288, 3546, 920, 3331, 7304, 17, 14, 5473, 7, 1471, 506, 282, 769, 503, 2008, 4765, 288, 4107, 12, 288, 1316, 3331, 7304, 17, 12, 8944, 9, 339, 347, 511, 63, 5473, 63, 11081, 63, 1459, 8, 277, 304, 267, 1021, 1316, 3331, 7304, 18, 8, 2113, 14, 12976, 304, 288, 5760, 275, 661, 354, 297, 283, 354, 358, 267, 291, 14, 14638, 8, 8499, 10951, 12, 288, 298, 10924, 787, 9250, 901, 8, 83, 9, 315, 1316, 3331, 7304, 18, 14, 5473, 401, 288, 4107, 12, 288, 1316, 3331, 7304, 18, 12, 8944, 9, 339, 347, 511, 63, 5473, 63, 262, 63, 6460, 8, 277, 304, 267, 1021, 1316, 3331, 7304, 10307, 8, 2113, 14, 30187, 10307, 304, 288, 1402, 275, 29405, 288, 5760, 275, 661, 1421, 358, 398, 1021, 1316, 3331, 7304, 26369, 4880, 8, 2113, 14, 12976, 304, 288, 1402, 275, 4580, 7767, 288, 29177, 275, 359, 920, 3331, 7304, 10307, 61, 398, 291, 14, 14638, 8, 8499, 10951, 12, 288, 3546, 920, 3331, 7304, 10307, 14, 5473, 7, 1471, 506, 282, 769, 503, 2008, 4765, 288, 4107, 12, 288, 1316, 3331, 7304, 26369, 4880, 12, 4580, 7767, 9, 339, 347, 511, 63, 5473, 63, 6460, 63, 1238, 63, 2113, 8, 277, 304, 267, 408, 267, 327, 13262, 511, 367, 327, 1020, 708, 446, 5760, 315, 24789, 12976, 267, 327, 1077, 440, 1395, 314, 12718, 901, 1202, 315, 30093, 14, 1238, 267, 408, 267, 1021, 29405, 10307, 8, 2113, 14, 4851, 379, 10307, 304, 288, 1402, 275, 29405, 288, 5760, 275, 788, 12110, 418, 398, 1021, 4580, 7767, 4880, 8, 2113, 14, 12976, 304, 288, 1402, 275, 4580, 7767, 288, 29177, 275, 359, 51, 951, 10307, 61, 398, 291, 14, 14638, 8, 8499, 10951, 12, 288, 298, 51, 951, 10307, 3913, 5760, 314, 901, 283, 12110, 7, 446, 642, 365, 314, 11608, 790, 370, 314, 1676, 1402, 4628, 63, 6136, 14, 26369, 4765, 288, 4107, 12, 288, 4580, 7767, 4880, 12, 4580, 7767, 9, 339, 347, 511, 63, 571, 63, 1302, 63, 262, 63, 2113, 63, 6136, 8, 277, 304, 267, 408, 267, 13262, 511, 367, 327, 1046, 15014, 446, 15783, 1145, 1768, 315, 4628, 6411, 3788, 267, 408, 267, 1021, 13480, 1304, 403, 88, 26958, 4880, 8, 2113, 14, 12976, 304, 288, 3066, 63, 344, 63, 955, 275, 661, 3592, 88, 26958, 9538, 398, 291, 14, 14638, 8, 8499, 10951, 12, 288, 3546, 7963, 1304, 403, 88, 26958, 4880, 14, 1773, 63, 344, 63, 955, 7, 15724, 370, 901, 283, 3592, 88, 26958, 7, 626, 365, 4124, 687, 1402, 283, 2113, 63, 6136, 14, 26369, 30532, 288, 4107, 12, 288, 13480, 1304, 403, 88, 26958, 4880, 12, 4580, 7767, 9, 339, 347, 511, 63, 9010, 63, 476, 10248, 8, 277, 304, 267, 408, 267, 13262, 511, 367, 327, 7362, 1643, 446, 1380, 5343, 367, 14830, 28529, 334, 6526, 5760, 365, 267, 1627, 9, 1852, 3238, 14830, 63, 354, 365, 394, 265, 2908, 503, 7645, 28511, 1536, 1380, 2337, 365, 1655, 267, 2419, 1373, 14830, 370, 314, 1676, 1402, 14, 267, 408, 267, 1021, 16853, 26369, 21490, 3325, 2493, 37, 10307, 8, 2113, 14, 30187, 10307, 304, 288, 1402, 275, 16853, 26369, 21490, 3325, 2493, 37, 288, 5760, 275, 1689, 69, 26360, 288, 14830, 63, 354, 275, 298, 12110, 17, 2, 267, 4107, 63, 6460, 8, 11467, 26369, 21490, 3325, 2493, 37, 10307, 12, 488, 12, 4580, 7767, 9, 339, 347, 511, 63, 6460, 63, 277, 63, 6136, 8, 277, 304, 267, 1021, 16853, 26369, 21490, 3325, 2493, 37, 10307, 8, 2113, 14, 30187, 10307, 304, 288, 1402, 275, 16853, 26369, 21490, 3325, 2493, 37, 398, 291, 14, 14638, 8, 1726, 12, 288, 3886, 533, 283, 12513, 2219, 14, 2113, 63, 6136, 14, 992, 14, 11467, 26369, 21490, 3325, 2493, 37, 8423, 965, 1655, 2419, 413, 12718, 370, 665, 533, 283, 12513, 2219, 14, 2113, 63, 6136, 14, 992, 14, 26369, 7, 7166, 288, 4107, 63, 6460, 12, 288, 16853, 26369, 21490, 3325, 2493, 37, 10307, 12, 488, 12, 4580, 7767, 9, 339, 347, 511, 63, 6460, 63, 1045, 63, 10085, 8, 277, 304, 267, 1021, 16853, 26369, 21490, 3325, 2493, 37, 10307, 8, 2113, 14, 30187, 10307, 304, 288, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
rsimba/scrapy-rethinkdb
tests/test_pipeline.py
2
5360
import unittest from mock import Mock, MagicMock, patch from itertools import combinations_with_replacement from scrapy_rethinkdb.pipeline import RethinkDBPipeline, NotConfigured, Item class RethinkDBPipelineTest(unittest.TestCase): def setUp(self): # default pipeline under test self.driver = Mock() self.table_name = Mock() self.insert_options = MagicMock() self.pipeline = RethinkDBPipeline( self.driver, self.table_name, self.insert_options ) # patch for driver self.driver_patcher = patch('scrapy_rethinkdb.pipeline.' 'RethinkDBDriver') # patcher for the pipeline constructor self.pipeline_cls_patcher = patch('scrapy_rethinkdb.pipeline.' 'RethinkDBPipeline.__init__') # returns iterator for all possible combinations for 3 arguments # which values can be either a Mock or None self.init_mocks_iter = lambda: \ combinations_with_replacement((None, Mock()), 3) # returns settings dictionary self.get_pipeline_settings = \ lambda conn_sett, table_name, insert_options: \ {'RETHINKDB_TABLE': table_name, 'RETHINKDB_CONNECTION': conn_sett, 'RETHINKDB_INSERT_OPTIONS': insert_options} def test_init_not_configured(self): # asserts constructor will raise NotConfigured id any of the arguments # is None comb_iter = self.init_mocks_iter() for driver, table_name, insert_options in comb_iter: if not driver or not table_name or not insert_options: self.assertRaises(NotConfigured, RethinkDBPipeline, driver, table_name, insert_options) def test_init_empty_table_name(self): # asserts constructor will raise NotConfigured if table_name is empty self.assertRaises(NotConfigured, RethinkDBPipeline, Mock(), '', Mock()) def test_init_configured(self): # asserts that the default pipeline under test tried to get the table self.assertEqual(self.pipeline.table, self.driver.get_table.return_value) self.driver.get_table.assert_called_once_with(self.table_name) def test_from_crawler_configured(self): # asserts that from_crawler will return a pipeline instance if the # constructor returns None, as expected crawler = Mock() comb_iter = self.init_mocks_iter() for conn_sett, table_name, insert_options in comb_iter: crawler.settings = self.get_pipeline_settings( conn_sett, table_name, insert_options ) with self.pipeline_cls_patcher as pipeline_cls, \ self.driver_patcher as driver_klass: pipeline_cls.return_value = None pipeline = RethinkDBPipeline.from_crawler(crawler) self.assertIsInstance(pipeline, RethinkDBPipeline) driver_klass.assert_called_once_with(conn_sett) pipeline_cls.assert_called_once_with( driver_klass.return_value, table_name, insert_options ) def test_from_crawler_not_configured(self): # asserts that from_crawler will raise NotConfigured the # constructor raises NotConfigured exception crawler = Mock() for conn_sett, table_name, insert_options in self.init_mocks_iter(): crawler.settings = self.get_pipeline_settings( conn_sett, table_name, insert_options ) with self.pipeline_cls_patcher as pipeline_cls, \ self.driver_patcher as driver_klass: pipeline_cls.side_effect = NotConfigured self.assertRaises(NotConfigured, RethinkDBPipeline.from_crawler, crawler) driver_klass.assert_called_once_with(conn_sett) pipeline_cls.assert_called_once_with( driver_klass.return_value, table_name, insert_options ) def test_process_item_not_an_item(self): # asserts that a non-item is just returned spider = Mock() # mocking before_insert to check that it won't be called in this test self.pipeline.before_insert = Mock() self.pipeline.process_item(Mock(), spider) self.assertTrue(spider.log.msg.called) self.assertFalse(self.pipeline.before_insert.called) def test_process_item_success(self): # asserts that a item is processed item = Mock(spec=Item) item._values = {} # mocking extension points self.pipeline.before_insert = Mock() self.pipeline.after_insert = Mock() self.pipeline.process_item(item, Mock()) self.pipeline.before_insert.assert_called_once_with( item ) self.pipeline.table.insert.assert_called_once_with( item._values ) self.pipeline.driver.execute.assert_called_once_with( self.pipeline.table.insert.return_value ) self.pipeline.after_insert.assert_called_once_with( item, self.pipeline.driver.execute.return_value )
apache-2.0
[ 646, 2882, 199, 504, 1683, 492, 4420, 12, 10079, 12, 3371, 199, 504, 7975, 492, 15821, 63, 1045, 63, 15895, 199, 199, 504, 18918, 63, 264, 29727, 697, 14, 7379, 492, 799, 29727, 2846, 17562, 12, 2832, 9902, 12, 7020, 421, 199, 533, 799, 29727, 2846, 17562, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 398, 327, 849, 7679, 1334, 511, 267, 291, 14, 3090, 275, 4420, 342, 267, 291, 14, 1224, 63, 354, 275, 4420, 342, 267, 291, 14, 3176, 63, 1419, 275, 10079, 342, 267, 291, 14, 7379, 275, 799, 29727, 2846, 17562, 8, 288, 291, 14, 3090, 12, 291, 14, 1224, 63, 354, 12, 291, 14, 3176, 63, 1419, 267, 776, 398, 327, 3371, 367, 5253, 267, 291, 14, 3090, 63, 11238, 275, 3371, 360, 26442, 63, 264, 29727, 697, 14, 7379, 3530, 2511, 283, 497, 29727, 2846, 6158, 358, 267, 327, 21198, 367, 314, 7679, 3787, 267, 291, 14, 7379, 63, 1886, 63, 11238, 275, 3371, 360, 26442, 63, 264, 29727, 697, 14, 7379, 3530, 5101, 283, 497, 29727, 2846, 17562, 855, 826, 13766, 398, 327, 2529, 6122, 367, 1006, 3962, 15821, 367, 650, 2368, 267, 327, 1314, 1338, 883, 506, 1902, 282, 4420, 503, 488, 267, 291, 14, 826, 63, 25191, 63, 1661, 275, 2400, 26, 971, 288, 15821, 63, 1045, 63, 15895, 1332, 403, 12, 4420, 4000, 650, 9, 398, 327, 2529, 2202, 2600, 267, 291, 14, 362, 63, 7379, 63, 1751, 275, 971, 288, 2400, 2557, 63, 409, 84, 12, 1817, 63, 354, 12, 5518, 63, 1419, 26, 971, 288, 791, 7341, 40, 12394, 2846, 63, 8723, 356, 1817, 63, 354, 12, 1467, 283, 7341, 40, 12394, 2846, 63, 18389, 356, 2557, 63, 409, 84, 12, 1467, 283, 7341, 40, 12394, 2846, 63, 10258, 63, 8808, 356, 5518, 63, 1419, 93, 339, 347, 511, 63, 826, 63, 1397, 63, 11786, 8, 277, 304, 267, 327, 702, 83, 3787, 911, 746, 2832, 9902, 1305, 1263, 402, 314, 2368, 267, 327, 365, 488, 398, 5300, 63, 1661, 275, 291, 14, 826, 63, 25191, 63, 1661, 342, 267, 367, 5253, 12, 1817, 63, 354, 12, 5518, 63, 1419, 315, 5300, 63, 1661, 26, 288, 340, 440, 5253, 503, 440, 1817, 63, 354, 503, 440, 5518, 63, 1419, 26, 355, 291, 14, 1855, 8, 1763, 9902, 12, 799, 29727, 2846, 17562, 12, 3303, 5253, 12, 1817, 63, 354, 12, 5518, 63, 1419, 9, 339, 347, 511, 63, 826, 63, 1667, 63, 1224, 63, 354, 8, 277, 304, 267, 327, 702, 83, 3787, 911, 746, 2832, 9902, 340, 1817, 63, 354, 365, 2701, 267, 291, 14, 1855, 8, 1763, 9902, 12, 799, 29727, 2846, 17562, 12, 4420, 1062, 3260, 4420, 1012, 339, 347, 511, 63, 826, 63, 11786, 8, 277, 304, 267, 327, 702, 83, 626, 314, 849, 7679, 1334, 511, 16416, 370, 664, 314, 1817, 398, 291, 14, 629, 8, 277, 14, 7379, 14, 1224, 12, 586, 291, 14, 3090, 14, 362, 63, 1224, 14, 1107, 63, 585, 9, 267, 291, 14, 3090, 14, 362, 63, 1224, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 277, 14, 1224, 63, 354, 9, 339, 347, 511, 63, 504, 63, 23972, 63, 11786, 8, 277, 304, 267, 327, 702, 83, 626, 687, 63, 23972, 911, 372, 282, 7679, 1256, 340, 314, 267, 327, 3787, 2529, 488, 12, 465, 1420, 398, 29550, 275, 4420, 342, 398, 5300, 63, 1661, 275, 291, 14, 826, 63, 25191, 63, 1661, 342, 267, 367, 2557, 63, 409, 84, 12, 1817, 63, 354, 12, 5518, 63, 1419, 315, 5300, 63, 1661, 26, 288, 29550, 14, 1751, 275, 291, 14, 362, 63, 7379, 63, 1751, 8, 355, 2557, 63, 409, 84, 12, 1817, 63, 354, 12, 5518, 63, 1419, 288, 776, 953, 543, 291, 14, 7379, 63, 1886, 63, 11238, 465, 7679, 63, 1886, 12, 971, 490, 291, 14, 3090, 63, 11238, 465, 5253, 63, 11645, 26, 355, 7679, 63, 1886, 14, 1107, 63, 585, 275, 488, 2234, 7679, 275, 799, 29727, 2846, 17562, 14, 504, 63, 23972, 8, 23972, 9, 355, 291, 14, 6926, 8, 7379, 12, 799, 29727, 2846, 17562, 9, 2234, 5253, 63, 11645, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 1631, 63, 409, 84, 9, 355, 7679, 63, 1886, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 490, 5253, 63, 11645, 14, 1107, 63, 585, 12, 1817, 63, 354, 12, 5518, 63, 1419, 355, 776, 339, 347, 511, 63, 504, 63, 23972, 63, 1397, 63, 11786, 8, 277, 304, 267, 327, 702, 83, 626, 687, 63, 23972, 911, 746, 2832, 9902, 314, 267, 327, 3787, 6534, 2832, 9902, 1919, 267, 29550, 275, 4420, 342, 398, 367, 2557, 63, 409, 84, 12, 1817, 63, 354, 12, 5518, 63, 1419, 315, 291, 14, 826, 63, 25191, 63, 1661, 837, 288, 29550, 14, 1751, 275, 291, 14, 362, 63, 7379, 63, 1751, 8, 355, 2557, 63, 409, 84, 12, 1817, 63, 354, 12, 5518, 63, 1419, 288, 776, 953, 543, 291, 14, 7379, 63, 1886, 63, 11238, 465, 7679, 63, 1886, 12, 971, 490, 291, 14, 3090, 63, 11238, 465, 5253, 63, 11645, 26, 355, 7679, 63, 1886, 14, 2441, 63, 5881, 275, 2832, 9902, 2234, 291, 14, 1855, 8, 1763, 9902, 12, 3303, 799, 29727, 2846, 17562, 14, 504, 63, 23972, 12, 3303, 29550, 9, 2234, 5253, 63, 11645, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 1631, 63, 409, 84, 9, 355, 7679, 63, 1886, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 490, 5253, 63, 11645, 14, 1107, 63, 585, 12, 1817, 63, 354, 12, 5518, 63, 1419, 355, 776, 339, 347, 511, 63, 1412, 63, 1053, 63, 1397, 63, 290, 63, 1053, 8, 277, 304, 267, 327, 702, 83, 626, 282, 2222, 13, 1053, 365, 2951, 2138, 398, 18094, 275, 4420, 342, 267, 327, 1683, 316, 2544, 63, 3176, 370, 1104, 626, 652, 7859, 1133, 506, 2797, 315, 642, 511, 267, 291, 14, 7379, 14, 5182, 63, 3176, 275, 4420, 342, 267, 291, 14, 7379, 14, 1412, 63, 1053, 8, 3346, 1062, 18094, 9, 267, 291, 14, 1815, 8, 12856, 14, 793, 14, 1328, 14, 3527, 9, 267, 291, 14, 3334, 8, 277, 14, 7379, 14 ]
[ 2882, 199, 504, 1683, 492, 4420, 12, 10079, 12, 3371, 199, 504, 7975, 492, 15821, 63, 1045, 63, 15895, 199, 199, 504, 18918, 63, 264, 29727, 697, 14, 7379, 492, 799, 29727, 2846, 17562, 12, 2832, 9902, 12, 7020, 421, 199, 533, 799, 29727, 2846, 17562, 774, 8, 2796, 14, 1746, 304, 339, 347, 3613, 8, 277, 304, 398, 327, 849, 7679, 1334, 511, 267, 291, 14, 3090, 275, 4420, 342, 267, 291, 14, 1224, 63, 354, 275, 4420, 342, 267, 291, 14, 3176, 63, 1419, 275, 10079, 342, 267, 291, 14, 7379, 275, 799, 29727, 2846, 17562, 8, 288, 291, 14, 3090, 12, 291, 14, 1224, 63, 354, 12, 291, 14, 3176, 63, 1419, 267, 776, 398, 327, 3371, 367, 5253, 267, 291, 14, 3090, 63, 11238, 275, 3371, 360, 26442, 63, 264, 29727, 697, 14, 7379, 3530, 2511, 283, 497, 29727, 2846, 6158, 358, 267, 327, 21198, 367, 314, 7679, 3787, 267, 291, 14, 7379, 63, 1886, 63, 11238, 275, 3371, 360, 26442, 63, 264, 29727, 697, 14, 7379, 3530, 5101, 283, 497, 29727, 2846, 17562, 855, 826, 13766, 398, 327, 2529, 6122, 367, 1006, 3962, 15821, 367, 650, 2368, 267, 327, 1314, 1338, 883, 506, 1902, 282, 4420, 503, 488, 267, 291, 14, 826, 63, 25191, 63, 1661, 275, 2400, 26, 971, 288, 15821, 63, 1045, 63, 15895, 1332, 403, 12, 4420, 4000, 650, 9, 398, 327, 2529, 2202, 2600, 267, 291, 14, 362, 63, 7379, 63, 1751, 275, 971, 288, 2400, 2557, 63, 409, 84, 12, 1817, 63, 354, 12, 5518, 63, 1419, 26, 971, 288, 791, 7341, 40, 12394, 2846, 63, 8723, 356, 1817, 63, 354, 12, 1467, 283, 7341, 40, 12394, 2846, 63, 18389, 356, 2557, 63, 409, 84, 12, 1467, 283, 7341, 40, 12394, 2846, 63, 10258, 63, 8808, 356, 5518, 63, 1419, 93, 339, 347, 511, 63, 826, 63, 1397, 63, 11786, 8, 277, 304, 267, 327, 702, 83, 3787, 911, 746, 2832, 9902, 1305, 1263, 402, 314, 2368, 267, 327, 365, 488, 398, 5300, 63, 1661, 275, 291, 14, 826, 63, 25191, 63, 1661, 342, 267, 367, 5253, 12, 1817, 63, 354, 12, 5518, 63, 1419, 315, 5300, 63, 1661, 26, 288, 340, 440, 5253, 503, 440, 1817, 63, 354, 503, 440, 5518, 63, 1419, 26, 355, 291, 14, 1855, 8, 1763, 9902, 12, 799, 29727, 2846, 17562, 12, 3303, 5253, 12, 1817, 63, 354, 12, 5518, 63, 1419, 9, 339, 347, 511, 63, 826, 63, 1667, 63, 1224, 63, 354, 8, 277, 304, 267, 327, 702, 83, 3787, 911, 746, 2832, 9902, 340, 1817, 63, 354, 365, 2701, 267, 291, 14, 1855, 8, 1763, 9902, 12, 799, 29727, 2846, 17562, 12, 4420, 1062, 3260, 4420, 1012, 339, 347, 511, 63, 826, 63, 11786, 8, 277, 304, 267, 327, 702, 83, 626, 314, 849, 7679, 1334, 511, 16416, 370, 664, 314, 1817, 398, 291, 14, 629, 8, 277, 14, 7379, 14, 1224, 12, 586, 291, 14, 3090, 14, 362, 63, 1224, 14, 1107, 63, 585, 9, 267, 291, 14, 3090, 14, 362, 63, 1224, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 277, 14, 1224, 63, 354, 9, 339, 347, 511, 63, 504, 63, 23972, 63, 11786, 8, 277, 304, 267, 327, 702, 83, 626, 687, 63, 23972, 911, 372, 282, 7679, 1256, 340, 314, 267, 327, 3787, 2529, 488, 12, 465, 1420, 398, 29550, 275, 4420, 342, 398, 5300, 63, 1661, 275, 291, 14, 826, 63, 25191, 63, 1661, 342, 267, 367, 2557, 63, 409, 84, 12, 1817, 63, 354, 12, 5518, 63, 1419, 315, 5300, 63, 1661, 26, 288, 29550, 14, 1751, 275, 291, 14, 362, 63, 7379, 63, 1751, 8, 355, 2557, 63, 409, 84, 12, 1817, 63, 354, 12, 5518, 63, 1419, 288, 776, 953, 543, 291, 14, 7379, 63, 1886, 63, 11238, 465, 7679, 63, 1886, 12, 971, 490, 291, 14, 3090, 63, 11238, 465, 5253, 63, 11645, 26, 355, 7679, 63, 1886, 14, 1107, 63, 585, 275, 488, 2234, 7679, 275, 799, 29727, 2846, 17562, 14, 504, 63, 23972, 8, 23972, 9, 355, 291, 14, 6926, 8, 7379, 12, 799, 29727, 2846, 17562, 9, 2234, 5253, 63, 11645, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 1631, 63, 409, 84, 9, 355, 7679, 63, 1886, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 490, 5253, 63, 11645, 14, 1107, 63, 585, 12, 1817, 63, 354, 12, 5518, 63, 1419, 355, 776, 339, 347, 511, 63, 504, 63, 23972, 63, 1397, 63, 11786, 8, 277, 304, 267, 327, 702, 83, 626, 687, 63, 23972, 911, 746, 2832, 9902, 314, 267, 327, 3787, 6534, 2832, 9902, 1919, 267, 29550, 275, 4420, 342, 398, 367, 2557, 63, 409, 84, 12, 1817, 63, 354, 12, 5518, 63, 1419, 315, 291, 14, 826, 63, 25191, 63, 1661, 837, 288, 29550, 14, 1751, 275, 291, 14, 362, 63, 7379, 63, 1751, 8, 355, 2557, 63, 409, 84, 12, 1817, 63, 354, 12, 5518, 63, 1419, 288, 776, 953, 543, 291, 14, 7379, 63, 1886, 63, 11238, 465, 7679, 63, 1886, 12, 971, 490, 291, 14, 3090, 63, 11238, 465, 5253, 63, 11645, 26, 355, 7679, 63, 1886, 14, 2441, 63, 5881, 275, 2832, 9902, 2234, 291, 14, 1855, 8, 1763, 9902, 12, 3303, 799, 29727, 2846, 17562, 14, 504, 63, 23972, 12, 3303, 29550, 9, 2234, 5253, 63, 11645, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 1631, 63, 409, 84, 9, 355, 7679, 63, 1886, 14, 479, 63, 3527, 63, 5089, 63, 1045, 8, 490, 5253, 63, 11645, 14, 1107, 63, 585, 12, 1817, 63, 354, 12, 5518, 63, 1419, 355, 776, 339, 347, 511, 63, 1412, 63, 1053, 63, 1397, 63, 290, 63, 1053, 8, 277, 304, 267, 327, 702, 83, 626, 282, 2222, 13, 1053, 365, 2951, 2138, 398, 18094, 275, 4420, 342, 267, 327, 1683, 316, 2544, 63, 3176, 370, 1104, 626, 652, 7859, 1133, 506, 2797, 315, 642, 511, 267, 291, 14, 7379, 14, 5182, 63, 3176, 275, 4420, 342, 267, 291, 14, 7379, 14, 1412, 63, 1053, 8, 3346, 1062, 18094, 9, 267, 291, 14, 1815, 8, 12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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
yunfeilu/scikit-learn
sklearn/decomposition/tests/test_sparse_pca.py
160
6028
# Author: Vlad Niculae # License: BSD 3 clause import sys import numpy as np from sklearn.utils.testing import assert_array_almost_equal from sklearn.utils.testing import assert_equal from sklearn.utils.testing import assert_array_equal from sklearn.utils.testing import SkipTest from sklearn.utils.testing import assert_true from sklearn.utils.testing import assert_false from sklearn.utils.testing import if_safe_multiprocessing_with_blas from sklearn.decomposition import SparsePCA, MiniBatchSparsePCA from sklearn.utils import check_random_state def generate_toy_data(n_components, n_samples, image_size, random_state=None): n_features = image_size[0] * image_size[1] rng = check_random_state(random_state) U = rng.randn(n_samples, n_components) V = rng.randn(n_components, n_features) centers = [(3, 3), (6, 7), (8, 1)] sz = [1, 2, 1] for k in range(n_components): img = np.zeros(image_size) xmin, xmax = centers[k][0] - sz[k], centers[k][0] + sz[k] ymin, ymax = centers[k][1] - sz[k], centers[k][1] + sz[k] img[xmin:xmax][:, ymin:ymax] = 1.0 V[k, :] = img.ravel() # Y is defined by : Y = UV + noise Y = np.dot(U, V) Y += 0.1 * rng.randn(Y.shape[0], Y.shape[1]) # Add noise return Y, U, V # SparsePCA can be a bit slow. To avoid having test times go up, we # test different aspects of the code in the same test def test_correct_shapes(): rng = np.random.RandomState(0) X = rng.randn(12, 10) spca = SparsePCA(n_components=8, random_state=rng) U = spca.fit_transform(X) assert_equal(spca.components_.shape, (8, 10)) assert_equal(U.shape, (12, 8)) # test overcomplete decomposition spca = SparsePCA(n_components=13, random_state=rng) U = spca.fit_transform(X) assert_equal(spca.components_.shape, (13, 10)) assert_equal(U.shape, (12, 13)) def test_fit_transform(): alpha = 1 rng = np.random.RandomState(0) Y, _, _ = generate_toy_data(3, 10, (8, 8), random_state=rng) # wide array spca_lars = SparsePCA(n_components=3, method='lars', alpha=alpha, random_state=0) spca_lars.fit(Y) # Test that CD gives similar results spca_lasso = SparsePCA(n_components=3, method='cd', random_state=0, alpha=alpha) spca_lasso.fit(Y) assert_array_almost_equal(spca_lasso.components_, spca_lars.components_) @if_safe_multiprocessing_with_blas def test_fit_transform_parallel(): alpha = 1 rng = np.random.RandomState(0) Y, _, _ = generate_toy_data(3, 10, (8, 8), random_state=rng) # wide array spca_lars = SparsePCA(n_components=3, method='lars', alpha=alpha, random_state=0) spca_lars.fit(Y) U1 = spca_lars.transform(Y) # Test multiple CPUs spca = SparsePCA(n_components=3, n_jobs=2, method='lars', alpha=alpha, random_state=0).fit(Y) U2 = spca.transform(Y) assert_true(not np.all(spca_lars.components_ == 0)) assert_array_almost_equal(U1, U2) def test_transform_nan(): # Test that SparsePCA won't return NaN when there is 0 feature in all # samples. rng = np.random.RandomState(0) Y, _, _ = generate_toy_data(3, 10, (8, 8), random_state=rng) # wide array Y[:, 0] = 0 estimator = SparsePCA(n_components=8) assert_false(np.any(np.isnan(estimator.fit_transform(Y)))) def test_fit_transform_tall(): rng = np.random.RandomState(0) Y, _, _ = generate_toy_data(3, 65, (8, 8), random_state=rng) # tall array spca_lars = SparsePCA(n_components=3, method='lars', random_state=rng) U1 = spca_lars.fit_transform(Y) spca_lasso = SparsePCA(n_components=3, method='cd', random_state=rng) U2 = spca_lasso.fit(Y).transform(Y) assert_array_almost_equal(U1, U2) def test_initialization(): rng = np.random.RandomState(0) U_init = rng.randn(5, 3) V_init = rng.randn(3, 4) model = SparsePCA(n_components=3, U_init=U_init, V_init=V_init, max_iter=0, random_state=rng) model.fit(rng.randn(5, 4)) assert_array_equal(model.components_, V_init) def test_mini_batch_correct_shapes(): rng = np.random.RandomState(0) X = rng.randn(12, 10) pca = MiniBatchSparsePCA(n_components=8, random_state=rng) U = pca.fit_transform(X) assert_equal(pca.components_.shape, (8, 10)) assert_equal(U.shape, (12, 8)) # test overcomplete decomposition pca = MiniBatchSparsePCA(n_components=13, random_state=rng) U = pca.fit_transform(X) assert_equal(pca.components_.shape, (13, 10)) assert_equal(U.shape, (12, 13)) def test_mini_batch_fit_transform(): raise SkipTest("skipping mini_batch_fit_transform.") alpha = 1 rng = np.random.RandomState(0) Y, _, _ = generate_toy_data(3, 10, (8, 8), random_state=rng) # wide array spca_lars = MiniBatchSparsePCA(n_components=3, random_state=0, alpha=alpha).fit(Y) U1 = spca_lars.transform(Y) # Test multiple CPUs if sys.platform == 'win32': # fake parallelism for win32 import sklearn.externals.joblib.parallel as joblib_par _mp = joblib_par.multiprocessing joblib_par.multiprocessing = None try: U2 = MiniBatchSparsePCA(n_components=3, n_jobs=2, alpha=alpha, random_state=0).fit(Y).transform(Y) finally: joblib_par.multiprocessing = _mp else: # we can efficiently use parallelism U2 = MiniBatchSparsePCA(n_components=3, n_jobs=2, alpha=alpha, random_state=0).fit(Y).transform(Y) assert_true(not np.all(spca_lars.components_ == 0)) assert_array_almost_equal(U1, U2) # Test that CD gives similar results spca_lasso = MiniBatchSparsePCA(n_components=3, method='cd', alpha=alpha, random_state=0).fit(Y) assert_array_almost_equal(spca_lasso.components_, spca_lars.components_)
bsd-3-clause
[ 3, 6529, 26, 812, 76, 350, 653, 530, 348, 3624, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 984, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 18795, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 2052, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3910, 199, 504, 6357, 14, 1208, 14, 4776, 492, 340, 63, 3489, 63, 25725, 63, 1045, 63, 21044, 199, 199, 504, 6357, 14, 31384, 492, 14531, 23852, 12, 24954, 8842, 8629, 23852, 199, 504, 6357, 14, 1208, 492, 1104, 63, 2355, 63, 929, 421, 199, 318, 3550, 63, 19126, 63, 576, 8, 78, 63, 4608, 12, 302, 63, 3356, 12, 1834, 63, 890, 12, 2196, 63, 929, 29, 403, 304, 272, 302, 63, 3179, 275, 1834, 63, 890, 59, 16, 61, 627, 1834, 63, 890, 59, 17, 61, 339, 9038, 275, 1104, 63, 2355, 63, 929, 8, 2355, 63, 929, 9, 272, 738, 275, 9038, 14, 10843, 8, 78, 63, 3356, 12, 302, 63, 4608, 9, 272, 812, 275, 9038, 14, 10843, 8, 78, 63, 4608, 12, 302, 63, 3179, 9, 339, 19190, 275, 3842, 19, 12, 650, 395, 334, 22, 12, 1520, 395, 334, 24, 12, 413, 1874, 272, 17176, 275, 359, 17, 12, 499, 12, 413, 61, 272, 367, 1022, 315, 1425, 8, 78, 63, 4608, 304, 267, 6050, 275, 980, 14, 4250, 8, 1569, 63, 890, 9, 267, 22036, 12, 19906, 275, 19190, 59, 75, 1527, 16, 61, 446, 17176, 59, 75, 467, 19190, 59, 75, 1527, 16, 61, 435, 17176, 59, 75, 61, 267, 22506, 12, 21023, 275, 19190, 59, 75, 1527, 17, 61, 446, 17176, 59, 75, 467, 19190, 59, 75, 1527, 17, 61, 435, 17176, 59, 75, 61, 267, 6050, 59, 21601, 26, 28961, 61, 3981, 22506, 26, 30036, 61, 275, 413, 14, 16, 267, 812, 59, 75, 12, 12228, 275, 6050, 14, 11186, 342, 339, 327, 1488, 365, 3247, 701, 520, 1488, 275, 738, 54, 435, 11145, 272, 1488, 275, 980, 14, 3287, 8, 53, 12, 812, 9, 272, 1488, 847, 378, 14, 17, 627, 9038, 14, 10843, 8, 57, 14, 1392, 59, 16, 467, 1488, 14, 1392, 59, 17, 566, 221, 327, 2654, 11145, 272, 372, 1488, 12, 738, 12, 812, 199, 199, 3, 14531, 23852, 883, 506, 282, 4546, 11999, 14, 4005, 5126, 9445, 511, 5431, 2621, 1536, 12, 781, 199, 3, 511, 3365, 17435, 83, 402, 314, 1233, 315, 314, 2011, 511, 421, 199, 318, 511, 63, 4525, 63, 9069, 837, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1323, 275, 9038, 14, 10843, 8, 713, 12, 1616, 9, 272, 2249, 696, 275, 14531, 23852, 8, 78, 63, 4608, 29, 24, 12, 2196, 63, 929, 29, 12686, 9, 272, 738, 275, 2249, 696, 14, 3269, 63, 4711, 8, 56, 9, 272, 702, 63, 1452, 8, 681, 696, 14, 4608, 3754, 1392, 12, 334, 24, 12, 1616, 430, 272, 702, 63, 1452, 8, 53, 14, 1392, 12, 334, 713, 12, 1695, 430, 272, 327, 511, 1806, 4883, 22706, 272, 2249, 696, 275, 14531, 23852, 8, 78, 63, 4608, 29, 969, 12, 2196, 63, 929, 29, 12686, 9, 272, 738, 275, 2249, 696, 14, 3269, 63, 4711, 8, 56, 9, 272, 702, 63, 1452, 8, 681, 696, 14, 4608, 3754, 1392, 12, 334, 969, 12, 1616, 430, 272, 702, 63, 1452, 8, 53, 14, 1392, 12, 334, 713, 12, 4944, 430, 421, 199, 318, 511, 63, 3269, 63, 4711, 837, 272, 5131, 275, 413, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1488, 12, 5501, 485, 275, 3550, 63, 19126, 63, 576, 8, 19, 12, 1616, 12, 334, 24, 12, 1695, 395, 2196, 63, 929, 29, 12686, 9, 221, 327, 20239, 1625, 272, 2249, 696, 63, 31590, 275, 14531, 23852, 8, 78, 63, 4608, 29, 19, 12, 1083, 534, 31590, 297, 5131, 29, 4468, 12, 2079, 2196, 63, 929, 29, 16, 9, 272, 2249, 696, 63, 31590, 14, 3269, 8, 57, 9, 339, 327, 1379, 626, 445, 36, 10557, 8545, 2058, 272, 2249, 696, 63, 18412, 275, 14531, 23852, 8, 78, 63, 4608, 29, 19, 12, 1083, 534, 2866, 297, 2196, 63, 929, 29, 16, 12, 2574, 5131, 29, 4468, 9, 272, 2249, 696, 63, 18412, 14, 3269, 8, 57, 9, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 681, 696, 63, 18412, 14, 4608, 3131, 2249, 696, 63, 31590, 14, 4608, 4602, 421, 199, 32, 692, 63, 3489, 63, 25725, 63, 1045, 63, 21044, 199, 318, 511, 63, 3269, 63, 4711, 63, 11887, 837, 272, 5131, 275, 413, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1488, 12, 5501, 485, 275, 3550, 63, 19126, 63, 576, 8, 19, 12, 1616, 12, 334, 24, 12, 1695, 395, 2196, 63, 929, 29, 12686, 9, 221, 327, 20239, 1625, 272, 2249, 696, 63, 31590, 275, 14531, 23852, 8, 78, 63, 4608, 29, 19, 12, 1083, 534, 31590, 297, 5131, 29, 4468, 12, 2079, 2196, 63, 929, 29, 16, 9, 272, 2249, 696, 63, 31590, 14, 3269, 8, 57, 9, 272, 738, 17, 275, 2249, 696, 63, 31590, 14, 4711, 8, 57, 9, 272, 327, 1379, 3663, 28504, 272, 2249, 696, 275, 14531, 23852, 8, 78, 63, 4608, 29, 19, 12, 302, 63, 6920, 29, 18, 12, 1083, 534, 31590, 297, 5131, 29, 4468, 12, 2151, 2196, 63, 929, 29, 16, 680, 3269, 8, 57, 9, 272, 738, 18, 275, 2249, 696, 14, 4711, 8, 57, 9, 272, 702, 63, 2052, 8, 1397, 980, 14, 452, 8, 681, 696, 63, 31590, 14, 4608, 63, 508, 378, 430, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 53, 17, 12, 738, 18, 9, 421, 199, 318, 511, 63, 4711, 63, 4304, 837, 272, 327, 1379, 626, 14531, 23852, 7859, 1133, 372, 16046, 1380, 2337, 365, 378, 3878, 315, 1006, 272, 327, 5845, 14, 272, 9038, 275, 980, 14, 2355, 14 ]
[ 6529, 26, 812, 76, 350, 653, 530, 348, 3624, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 984, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 4398, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 1144, 63, 1452, 199, 504, 6357, 14, 1208, 14, 4776, 492, 18795, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 2052, 199, 504, 6357, 14, 1208, 14, 4776, 492, 702, 63, 3910, 199, 504, 6357, 14, 1208, 14, 4776, 492, 340, 63, 3489, 63, 25725, 63, 1045, 63, 21044, 199, 199, 504, 6357, 14, 31384, 492, 14531, 23852, 12, 24954, 8842, 8629, 23852, 199, 504, 6357, 14, 1208, 492, 1104, 63, 2355, 63, 929, 421, 199, 318, 3550, 63, 19126, 63, 576, 8, 78, 63, 4608, 12, 302, 63, 3356, 12, 1834, 63, 890, 12, 2196, 63, 929, 29, 403, 304, 272, 302, 63, 3179, 275, 1834, 63, 890, 59, 16, 61, 627, 1834, 63, 890, 59, 17, 61, 339, 9038, 275, 1104, 63, 2355, 63, 929, 8, 2355, 63, 929, 9, 272, 738, 275, 9038, 14, 10843, 8, 78, 63, 3356, 12, 302, 63, 4608, 9, 272, 812, 275, 9038, 14, 10843, 8, 78, 63, 4608, 12, 302, 63, 3179, 9, 339, 19190, 275, 3842, 19, 12, 650, 395, 334, 22, 12, 1520, 395, 334, 24, 12, 413, 1874, 272, 17176, 275, 359, 17, 12, 499, 12, 413, 61, 272, 367, 1022, 315, 1425, 8, 78, 63, 4608, 304, 267, 6050, 275, 980, 14, 4250, 8, 1569, 63, 890, 9, 267, 22036, 12, 19906, 275, 19190, 59, 75, 1527, 16, 61, 446, 17176, 59, 75, 467, 19190, 59, 75, 1527, 16, 61, 435, 17176, 59, 75, 61, 267, 22506, 12, 21023, 275, 19190, 59, 75, 1527, 17, 61, 446, 17176, 59, 75, 467, 19190, 59, 75, 1527, 17, 61, 435, 17176, 59, 75, 61, 267, 6050, 59, 21601, 26, 28961, 61, 3981, 22506, 26, 30036, 61, 275, 413, 14, 16, 267, 812, 59, 75, 12, 12228, 275, 6050, 14, 11186, 342, 339, 327, 1488, 365, 3247, 701, 520, 1488, 275, 738, 54, 435, 11145, 272, 1488, 275, 980, 14, 3287, 8, 53, 12, 812, 9, 272, 1488, 847, 378, 14, 17, 627, 9038, 14, 10843, 8, 57, 14, 1392, 59, 16, 467, 1488, 14, 1392, 59, 17, 566, 221, 327, 2654, 11145, 272, 372, 1488, 12, 738, 12, 812, 199, 199, 3, 14531, 23852, 883, 506, 282, 4546, 11999, 14, 4005, 5126, 9445, 511, 5431, 2621, 1536, 12, 781, 199, 3, 511, 3365, 17435, 83, 402, 314, 1233, 315, 314, 2011, 511, 421, 199, 318, 511, 63, 4525, 63, 9069, 837, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1323, 275, 9038, 14, 10843, 8, 713, 12, 1616, 9, 272, 2249, 696, 275, 14531, 23852, 8, 78, 63, 4608, 29, 24, 12, 2196, 63, 929, 29, 12686, 9, 272, 738, 275, 2249, 696, 14, 3269, 63, 4711, 8, 56, 9, 272, 702, 63, 1452, 8, 681, 696, 14, 4608, 3754, 1392, 12, 334, 24, 12, 1616, 430, 272, 702, 63, 1452, 8, 53, 14, 1392, 12, 334, 713, 12, 1695, 430, 272, 327, 511, 1806, 4883, 22706, 272, 2249, 696, 275, 14531, 23852, 8, 78, 63, 4608, 29, 969, 12, 2196, 63, 929, 29, 12686, 9, 272, 738, 275, 2249, 696, 14, 3269, 63, 4711, 8, 56, 9, 272, 702, 63, 1452, 8, 681, 696, 14, 4608, 3754, 1392, 12, 334, 969, 12, 1616, 430, 272, 702, 63, 1452, 8, 53, 14, 1392, 12, 334, 713, 12, 4944, 430, 421, 199, 318, 511, 63, 3269, 63, 4711, 837, 272, 5131, 275, 413, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1488, 12, 5501, 485, 275, 3550, 63, 19126, 63, 576, 8, 19, 12, 1616, 12, 334, 24, 12, 1695, 395, 2196, 63, 929, 29, 12686, 9, 221, 327, 20239, 1625, 272, 2249, 696, 63, 31590, 275, 14531, 23852, 8, 78, 63, 4608, 29, 19, 12, 1083, 534, 31590, 297, 5131, 29, 4468, 12, 2079, 2196, 63, 929, 29, 16, 9, 272, 2249, 696, 63, 31590, 14, 3269, 8, 57, 9, 339, 327, 1379, 626, 445, 36, 10557, 8545, 2058, 272, 2249, 696, 63, 18412, 275, 14531, 23852, 8, 78, 63, 4608, 29, 19, 12, 1083, 534, 2866, 297, 2196, 63, 929, 29, 16, 12, 2574, 5131, 29, 4468, 9, 272, 2249, 696, 63, 18412, 14, 3269, 8, 57, 9, 272, 702, 63, 1144, 63, 4398, 63, 1452, 8, 681, 696, 63, 18412, 14, 4608, 3131, 2249, 696, 63, 31590, 14, 4608, 4602, 421, 199, 32, 692, 63, 3489, 63, 25725, 63, 1045, 63, 21044, 199, 318, 511, 63, 3269, 63, 4711, 63, 11887, 837, 272, 5131, 275, 413, 272, 9038, 275, 980, 14, 2355, 14, 15726, 8, 16, 9, 272, 1488, 12, 5501, 485, 275, 3550, 63, 19126, 63, 576, 8, 19, 12, 1616, 12, 334, 24, 12, 1695, 395, 2196, 63, 929, 29, 12686, 9, 221, 327, 20239, 1625, 272, 2249, 696, 63, 31590, 275, 14531, 23852, 8, 78, 63, 4608, 29, 19, 12, 1083, 534, 31590, 297, 5131, 29, 4468, 12, 2079, 2196, 63, 929, 29, 16, 9, 272, 2249, 696, 63, 31590, 14, 3269, 8, 57, 9, 272, 738, 17, 275, 2249, 696, 63, 31590, 14, 4711, 8, 57, 9, 272, 327, 1379, 3663, 28504, 272, 2249, 696, 275, 14531, 23852, 8, 78, 63, 4608, 29, 19, 12, 302, 63, 6920, 29, 18, 12, 1083, 534, 31590, 297, 5131, 29, 4468, 12, 2151, 2196, 63, 929, 29, 16, 680, 3269, 8, 57, 9, 272, 738, 18, 275, 2249, 696, 14, 4711, 8, 57, 9, 272, 702, 63, 2052, 8, 1397, 980, 14, 452, 8, 681, 696, 63, 31590, 14, 4608, 63, 508, 378, 430, 272, 702, 63, 1144, 63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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
rickerc/horizon_audit
openstack_dashboard/dashboards/project/access_and_security/security_groups/tests.py
8
30188
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2012 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # Copyright 2012 Nebula, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import cgi from django.conf import settings # noqa from django.core.urlresolvers import reverse # noqa from django import http from mox import IsA # noqa from openstack_dashboard import api from openstack_dashboard.test import helpers as test from openstack_dashboard.dashboards.project.access_and_security.\ security_groups import tables INDEX_URL = reverse('horizon:project:access_and_security:index') SG_CREATE_URL = reverse('horizon:project:access_and_security:' 'security_groups:create') def strip_absolute_base(uri): return uri.split(settings.TESTSERVER, 1)[-1] class SecurityGroupsViewTests(test.TestCase): secgroup_backend = 'nova' def setUp(self): super(SecurityGroupsViewTests, self).setUp() sec_group = self.security_groups.first() self.detail_url = reverse('horizon:project:access_and_security:' 'security_groups:detail', args=[sec_group.id]) self.edit_url = reverse('horizon:project:access_and_security:' 'security_groups:add_rule', args=[sec_group.id]) @test.create_stubs({api.network: ('security_group_get',)}) def test_update_security_groups_get(self): sec_group = self.security_groups.first() api.network.security_group_get(IsA(http.HttpRequest), sec_group.id).AndReturn(sec_group) self.mox.ReplayAll() res = self.client.get(reverse('horizon:project:access_and_security:' 'security_groups:update', args=[sec_group.id])) self.assertTemplateUsed(res, 'project/access_and_security/security_groups/_update.html') self.assertEqual(res.context['security_group'].name, sec_group.name) @test.create_stubs({api.network: ('security_group_update', 'security_group_get')}) def test_update_security_groups_post(self): sec_group = self.security_groups.get(name="other_group") api.network.security_group_update(IsA(http.HttpRequest), str(sec_group.id), sec_group.name, sec_group.description) \ .AndReturn(sec_group) api.network.security_group_get(IsA(http.HttpRequest), sec_group.id).AndReturn(sec_group) self.mox.ReplayAll() formData = {'method': 'UpdateGroup', 'id': sec_group.id, 'name': sec_group.name, 'description': sec_group.description} update_url = reverse('horizon:project:access_and_security:' 'security_groups:update', args=[sec_group.id]) res = self.client.post(update_url, formData) self.assertRedirectsNoFollow(res, INDEX_URL) def test_create_security_groups_get(self): res = self.client.get(SG_CREATE_URL) self.assertTemplateUsed(res, 'project/access_and_security/security_groups/create.html') @test.create_stubs({api.network: ('security_group_create',)}) def test_create_security_groups_post(self): sec_group = self.security_groups.first() api.network.security_group_create(IsA(http.HttpRequest), sec_group.name, sec_group.description) \ .AndReturn(sec_group) self.mox.ReplayAll() formData = {'method': 'CreateGroup', 'name': sec_group.name, 'description': sec_group.description} res = self.client.post(SG_CREATE_URL, formData) self.assertRedirectsNoFollow(res, INDEX_URL) @test.create_stubs({api.network: ('security_group_create',)}) def test_create_security_groups_post_exception(self): sec_group = self.security_groups.first() api.network.security_group_create(IsA(http.HttpRequest), sec_group.name, sec_group.description) \ .AndRaise(self.exceptions.nova) self.mox.ReplayAll() formData = {'method': 'CreateGroup', 'name': sec_group.name, 'description': sec_group.description} res = self.client.post(SG_CREATE_URL, formData) self.assertMessageCount(error=1) self.assertRedirectsNoFollow(res, INDEX_URL) @test.create_stubs({api.network: ('security_group_create',)}) def test_create_security_groups_post_wrong_name(self): sec_group = self.security_groups.first() fail_name = sec_group.name + ' invalid' self.mox.ReplayAll() formData = {'method': 'CreateGroup', 'name': fail_name, 'description': sec_group.description} res = self.client.post(SG_CREATE_URL, formData) self.assertTemplateUsed(res, 'project/access_and_security/security_groups/create.html') self.assertContains(res, "ASCII") @test.create_stubs({api.network: ('security_group_get',)}) def test_detail_get(self): sec_group = self.security_groups.first() api.network.security_group_get(IsA(http.HttpRequest), sec_group.id).AndReturn(sec_group) self.mox.ReplayAll() res = self.client.get(self.detail_url) self.assertTemplateUsed(res, 'project/access_and_security/security_groups/detail.html') @test.create_stubs({api.network: ('security_group_get',)}) def test_detail_get_exception(self): sec_group = self.security_groups.first() api.network.security_group_get(IsA(http.HttpRequest), sec_group.id) \ .AndRaise(self.exceptions.nova) self.mox.ReplayAll() res = self.client.get(self.detail_url) self.assertRedirectsNoFollow(res, INDEX_URL) @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list', 'security_group_backend')}) def test_detail_add_rule_cidr(self): sec_group = self.security_groups.first() sec_group_list = self.security_groups.list() rule = self.security_group_rules.first() api.network.security_group_backend( IsA(http.HttpRequest)).AndReturn(self.secgroup_backend) api.network.security_group_rule_create(IsA(http.HttpRequest), sec_group.id, 'ingress', 'IPv4', rule.ip_protocol, int(rule.from_port), int(rule.to_port), rule.ip_range['cidr'], None).AndReturn(rule) api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', 'id': sec_group.id, 'port_or_range': 'port', 'port': rule.from_port, 'rule_menu': rule.ip_protocol, 'cidr': rule.ip_range['cidr'], 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertRedirectsNoFollow(res, self.detail_url) @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list', 'security_group_backend')}) def test_detail_add_rule_cidr_with_template(self): sec_group = self.security_groups.first() sec_group_list = self.security_groups.list() rule = self.security_group_rules.first() api.network.security_group_backend( IsA(http.HttpRequest)).AndReturn(self.secgroup_backend) api.network.security_group_rule_create(IsA(http.HttpRequest), sec_group.id, 'ingress', 'IPv4', rule.ip_protocol, int(rule.from_port), int(rule.to_port), rule.ip_range['cidr'], None).AndReturn(rule) api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', 'id': sec_group.id, 'rule_menu': 'http', 'port_or_range': 'port', 'cidr': rule.ip_range['cidr'], 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertRedirectsNoFollow(res, self.detail_url) def _get_source_group_rule(self): return self.security_group_rules.get(id=3) @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list', 'security_group_backend')}) def test_detail_add_rule_self_as_source_group(self): sec_group = self.security_groups.first() sec_group_list = self.security_groups.list() rule = self._get_source_group_rule() api.network.security_group_backend( IsA(http.HttpRequest)).AndReturn(self.secgroup_backend) api.network.security_group_rule_create( IsA(http.HttpRequest), sec_group.id, 'ingress', # ethertype is empty for source_group of Nova Security Group '', rule.ip_protocol, int(rule.from_port), int(rule.to_port), None, u'%s' % sec_group.id).AndReturn(rule) api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', 'id': sec_group.id, 'port_or_range': 'port', 'port': rule.from_port, 'rule_menu': rule.ip_protocol, 'cidr': '0.0.0.0/0', 'security_group': sec_group.id, 'remote': 'sg'} res = self.client.post(self.edit_url, formData) self.assertRedirectsNoFollow(res, self.detail_url) @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list', 'security_group_backend')}) def test_detail_add_rule_self_as_source_group_with_template(self): sec_group = self.security_groups.first() sec_group_list = self.security_groups.list() rule = self._get_source_group_rule() api.network.security_group_backend( IsA(http.HttpRequest)).AndReturn(self.secgroup_backend) api.network.security_group_rule_create( IsA(http.HttpRequest), sec_group.id, 'ingress', # ethertype is empty for source_group of Nova Security Group '', rule.ip_protocol, int(rule.from_port), int(rule.to_port), None, u'%s' % sec_group.id).AndReturn(rule) api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', 'id': sec_group.id, 'rule_menu': 'http', 'port_or_range': 'port', 'cidr': '0.0.0.0/0', 'security_group': sec_group.id, 'remote': 'sg'} res = self.client.post(self.edit_url, formData) self.assertRedirectsNoFollow(res, self.detail_url) @test.create_stubs({api.network: ('security_group_list', 'security_group_backend')}) def test_detail_invalid_port(self): sec_group = self.security_groups.first() sec_group_list = self.security_groups.list() rule = self.security_group_rules.first() api.network.security_group_backend( IsA(http.HttpRequest)).AndReturn(self.secgroup_backend) api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', 'id': sec_group.id, 'port_or_range': 'port', 'port': None, 'rule_menu': rule.ip_protocol, 'cidr': rule.ip_range['cidr'], 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertNoMessages() self.assertContains(res, "The specified port is invalid") @test.create_stubs({api.network: ('security_group_list', 'security_group_backend')}) def test_detail_invalid_port_range(self): sec_group = self.security_groups.first() sec_group_list = self.security_groups.list() rule = self.security_group_rules.first() for i in range(3): api.network.security_group_backend( IsA(http.HttpRequest)).AndReturn(self.secgroup_backend) api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', 'id': sec_group.id, 'port_or_range': 'range', 'from_port': rule.from_port, 'to_port': int(rule.from_port) - 1, 'rule_menu': rule.ip_protocol, 'cidr': rule.ip_range['cidr'], 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertNoMessages() self.assertContains(res, "greater than or equal to") formData = {'method': 'AddRule', 'id': sec_group.id, 'port_or_range': 'range', 'from_port': None, 'to_port': rule.to_port, 'rule_menu': rule.ip_protocol, 'cidr': rule.ip_range['cidr'], 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertNoMessages() self.assertContains(res, cgi.escape('"from" port number is invalid', quote=True)) formData = {'method': 'AddRule', 'id': sec_group.id, 'port_or_range': 'range', 'from_port': rule.from_port, 'to_port': None, 'rule_menu': rule.ip_protocol, 'cidr': rule.ip_range['cidr'], 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertNoMessages() self.assertContains(res, cgi.escape('"to" port number is invalid', quote=True)) @test.create_stubs({api.network: ('security_group_get', 'security_group_list', 'security_group_backend')}) def test_detail_invalid_icmp_rule(self): sec_group = self.security_groups.first() sec_group_list = self.security_groups.list() icmp_rule = self.security_group_rules.list()[1] # Call POST 4 times for i in range(4): api.network.security_group_backend( IsA(http.HttpRequest)).AndReturn(self.secgroup_backend) api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', 'id': sec_group.id, 'port_or_range': 'port', 'icmp_type': 256, 'icmp_code': icmp_rule.to_port, 'rule_menu': icmp_rule.ip_protocol, 'cidr': icmp_rule.ip_range['cidr'], 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertNoMessages() self.assertContains(res, "The ICMP type not in range (-1, 255)") formData = {'method': 'AddRule', 'id': sec_group.id, 'port_or_range': 'port', 'icmp_type': icmp_rule.from_port, 'icmp_code': 256, 'rule_menu': icmp_rule.ip_protocol, 'cidr': icmp_rule.ip_range['cidr'], 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertNoMessages() self.assertContains(res, "The ICMP code not in range (-1, 255)") formData = {'method': 'AddRule', 'id': sec_group.id, 'port_or_range': 'port', 'icmp_type': icmp_rule.from_port, 'icmp_code': None, 'rule_menu': icmp_rule.ip_protocol, 'cidr': icmp_rule.ip_range['cidr'], 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertNoMessages() self.assertContains(res, "The ICMP code is invalid") formData = {'method': 'AddRule', 'id': sec_group.id, 'port_or_range': 'port', 'icmp_type': None, 'icmp_code': icmp_rule.to_port, 'rule_menu': icmp_rule.ip_protocol, 'cidr': icmp_rule.ip_range['cidr'], 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertNoMessages() self.assertContains(res, "The ICMP type is invalid") @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list', 'security_group_backend')}) def test_detail_add_rule_exception(self): sec_group = self.security_groups.first() sec_group_list = self.security_groups.list() rule = self.security_group_rules.first() api.network.security_group_backend( IsA(http.HttpRequest)).AndReturn(self.secgroup_backend) api.network.security_group_rule_create( IsA(http.HttpRequest), sec_group.id, 'ingress', 'IPv4', rule.ip_protocol, int(rule.from_port), int(rule.to_port), rule.ip_range['cidr'], None).AndRaise(self.exceptions.nova) api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', 'id': sec_group.id, 'port_or_range': 'port', 'port': rule.from_port, 'rule_menu': rule.ip_protocol, 'cidr': rule.ip_range['cidr'], 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertRedirectsNoFollow(res, self.detail_url) @test.create_stubs({api.network: ('security_group_rule_delete',)}) def test_detail_delete_rule(self): sec_group = self.security_groups.first() rule = self.security_group_rules.first() api.network.security_group_rule_delete(IsA(http.HttpRequest), rule.id) self.mox.ReplayAll() form_data = {"action": "rules__delete__%s" % rule.id} req = self.factory.post(self.edit_url, form_data) kwargs = {'security_group_id': sec_group.id} table = tables.RulesTable(req, sec_group.rules, **kwargs) handled = table.maybe_handle() self.assertEqual(strip_absolute_base(handled['location']), self.detail_url) @test.create_stubs({api.network: ('security_group_rule_delete',)}) def test_detail_delete_rule_exception(self): sec_group = self.security_groups.first() rule = self.security_group_rules.first() api.network.security_group_rule_delete( IsA(http.HttpRequest), rule.id).AndRaise(self.exceptions.nova) self.mox.ReplayAll() form_data = {"action": "rules__delete__%s" % rule.id} req = self.factory.post(self.edit_url, form_data) kwargs = {'security_group_id': sec_group.id} table = tables.RulesTable( req, self.security_group_rules.list(), **kwargs) handled = table.maybe_handle() self.assertEqual(strip_absolute_base(handled['location']), self.detail_url) @test.create_stubs({api.network: ('security_group_delete',)}) def test_delete_group(self): sec_group = self.security_groups.get(name="other_group") api.network.security_group_delete(IsA(http.HttpRequest), sec_group.id) self.mox.ReplayAll() form_data = {"action": "security_groups__delete__%s" % sec_group.id} req = self.factory.post(INDEX_URL, form_data) table = tables.SecurityGroupsTable(req, self.security_groups.list()) handled = table.maybe_handle() self.assertEqual(strip_absolute_base(handled['location']), INDEX_URL) @test.create_stubs({api.network: ('security_group_delete',)}) def test_delete_group_exception(self): sec_group = self.security_groups.get(name="other_group") api.network.security_group_delete( IsA(http.HttpRequest), sec_group.id).AndRaise(self.exceptions.nova) self.mox.ReplayAll() form_data = {"action": "security_groups__delete__%s" % sec_group.id} req = self.factory.post(INDEX_URL, form_data) table = tables.SecurityGroupsTable(req, self.security_groups.list()) handled = table.maybe_handle() self.assertEqual(strip_absolute_base(handled['location']), INDEX_URL) class SecurityGroupsNovaNeutronDriverTests(SecurityGroupsViewTests): secgroup_backend = 'nova' def setUp(self): super(SecurityGroupsNovaNeutronDriverTests, self).setUp() self._sec_groups_orig = self.security_groups self.security_groups = self.security_groups_uuid self._sec_group_rules_orig = self.security_group_rules self.security_group_rules = self.security_group_rules_uuid sec_group = self.security_groups.first() self.detail_url = reverse('horizon:project:access_and_security:' 'security_groups:detail', args=[sec_group.id]) self.edit_url = reverse('horizon:project:access_and_security:' 'security_groups:add_rule', args=[sec_group.id]) def tearDown(self): self.security_groups = self._sec_groups_orig self.security_group_rules = self._sec_group_rules_orig super(SecurityGroupsNovaNeutronDriverTests, self).tearDown() class SecurityGroupsNeutronTests(SecurityGroupsViewTests): secgroup_backend = 'neutron' def setUp(self): super(SecurityGroupsNeutronTests, self).setUp() self._sec_groups_orig = self.security_groups self.security_groups = self.q_secgroups self._sec_group_rules_orig = self.security_group_rules self.security_group_rules = self.q_secgroup_rules sec_group = self.security_groups.first() self.detail_url = reverse('horizon:project:access_and_security:' 'security_groups:detail', args=[sec_group.id]) self.edit_url = reverse('horizon:project:access_and_security:' 'security_groups:add_rule', args=[sec_group.id]) def tearDown(self): self.security_groups = self._sec_groups_orig self.security_group_rules = self._sec_group_rules_orig super(SecurityGroupsNeutronTests, self).tearDown() def _get_source_group_rule(self): for rule in self.security_group_rules.list(): if rule.group: return rule raise Exception("No matches found.") # Additional tests for Neutron Security Group original features @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list', 'security_group_backend')}) def test_detail_add_rule_custom_protocol(self): sec_group = self.security_groups.first() sec_group_list = self.security_groups.list() rule = self.security_group_rules.first() api.network.security_group_backend( IsA(http.HttpRequest)).AndReturn(self.secgroup_backend) api.network.security_group_rule_create(IsA(http.HttpRequest), sec_group.id, 'ingress', 'IPv6', 37, None, None, 'fe80::/48', None).AndReturn(rule) api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', 'id': sec_group.id, 'rule_menu': 'custom', 'direction': 'ingress', 'port_or_range': 'port', 'ip_protocol': 37, 'cidr': 'fe80::/48', 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertRedirectsNoFollow(res, self.detail_url) @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list', 'security_group_backend')}) def test_detail_add_rule_egress(self): sec_group = self.security_groups.first() sec_group_list = self.security_groups.list() rule = self.security_group_rules.first() api.network.security_group_backend( IsA(http.HttpRequest)).AndReturn(self.secgroup_backend) api.network.security_group_rule_create(IsA(http.HttpRequest), sec_group.id, 'egress', 'IPv4', 'udp', 80, 80, '10.1.1.0/24', None).AndReturn(rule) api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', 'id': sec_group.id, 'direction': 'egress', 'rule_menu': 'udp', 'port_or_range': 'port', 'port': 80, 'cidr': '10.1.1.0/24', 'remote': 'cidr'} res = self.client.post(self.edit_url, formData) self.assertRedirectsNoFollow(res, self.detail_url) @test.create_stubs({api.network: ('security_group_rule_create', 'security_group_list', 'security_group_backend')}) def test_detail_add_rule_source_group_with_direction_ethertype(self): sec_group = self.security_groups.first() sec_group_list = self.security_groups.list() rule = self._get_source_group_rule() api.network.security_group_backend( IsA(http.HttpRequest)).AndReturn(self.secgroup_backend) api.network.security_group_rule_create( IsA(http.HttpRequest), sec_group.id, 'egress', # ethertype is empty for source_group of Nova Security Group 'IPv6', rule.ip_protocol, int(rule.from_port), int(rule.to_port), None, u'%s' % sec_group.id).AndReturn(rule) api.network.security_group_list( IsA(http.HttpRequest)).AndReturn(sec_group_list) self.mox.ReplayAll() formData = {'method': 'AddRule', 'id': sec_group.id, 'direction': 'egress', 'port_or_range': 'port', 'port': rule.from_port, 'rule_menu': rule.ip_protocol, 'cidr': '0.0.0.0/0', 'security_group': sec_group.id, 'remote': 'sg', 'ethertype': 'IPv6'} res = self.client.post(self.edit_url, formData) self.assertRedirectsNoFollow(res, self.detail_url)
apache-2.0
[ 3, 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 6029, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 16004, 199, 199, 504, 1639, 14, 2190, 492, 2202, 221, 327, 8151, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 221, 327, 8151, 199, 504, 1639, 492, 1455, 199, 199, 504, 18610, 492, 29719, 221, 327, 8151, 199, 199, 504, 13869, 63, 9743, 492, 2986, 199, 504, 13869, 63, 9743, 14, 396, 492, 10897, 465, 511, 199, 199, 504, 13869, 63, 9743, 14, 30424, 14, 1715, 14, 2732, 63, 460, 63, 4416, 3134, 272, 6391, 63, 2634, 492, 6716, 421, 199, 10215, 63, 2632, 275, 3837, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 26, 1080, 358, 199, 4254, 63, 8366, 63, 2632, 275, 3837, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 4881, 717, 283, 4416, 63, 2634, 26, 981, 358, 421, 199, 318, 6202, 63, 6116, 63, 1095, 8, 2302, 304, 272, 372, 5108, 14, 1294, 8, 1751, 14, 2864, 6613, 12, 413, 15786, 17, 61, 421, 199, 533, 13863, 10177, 2768, 2925, 8, 396, 14, 1746, 304, 272, 6513, 923, 63, 4620, 275, 283, 6765, 7, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 7676, 10177, 2768, 2925, 12, 291, 680, 5996, 342, 267, 6513, 63, 923, 275, 291, 14, 4416, 63, 2634, 14, 2246, 342, 267, 291, 14, 5506, 63, 633, 275, 3837, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 4881, 3303, 283, 4416, 63, 2634, 26, 5506, 297, 3303, 1249, 1524, 3321, 63, 923, 14, 344, 566, 267, 291, 14, 3773, 63, 633, 275, 3837, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 4881, 1816, 283, 4416, 63, 2634, 26, 525, 63, 2200, 297, 1816, 1249, 1524, 3321, 63, 923, 14, 344, 566, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 1200, 26, 661, 4416, 63, 923, 63, 362, 9538, 1552, 272, 347, 511, 63, 873, 63, 4416, 63, 2634, 63, 362, 8, 277, 304, 267, 6513, 63, 923, 275, 291, 14, 4416, 63, 2634, 14, 2246, 342, 267, 2986, 14, 1200, 14, 4416, 63, 923, 63, 362, 8, 14104, 8, 1014, 14, 10441, 395, 3147, 6513, 63, 923, 14, 344, 680, 8572, 8, 3321, 63, 923, 9, 267, 291, 14, 6625, 14, 12982, 342, 398, 522, 275, 291, 14, 1258, 14, 362, 8, 4471, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 4881, 4228, 283, 4416, 63, 2634, 26, 873, 297, 4228, 1249, 1524, 3321, 63, 923, 14, 344, 2459, 267, 291, 14, 19661, 8, 470, 12, 355, 283, 1715, 15, 2732, 63, 460, 63, 4416, 15, 4416, 63, 2634, 15607, 873, 14, 1360, 358, 267, 291, 14, 629, 8, 470, 14, 1100, 459, 4416, 63, 923, 2278, 354, 12, 586, 6513, 63, 923, 14, 354, 9, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 1200, 26, 661, 4416, 63, 923, 63, 873, 297, 4228, 283, 4416, 63, 923, 63, 362, 22220, 272, 347, 511, 63, 873, 63, 4416, 63, 2634, 63, 1932, 8, 277, 304, 267, 6513, 63, 923, 275, 291, 14, 4416, 63, 2634, 14, 362, 8, 354, 628, 1848, 63, 923, 531, 267, 2986, 14, 1200, 14, 4416, 63, 923, 63, 873, 8, 14104, 8, 1014, 14, 10441, 395, 4318, 620, 8, 3321, 63, 923, 14, 344, 395, 4318, 6513, 63, 923, 14, 354, 12, 4318, 6513, 63, 923, 14, 1802, 9, 971, 288, 1275, 8572, 8, 3321, 63, 923, 9, 267, 2986, 14, 1200, 14, 4416, 63, 923, 63, 362, 8, 14104, 8, 1014, 14, 10441, 395, 3147, 6513, 63, 923, 14, 344, 680, 8572, 8, 3321, 63, 923, 9, 267, 291, 14, 6625, 14, 12982, 342, 398, 1824, 1451, 275, 791, 765, 356, 283, 4152, 2448, 297, 490, 283, 344, 356, 6513, 63, 923, 14, 344, 12, 490, 283, 354, 356, 6513, 63, 923, 14, 354, 12, 490, 283, 1802, 356, 6513, 63, 923, 14, 1802, 93, 398, 1678, 63, 633, 275, 3837, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 4881, 2490, 283, 4416, 63, 2634, 26, 873, 297, 2490, 1249, 1524, 3321, 63, 923, 14, 344, 566, 267, 522, 275, 291, 14, 1258, 14, 1932, 8, 873, 63, 633, 12, 1824, 1451, 9, 267, 291, 14, 17466, 1944, 18696, 8, 470, 12, 17055, 63, 2632, 9, 339, 347, 511, 63, 981, 63, 4416, 63, 2634, 63, 362, 8, 277, 304, 267, 522, 275, 291, 14, 1258, 14, 362, 8, 4254, 63, 8366, 63, 2632, 9, 267, 291, 14, 19661, 8, 470, 12, 490, 283, 1715, 15, 2732, 63, 460, 63, 4416, 15, 4416, 63, 2634, 15, 981, 14, 1360, 358, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 1200, 26, 661, 4416, 63, 923, 63, 981, 9538, 1552, 272, 347, 511, 63, 981, 63, 4416, 63, 2634, 63, 1932, 8, 277, 304, 267, 6513, 63, 923, 275, 291, 14, 4416, 63, 2634, 14, 2246, 342, 267, 2986, 14, 1200, 14, 4416, 63, 923, 63, 981, 8, 14104, 8, 1014, 14, 10441, 395, 4318, 6513, 63, 923, 14, 354 ]
[ 6695, 26, 20849, 29, 20, 20105, 29, 20, 25966, 29, 20, 199, 199, 3, 1898, 6029, 1910, 5703, 24230, 598, 27639, 465, 11159, 701, 314, 199, 3, 30660, 402, 314, 20548, 437, 281, 265, 3844, 7769, 436, 19326, 9516, 4633, 14, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 1898, 6029, 653, 2871, 7586, 12, 3277, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 199, 646, 16004, 199, 199, 504, 1639, 14, 2190, 492, 2202, 221, 327, 8151, 199, 504, 1639, 14, 1018, 14, 16522, 492, 3837, 221, 327, 8151, 199, 504, 1639, 492, 1455, 199, 199, 504, 18610, 492, 29719, 221, 327, 8151, 199, 199, 504, 13869, 63, 9743, 492, 2986, 199, 504, 13869, 63, 9743, 14, 396, 492, 10897, 465, 511, 199, 199, 504, 13869, 63, 9743, 14, 30424, 14, 1715, 14, 2732, 63, 460, 63, 4416, 3134, 272, 6391, 63, 2634, 492, 6716, 421, 199, 10215, 63, 2632, 275, 3837, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 26, 1080, 358, 199, 4254, 63, 8366, 63, 2632, 275, 3837, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 4881, 717, 283, 4416, 63, 2634, 26, 981, 358, 421, 199, 318, 6202, 63, 6116, 63, 1095, 8, 2302, 304, 272, 372, 5108, 14, 1294, 8, 1751, 14, 2864, 6613, 12, 413, 15786, 17, 61, 421, 199, 533, 13863, 10177, 2768, 2925, 8, 396, 14, 1746, 304, 272, 6513, 923, 63, 4620, 275, 283, 6765, 7, 339, 347, 3613, 8, 277, 304, 267, 1613, 8, 7676, 10177, 2768, 2925, 12, 291, 680, 5996, 342, 267, 6513, 63, 923, 275, 291, 14, 4416, 63, 2634, 14, 2246, 342, 267, 291, 14, 5506, 63, 633, 275, 3837, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 4881, 3303, 283, 4416, 63, 2634, 26, 5506, 297, 3303, 1249, 1524, 3321, 63, 923, 14, 344, 566, 267, 291, 14, 3773, 63, 633, 275, 3837, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 4881, 1816, 283, 4416, 63, 2634, 26, 525, 63, 2200, 297, 1816, 1249, 1524, 3321, 63, 923, 14, 344, 566, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 1200, 26, 661, 4416, 63, 923, 63, 362, 9538, 1552, 272, 347, 511, 63, 873, 63, 4416, 63, 2634, 63, 362, 8, 277, 304, 267, 6513, 63, 923, 275, 291, 14, 4416, 63, 2634, 14, 2246, 342, 267, 2986, 14, 1200, 14, 4416, 63, 923, 63, 362, 8, 14104, 8, 1014, 14, 10441, 395, 3147, 6513, 63, 923, 14, 344, 680, 8572, 8, 3321, 63, 923, 9, 267, 291, 14, 6625, 14, 12982, 342, 398, 522, 275, 291, 14, 1258, 14, 362, 8, 4471, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 4881, 4228, 283, 4416, 63, 2634, 26, 873, 297, 4228, 1249, 1524, 3321, 63, 923, 14, 344, 2459, 267, 291, 14, 19661, 8, 470, 12, 355, 283, 1715, 15, 2732, 63, 460, 63, 4416, 15, 4416, 63, 2634, 15607, 873, 14, 1360, 358, 267, 291, 14, 629, 8, 470, 14, 1100, 459, 4416, 63, 923, 2278, 354, 12, 586, 6513, 63, 923, 14, 354, 9, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 1200, 26, 661, 4416, 63, 923, 63, 873, 297, 4228, 283, 4416, 63, 923, 63, 362, 22220, 272, 347, 511, 63, 873, 63, 4416, 63, 2634, 63, 1932, 8, 277, 304, 267, 6513, 63, 923, 275, 291, 14, 4416, 63, 2634, 14, 362, 8, 354, 628, 1848, 63, 923, 531, 267, 2986, 14, 1200, 14, 4416, 63, 923, 63, 873, 8, 14104, 8, 1014, 14, 10441, 395, 4318, 620, 8, 3321, 63, 923, 14, 344, 395, 4318, 6513, 63, 923, 14, 354, 12, 4318, 6513, 63, 923, 14, 1802, 9, 971, 288, 1275, 8572, 8, 3321, 63, 923, 9, 267, 2986, 14, 1200, 14, 4416, 63, 923, 63, 362, 8, 14104, 8, 1014, 14, 10441, 395, 3147, 6513, 63, 923, 14, 344, 680, 8572, 8, 3321, 63, 923, 9, 267, 291, 14, 6625, 14, 12982, 342, 398, 1824, 1451, 275, 791, 765, 356, 283, 4152, 2448, 297, 490, 283, 344, 356, 6513, 63, 923, 14, 344, 12, 490, 283, 354, 356, 6513, 63, 923, 14, 354, 12, 490, 283, 1802, 356, 6513, 63, 923, 14, 1802, 93, 398, 1678, 63, 633, 275, 3837, 360, 16561, 26, 1715, 26, 2732, 63, 460, 63, 4416, 4881, 2490, 283, 4416, 63, 2634, 26, 873, 297, 2490, 1249, 1524, 3321, 63, 923, 14, 344, 566, 267, 522, 275, 291, 14, 1258, 14, 1932, 8, 873, 63, 633, 12, 1824, 1451, 9, 267, 291, 14, 17466, 1944, 18696, 8, 470, 12, 17055, 63, 2632, 9, 339, 347, 511, 63, 981, 63, 4416, 63, 2634, 63, 362, 8, 277, 304, 267, 522, 275, 291, 14, 1258, 14, 362, 8, 4254, 63, 8366, 63, 2632, 9, 267, 291, 14, 19661, 8, 470, 12, 490, 283, 1715, 15, 2732, 63, 460, 63, 4416, 15, 4416, 63, 2634, 15, 981, 14, 1360, 358, 339, 768, 396, 14, 981, 63, 8957, 2561, 1246, 14, 1200, 26, 661, 4416, 63, 923, 63, 981, 9538, 1552, 272, 347, 511, 63, 981, 63, 4416, 63, 2634, 63, 1932, 8, 277, 304, 267, 6513, 63, 923, 275, 291, 14, 4416, 63, 2634, 14, 2246, 342, 267, 2986, 14, 1200, 14, 4416, 63, 923, 63, 981, 8, 14104, 8, 1014, 14, 10441, 395, 4318, 6513,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1, 1, 1, 1, 1, 1, 1 ]
winklerand/pandas
pandas/tests/reshape/test_merge_ordered.py
2
2966
import pandas as pd from pandas import DataFrame, merge_ordered from pandas.util import testing as tm from pandas.util.testing import assert_frame_equal from numpy import nan class TestMergeOrdered(object): def setup_method(self, method): self.left = DataFrame({'key': ['a', 'c', 'e'], 'lvalue': [1, 2., 3]}) self.right = DataFrame({'key': ['b', 'c', 'd', 'f'], 'rvalue': [1, 2, 3., 4]}) def test_basic(self): result = merge_ordered(self.left, self.right, on='key') expected = DataFrame({'key': ['a', 'b', 'c', 'd', 'e', 'f'], 'lvalue': [1, nan, 2, nan, 3, nan], 'rvalue': [nan, 1, 2, 3, nan, 4]}) assert_frame_equal(result, expected) def test_ffill(self): result = merge_ordered( self.left, self.right, on='key', fill_method='ffill') expected = DataFrame({'key': ['a', 'b', 'c', 'd', 'e', 'f'], 'lvalue': [1., 1, 2, 2, 3, 3.], 'rvalue': [nan, 1, 2, 3, 3, 4]}) assert_frame_equal(result, expected) def test_multigroup(self): left = pd.concat([self.left, self.left], ignore_index=True) left['group'] = ['a'] * 3 + ['b'] * 3 result = merge_ordered(left, self.right, on='key', left_by='group', fill_method='ffill') expected = DataFrame({'key': ['a', 'b', 'c', 'd', 'e', 'f'] * 2, 'lvalue': [1., 1, 2, 2, 3, 3.] * 2, 'rvalue': [nan, 1, 2, 3, 3, 4] * 2}) expected['group'] = ['a'] * 6 + ['b'] * 6 assert_frame_equal(result, expected.loc[:, result.columns]) result2 = merge_ordered(self.right, left, on='key', right_by='group', fill_method='ffill') assert_frame_equal(result, result2.loc[:, result.columns]) result = merge_ordered(left, self.right, on='key', left_by='group') assert result['group'].notna().all() def test_merge_type(self): class NotADataFrame(DataFrame): @property def _constructor(self): return NotADataFrame nad = NotADataFrame(self.left) result = nad.merge(self.right, on='key') assert isinstance(result, NotADataFrame) def test_empty_sequence_concat(self): # GH 9157 empty_pat = "[Nn]o objects" none_pat = "objects.*None" test_cases = [ ((), empty_pat), ([], empty_pat), ({}, empty_pat), ([None], none_pat), ([None, None], none_pat) ] for df_seq, pattern in test_cases: tm.assert_raises_regex(ValueError, pattern, pd.concat, df_seq) pd.concat([pd.DataFrame()]) pd.concat([None, pd.DataFrame()]) pd.concat([pd.DataFrame(), None])
bsd-3-clause
[ 646, 10634, 465, 6454, 199, 504, 10634, 492, 10071, 12, 5389, 63, 8235, 199, 504, 10634, 14, 1974, 492, 5343, 465, 7352, 199, 504, 10634, 14, 1974, 14, 4776, 492, 702, 63, 1943, 63, 1452, 199, 199, 504, 2680, 492, 12055, 421, 199, 533, 1379, 11359, 22567, 8, 785, 304, 339, 347, 3272, 63, 765, 8, 277, 12, 1083, 304, 267, 291, 14, 3039, 275, 10071, 3252, 498, 356, 788, 65, 297, 283, 67, 297, 283, 69, 995, 3044, 283, 76, 585, 356, 359, 17, 12, 499, 2020, 650, 13412, 398, 291, 14, 1019, 275, 10071, 3252, 498, 356, 788, 66, 297, 283, 67, 297, 283, 68, 297, 283, 70, 995, 1816, 283, 82, 585, 356, 359, 17, 12, 499, 12, 650, 2020, 841, 13412, 339, 347, 511, 63, 4316, 8, 277, 304, 267, 754, 275, 5389, 63, 8235, 8, 277, 14, 3039, 12, 291, 14, 1019, 12, 641, 534, 498, 358, 267, 1420, 275, 10071, 3252, 498, 356, 788, 65, 297, 283, 66, 297, 283, 67, 297, 283, 68, 297, 283, 69, 297, 283, 70, 995, 2892, 283, 76, 585, 356, 359, 17, 12, 12055, 12, 499, 12, 12055, 12, 650, 12, 12055, 467, 2892, 283, 82, 585, 356, 359, 4304, 12, 413, 12, 499, 12, 650, 12, 12055, 12, 841, 13412, 398, 702, 63, 1943, 63, 1452, 8, 1099, 12, 1420, 9, 339, 347, 511, 63, 70, 4498, 8, 277, 304, 267, 754, 275, 5389, 63, 8235, 8, 288, 291, 14, 3039, 12, 291, 14, 1019, 12, 641, 534, 498, 297, 5554, 63, 765, 534, 70, 4498, 358, 267, 1420, 275, 10071, 3252, 498, 356, 788, 65, 297, 283, 66, 297, 283, 67, 297, 283, 68, 297, 283, 69, 297, 283, 70, 995, 2892, 283, 76, 585, 356, 359, 17, 2020, 413, 12, 499, 12, 499, 12, 650, 12, 650, 8333, 2892, 283, 82, 585, 356, 359, 4304, 12, 413, 12, 499, 12, 650, 12, 650, 12, 841, 13412, 267, 702, 63, 1943, 63, 1452, 8, 1099, 12, 1420, 9, 339, 347, 511, 63, 3029, 923, 8, 277, 304, 267, 3602, 275, 6454, 14, 9419, 779, 277, 14, 3039, 12, 291, 14, 3039, 467, 3686, 63, 1080, 29, 549, 9, 398, 3602, 459, 923, 418, 275, 788, 65, 418, 627, 650, 435, 788, 66, 418, 627, 650, 398, 754, 275, 5389, 63, 8235, 8, 3039, 12, 291, 14, 1019, 12, 641, 534, 498, 297, 3602, 63, 991, 534, 923, 297, 3044, 5554, 63, 765, 534, 70, 4498, 358, 267, 1420, 275, 10071, 3252, 498, 356, 788, 65, 297, 283, 66, 297, 283, 67, 297, 283, 68, 297, 283, 69, 297, 283, 70, 418, 627, 499, 12, 2892, 283, 76, 585, 356, 359, 17, 2020, 413, 12, 499, 12, 499, 12, 650, 12, 650, 19784, 627, 499, 12, 2892, 283, 82, 585, 356, 359, 4304, 12, 413, 12, 499, 12, 650, 12, 650, 12, 841, 61, 627, 499, 1552, 267, 1420, 459, 923, 418, 275, 788, 65, 418, 627, 1227, 435, 788, 66, 418, 627, 1227, 398, 702, 63, 1943, 63, 1452, 8, 1099, 12, 1420, 14, 2102, 3981, 754, 14, 3406, 566, 398, 754, 18, 275, 5389, 63, 8235, 8, 277, 14, 1019, 12, 3602, 12, 641, 534, 498, 297, 2451, 63, 991, 534, 923, 297, 1816, 5554, 63, 765, 534, 70, 4498, 358, 267, 702, 63, 1943, 63, 1452, 8, 1099, 12, 754, 18, 14, 2102, 3981, 754, 14, 3406, 566, 398, 754, 275, 5389, 63, 8235, 8, 3039, 12, 291, 14, 1019, 12, 641, 534, 498, 297, 3602, 63, 991, 534, 923, 358, 267, 702, 754, 459, 923, 2278, 1397, 3540, 1252, 452, 342, 339, 347, 511, 63, 5628, 63, 466, 8, 277, 304, 267, 1021, 2832, 33, 9205, 8, 9205, 304, 953, 768, 1829, 288, 347, 485, 1880, 8, 277, 304, 355, 372, 2832, 33, 9205, 398, 302, 350, 275, 2832, 33, 9205, 8, 277, 14, 3039, 9, 267, 754, 275, 302, 350, 14, 5628, 8, 277, 14, 1019, 12, 641, 534, 498, 358, 398, 702, 1228, 8, 1099, 12, 2832, 33, 9205, 9, 339, 347, 511, 63, 1667, 63, 4041, 63, 9419, 8, 277, 304, 267, 327, 20321, 1749, 10823, 267, 2701, 63, 10853, 275, 7369, 46, 78, 61, 79, 2251, 2, 267, 7179, 63, 10853, 275, 298, 1462, 2795, 403, 2, 267, 511, 63, 9403, 275, 359, 288, 334, 1062, 2701, 63, 10853, 395, 288, 23293, 2701, 63, 10853, 395, 288, 11459, 1386, 2701, 63, 10853, 395, 288, 7287, 403, 467, 7179, 63, 10853, 395, 288, 7287, 403, 12, 488, 467, 7179, 63, 10853, 9, 267, 1622, 267, 367, 4051, 63, 3610, 12, 3851, 315, 511, 63, 9403, 26, 288, 7352, 14, 479, 63, 3536, 63, 3821, 8, 3393, 12, 3851, 12, 6454, 14, 9419, 12, 4051, 63, 3610, 9, 398, 6454, 14, 9419, 779, 8961, 14, 9205, 9383, 267, 6454, 14, 9419, 779, 403, 12, 6454, 14, 9205, 9383, 267, 6454, 14, 9419, 779, 8961, 14, 9205, 1062, 488, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 10634, 465, 6454, 199, 504, 10634, 492, 10071, 12, 5389, 63, 8235, 199, 504, 10634, 14, 1974, 492, 5343, 465, 7352, 199, 504, 10634, 14, 1974, 14, 4776, 492, 702, 63, 1943, 63, 1452, 199, 199, 504, 2680, 492, 12055, 421, 199, 533, 1379, 11359, 22567, 8, 785, 304, 339, 347, 3272, 63, 765, 8, 277, 12, 1083, 304, 267, 291, 14, 3039, 275, 10071, 3252, 498, 356, 788, 65, 297, 283, 67, 297, 283, 69, 995, 3044, 283, 76, 585, 356, 359, 17, 12, 499, 2020, 650, 13412, 398, 291, 14, 1019, 275, 10071, 3252, 498, 356, 788, 66, 297, 283, 67, 297, 283, 68, 297, 283, 70, 995, 1816, 283, 82, 585, 356, 359, 17, 12, 499, 12, 650, 2020, 841, 13412, 339, 347, 511, 63, 4316, 8, 277, 304, 267, 754, 275, 5389, 63, 8235, 8, 277, 14, 3039, 12, 291, 14, 1019, 12, 641, 534, 498, 358, 267, 1420, 275, 10071, 3252, 498, 356, 788, 65, 297, 283, 66, 297, 283, 67, 297, 283, 68, 297, 283, 69, 297, 283, 70, 995, 2892, 283, 76, 585, 356, 359, 17, 12, 12055, 12, 499, 12, 12055, 12, 650, 12, 12055, 467, 2892, 283, 82, 585, 356, 359, 4304, 12, 413, 12, 499, 12, 650, 12, 12055, 12, 841, 13412, 398, 702, 63, 1943, 63, 1452, 8, 1099, 12, 1420, 9, 339, 347, 511, 63, 70, 4498, 8, 277, 304, 267, 754, 275, 5389, 63, 8235, 8, 288, 291, 14, 3039, 12, 291, 14, 1019, 12, 641, 534, 498, 297, 5554, 63, 765, 534, 70, 4498, 358, 267, 1420, 275, 10071, 3252, 498, 356, 788, 65, 297, 283, 66, 297, 283, 67, 297, 283, 68, 297, 283, 69, 297, 283, 70, 995, 2892, 283, 76, 585, 356, 359, 17, 2020, 413, 12, 499, 12, 499, 12, 650, 12, 650, 8333, 2892, 283, 82, 585, 356, 359, 4304, 12, 413, 12, 499, 12, 650, 12, 650, 12, 841, 13412, 267, 702, 63, 1943, 63, 1452, 8, 1099, 12, 1420, 9, 339, 347, 511, 63, 3029, 923, 8, 277, 304, 267, 3602, 275, 6454, 14, 9419, 779, 277, 14, 3039, 12, 291, 14, 3039, 467, 3686, 63, 1080, 29, 549, 9, 398, 3602, 459, 923, 418, 275, 788, 65, 418, 627, 650, 435, 788, 66, 418, 627, 650, 398, 754, 275, 5389, 63, 8235, 8, 3039, 12, 291, 14, 1019, 12, 641, 534, 498, 297, 3602, 63, 991, 534, 923, 297, 3044, 5554, 63, 765, 534, 70, 4498, 358, 267, 1420, 275, 10071, 3252, 498, 356, 788, 65, 297, 283, 66, 297, 283, 67, 297, 283, 68, 297, 283, 69, 297, 283, 70, 418, 627, 499, 12, 2892, 283, 76, 585, 356, 359, 17, 2020, 413, 12, 499, 12, 499, 12, 650, 12, 650, 19784, 627, 499, 12, 2892, 283, 82, 585, 356, 359, 4304, 12, 413, 12, 499, 12, 650, 12, 650, 12, 841, 61, 627, 499, 1552, 267, 1420, 459, 923, 418, 275, 788, 65, 418, 627, 1227, 435, 788, 66, 418, 627, 1227, 398, 702, 63, 1943, 63, 1452, 8, 1099, 12, 1420, 14, 2102, 3981, 754, 14, 3406, 566, 398, 754, 18, 275, 5389, 63, 8235, 8, 277, 14, 1019, 12, 3602, 12, 641, 534, 498, 297, 2451, 63, 991, 534, 923, 297, 1816, 5554, 63, 765, 534, 70, 4498, 358, 267, 702, 63, 1943, 63, 1452, 8, 1099, 12, 754, 18, 14, 2102, 3981, 754, 14, 3406, 566, 398, 754, 275, 5389, 63, 8235, 8, 3039, 12, 291, 14, 1019, 12, 641, 534, 498, 297, 3602, 63, 991, 534, 923, 358, 267, 702, 754, 459, 923, 2278, 1397, 3540, 1252, 452, 342, 339, 347, 511, 63, 5628, 63, 466, 8, 277, 304, 267, 1021, 2832, 33, 9205, 8, 9205, 304, 953, 768, 1829, 288, 347, 485, 1880, 8, 277, 304, 355, 372, 2832, 33, 9205, 398, 302, 350, 275, 2832, 33, 9205, 8, 277, 14, 3039, 9, 267, 754, 275, 302, 350, 14, 5628, 8, 277, 14, 1019, 12, 641, 534, 498, 358, 398, 702, 1228, 8, 1099, 12, 2832, 33, 9205, 9, 339, 347, 511, 63, 1667, 63, 4041, 63, 9419, 8, 277, 304, 267, 327, 20321, 1749, 10823, 267, 2701, 63, 10853, 275, 7369, 46, 78, 61, 79, 2251, 2, 267, 7179, 63, 10853, 275, 298, 1462, 2795, 403, 2, 267, 511, 63, 9403, 275, 359, 288, 334, 1062, 2701, 63, 10853, 395, 288, 23293, 2701, 63, 10853, 395, 288, 11459, 1386, 2701, 63, 10853, 395, 288, 7287, 403, 467, 7179, 63, 10853, 395, 288, 7287, 403, 12, 488, 467, 7179, 63, 10853, 9, 267, 1622, 267, 367, 4051, 63, 3610, 12, 3851, 315, 511, 63, 9403, 26, 288, 7352, 14, 479, 63, 3536, 63, 3821, 8, 3393, 12, 3851, 12, 6454, 14, 9419, 12, 4051, 63, 3610, 9, 398, 6454, 14, 9419, 779, 8961, 14, 9205, 9383, 267, 6454, 14, 9419, 779, 403, 12, 6454, 14, 9205, 9383, 267, 6454, 14, 9419, 779, 8961, 14, 9205, 1062, 488, 566, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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py
4
3762
import imp import os import sys import warnings # opcode is not a virtualenv module, so we can use it to find the stdlib # Important! To work on pypy, this must be a module that resides in the # lib-python/modified-x.y.z directory import opcode dirname = os.path.dirname distutils_path = os.path.join(os.path.dirname(opcode.__file__), "distutils") if os.path.normpath(distutils_path) == os.path.dirname(os.path.normpath(__file__)): warnings.warn("The virtualenv distutils package at %s appears to be in the same location as the system distutils?") else: __path__.insert(0, distutils_path) # noqa: F821 real_distutils = imp.load_module("_virtualenv_distutils", None, distutils_path, ("", "", imp.PKG_DIRECTORY)) # Copy the relevant attributes try: __revision__ = real_distutils.__revision__ except AttributeError: pass __version__ = real_distutils.__version__ from distutils import dist, sysconfig # isort:skip try: basestring except NameError: basestring = str # patch build_ext (distutils doesn't know how to get the libs directory # path on windows - it hardcodes the paths around the patched sys.prefix) if sys.platform == "win32": from distutils.command.build_ext import build_ext as old_build_ext class build_ext(old_build_ext): def finalize_options(self): if self.library_dirs is None: self.library_dirs = [] elif isinstance(self.library_dirs, basestring): self.library_dirs = self.library_dirs.split(os.pathsep) self.library_dirs.insert(0, os.path.join(sys.real_prefix, "Libs")) old_build_ext.finalize_options(self) from distutils.command import build_ext as build_ext_module build_ext_module.build_ext = build_ext # distutils.dist patches: old_find_config_files = dist.Distribution.find_config_files def find_config_files(self): found = old_find_config_files(self) if os.name == "posix": user_filename = ".pydistutils.cfg" else: user_filename = "pydistutils.cfg" user_filename = os.path.join(sys.prefix, user_filename) if os.path.isfile(user_filename): for item in list(found): if item.endswith("pydistutils.cfg"): found.remove(item) found.append(user_filename) return found dist.Distribution.find_config_files = find_config_files # distutils.sysconfig patches: old_get_python_inc = sysconfig.get_python_inc def sysconfig_get_python_inc(plat_specific=0, prefix=None): if prefix is None: prefix = sys.real_prefix return old_get_python_inc(plat_specific, prefix) sysconfig_get_python_inc.__doc__ = old_get_python_inc.__doc__ sysconfig.get_python_inc = sysconfig_get_python_inc old_get_python_lib = sysconfig.get_python_lib def sysconfig_get_python_lib(plat_specific=0, standard_lib=0, prefix=None): if standard_lib and prefix is None: prefix = sys.real_prefix return old_get_python_lib(plat_specific, standard_lib, prefix) sysconfig_get_python_lib.__doc__ = old_get_python_lib.__doc__ sysconfig.get_python_lib = sysconfig_get_python_lib old_get_config_vars = sysconfig.get_config_vars def sysconfig_get_config_vars(*args): real_vars = old_get_config_vars(*args) if sys.platform == "win32": lib_dir = os.path.join(sys.real_prefix, "libs") if isinstance(real_vars, dict) and "LIBDIR" not in real_vars: real_vars["LIBDIR"] = lib_dir # asked for all elif isinstance(real_vars, list) and "LIBDIR" in args: real_vars = real_vars + [lib_dir] # asked for list return real_vars sysconfig_get_config_vars.__doc__ = old_get_config_vars.__doc__ sysconfig.get_config_vars = sysconfig_get_config_vars
mit
[ 646, 1742, 199, 646, 747, 199, 646, 984, 199, 646, 3598, 199, 199, 3, 10508, 365, 440, 282, 19128, 859, 12, 880, 781, 883, 675, 652, 370, 2342, 314, 26678, 199, 3, 3161, 867, 1, 4005, 1736, 641, 1134, 647, 12, 642, 1471, 506, 282, 859, 626, 295, 19564, 315, 314, 199, 3, 1973, 13, 1548, 15, 5540, 13, 88, 14, 89, 14, 90, 2082, 199, 646, 10508, 199, 199, 3475, 275, 747, 14, 515, 14, 3475, 199, 199, 13350, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 14325, 855, 493, 10139, 298, 13350, 531, 199, 692, 747, 14, 515, 14, 9267, 8, 13350, 63, 515, 9, 508, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 9267, 3460, 493, 363, 2298, 272, 3598, 14, 4050, 480, 1918, 19128, 7065, 2559, 737, 450, 83, 11337, 370, 506, 315, 314, 2011, 2909, 465, 314, 2656, 7065, 18582, 199, 2836, 26, 272, 636, 515, 4343, 3176, 8, 16, 12, 7065, 63, 515, 9, 221, 327, 8151, 26, 481, 24, 2025, 272, 3363, 63, 13350, 275, 1742, 14, 912, 63, 578, 11008, 21611, 63, 13350, 401, 488, 12, 7065, 63, 515, 12, 24727, 4873, 1742, 14, 18150, 63, 16436, 430, 272, 327, 11247, 314, 12082, 3004, 272, 862, 26, 267, 636, 5792, 363, 275, 3363, 63, 13350, 855, 5792, 363, 272, 871, 4281, 26, 267, 986, 272, 636, 1023, 363, 275, 3363, 63, 13350, 855, 1023, 363, 199, 199, 504, 7065, 492, 2917, 12, 22381, 221, 327, 365, 361, 26, 2759, 199, 199, 893, 26, 272, 7116, 199, 2590, 12746, 26, 272, 7116, 275, 620, 199, 199, 3, 3371, 1900, 63, 832, 334, 13350, 3181, 1133, 5715, 4212, 370, 664, 314, 20314, 2082, 199, 3, 931, 641, 10061, 446, 652, 7508, 6021, 314, 3792, 6818, 314, 19483, 984, 14, 1861, 9, 199, 199, 692, 984, 14, 3246, 508, 298, 2676, 708, 582, 272, 687, 7065, 14, 1531, 14, 1506, 63, 832, 492, 1900, 63, 832, 465, 2269, 63, 1506, 63, 832, 339, 1021, 1900, 63, 832, 8, 1753, 63, 1506, 63, 832, 304, 267, 347, 17284, 63, 1419, 8, 277, 304, 288, 340, 291, 14, 4342, 63, 3220, 365, 488, 26, 355, 291, 14, 4342, 63, 3220, 275, 942, 288, 916, 1228, 8, 277, 14, 4342, 63, 3220, 12, 7116, 304, 355, 291, 14, 4342, 63, 3220, 275, 291, 14, 4342, 63, 3220, 14, 1294, 8, 736, 14, 17843, 9, 953, 291, 14, 4342, 63, 3220, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 904, 8, 1274, 14, 3093, 63, 1861, 12, 298, 13009, 1533, 2237, 288, 2269, 63, 1506, 63, 832, 14, 14450, 63, 1419, 8, 277, 9, 339, 687, 7065, 14, 1531, 492, 1900, 63, 832, 465, 1900, 63, 832, 63, 578, 339, 1900, 63, 832, 63, 578, 14, 1506, 63, 832, 275, 1900, 63, 832, 199, 199, 3, 7065, 14, 2686, 12385, 26, 199, 199, 1753, 63, 1623, 63, 888, 63, 1725, 275, 2917, 14, 8580, 14, 1623, 63, 888, 63, 1725, 421, 199, 318, 2342, 63, 888, 63, 1725, 8, 277, 304, 272, 1911, 275, 2269, 63, 1623, 63, 888, 63, 1725, 8, 277, 9, 272, 340, 747, 14, 354, 508, 298, 9228, 582, 267, 922, 63, 1501, 275, 3680, 647, 13350, 14, 4128, 2, 272, 587, 26, 267, 922, 63, 1501, 275, 298, 647, 13350, 14, 4128, 2, 272, 922, 63, 1501, 275, 747, 14, 515, 14, 904, 8, 1274, 14, 1861, 12, 922, 63, 1501, 9, 272, 340, 747, 14, 515, 14, 6292, 8, 751, 63, 1501, 304, 267, 367, 1242, 315, 769, 8, 4214, 304, 288, 340, 1242, 14, 4130, 480, 647, 13350, 14, 4128, 2349, 355, 1911, 14, 2168, 8, 1053, 9, 267, 1911, 14, 740, 8, 751, 63, 1501, 9, 272, 372, 1911, 421, 199, 2686, 14, 8580, 14, 1623, 63, 888, 63, 1725, 275, 2342, 63, 888, 63, 1725, 199, 199, 3, 7065, 14, 24030, 12385, 26, 199, 199, 1753, 63, 362, 63, 1548, 63, 6559, 275, 22381, 14, 362, 63, 1548, 63, 6559, 421, 199, 318, 22381, 63, 362, 63, 1548, 63, 6559, 8, 14156, 63, 6100, 29, 16, 12, 2403, 29, 403, 304, 272, 340, 2403, 365, 488, 26, 267, 2403, 275, 984, 14, 3093, 63, 1861, 272, 372, 2269, 63, 362, 63, 1548, 63, 6559, 8, 14156, 63, 6100, 12, 2403, 9, 421, 199, 24030, 63, 362, 63, 1548, 63, 6559, 855, 1301, 363, 275, 2269, 63, 362, 63, 1548, 63, 6559, 855, 1301, 363, 199, 24030, 14, 362, 63, 1548, 63, 6559, 275, 22381, 63, 362, 63, 1548, 63, 6559, 199, 199, 1753, 63, 362, 63, 1548, 63, 773, 275, 22381, 14, 362, 63, 1548, 63, 773, 421, 199, 318, 22381, 63, 362, 63, 1548, 63, 773, 8, 14156, 63, 6100, 29, 16, 12, 4465, 63, 773, 29, 16, 12, 2403, 29, 403, 304, 272, 340, 4465, 63, 773, 436, 2403, 365, 488, 26, 267, 2403, 275, 984, 14, 3093, 63, 1861, 272, 372, 2269, 63, 362, 63, 1548, 63, 773, 8, 14156, 63, 6100, 12, 4465, 63, 773, 12, 2403, 9, 421, 199, 24030, 63, 362, 63, 1548, 63, 773, 855, 1301, 363, 275, 2269, 63, 362, 63, 1548, 63, 773, 855, 1301, 363, 199, 24030, 14, 362, 63, 1548, 63, 773, 275, 22381, 63, 362, 63, 1548, 63, 773, 199, 199, 1753, 63, 362, 63, 888, 63, 2936, 275, 22381, 14, 362, 63, 888, 63, 2936, 421, 199, 318, 22381, 63, 362, 63, 888, 63, 2936, 2031, 589, 304, 272, 3363, 63, 2936, 275, 2269, 63, 362, 63, 888, 63, 2936, 2031, 589, 9, 272, 340, 984, 14, 3246, 508, 298, 2676, 708, 582, 267, 1973, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1274, 14, 3093, 63, 1861, 12, 298, 8450, 531, 267, 340, 1228, 8, 3093, 63, 2936, 12, 1211, 9, 436, 298, 5617, 3022, 2, 440, 315, 3363, 63, 2936, 26, 288, 3363, 63, 2936, 905, 5617, 3022, 937, 275, 1973, 63, 694, 221, 327, 20864, 367, 1006, 267, 916, 1228, 8, 3093, 63, 2936, 12, 769, 9, 436, 298, 5617, 3022, 2, 315, 1249, 26, 288, 3363, 63, 2936, 275, 3363, 63, 2936, 435, 359, 773, 63 ]
[ 1742, 199, 646, 747, 199, 646, 984, 199, 646, 3598, 199, 199, 3, 10508, 365, 440, 282, 19128, 859, 12, 880, 781, 883, 675, 652, 370, 2342, 314, 26678, 199, 3, 3161, 867, 1, 4005, 1736, 641, 1134, 647, 12, 642, 1471, 506, 282, 859, 626, 295, 19564, 315, 314, 199, 3, 1973, 13, 1548, 15, 5540, 13, 88, 14, 89, 14, 90, 2082, 199, 646, 10508, 199, 199, 3475, 275, 747, 14, 515, 14, 3475, 199, 199, 13350, 63, 515, 275, 747, 14, 515, 14, 904, 8, 736, 14, 515, 14, 3475, 8, 14325, 855, 493, 10139, 298, 13350, 531, 199, 692, 747, 14, 515, 14, 9267, 8, 13350, 63, 515, 9, 508, 747, 14, 515, 14, 3475, 8, 736, 14, 515, 14, 9267, 3460, 493, 363, 2298, 272, 3598, 14, 4050, 480, 1918, 19128, 7065, 2559, 737, 450, 83, 11337, 370, 506, 315, 314, 2011, 2909, 465, 314, 2656, 7065, 18582, 199, 2836, 26, 272, 636, 515, 4343, 3176, 8, 16, 12, 7065, 63, 515, 9, 221, 327, 8151, 26, 481, 24, 2025, 272, 3363, 63, 13350, 275, 1742, 14, 912, 63, 578, 11008, 21611, 63, 13350, 401, 488, 12, 7065, 63, 515, 12, 24727, 4873, 1742, 14, 18150, 63, 16436, 430, 272, 327, 11247, 314, 12082, 3004, 272, 862, 26, 267, 636, 5792, 363, 275, 3363, 63, 13350, 855, 5792, 363, 272, 871, 4281, 26, 267, 986, 272, 636, 1023, 363, 275, 3363, 63, 13350, 855, 1023, 363, 199, 199, 504, 7065, 492, 2917, 12, 22381, 221, 327, 365, 361, 26, 2759, 199, 199, 893, 26, 272, 7116, 199, 2590, 12746, 26, 272, 7116, 275, 620, 199, 199, 3, 3371, 1900, 63, 832, 334, 13350, 3181, 1133, 5715, 4212, 370, 664, 314, 20314, 2082, 199, 3, 931, 641, 10061, 446, 652, 7508, 6021, 314, 3792, 6818, 314, 19483, 984, 14, 1861, 9, 199, 199, 692, 984, 14, 3246, 508, 298, 2676, 708, 582, 272, 687, 7065, 14, 1531, 14, 1506, 63, 832, 492, 1900, 63, 832, 465, 2269, 63, 1506, 63, 832, 339, 1021, 1900, 63, 832, 8, 1753, 63, 1506, 63, 832, 304, 267, 347, 17284, 63, 1419, 8, 277, 304, 288, 340, 291, 14, 4342, 63, 3220, 365, 488, 26, 355, 291, 14, 4342, 63, 3220, 275, 942, 288, 916, 1228, 8, 277, 14, 4342, 63, 3220, 12, 7116, 304, 355, 291, 14, 4342, 63, 3220, 275, 291, 14, 4342, 63, 3220, 14, 1294, 8, 736, 14, 17843, 9, 953, 291, 14, 4342, 63, 3220, 14, 3176, 8, 16, 12, 747, 14, 515, 14, 904, 8, 1274, 14, 3093, 63, 1861, 12, 298, 13009, 1533, 2237, 288, 2269, 63, 1506, 63, 832, 14, 14450, 63, 1419, 8, 277, 9, 339, 687, 7065, 14, 1531, 492, 1900, 63, 832, 465, 1900, 63, 832, 63, 578, 339, 1900, 63, 832, 63, 578, 14, 1506, 63, 832, 275, 1900, 63, 832, 199, 199, 3, 7065, 14, 2686, 12385, 26, 199, 199, 1753, 63, 1623, 63, 888, 63, 1725, 275, 2917, 14, 8580, 14, 1623, 63, 888, 63, 1725, 421, 199, 318, 2342, 63, 888, 63, 1725, 8, 277, 304, 272, 1911, 275, 2269, 63, 1623, 63, 888, 63, 1725, 8, 277, 9, 272, 340, 747, 14, 354, 508, 298, 9228, 582, 267, 922, 63, 1501, 275, 3680, 647, 13350, 14, 4128, 2, 272, 587, 26, 267, 922, 63, 1501, 275, 298, 647, 13350, 14, 4128, 2, 272, 922, 63, 1501, 275, 747, 14, 515, 14, 904, 8, 1274, 14, 1861, 12, 922, 63, 1501, 9, 272, 340, 747, 14, 515, 14, 6292, 8, 751, 63, 1501, 304, 267, 367, 1242, 315, 769, 8, 4214, 304, 288, 340, 1242, 14, 4130, 480, 647, 13350, 14, 4128, 2349, 355, 1911, 14, 2168, 8, 1053, 9, 267, 1911, 14, 740, 8, 751, 63, 1501, 9, 272, 372, 1911, 421, 199, 2686, 14, 8580, 14, 1623, 63, 888, 63, 1725, 275, 2342, 63, 888, 63, 1725, 199, 199, 3, 7065, 14, 24030, 12385, 26, 199, 199, 1753, 63, 362, 63, 1548, 63, 6559, 275, 22381, 14, 362, 63, 1548, 63, 6559, 421, 199, 318, 22381, 63, 362, 63, 1548, 63, 6559, 8, 14156, 63, 6100, 29, 16, 12, 2403, 29, 403, 304, 272, 340, 2403, 365, 488, 26, 267, 2403, 275, 984, 14, 3093, 63, 1861, 272, 372, 2269, 63, 362, 63, 1548, 63, 6559, 8, 14156, 63, 6100, 12, 2403, 9, 421, 199, 24030, 63, 362, 63, 1548, 63, 6559, 855, 1301, 363, 275, 2269, 63, 362, 63, 1548, 63, 6559, 855, 1301, 363, 199, 24030, 14, 362, 63, 1548, 63, 6559, 275, 22381, 63, 362, 63, 1548, 63, 6559, 199, 199, 1753, 63, 362, 63, 1548, 63, 773, 275, 22381, 14, 362, 63, 1548, 63, 773, 421, 199, 318, 22381, 63, 362, 63, 1548, 63, 773, 8, 14156, 63, 6100, 29, 16, 12, 4465, 63, 773, 29, 16, 12, 2403, 29, 403, 304, 272, 340, 4465, 63, 773, 436, 2403, 365, 488, 26, 267, 2403, 275, 984, 14, 3093, 63, 1861, 272, 372, 2269, 63, 362, 63, 1548, 63, 773, 8, 14156, 63, 6100, 12, 4465, 63, 773, 12, 2403, 9, 421, 199, 24030, 63, 362, 63, 1548, 63, 773, 855, 1301, 363, 275, 2269, 63, 362, 63, 1548, 63, 773, 855, 1301, 363, 199, 24030, 14, 362, 63, 1548, 63, 773, 275, 22381, 63, 362, 63, 1548, 63, 773, 199, 199, 1753, 63, 362, 63, 888, 63, 2936, 275, 22381, 14, 362, 63, 888, 63, 2936, 421, 199, 318, 22381, 63, 362, 63, 888, 63, 2936, 2031, 589, 304, 272, 3363, 63, 2936, 275, 2269, 63, 362, 63, 888, 63, 2936, 2031, 589, 9, 272, 340, 984, 14, 3246, 508, 298, 2676, 708, 582, 267, 1973, 63, 694, 275, 747, 14, 515, 14, 904, 8, 1274, 14, 3093, 63, 1861, 12, 298, 8450, 531, 267, 340, 1228, 8, 3093, 63, 2936, 12, 1211, 9, 436, 298, 5617, 3022, 2, 440, 315, 3363, 63, 2936, 26, 288, 3363, 63, 2936, 905, 5617, 3022, 937, 275, 1973, 63, 694, 221, 327, 20864, 367, 1006, 267, 916, 1228, 8, 3093, 63, 2936, 12, 769, 9, 436, 298, 5617, 3022, 2, 315, 1249, 26, 288, 3363, 63, 2936, 275, 3363, 63, 2936, 435, 359, 773, 63, 0 ]
[ 1, 1, 1, 1, 1, 1, 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film/GoogleScraper/database.py
2
9289
# -*- coding: utf-8 -*- """ The database schema of GoogleScraper. There are four entities: ScraperSearch: Represents a call to GoogleScraper. A search job. SearchEngineResultsPage: Represents a SERP result page of a search_engine Link: Represents a LINK on a SERP Proxy: Stores all proxies and their statuses. Because searches repeat themselves and we avoid doing them again (caching), one SERP page can be assigned to more than one ScraperSearch. Therefore we need a n:m relationship. """ import datetime from urllib.parse import urlparse from sqlalchemy import Column, String, Integer, ForeignKey, Table, DateTime, Enum, Boolean from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, backref from sqlalchemy import create_engine, UniqueConstraint from sqlalchemy.orm import scoped_session from sqlalchemy.orm import sessionmaker Base = declarative_base() scraper_searches_serps = Table('scraper_searches_serps', Base.metadata, Column('scraper_search_id', Integer, ForeignKey('scraper_search.id')), Column('serp_id', Integer, ForeignKey('serp.id'))) class ScraperSearch(Base): __tablename__ = 'scraper_search' id = Column(Integer, primary_key=True) keyword_file = Column(String) number_search_engines_used = Column(Integer) used_search_engines = Column(String) number_proxies_used = Column(Integer) number_search_queries = Column(Integer) started_searching = Column(DateTime, default=datetime.datetime.utcnow) stopped_searching = Column(DateTime) serps = relationship( 'SearchEngineResultsPage', secondary=scraper_searches_serps, backref=backref('scraper_searches', uselist=True) ) def __str__(self): return '<ScraperSearch[{id}] scraped for {number_search_queries} unique keywords. Started scraping: {started_' \ 'searching} and stopped: {stopped_searching}>'.format(**self.__dict__) def __repr__(self): return self.__str__() class SearchEngineResultsPage(Base): __tablename__ = 'serp' id = Column(Integer, primary_key=True) status = Column(String, default='successful') search_engine_name = Column(String) scrape_method = Column(String) page_number = Column(Integer) requested_at = Column(DateTime, default=datetime.datetime.utcnow) requested_by = Column(String, default='127.0.0.1') # The string in the SERP that indicates how many results we got for the search term. num_results_for_query = Column(String, default='') # Whether we got any results at all. This is the same as len(serp.links) num_results = Column(Integer, default=-1) query = Column(String) # if the query was modified by the search engine because there weren't any # results, this variable is set to the query that was used instead. # Otherwise it remains empty. effective_query = Column(String, default='') # Whether the search engine has no results. # This is not the same as num_results, because some search engines # automatically search other similar search queries when they find no results. # Sometimes they have results for the query, but detect a spelling mistake and only # suggest an alternative. This is another case! # If no_results is true, then there weren't ANY RESULTS FOUND FOR THIS QUERY!!! But there # could have been results for an auto corrected query. no_results = Column(Boolean, default=False) def __str__(self): return '<SERP[{search_engine_name}] has [{num_results}] link results for query "{query}">'.format( **self.__dict__) def __repr__(self): return self.__str__() def has_no_results_for_query(self): """ Returns True if the original query did not yield any results. Returns False if either there are no serp entries, or the search engine auto corrected the query. """ return self.num_results == 0 or self.effective_query def set_values_from_parser(self, parser): """Populate itself from a parser object. Args: A parser object. """ self.num_results_for_query = parser.num_results_for_query self.num_results = parser.num_results self.effective_query = parser.effective_query self.no_results = parser.no_results for key, value in parser.search_results.items(): if isinstance(value, list): for link in value: parsed = urlparse(link['link']) # fill with nones to prevent key errors [link.update({key: None}) for key in ('snippet', 'title', 'visible_link') if key not in link] Link( link=link['link'], snippet=link['snippet'], title=link['title'], visible_link=link['visible_link'], domain=parsed.netloc, rank=link['rank'], serp=self, link_type=key ) def set_values_from_scraper(self, scraper): """Populate itself from a scraper object. A scraper may be any object of type: - SelScrape - HttpScrape - AsyncHttpScrape Args: A scraper object. """ self.query = scraper.query self.search_engine_name = scraper.search_engine_name self.scrape_method = scraper.scrape_method self.page_number = scraper.page_number self.requested_at = scraper.requested_at self.requested_by = scraper.requested_by self.status = scraper.status def was_correctly_requested(self): return self.status == 'successful' # Alias as a shorthand for working in the shell SERP = SearchEngineResultsPage class Link(Base): __tablename__ = 'link' id = Column(Integer, primary_key=True) title = Column(String) snippet = Column(String) link = Column(String) domain = Column(String) visible_link = Column(String) rank = Column(Integer) link_type = Column(String) serp_id = Column(Integer, ForeignKey('serp.id')) serp = relationship(SearchEngineResultsPage, backref=backref('links', uselist=True)) def __str__(self): return '<Link at rank {rank} has url: {link}>'.format(**self.__dict__) def __repr__(self): return self.__str__() class Proxy(Base): __tablename__ = 'proxy' id = Column(Integer, primary_key=True) ip = Column(String) hostname = Column(String) port = Column(Integer) proto = Column(Enum('socks5', 'socks4', 'http')) username = Column(String) password = Column(String) online = Column(Boolean) status = Column(String) checked_at = Column(DateTime) created_at = Column(DateTime, default=datetime.datetime.utcnow) city = Column(String) region = Column(String) country = Column(String) loc = Column(String) org = Column(String) postal = Column(String) UniqueConstraint(ip, port, name='unique_proxy') def __str__(self): return '<Proxy {ip}>'.format(**self.__dict__) def __repr__(self): return self.__str__() db_Proxy = Proxy class SearchEngine(Base): __tablename__ = 'search_engine' id = Column(Integer, primary_key=True) name = Column(String, unique=True) http_url = Column(String) selenium_url = Column(String) image_url = Column(String) class SearchEngineProxyStatus(Base): """Stores last proxy status for the given search engine. A proxy can either work on a search engine or not. """ __tablename__ = 'search_engine_proxy_status' id = Column(Integer, primary_key=True) proxy_id = Column(Integer, ForeignKey('proxy.id')) search_engine_id = Column(Integer, ForeignKey('search_engine.id')) available = Column(Boolean) last_check = Column(DateTime) def get_engine(config, path=None): """Return the sqlalchemy engine. Args: path: The path/name of the database to create/read from. Returns: The sqlalchemy engine. """ db_path = path if path else config.get('database_name', 'google_scraper') + '.db' echo = config.get('log_sqlalchemy', False) engine = create_engine('sqlite:///' + db_path, echo=echo, connect_args={'check_same_thread': False}) Base.metadata.create_all(engine) return engine def get_session(config, scoped=False, engine=None, path=None): if not engine: engine = get_engine(config, path=path) session_factory = sessionmaker( bind=engine, autoflush=True, autocommit=False, ) if scoped: ScopedSession = scoped_session(session_factory) return ScopedSession else: return session_factory def fixtures(config, session): """Add some base data.""" for se in config.get('supported_search_engines', []): if se: search_engine = session.query(SearchEngine).filter(SearchEngine.name == se).first() if not search_engine: session.add(SearchEngine(name=se)) session.commit()
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 1918, 3050, 4177, 402, 4475, 7181, 345, 529, 14, 199, 199, 10924, 787, 11648, 9045, 26, 339, 13916, 345, 529, 5278, 26, 21591, 282, 1240, 370, 4475, 7181, 345, 529, 14, 437, 2754, 3906, 14, 272, 8730, 8524, 6579, 3276, 26, 21591, 282, 428, 6758, 754, 2034, 402, 282, 2754, 63, 3908, 272, 10967, 26, 21591, 282, 19774, 641, 282, 428, 6758, 272, 12373, 26, 31299, 1006, 14942, 436, 3932, 24498, 14, 199, 199, 3655, 2651, 21858, 11982, 17279, 436, 781, 5126, 9689, 3062, 4020, 334, 22738, 395, 1373, 428, 6758, 2034, 199, 2425, 506, 7943, 370, 1655, 2419, 1373, 13916, 345, 529, 5278, 14, 21039, 781, 1929, 282, 302, 26, 77, 8931, 14, 199, 624, 199, 199, 646, 2197, 199, 504, 4011, 14, 1122, 492, 7097, 199, 504, 8335, 492, 4996, 12, 2624, 12, 7225, 12, 12718, 12, 6957, 12, 13686, 12, 11305, 12, 9411, 199, 504, 8335, 14, 832, 14, 12164, 1905, 492, 30191, 63, 1095, 199, 504, 8335, 14, 1025, 492, 8931, 12, 23412, 199, 504, 8335, 492, 1218, 63, 3908, 12, 18276, 8463, 199, 504, 8335, 14, 1025, 492, 27582, 63, 1730, 199, 504, 8335, 14, 1025, 492, 2351, 14367, 199, 199, 1563, 275, 30191, 63, 1095, 342, 199, 199, 12865, 529, 63, 1733, 397, 63, 332, 1190, 275, 6957, 360, 12865, 529, 63, 1733, 397, 63, 332, 1190, 297, 3523, 14, 2343, 12, 3044, 4996, 360, 12865, 529, 63, 1733, 63, 344, 297, 7225, 12, 12718, 360, 12865, 529, 63, 1733, 14, 344, 3855, 3044, 4996, 360, 332, 80, 63, 344, 297, 7225, 12, 12718, 360, 332, 80, 14, 344, 7058, 421, 199, 533, 13916, 345, 529, 5278, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 12865, 529, 63, 1733, 7, 339, 1305, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 4252, 63, 493, 275, 4996, 8, 1558, 9, 272, 1329, 63, 1733, 63, 30378, 63, 2972, 275, 4996, 8, 2674, 9, 272, 1202, 63, 1733, 63, 30378, 275, 4996, 8, 1558, 9, 272, 1329, 63, 17128, 63, 2972, 275, 4996, 8, 2674, 9, 272, 1329, 63, 1733, 63, 10590, 275, 4996, 8, 2674, 9, 272, 8239, 63, 1733, 316, 275, 4996, 8, 3926, 12, 849, 29, 2083, 14, 2083, 14, 10779, 9, 272, 15248, 63, 1733, 316, 275, 4996, 8, 3926, 9, 339, 8926, 1190, 275, 8931, 8, 267, 283, 5278, 8524, 6579, 3276, 297, 267, 13851, 29, 12865, 529, 63, 1733, 397, 63, 332, 1190, 12, 267, 23412, 29, 894, 1121, 360, 12865, 529, 63, 1733, 397, 297, 675, 513, 29, 549, 9, 272, 776, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2650, 7181, 345, 529, 5278, 59, 91, 344, 11049, 24514, 367, 469, 1955, 63, 1733, 63, 10590, 93, 3747, 7681, 14, 1933, 5015, 4061, 1330, 316, 26, 469, 8924, 8650, 971, 2049, 283, 1733, 316, 93, 436, 15248, 26, 469, 14661, 63, 1733, 316, 93, 22936, 908, 3682, 277, 855, 807, 3368, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 855, 495, 4533, 421, 199, 533, 8730, 8524, 6579, 3276, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 332, 80, 7, 339, 1305, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 2004, 275, 4996, 8, 1558, 12, 849, 534, 18157, 358, 272, 2754, 63, 3908, 63, 354, 275, 4996, 8, 1558, 9, 272, 10328, 321, 63, 765, 275, 4996, 8, 1558, 9, 272, 2034, 63, 1955, 275, 4996, 8, 2674, 9, 272, 5839, 63, 292, 275, 4996, 8, 3926, 12, 849, 29, 2083, 14, 2083, 14, 10779, 9, 272, 5839, 63, 991, 275, 4996, 8, 1558, 12, 849, 534, 4195, 14, 16, 14, 16, 14, 17, 358, 339, 327, 710, 1059, 315, 314, 428, 6758, 626, 9126, 4212, 5002, 2058, 781, 4788, 367, 314, 2754, 6707, 14, 272, 1967, 63, 2604, 63, 509, 63, 1131, 275, 4996, 8, 1558, 12, 849, 13275, 339, 327, 7480, 781, 4788, 1263, 2058, 737, 1006, 14, 961, 365, 314, 2011, 465, 822, 8, 332, 80, 14, 4614, 9, 272, 1967, 63, 2604, 275, 4996, 8, 2674, 12, 849, 4022, 17, 9, 339, 1827, 275, 4996, 8, 1558, 9, 339, 327, 340, 314, 1827, 1990, 6042, 701, 314, 2754, 6869, 2952, 2337, 781, 828, 1133, 1263, 272, 327, 2058, 12, 642, 1750, 365, 663, 370, 314, 1827, 626, 1990, 1202, 3140, 14, 272, 327, 6630, 652, 25803, 2701, 14, 272, 15826, 63, 1131, 275, 4996, 8, 1558, 12, 849, 13275, 339, 327, 7480, 314, 2754, 6869, 965, 949, 2058, 14, 272, 327, 961, 365, 440, 314, 2011, 465, 1967, 63, 2604, 12, 2952, 2005, 2754, 28156, 272, 327, 5847, 2754, 1163, 8545, 2754, 9212, 1380, 2985, 2342, 949, 2058, 14, 272, 327, 30094, 2985, 1172, 2058, 367, 314, 1827, 12, 1325, 9696, 282, 27928, 27572, 1728, 436, 1454, 272, 327, 18453, 376, 13943, 14, 961, 365, 4573, 1930, 1, 272, 327, 982, 949, 63, 2604, 365, 2549, 12, 2066, 2337, 781, 828, 1133, 1821, 20668, 51, 481, 47, 6131, 2381, 5749, 7813, 9418, 21512, 11017, 2337, 272, 327, 4293, 1172, 2757, 2058, 367, 376, 2599, 30156, 1827, 14, 272, 949, 63, 2604, 275, 4996, 8, 4082, 12, 849, 29, 797, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2650, 3279, 48, 59, 91, 1733, 63, 3908, 63, 354, 11049, 965, 8910, 1507, 63, 2604, 11049, 2142, 2058, 367, 1827, 5310, 1131, 93, 1743, 1370, 908, 8, 288, 1011, 277, 855, 807, 3368, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 855, 495, 4533, 339, 347, 965, 63, 889, 63, 2604, 63, 509, 63, 1131, 8, 277, 304, 267, 408, 267, 1803, 715, 340, 314, 3379, 1827, 8103, 440, 1995, 1263, 2058, 14, 267, 1803, 756, 340, 1902, 2337, 787, 949, 8926, 80, 4811, 12, 503, 314, 2754, 6869, 2599, 30156, 314, 1827, 14, 267, 408, 267, 372, 291, 14, 1507, 63, 2604, 508, 378, 503, 291, 14, 20427, 63, 1131, 339, 347, 663, 63, 1459, 63, 504, 63, 2087, 8, 277, 12, 1798, 304, 267, 408, 9606, 5434, 6337, 687, 282, 1798, 909, 14, 398, 3033, 26, 288, 437, 1798 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 199, 624, 199, 1918, 3050, 4177, 402, 4475, 7181, 345, 529, 14, 199, 199, 10924, 787, 11648, 9045, 26, 339, 13916, 345, 529, 5278, 26, 21591, 282, 1240, 370, 4475, 7181, 345, 529, 14, 437, 2754, 3906, 14, 272, 8730, 8524, 6579, 3276, 26, 21591, 282, 428, 6758, 754, 2034, 402, 282, 2754, 63, 3908, 272, 10967, 26, 21591, 282, 19774, 641, 282, 428, 6758, 272, 12373, 26, 31299, 1006, 14942, 436, 3932, 24498, 14, 199, 199, 3655, 2651, 21858, 11982, 17279, 436, 781, 5126, 9689, 3062, 4020, 334, 22738, 395, 1373, 428, 6758, 2034, 199, 2425, 506, 7943, 370, 1655, 2419, 1373, 13916, 345, 529, 5278, 14, 21039, 781, 1929, 282, 302, 26, 77, 8931, 14, 199, 624, 199, 199, 646, 2197, 199, 504, 4011, 14, 1122, 492, 7097, 199, 504, 8335, 492, 4996, 12, 2624, 12, 7225, 12, 12718, 12, 6957, 12, 13686, 12, 11305, 12, 9411, 199, 504, 8335, 14, 832, 14, 12164, 1905, 492, 30191, 63, 1095, 199, 504, 8335, 14, 1025, 492, 8931, 12, 23412, 199, 504, 8335, 492, 1218, 63, 3908, 12, 18276, 8463, 199, 504, 8335, 14, 1025, 492, 27582, 63, 1730, 199, 504, 8335, 14, 1025, 492, 2351, 14367, 199, 199, 1563, 275, 30191, 63, 1095, 342, 199, 199, 12865, 529, 63, 1733, 397, 63, 332, 1190, 275, 6957, 360, 12865, 529, 63, 1733, 397, 63, 332, 1190, 297, 3523, 14, 2343, 12, 3044, 4996, 360, 12865, 529, 63, 1733, 63, 344, 297, 7225, 12, 12718, 360, 12865, 529, 63, 1733, 14, 344, 3855, 3044, 4996, 360, 332, 80, 63, 344, 297, 7225, 12, 12718, 360, 332, 80, 14, 344, 7058, 421, 199, 533, 13916, 345, 529, 5278, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 12865, 529, 63, 1733, 7, 339, 1305, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 4252, 63, 493, 275, 4996, 8, 1558, 9, 272, 1329, 63, 1733, 63, 30378, 63, 2972, 275, 4996, 8, 2674, 9, 272, 1202, 63, 1733, 63, 30378, 275, 4996, 8, 1558, 9, 272, 1329, 63, 17128, 63, 2972, 275, 4996, 8, 2674, 9, 272, 1329, 63, 1733, 63, 10590, 275, 4996, 8, 2674, 9, 272, 8239, 63, 1733, 316, 275, 4996, 8, 3926, 12, 849, 29, 2083, 14, 2083, 14, 10779, 9, 272, 15248, 63, 1733, 316, 275, 4996, 8, 3926, 9, 339, 8926, 1190, 275, 8931, 8, 267, 283, 5278, 8524, 6579, 3276, 297, 267, 13851, 29, 12865, 529, 63, 1733, 397, 63, 332, 1190, 12, 267, 23412, 29, 894, 1121, 360, 12865, 529, 63, 1733, 397, 297, 675, 513, 29, 549, 9, 272, 776, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2650, 7181, 345, 529, 5278, 59, 91, 344, 11049, 24514, 367, 469, 1955, 63, 1733, 63, 10590, 93, 3747, 7681, 14, 1933, 5015, 4061, 1330, 316, 26, 469, 8924, 8650, 971, 2049, 283, 1733, 316, 93, 436, 15248, 26, 469, 14661, 63, 1733, 316, 93, 22936, 908, 3682, 277, 855, 807, 3368, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 855, 495, 4533, 421, 199, 533, 8730, 8524, 6579, 3276, 8, 1563, 304, 272, 636, 10983, 363, 275, 283, 332, 80, 7, 339, 1305, 275, 4996, 8, 2674, 12, 5062, 63, 498, 29, 549, 9, 272, 2004, 275, 4996, 8, 1558, 12, 849, 534, 18157, 358, 272, 2754, 63, 3908, 63, 354, 275, 4996, 8, 1558, 9, 272, 10328, 321, 63, 765, 275, 4996, 8, 1558, 9, 272, 2034, 63, 1955, 275, 4996, 8, 2674, 9, 272, 5839, 63, 292, 275, 4996, 8, 3926, 12, 849, 29, 2083, 14, 2083, 14, 10779, 9, 272, 5839, 63, 991, 275, 4996, 8, 1558, 12, 849, 534, 4195, 14, 16, 14, 16, 14, 17, 358, 339, 327, 710, 1059, 315, 314, 428, 6758, 626, 9126, 4212, 5002, 2058, 781, 4788, 367, 314, 2754, 6707, 14, 272, 1967, 63, 2604, 63, 509, 63, 1131, 275, 4996, 8, 1558, 12, 849, 13275, 339, 327, 7480, 781, 4788, 1263, 2058, 737, 1006, 14, 961, 365, 314, 2011, 465, 822, 8, 332, 80, 14, 4614, 9, 272, 1967, 63, 2604, 275, 4996, 8, 2674, 12, 849, 4022, 17, 9, 339, 1827, 275, 4996, 8, 1558, 9, 339, 327, 340, 314, 1827, 1990, 6042, 701, 314, 2754, 6869, 2952, 2337, 781, 828, 1133, 1263, 272, 327, 2058, 12, 642, 1750, 365, 663, 370, 314, 1827, 626, 1990, 1202, 3140, 14, 272, 327, 6630, 652, 25803, 2701, 14, 272, 15826, 63, 1131, 275, 4996, 8, 1558, 12, 849, 13275, 339, 327, 7480, 314, 2754, 6869, 965, 949, 2058, 14, 272, 327, 961, 365, 440, 314, 2011, 465, 1967, 63, 2604, 12, 2952, 2005, 2754, 28156, 272, 327, 5847, 2754, 1163, 8545, 2754, 9212, 1380, 2985, 2342, 949, 2058, 14, 272, 327, 30094, 2985, 1172, 2058, 367, 314, 1827, 12, 1325, 9696, 282, 27928, 27572, 1728, 436, 1454, 272, 327, 18453, 376, 13943, 14, 961, 365, 4573, 1930, 1, 272, 327, 982, 949, 63, 2604, 365, 2549, 12, 2066, 2337, 781, 828, 1133, 1821, 20668, 51, 481, 47, 6131, 2381, 5749, 7813, 9418, 21512, 11017, 2337, 272, 327, 4293, 1172, 2757, 2058, 367, 376, 2599, 30156, 1827, 14, 272, 949, 63, 2604, 275, 4996, 8, 4082, 12, 849, 29, 797, 9, 339, 347, 636, 495, 721, 277, 304, 267, 372, 2650, 3279, 48, 59, 91, 1733, 63, 3908, 63, 354, 11049, 965, 8910, 1507, 63, 2604, 11049, 2142, 2058, 367, 1827, 5310, 1131, 93, 1743, 1370, 908, 8, 288, 1011, 277, 855, 807, 3368, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 291, 855, 495, 4533, 339, 347, 965, 63, 889, 63, 2604, 63, 509, 63, 1131, 8, 277, 304, 267, 408, 267, 1803, 715, 340, 314, 3379, 1827, 8103, 440, 1995, 1263, 2058, 14, 267, 1803, 756, 340, 1902, 2337, 787, 949, 8926, 80, 4811, 12, 503, 314, 2754, 6869, 2599, 30156, 314, 1827, 14, 267, 408, 267, 372, 291, 14, 1507, 63, 2604, 508, 378, 503, 291, 14, 20427, 63, 1131, 339, 347, 663, 63, 1459, 63, 504, 63, 2087, 8, 277, 12, 1798, 304, 267, 408, 9606, 5434, 6337, 687, 282, 1798, 909, 14, 398, 3033, 26, 288, 437, 1798, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
aestheticblasphemy/aestheticBlasphemy
pl_messages/migrations/0002_auto_20200828_2129.py
1
1972
# Generated by Django 3.1 on 2020-08-28 15:59 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('pl_messages', '0001_initial'), ] operations = [ migrations.AlterField( model_name='messages', name='parent', field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='pl_messages.messages'), ), migrations.AlterField( model_name='participantnotifications', name='participant', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='notified_participant', to=settings.AUTH_USER_MODEL, verbose_name='Notification Participant'), ), migrations.AlterField( model_name='participantthreads', name='participant', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='thread_participant', to=settings.AUTH_USER_MODEL, verbose_name='Thread Participant'), ), migrations.AlterField( model_name='participantthreads', name='threads', field=models.ManyToManyField(related_name='participant_threads', to='pl_messages.Thread', verbose_name='Participant Threads'), ), migrations.AlterField( model_name='thread', name='last_message', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='last_message_in_thread', to='pl_messages.messages', verbose_name='Last Message'), ), migrations.AlterField( model_name='thread', name='messages', field=models.ManyToManyField(related_name='thread_messages', to='pl_messages.Messages', verbose_name='Thread Messages'), ), ]
gpl-3.0
[ 3, 17065, 701, 5634, 650, 14, 17, 641, 25455, 13, 2036, 13, 1651, 4114, 26, 1427, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 6180, 14, 31925, 63, 8575, 8, 1751, 14, 5580, 63, 3791, 63, 11429, 395, 267, 661, 1168, 63, 3431, 297, 283, 4183, 63, 2747, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 3431, 297, 288, 536, 534, 1708, 297, 288, 901, 29, 992, 14, 3190, 8, 2307, 29, 549, 12, 641, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 3597, 63, 8084, 12, 370, 534, 1168, 63, 3431, 14, 3431, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 29253, 12782, 297, 288, 536, 534, 29253, 297, 288, 901, 29, 992, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 4048, 63, 354, 534, 889, 8981, 63, 29253, 297, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 12, 3376, 63, 354, 534, 11598, 2235, 16448, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 29253, 6962, 297, 288, 536, 534, 29253, 297, 288, 901, 29, 992, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 4048, 63, 354, 534, 2671, 63, 29253, 297, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 12, 3376, 63, 354, 534, 4436, 2235, 16448, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 29253, 6962, 297, 288, 536, 534, 6962, 297, 288, 901, 29, 992, 14, 7624, 8, 2407, 63, 354, 534, 29253, 63, 6962, 297, 370, 534, 1168, 63, 3431, 14, 4436, 297, 3376, 63, 354, 534, 1262, 16448, 11086, 83, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2671, 297, 288, 536, 534, 2019, 63, 1188, 297, 288, 901, 29, 992, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 4048, 63, 354, 534, 2019, 63, 1188, 63, 262, 63, 2671, 297, 370, 534, 1168, 63, 3431, 14, 3431, 297, 3376, 63, 354, 534, 6090, 6430, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2671, 297, 288, 536, 534, 3431, 297, 288, 901, 29, 992, 14, 7624, 8, 2407, 63, 354, 534, 2671, 63, 3431, 297, 370, 534, 1168, 63, 3431, 14, 14508, 297, 3376, 63, 354, 534, 4436, 27377, 659, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 17065, 701, 5634, 650, 14, 17, 641, 25455, 13, 2036, 13, 1651, 4114, 26, 1427, 199, 199, 504, 1639, 14, 2190, 492, 2202, 199, 504, 1639, 14, 697, 492, 6180, 12, 1709, 199, 646, 1639, 14, 697, 14, 992, 14, 14281, 421, 199, 533, 12090, 8, 7685, 14, 9816, 304, 339, 5124, 275, 359, 267, 6180, 14, 31925, 63, 8575, 8, 1751, 14, 5580, 63, 3791, 63, 11429, 395, 267, 661, 1168, 63, 3431, 297, 283, 4183, 63, 2747, 659, 272, 1622, 339, 5331, 275, 359, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 3431, 297, 288, 536, 534, 1708, 297, 288, 901, 29, 992, 14, 3190, 8, 2307, 29, 549, 12, 641, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 3597, 63, 8084, 12, 370, 534, 1168, 63, 3431, 14, 3431, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 29253, 12782, 297, 288, 536, 534, 29253, 297, 288, 901, 29, 992, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 4048, 63, 354, 534, 889, 8981, 63, 29253, 297, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 12, 3376, 63, 354, 534, 11598, 2235, 16448, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 29253, 6962, 297, 288, 536, 534, 29253, 297, 288, 901, 29, 992, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 4048, 63, 354, 534, 2671, 63, 29253, 297, 370, 29, 1751, 14, 5580, 63, 3791, 63, 11429, 12, 3376, 63, 354, 534, 4436, 2235, 16448, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 29253, 6962, 297, 288, 536, 534, 6962, 297, 288, 901, 29, 992, 14, 7624, 8, 2407, 63, 354, 534, 29253, 63, 6962, 297, 370, 534, 1168, 63, 3431, 14, 4436, 297, 3376, 63, 354, 534, 1262, 16448, 11086, 83, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2671, 297, 288, 536, 534, 2019, 63, 1188, 297, 288, 901, 29, 992, 14, 3190, 8, 265, 63, 1807, 29, 1176, 14, 697, 14, 992, 14, 14281, 14, 10855, 12, 4048, 63, 354, 534, 2019, 63, 1188, 63, 262, 63, 2671, 297, 370, 534, 1168, 63, 3431, 14, 3431, 297, 3376, 63, 354, 534, 6090, 6430, 659, 267, 2318, 267, 6180, 14, 19275, 8, 288, 1402, 63, 354, 534, 2671, 297, 288, 536, 534, 3431, 297, 288, 901, 29, 992, 14, 7624, 8, 2407, 63, 354, 534, 2671, 63, 3431, 297, 370, 534, 1168, 63, 3431, 14, 14508, 297, 3376, 63, 354, 534, 4436, 27377, 659, 267, 2318, 272, 1622, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ZdenekM/ar-table-itable
art_instructions/src/art_instructions/brain/wait_for_user.py
6
1300
from art_instructions.brain import BrainFSM, BrainInstruction from transitions import State import rospy from art_msgs.msg import UserActivity class WaitForUser(BrainInstruction): pass class WaitForUserLearn(WaitForUser): pass class WaitForUserRun(WaitForUser): pass class WaitForUserFSM(BrainFSM): states = [ State(name='wait_for_user', on_enter=[ 'state_update_program_item', 'check_robot_in', 'state_wait_for_user'], on_exit=['check_robot_out']), ] transitions = [ ('wait_for_user', 'program_run', 'wait_for_user'), ('done', 'wait_for_user', 'program_load_instruction'), ('error', 'wait_for_user', 'program_error'), ] state_functions = [ 'state_wait_for_user' ] def run(self): self.fsm.wait_for_user() def state_wait_for_user(self, event): rospy.logdebug('Current state: state_wait_for_user') self.brain.state_manager.update_program_item( self.brain.ph.get_program_id(), self.brain.block_id, self.brain.instruction) rate = rospy.Rate(10) while self.brain.user_activity != UserActivity.READY and self.brain.executing_program \ and not rospy.is_shutdown(): rate.sleep() self.fsm.done(success=True)
lgpl-2.1
[ 504, 24701, 63, 20718, 14, 22246, 492, 699, 6322, 38, 4029, 12, 699, 6322, 17700, 199, 504, 19077, 492, 8511, 199, 646, 21848, 199, 504, 24701, 63, 13429, 14, 1328, 492, 2876, 14350, 421, 199, 533, 13144, 1858, 1899, 8, 34, 6322, 17700, 304, 272, 986, 421, 199, 533, 13144, 1858, 1899, 21424, 8, 21433, 1899, 304, 272, 986, 421, 199, 533, 13144, 1858, 1899, 2540, 8, 21433, 1899, 304, 272, 986, 421, 199, 533, 13144, 1858, 1899, 38, 4029, 8, 34, 6322, 38, 4029, 304, 272, 6363, 275, 359, 267, 8511, 8, 354, 534, 2573, 63, 509, 63, 751, 297, 641, 63, 4200, 1524, 288, 283, 929, 63, 873, 63, 6815, 63, 1053, 297, 283, 1074, 63, 9751, 63, 262, 297, 283, 929, 63, 2573, 63, 509, 63, 751, 995, 641, 63, 2224, 2968, 1074, 63, 9751, 63, 548, 3815, 339, 1622, 339, 19077, 275, 359, 267, 661, 2573, 63, 509, 63, 751, 297, 283, 6815, 63, 1065, 297, 283, 2573, 63, 509, 63, 751, 659, 267, 661, 4456, 297, 283, 2573, 63, 509, 63, 751, 297, 283, 6815, 63, 912, 63, 22880, 659, 267, 661, 705, 297, 283, 2573, 63, 509, 63, 751, 297, 283, 6815, 63, 705, 659, 272, 1622, 339, 1174, 63, 5777, 275, 359, 267, 283, 929, 63, 2573, 63, 509, 63, 751, 7, 272, 1622, 339, 347, 1255, 8, 277, 304, 267, 291, 14, 23078, 14, 2573, 63, 509, 63, 751, 342, 339, 347, 1174, 63, 2573, 63, 509, 63, 751, 8, 277, 12, 1566, 304, 267, 21848, 14, 793, 1757, 360, 5639, 1174, 26, 1174, 63, 2573, 63, 509, 63, 751, 358, 398, 291, 14, 22246, 14, 929, 63, 2609, 14, 873, 63, 6815, 63, 1053, 8, 288, 291, 14, 22246, 14, 838, 14, 362, 63, 6815, 63, 344, 1062, 291, 14, 22246, 14, 1457, 63, 344, 12, 291, 14, 22246, 14, 22880, 9, 398, 6634, 275, 21848, 14, 6621, 8, 709, 9, 398, 1830, 291, 14, 22246, 14, 751, 63, 8240, 1137, 2876, 14350, 14, 22579, 436, 291, 14, 22246, 14, 23722, 63, 6815, 971, 355, 436, 440, 21848, 14, 374, 63, 8831, 837, 288, 6634, 14, 4532, 342, 398, 291, 14, 23078, 14, 4456, 8, 3742, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 24701, 63, 20718, 14, 22246, 492, 699, 6322, 38, 4029, 12, 699, 6322, 17700, 199, 504, 19077, 492, 8511, 199, 646, 21848, 199, 504, 24701, 63, 13429, 14, 1328, 492, 2876, 14350, 421, 199, 533, 13144, 1858, 1899, 8, 34, 6322, 17700, 304, 272, 986, 421, 199, 533, 13144, 1858, 1899, 21424, 8, 21433, 1899, 304, 272, 986, 421, 199, 533, 13144, 1858, 1899, 2540, 8, 21433, 1899, 304, 272, 986, 421, 199, 533, 13144, 1858, 1899, 38, 4029, 8, 34, 6322, 38, 4029, 304, 272, 6363, 275, 359, 267, 8511, 8, 354, 534, 2573, 63, 509, 63, 751, 297, 641, 63, 4200, 1524, 288, 283, 929, 63, 873, 63, 6815, 63, 1053, 297, 283, 1074, 63, 9751, 63, 262, 297, 283, 929, 63, 2573, 63, 509, 63, 751, 995, 641, 63, 2224, 2968, 1074, 63, 9751, 63, 548, 3815, 339, 1622, 339, 19077, 275, 359, 267, 661, 2573, 63, 509, 63, 751, 297, 283, 6815, 63, 1065, 297, 283, 2573, 63, 509, 63, 751, 659, 267, 661, 4456, 297, 283, 2573, 63, 509, 63, 751, 297, 283, 6815, 63, 912, 63, 22880, 659, 267, 661, 705, 297, 283, 2573, 63, 509, 63, 751, 297, 283, 6815, 63, 705, 659, 272, 1622, 339, 1174, 63, 5777, 275, 359, 267, 283, 929, 63, 2573, 63, 509, 63, 751, 7, 272, 1622, 339, 347, 1255, 8, 277, 304, 267, 291, 14, 23078, 14, 2573, 63, 509, 63, 751, 342, 339, 347, 1174, 63, 2573, 63, 509, 63, 751, 8, 277, 12, 1566, 304, 267, 21848, 14, 793, 1757, 360, 5639, 1174, 26, 1174, 63, 2573, 63, 509, 63, 751, 358, 398, 291, 14, 22246, 14, 929, 63, 2609, 14, 873, 63, 6815, 63, 1053, 8, 288, 291, 14, 22246, 14, 838, 14, 362, 63, 6815, 63, 344, 1062, 291, 14, 22246, 14, 1457, 63, 344, 12, 291, 14, 22246, 14, 22880, 9, 398, 6634, 275, 21848, 14, 6621, 8, 709, 9, 398, 1830, 291, 14, 22246, 14, 751, 63, 8240, 1137, 2876, 14350, 14, 22579, 436, 291, 14, 22246, 14, 23722, 63, 6815, 971, 355, 436, 440, 21848, 14, 374, 63, 8831, 837, 288, 6634, 14, 4532, 342, 398, 291, 14, 23078, 14, 4456, 8, 3742, 29, 549, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
isvaldo/Ola_Bemobenses
tests/Selenium/environment/lib/python3.4/site-packages/pip/_vendor/requests/packages/urllib3/util/url.py
553
5836
from collections import namedtuple from ..exceptions import LocationParseError url_attrs = ['scheme', 'auth', 'host', 'port', 'path', 'query', 'fragment'] class Url(namedtuple('Url', url_attrs)): """ Datastructure for representing an HTTP URL. Used as a return value for :func:`parse_url`. """ slots = () def __new__(cls, scheme=None, auth=None, host=None, port=None, path=None, query=None, fragment=None): if path and not path.startswith('/'): path = '/' + path return super(Url, cls).__new__(cls, scheme, auth, host, port, path, query, fragment) @property def hostname(self): """For backwards-compatibility with urlparse. We're nice like that.""" return self.host @property def request_uri(self): """Absolute path including the query string.""" uri = self.path or '/' if self.query is not None: uri += '?' + self.query return uri @property def netloc(self): """Network location including host and port""" if self.port: return '%s:%d' % (self.host, self.port) return self.host @property def url(self): """ Convert self into a url This function should more or less round-trip with :func:`.parse_url`. The returned url may not be exactly the same as the url inputted to :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls with a blank port will have : removed). Example: :: >>> U = parse_url('http://google.com/mail/') >>> U.url 'http://google.com/mail/' >>> Url('http', 'username:password', 'host.com', 80, ... '/path', 'query', 'fragment').url 'http://username:password@host.com:80/path?query#fragment' """ scheme, auth, host, port, path, query, fragment = self url = '' # We use "is not None" we want things to happen with empty strings (or 0 port) if scheme is not None: url += scheme + '://' if auth is not None: url += auth + '@' if host is not None: url += host if port is not None: url += ':' + str(port) if path is not None: url += path if query is not None: url += '?' + query if fragment is not None: url += '#' + fragment return url def __str__(self): return self.url def split_first(s, delims): """ Given a string and an iterable of delimiters, split on the first found delimiter. Return two split parts and the matched delimiter. If not found, then the first part is the full input string. Example:: >>> split_first('foo/bar?baz', '?/=') ('foo', 'bar?baz', '/') >>> split_first('foo/bar?baz', '123') ('foo/bar?baz', '', None) Scales linearly with number of delims. Not ideal for large number of delims. """ min_idx = None min_delim = None for d in delims: idx = s.find(d) if idx < 0: continue if min_idx is None or idx < min_idx: min_idx = idx min_delim = d if min_idx is None or min_idx < 0: return s, '', None return s[:min_idx], s[min_idx+1:], min_delim def parse_url(url): """ Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is performed to parse incomplete urls. Fields not provided will be None. Partly backwards-compatible with :mod:`urlparse`. Example:: >>> parse_url('http://google.com/mail/') Url(scheme='http', host='google.com', port=None, path='/mail/', ...) >>> parse_url('google.com:80') Url(scheme=None, host='google.com', port=80, path=None, ...) >>> parse_url('/foo?bar') Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...) """ # While this code has overlap with stdlib's urlparse, it is much # simplified for our needs and less annoying. # Additionally, this implementations does silly things to be optimal # on CPython. if not url: # Empty return Url() scheme = None auth = None host = None port = None path = None fragment = None query = None # Scheme if '://' in url: scheme, url = url.split('://', 1) # Find the earliest Authority Terminator # (http://tools.ietf.org/html/rfc3986#section-3.2) url, path_, delim = split_first(url, ['/', '?', '#']) if delim: # Reassemble the path path = delim + path_ # Auth if '@' in url: # Last '@' denotes end of auth part auth, url = url.rsplit('@', 1) # IPv6 if url and url[0] == '[': host, url = url.split(']', 1) host += ']' # Port if ':' in url: _host, port = url.split(':', 1) if not host: host = _host if port: # If given, ports must be integers. if not port.isdigit(): raise LocationParseError(url) port = int(port) else: # Blank ports are cool, too. (rfc3986#section-3.2.3) port = None elif not host and url: host = url if not path: return Url(scheme, auth, host, port, path, query, fragment) # Fragment if '#' in path: path, fragment = path.split('#', 1) # Query if '?' in path: path, query = path.split('?', 1) return Url(scheme, auth, host, port, path, query, fragment) def get_host(url): """ Deprecated. Use :func:`.parse_url` instead. """ p = parse_url(url) return p.scheme or 'http', p.hostname, p.port
cc0-1.0
[ 504, 5055, 492, 12863, 199, 199, 504, 2508, 3924, 492, 12625, 9123, 421, 199, 633, 63, 3288, 275, 788, 5512, 297, 283, 1178, 297, 283, 1102, 297, 283, 719, 297, 283, 515, 297, 283, 1131, 297, 283, 7677, 418, 421, 199, 533, 20503, 8, 18921, 360, 6417, 297, 1166, 63, 3288, 2298, 272, 408, 272, 3918, 6976, 367, 6144, 376, 3101, 2851, 14, 8051, 465, 282, 372, 574, 367, 272, 520, 1532, 1705, 1122, 63, 633, 2313, 272, 408, 272, 14319, 275, 6248, 339, 347, 636, 1222, 721, 1886, 12, 5687, 29, 403, 12, 1790, 29, 403, 12, 1591, 29, 403, 12, 1844, 29, 403, 12, 931, 29, 403, 12, 355, 1827, 29, 403, 12, 7956, 29, 403, 304, 267, 340, 931, 436, 440, 931, 14, 2460, 18265, 288, 931, 275, 7324, 435, 931, 267, 372, 1613, 8, 6417, 12, 843, 2843, 1222, 721, 1886, 12, 5687, 12, 1790, 12, 1591, 12, 1844, 12, 931, 12, 4318, 1827, 12, 7956, 9, 339, 768, 1829, 272, 347, 6246, 8, 277, 304, 267, 408, 1858, 8552, 13, 15390, 543, 7097, 14, 2136, 3984, 14213, 2839, 626, 1041, 267, 372, 291, 14, 1102, 339, 768, 1829, 272, 347, 1056, 63, 2302, 8, 277, 304, 267, 408, 24677, 931, 5893, 314, 1827, 1059, 1041, 267, 5108, 275, 291, 14, 515, 503, 7324, 398, 340, 291, 14, 1131, 365, 440, 488, 26, 288, 5108, 847, 15539, 435, 291, 14, 1131, 398, 372, 5108, 339, 768, 1829, 272, 347, 10154, 8, 277, 304, 267, 408, 4491, 2909, 5893, 1591, 436, 1844, 624, 267, 340, 291, 14, 719, 26, 288, 372, 1543, 83, 2689, 68, 7, 450, 334, 277, 14, 1102, 12, 291, 14, 719, 9, 267, 372, 291, 14, 1102, 339, 768, 1829, 272, 347, 1166, 8, 277, 304, 267, 408, 267, 7905, 291, 1901, 282, 1166, 398, 961, 805, 1077, 1655, 503, 6656, 6168, 13, 7254, 543, 520, 1532, 5026, 1122, 63, 633, 2313, 710, 267, 2138, 1166, 1443, 440, 506, 8840, 314, 2011, 465, 314, 1166, 1324, 471, 370, 267, 520, 1532, 5026, 1122, 63, 633, 3559, 1325, 652, 1077, 506, 7353, 701, 314, 7329, 334, 69, 14, 71, 2020, 8187, 267, 543, 282, 4596, 1844, 911, 1172, 520, 4829, 680, 398, 5679, 26, 3800, 953, 1306, 738, 275, 2198, 63, 633, 360, 1014, 921, 3098, 14, 957, 15, 1198, 6217, 288, 1306, 738, 14, 633, 288, 283, 1014, 921, 3098, 14, 957, 15, 1198, 4805, 288, 1306, 20503, 360, 1014, 297, 283, 2473, 26, 2060, 297, 283, 1102, 14, 957, 297, 5939, 12, 288, 2263, 1994, 515, 297, 283, 1131, 297, 283, 7677, 1959, 633, 288, 283, 1014, 921, 2473, 26, 2060, 32, 1102, 14, 957, 26, 1257, 15, 515, 31, 1131, 3, 7677, 7, 267, 408, 267, 5687, 12, 1790, 12, 1591, 12, 1844, 12, 931, 12, 1827, 12, 7956, 275, 291, 267, 1166, 275, 2125, 398, 327, 2136, 675, 298, 374, 440, 488, 2, 781, 2934, 7645, 370, 5992, 543, 2701, 3326, 334, 269, 378, 1844, 9, 267, 340, 5687, 365, 440, 488, 26, 288, 1166, 847, 5687, 435, 283, 22399, 267, 340, 1790, 365, 440, 488, 26, 288, 1166, 847, 1790, 435, 22143, 267, 340, 1591, 365, 440, 488, 26, 288, 1166, 847, 1591, 267, 340, 1844, 365, 440, 488, 26, 288, 1166, 847, 10871, 435, 620, 8, 719, 9, 267, 340, 931, 365, 440, 488, 26, 288, 1166, 847, 931, 267, 340, 1827, 365, 440, 488, 26, 288, 1166, 847, 15539, 435, 1827, 267, 340, 7956, 365, 440, 488, 26, 288, 1166, 847, 19619, 435, 7956, 398, 372, 1166, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 633, 199, 199, 318, 3715, 63, 2246, 8, 83, 12, 9122, 706, 304, 272, 408, 272, 9138, 282, 1059, 436, 376, 6076, 402, 26968, 12, 3715, 641, 314, 1642, 1911, 272, 11172, 14, 1432, 2877, 3715, 4184, 436, 314, 7838, 11172, 14, 339, 982, 440, 1911, 12, 2066, 314, 1642, 1777, 365, 314, 2615, 1324, 1059, 14, 339, 5679, 447, 398, 1306, 3715, 63, 2246, 360, 1421, 15, 1700, 31, 6185, 297, 8720, 15, 14619, 267, 661, 1421, 297, 283, 1700, 31, 6185, 297, 15107, 267, 1306, 3715, 63, 2246, 360, 1421, 15, 1700, 31, 6185, 297, 283, 4288, 358, 267, 661, 1421, 15, 1700, 31, 6185, 297, 3260, 488, 9, 339, 22869, 83, 7798, 590, 543, 1329, 402, 9122, 706, 14, 2832, 28264, 367, 7031, 1329, 402, 9122, 706, 14, 272, 408, 272, 1748, 63, 2996, 275, 488, 272, 1748, 63, 15966, 275, 488, 272, 367, 366, 315, 9122, 706, 26, 267, 4280, 275, 308, 14, 1623, 8, 68, 9, 267, 340, 4280, 665, 378, 26, 288, 1980, 398, 340, 1748, 63, 2996, 365, 488, 503, 4280, 665, 1748, 63, 2996, 26, 288, 1748, 63, 2996, 275, 4280, 288, 1748, 63, 15966, 275, 366, 339, 340, 1748, 63, 2996, 365, 488, 503, 1748, 63, 2996, 665, 378, 26, 267, 372, 308, 12, 3260, 488, 339, 372, 308, 1491, 827, 63, 2996, 467, 308, 59, 827, 63, 2996, 11, 17, 8429, 1748, 63, 15966, 421, 199, 318, 2198, 63, 633, 8, 633, 304, 272, 408, 272, 9138, 282, 1166, 12, 372, 282, 4565, 520, 533, 5026, 6417, 64, 12863, 14, 699, 597, 13, 26088, 365, 272, 10585, 370, 2198, 17110, 8187, 14, 16424, 440, 2741, 911, 506, 488, 14, 339, 14320, 590, 8552, 13, 6490, 543, 520, 1494, 1705, 10290, 2313, 339, 5679, 447, 398, 1306, 2198, 63, 633, 360, 1014, 921, 3098, 14, 957, 15, 1198, 6217, 267, 20503, 8, 5512, 534, 1014, 297, 1591, 534, 3098, 14, 957, 297, 1844, 29, 403, 12, 931, 8805, 1198, 3678, 19172, 267, 1306, 2198, 63, 633, 360, 3098, 14, 957, 26, 1257, 358, 267, 20503, 8, 5512, 29, 403, 12, 1591, 534, 3098, 14, 957, 297, 1844, 29, 1257, 12, 931, 29, 403, 12, 19172, 267, 1306, 2198, 63, 633, 2336, 1421, 31, 1700, 358, 267, 20503, 8, 5512, 29, 403, 12, 1591, 29, 403, 12, 1844, 29, 403, 12, 931, 8805, 1421, 297, 1827, 534, 1700, 297, 19172, 272, 408, 339, 327, 22117, 642, 1233, 965, 15145, 543, 26678, 1159, 7097, 12, 652, 365, 8298, 272, 327, 26867, 367, 4154, 4839, 436, 6656 ]
[ 5055, 492, 12863, 199, 199, 504, 2508, 3924, 492, 12625, 9123, 421, 199, 633, 63, 3288, 275, 788, 5512, 297, 283, 1178, 297, 283, 1102, 297, 283, 719, 297, 283, 515, 297, 283, 1131, 297, 283, 7677, 418, 421, 199, 533, 20503, 8, 18921, 360, 6417, 297, 1166, 63, 3288, 2298, 272, 408, 272, 3918, 6976, 367, 6144, 376, 3101, 2851, 14, 8051, 465, 282, 372, 574, 367, 272, 520, 1532, 1705, 1122, 63, 633, 2313, 272, 408, 272, 14319, 275, 6248, 339, 347, 636, 1222, 721, 1886, 12, 5687, 29, 403, 12, 1790, 29, 403, 12, 1591, 29, 403, 12, 1844, 29, 403, 12, 931, 29, 403, 12, 355, 1827, 29, 403, 12, 7956, 29, 403, 304, 267, 340, 931, 436, 440, 931, 14, 2460, 18265, 288, 931, 275, 7324, 435, 931, 267, 372, 1613, 8, 6417, 12, 843, 2843, 1222, 721, 1886, 12, 5687, 12, 1790, 12, 1591, 12, 1844, 12, 931, 12, 4318, 1827, 12, 7956, 9, 339, 768, 1829, 272, 347, 6246, 8, 277, 304, 267, 408, 1858, 8552, 13, 15390, 543, 7097, 14, 2136, 3984, 14213, 2839, 626, 1041, 267, 372, 291, 14, 1102, 339, 768, 1829, 272, 347, 1056, 63, 2302, 8, 277, 304, 267, 408, 24677, 931, 5893, 314, 1827, 1059, 1041, 267, 5108, 275, 291, 14, 515, 503, 7324, 398, 340, 291, 14, 1131, 365, 440, 488, 26, 288, 5108, 847, 15539, 435, 291, 14, 1131, 398, 372, 5108, 339, 768, 1829, 272, 347, 10154, 8, 277, 304, 267, 408, 4491, 2909, 5893, 1591, 436, 1844, 624, 267, 340, 291, 14, 719, 26, 288, 372, 1543, 83, 2689, 68, 7, 450, 334, 277, 14, 1102, 12, 291, 14, 719, 9, 267, 372, 291, 14, 1102, 339, 768, 1829, 272, 347, 1166, 8, 277, 304, 267, 408, 267, 7905, 291, 1901, 282, 1166, 398, 961, 805, 1077, 1655, 503, 6656, 6168, 13, 7254, 543, 520, 1532, 5026, 1122, 63, 633, 2313, 710, 267, 2138, 1166, 1443, 440, 506, 8840, 314, 2011, 465, 314, 1166, 1324, 471, 370, 267, 520, 1532, 5026, 1122, 63, 633, 3559, 1325, 652, 1077, 506, 7353, 701, 314, 7329, 334, 69, 14, 71, 2020, 8187, 267, 543, 282, 4596, 1844, 911, 1172, 520, 4829, 680, 398, 5679, 26, 3800, 953, 1306, 738, 275, 2198, 63, 633, 360, 1014, 921, 3098, 14, 957, 15, 1198, 6217, 288, 1306, 738, 14, 633, 288, 283, 1014, 921, 3098, 14, 957, 15, 1198, 4805, 288, 1306, 20503, 360, 1014, 297, 283, 2473, 26, 2060, 297, 283, 1102, 14, 957, 297, 5939, 12, 288, 2263, 1994, 515, 297, 283, 1131, 297, 283, 7677, 1959, 633, 288, 283, 1014, 921, 2473, 26, 2060, 32, 1102, 14, 957, 26, 1257, 15, 515, 31, 1131, 3, 7677, 7, 267, 408, 267, 5687, 12, 1790, 12, 1591, 12, 1844, 12, 931, 12, 1827, 12, 7956, 275, 291, 267, 1166, 275, 2125, 398, 327, 2136, 675, 298, 374, 440, 488, 2, 781, 2934, 7645, 370, 5992, 543, 2701, 3326, 334, 269, 378, 1844, 9, 267, 340, 5687, 365, 440, 488, 26, 288, 1166, 847, 5687, 435, 283, 22399, 267, 340, 1790, 365, 440, 488, 26, 288, 1166, 847, 1790, 435, 22143, 267, 340, 1591, 365, 440, 488, 26, 288, 1166, 847, 1591, 267, 340, 1844, 365, 440, 488, 26, 288, 1166, 847, 10871, 435, 620, 8, 719, 9, 267, 340, 931, 365, 440, 488, 26, 288, 1166, 847, 931, 267, 340, 1827, 365, 440, 488, 26, 288, 1166, 847, 15539, 435, 1827, 267, 340, 7956, 365, 440, 488, 26, 288, 1166, 847, 19619, 435, 7956, 398, 372, 1166, 339, 347, 636, 495, 721, 277, 304, 267, 372, 291, 14, 633, 199, 199, 318, 3715, 63, 2246, 8, 83, 12, 9122, 706, 304, 272, 408, 272, 9138, 282, 1059, 436, 376, 6076, 402, 26968, 12, 3715, 641, 314, 1642, 1911, 272, 11172, 14, 1432, 2877, 3715, 4184, 436, 314, 7838, 11172, 14, 339, 982, 440, 1911, 12, 2066, 314, 1642, 1777, 365, 314, 2615, 1324, 1059, 14, 339, 5679, 447, 398, 1306, 3715, 63, 2246, 360, 1421, 15, 1700, 31, 6185, 297, 8720, 15, 14619, 267, 661, 1421, 297, 283, 1700, 31, 6185, 297, 15107, 267, 1306, 3715, 63, 2246, 360, 1421, 15, 1700, 31, 6185, 297, 283, 4288, 358, 267, 661, 1421, 15, 1700, 31, 6185, 297, 3260, 488, 9, 339, 22869, 83, 7798, 590, 543, 1329, 402, 9122, 706, 14, 2832, 28264, 367, 7031, 1329, 402, 9122, 706, 14, 272, 408, 272, 1748, 63, 2996, 275, 488, 272, 1748, 63, 15966, 275, 488, 272, 367, 366, 315, 9122, 706, 26, 267, 4280, 275, 308, 14, 1623, 8, 68, 9, 267, 340, 4280, 665, 378, 26, 288, 1980, 398, 340, 1748, 63, 2996, 365, 488, 503, 4280, 665, 1748, 63, 2996, 26, 288, 1748, 63, 2996, 275, 4280, 288, 1748, 63, 15966, 275, 366, 339, 340, 1748, 63, 2996, 365, 488, 503, 1748, 63, 2996, 665, 378, 26, 267, 372, 308, 12, 3260, 488, 339, 372, 308, 1491, 827, 63, 2996, 467, 308, 59, 827, 63, 2996, 11, 17, 8429, 1748, 63, 15966, 421, 199, 318, 2198, 63, 633, 8, 633, 304, 272, 408, 272, 9138, 282, 1166, 12, 372, 282, 4565, 520, 533, 5026, 6417, 64, 12863, 14, 699, 597, 13, 26088, 365, 272, 10585, 370, 2198, 17110, 8187, 14, 16424, 440, 2741, 911, 506, 488, 14, 339, 14320, 590, 8552, 13, 6490, 543, 520, 1494, 1705, 10290, 2313, 339, 5679, 447, 398, 1306, 2198, 63, 633, 360, 1014, 921, 3098, 14, 957, 15, 1198, 6217, 267, 20503, 8, 5512, 534, 1014, 297, 1591, 534, 3098, 14, 957, 297, 1844, 29, 403, 12, 931, 8805, 1198, 3678, 19172, 267, 1306, 2198, 63, 633, 360, 3098, 14, 957, 26, 1257, 358, 267, 20503, 8, 5512, 29, 403, 12, 1591, 534, 3098, 14, 957, 297, 1844, 29, 1257, 12, 931, 29, 403, 12, 19172, 267, 1306, 2198, 63, 633, 2336, 1421, 31, 1700, 358, 267, 20503, 8, 5512, 29, 403, 12, 1591, 29, 403, 12, 1844, 29, 403, 12, 931, 8805, 1421, 297, 1827, 534, 1700, 297, 19172, 272, 408, 339, 327, 22117, 642, 1233, 965, 15145, 543, 26678, 1159, 7097, 12, 652, 365, 8298, 272, 327, 26867, 367, 4154, 4839, 436, 6656, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
wileeam/airflow
tests/providers/amazon/aws/operators/test_gcs_to_s3.py
4
8632
# # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. import unittest import mock from airflow.providers.amazon.aws.hooks.s3 import S3Hook from airflow.providers.amazon.aws.operators.gcs_to_s3 import GCSToS3Operator try: from moto import mock_s3 except ImportError: mock_s3 = None TASK_ID = 'test-gcs-list-operator' GCS_BUCKET = 'test-bucket' DELIMITER = '.csv' PREFIX = 'TEST' S3_BUCKET = 's3://bucket/' MOCK_FILES = ["TEST1.csv", "TEST2.csv", "TEST3.csv"] class TestGCSToS3Operator(unittest.TestCase): # Test1: incremental behaviour (just some files missing) @mock_s3 @mock.patch('airflow.providers.google.cloud.operators.gcs.GCSHook') @mock.patch('airflow.providers.amazon.aws.operators.gcs_to_s3.GCSHook') def test_execute_incremental(self, mock_hook, mock_hook2): mock_hook.return_value.list.return_value = MOCK_FILES mock_hook.return_value.download.return_value = b"testing" mock_hook2.return_value.list.return_value = MOCK_FILES operator = GCSToS3Operator(task_id=TASK_ID, bucket=GCS_BUCKET, prefix=PREFIX, delimiter=DELIMITER, dest_aws_conn_id=None, dest_s3_key=S3_BUCKET, replace=False) # create dest bucket hook = S3Hook(aws_conn_id=None) bucket = hook.get_bucket('bucket') bucket.create() bucket.put_object(Key=MOCK_FILES[0], Body=b'testing') # we expect all except first file in MOCK_FILES to be uploaded # and all the MOCK_FILES to be present at the S3 bucket uploaded_files = operator.execute(None) self.assertEqual(sorted(MOCK_FILES[1:]), sorted(uploaded_files)) self.assertEqual(sorted(MOCK_FILES), sorted(hook.list_keys('bucket', delimiter='/'))) # Test2: All the files are already in origin and destination without replace @mock_s3 @mock.patch('airflow.providers.google.cloud.operators.gcs.GCSHook') @mock.patch('airflow.providers.amazon.aws.operators.gcs_to_s3.GCSHook') def test_execute_without_replace(self, mock_hook, mock_hook2): mock_hook.return_value.list.return_value = MOCK_FILES mock_hook.return_value.download.return_value = b"testing" mock_hook2.return_value.list.return_value = MOCK_FILES operator = GCSToS3Operator(task_id=TASK_ID, bucket=GCS_BUCKET, prefix=PREFIX, delimiter=DELIMITER, dest_aws_conn_id=None, dest_s3_key=S3_BUCKET, replace=False) # create dest bucket with all the files hook = S3Hook(aws_conn_id=None) bucket = hook.get_bucket('bucket') bucket.create() for mock_file in MOCK_FILES: bucket.put_object(Key=mock_file, Body=b'testing') # we expect nothing to be uploaded # and all the MOCK_FILES to be present at the S3 bucket uploaded_files = operator.execute(None) self.assertEqual([], uploaded_files) self.assertEqual(sorted(MOCK_FILES), sorted(hook.list_keys('bucket', delimiter='/'))) # Test3: There are no files in destination bucket @mock_s3 @mock.patch('airflow.providers.google.cloud.operators.gcs.GCSHook') @mock.patch('airflow.providers.amazon.aws.operators.gcs_to_s3.GCSHook') def test_execute(self, mock_hook, mock_hook2): mock_hook.return_value.list.return_value = MOCK_FILES mock_hook.return_value.download.return_value = b"testing" mock_hook2.return_value.list.return_value = MOCK_FILES operator = GCSToS3Operator(task_id=TASK_ID, bucket=GCS_BUCKET, prefix=PREFIX, delimiter=DELIMITER, dest_aws_conn_id=None, dest_s3_key=S3_BUCKET, replace=False) # create dest bucket without files hook = S3Hook(aws_conn_id=None) bucket = hook.get_bucket('bucket') bucket.create() # we expect all MOCK_FILES to be uploaded # and all MOCK_FILES to be present at the S3 bucket uploaded_files = operator.execute(None) self.assertEqual(sorted(MOCK_FILES), sorted(uploaded_files)) self.assertEqual(sorted(MOCK_FILES), sorted(hook.list_keys('bucket', delimiter='/'))) # Test4: Destination and Origin are in sync but replace all files in destination @mock_s3 @mock.patch('airflow.providers.google.cloud.operators.gcs.GCSHook') @mock.patch('airflow.providers.amazon.aws.operators.gcs_to_s3.GCSHook') def test_execute_with_replace(self, mock_hook, mock_hook2): mock_hook.return_value.list.return_value = MOCK_FILES mock_hook.return_value.download.return_value = b"testing" mock_hook2.return_value.list.return_value = MOCK_FILES operator = GCSToS3Operator(task_id=TASK_ID, bucket=GCS_BUCKET, prefix=PREFIX, delimiter=DELIMITER, dest_aws_conn_id=None, dest_s3_key=S3_BUCKET, replace=True) # create dest bucket with all the files hook = S3Hook(aws_conn_id=None) bucket = hook.get_bucket('bucket') bucket.create() for mock_file in MOCK_FILES: bucket.put_object(Key=mock_file, Body=b'testing') # we expect all MOCK_FILES to be uploaded and replace the existing ones # and all MOCK_FILES to be present at the S3 bucket uploaded_files = operator.execute(None) self.assertEqual(sorted(MOCK_FILES), sorted(uploaded_files)) self.assertEqual(sorted(MOCK_FILES), sorted(hook.list_keys('bucket', delimiter='/'))) # Test5: Incremental sync with replace @mock_s3 @mock.patch('airflow.providers.google.cloud.operators.gcs.GCSHook') @mock.patch('airflow.providers.amazon.aws.operators.gcs_to_s3.GCSHook') def test_execute_incremental_with_replace(self, mock_hook, mock_hook2): mock_hook.return_value.list.return_value = MOCK_FILES mock_hook.return_value.download.return_value = b"testing" mock_hook2.return_value.list.return_value = MOCK_FILES operator = GCSToS3Operator(task_id=TASK_ID, bucket=GCS_BUCKET, prefix=PREFIX, delimiter=DELIMITER, dest_aws_conn_id=None, dest_s3_key=S3_BUCKET, replace=True) # create dest bucket with just two files (the first two files in MOCK_FILES) hook = S3Hook(aws_conn_id=None) bucket = hook.get_bucket('bucket') bucket.create() for mock_file in MOCK_FILES[:2]: bucket.put_object(Key=mock_file, Body=b'testing') # we expect all the MOCK_FILES to be uploaded and replace the existing ones # and all MOCK_FILES to be present at the S3 bucket uploaded_files = operator.execute(None) self.assertEqual(sorted(MOCK_FILES), sorted(uploaded_files)) self.assertEqual(sorted(MOCK_FILES), sorted(hook.list_keys('bucket', delimiter='/')))
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 2882, 199, 199, 646, 1683, 199, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 7922, 14, 83, 19, 492, 428, 19, 8481, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 12688, 14, 21757, 63, 475, 63, 83, 19, 492, 31555, 840, 79, 51, 19, 7961, 199, 199, 893, 26, 272, 687, 333, 3459, 492, 1683, 63, 83, 19, 199, 2590, 3545, 26, 272, 1683, 63, 83, 19, 275, 488, 199, 199, 17179, 63, 998, 275, 283, 396, 13, 21757, 13, 513, 13, 3856, 7, 199, 39, 3298, 63, 20156, 275, 283, 396, 13, 4623, 7, 199, 32717, 540, 275, 1987, 4737, 7, 199, 6351, 275, 283, 2864, 7, 199, 51, 19, 63, 20156, 275, 283, 83, 19, 921, 4623, 4805, 199, 17749, 63, 9472, 275, 2097, 2864, 17, 14, 4737, 401, 298, 2864, 18, 14, 4737, 401, 298, 2864, 19, 14, 4737, 937, 421, 199, 533, 1379, 7484, 840, 79, 51, 19, 7961, 8, 2796, 14, 1746, 304, 339, 327, 1379, 17, 26, 16316, 13942, 334, 4764, 2005, 1584, 4124, 9, 272, 768, 1805, 63, 83, 19, 272, 768, 1805, 14, 2068, 360, 15815, 14, 9710, 14, 3098, 14, 4091, 14, 12688, 14, 21757, 14, 7484, 3234, 6992, 358, 272, 768, 1805, 14, 2068, 360, 15815, 14, 9710, 14, 15144, 14, 7231, 14, 12688, 14, 21757, 63, 475, 63, 83, 19, 14, 7484, 3234, 6992, 358, 272, 347, 511, 63, 2526, 63, 23760, 8, 277, 12, 1683, 63, 3664, 12, 1683, 63, 3664, 18, 304, 267, 1683, 63, 3664, 14, 1107, 63, 585, 14, 513, 14, 1107, 63, 585, 275, 10362, 2504, 63, 9472, 267, 1683, 63, 3664, 14, 1107, 63, 585, 14, 4249, 14, 1107, 63, 585, 275, 330, 2, 4776, 2, 267, 1683, 63, 3664, 18, 14, 1107, 63, 585, 14, 513, 14, 1107, 63, 585, 275, 10362, 2504, 63, 9472, 398, 4182, 275, 31555, 840, 79, 51, 19, 7961, 8, 1765, 63, 344, 29, 17179, 63, 998, 12, 3521, 5315, 29, 39, 3298, 63, 20156, 12, 3521, 2403, 29, 6351, 12, 3521, 11172, 29, 32717, 540, 12, 3521, 2053, 63, 7231, 63, 1631, 63, 344, 29, 403, 12, 3521, 2053, 63, 83, 19, 63, 498, 29, 51, 19, 63, 20156, 12, 3521, 3350, 29, 797, 9, 267, 327, 1218, 2053, 5315, 267, 5759, 275, 428, 19, 8481, 8, 7231, 63, 1631, 63, 344, 29, 403, 9, 267, 5315, 275, 5759, 14, 362, 63, 4623, 360, 4623, 358, 267, 5315, 14, 981, 342, 267, 5315, 14, 524, 63, 785, 8, 1197, 29, 17749, 63, 9472, 59, 16, 467, 29665, 29, 66, 1133, 597, 316, 358, 398, 327, 781, 4282, 1006, 871, 1642, 570, 315, 10362, 2504, 63, 9472, 370, 506, 14238, 267, 327, 436, 1006, 314, 10362, 2504, 63, 9472, 370, 506, 3451, 737, 314, 428, 19, 5315, 267, 14238, 63, 1725, 275, 4182, 14, 2526, 8, 403, 9, 267, 291, 14, 629, 8, 5917, 8, 17749, 63, 9472, 59, 17, 26, 2522, 586, 3355, 8, 19044, 63, 1725, 430, 267, 291, 14, 629, 8, 5917, 8, 17749, 63, 9472, 395, 586, 3355, 8, 3664, 14, 513, 63, 1612, 360, 4623, 297, 11172, 534, 6217, 430, 339, 327, 1379, 18, 26, 2900, 314, 1584, 787, 2575, 315, 6330, 436, 5724, 1928, 3350, 272, 768, 1805, 63, 83, 19, 272, 768, 1805, 14, 2068, 360, 15815, 14, 9710, 14, 3098, 14, 4091, 14, 12688, 14, 21757, 14, 7484, 3234, 6992, 358, 272, 768, 1805, 14, 2068, 360, 15815, 14, 9710, 14, 15144, 14, 7231, 14, 12688, 14, 21757, 63, 475, 63, 83, 19, 14, 7484, 3234, 6992, 358, 272, 347, 511, 63, 2526, 63, 7395, 63, 1814, 8, 277, 12, 1683, 63, 3664, 12, 1683, 63, 3664, 18, 304, 267, 1683, 63, 3664, 14, 1107, 63, 585, 14, 513, 14, 1107, 63, 585, 275, 10362, 2504, 63, 9472, 267, 1683, 63, 3664, 14, 1107, 63, 585, 14, 4249, 14, 1107, 63, 585, 275, 330, 2, 4776, 2, 267, 1683, 63, 3664, 18, 14, 1107, 63, 585, 14, 513, 14, 1107, 63, 585, 275, 10362, 2504, 63, 9472, 398, 4182, 275, 31555, 840, 79, 51, 19, 7961, 8, 1765, 63, 344, 29, 17179, 63, 998, 12, 3521, 5315, 29, 39, 3298, 63, 20156, 12, 3521, 2403, 29, 6351, 12, 3521, 11172, 29, 32717, 540, 12, 3521, 2053, 63, 7231, 63, 1631, 63, 344, 29, 403, 12, 3521, 2053, 63, 83, 19, 63, 498, 29, 51, 19, 63, 20156, 12, 3521, 3350, 29, 797, 9, 267, 327, 1218, 2053, 5315, 543, 1006, 314, 1584, 267, 5759, 275, 428, 19, 8481, 8, 7231, 63, 1631, 63, 344, 29, 403, 9, 267, 5315, 275, 5759, 14, 362, 63, 4623, 360, 4623, 358, 267, 5315, 14, 981, 342, 267, 367, 1683, 63, 493, 315, 10362, 2504, 63, 9472, 26, 288, 5315, 14, 524, 63, 785, 8, 1197, 29, 1805, 63, 493, 12, 29665, 29, 66, 1133, 597, 316, 358, 398, 327, 781, 4282, 6548, 370, 506, 14238, 267, 327, 436, 1006, 314, 10362, 2504, 63, 9472, 370, 506, 3451, 737, 314, 428, 19, 5315, 267, 14238, 63, 1725, 275 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 199, 3, 503, 1655, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 199, 3, 1854, 543, 642, 1736, 367, 4722, 2556, 199, 3, 12602, 4248, 12715, 14, 221, 710, 14857, 12378, 642, 570, 199, 3, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 199, 3, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 199, 3, 543, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 257, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 199, 3, 2032, 1854, 1334, 314, 844, 365, 1854, 641, 376, 199, 3, 298, 1179, 2281, 2, 4207, 12, 2428, 2990, 1549, 4217, 1634, 1821, 199, 3, 3826, 12, 1902, 4056, 503, 2478, 14, 221, 1666, 314, 844, 367, 314, 199, 3, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 1334, 314, 844, 14, 199, 199, 646, 2882, 199, 199, 646, 1683, 199, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 7922, 14, 83, 19, 492, 428, 19, 8481, 199, 504, 16321, 14, 9710, 14, 15144, 14, 7231, 14, 12688, 14, 21757, 63, 475, 63, 83, 19, 492, 31555, 840, 79, 51, 19, 7961, 199, 199, 893, 26, 272, 687, 333, 3459, 492, 1683, 63, 83, 19, 199, 2590, 3545, 26, 272, 1683, 63, 83, 19, 275, 488, 199, 199, 17179, 63, 998, 275, 283, 396, 13, 21757, 13, 513, 13, 3856, 7, 199, 39, 3298, 63, 20156, 275, 283, 396, 13, 4623, 7, 199, 32717, 540, 275, 1987, 4737, 7, 199, 6351, 275, 283, 2864, 7, 199, 51, 19, 63, 20156, 275, 283, 83, 19, 921, 4623, 4805, 199, 17749, 63, 9472, 275, 2097, 2864, 17, 14, 4737, 401, 298, 2864, 18, 14, 4737, 401, 298, 2864, 19, 14, 4737, 937, 421, 199, 533, 1379, 7484, 840, 79, 51, 19, 7961, 8, 2796, 14, 1746, 304, 339, 327, 1379, 17, 26, 16316, 13942, 334, 4764, 2005, 1584, 4124, 9, 272, 768, 1805, 63, 83, 19, 272, 768, 1805, 14, 2068, 360, 15815, 14, 9710, 14, 3098, 14, 4091, 14, 12688, 14, 21757, 14, 7484, 3234, 6992, 358, 272, 768, 1805, 14, 2068, 360, 15815, 14, 9710, 14, 15144, 14, 7231, 14, 12688, 14, 21757, 63, 475, 63, 83, 19, 14, 7484, 3234, 6992, 358, 272, 347, 511, 63, 2526, 63, 23760, 8, 277, 12, 1683, 63, 3664, 12, 1683, 63, 3664, 18, 304, 267, 1683, 63, 3664, 14, 1107, 63, 585, 14, 513, 14, 1107, 63, 585, 275, 10362, 2504, 63, 9472, 267, 1683, 63, 3664, 14, 1107, 63, 585, 14, 4249, 14, 1107, 63, 585, 275, 330, 2, 4776, 2, 267, 1683, 63, 3664, 18, 14, 1107, 63, 585, 14, 513, 14, 1107, 63, 585, 275, 10362, 2504, 63, 9472, 398, 4182, 275, 31555, 840, 79, 51, 19, 7961, 8, 1765, 63, 344, 29, 17179, 63, 998, 12, 3521, 5315, 29, 39, 3298, 63, 20156, 12, 3521, 2403, 29, 6351, 12, 3521, 11172, 29, 32717, 540, 12, 3521, 2053, 63, 7231, 63, 1631, 63, 344, 29, 403, 12, 3521, 2053, 63, 83, 19, 63, 498, 29, 51, 19, 63, 20156, 12, 3521, 3350, 29, 797, 9, 267, 327, 1218, 2053, 5315, 267, 5759, 275, 428, 19, 8481, 8, 7231, 63, 1631, 63, 344, 29, 403, 9, 267, 5315, 275, 5759, 14, 362, 63, 4623, 360, 4623, 358, 267, 5315, 14, 981, 342, 267, 5315, 14, 524, 63, 785, 8, 1197, 29, 17749, 63, 9472, 59, 16, 467, 29665, 29, 66, 1133, 597, 316, 358, 398, 327, 781, 4282, 1006, 871, 1642, 570, 315, 10362, 2504, 63, 9472, 370, 506, 14238, 267, 327, 436, 1006, 314, 10362, 2504, 63, 9472, 370, 506, 3451, 737, 314, 428, 19, 5315, 267, 14238, 63, 1725, 275, 4182, 14, 2526, 8, 403, 9, 267, 291, 14, 629, 8, 5917, 8, 17749, 63, 9472, 59, 17, 26, 2522, 586, 3355, 8, 19044, 63, 1725, 430, 267, 291, 14, 629, 8, 5917, 8, 17749, 63, 9472, 395, 586, 3355, 8, 3664, 14, 513, 63, 1612, 360, 4623, 297, 11172, 534, 6217, 430, 339, 327, 1379, 18, 26, 2900, 314, 1584, 787, 2575, 315, 6330, 436, 5724, 1928, 3350, 272, 768, 1805, 63, 83, 19, 272, 768, 1805, 14, 2068, 360, 15815, 14, 9710, 14, 3098, 14, 4091, 14, 12688, 14, 21757, 14, 7484, 3234, 6992, 358, 272, 768, 1805, 14, 2068, 360, 15815, 14, 9710, 14, 15144, 14, 7231, 14, 12688, 14, 21757, 63, 475, 63, 83, 19, 14, 7484, 3234, 6992, 358, 272, 347, 511, 63, 2526, 63, 7395, 63, 1814, 8, 277, 12, 1683, 63, 3664, 12, 1683, 63, 3664, 18, 304, 267, 1683, 63, 3664, 14, 1107, 63, 585, 14, 513, 14, 1107, 63, 585, 275, 10362, 2504, 63, 9472, 267, 1683, 63, 3664, 14, 1107, 63, 585, 14, 4249, 14, 1107, 63, 585, 275, 330, 2, 4776, 2, 267, 1683, 63, 3664, 18, 14, 1107, 63, 585, 14, 513, 14, 1107, 63, 585, 275, 10362, 2504, 63, 9472, 398, 4182, 275, 31555, 840, 79, 51, 19, 7961, 8, 1765, 63, 344, 29, 17179, 63, 998, 12, 3521, 5315, 29, 39, 3298, 63, 20156, 12, 3521, 2403, 29, 6351, 12, 3521, 11172, 29, 32717, 540, 12, 3521, 2053, 63, 7231, 63, 1631, 63, 344, 29, 403, 12, 3521, 2053, 63, 83, 19, 63, 498, 29, 51, 19, 63, 20156, 12, 3521, 3350, 29, 797, 9, 267, 327, 1218, 2053, 5315, 543, 1006, 314, 1584, 267, 5759, 275, 428, 19, 8481, 8, 7231, 63, 1631, 63, 344, 29, 403, 9, 267, 5315, 275, 5759, 14, 362, 63, 4623, 360, 4623, 358, 267, 5315, 14, 981, 342, 267, 367, 1683, 63, 493, 315, 10362, 2504, 63, 9472, 26, 288, 5315, 14, 524, 63, 785, 8, 1197, 29, 1805, 63, 493, 12, 29665, 29, 66, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
dmwyatt/disney.api
pages/timepicker.py
1
3504
import datetime import logging import os import time import re import webbrowser from dateutil import parser from selenium import webdriver from selenium.common.exceptions import WebDriverException, NoSuchElementException from selenium.webdriver.support.select import Select from helpers import roundTime, difference_in_minutes, format_dt from pages.helpers import wait_for logger = logging.getLogger(__name__) class TimeNotBookableError(Exception): pass class BasicTimePicker: select_selector = 'select#diningAvailabilityForm-searchTime' def __init__(self, browser: webdriver.PhantomJS): self.browser = browser @property def select_element(self): return self.browser.find_element_by_css_selector(self.select_selector) @property def select(self): return Select(self.select_element) @property def option_elements(self): return self.select_element.find_elements_by_tag_name('option') @property def selectable_values(self): return [x.get_attribute('value') for x in self.option_elements] @property def selectable_texts(self): return [x.text for x in self.option_elements] def select_exact_time(self, desired_dt: datetime.datetime): the_time = desired_dt.strftime('%H:%M') if not the_time in self.selectable_values: raise TimeNotBookableError("Cannot select '{}' from {}".format(the_time, self.selectable_values)) self.select.select_by_value(the_time) def select_time_with_leeway(self, desired_dt: datetime.datetime, leeway: int): closest = None closest_delta = None for sv in self.selectable_values: if not re.match('\d\d:\d\d', sv): continue sv_dt = time_to_datetime(sv, desired_dt) if not closest: closest = sv_dt closest_delta = difference_in_minutes(desired_dt, closest) curr_sv_delta = difference_in_minutes(sv_dt, desired_dt) if curr_sv_delta < closest_delta: closest = sv_dt closest_delta = curr_sv_delta if closest_delta <= leeway: self.select_exact_time(closest) else: raise TimeNotBookableError("There is no selectable time that's " "less than {} minutes from {} " "in {}".format(leeway, format_dt(desired_dt), self.selectable_values)) def select_closest_time(self, desired_dt: datetime.datetime): closest = None closest_delta = None for sv in self.selectable_values: if not re.match('\d\d:\d\d', sv): continue sv_dt = time_to_datetime(sv, desired_dt) if not closest: closest = sv_dt closest_delta = difference_in_minutes(desired_dt, closest) curr_sv_delta = difference_in_minutes(sv_dt, desired_dt) if curr_sv_delta < closest_delta: closest = sv_dt closest_delta = curr_sv_delta self.select_exact_time(closest) def select_meal(self, meal): try: self.select.select_by_visible_text(meal) except NoSuchElementException: raise TimeNotBookableError("Cannot select '{}' from {}".format(meal, self.selectable_texts)) def select_breakfast(self): self.select_meal('Breakfast') def select_lunch(self): self.select_meal('Lunch') def select_dinner(self): self.select_meal('Dinner') def time_to_datetime(the_time: str, reference_dt: datetime.datetime) -> datetime.datetime: """ Takes a string representing a time and a datetime.datetime that represents the day that time is on, and returns a datetime.datetime on that day with the new time. """ dt = parser.parse(the_time) return dt.replace(year=reference_dt.year, month=reference_dt.month, day=reference_dt.day)
mit
[ 646, 2197, 199, 646, 2050, 199, 646, 747, 199, 646, 900, 199, 199, 646, 295, 199, 646, 781, 29063, 199, 199, 504, 22208, 492, 1798, 199, 504, 19481, 492, 28094, 199, 504, 19481, 14, 2330, 14, 3924, 492, 27104, 1726, 12, 23798, 2162, 1726, 199, 504, 19481, 14, 17946, 14, 4058, 14, 2416, 492, 9496, 199, 199, 504, 10897, 492, 6168, 1366, 12, 8865, 63, 262, 63, 10430, 12, 1475, 63, 3583, 199, 504, 6497, 14, 7546, 492, 3618, 63, 509, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 4703, 1763, 8696, 461, 547, 8, 1726, 304, 199, 198, 1529, 199, 199, 533, 10082, 1366, 27269, 26, 199, 198, 2416, 63, 6662, 275, 283, 2416, 3, 68, 7969, 26462, 2821, 13, 1733, 1366, 7, 421, 198, 318, 636, 826, 721, 277, 12, 7042, 26, 28094, 14, 5663, 290, 3151, 11378, 304, 507, 198, 277, 14, 5750, 275, 7042, 421, 198, 32, 1829, 199, 198, 318, 3504, 63, 2108, 8, 277, 304, 507, 198, 1107, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 8, 277, 14, 2416, 63, 6662, 9, 421, 198, 32, 1829, 199, 198, 318, 3504, 8, 277, 304, 507, 198, 1107, 9496, 8, 277, 14, 2416, 63, 2108, 9, 421, 198, 32, 1829, 199, 198, 318, 945, 63, 5527, 8, 277, 304, 507, 198, 1107, 291, 14, 2416, 63, 2108, 14, 1623, 63, 5527, 63, 991, 63, 1450, 63, 354, 360, 1422, 358, 421, 198, 32, 1829, 199, 198, 318, 23378, 63, 1459, 8, 277, 304, 507, 198, 1107, 359, 88, 14, 362, 63, 3215, 360, 585, 358, 367, 671, 315, 291, 14, 1422, 63, 5527, 61, 421, 198, 32, 1829, 199, 198, 318, 23378, 63, 19517, 8, 277, 304, 507, 198, 1107, 359, 88, 14, 505, 367, 671, 315, 291, 14, 1422, 63, 5527, 61, 421, 198, 318, 3504, 63, 7327, 63, 521, 8, 277, 12, 6387, 63, 3583, 26, 2197, 14, 2083, 304, 507, 198, 1589, 63, 521, 275, 6387, 63, 3583, 14, 6205, 3508, 40, 2689, 45, 358, 507, 198, 692, 440, 314, 63, 521, 315, 291, 14, 18837, 63, 1459, 26, 686, 198, 3730, 4703, 1763, 8696, 461, 547, 480, 6612, 3504, 19574, 687, 8352, 908, 8, 1589, 63, 521, 12, 291, 14, 18837, 63, 1459, 430, 507, 198, 277, 14, 2416, 14, 2416, 63, 991, 63, 585, 8, 1589, 63, 521, 9, 421, 198, 318, 3504, 63, 521, 63, 1045, 63, 274, 546, 1187, 8, 277, 12, 6387, 63, 3583, 26, 2197, 14, 2083, 12, 1026, 546, 1187, 26, 1109, 304, 507, 198, 22061, 275, 488, 507, 198, 22061, 63, 3136, 275, 488, 507, 198, 509, 19291, 315, 291, 14, 18837, 63, 1459, 26, 686, 198, 692, 440, 295, 14, 1431, 2258, 68, 60, 68, 3427, 68, 60, 68, 297, 19291, 304, 1585, 198, 6958, 6319, 198, 2772, 63, 3583, 275, 900, 63, 475, 63, 2083, 8, 2772, 12, 6387, 63, 3583, 9, 6319, 198, 692, 440, 18284, 26, 1585, 198, 22061, 275, 19291, 63, 3583, 1585, 198, 22061, 63, 3136, 275, 8865, 63, 262, 63, 10430, 8, 16035, 63, 3583, 12, 18284, 9, 6319, 198, 9808, 63, 2772, 63, 3136, 275, 8865, 63, 262, 63, 10430, 8, 2772, 63, 3583, 12, 6387, 63, 3583, 9, 686, 198, 692, 8230, 63, 2772, 63, 3136, 665, 18284, 63, 3136, 26, 1585, 198, 22061, 275, 19291, 63, 3583, 1585, 198, 22061, 63, 3136, 275, 8230, 63, 2772, 63, 3136, 2742, 198, 692, 18284, 63, 3136, 2695, 1026, 546, 1187, 26, 686, 198, 277, 14, 2416, 63, 7327, 63, 521, 8, 22061, 9, 507, 198, 2836, 26, 686, 198, 3730, 4703, 1763, 8696, 461, 547, 480, 10924, 365, 949, 23378, 900, 626, 1159, 298, 1585, 13235, 298, 2003, 2419, 1052, 9395, 687, 1052, 298, 1585, 13235, 298, 262, 8352, 908, 8, 274, 546, 1187, 12, 1475, 63, 3583, 8, 16035, 63, 3583, 395, 291, 14, 18837, 63, 1459, 430, 421, 198, 318, 3504, 63, 22061, 63, 521, 8, 277, 12, 6387, 63, 3583, 26, 2197, 14, 2083, 304, 507, 198, 22061, 275, 488, 507, 198, 22061, 63, 3136, 275, 488, 507, 198, 509, 19291, 315, 291, 14, 18837, 63, 1459, 26, 686, 198, 692, 440, 295, 14, 1431, 2258, 68, 60, 68, 3427, 68, 60, 68, 297, 19291, 304, 1585, 198, 6958, 6319, 198, 2772, 63, 3583, 275, 900, 63, 475, 63, 2083, 8, 2772, 12, 6387, 63, 3583, 9, 6319, 198, 692, 440, 18284, 26, 1585, 198, 22061, 275, 19291, 63, 3583, 1585, 198, 22061, 63, 3136, 275, 8865, 63, 262, 63, 10430, 8, 16035, 63, 3583, 12, 18284, 9, 6319, 198, 9808, 63, 2772, 63, 3136, 275, 8865, 63, 262, 63, 10430, 8, 2772, 63, 3583, 12, 6387, 63, 3583, 9, 686, 198, 692, 8230, 63, 2772, 63, 3136, 665, 18284, 63, 3136, 26, 1585, 198, 22061, 275, 19291, 63, 3583, 1585, 198, 22061, 63, 3136, 275, 8230, 63, 2772, 63, 3136, 2742, 198, 277, 14, 2416, 63, 7327, 63, 521, 8, 22061, 9, 421, 198, 318, 3504, 63, 278, 279, 8, 277, 12, 562, 279, 304, 507, 198, 893, 26, 686, 198, 277, 14, 2416, 14, 2416, 63, 991, 63, 6604, 63, 505, 8, 278, 279, 9, 507, 198, 2590, 23798, 2162, 1726, 26, 686, 198, 3730, 4703, 1763, 8696, 461, 547, 480, 6612, 3504, 19574, 687, 8352, 908, 8, 278, 279, 12, 291, 14, 18837, 63, 19517, 430, 421, 198, 318, 3504, 63, 4785, 7015, 8, 277, 304, 507, 198, 277, 14, 2416, 63, 278, 279, 360, 13948, 7015, 358, 421, 198, 318, 3504, 63, 76, 4689, 8, 277, 304, 507, 198, 277, 14, 2416, 63, 278, 279, 360, 44, 4689, 358, 421, 198, 318, 3504, 63, 68, 5216, 8, 277, 304, 507, 198, 277, 14, 2416, 63, 278, 279, 360, 36, 5216, 358, 421, 199, 318, 900, 63, 475, 63, 2083, 8, 1589, 63, 521, 26, 620, 12, 3659, 63, 3583, 26, 2197, 14, 2083, 9, 1035, 2197, 14, 2083, 26, 199, 198, 624, 199, 198, 32488, 282, 1059, 6144, 282, 900, 436, 282, 2197, 14, 2083, 626, 8469, 314, 5382, 626, 900, 199, 198, 374, 641, 12, 436, 2529, 282, 2197, 14, 2083, 641 ]
[ 2197, 199, 646, 2050, 199, 646, 747, 199, 646, 900, 199, 199, 646, 295, 199, 646, 781, 29063, 199, 199, 504, 22208, 492, 1798, 199, 504, 19481, 492, 28094, 199, 504, 19481, 14, 2330, 14, 3924, 492, 27104, 1726, 12, 23798, 2162, 1726, 199, 504, 19481, 14, 17946, 14, 4058, 14, 2416, 492, 9496, 199, 199, 504, 10897, 492, 6168, 1366, 12, 8865, 63, 262, 63, 10430, 12, 1475, 63, 3583, 199, 504, 6497, 14, 7546, 492, 3618, 63, 509, 199, 199, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 533, 4703, 1763, 8696, 461, 547, 8, 1726, 304, 199, 198, 1529, 199, 199, 533, 10082, 1366, 27269, 26, 199, 198, 2416, 63, 6662, 275, 283, 2416, 3, 68, 7969, 26462, 2821, 13, 1733, 1366, 7, 421, 198, 318, 636, 826, 721, 277, 12, 7042, 26, 28094, 14, 5663, 290, 3151, 11378, 304, 507, 198, 277, 14, 5750, 275, 7042, 421, 198, 32, 1829, 199, 198, 318, 3504, 63, 2108, 8, 277, 304, 507, 198, 1107, 291, 14, 5750, 14, 1623, 63, 2108, 63, 991, 63, 3919, 63, 6662, 8, 277, 14, 2416, 63, 6662, 9, 421, 198, 32, 1829, 199, 198, 318, 3504, 8, 277, 304, 507, 198, 1107, 9496, 8, 277, 14, 2416, 63, 2108, 9, 421, 198, 32, 1829, 199, 198, 318, 945, 63, 5527, 8, 277, 304, 507, 198, 1107, 291, 14, 2416, 63, 2108, 14, 1623, 63, 5527, 63, 991, 63, 1450, 63, 354, 360, 1422, 358, 421, 198, 32, 1829, 199, 198, 318, 23378, 63, 1459, 8, 277, 304, 507, 198, 1107, 359, 88, 14, 362, 63, 3215, 360, 585, 358, 367, 671, 315, 291, 14, 1422, 63, 5527, 61, 421, 198, 32, 1829, 199, 198, 318, 23378, 63, 19517, 8, 277, 304, 507, 198, 1107, 359, 88, 14, 505, 367, 671, 315, 291, 14, 1422, 63, 5527, 61, 421, 198, 318, 3504, 63, 7327, 63, 521, 8, 277, 12, 6387, 63, 3583, 26, 2197, 14, 2083, 304, 507, 198, 1589, 63, 521, 275, 6387, 63, 3583, 14, 6205, 3508, 40, 2689, 45, 358, 507, 198, 692, 440, 314, 63, 521, 315, 291, 14, 18837, 63, 1459, 26, 686, 198, 3730, 4703, 1763, 8696, 461, 547, 480, 6612, 3504, 19574, 687, 8352, 908, 8, 1589, 63, 521, 12, 291, 14, 18837, 63, 1459, 430, 507, 198, 277, 14, 2416, 14, 2416, 63, 991, 63, 585, 8, 1589, 63, 521, 9, 421, 198, 318, 3504, 63, 521, 63, 1045, 63, 274, 546, 1187, 8, 277, 12, 6387, 63, 3583, 26, 2197, 14, 2083, 12, 1026, 546, 1187, 26, 1109, 304, 507, 198, 22061, 275, 488, 507, 198, 22061, 63, 3136, 275, 488, 507, 198, 509, 19291, 315, 291, 14, 18837, 63, 1459, 26, 686, 198, 692, 440, 295, 14, 1431, 2258, 68, 60, 68, 3427, 68, 60, 68, 297, 19291, 304, 1585, 198, 6958, 6319, 198, 2772, 63, 3583, 275, 900, 63, 475, 63, 2083, 8, 2772, 12, 6387, 63, 3583, 9, 6319, 198, 692, 440, 18284, 26, 1585, 198, 22061, 275, 19291, 63, 3583, 1585, 198, 22061, 63, 3136, 275, 8865, 63, 262, 63, 10430, 8, 16035, 63, 3583, 12, 18284, 9, 6319, 198, 9808, 63, 2772, 63, 3136, 275, 8865, 63, 262, 63, 10430, 8, 2772, 63, 3583, 12, 6387, 63, 3583, 9, 686, 198, 692, 8230, 63, 2772, 63, 3136, 665, 18284, 63, 3136, 26, 1585, 198, 22061, 275, 19291, 63, 3583, 1585, 198, 22061, 63, 3136, 275, 8230, 63, 2772, 63, 3136, 2742, 198, 692, 18284, 63, 3136, 2695, 1026, 546, 1187, 26, 686, 198, 277, 14, 2416, 63, 7327, 63, 521, 8, 22061, 9, 507, 198, 2836, 26, 686, 198, 3730, 4703, 1763, 8696, 461, 547, 480, 10924, 365, 949, 23378, 900, 626, 1159, 298, 1585, 13235, 298, 2003, 2419, 1052, 9395, 687, 1052, 298, 1585, 13235, 298, 262, 8352, 908, 8, 274, 546, 1187, 12, 1475, 63, 3583, 8, 16035, 63, 3583, 395, 291, 14, 18837, 63, 1459, 430, 421, 198, 318, 3504, 63, 22061, 63, 521, 8, 277, 12, 6387, 63, 3583, 26, 2197, 14, 2083, 304, 507, 198, 22061, 275, 488, 507, 198, 22061, 63, 3136, 275, 488, 507, 198, 509, 19291, 315, 291, 14, 18837, 63, 1459, 26, 686, 198, 692, 440, 295, 14, 1431, 2258, 68, 60, 68, 3427, 68, 60, 68, 297, 19291, 304, 1585, 198, 6958, 6319, 198, 2772, 63, 3583, 275, 900, 63, 475, 63, 2083, 8, 2772, 12, 6387, 63, 3583, 9, 6319, 198, 692, 440, 18284, 26, 1585, 198, 22061, 275, 19291, 63, 3583, 1585, 198, 22061, 63, 3136, 275, 8865, 63, 262, 63, 10430, 8, 16035, 63, 3583, 12, 18284, 9, 6319, 198, 9808, 63, 2772, 63, 3136, 275, 8865, 63, 262, 63, 10430, 8, 2772, 63, 3583, 12, 6387, 63, 3583, 9, 686, 198, 692, 8230, 63, 2772, 63, 3136, 665, 18284, 63, 3136, 26, 1585, 198, 22061, 275, 19291, 63, 3583, 1585, 198, 22061, 63, 3136, 275, 8230, 63, 2772, 63, 3136, 2742, 198, 277, 14, 2416, 63, 7327, 63, 521, 8, 22061, 9, 421, 198, 318, 3504, 63, 278, 279, 8, 277, 12, 562, 279, 304, 507, 198, 893, 26, 686, 198, 277, 14, 2416, 14, 2416, 63, 991, 63, 6604, 63, 505, 8, 278, 279, 9, 507, 198, 2590, 23798, 2162, 1726, 26, 686, 198, 3730, 4703, 1763, 8696, 461, 547, 480, 6612, 3504, 19574, 687, 8352, 908, 8, 278, 279, 12, 291, 14, 18837, 63, 19517, 430, 421, 198, 318, 3504, 63, 4785, 7015, 8, 277, 304, 507, 198, 277, 14, 2416, 63, 278, 279, 360, 13948, 7015, 358, 421, 198, 318, 3504, 63, 76, 4689, 8, 277, 304, 507, 198, 277, 14, 2416, 63, 278, 279, 360, 44, 4689, 358, 421, 198, 318, 3504, 63, 68, 5216, 8, 277, 304, 507, 198, 277, 14, 2416, 63, 278, 279, 360, 36, 5216, 358, 421, 199, 318, 900, 63, 475, 63, 2083, 8, 1589, 63, 521, 26, 620, 12, 3659, 63, 3583, 26, 2197, 14, 2083, 9, 1035, 2197, 14, 2083, 26, 199, 198, 624, 199, 198, 32488, 282, 1059, 6144, 282, 900, 436, 282, 2197, 14, 2083, 626, 8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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
tangyiyong/odoo
addons/base_vat/base_vat.py
238
14207
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2012 OpenERP SA (<http://openerp.com>) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import logging import string import datetime import re _logger = logging.getLogger(__name__) try: import vatnumber except ImportError: _logger.warning("VAT validation partially unavailable because the `vatnumber` Python library cannot be found. " "Install it to support more countries, for example with `easy_install vatnumber`.") vatnumber = None from openerp.osv import fields, osv from openerp.tools.misc import ustr from openerp.tools.translate import _ _ref_vat = { 'at': 'ATU12345675', 'be': 'BE0477472701', 'bg': 'BG1234567892', 'ch': 'CHE-123.456.788 TVA or CH TVA 123456', #Swiss by Yannick Vaucher @ Camptocamp 'cy': 'CY12345678F', 'cz': 'CZ12345679', 'de': 'DE123456788', 'dk': 'DK12345674', 'ee': 'EE123456780', 'el': 'EL12345670', 'es': 'ESA12345674', 'fi': 'FI12345671', 'fr': 'FR32123456789', 'gb': 'GB123456782', 'gr': 'GR12345670', 'hu': 'HU12345676', 'hr': 'HR01234567896', # Croatia, contributed by Milan Tribuson 'ie': 'IE1234567FA', 'it': 'IT12345670017', 'lt': 'LT123456715', 'lu': 'LU12345613', 'lv': 'LV41234567891', 'mt': 'MT12345634', 'mx': 'MXABC123456T1B', 'nl': 'NL123456782B90', 'no': 'NO123456785', 'pe': 'PER10254824220 or PED10254824220', 'pl': 'PL1234567883', 'pt': 'PT123456789', 'ro': 'RO1234567897', 'se': 'SE123456789701', 'si': 'SI12345679', 'sk': 'SK0012345675', 'tr': 'TR1234567890 (VERGINO) veya TR12345678901 (TCKIMLIKNO)' # Levent Karakas @ Eska Yazilim A.S. } class res_partner(osv.osv): _inherit = 'res.partner' def _split_vat(self, vat): vat_country, vat_number = vat[:2].lower(), vat[2:].replace(' ', '') return vat_country, vat_number def simple_vat_check(self, cr, uid, country_code, vat_number, context=None): ''' Check the VAT number depending of the country. http://sima-pc.com/nif.php ''' if not ustr(country_code).encode('utf-8').isalpha(): return False check_func_name = 'check_vat_' + country_code check_func = getattr(self, check_func_name, None) or \ getattr(vatnumber, check_func_name, None) if not check_func: # No VAT validation available, default to check that the country code exists if country_code.upper() == 'EU': # Foreign companies that trade with non-enterprises in the EU # may have a VATIN starting with "EU" instead of a country code. return True res_country = self.pool.get('res.country') return bool(res_country.search(cr, uid, [('code', '=ilike', country_code)], context=context)) return check_func(vat_number) def vies_vat_check(self, cr, uid, country_code, vat_number, context=None): try: # Validate against VAT Information Exchange System (VIES) # see also http://ec.europa.eu/taxation_customs/vies/ return vatnumber.check_vies(country_code.upper()+vat_number) except Exception: # see http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl # Fault code may contain INVALID_INPUT, SERVICE_UNAVAILABLE, MS_UNAVAILABLE, # TIMEOUT or SERVER_BUSY. There is no way we can validate the input # with VIES if any of these arise, including the first one (it means invalid # country code or empty VAT number), so we fall back to the simple check. return self.simple_vat_check(cr, uid, country_code, vat_number, context=context) def button_check_vat(self, cr, uid, ids, context=None): if not self.check_vat(cr, uid, ids, context=context): msg = self._construct_constraint_msg(cr, uid, ids, context=context) raise osv.except_osv(_('Error!'), msg) return True def check_vat(self, cr, uid, ids, context=None): user_company = self.pool.get('res.users').browse(cr, uid, uid).company_id if user_company.vat_check_vies: # force full VIES online check check_func = self.vies_vat_check else: # quick and partial off-line checksum validation check_func = self.simple_vat_check for partner in self.browse(cr, uid, ids, context=context): if not partner.vat: continue vat_country, vat_number = self._split_vat(partner.vat) if not check_func(cr, uid, vat_country, vat_number, context=context): _logger.info(_("Importing VAT Number [%s] is not valid !" % vat_number)) return False return True def vat_change(self, cr, uid, ids, value, context=None): return {'value': {'vat_subjected': bool(value)}} def _commercial_fields(self, cr, uid, context=None): return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['vat_subjected'] def _construct_constraint_msg(self, cr, uid, ids, context=None): def default_vat_check(cn, vn): # by default, a VAT number is valid if: # it starts with 2 letters # has more than 3 characters return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat) vat_no = "'CC##' (CC=Country Code, ##=VAT Number)" error_partner = self.browse(cr, uid, ids, context=context) if default_vat_check(vat_country, vat_number): vat_no = _ref_vat[vat_country] if vat_country in _ref_vat else vat_no if self.pool['res.users'].browse(cr, uid, uid).company_id.vat_check_vies: return '\n' + _('The VAT number [%s] for partner [%s] either failed the VIES VAT validation check or did not respect the expected format %s.') % (error_partner[0].vat, error_partner[0].name, vat_no) return '\n' + _('The VAT number [%s] for partner [%s] does not seem to be valid. \nNote: the expected format is %s') % (error_partner[0].vat, error_partner[0].name, vat_no) _constraints = [(check_vat, _construct_constraint_msg, ["vat"])] __check_vat_ch_re1 = re.compile(r'(MWST|TVA|IVA)[0-9]{6}$') __check_vat_ch_re2 = re.compile(r'E([0-9]{9}|-[0-9]{3}\.[0-9]{3}\.[0-9]{3})(MWST|TVA|IVA)$') def check_vat_ch(self, vat): ''' Check Switzerland VAT number. ''' # VAT number in Switzerland will change between 2011 and 2013 # http://www.estv.admin.ch/mwst/themen/00154/00589/01107/index.html?lang=fr # Old format is "TVA 123456" we will admit the user has to enter ch before the number # Format will becomes such as "CHE-999.999.99C TVA" # Both old and new format will be accepted till end of 2013 # Accepted format are: (spaces are ignored) # CH TVA ###### # CH IVA ###### # CH MWST ####### # # CHE#########MWST # CHE#########TVA # CHE#########IVA # CHE-###.###.### MWST # CHE-###.###.### TVA # CHE-###.###.### IVA # if self.__check_vat_ch_re1.match(vat): return True match = self.__check_vat_ch_re2.match(vat) if match: # For new TVA numbers, do a mod11 check num = filter(lambda s: s.isdigit(), match.group(1)) # get the digits only factor = (5,4,3,2,7,6,5,4) csum = sum([int(num[i]) * factor[i] for i in range(8)]) check = (11 - (csum % 11)) % 11 return check == int(num[8]) return False def _ie_check_char(self, vat): vat = vat.zfill(8) extra = 0 if vat[7] not in ' W': if vat[7].isalpha(): extra = 9 * (ord(vat[7]) - 64) else: # invalid return -1 checksum = extra + sum((8-i) * int(x) for i, x in enumerate(vat[:7])) return 'WABCDEFGHIJKLMNOPQRSTUV'[checksum % 23] def check_vat_ie(self, vat): """ Temporary Ireland VAT validation to support the new format introduced in January 2013 in Ireland, until upstream is fixed. TODO: remove when fixed upstream""" if len(vat) not in (8, 9) or not vat[2:7].isdigit(): return False if len(vat) == 8: # Normalize pre-2013 numbers: final space or 'W' not significant vat += ' ' if vat[:7].isdigit(): return vat[7] == self._ie_check_char(vat[:7] + vat[8]) elif vat[1] in (string.ascii_uppercase + '+*'): # Deprecated format # See http://www.revenue.ie/en/online/third-party-reporting/reporting-payment-details/faqs.html#section3 return vat[7] == self._ie_check_char(vat[2:7] + vat[0] + vat[8]) return False # Mexican VAT verification, contributed by Vauxoo # and Panos Christeas <p_christ@hol.gr> __check_vat_mx_re = re.compile(r"(?P<primeras>[A-Za-z\xd1\xf1&]{3,4})" \ r"[ \-_]?" \ r"(?P<ano>[0-9]{2})(?P<mes>[01][0-9])(?P<dia>[0-3][0-9])" \ r"[ \-_]?" \ r"(?P<code>[A-Za-z0-9&\xd1\xf1]{3})$") def check_vat_mx(self, vat): ''' Mexican VAT verification Verificar RFC México ''' # we convert to 8-bit encoding, to help the regex parse only bytes vat = ustr(vat).encode('iso8859-1') m = self.__check_vat_mx_re.match(vat) if not m: #No valid format return False try: ano = int(m.group('ano')) if ano > 30: ano = 1900 + ano else: ano = 2000 + ano datetime.date(ano, int(m.group('mes')), int(m.group('dia'))) except ValueError: return False #Valid format and valid date return True # Norway VAT validation, contributed by Rolv Råen (adEgo) <rora@adego.no> def check_vat_no(self, vat): ''' Check Norway VAT number.See http://www.brreg.no/english/coordination/number.html ''' if len(vat) != 9: return False try: int(vat) except ValueError: return False sum = (3 * int(vat[0])) + (2 * int(vat[1])) + \ (7 * int(vat[2])) + (6 * int(vat[3])) + \ (5 * int(vat[4])) + (4 * int(vat[5])) + \ (3 * int(vat[6])) + (2 * int(vat[7])) check = 11 -(sum % 11) if check == 11: check = 0 if check == 10: # 10 is not a valid check digit for an organization number return False return check == int(vat[8]) # Peruvian VAT validation, contributed by Vauxoo def check_vat_pe(self, vat): vat_type,vat = vat and len(vat)>=2 and (vat[0], vat[1:]) or (False, False) if vat_type and vat_type.upper() == 'D': #DNI return True elif vat_type and vat_type.upper() == 'R': #verify RUC factor = '5432765432' sum = 0 dig_check = False if len(vat) != 11: return False try: int(vat) except ValueError: return False for f in range(0,10): sum += int(factor[f]) * int(vat[f]) subtraction = 11 - (sum % 11) if subtraction == 10: dig_check = 0 elif subtraction == 11: dig_check = 1 else: dig_check = subtraction return int(vat[10]) == dig_check else: return False # VAT validation in Turkey, contributed by # Levent Karakas @ Eska Yazilim A.S. def check_vat_tr(self, vat): if not (10 <= len(vat) <= 11): return False try: int(vat) except ValueError: return False # check vat number (vergi no) if len(vat) == 10: sum = 0 check = 0 for f in range(0,9): c1 = (int(vat[f]) + (9-f)) % 10 c2 = ( c1 * (2 ** (9-f)) ) % 9 if (c1 != 0) and (c2 == 0): c2 = 9 sum += c2 if sum % 10 == 0: check = 0 else: check = 10 - (sum % 10) return int(vat[9]) == check # check personal id (tc kimlik no) if len(vat) == 11: c1a = 0 c1b = 0 c2 = 0 for f in range(0,9,2): c1a += int(vat[f]) for f in range(1,9,2): c1b += int(vat[f]) c1 = ( (7 * c1a) - c1b) % 10 for f in range(0,10): c2 += int(vat[f]) c2 = c2 % 10 return int(vat[9]) == c1 and int(vat[10]) == c2 return False # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 7409, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 18956, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 2050, 199, 646, 1059, 199, 646, 2197, 199, 646, 295, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 893, 26, 272, 492, 373, 292, 1955, 199, 2590, 3545, 26, 272, 485, 2921, 14, 3764, 480, 54, 619, 6411, 25172, 18735, 2952, 314, 658, 16305, 1955, 64, 2018, 3555, 3913, 506, 1911, 14, 298, 5101, 298, 8154, 652, 370, 2291, 1655, 26013, 12, 367, 2893, 543, 658, 13581, 63, 3174, 373, 292, 1955, 2313, 531, 272, 373, 292, 1955, 275, 488, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 9923, 492, 399, 495, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 63, 1121, 63, 16305, 275, 469, 272, 283, 292, 356, 283, 619, 53, 19060, 2194, 297, 272, 283, 1235, 356, 283, 6773, 966, 1138, 2417, 1465, 614, 297, 272, 283, 6856, 356, 283, 18998, 11272, 18, 297, 272, 283, 335, 356, 283, 4576, 13, 4288, 14, 11419, 14, 29831, 377, 15162, 503, 6624, 377, 15162, 14763, 1367, 297, 327, 10941, 19857, 701, 1488, 1189, 2000, 812, 65, 2133, 281, 768, 24569, 475, 20290, 272, 283, 1480, 356, 283, 15068, 19542, 38, 297, 272, 283, 16823, 356, 283, 27808, 19060, 1965, 297, 272, 283, 271, 356, 283, 1093, 30217, 1299, 297, 272, 283, 6341, 356, 283, 10892, 19060, 1342, 297, 272, 283, 1024, 356, 283, 8699, 30217, 1257, 297, 272, 283, 352, 356, 283, 2901, 19060, 2760, 297, 272, 283, 397, 356, 283, 654, 33, 19060, 1342, 297, 272, 283, 329, 356, 283, 1976, 19060, 3172, 297, 272, 283, 4391, 356, 283, 5372, 708, 11272, 297, 272, 283, 4908, 356, 283, 6487, 19542, 18, 297, 272, 283, 2587, 356, 283, 3975, 19060, 2760, 297, 272, 283, 10616, 356, 283, 28327, 19060, 2114, 297, 272, 283, 6271, 356, 283, 14784, 11371, 22, 297, 327, 445, 293, 2159, 65, 12, 406, 24855, 701, 603, 382, 290, 12480, 464, 834, 5591, 283, 1873, 356, 283, 4332, 30217, 2078, 297, 272, 283, 390, 356, 283, 649, 30217, 24938, 297, 272, 283, 4116, 356, 283, 17090, 30217, 1046, 297, 272, 283, 10836, 356, 283, 20237, 19060, 969, 297, 272, 283, 6371, 356, 283, 18750, 20, 11272, 17, 297, 272, 283, 2037, 356, 283, 5747, 19060, 1082, 297, 272, 283, 9457, 356, 283, 17401, 8390, 19060, 52, 17, 34, 297, 272, 283, 7530, 356, 283, 14176, 19542, 18, 34, 2710, 297, 272, 283, 889, 356, 283, 2826, 19542, 21, 297, 272, 283, 321, 356, 283, 4227, 32105, 2006, 1194, 11174, 503, 510, 1149, 32105, 2006, 1194, 11174, 297, 272, 283, 1168, 356, 283, 2749, 30217, 16456, 297, 272, 283, 541, 356, 283, 4189, 11272, 297, 272, 283, 293, 356, 283, 1092, 11272, 23, 297, 272, 283, 261, 356, 283, 899, 11272, 28852, 297, 272, 283, 338, 356, 283, 2684, 19060, 1965, 297, 272, 283, 1339, 356, 283, 8656, 383, 19060, 2194, 297, 272, 283, 454, 356, 283, 1766, 21515, 334, 2111, 39, 568, 47, 9, 11199, 11552, 9074, 11272, 614, 334, 52, 2504, 1469, 2673, 43, 2826, 3171, 327, 491, 1430, 1804, 285, 1151, 305, 768, 662, 1339, 65, 1488, 4651, 1638, 77, 437, 14, 51, 14, 199, 93, 199, 199, 533, 522, 63, 3899, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 283, 470, 14, 3899, 7, 339, 347, 485, 1294, 63, 16305, 8, 277, 12, 373, 292, 304, 267, 373, 292, 63, 6063, 12, 373, 292, 63, 1955, 275, 373, 292, 1491, 18, 1055, 2325, 1062, 373, 292, 59, 18, 11455, 1814, 360, 1656, 4074, 267, 372, 373, 292, 63, 6063, 12, 373, 292, 63, 1955, 339, 347, 3486, 63, 16305, 63, 1074, 8, 277, 12, 2467, 12, 1747, 12, 9023, 63, 600, 12, 373, 292, 63, 1955, 12, 1067, 29, 403, 304, 267, 1449, 267, 2670, 314, 812, 619, 1329, 10298, 402, 314, 9023, 14, 267, 1455, 921, 338, 391, 13, 2352, 14, 957, 15, 78, 692, 14, 8624, 267, 1449, 267, 340, 440, 399, 495, 8, 6063, 63, 600, 680, 2143, 360, 1624, 13, 24, 1959, 374, 4468, 837, 288, 372, 756, 267, 1104, 63, 1532, 63, 354, 275, 283, 1074, 63, 16305, 8650, 435, 9023, 63, 600, 267, 1104, 63, 1532, 275, 2519, 8, 277, 12, 1104, 63, 1532, 63, 354, 12, 488, 9, 503, 971, 717, 2519, 8, 16305, 1955, 12, 1104, 63, 1532, 63, 354, 12, 488, 9, 267, 340, 440, 1104, 63, 1532, 26, 288, 327, 3091, 812, 619, 6411, 2808, 12, 849, 370, 1104, 626, 314, 9023, 1233, 3495, 288, 340, 9023, 63, 600, 14, 4142, 342, 508, 283, 23539, 356, 355, 327, 481, 2692, 1013, 23461, 626, 21032, 543, 2222, 13, 4200, 1359, 874, 315, 314, 26007, 355, 327, 1443, 1172, 282, 812, 1934, 6617, 543, 298, 23539, 2, 3140, 402, 282, 9023, 1233, 14, 355, 372, 715, 288, 522, 63, 6063, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 6063, 358, 288, 372, 2155, 8 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 7409, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 18956, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 259, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 259, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 646, 2050, 199, 646, 1059, 199, 646, 2197, 199, 646, 295, 199, 63, 2921, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 893, 26, 272, 492, 373, 292, 1955, 199, 2590, 3545, 26, 272, 485, 2921, 14, 3764, 480, 54, 619, 6411, 25172, 18735, 2952, 314, 658, 16305, 1955, 64, 2018, 3555, 3913, 506, 1911, 14, 298, 5101, 298, 8154, 652, 370, 2291, 1655, 26013, 12, 367, 2893, 543, 658, 13581, 63, 3174, 373, 292, 1955, 2313, 531, 272, 373, 292, 1955, 275, 488, 199, 199, 504, 5166, 14, 4795, 492, 1504, 12, 9506, 199, 504, 5166, 14, 2537, 14, 9923, 492, 399, 495, 199, 504, 5166, 14, 2537, 14, 5275, 492, 485, 199, 199, 63, 1121, 63, 16305, 275, 469, 272, 283, 292, 356, 283, 619, 53, 19060, 2194, 297, 272, 283, 1235, 356, 283, 6773, 966, 1138, 2417, 1465, 614, 297, 272, 283, 6856, 356, 283, 18998, 11272, 18, 297, 272, 283, 335, 356, 283, 4576, 13, 4288, 14, 11419, 14, 29831, 377, 15162, 503, 6624, 377, 15162, 14763, 1367, 297, 327, 10941, 19857, 701, 1488, 1189, 2000, 812, 65, 2133, 281, 768, 24569, 475, 20290, 272, 283, 1480, 356, 283, 15068, 19542, 38, 297, 272, 283, 16823, 356, 283, 27808, 19060, 1965, 297, 272, 283, 271, 356, 283, 1093, 30217, 1299, 297, 272, 283, 6341, 356, 283, 10892, 19060, 1342, 297, 272, 283, 1024, 356, 283, 8699, 30217, 1257, 297, 272, 283, 352, 356, 283, 2901, 19060, 2760, 297, 272, 283, 397, 356, 283, 654, 33, 19060, 1342, 297, 272, 283, 329, 356, 283, 1976, 19060, 3172, 297, 272, 283, 4391, 356, 283, 5372, 708, 11272, 297, 272, 283, 4908, 356, 283, 6487, 19542, 18, 297, 272, 283, 2587, 356, 283, 3975, 19060, 2760, 297, 272, 283, 10616, 356, 283, 28327, 19060, 2114, 297, 272, 283, 6271, 356, 283, 14784, 11371, 22, 297, 327, 445, 293, 2159, 65, 12, 406, 24855, 701, 603, 382, 290, 12480, 464, 834, 5591, 283, 1873, 356, 283, 4332, 30217, 2078, 297, 272, 283, 390, 356, 283, 649, 30217, 24938, 297, 272, 283, 4116, 356, 283, 17090, 30217, 1046, 297, 272, 283, 10836, 356, 283, 20237, 19060, 969, 297, 272, 283, 6371, 356, 283, 18750, 20, 11272, 17, 297, 272, 283, 2037, 356, 283, 5747, 19060, 1082, 297, 272, 283, 9457, 356, 283, 17401, 8390, 19060, 52, 17, 34, 297, 272, 283, 7530, 356, 283, 14176, 19542, 18, 34, 2710, 297, 272, 283, 889, 356, 283, 2826, 19542, 21, 297, 272, 283, 321, 356, 283, 4227, 32105, 2006, 1194, 11174, 503, 510, 1149, 32105, 2006, 1194, 11174, 297, 272, 283, 1168, 356, 283, 2749, 30217, 16456, 297, 272, 283, 541, 356, 283, 4189, 11272, 297, 272, 283, 293, 356, 283, 1092, 11272, 23, 297, 272, 283, 261, 356, 283, 899, 11272, 28852, 297, 272, 283, 338, 356, 283, 2684, 19060, 1965, 297, 272, 283, 1339, 356, 283, 8656, 383, 19060, 2194, 297, 272, 283, 454, 356, 283, 1766, 21515, 334, 2111, 39, 568, 47, 9, 11199, 11552, 9074, 11272, 614, 334, 52, 2504, 1469, 2673, 43, 2826, 3171, 327, 491, 1430, 1804, 285, 1151, 305, 768, 662, 1339, 65, 1488, 4651, 1638, 77, 437, 14, 51, 14, 199, 93, 199, 199, 533, 522, 63, 3899, 8, 4795, 14, 4795, 304, 272, 485, 6486, 275, 283, 470, 14, 3899, 7, 339, 347, 485, 1294, 63, 16305, 8, 277, 12, 373, 292, 304, 267, 373, 292, 63, 6063, 12, 373, 292, 63, 1955, 275, 373, 292, 1491, 18, 1055, 2325, 1062, 373, 292, 59, 18, 11455, 1814, 360, 1656, 4074, 267, 372, 373, 292, 63, 6063, 12, 373, 292, 63, 1955, 339, 347, 3486, 63, 16305, 63, 1074, 8, 277, 12, 2467, 12, 1747, 12, 9023, 63, 600, 12, 373, 292, 63, 1955, 12, 1067, 29, 403, 304, 267, 1449, 267, 2670, 314, 812, 619, 1329, 10298, 402, 314, 9023, 14, 267, 1455, 921, 338, 391, 13, 2352, 14, 957, 15, 78, 692, 14, 8624, 267, 1449, 267, 340, 440, 399, 495, 8, 6063, 63, 600, 680, 2143, 360, 1624, 13, 24, 1959, 374, 4468, 837, 288, 372, 756, 267, 1104, 63, 1532, 63, 354, 275, 283, 1074, 63, 16305, 8650, 435, 9023, 63, 600, 267, 1104, 63, 1532, 275, 2519, 8, 277, 12, 1104, 63, 1532, 63, 354, 12, 488, 9, 503, 971, 717, 2519, 8, 16305, 1955, 12, 1104, 63, 1532, 63, 354, 12, 488, 9, 267, 340, 440, 1104, 63, 1532, 26, 288, 327, 3091, 812, 619, 6411, 2808, 12, 849, 370, 1104, 626, 314, 9023, 1233, 3495, 288, 340, 9023, 63, 600, 14, 4142, 342, 508, 283, 23539, 356, 355, 327, 481, 2692, 1013, 23461, 626, 21032, 543, 2222, 13, 4200, 1359, 874, 315, 314, 26007, 355, 327, 1443, 1172, 282, 812, 1934, 6617, 543, 298, 23539, 2, 3140, 402, 282, 9023, 1233, 14, 355, 372, 715, 288, 522, 63, 6063, 275, 291, 14, 2293, 14, 362, 360, 470, 14, 6063, 358, 288, 372, 2155, 8, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
tmenjo/cinder-2015.1.0
cinder/volume/drivers/ibm/xiv_ds8k.py
3
8912
# Copyright 2013 IBM Corp. # Copyright (c) 2013 OpenStack Foundation # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # # Authors: # Erik Zaadi <erikz@il.ibm.com> # Avishay Traeger <avishay@il.ibm.com> """ Unified Volume driver for IBM XIV and DS8K Storage Systems. """ from oslo_config import cfg from oslo_log import log as logging from oslo_utils import importutils from cinder import exception from cinder.volume.drivers.san import san xiv_ds8k_opts = [ cfg.StrOpt( 'xiv_ds8k_proxy', default='xiv_ds8k_openstack.nova_proxy.XIVDS8KNovaProxy', help='Proxy driver that connects to the IBM Storage Array'), cfg.StrOpt( 'xiv_ds8k_connection_type', default='iscsi', choices=['fibre_channel', 'iscsi'], help='Connection type to the IBM Storage Array'), cfg.StrOpt( 'xiv_chap', default='disabled', choices=['disabled', 'enabled'], help='CHAP authentication mode, effective only for iscsi' ' (disabled|enabled)'), ] CONF = cfg.CONF CONF.register_opts(xiv_ds8k_opts) LOG = logging.getLogger(__name__) class XIVDS8KDriver(san.SanDriver): """Unified IBM XIV and DS8K volume driver.""" def __init__(self, *args, **kwargs): """Initialize the driver.""" super(XIVDS8KDriver, self).__init__(*args, **kwargs) self.configuration.append_config_values(xiv_ds8k_opts) proxy = importutils.import_class(self.configuration.xiv_ds8k_proxy) # NOTE: All Array specific configurations are prefixed with: # "xiv_ds8k_array_" # These additional flags should be specified in the cinder.conf # preferably in each backend configuration. self.xiv_ds8k_proxy = proxy( { "xiv_ds8k_user": self.configuration.san_login, "xiv_ds8k_pass": self.configuration.san_password, "xiv_ds8k_address": self.configuration.san_ip, "xiv_ds8k_vol_pool": self.configuration.san_clustername, "xiv_ds8k_connection_type": self.configuration.xiv_ds8k_connection_type, "xiv_chap": self.configuration.xiv_chap }, LOG, exception, driver=self) def do_setup(self, context): """Setup and verify IBM XIV and DS8K Storage connection.""" self.xiv_ds8k_proxy.setup(context) def ensure_export(self, context, volume): """Ensure an export.""" return self.xiv_ds8k_proxy.ensure_export(context, volume) def create_export(self, context, volume): """Create an export.""" return self.xiv_ds8k_proxy.create_export(context, volume) def create_volume(self, volume): """Create a volume on the IBM XIV and DS8K Storage system.""" return self.xiv_ds8k_proxy.create_volume(volume) def delete_volume(self, volume): """Delete a volume on the IBM XIV and DS8K Storage system.""" self.xiv_ds8k_proxy.delete_volume(volume) def remove_export(self, context, volume): """Disconnect a volume from an attached instance.""" return self.xiv_ds8k_proxy.remove_export(context, volume) def initialize_connection(self, volume, connector): """Map the created volume.""" return self.xiv_ds8k_proxy.initialize_connection(volume, connector) def terminate_connection(self, volume, connector, **kwargs): """Terminate a connection to a volume.""" return self.xiv_ds8k_proxy.terminate_connection(volume, connector) def create_volume_from_snapshot(self, volume, snapshot): """Create a volume from a snapshot.""" return self.xiv_ds8k_proxy.create_volume_from_snapshot( volume, snapshot) def create_snapshot(self, snapshot): """Create a snapshot.""" return self.xiv_ds8k_proxy.create_snapshot(snapshot) def delete_snapshot(self, snapshot): """Delete a snapshot.""" return self.xiv_ds8k_proxy.delete_snapshot(snapshot) def get_volume_stats(self, refresh=False): """Get volume stats.""" return self.xiv_ds8k_proxy.get_volume_stats(refresh) def create_cloned_volume(self, tgt_volume, src_volume): """Create Cloned Volume.""" return self.xiv_ds8k_proxy.create_cloned_volume(tgt_volume, src_volume) def extend_volume(self, volume, new_size): """Extend Created Volume.""" self.xiv_ds8k_proxy.extend_volume(volume, new_size) def migrate_volume(self, context, volume, host): """Migrate the volume to the specified host.""" return self.xiv_ds8k_proxy.migrate_volume(context, volume, host) def manage_existing(self, volume, existing_ref): """Brings an existing backend storage object under Cinder management. existing_ref is passed straight through from the API request's manage_existing_ref value, and it is up to the driver how this should be interpreted. It should be sufficient to identify a storage object that the driver should somehow associate with the newly-created cinder volume structure. In the case of XIV, the existing_ref consists of a single field named 'existing_ref' representing the name of the volume on the storage. There are two ways to do this: 1. Rename the backend storage object so that it matches the, volume['name'] which is how drivers traditionally map between a cinder volume and the associated backend storage object. 2. Place some metadata on the volume, or somewhere in the backend, that allows other driver requests (e.g. delete, clone, attach, detach...) to locate the backend storage object when required. If the existing_ref doesn't make sense, or doesn't refer to an existing backend storage object, raise a ManageExistingInvalidReference exception. The volume may have a volume_type, and the driver can inspect that and compare against the properties of the referenced backend storage object. If they are incompatible, raise a ManageExistingVolumeTypeMismatch, specifying a reason for the failure. """ return self.xiv_ds8k_proxy.manage_volume(volume, existing_ref) def manage_existing_get_size(self, volume, existing_ref): """Return size of volume to be managed by manage_existing.""" return self.xiv_ds8k_proxy.manage_volume_get_size(volume, existing_ref) def unmanage(self, volume): """Removes the specified volume from Cinder management.""" return self.xiv_ds8k_proxy.unmanage_volume(volume) def reenable_replication(self, context, volume): """Re-enable volume replication. """ return self.xiv_ds8k_proxy.reenable_replication(context, volume) def get_replication_status(self, context, volume): """Return replication status.""" return self.xiv_ds8k_proxy.get_replication_status(context, volume) def promote_replica(self, context, volume): """Promote the replica to be the primary volume.""" return self.xiv_ds8k_proxy.promote_replica(context, volume) def create_replica_test_volume(self, volume, src_vref): """Creates a test replica clone of the specified replicated volume.""" return self.xiv_ds8k_proxy.create_replica_test_volume(volume, src_vref) def retype(self, ctxt, volume, new_type, diff, host): """Convert the volume to be of the new type.""" return self.xiv_ds8k_proxy.retype(ctxt, volume, new_type, diff, host) def create_consistencygroup(self, context, group): """Creates a consistency group.""" return self.xiv_ds8k_proxy.create_consistencygroup(context, group) def delete_consistencygroup(self, context, group): """Deletes a consistency group.""" return self.xiv_ds8k_proxy.delete_consistencygroup(context, group) def create_cgsnapshot(self, context, cgsnapshot): """Creates a consistency group snapshot.""" return self.xiv_ds8k_proxy.create_cgsnapshot(context, cgsnapshot) def delete_cgsnapshot(self, context, cgsnapshot): """Deletes a consistency group snapshot.""" return self.xiv_ds8k_proxy.delete_cgsnapshot(context, cgsnapshot)
apache-2.0
[ 3, 1898, 6171, 26202, 22304, 14, 199, 3, 1898, 334, 67, 9, 6171, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 3, 199, 3, 6642, 26, 199, 3, 257, 662, 25844, 3107, 2158, 328, 665, 281, 3258, 90, 32, 382, 14, 19870, 14, 957, 30, 199, 3, 257, 16599, 2453, 1187, 12643, 69, 836, 665, 1214, 2453, 1187, 32, 382, 14, 19870, 14, 957, 30, 199, 199, 624, 199, 1358, 4541, 15018, 5253, 367, 26202, 1323, 6882, 436, 577, 51, 24, 43, 10533, 15285, 14, 199, 624, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 1208, 492, 492, 1208, 199, 199, 504, 13069, 492, 1919, 199, 504, 13069, 14, 2405, 14, 13337, 14, 18904, 492, 28698, 199, 199, 25034, 63, 795, 24, 75, 63, 3291, 275, 359, 272, 4810, 14, 19340, 8, 267, 283, 25034, 63, 795, 24, 75, 63, 3280, 297, 267, 849, 534, 25034, 63, 795, 24, 75, 63, 8512, 14, 6765, 63, 3280, 14, 56, 6882, 3177, 24, 43, 19884, 4936, 297, 267, 1720, 534, 4936, 5253, 626, 4907, 83, 370, 314, 26202, 10533, 8725, 659, 272, 4810, 14, 19340, 8, 267, 283, 25034, 63, 795, 24, 75, 63, 2105, 63, 466, 297, 267, 849, 534, 17139, 297, 267, 3415, 2968, 329, 10205, 63, 2775, 297, 283, 17139, 995, 267, 1720, 534, 3225, 730, 370, 314, 26202, 10533, 8725, 659, 272, 4810, 14, 19340, 8, 267, 283, 25034, 63, 28765, 297, 267, 849, 534, 7011, 297, 267, 3415, 2968, 7011, 297, 283, 3827, 995, 267, 1720, 534, 1244, 1282, 6299, 818, 12, 15826, 1454, 367, 22144, 7, 267, 283, 334, 7011, 92, 3827, 11218, 199, 61, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 2683, 63, 3291, 8, 25034, 63, 795, 24, 75, 63, 3291, 9, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 1323, 6882, 3177, 24, 43, 6158, 8, 18904, 14, 23906, 6158, 304, 272, 408, 1358, 4541, 26202, 1323, 6882, 436, 577, 51, 24, 43, 3301, 5253, 1041, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 9345, 314, 5253, 1041, 398, 1613, 8, 56, 6882, 3177, 24, 43, 6158, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 398, 291, 14, 4758, 14, 740, 63, 888, 63, 1459, 8, 25034, 63, 795, 24, 75, 63, 3291, 9, 398, 4566, 275, 492, 1208, 14, 646, 63, 533, 8, 277, 14, 4758, 14, 25034, 63, 795, 24, 75, 63, 3280, 9, 398, 327, 6944, 26, 2900, 8725, 2488, 13422, 787, 18239, 543, 26, 267, 327, 298, 25034, 63, 795, 24, 75, 63, 1144, 12172, 267, 327, 5723, 4722, 3285, 1077, 506, 2013, 315, 314, 13069, 14, 2190, 267, 327, 16602, 6665, 315, 1924, 4865, 2897, 14, 398, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 275, 4566, 8, 288, 469, 355, 298, 25034, 63, 795, 24, 75, 63, 751, 582, 291, 14, 4758, 14, 18904, 63, 2886, 12, 355, 298, 25034, 63, 795, 24, 75, 63, 1529, 582, 291, 14, 4758, 14, 18904, 63, 2060, 12, 355, 298, 25034, 63, 795, 24, 75, 63, 1562, 582, 291, 14, 4758, 14, 18904, 63, 711, 12, 355, 298, 25034, 63, 795, 24, 75, 63, 5650, 63, 2293, 582, 291, 14, 4758, 14, 18904, 63, 4201, 354, 12, 355, 298, 25034, 63, 795, 24, 75, 63, 2105, 63, 466, 582, 355, 291, 14, 4758, 14, 25034, 63, 795, 24, 75, 63, 2105, 63, 466, 12, 355, 298, 25034, 63, 28765, 582, 291, 14, 4758, 14, 25034, 63, 28765, 288, 1660, 288, 5051, 12, 288, 1919, 12, 288, 5253, 29, 277, 9, 339, 347, 886, 63, 2758, 8, 277, 12, 1067, 304, 267, 408, 8555, 436, 4911, 26202, 1323, 6882, 436, 577, 51, 24, 43, 10533, 1950, 1041, 398, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 14, 2758, 8, 1100, 9, 339, 347, 4868, 63, 3790, 8, 277, 12, 1067, 12, 3301, 304, 267, 408, 13913, 376, 4843, 1041, 398, 372, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 14, 7505, 63, 3790, 8, 1100, 12, 3301, 9, 339, 347, 1218, 63, 3790, 8, 277, 12, 1067, 12, 3301, 304, 267, 408, 2499, 376, 4843, 1041, 398, 372, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 14, 981, 63, 3790, 8, 1100, 12, 3301, 9, 339, 347, 1218, 63, 2405, 8, 277, 12, 3301, 304, 267, 408, 2499, 282, 3301, 641, 314, 26202, 1323, 6882, 436, 577, 51, 24, 43, 10533, 2656, 1041, 398, 372, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 14, 981, 63, 2405, 8, 2405, 9, 339, 347, 3145, 63, 2405, 8, 277, 12, 3301, 304, 267, 408, 5392, 282, 3301, 641, 314, 26202, 1323, 6882, 436, 577, 51, 24, 43, 10533, 2656, 1041, 398, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 14, 1807, 63, 2405, 8, 2405, 9, 339, 347, 2813, 63, 3790, 8, 277, 12, 1067, 12, 3301, 304, 267, 408, 16761, 282, 3301, 687, 376, 10102, 1256, 1041, 398, 372, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 14, 2168, 63, 3790, 8, 1100, 12, 3301, 9, 339, 347, 8265, 63, 2105, 8, 277, 12, 3301, 12, 13252, 304, 267, 408, 2956, 314, 2737, 3301, 1041, 398, 372, 291, 14 ]
[ 1898, 6171, 26202, 22304, 14, 199, 3, 1898, 334, 67, 9, 6171, 14260, 2752, 199, 3, 2900, 5924, 5702, 14, 199, 3, 199, 3, 259, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 199, 3, 259, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 2047, 1443, 3332, 199, 3, 259, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 260, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 259, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 259, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 2428, 199, 3, 259, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 1666, 314, 199, 3, 259, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 4204, 199, 3, 259, 1334, 314, 844, 14, 199, 3, 199, 3, 6642, 26, 199, 3, 257, 662, 25844, 3107, 2158, 328, 665, 281, 3258, 90, 32, 382, 14, 19870, 14, 957, 30, 199, 3, 257, 16599, 2453, 1187, 12643, 69, 836, 665, 1214, 2453, 1187, 32, 382, 14, 19870, 14, 957, 30, 199, 199, 624, 199, 1358, 4541, 15018, 5253, 367, 26202, 1323, 6882, 436, 577, 51, 24, 43, 10533, 15285, 14, 199, 624, 199, 199, 504, 11258, 63, 888, 492, 4810, 199, 504, 11258, 63, 793, 492, 943, 465, 2050, 199, 504, 11258, 63, 1208, 492, 492, 1208, 199, 199, 504, 13069, 492, 1919, 199, 504, 13069, 14, 2405, 14, 13337, 14, 18904, 492, 28698, 199, 199, 25034, 63, 795, 24, 75, 63, 3291, 275, 359, 272, 4810, 14, 19340, 8, 267, 283, 25034, 63, 795, 24, 75, 63, 3280, 297, 267, 849, 534, 25034, 63, 795, 24, 75, 63, 8512, 14, 6765, 63, 3280, 14, 56, 6882, 3177, 24, 43, 19884, 4936, 297, 267, 1720, 534, 4936, 5253, 626, 4907, 83, 370, 314, 26202, 10533, 8725, 659, 272, 4810, 14, 19340, 8, 267, 283, 25034, 63, 795, 24, 75, 63, 2105, 63, 466, 297, 267, 849, 534, 17139, 297, 267, 3415, 2968, 329, 10205, 63, 2775, 297, 283, 17139, 995, 267, 1720, 534, 3225, 730, 370, 314, 26202, 10533, 8725, 659, 272, 4810, 14, 19340, 8, 267, 283, 25034, 63, 28765, 297, 267, 849, 534, 7011, 297, 267, 3415, 2968, 7011, 297, 283, 3827, 995, 267, 1720, 534, 1244, 1282, 6299, 818, 12, 15826, 1454, 367, 22144, 7, 267, 283, 334, 7011, 92, 3827, 11218, 199, 61, 199, 199, 3103, 275, 4810, 14, 3103, 199, 3103, 14, 2683, 63, 3291, 8, 25034, 63, 795, 24, 75, 63, 3291, 9, 199, 199, 4947, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 533, 1323, 6882, 3177, 24, 43, 6158, 8, 18904, 14, 23906, 6158, 304, 272, 408, 1358, 4541, 26202, 1323, 6882, 436, 577, 51, 24, 43, 3301, 5253, 1041, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 9345, 314, 5253, 1041, 398, 1613, 8, 56, 6882, 3177, 24, 43, 6158, 12, 291, 2843, 826, 9308, 589, 12, 1011, 958, 9, 398, 291, 14, 4758, 14, 740, 63, 888, 63, 1459, 8, 25034, 63, 795, 24, 75, 63, 3291, 9, 398, 4566, 275, 492, 1208, 14, 646, 63, 533, 8, 277, 14, 4758, 14, 25034, 63, 795, 24, 75, 63, 3280, 9, 398, 327, 6944, 26, 2900, 8725, 2488, 13422, 787, 18239, 543, 26, 267, 327, 298, 25034, 63, 795, 24, 75, 63, 1144, 12172, 267, 327, 5723, 4722, 3285, 1077, 506, 2013, 315, 314, 13069, 14, 2190, 267, 327, 16602, 6665, 315, 1924, 4865, 2897, 14, 398, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 275, 4566, 8, 288, 469, 355, 298, 25034, 63, 795, 24, 75, 63, 751, 582, 291, 14, 4758, 14, 18904, 63, 2886, 12, 355, 298, 25034, 63, 795, 24, 75, 63, 1529, 582, 291, 14, 4758, 14, 18904, 63, 2060, 12, 355, 298, 25034, 63, 795, 24, 75, 63, 1562, 582, 291, 14, 4758, 14, 18904, 63, 711, 12, 355, 298, 25034, 63, 795, 24, 75, 63, 5650, 63, 2293, 582, 291, 14, 4758, 14, 18904, 63, 4201, 354, 12, 355, 298, 25034, 63, 795, 24, 75, 63, 2105, 63, 466, 582, 355, 291, 14, 4758, 14, 25034, 63, 795, 24, 75, 63, 2105, 63, 466, 12, 355, 298, 25034, 63, 28765, 582, 291, 14, 4758, 14, 25034, 63, 28765, 288, 1660, 288, 5051, 12, 288, 1919, 12, 288, 5253, 29, 277, 9, 339, 347, 886, 63, 2758, 8, 277, 12, 1067, 304, 267, 408, 8555, 436, 4911, 26202, 1323, 6882, 436, 577, 51, 24, 43, 10533, 1950, 1041, 398, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 14, 2758, 8, 1100, 9, 339, 347, 4868, 63, 3790, 8, 277, 12, 1067, 12, 3301, 304, 267, 408, 13913, 376, 4843, 1041, 398, 372, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 14, 7505, 63, 3790, 8, 1100, 12, 3301, 9, 339, 347, 1218, 63, 3790, 8, 277, 12, 1067, 12, 3301, 304, 267, 408, 2499, 376, 4843, 1041, 398, 372, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 14, 981, 63, 3790, 8, 1100, 12, 3301, 9, 339, 347, 1218, 63, 2405, 8, 277, 12, 3301, 304, 267, 408, 2499, 282, 3301, 641, 314, 26202, 1323, 6882, 436, 577, 51, 24, 43, 10533, 2656, 1041, 398, 372, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 14, 981, 63, 2405, 8, 2405, 9, 339, 347, 3145, 63, 2405, 8, 277, 12, 3301, 304, 267, 408, 5392, 282, 3301, 641, 314, 26202, 1323, 6882, 436, 577, 51, 24, 43, 10533, 2656, 1041, 398, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 14, 1807, 63, 2405, 8, 2405, 9, 339, 347, 2813, 63, 3790, 8, 277, 12, 1067, 12, 3301, 304, 267, 408, 16761, 282, 3301, 687, 376, 10102, 1256, 1041, 398, 372, 291, 14, 25034, 63, 795, 24, 75, 63, 3280, 14, 2168, 63, 3790, 8, 1100, 12, 3301, 9, 339, 347, 8265, 63, 2105, 8, 277, 12, 3301, 12, 13252, 304, 267, 408, 2956, 314, 2737, 3301, 1041, 398, 372, 291, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
idea4bsd/idea4bsd
python/lib/Lib/xml/sax/handler.py
109
14076
""" This module contains the core classes of version 2.0 of SAX for Python. This file provides only default classes with absolutely minimum functionality, from which drivers and applications can be subclassed. Many of these classes are empty and are included only as documentation of the interfaces. $Id: handler.py,v 1.5 2002/02/14 08:09:36 loewis Exp $ """ version = '2.0beta' #============================================================================ # # HANDLER INTERFACES # #============================================================================ # ===== ERRORHANDLER ===== class ErrorHandler: """Basic interface for SAX error handlers. If you create an object that implements this interface, then register the object with your XMLReader, the parser will call the methods in your object to report all warnings and errors. There are three levels of errors available: warnings, (possibly) recoverable errors, and unrecoverable errors. All methods take a SAXParseException as the only parameter.""" def error(self, exception): "Handle a recoverable error." raise exception def fatalError(self, exception): "Handle a non-recoverable error." raise exception def warning(self, exception): "Handle a warning." print exception # ===== CONTENTHANDLER ===== class ContentHandler: """Interface for receiving logical document content events. This is the main callback interface in SAX, and the one most important to applications. The order of events in this interface mirrors the order of the information in the document.""" def __init__(self): self._locator = None def setDocumentLocator(self, locator): """Called by the parser to give the application a locator for locating the origin of document events. SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must supply the locator to the application by invoking this method before invoking any of the other methods in the DocumentHandler interface. The locator allows the application to determine the end position of any document-related event, even if the parser is not reporting an error. Typically, the application will use this information for reporting its own errors (such as character content that does not match an application's business rules). The information returned by the locator is probably not sufficient for use with a search engine. Note that the locator will return correct information only during the invocation of the events in this interface. The application should not attempt to use it at any other time.""" self._locator = locator def startDocument(self): """Receive notification of the beginning of a document. The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).""" def endDocument(self): """Receive notification of the end of a document. The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.""" def startPrefixMapping(self, prefix, uri): """Begin the scope of a prefix-URI Namespace mapping. The information from this event is not necessary for normal Namespace processing: the SAX XML reader will automatically replace prefixes for element and attribute names when the http://xml.org/sax/features/namespaces feature is true (the default). There are cases, however, when applications need to use prefixes in character data or in attribute values, where they cannot safely be expanded automatically; the start/endPrefixMapping event supplies the information to the application to expand prefixes in those contexts itself, if necessary. Note that start/endPrefixMapping events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping events will occur before the corresponding startElement event, and all endPrefixMapping events will occur after the corresponding endElement event, but their order is not guaranteed.""" def endPrefixMapping(self, prefix): """End the scope of a prefix-URI mapping. See startPrefixMapping for details. This event will always occur after the corresponding endElement event, but the order of endPrefixMapping events is not otherwise guaranteed.""" def startElement(self, name, attrs): """Signals the start of an element in non-namespace mode. The name parameter contains the raw XML 1.0 name of the element type as a string and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.""" def endElement(self, name): """Signals the end of an element in non-namespace mode. The name parameter contains the name of the element type, just as with the startElement event.""" def startElementNS(self, name, qname, attrs): """Signals the start of an element in namespace mode. The name parameter contains the name of the element type as a (uri, localname) tuple, the qname parameter the raw XML 1.0 name used in the source document, and the attrs parameter holds an instance of the Attributes class containing the attributes of the element. The uri part of the name tuple is None for elements which have no namespace.""" def endElementNS(self, name, qname): """Signals the end of an element in namespace mode. The name parameter contains the name of the element type, just as with the startElementNS event.""" def characters(self, content): """Receive notification of character data. The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.""" def ignorableWhitespace(self, whitespace): """Receive notification of ignorable whitespace in element content. Validating Parsers must use this method to report each chunk of ignorable whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models. SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information. The application must not attempt to read from the array outside of the specified range.""" def processingInstruction(self, target, data): """Receive notification of a processing instruction. The Parser will invoke this method once for each processing instruction found: note that processing instructions may occur before or after the main document element. A SAX parser should never report an XML declaration (XML 1.0, section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.""" def skippedEntity(self, name): """Receive notification of a skipped entity. The Parser will invoke this method once for each entity skipped. Non-validating processors may skip entities if they have not seen the declarations (because, for example, the entity was declared in an external DTD subset). All processors may skip external entities, depending on the values of the http://xml.org/sax/features/external-general-entities and the http://xml.org/sax/features/external-parameter-entities properties.""" # ===== DTDHandler ===== class DTDHandler: """Handle DTD events. This interface specifies only those DTD events required for basic parsing (unparsed entities and attributes).""" def notationDecl(self, name, publicId, systemId): "Handle a notation declaration event." def unparsedEntityDecl(self, name, publicId, systemId, ndata): "Handle an unparsed entity declaration event." # ===== ENTITYRESOLVER ===== class EntityResolver: """Basic interface for resolving entities. If you create an object implementing this interface, then register the object with your Parser, the parser will call the method in your object to resolve all external entities. Note that DefaultHandler implements this interface with the default behaviour.""" def resolveEntity(self, publicId, systemId): """Resolve the system identifier of an entity and return either the system identifier to read from as a string, or an InputSource to read from.""" return systemId #============================================================================ # # CORE FEATURES # #============================================================================ feature_namespaces = "http://xml.org/sax/features/namespaces" # true: Perform Namespace processing (default). # false: Optionally do not perform Namespace processing # (implies namespace-prefixes). # access: (parsing) read-only; (not parsing) read/write feature_namespace_prefixes = "http://xml.org/sax/features/namespace-prefixes" # true: Report the original prefixed names and attributes used for Namespace # declarations. # false: Do not report attributes used for Namespace declarations, and # optionally do not report original prefixed names (default). # access: (parsing) read-only; (not parsing) read/write feature_string_interning = "http://xml.org/sax/features/string-interning" # true: All element names, prefixes, attribute names, Namespace URIs, and # local names are interned using the built-in intern function. # false: Names are not necessarily interned, although they may be (default). # access: (parsing) read-only; (not parsing) read/write feature_validation = "http://xml.org/sax/features/validation" # true: Report all validation errors (implies external-general-entities and # external-parameter-entities). # false: Do not report validation errors. # access: (parsing) read-only; (not parsing) read/write feature_external_ges = "http://xml.org/sax/features/external-general-entities" # true: Include all external general (text) entities. # false: Do not include external general entities. # access: (parsing) read-only; (not parsing) read/write feature_external_pes = "http://xml.org/sax/features/external-parameter-entities" # true: Include all external parameter entities, including the external # DTD subset. # false: Do not include any external parameter entities, even the external # DTD subset. # access: (parsing) read-only; (not parsing) read/write all_features = [feature_namespaces, feature_namespace_prefixes, feature_string_interning, feature_validation, feature_external_ges, feature_external_pes] #============================================================================ # # CORE PROPERTIES # #============================================================================ property_lexical_handler = "http://xml.org/sax/properties/lexical-handler" # data type: xml.sax.sax2lib.LexicalHandler # description: An optional extension handler for lexical events like comments. # access: read/write property_declaration_handler = "http://xml.org/sax/properties/declaration-handler" # data type: xml.sax.sax2lib.DeclHandler # description: An optional extension handler for DTD-related events other # than notations and unparsed entities. # access: read/write property_dom_node = "http://xml.org/sax/properties/dom-node" # data type: org.w3c.dom.Node # description: When parsing, the current DOM node being visited if this is # a DOM iterator; when not parsing, the root DOM node for # iteration. # access: (parsing) read-only; (not parsing) read/write property_xml_string = "http://xml.org/sax/properties/xml-string" # data type: String # description: The literal string of characters that was the source for # the current event. # access: read-only property_encoding = "http://www.python.org/sax/properties/encoding" # data type: String # description: The name of the encoding to assume for input data. # access: write: set the encoding, e.g. established by a higher-level # protocol. May change during parsing (e.g. after # processing a META tag) # read: return the current encoding (possibly established through # auto-detection. # initial value: UTF-8 # property_interning_dict = "http://www.python.org/sax/properties/interning-dict" # data type: Dictionary # description: The dictionary used to intern common strings in the document # access: write: Request that the parser uses a specific dictionary, to # allow interning across different documents # read: return the current interning dictionary, or None # all_properties = [property_lexical_handler, property_dom_node, property_declaration_handler, property_xml_string, property_encoding, property_interning_dict]
apache-2.0
[ 624, 199, 2765, 859, 3509, 314, 6170, 3992, 402, 1015, 499, 14, 16, 402, 19310, 367, 2018, 14, 199, 2765, 570, 6571, 1454, 849, 3992, 543, 3679, 590, 7481, 199, 1593, 6712, 12, 687, 1314, 19016, 436, 13103, 883, 506, 1007, 28271, 14, 199, 199, 4089, 402, 3520, 3992, 787, 2701, 436, 787, 5120, 1454, 465, 3794, 199, 1618, 314, 8386, 14, 199, 199, 4, 1304, 26, 3016, 14, 647, 12, 86, 413, 14, 21, 14790, 15, 996, 15, 1079, 19363, 26, 1643, 26, 1344, 560, 546, 374, 7910, 2672, 199, 624, 199, 199, 1023, 275, 283, 18, 14, 16, 5683, 7, 199, 199, 14813, 5769, 199, 3, 199, 3, 23276, 19650, 8729, 38, 21287, 199, 3, 199, 14813, 5769, 199, 199, 3, 9310, 12539, 30872, 9310, 199, 199, 533, 4520, 2461, 26, 272, 408, 6845, 3217, 367, 19310, 1125, 8297, 14, 339, 982, 1265, 1218, 376, 909, 626, 9031, 642, 3217, 12, 2066, 272, 2274, 314, 909, 543, 2195, 4692, 5929, 12, 314, 1798, 911, 1240, 314, 272, 3102, 315, 2195, 909, 370, 3622, 1006, 3598, 436, 2552, 14, 6006, 272, 787, 7795, 11106, 402, 2552, 2808, 26, 3598, 12, 334, 19614, 9, 272, 22803, 461, 2552, 12, 436, 625, 23131, 461, 2552, 14, 2900, 3102, 5452, 282, 272, 19310, 4003, 1726, 465, 314, 1454, 2725, 1041, 339, 347, 1125, 8, 277, 12, 1919, 304, 267, 298, 5940, 282, 22803, 461, 1125, 2122, 267, 746, 1919, 339, 347, 14294, 547, 8, 277, 12, 1919, 304, 267, 298, 5940, 282, 2222, 13, 23131, 461, 1125, 2122, 267, 746, 1919, 339, 347, 5721, 8, 277, 12, 1919, 304, 267, 298, 5940, 282, 5721, 2122, 267, 870, 1919, 421, 199, 3, 9310, 29417, 30872, 9310, 199, 199, 533, 6646, 2461, 26, 272, 408, 4267, 367, 18390, 11461, 2213, 1564, 4474, 14, 339, 961, 365, 314, 2446, 3233, 3217, 315, 19310, 12, 436, 314, 1373, 4750, 272, 11012, 370, 13103, 14, 710, 1865, 402, 4474, 315, 642, 3217, 272, 15216, 83, 314, 1865, 402, 314, 2556, 315, 314, 2213, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 6354, 275, 488, 339, 347, 663, 5564, 10725, 8, 277, 12, 14067, 304, 267, 408, 10474, 701, 314, 1798, 370, 8120, 314, 4223, 282, 14067, 367, 267, 4355, 1958, 314, 6330, 402, 2213, 4474, 14, 398, 19310, 21295, 787, 30390, 655, 25715, 6028, 334, 15401, 440, 3679, 590, 267, 1415, 9, 370, 17169, 282, 14067, 26, 340, 652, 1630, 880, 12, 652, 1471, 17169, 267, 314, 14067, 370, 314, 4223, 701, 26750, 642, 1083, 2544, 267, 26750, 1263, 402, 314, 1163, 3102, 315, 314, 7543, 2461, 267, 3217, 14, 398, 710, 14067, 6127, 314, 4223, 370, 6705, 314, 1284, 267, 3421, 402, 1263, 2213, 13, 2407, 1566, 12, 2755, 340, 314, 1798, 365, 267, 440, 17290, 376, 1125, 14, 26914, 12, 314, 4223, 911, 675, 267, 642, 2556, 367, 17290, 2399, 5705, 2552, 334, 10180, 465, 267, 4528, 1564, 626, 1630, 440, 1336, 376, 4223, 1159, 267, 26440, 4713, 680, 710, 2556, 2138, 701, 314, 14067, 365, 267, 8646, 440, 19258, 367, 675, 543, 282, 2754, 6869, 14, 398, 3390, 626, 314, 14067, 911, 372, 3211, 2556, 1454, 267, 5309, 314, 19569, 402, 314, 4474, 315, 642, 3217, 14, 710, 267, 4223, 1077, 440, 7427, 370, 675, 652, 737, 1263, 1163, 900, 1041, 267, 291, 423, 6354, 275, 14067, 339, 347, 1343, 5564, 8, 277, 304, 267, 408, 14235, 6955, 402, 314, 9608, 402, 282, 2213, 14, 398, 710, 19310, 1798, 911, 12677, 642, 1083, 1454, 5403, 12, 2544, 1263, 267, 1163, 3102, 315, 642, 3217, 503, 315, 577, 13449, 2461, 334, 2590, 367, 267, 663, 5564, 10725, 10477, 339, 347, 1284, 5564, 8, 277, 304, 267, 408, 14235, 6955, 402, 314, 1284, 402, 282, 2213, 14, 398, 710, 19310, 1798, 911, 12677, 642, 1083, 1454, 5403, 12, 436, 652, 911, 267, 506, 314, 2061, 1083, 10302, 5309, 314, 2198, 14, 710, 1798, 10989, 267, 440, 12677, 642, 1083, 5133, 652, 965, 1902, 2236, 460, 28918, 6057, 267, 334, 20684, 402, 376, 625, 23131, 461, 1125, 9, 503, 13075, 314, 1284, 402, 267, 1324, 1041, 339, 347, 1343, 4793, 7674, 8, 277, 12, 2403, 12, 5108, 304, 267, 408, 5595, 314, 4194, 402, 282, 2403, 13, 7639, 19317, 4412, 14, 398, 710, 2556, 687, 642, 1566, 365, 440, 5784, 367, 3293, 267, 19317, 6661, 26, 314, 19310, 4692, 7002, 911, 5847, 267, 3350, 13158, 367, 1819, 436, 2225, 1561, 1380, 314, 267, 1455, 921, 1652, 14, 1308, 15, 14338, 15, 3179, 15, 9247, 3878, 365, 2549, 334, 1589, 267, 849, 680, 398, 6006, 787, 5560, 12, 13432, 12, 1380, 13103, 1929, 370, 675, 267, 13158, 315, 4528, 666, 503, 315, 2225, 1338, 12, 2382, 2985, 267, 3913, 19353, 506, 11507, 5847, 27, 314, 267, 1343, 15, 500, 4793, 7674, 1566, 4973, 6528, 314, 2556, 370, 314, 267, 4223, 370, 6544, 13158, 315, 5204, 18191, 6337, 12, 340, 267, 5784, 14, 398, 3390, 626, 1343, 15, 500, 4793, 7674, 4474, 787, 440, 17334, 370, 267, 506, 7684, 6032, 3847, 370, 1924, 13, 1848, 26, 1006, 267, 1343, 4793, 7674, 4474, 911, 4781, 2544, 314, 5226, 267, 26325, 1566, 12, 436, 1006, 1284, 4793, 7674, 4474, 911, 4781, 267, 2410, 314, 5226, 28920, 1566, 12, 1325, 3932, 1865, 365, 267, 440, 17334, 1041, 339, 347, 1284, 4793, 7674, 8, 277, 12, 2403, 304, 267, 408, 3005, 314, 4194, 402, 282, 2403, 13, 7639, 4412, 14, 398, 1666, 1343, 4793, 7674, 367, 2436, 14, 961, 1566, 911, 3544, 267, 4781, 2410, 314, 5226, 28920, 1566, 12, 1325, 314, 1865, 267, 402, 1284, 4793, 7674, 4474, 365, 440, 4257, 17334, 1041, 339, 347, 26325, 8, 277, 12, 536, 12, 3290, 304, 267, 408, 28536, 314, 1343, 402, 376, 1819, 315, 2222, 13, 3251, 818, 14, 398, 710, 536, 2725, 3509, 314, 3066, 4692, 413, 14, 16, 536, 402, 314, 267, 1819, 730, 465, 282, 1059, 436, 314, 3290, 2725, 15164, 376, 267, 1256, 402, 314, 9382, 1021, 3035, 314, 3004, 402, 267, 314, 1819, 1041, 339, 347, 28920, 8, 277, 12, 536, 304, 267, 408, 28536, 314, 1284, 402, 376, 1819, 315, 2222, 13, 3251, 818, 14, 398, 710, 536, 2725 ]
[ 199, 2765, 859, 3509, 314, 6170, 3992, 402, 1015, 499, 14, 16, 402, 19310, 367, 2018, 14, 199, 2765, 570, 6571, 1454, 849, 3992, 543, 3679, 590, 7481, 199, 1593, 6712, 12, 687, 1314, 19016, 436, 13103, 883, 506, 1007, 28271, 14, 199, 199, 4089, 402, 3520, 3992, 787, 2701, 436, 787, 5120, 1454, 465, 3794, 199, 1618, 314, 8386, 14, 199, 199, 4, 1304, 26, 3016, 14, 647, 12, 86, 413, 14, 21, 14790, 15, 996, 15, 1079, 19363, 26, 1643, 26, 1344, 560, 546, 374, 7910, 2672, 199, 624, 199, 199, 1023, 275, 283, 18, 14, 16, 5683, 7, 199, 199, 14813, 5769, 199, 3, 199, 3, 23276, 19650, 8729, 38, 21287, 199, 3, 199, 14813, 5769, 199, 199, 3, 9310, 12539, 30872, 9310, 199, 199, 533, 4520, 2461, 26, 272, 408, 6845, 3217, 367, 19310, 1125, 8297, 14, 339, 982, 1265, 1218, 376, 909, 626, 9031, 642, 3217, 12, 2066, 272, 2274, 314, 909, 543, 2195, 4692, 5929, 12, 314, 1798, 911, 1240, 314, 272, 3102, 315, 2195, 909, 370, 3622, 1006, 3598, 436, 2552, 14, 6006, 272, 787, 7795, 11106, 402, 2552, 2808, 26, 3598, 12, 334, 19614, 9, 272, 22803, 461, 2552, 12, 436, 625, 23131, 461, 2552, 14, 2900, 3102, 5452, 282, 272, 19310, 4003, 1726, 465, 314, 1454, 2725, 1041, 339, 347, 1125, 8, 277, 12, 1919, 304, 267, 298, 5940, 282, 22803, 461, 1125, 2122, 267, 746, 1919, 339, 347, 14294, 547, 8, 277, 12, 1919, 304, 267, 298, 5940, 282, 2222, 13, 23131, 461, 1125, 2122, 267, 746, 1919, 339, 347, 5721, 8, 277, 12, 1919, 304, 267, 298, 5940, 282, 5721, 2122, 267, 870, 1919, 421, 199, 3, 9310, 29417, 30872, 9310, 199, 199, 533, 6646, 2461, 26, 272, 408, 4267, 367, 18390, 11461, 2213, 1564, 4474, 14, 339, 961, 365, 314, 2446, 3233, 3217, 315, 19310, 12, 436, 314, 1373, 4750, 272, 11012, 370, 13103, 14, 710, 1865, 402, 4474, 315, 642, 3217, 272, 15216, 83, 314, 1865, 402, 314, 2556, 315, 314, 2213, 1041, 339, 347, 636, 826, 721, 277, 304, 267, 291, 423, 6354, 275, 488, 339, 347, 663, 5564, 10725, 8, 277, 12, 14067, 304, 267, 408, 10474, 701, 314, 1798, 370, 8120, 314, 4223, 282, 14067, 367, 267, 4355, 1958, 314, 6330, 402, 2213, 4474, 14, 398, 19310, 21295, 787, 30390, 655, 25715, 6028, 334, 15401, 440, 3679, 590, 267, 1415, 9, 370, 17169, 282, 14067, 26, 340, 652, 1630, 880, 12, 652, 1471, 17169, 267, 314, 14067, 370, 314, 4223, 701, 26750, 642, 1083, 2544, 267, 26750, 1263, 402, 314, 1163, 3102, 315, 314, 7543, 2461, 267, 3217, 14, 398, 710, 14067, 6127, 314, 4223, 370, 6705, 314, 1284, 267, 3421, 402, 1263, 2213, 13, 2407, 1566, 12, 2755, 340, 314, 1798, 365, 267, 440, 17290, 376, 1125, 14, 26914, 12, 314, 4223, 911, 675, 267, 642, 2556, 367, 17290, 2399, 5705, 2552, 334, 10180, 465, 267, 4528, 1564, 626, 1630, 440, 1336, 376, 4223, 1159, 267, 26440, 4713, 680, 710, 2556, 2138, 701, 314, 14067, 365, 267, 8646, 440, 19258, 367, 675, 543, 282, 2754, 6869, 14, 398, 3390, 626, 314, 14067, 911, 372, 3211, 2556, 1454, 267, 5309, 314, 19569, 402, 314, 4474, 315, 642, 3217, 14, 710, 267, 4223, 1077, 440, 7427, 370, 675, 652, 737, 1263, 1163, 900, 1041, 267, 291, 423, 6354, 275, 14067, 339, 347, 1343, 5564, 8, 277, 304, 267, 408, 14235, 6955, 402, 314, 9608, 402, 282, 2213, 14, 398, 710, 19310, 1798, 911, 12677, 642, 1083, 1454, 5403, 12, 2544, 1263, 267, 1163, 3102, 315, 642, 3217, 503, 315, 577, 13449, 2461, 334, 2590, 367, 267, 663, 5564, 10725, 10477, 339, 347, 1284, 5564, 8, 277, 304, 267, 408, 14235, 6955, 402, 314, 1284, 402, 282, 2213, 14, 398, 710, 19310, 1798, 911, 12677, 642, 1083, 1454, 5403, 12, 436, 652, 911, 267, 506, 314, 2061, 1083, 10302, 5309, 314, 2198, 14, 710, 1798, 10989, 267, 440, 12677, 642, 1083, 5133, 652, 965, 1902, 2236, 460, 28918, 6057, 267, 334, 20684, 402, 376, 625, 23131, 461, 1125, 9, 503, 13075, 314, 1284, 402, 267, 1324, 1041, 339, 347, 1343, 4793, 7674, 8, 277, 12, 2403, 12, 5108, 304, 267, 408, 5595, 314, 4194, 402, 282, 2403, 13, 7639, 19317, 4412, 14, 398, 710, 2556, 687, 642, 1566, 365, 440, 5784, 367, 3293, 267, 19317, 6661, 26, 314, 19310, 4692, 7002, 911, 5847, 267, 3350, 13158, 367, 1819, 436, 2225, 1561, 1380, 314, 267, 1455, 921, 1652, 14, 1308, 15, 14338, 15, 3179, 15, 9247, 3878, 365, 2549, 334, 1589, 267, 849, 680, 398, 6006, 787, 5560, 12, 13432, 12, 1380, 13103, 1929, 370, 675, 267, 13158, 315, 4528, 666, 503, 315, 2225, 1338, 12, 2382, 2985, 267, 3913, 19353, 506, 11507, 5847, 27, 314, 267, 1343, 15, 500, 4793, 7674, 1566, 4973, 6528, 314, 2556, 370, 314, 267, 4223, 370, 6544, 13158, 315, 5204, 18191, 6337, 12, 340, 267, 5784, 14, 398, 3390, 626, 1343, 15, 500, 4793, 7674, 4474, 787, 440, 17334, 370, 267, 506, 7684, 6032, 3847, 370, 1924, 13, 1848, 26, 1006, 267, 1343, 4793, 7674, 4474, 911, 4781, 2544, 314, 5226, 267, 26325, 1566, 12, 436, 1006, 1284, 4793, 7674, 4474, 911, 4781, 267, 2410, 314, 5226, 28920, 1566, 12, 1325, 3932, 1865, 365, 267, 440, 17334, 1041, 339, 347, 1284, 4793, 7674, 8, 277, 12, 2403, 304, 267, 408, 3005, 314, 4194, 402, 282, 2403, 13, 7639, 4412, 14, 398, 1666, 1343, 4793, 7674, 367, 2436, 14, 961, 1566, 911, 3544, 267, 4781, 2410, 314, 5226, 28920, 1566, 12, 1325, 314, 1865, 267, 402, 1284, 4793, 7674, 4474, 365, 440, 4257, 17334, 1041, 339, 347, 26325, 8, 277, 12, 536, 12, 3290, 304, 267, 408, 28536, 314, 1343, 402, 376, 1819, 315, 2222, 13, 3251, 818, 14, 398, 710, 536, 2725, 3509, 314, 3066, 4692, 413, 14, 16, 536, 402, 314, 267, 1819, 730, 465, 282, 1059, 436, 314, 3290, 2725, 15164, 376, 267, 1256, 402, 314, 9382, 1021, 3035, 314, 3004, 402, 267, 314, 1819, 1041, 339, 347, 28920, 8, 277, 12, 536, 304, 267, 408, 28536, 314, 1284, 402, 376, 1819, 315, 2222, 13, 3251, 818, 14, 398, 710, 536, 2725, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
junhuac/MQUIC
depot_tools/external_bin/gsutil/gsutil_4.15/gsutil/third_party/boto/boto/ec2/elb/healthcheck.py
185
3775
# Copyright (c) 2006-2012 Mitch Garnaat http://garnaat.org/ # Copyright (c) 2012 Amazon.com, Inc. or its affiliates. # All Rights Reserved # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing conditions: # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. class HealthCheck(object): """ Represents an EC2 Access Point Health Check. See :ref:`elb-configuring-a-health-check` for a walkthrough on configuring load balancer health checks. """ def __init__(self, access_point=None, interval=30, target=None, healthy_threshold=3, timeout=5, unhealthy_threshold=5): """ :ivar str access_point: The name of the load balancer this health check is associated with. :ivar int interval: Specifies how many seconds there are between health checks. :ivar str target: Determines what to check on an instance. See the Amazon HealthCheck_ documentation for possible Target values. .. _HealthCheck: http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/APIReference/API_HealthCheck.html """ self.access_point = access_point self.interval = interval self.target = target self.healthy_threshold = healthy_threshold self.timeout = timeout self.unhealthy_threshold = unhealthy_threshold def __repr__(self): return 'HealthCheck:%s' % self.target def startElement(self, name, attrs, connection): return None def endElement(self, name, value, connection): if name == 'Interval': self.interval = int(value) elif name == 'Target': self.target = value elif name == 'HealthyThreshold': self.healthy_threshold = int(value) elif name == 'Timeout': self.timeout = int(value) elif name == 'UnhealthyThreshold': self.unhealthy_threshold = int(value) else: setattr(self, name, value) def update(self): """ In the case where you have accessed an existing health check on a load balancer, this method applies this instance's health check values to the load balancer it is attached to. .. note:: This method will not do anything if the :py:attr:`access_point` attribute isn't set, as is the case with a newly instantiated HealthCheck instance. """ if not self.access_point: return new_hc = self.connection.configure_health_check(self.access_point, self) self.interval = new_hc.interval self.target = new_hc.target self.healthy_threshold = new_hc.healthy_threshold self.unhealthy_threshold = new_hc.unhealthy_threshold self.timeout = new_hc.timeout
mit
[ 3, 1898, 334, 67, 9, 8315, 13, 7409, 603, 9414, 598, 26272, 1455, 921, 71, 26272, 14, 1308, 15, 199, 3, 1898, 334, 67, 9, 6029, 14347, 14, 957, 12, 3277, 14, 503, 2399, 29172, 2335, 14, 199, 3, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 421, 199, 533, 5311, 6130, 1799, 8, 785, 304, 272, 408, 272, 21591, 376, 15352, 18, 11003, 7584, 5311, 6130, 2670, 14, 1666, 272, 520, 1121, 1705, 17778, 13, 888, 4039, 13, 65, 13, 9665, 13, 1074, 64, 367, 282, 12778, 8304, 641, 1101, 4039, 272, 2248, 17005, 13822, 5920, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2879, 63, 1403, 29, 403, 12, 6252, 29, 1216, 12, 1347, 29, 403, 12, 326, 13822, 89, 63, 7227, 29, 19, 12, 2653, 29, 21, 12, 625, 29584, 63, 7227, 29, 21, 304, 267, 408, 267, 520, 7725, 620, 2879, 63, 1403, 26, 710, 536, 402, 314, 2248, 17005, 642, 288, 13822, 1104, 365, 4568, 543, 14, 267, 520, 7725, 1109, 6252, 26, 11015, 4212, 5002, 4696, 2337, 787, 3382, 288, 13822, 5920, 14, 267, 520, 7725, 620, 1347, 26, 22391, 4052, 370, 1104, 641, 376, 1256, 14, 1666, 314, 288, 14347, 5311, 6130, 1799, 63, 3794, 367, 3962, 10256, 1338, 14, 398, 2508, 485, 18850, 1799, 26, 1455, 921, 4757, 14, 15144, 2520, 5950, 14, 957, 15, 27822, 6200, 13129, 15763, 15, 7410, 15, 3735, 5083, 15, 3735, 63, 18850, 1799, 14, 1360, 267, 408, 267, 291, 14, 2732, 63, 1403, 275, 2879, 63, 1403, 267, 291, 14, 4284, 275, 6252, 267, 291, 14, 1375, 275, 1347, 267, 291, 14, 29584, 63, 7227, 275, 13822, 89, 63, 7227, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 324, 29584, 63, 7227, 275, 625, 29584, 63, 7227, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 18850, 1799, 2689, 83, 7, 450, 291, 14, 1375, 339, 347, 26325, 8, 277, 12, 536, 12, 3290, 12, 1950, 304, 267, 372, 488, 339, 347, 28920, 8, 277, 12, 536, 12, 574, 12, 1950, 304, 267, 340, 536, 508, 283, 8227, 356, 288, 291, 14, 4284, 275, 1109, 8, 585, 9, 267, 916, 536, 508, 283, 4277, 356, 288, 291, 14, 1375, 275, 574, 267, 916, 536, 508, 283, 18850, 89, 12109, 356, 288, 291, 14, 29584, 63, 7227, 275, 1109, 8, 585, 9, 267, 916, 536, 508, 283, 6372, 356, 288, 291, 14, 2593, 275, 1109, 8, 585, 9, 267, 916, 536, 508, 283, 1358, 29584, 12109, 356, 288, 291, 14, 324, 29584, 63, 7227, 275, 1109, 8, 585, 9, 267, 587, 26, 288, 5371, 8, 277, 12, 536, 12, 574, 9, 339, 347, 1678, 8, 277, 304, 267, 408, 267, 1010, 314, 1930, 2382, 1265, 1172, 13810, 376, 3411, 13822, 1104, 641, 282, 267, 2248, 17005, 12, 642, 1083, 12966, 642, 1256, 1159, 13822, 1104, 267, 1338, 370, 314, 2248, 17005, 652, 365, 10102, 370, 14, 398, 2508, 5317, 447, 961, 1083, 911, 440, 886, 7003, 340, 314, 520, 647, 26, 962, 1705, 2732, 63, 1403, 64, 288, 2225, 5712, 1133, 663, 12, 465, 365, 314, 1930, 543, 282, 13903, 17544, 288, 5311, 6130, 1799, 1256, 14, 267, 408, 267, 340, 440, 291, 14, 2732, 63, 1403, 26, 288, 372, 398, 892, 63, 15907, 275, 291, 14, 2105, 14, 6472, 63, 9665, 63, 1074, 8, 277, 14, 2732, 63, 1403, 12, 9144, 291, 9, 267, 291, 14, 4284, 275, 892, 63, 15907, 14, 4284, 267, 291, 14, 1375, 275, 892, 63, 15907, 14, 1375, 267, 291, 14, 29584, 63, 7227, 275, 892, 63, 15907, 14, 29584, 63, 7227, 267, 291, 14, 324, 29584, 63, 7227, 275, 892, 63, 15907, 14, 324, 29584, 63, 7227, 267, 291, 14, 2593, 275, 892, 63, 15907, 14, 2593, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1898, 334, 67, 9, 8315, 13, 7409, 603, 9414, 598, 26272, 1455, 921, 71, 26272, 14, 1308, 15, 199, 3, 1898, 334, 67, 9, 6029, 14347, 14, 957, 12, 3277, 14, 503, 2399, 29172, 2335, 14, 199, 3, 2900, 5924, 5702, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 199, 3, 1331, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 199, 3, 298, 10337, 1288, 370, 7962, 315, 314, 2290, 1928, 10588, 12, 5893, 199, 3, 1928, 12305, 314, 4481, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 2153, 13, 199, 3, 28420, 12, 13473, 12, 436, 15, 269, 12743, 6866, 402, 314, 2290, 12, 436, 370, 11291, 199, 3, 12103, 370, 12676, 314, 2290, 365, 13985, 370, 886, 880, 12, 5420, 370, 314, 1699, 13, 199, 3, 28486, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 199, 3, 315, 1006, 6866, 503, 13393, 12468, 402, 314, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 199, 3, 1549, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 28471, 13, 199, 3, 28463, 12, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 199, 3, 7000, 2334, 17632, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 5603, 12, 199, 3, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 199, 3, 1621, 2334, 4141, 14, 421, 199, 533, 5311, 6130, 1799, 8, 785, 304, 272, 408, 272, 21591, 376, 15352, 18, 11003, 7584, 5311, 6130, 2670, 14, 1666, 272, 520, 1121, 1705, 17778, 13, 888, 4039, 13, 65, 13, 9665, 13, 1074, 64, 367, 282, 12778, 8304, 641, 1101, 4039, 272, 2248, 17005, 13822, 5920, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 2879, 63, 1403, 29, 403, 12, 6252, 29, 1216, 12, 1347, 29, 403, 12, 326, 13822, 89, 63, 7227, 29, 19, 12, 2653, 29, 21, 12, 625, 29584, 63, 7227, 29, 21, 304, 267, 408, 267, 520, 7725, 620, 2879, 63, 1403, 26, 710, 536, 402, 314, 2248, 17005, 642, 288, 13822, 1104, 365, 4568, 543, 14, 267, 520, 7725, 1109, 6252, 26, 11015, 4212, 5002, 4696, 2337, 787, 3382, 288, 13822, 5920, 14, 267, 520, 7725, 620, 1347, 26, 22391, 4052, 370, 1104, 641, 376, 1256, 14, 1666, 314, 288, 14347, 5311, 6130, 1799, 63, 3794, 367, 3962, 10256, 1338, 14, 398, 2508, 485, 18850, 1799, 26, 1455, 921, 4757, 14, 15144, 2520, 5950, 14, 957, 15, 27822, 6200, 13129, 15763, 15, 7410, 15, 3735, 5083, 15, 3735, 63, 18850, 1799, 14, 1360, 267, 408, 267, 291, 14, 2732, 63, 1403, 275, 2879, 63, 1403, 267, 291, 14, 4284, 275, 6252, 267, 291, 14, 1375, 275, 1347, 267, 291, 14, 29584, 63, 7227, 275, 13822, 89, 63, 7227, 267, 291, 14, 2593, 275, 2653, 267, 291, 14, 324, 29584, 63, 7227, 275, 625, 29584, 63, 7227, 339, 347, 636, 2722, 721, 277, 304, 267, 372, 283, 18850, 1799, 2689, 83, 7, 450, 291, 14, 1375, 339, 347, 26325, 8, 277, 12, 536, 12, 3290, 12, 1950, 304, 267, 372, 488, 339, 347, 28920, 8, 277, 12, 536, 12, 574, 12, 1950, 304, 267, 340, 536, 508, 283, 8227, 356, 288, 291, 14, 4284, 275, 1109, 8, 585, 9, 267, 916, 536, 508, 283, 4277, 356, 288, 291, 14, 1375, 275, 574, 267, 916, 536, 508, 283, 18850, 89, 12109, 356, 288, 291, 14, 29584, 63, 7227, 275, 1109, 8, 585, 9, 267, 916, 536, 508, 283, 6372, 356, 288, 291, 14, 2593, 275, 1109, 8, 585, 9, 267, 916, 536, 508, 283, 1358, 29584, 12109, 356, 288, 291, 14, 324, 29584, 63, 7227, 275, 1109, 8, 585, 9, 267, 587, 26, 288, 5371, 8, 277, 12, 536, 12, 574, 9, 339, 347, 1678, 8, 277, 304, 267, 408, 267, 1010, 314, 1930, 2382, 1265, 1172, 13810, 376, 3411, 13822, 1104, 641, 282, 267, 2248, 17005, 12, 642, 1083, 12966, 642, 1256, 1159, 13822, 1104, 267, 1338, 370, 314, 2248, 17005, 652, 365, 10102, 370, 14, 398, 2508, 5317, 447, 961, 1083, 911, 440, 886, 7003, 340, 314, 520, 647, 26, 962, 1705, 2732, 63, 1403, 64, 288, 2225, 5712, 1133, 663, 12, 465, 365, 314, 1930, 543, 282, 13903, 17544, 288, 5311, 6130, 1799, 1256, 14, 267, 408, 267, 340, 440, 291, 14, 2732, 63, 1403, 26, 288, 372, 398, 892, 63, 15907, 275, 291, 14, 2105, 14, 6472, 63, 9665, 63, 1074, 8, 277, 14, 2732, 63, 1403, 12, 9144, 291, 9, 267, 291, 14, 4284, 275, 892, 63, 15907, 14, 4284, 267, 291, 14, 1375, 275, 892, 63, 15907, 14, 1375, 267, 291, 14, 29584, 63, 7227, 275, 892, 63, 15907, 14, 29584, 63, 7227, 267, 291, 14, 324, 29584, 63, 7227, 275, 892, 63, 15907, 14, 324, 29584, 63, 7227, 267, 291, 14, 2593, 275, 892, 63, 15907, 14, 2593, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jakesyl/fail2ban
fail2ban/protocol.py
1
9025
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fail2Ban is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Author: Cyril Jaquier # __author__ = "Cyril Jaquier" __copyright__ = "Copyright (c) 2004 Cyril Jaquier" __license__ = "GPL" import textwrap ## # Describes the protocol used to communicate with the server. protocol = [ ['', "BASIC", ""], ["start", "starts the server and the jails"], ["reload", "reloads the configuration"], ["reload <JAIL>", "reloads the jail <JAIL>"], ["stop", "stops all jails and terminate the server"], ["status", "gets the current status of the server"], ["ping", "tests if the server is alive"], ["help", "return this output"], ["version", "return the server version"], ['', "LOGGING", ""], ["set loglevel <LEVEL>", "sets logging level to <LEVEL>. Levels: CRITICAL, ERROR, WARNING, NOTICE, INFO, DEBUG"], ["get loglevel", "gets the logging level"], ["set logtarget <TARGET>", "sets logging target to <TARGET>. Can be STDOUT, STDERR, SYSLOG or a file"], ["get logtarget", "gets logging target"], ["flushlogs", "flushes the logtarget if a file and reopens it. For log rotation."], ['', "DATABASE", ""], ["set dbfile <FILE>", "set the location of fail2ban persistent datastore. Set to \"None\" to disable"], ["get dbfile", "get the location of fail2ban persistent datastore"], ["set dbpurgeage <SECONDS>", "sets the max age in <SECONDS> that history of bans will be kept"], ["get dbpurgeage", "gets the max age in seconds that history of bans will be kept"], ['', "JAIL CONTROL", ""], ["add <JAIL> <BACKEND>", "creates <JAIL> using <BACKEND>"], ["start <JAIL>", "starts the jail <JAIL>"], ["stop <JAIL>", "stops the jail <JAIL>. The jail is removed"], ["status <JAIL> [FLAVOR]", "gets the current status of <JAIL>, with optional flavor or extended info"], ['', "JAIL CONFIGURATION", ""], ["set <JAIL> idle on|off", "sets the idle state of <JAIL>"], ["set <JAIL> addignoreip <IP>", "adds <IP> to the ignore list of <JAIL>"], ["set <JAIL> delignoreip <IP>", "removes <IP> from the ignore list of <JAIL>"], ["set <JAIL> addlogpath <FILE> ['tail']", "adds <FILE> to the monitoring list of <JAIL>, optionally starting at the 'tail' of the file (default 'head')."], ["set <JAIL> dellogpath <FILE>", "removes <FILE> from the monitoring list of <JAIL>"], ["set <JAIL> logencoding <ENCODING>", "sets the <ENCODING> of the log files for <JAIL>"], ["set <JAIL> addjournalmatch <MATCH>", "adds <MATCH> to the journal filter of <JAIL>"], ["set <JAIL> deljournalmatch <MATCH>", "removes <MATCH> from the journal filter of <JAIL>"], ["set <JAIL> addfailregex <REGEX>", "adds the regular expression <REGEX> which must match failures for <JAIL>"], ["set <JAIL> delfailregex <INDEX>", "removes the regular expression at <INDEX> for failregex"], ["set <JAIL> ignorecommand <VALUE>", "sets ignorecommand of <JAIL>"], ["set <JAIL> addignoreregex <REGEX>", "adds the regular expression <REGEX> which should match pattern to exclude for <JAIL>"], ["set <JAIL> delignoreregex <INDEX>", "removes the regular expression at <INDEX> for ignoreregex"], ["set <JAIL> findtime <TIME>", "sets the number of seconds <TIME> for which the filter will look back for <JAIL>"], ["set <JAIL> bantime <TIME>", "sets the number of seconds <TIME> a host will be banned for <JAIL>"], ["set <JAIL> datepattern <PATTERN>", "sets the <PATTERN> used to match date/times for <JAIL>"], ["set <JAIL> usedns <VALUE>", "sets the usedns mode for <JAIL>"], ["set <JAIL> banip <IP>", "manually Ban <IP> for <JAIL>"], ["set <JAIL> unbanip <IP>", "manually Unban <IP> in <JAIL>"], ["set <JAIL> maxretry <RETRY>", "sets the number of failures <RETRY> before banning the host for <JAIL>"], ["set <JAIL> maxlines <LINES>", "sets the number of <LINES> to buffer for regex search for <JAIL>"], ["set <JAIL> addaction <ACT>[ <PYTHONFILE> <JSONKWARGS>]", "adds a new action named <NAME> for <JAIL>. Optionally for a Python based action, a <PYTHONFILE> and <JSONKWARGS> can be specified, else will be a Command Action"], ["set <JAIL> delaction <ACT>", "removes the action <ACT> from <JAIL>"], ["", "COMMAND ACTION CONFIGURATION", ""], ["set <JAIL> action <ACT> actionstart <CMD>", "sets the start command <CMD> of the action <ACT> for <JAIL>"], ["set <JAIL> action <ACT> actionstop <CMD>", "sets the stop command <CMD> of the action <ACT> for <JAIL>"], ["set <JAIL> action <ACT> actioncheck <CMD>", "sets the check command <CMD> of the action <ACT> for <JAIL>"], ["set <JAIL> action <ACT> actionban <CMD>", "sets the ban command <CMD> of the action <ACT> for <JAIL>"], ["set <JAIL> action <ACT> actionunban <CMD>", "sets the unban command <CMD> of the action <ACT> for <JAIL>"], ["set <JAIL> action <ACT> timeout <TIMEOUT>", "sets <TIMEOUT> as the command timeout in seconds for the action <ACT> for <JAIL>"], ["", "GENERAL ACTION CONFIGURATION", ""], ["set <JAIL> action <ACT> <PROPERTY> <VALUE>", "sets the <VALUE> of <PROPERTY> for the action <ACT> for <JAIL>"], ["set <JAIL> action <ACT> <METHOD>[ <JSONKWARGS>]", "calls the <METHOD> with <JSONKWARGS> for the action <ACT> for <JAIL>"], ['', "JAIL INFORMATION", ""], ["get <JAIL> logpath", "gets the list of the monitored files for <JAIL>"], ["get <JAIL> logencoding", "gets the encoding of the log files for <JAIL>"], ["get <JAIL> journalmatch", "gets the journal filter match for <JAIL>"], ["get <JAIL> ignoreip", "gets the list of ignored IP addresses for <JAIL>"], ["get <JAIL> ignorecommand", "gets ignorecommand of <JAIL>"], ["get <JAIL> failregex", "gets the list of regular expressions which matches the failures for <JAIL>"], ["get <JAIL> ignoreregex", "gets the list of regular expressions which matches patterns to ignore for <JAIL>"], ["get <JAIL> findtime", "gets the time for which the filter will look back for failures for <JAIL>"], ["get <JAIL> bantime", "gets the time a host is banned for <JAIL>"], ["get <JAIL> datepattern", "gets the patern used to match date/times for <JAIL>"], ["get <JAIL> usedns", "gets the usedns setting for <JAIL>"], ["get <JAIL> maxretry", "gets the number of failures allowed for <JAIL>"], ["get <JAIL> maxlines", "gets the number of lines to buffer for <JAIL>"], ["get <JAIL> actions", "gets a list of actions for <JAIL>"], ["", "COMMAND ACTION INFORMATION",""], ["get <JAIL> action <ACT> actionstart", "gets the start command for the action <ACT> for <JAIL>"], ["get <JAIL> action <ACT> actionstop", "gets the stop command for the action <ACT> for <JAIL>"], ["get <JAIL> action <ACT> actioncheck", "gets the check command for the action <ACT> for <JAIL>"], ["get <JAIL> action <ACT> actionban", "gets the ban command for the action <ACT> for <JAIL>"], ["get <JAIL> action <ACT> actionunban", "gets the unban command for the action <ACT> for <JAIL>"], ["get <JAIL> action <ACT> timeout", "gets the command timeout in seconds for the action <ACT> for <JAIL>"], ["", "GENERAL ACTION INFORMATION", ""], ["get <JAIL> actionproperties <ACT>", "gets a list of properties for the action <ACT> for <JAIL>"], ["get <JAIL> actionmethods <ACT>", "gets a list of methods for the action <ACT> for <JAIL>"], ["get <JAIL> action <ACT> <PROPERTY>", "gets the value of <PROPERTY> for the action <ACT> for <JAIL>"], ] ## # Prints the protocol in a "man" format. This is used for the # "-h" output of fail2ban-client. def printFormatted(): INDENT=4 MARGIN=41 WIDTH=34 firstHeading = False for m in protocol: if m[0] == '' and firstHeading: print firstHeading = True first = True if len(m[0]) >= MARGIN: m[1] = ' ' * WIDTH + m[1] for n in textwrap.wrap(m[1], WIDTH, drop_whitespace=False): if first: line = ' ' * INDENT + m[0] + ' ' * (MARGIN - len(m[0])) + n.strip() first = False else: line = ' ' * (INDENT + MARGIN) + n.strip() print line ## # Prints the protocol in a "mediawiki" format. def printWiki(): firstHeading = False for m in protocol: if m[0] == '': if firstHeading: print "|}" __printWikiHeader(m[1], m[2]) firstHeading = True else: print "|-" print "| <span style=\"white-space:nowrap;\"><tt>" + m[0] + "</tt></span> || || " + m[1] print "|}" def __printWikiHeader(section, desc): print print "=== " + section + " ===" print print desc print print "{|" print "| '''Command''' || || '''Description'''"
gpl-2.0
[ 3, 325, 19309, 26, 1882, 818, 26, 2366, 27, 1134, 13, 3724, 13, 2743, 26, 841, 27, 4363, 13, 8741, 13, 632, 26, 307, 1882, 199, 3, 1321, 26, 663, 18133, 29, 1548, 23014, 29, 20, 6714, 29, 20, 5584, 29, 20, 949, 386, 520, 199, 199, 3, 961, 570, 365, 1777, 402, 12176, 18, 28018, 14, 199, 3, 199, 3, 12176, 18, 28018, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12176, 18, 28018, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 12176, 18, 28018, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 12, 8217, 14, 199, 199, 3, 6529, 26, 18461, 10363, 1603, 65, 783, 281, 199, 3, 9948, 199, 363, 2502, 363, 275, 298, 9156, 10363, 1603, 65, 783, 281, 2, 199, 363, 7307, 363, 275, 298, 7384, 334, 67, 9, 8353, 18461, 10363, 1603, 65, 783, 281, 2, 199, 363, 1682, 363, 275, 298, 12006, 2, 199, 199, 646, 13390, 199, 199, 309, 199, 3, 28571, 11562, 314, 4113, 1202, 370, 26808, 543, 314, 1654, 14, 199, 199, 3922, 275, 359, 199, 459, 297, 298, 27271, 401, 298, 2255, 199, 905, 928, 401, 298, 17116, 314, 1654, 436, 314, 1335, 1054, 83, 2255, 221, 199, 905, 9233, 401, 298, 264, 3640, 314, 2897, 2255, 221, 199, 905, 9233, 665, 42, 6593, 7166, 298, 264, 3640, 314, 1335, 1054, 665, 42, 6593, 30, 2255, 221, 199, 905, 2379, 401, 298, 270, 1483, 1006, 1335, 1054, 83, 436, 15095, 314, 1654, 2255, 221, 199, 905, 1205, 401, 298, 24894, 314, 1453, 2004, 402, 314, 1654, 2255, 221, 199, 905, 4073, 401, 298, 2219, 340, 314, 1654, 365, 19708, 2255, 221, 199, 905, 3437, 401, 298, 1107, 642, 1072, 2255, 221, 199, 905, 1023, 401, 298, 1107, 314, 1654, 1015, 2255, 199, 459, 297, 298, 27896, 401, 298, 2255, 199, 905, 409, 943, 1896, 665, 11817, 7166, 298, 2193, 2050, 2166, 370, 665, 11817, 10827, 20400, 83, 26, 17101, 19223, 12, 12539, 12, 14750, 12, 12840, 12, 24008, 12, 10990, 2255, 221, 199, 905, 362, 943, 1896, 401, 298, 24894, 314, 2050, 2166, 2255, 221, 199, 905, 409, 943, 1375, 665, 9268, 7166, 298, 2193, 2050, 1347, 370, 665, 9268, 10827, 6855, 506, 4384, 12619, 12, 30118, 2666, 12, 10046, 51, 4947, 503, 282, 570, 2255, 221, 199, 905, 362, 943, 1375, 401, 298, 24894, 2050, 1347, 2255, 221, 199, 905, 4939, 7270, 401, 298, 4939, 397, 314, 943, 1375, 340, 282, 570, 436, 295, 1490, 83, 652, 14, 2104, 943, 13038, 2122, 467, 221, 199, 459, 297, 298, 17873, 401, 298, 2255, 199, 905, 409, 1592, 493, 665, 3817, 7166, 298, 409, 314, 2909, 402, 2449, 18, 13206, 16149, 12007, 14, 2494, 370, 8441, 403, 4451, 370, 3507, 2255, 221, 199, 905, 362, 1592, 493, 401, 298, 362, 314, 2909, 402, 2449, 18, 13206, 16149, 12007, 2255, 221, 199, 905, 409, 1592, 18254, 474, 665, 23319, 7166, 298, 2193, 314, 1390, 11437, 315, 665, 23319, 30, 626, 7994, 402, 330, 796, 911, 506, 16204, 2255, 221, 199, 905, 362, 1592, 18254, 474, 401, 298, 24894, 314, 1390, 11437, 315, 4696, 626, 7994, 402, 330, 796, 911, 506, 16204, 2255, 221, 199, 459, 297, 298, 42, 6593, 8098, 401, 298, 2255, 199, 905, 525, 665, 42, 6593, 30, 665, 18145, 7166, 298, 28219, 665, 42, 6593, 30, 1808, 665, 18145, 30, 2255, 221, 199, 905, 928, 665, 42, 6593, 7166, 298, 17116, 314, 1335, 1054, 665, 42, 6593, 30, 2255, 221, 199, 905, 2379, 665, 42, 6593, 7166, 298, 270, 1483, 314, 1335, 1054, 665, 42, 6593, 10827, 710, 1335, 1054, 365, 4829, 2255, 221, 199, 905, 1205, 665, 42, 6593, 30, 359, 3143, 6087, 726, 11472, 298, 24894, 314, 1453, 2004, 402, 665, 42, 6593, 6244, 543, 2716, 8541, 503, 9243, 2256, 2255, 199, 459, 297, 298, 42, 6593, 15869, 15301, 401, 298, 2255, 199, 905, 409, 665, 42, 6593, 30, 15072, 641, 92, 1997, 401, 298, 2193, 314, 15072, 1174, 402, 665, 42, 6593, 30, 2255, 221, 199, 905, 409, 665, 42, 6593, 30, 1503, 328, 7160, 711, 665, 1772, 7166, 298, 525, 83, 665, 1772, 30, 370, 314, 3686, 769, 402, 665, 42, 6593, 30, 2255, 221, 199, 905, 409, 665, 42, 6593, 30, 9122, 7160, 711, 665, 1772, 7166, 298, 264, 4912, 665, 1772, 30, 687, 314, 3686, 769, 402, 665, 42, 6593, 30, 2255, 221, 199, 905, 409, 665, 42, 6593, 30, 1050, 793, 515, 665, 3817, 30, 788, 1521, 6256, 298, 525, 83, 665, 3817, 30, 370, 314, 20391, 769, 402, 665, 42, 6593, 6244, 14190, 6617, 737, 314, 283, 1521, 7, 402, 314, 570, 334, 885, 283, 2993, 1959, 2255, 221, 199, 905, 409, 665, 42, 6593, 30, 2150, 793, 515, 665, 3817, 7166, 298, 264, 4912, 665, 3817, 30, 687, 314, 20391, 769, 402, 665, 42, 6593, 30, 2255, 199, 905, 409, 665, 42, 6593, 30, 943, 2991, 665, 16314, 7166, 298, 2193, 314, 665, 16314, 30, 402, 314, 943, 1584, 367, 665, 42, 6593, 30, 2255, 199, 905, 409, 665, 42, 6593, 30, 1050, 7067, 1431, 665, 14747, 7166, 298, 525, 83, 665, 14747, 30, 370, 314, 9605, 2457, 402, 665, 42, 6593, 30, 2255, 199, 905, 409, 665, 42, 6593, 30, 2150, 7067, 1431, 665, 14747, 7166, 298, 264, 4912, 665, 14747, 30, 687, 314, 9605, 2457, 402, 665, 42, 6593, 30, 2255, 199, 905, 409, 665, 42, 6593, 30, 1050, 1633, 3821, 665 ]
[ 325, 19309, 26, 1882, 818, 26, 2366, 27, 1134, 13, 3724, 13, 2743, 26, 841, 27, 4363, 13, 8741, 13, 632, 26, 307, 1882, 199, 3, 1321, 26, 663, 18133, 29, 1548, 23014, 29, 20, 6714, 29, 20, 5584, 29, 20, 949, 386, 520, 199, 199, 3, 961, 570, 365, 1777, 402, 12176, 18, 28018, 14, 199, 3, 199, 3, 12176, 18, 28018, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 27, 1902, 1015, 499, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 12176, 18, 28018, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 12176, 18, 28018, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 12, 8217, 14, 199, 199, 3, 6529, 26, 18461, 10363, 1603, 65, 783, 281, 199, 3, 9948, 199, 363, 2502, 363, 275, 298, 9156, 10363, 1603, 65, 783, 281, 2, 199, 363, 7307, 363, 275, 298, 7384, 334, 67, 9, 8353, 18461, 10363, 1603, 65, 783, 281, 2, 199, 363, 1682, 363, 275, 298, 12006, 2, 199, 199, 646, 13390, 199, 199, 309, 199, 3, 28571, 11562, 314, 4113, 1202, 370, 26808, 543, 314, 1654, 14, 199, 199, 3922, 275, 359, 199, 459, 297, 298, 27271, 401, 298, 2255, 199, 905, 928, 401, 298, 17116, 314, 1654, 436, 314, 1335, 1054, 83, 2255, 221, 199, 905, 9233, 401, 298, 264, 3640, 314, 2897, 2255, 221, 199, 905, 9233, 665, 42, 6593, 7166, 298, 264, 3640, 314, 1335, 1054, 665, 42, 6593, 30, 2255, 221, 199, 905, 2379, 401, 298, 270, 1483, 1006, 1335, 1054, 83, 436, 15095, 314, 1654, 2255, 221, 199, 905, 1205, 401, 298, 24894, 314, 1453, 2004, 402, 314, 1654, 2255, 221, 199, 905, 4073, 401, 298, 2219, 340, 314, 1654, 365, 19708, 2255, 221, 199, 905, 3437, 401, 298, 1107, 642, 1072, 2255, 221, 199, 905, 1023, 401, 298, 1107, 314, 1654, 1015, 2255, 199, 459, 297, 298, 27896, 401, 298, 2255, 199, 905, 409, 943, 1896, 665, 11817, 7166, 298, 2193, 2050, 2166, 370, 665, 11817, 10827, 20400, 83, 26, 17101, 19223, 12, 12539, 12, 14750, 12, 12840, 12, 24008, 12, 10990, 2255, 221, 199, 905, 362, 943, 1896, 401, 298, 24894, 314, 2050, 2166, 2255, 221, 199, 905, 409, 943, 1375, 665, 9268, 7166, 298, 2193, 2050, 1347, 370, 665, 9268, 10827, 6855, 506, 4384, 12619, 12, 30118, 2666, 12, 10046, 51, 4947, 503, 282, 570, 2255, 221, 199, 905, 362, 943, 1375, 401, 298, 24894, 2050, 1347, 2255, 221, 199, 905, 4939, 7270, 401, 298, 4939, 397, 314, 943, 1375, 340, 282, 570, 436, 295, 1490, 83, 652, 14, 2104, 943, 13038, 2122, 467, 221, 199, 459, 297, 298, 17873, 401, 298, 2255, 199, 905, 409, 1592, 493, 665, 3817, 7166, 298, 409, 314, 2909, 402, 2449, 18, 13206, 16149, 12007, 14, 2494, 370, 8441, 403, 4451, 370, 3507, 2255, 221, 199, 905, 362, 1592, 493, 401, 298, 362, 314, 2909, 402, 2449, 18, 13206, 16149, 12007, 2255, 221, 199, 905, 409, 1592, 18254, 474, 665, 23319, 7166, 298, 2193, 314, 1390, 11437, 315, 665, 23319, 30, 626, 7994, 402, 330, 796, 911, 506, 16204, 2255, 221, 199, 905, 362, 1592, 18254, 474, 401, 298, 24894, 314, 1390, 11437, 315, 4696, 626, 7994, 402, 330, 796, 911, 506, 16204, 2255, 221, 199, 459, 297, 298, 42, 6593, 8098, 401, 298, 2255, 199, 905, 525, 665, 42, 6593, 30, 665, 18145, 7166, 298, 28219, 665, 42, 6593, 30, 1808, 665, 18145, 30, 2255, 221, 199, 905, 928, 665, 42, 6593, 7166, 298, 17116, 314, 1335, 1054, 665, 42, 6593, 30, 2255, 221, 199, 905, 2379, 665, 42, 6593, 7166, 298, 270, 1483, 314, 1335, 1054, 665, 42, 6593, 10827, 710, 1335, 1054, 365, 4829, 2255, 221, 199, 905, 1205, 665, 42, 6593, 30, 359, 3143, 6087, 726, 11472, 298, 24894, 314, 1453, 2004, 402, 665, 42, 6593, 6244, 543, 2716, 8541, 503, 9243, 2256, 2255, 199, 459, 297, 298, 42, 6593, 15869, 15301, 401, 298, 2255, 199, 905, 409, 665, 42, 6593, 30, 15072, 641, 92, 1997, 401, 298, 2193, 314, 15072, 1174, 402, 665, 42, 6593, 30, 2255, 221, 199, 905, 409, 665, 42, 6593, 30, 1503, 328, 7160, 711, 665, 1772, 7166, 298, 525, 83, 665, 1772, 30, 370, 314, 3686, 769, 402, 665, 42, 6593, 30, 2255, 221, 199, 905, 409, 665, 42, 6593, 30, 9122, 7160, 711, 665, 1772, 7166, 298, 264, 4912, 665, 1772, 30, 687, 314, 3686, 769, 402, 665, 42, 6593, 30, 2255, 221, 199, 905, 409, 665, 42, 6593, 30, 1050, 793, 515, 665, 3817, 30, 788, 1521, 6256, 298, 525, 83, 665, 3817, 30, 370, 314, 20391, 769, 402, 665, 42, 6593, 6244, 14190, 6617, 737, 314, 283, 1521, 7, 402, 314, 570, 334, 885, 283, 2993, 1959, 2255, 221, 199, 905, 409, 665, 42, 6593, 30, 2150, 793, 515, 665, 3817, 7166, 298, 264, 4912, 665, 3817, 30, 687, 314, 20391, 769, 402, 665, 42, 6593, 30, 2255, 199, 905, 409, 665, 42, 6593, 30, 943, 2991, 665, 16314, 7166, 298, 2193, 314, 665, 16314, 30, 402, 314, 943, 1584, 367, 665, 42, 6593, 30, 2255, 199, 905, 409, 665, 42, 6593, 30, 1050, 7067, 1431, 665, 14747, 7166, 298, 525, 83, 665, 14747, 30, 370, 314, 9605, 2457, 402, 665, 42, 6593, 30, 2255, 199, 905, 409, 665, 42, 6593, 30, 2150, 7067, 1431, 665, 14747, 7166, 298, 264, 4912, 665, 14747, 30, 687, 314, 9605, 2457, 402, 665, 42, 6593, 30, 2255, 199, 905, 409, 665, 42, 6593, 30, 1050, 1633, 3821, 665, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
matthiasdiener/spack
var/spack/repos/builtin/packages/r-rsolnp/package.py
5
1685
############################################################################## # Copyright (c) 2013-2018, Lawrence Livermore National Security, LLC. # Produced at the Lawrence Livermore National Laboratory. # # This file is part of Spack. # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. # LLNL-CODE-647188 # # For details, see https://github.com/spack/spack # Please also see the NOTICE and LICENSE files for our notice and the LGPL. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License (as # published by the Free Software Foundation) version 2.1, February 1999. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and # conditions of the GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack import * class RRsolnp(RPackage): """General Non-linear Optimization Using Augmented Lagrange Multiplier Method.""" homepage = "https://cran.r-project.org/package=Rsolnp" url = "https://cran.rstudio.com/src/contrib/Rsolnp_1.16.tar.gz" list_url = "https://cran.rstudio.com/src/contrib/Archive/Rsolnp" version('1.16', '507e1e1a64f5f1d32b7e4e12ed19599f') depends_on('r-truncnorm', type=('build', 'run'))
lgpl-2.1
[ 4605, 199, 3, 1898, 334, 67, 9, 6171, 13, 12682, 12, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 14, 199, 3, 2165, 16584, 737, 314, 7964, 29590, 491, 4380, 6878, 20548, 16871, 31671, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 428, 1389, 14, 199, 3, 18208, 701, 377, 16216, 598, 11020, 472, 12, 22387, 11020, 472, 32, 914, 7530, 14, 16294, 12, 2900, 4481, 4644, 14, 199, 3, 491, 44, 14176, 13, 6012, 13, 8557, 11501, 199, 3, 199, 3, 2104, 2436, 12, 1937, 4178, 921, 5031, 14, 957, 15, 83, 1389, 15, 83, 1389, 199, 3, 7754, 2597, 1937, 314, 12840, 436, 5113, 1584, 367, 4154, 4245, 436, 314, 32426, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 334, 305, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 9, 1015, 499, 14, 17, 12, 21141, 26709, 21300, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 5292, 3408, 1634, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 2895, 436, 199, 3, 3704, 402, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 4605, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 27222, 7873, 1590, 8, 50, 8599, 304, 272, 408, 14109, 10172, 13, 6676, 19246, 2072, 11719, 25298, 2509, 491, 643, 1842, 603, 2092, 5697, 272, 9075, 1041, 339, 26586, 275, 298, 2859, 921, 67, 1312, 14, 82, 13, 1715, 14, 1308, 15, 2491, 29, 50, 7873, 1590, 2, 272, 1166, 420, 275, 298, 2859, 921, 67, 1312, 14, 8332, 5208, 14, 957, 15, 2164, 15, 2828, 15, 50, 7873, 1590, 63, 17, 14, 975, 14, 5369, 14, 6838, 2, 272, 769, 63, 633, 275, 298, 2859, 921, 67, 1312, 14, 8332, 5208, 14, 957, 15, 2164, 15, 2828, 15, 13042, 15, 50, 7873, 1590, 2, 339, 1015, 360, 17, 14, 975, 297, 283, 13583, 69, 17, 69, 17, 65, 772, 70, 21, 70, 17, 68, 708, 66, 23, 69, 20, 69, 713, 379, 11874, 1020, 70, 358, 339, 8350, 63, 265, 360, 82, 13, 8208, 4791, 297, 730, 7782, 1506, 297, 283, 1065, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 3, 1898, 334, 67, 9, 6171, 13, 12682, 12, 7964, 29590, 491, 4380, 6878, 20548, 13863, 12, 20376, 14, 199, 3, 2165, 16584, 737, 314, 7964, 29590, 491, 4380, 6878, 20548, 16871, 31671, 14, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 428, 1389, 14, 199, 3, 18208, 701, 377, 16216, 598, 11020, 472, 12, 22387, 11020, 472, 32, 914, 7530, 14, 16294, 12, 2900, 4481, 4644, 14, 199, 3, 491, 44, 14176, 13, 6012, 13, 8557, 11501, 199, 3, 199, 3, 2104, 2436, 12, 1937, 4178, 921, 5031, 14, 957, 15, 83, 1389, 15, 83, 1389, 199, 3, 7754, 2597, 1937, 314, 12840, 436, 5113, 1584, 367, 4154, 4245, 436, 314, 32426, 14, 199, 3, 199, 3, 961, 2240, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 844, 334, 305, 199, 3, 3267, 701, 314, 2868, 2290, 2752, 9, 1015, 499, 14, 17, 12, 21141, 26709, 21300, 14, 199, 3, 199, 3, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 1325, 199, 3, 2428, 1821, 3408, 27, 1928, 2755, 314, 5292, 3408, 1634, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 1666, 314, 2895, 436, 199, 3, 3704, 402, 314, 1664, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 844, 3180, 543, 642, 2240, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 2752, 12, 3277, 2020, 8155, 15630, 10902, 12, 14453, 13540, 12, 8226, 12, 4828, 15673, 13, 13421, 8217, 199, 4605, 199, 504, 308, 1389, 492, 627, 421, 199, 533, 27222, 7873, 1590, 8, 50, 8599, 304, 272, 408, 14109, 10172, 13, 6676, 19246, 2072, 11719, 25298, 2509, 491, 643, 1842, 603, 2092, 5697, 272, 9075, 1041, 339, 26586, 275, 298, 2859, 921, 67, 1312, 14, 82, 13, 1715, 14, 1308, 15, 2491, 29, 50, 7873, 1590, 2, 272, 1166, 420, 275, 298, 2859, 921, 67, 1312, 14, 8332, 5208, 14, 957, 15, 2164, 15, 2828, 15, 50, 7873, 1590, 63, 17, 14, 975, 14, 5369, 14, 6838, 2, 272, 769, 63, 633, 275, 298, 2859, 921, 67, 1312, 14, 8332, 5208, 14, 957, 15, 2164, 15, 2828, 15, 13042, 15, 50, 7873, 1590, 2, 339, 1015, 360, 17, 14, 975, 297, 283, 13583, 69, 17, 69, 17, 65, 772, 70, 21, 70, 17, 68, 708, 66, 23, 69, 20, 69, 713, 379, 11874, 1020, 70, 358, 339, 8350, 63, 265, 360, 82, 13, 8208, 4791, 297, 730, 7782, 1506, 297, 283, 1065, 1333, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
wrouesnel/ansible
lib/ansible/modules/network/panos/panos_nat_rule.py
6
16293
#!/usr/bin/python # -*- coding: utf-8 -*- # (c) 2016, techbizdev <techbizdev@paloaltonetworks.com> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type DOCUMENTATION = ''' --- module: panos_nat_rule short_description: create a policy NAT rule description: > - Create a policy nat rule. Keep in mind that we can either end up configuring source NAT, destination NAT, or both. Instead of splitting it into two we will make a fair attempt to determine which one the user wants. author: "Luigi Mori (@jtschichold), Ivan Bojer (@ivanbojer), Robert Hagen (@rnh556)" version_added: "2.4" requirements: - pan-python can be obtained from PyPi U(https://pypi.python.org/pypi/pan-python) - pandevice can be obtained from PyPi U(https://pypi.python.org/pypi/pandevice) notes: - Checkmode is not supported. - Panorama is supported. options: ip_address: description: - IP address (or hostname) of PAN-OS device being configured. required: true username: description: - Username credentials to use for auth unless I(api_key) is set. default: "admin" password: description: - Password credentials to use for auth unless I(api_key) is set. required: true api_key: description: - API key that can be used instead of I(username)/I(password) credentials. operation: description: - The action to be taken. Supported values are I(add)/I(update)/I(find)/I(delete). rule_name: description: - name of the SNAT rule required: true source_zone: description: - list of source zones required: true destination_zone: description: - destination zone required: true source_ip: description: - list of source addresses required: false default: ["any"] destination_ip: description: - list of destination addresses required: false default: ["any"] service: description: - service required: false default: "any" snat_type: description: - type of source translation required: false default: None snat_address_type: description: - type of source translation. Supported values are I(translated-address)/I(translated-address). required: false default: 'translated-address' snat_static_address: description: - Source NAT translated address. Used with Static-IP translation. required: false default: None snat_dynamic_address: description: - Source NAT translated address. Used with Dynamic-IP and Dynamic-IP-and-Port. required: false default: None snat_interface: description: - snat interface required: false default: None snat_interface_address: description: - snat interface address required: false default: None snat_bidirectional: description: - bidirectional flag required: false default: "false" dnat_address: description: - dnat translated address required: false default: None dnat_port: description: - dnat translated port required: false default: None commit: description: - Commit configuration if changed. default: true ''' EXAMPLES = ''' # Create a source and destination nat rule - name: Create NAT SSH rule for 10.0.1.101 panos_nat_rule: ip_address: '{{ ip_address }}' username: '{{ username }}' password: '{{ password }}' rule_name: "Web SSH" source_zone: ["external"] destination_zone: "external" source: ["any"] destination: ["10.0.0.100"] service: "service-tcp-221" snat_type: "dynamic-ip-and-port" snat_interface: "ethernet1/2" dnat_address: "10.0.1.101" dnat_port: "22" ''' RETURN = ''' # Default return values ''' ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} # import pydevd # pydevd.settrace('localhost', port=60374, stdoutToServer=True, stderrToServer=True) from ansible.module_utils.basic import AnsibleModule from ansible.module_utils._text import to_native try: import pan.xapi from pan.xapi import PanXapiError import pandevice from pandevice import base from pandevice import firewall from pandevice import panorama from pandevice import objects from pandevice import policies import xmltodict import json HAS_LIB = True except ImportError: HAS_LIB = False def get_devicegroup(device, devicegroup): dg_list = device.refresh_devices() for group in dg_list: if isinstance(group, pandevice.panorama.DeviceGroup): if group.name == devicegroup: return group return False def get_rulebase(device, devicegroup): # Build the rulebase if isinstance(device, pandevice.firewall.Firewall): rulebase = pandevice.policies.Rulebase() device.add(rulebase) elif isinstance(device, pandevice.panorama.Panorama): dg = panorama.DeviceGroup(devicegroup) device.add(dg) rulebase = policies.PreRulebase() dg.add(rulebase) else: return False policies.NatRule.refreshall(rulebase) return rulebase def find_rule(rulebase, rule_name): # Search for the rule name rule = rulebase.find(rule_name) if rule: return rule else: return False def create_nat_rule(**kwargs): nat_rule = policies.NatRule( name=kwargs['rule_name'], description=kwargs['description'], fromzone=kwargs['source_zone'], source=kwargs['source_ip'], tozone=kwargs['destination_zone'], destination=kwargs['destination_ip'], service=kwargs['service'], to_interface=kwargs['to_interface'], nat_type=kwargs['nat_type'] ) # Source translation: Static IP if kwargs['snat_type'] in ['static-ip'] and kwargs['snat_static_address']: nat_rule.source_translation_type = kwargs['snat_type'] nat_rule.source_translation_static_translated_address = kwargs['snat_static_address'] # Bi-directional flag set? if kwargs['snat_bidirectional']: nat_rule.source_translation_static_bi_directional = kwargs['snat_bidirectional'] # Source translation: Dynamic IP and port elif kwargs['snat_type'] in ['dynamic-ip-and-port']: nat_rule.source_translation_type = kwargs['snat_type'] nat_rule.source_translation_address_type = kwargs['snat_address_type'] # Interface address? if kwargs['snat_interface']: nat_rule.source_translation_interface = kwargs['snat_interface'] # Interface IP? if kwargs['snat_interface_address']: nat_rule.source_translation_ip_address = kwargs['snat_interface_address'] else: nat_rule.source_translation_translated_addresses = kwargs['snat_dynamic_address'] # Source translation: Dynamic IP elif kwargs['snat_type'] in ['dynamic-ip']: if kwargs['snat_dynamic_address']: nat_rule.source_translation_type = kwargs['snat_type'] nat_rule.source_translation_translated_addresses = kwargs['snat_dynamic_address'] else: return False # Destination translation if kwargs['dnat_address']: nat_rule.destination_translated_address = kwargs['dnat_address'] if kwargs['dnat_port']: nat_rule.destination_translated_port = kwargs['dnat_port'] # Any tags? if 'tag_name' in kwargs: nat_rule.tag = kwargs['tag_name'] return nat_rule def add_rule(rulebase, nat_rule): if rulebase: rulebase.add(nat_rule) nat_rule.create() return True else: return False def update_rule(rulebase, nat_rule): if rulebase: rulebase.add(nat_rule) nat_rule.apply() return True else: return False def main(): argument_spec = dict( ip_address=dict(required=True), username=dict(default='admin'), password=dict(required=True, no_log=True), api_key=dict(no_log=True), operation=dict(required=True, choices=['add', 'update', 'delete', 'find']), rule_name=dict(required=True), description=dict(), tag_name=dict(), source_zone=dict(type='list'), source_ip=dict(type='list', default=['any']), destination_zone=dict(), destination_ip=dict(type='list', default=['any']), service=dict(default='any'), to_interface=dict(default='any'), snat_type=dict(choices=['static-ip', 'dynamic-ip-and-port', 'dynamic-ip']), snat_address_type=dict(choices=['interface-address', 'translated-address'], default='interface-address'), snat_static_address=dict(), snat_dynamic_address=dict(type='list'), snat_interface=dict(), snat_interface_address=dict(), snat_bidirectional=dict(type='bool', default=False), dnat_address=dict(), dnat_port=dict(), devicegroup=dict(), commit=dict(type='bool', default=True) ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False, required_one_of=[['api_key', 'password']]) if not HAS_LIB: module.fail_json(msg='Missing required libraries.') ip_address = module.params["ip_address"] password = module.params["password"] username = module.params['username'] api_key = module.params['api_key'] operation = module.params['operation'] rule_name = module.params['rule_name'] description = module.params['description'] tag_name = module.params['tag_name'] source_zone = module.params['source_zone'] source_ip = module.params['source_ip'] destination_zone = module.params['destination_zone'] destination_ip = module.params['destination_ip'] service = module.params['service'] to_interface = module.params['to_interface'] nat_type = 'ipv4' snat_type = module.params['snat_type'] snat_address_type = module.params['snat_address_type'] snat_static_address = module.params['snat_static_address'] snat_dynamic_address = module.params['snat_dynamic_address'] snat_interface = module.params['snat_interface'] snat_interface_address = module.params['snat_interface_address'] snat_bidirectional = module.params['snat_bidirectional'] dnat_address = module.params['dnat_address'] dnat_port = module.params['dnat_port'] devicegroup = module.params['devicegroup'] commit = module.params['commit'] # Create the device with the appropriate pandevice type device = base.PanDevice.create_from_device(ip_address, username, password, api_key=api_key) # If Panorama, validate the devicegroup dev_group = None if devicegroup and isinstance(device, panorama.Panorama): dev_group = get_devicegroup(device, devicegroup) if dev_group: device.add(dev_group) else: module.fail_json(msg='\'%s\' device group not found in Panorama. Is the name correct?' % devicegroup) # Get the rulebase rulebase = get_rulebase(device, dev_group) # Which action shall we take on the object? if operation == "find": # Search for the rule match = find_rule(rulebase, rule_name) # If found, format and return the result if match: match_dict = xmltodict.parse(match.element_str()) module.exit_json( stdout_lines=json.dumps(match_dict, indent=2), msg='Rule matched' ) else: module.fail_json(msg='Rule \'%s\' not found. Is the name correct?' % rule_name) elif operation == "delete": # Search for the object match = find_rule(rulebase, rule_name) # If found, delete it if match: try: match.delete() if commit: device.commit(sync=True) except PanXapiError as exc: module.fail_json(msg=to_native(exc)) module.exit_json(changed=True, msg='Rule \'%s\' successfully deleted.' % rule_name) else: module.fail_json(msg='Rule \'%s\' not found. Is the name correct?' % rule_name) elif operation == "add": # Look for required parameters if source_zone and destination_zone and nat_type: pass else: module.fail_json(msg='Missing parameter. Required: source_zone, destination_zone, nat_type') # Search for the rule. Fail if found. match = find_rule(rulebase, rule_name) if match: module.fail_json(msg='Rule \'%s\' already exists. Use operation: \'update\' to change it.' % rule_name) else: try: new_rule = create_nat_rule( rule_name=rule_name, description=description, tag_name=tag_name, source_zone=source_zone, destination_zone=destination_zone, source_ip=source_ip, destination_ip=destination_ip, service=service, to_interface=to_interface, nat_type=nat_type, snat_type=snat_type, snat_address_type=snat_address_type, snat_static_address=snat_static_address, snat_dynamic_address=snat_dynamic_address, snat_interface=snat_interface, snat_interface_address=snat_interface_address, snat_bidirectional=snat_bidirectional, dnat_address=dnat_address, dnat_port=dnat_port ) changed = add_rule(rulebase, new_rule) if changed and commit: device.commit(sync=True) except PanXapiError as exc: module.fail_json(msg=to_native(exc)) module.exit_json(changed=changed, msg='Rule \'%s\' successfully added.' % rule_name) elif operation == 'update': # Search for the rule. Update if found. match = find_rule(rulebase, rule_name) if match: try: new_rule = create_nat_rule( rule_name=rule_name, description=description, tag_name=tag_name, source_zone=source_zone, destination_zone=destination_zone, source_ip=source_ip, destination_ip=destination_ip, service=service, to_interface=to_interface, nat_type=nat_type, snat_type=snat_type, snat_address_type=snat_address_type, snat_static_address=snat_static_address, snat_dynamic_address=snat_dynamic_address, snat_interface=snat_interface, snat_interface_address=snat_interface_address, snat_bidirectional=snat_bidirectional, dnat_address=dnat_address, dnat_port=dnat_port ) changed = update_rule(rulebase, new_rule) if changed and commit: device.commit(sync=True) except PanXapiError as exc: module.fail_json(msg=to_native(exc)) module.exit_json(changed=changed, msg='Rule \'%s\' successfully updated.' % rule_name) else: module.fail_json(msg='Rule \'%s\' does not exist. Use operation: \'add\' to add it.' % rule_name) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 7800, 12, 28222, 66, 565, 2374, 665, 15970, 66, 565, 2374, 32, 80, 12201, 4478, 25759, 12243, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 21379, 736, 63, 9468, 63, 2200, 199, 3612, 63, 1802, 26, 1218, 282, 4592, 31363, 2332, 199, 1802, 26, 690, 272, 446, 2790, 282, 4592, 13872, 2332, 14, 14797, 315, 25169, 626, 781, 883, 1902, 1284, 1536, 1101, 4039, 1350, 31363, 12, 5724, 31363, 12, 503, 272, 3865, 14, 15345, 402, 26518, 652, 1901, 2877, 781, 911, 1852, 282, 28092, 7427, 370, 6705, 1314, 1373, 314, 922, 15061, 14, 199, 2502, 26, 298, 18176, 13721, 603, 16039, 8593, 74, 1086, 335, 1158, 1753, 395, 473, 20662, 5088, 74, 281, 8593, 1003, 290, 656, 74, 281, 395, 6848, 12504, 869, 24758, 8593, 11641, 72, 18683, 2924, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 7538, 26, 272, 446, 21379, 13, 1548, 883, 506, 15884, 687, 1611, 10542, 738, 8, 2859, 921, 17343, 14, 1548, 14, 1308, 15, 17343, 15, 10384, 13, 1548, 9, 272, 446, 21379, 1782, 883, 506, 15884, 687, 1611, 10542, 738, 8, 2859, 921, 17343, 14, 1548, 14, 1308, 15, 17343, 15, 10384, 1782, 9, 199, 5983, 26, 272, 446, 2670, 632, 365, 440, 3748, 14, 272, 446, 510, 290, 11131, 391, 365, 3748, 14, 199, 1419, 26, 272, 3384, 63, 1562, 26, 267, 1369, 26, 288, 446, 3531, 2287, 334, 269, 6246, 9, 402, 510, 879, 13, 3100, 2243, 3769, 7526, 14, 267, 1415, 26, 2549, 272, 3434, 26, 267, 1369, 26, 288, 446, 29739, 6235, 370, 675, 367, 1790, 7444, 473, 8, 1246, 63, 498, 9, 365, 663, 14, 267, 849, 26, 298, 2113, 2, 272, 2505, 26, 267, 1369, 26, 288, 446, 13635, 6235, 370, 675, 367, 1790, 7444, 473, 8, 1246, 63, 498, 9, 365, 663, 14, 267, 1415, 26, 2549, 272, 2986, 63, 498, 26, 267, 1369, 26, 288, 446, 3261, 790, 626, 883, 506, 1202, 3140, 402, 473, 8, 2473, 2447, 41, 8, 2060, 9, 6235, 14, 272, 3439, 26, 267, 1369, 26, 288, 446, 710, 1595, 370, 506, 9394, 14, 221, 26167, 1338, 787, 473, 8, 525, 2447, 41, 8, 873, 2447, 41, 8, 1623, 2447, 41, 8, 1807, 680, 272, 2332, 63, 354, 26, 267, 1369, 26, 288, 446, 536, 402, 314, 428, 28927, 2332, 267, 1415, 26, 2549, 272, 1350, 63, 2619, 26, 267, 1369, 26, 288, 446, 769, 402, 1350, 18666, 267, 1415, 26, 2549, 272, 5724, 63, 2619, 26, 267, 1369, 26, 288, 446, 5724, 5718, 267, 1415, 26, 2549, 272, 1350, 63, 711, 26, 267, 1369, 26, 288, 446, 769, 402, 1350, 7149, 267, 1415, 26, 3055, 267, 849, 26, 2097, 1629, 937, 272, 5724, 63, 711, 26, 267, 1369, 26, 288, 446, 769, 402, 5724, 7149, 267, 1415, 26, 3055, 267, 849, 26, 2097, 1629, 937, 272, 2435, 26, 267, 1369, 26, 288, 446, 2435, 267, 1415, 26, 3055, 267, 849, 26, 298, 1629, 2, 272, 6895, 292, 63, 466, 26, 267, 1369, 26, 288, 446, 730, 402, 1350, 7761, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 6895, 292, 63, 1562, 63, 466, 26, 267, 1369, 26, 288, 446, 730, 402, 1350, 7761, 14, 26167, 1338, 787, 473, 8, 18065, 13, 1562, 2447, 41, 8, 18065, 13, 1562, 680, 267, 1415, 26, 3055, 267, 849, 26, 283, 18065, 13, 1562, 7, 272, 6895, 292, 63, 1986, 63, 1562, 26, 267, 1369, 26, 288, 446, 5800, 31363, 14598, 2287, 14, 8051, 543, 13599, 13, 1772, 7761, 14, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 6895, 292, 63, 7764, 63, 1562, 26, 267, 1369, 26, 288, 446, 5800, 31363, 14598, 2287, 14, 8051, 543, 21907, 13, 1772, 436, 21907, 13, 1772, 13, 460, 13, 4313, 14, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 6895, 292, 63, 3266, 26, 267, 1369, 26, 288, 446, 6895, 292, 3217, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 6895, 292, 63, 3266, 63, 1562, 26, 267, 1369, 26, 288, 446, 6895, 292, 3217, 2287, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 6895, 292, 63, 4492, 21360, 26, 267, 1369, 26, 288, 446, 12111, 21360, 3305, 267, 1415, 26, 3055, 267, 849, 26, 298, 3910, 2, 272, 366, 9468, 63, 1562, 26, 267, 1369, 26, 288, 446, 366, 9468, 14598, 2287, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 366, 9468, 63, 719, 26, 267, 1369, 26, 288, 446, 366, 9468, 14598, 1844, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 5532, 26, 267, 1369, 26, 288, 446, 21447, 2897, 340, 2896, 14, 267, 849, 26, 2549, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2790, 282, 1350, 436, 5724, 13872, 2332, 523, 446, 536, 26, 2790, 31363, 12027, 2332, 367, 1616, 14, 16, 14, 17, 14, 4893, 272, 21379, 736, 63, 9468, 63, 2200, 26, 489, 3384, 63, 1562, 26, 11400, 3384, 63, 1562, 16339, 489, 3434, 26, 11400, 3434, 16339, 489, 2505, 26, 11400, 2505, 16339, 489, 2332, 63, 354, 26, 298, 5926, 12027, 2, 489, 1350, 63, 2619, 26, 2097, 5159, 937, 489, 5724, 63, 2619, 26, 298, 5159, 2, 489, 1350, 26, 2097, 1629, 937, 489, 5724, 26, 2097, 709, 14, 16, 14, 16, 14, 1960, 937, 489, 2435, 26, 298, 1364, 13, 8815, 13, 11564, 2, 489, 6895, 292, 63, 466, 26, 298, 7764, 13, 711, 13, 460, 13, 719, 2, 489, 6895, 292, 63, 3266, 26, 298, 20354, 17, 15, 18, 2, 489, 366, 9468, 63, 1562, 26, 298, 709, 14, 16, 14, 17, 14, 4893, 2, 489, 366, 9468, 63, 719, 26, 298, 1081, 2, 199, 2344, 199, 199, 9677, 275, 1449, 199, 3, 3758, 372, 1338, 199, 2344 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 334, 67, 9, 7800, 12, 28222, 66, 565, 2374, 665, 15970, 66, 565, 2374, 32, 80, 12201, 4478, 25759, 12243, 14, 957, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 21379, 736, 63, 9468, 63, 2200, 199, 3612, 63, 1802, 26, 1218, 282, 4592, 31363, 2332, 199, 1802, 26, 690, 272, 446, 2790, 282, 4592, 13872, 2332, 14, 14797, 315, 25169, 626, 781, 883, 1902, 1284, 1536, 1101, 4039, 1350, 31363, 12, 5724, 31363, 12, 503, 272, 3865, 14, 15345, 402, 26518, 652, 1901, 2877, 781, 911, 1852, 282, 28092, 7427, 370, 6705, 1314, 1373, 314, 922, 15061, 14, 199, 2502, 26, 298, 18176, 13721, 603, 16039, 8593, 74, 1086, 335, 1158, 1753, 395, 473, 20662, 5088, 74, 281, 8593, 1003, 290, 656, 74, 281, 395, 6848, 12504, 869, 24758, 8593, 11641, 72, 18683, 2924, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 7538, 26, 272, 446, 21379, 13, 1548, 883, 506, 15884, 687, 1611, 10542, 738, 8, 2859, 921, 17343, 14, 1548, 14, 1308, 15, 17343, 15, 10384, 13, 1548, 9, 272, 446, 21379, 1782, 883, 506, 15884, 687, 1611, 10542, 738, 8, 2859, 921, 17343, 14, 1548, 14, 1308, 15, 17343, 15, 10384, 1782, 9, 199, 5983, 26, 272, 446, 2670, 632, 365, 440, 3748, 14, 272, 446, 510, 290, 11131, 391, 365, 3748, 14, 199, 1419, 26, 272, 3384, 63, 1562, 26, 267, 1369, 26, 288, 446, 3531, 2287, 334, 269, 6246, 9, 402, 510, 879, 13, 3100, 2243, 3769, 7526, 14, 267, 1415, 26, 2549, 272, 3434, 26, 267, 1369, 26, 288, 446, 29739, 6235, 370, 675, 367, 1790, 7444, 473, 8, 1246, 63, 498, 9, 365, 663, 14, 267, 849, 26, 298, 2113, 2, 272, 2505, 26, 267, 1369, 26, 288, 446, 13635, 6235, 370, 675, 367, 1790, 7444, 473, 8, 1246, 63, 498, 9, 365, 663, 14, 267, 1415, 26, 2549, 272, 2986, 63, 498, 26, 267, 1369, 26, 288, 446, 3261, 790, 626, 883, 506, 1202, 3140, 402, 473, 8, 2473, 2447, 41, 8, 2060, 9, 6235, 14, 272, 3439, 26, 267, 1369, 26, 288, 446, 710, 1595, 370, 506, 9394, 14, 221, 26167, 1338, 787, 473, 8, 525, 2447, 41, 8, 873, 2447, 41, 8, 1623, 2447, 41, 8, 1807, 680, 272, 2332, 63, 354, 26, 267, 1369, 26, 288, 446, 536, 402, 314, 428, 28927, 2332, 267, 1415, 26, 2549, 272, 1350, 63, 2619, 26, 267, 1369, 26, 288, 446, 769, 402, 1350, 18666, 267, 1415, 26, 2549, 272, 5724, 63, 2619, 26, 267, 1369, 26, 288, 446, 5724, 5718, 267, 1415, 26, 2549, 272, 1350, 63, 711, 26, 267, 1369, 26, 288, 446, 769, 402, 1350, 7149, 267, 1415, 26, 3055, 267, 849, 26, 2097, 1629, 937, 272, 5724, 63, 711, 26, 267, 1369, 26, 288, 446, 769, 402, 5724, 7149, 267, 1415, 26, 3055, 267, 849, 26, 2097, 1629, 937, 272, 2435, 26, 267, 1369, 26, 288, 446, 2435, 267, 1415, 26, 3055, 267, 849, 26, 298, 1629, 2, 272, 6895, 292, 63, 466, 26, 267, 1369, 26, 288, 446, 730, 402, 1350, 7761, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 6895, 292, 63, 1562, 63, 466, 26, 267, 1369, 26, 288, 446, 730, 402, 1350, 7761, 14, 26167, 1338, 787, 473, 8, 18065, 13, 1562, 2447, 41, 8, 18065, 13, 1562, 680, 267, 1415, 26, 3055, 267, 849, 26, 283, 18065, 13, 1562, 7, 272, 6895, 292, 63, 1986, 63, 1562, 26, 267, 1369, 26, 288, 446, 5800, 31363, 14598, 2287, 14, 8051, 543, 13599, 13, 1772, 7761, 14, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 6895, 292, 63, 7764, 63, 1562, 26, 267, 1369, 26, 288, 446, 5800, 31363, 14598, 2287, 14, 8051, 543, 21907, 13, 1772, 436, 21907, 13, 1772, 13, 460, 13, 4313, 14, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 6895, 292, 63, 3266, 26, 267, 1369, 26, 288, 446, 6895, 292, 3217, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 6895, 292, 63, 3266, 63, 1562, 26, 267, 1369, 26, 288, 446, 6895, 292, 3217, 2287, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 6895, 292, 63, 4492, 21360, 26, 267, 1369, 26, 288, 446, 12111, 21360, 3305, 267, 1415, 26, 3055, 267, 849, 26, 298, 3910, 2, 272, 366, 9468, 63, 1562, 26, 267, 1369, 26, 288, 446, 366, 9468, 14598, 2287, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 366, 9468, 63, 719, 26, 267, 1369, 26, 288, 446, 366, 9468, 14598, 1844, 267, 1415, 26, 3055, 267, 849, 26, 488, 272, 5532, 26, 267, 1369, 26, 288, 446, 21447, 2897, 340, 2896, 14, 267, 849, 26, 2549, 199, 2344, 199, 199, 8918, 275, 1449, 199, 3, 2790, 282, 1350, 436, 5724, 13872, 2332, 523, 446, 536, 26, 2790, 31363, 12027, 2332, 367, 1616, 14, 16, 14, 17, 14, 4893, 272, 21379, 736, 63, 9468, 63, 2200, 26, 489, 3384, 63, 1562, 26, 11400, 3384, 63, 1562, 16339, 489, 3434, 26, 11400, 3434, 16339, 489, 2505, 26, 11400, 2505, 16339, 489, 2332, 63, 354, 26, 298, 5926, 12027, 2, 489, 1350, 63, 2619, 26, 2097, 5159, 937, 489, 5724, 63, 2619, 26, 298, 5159, 2, 489, 1350, 26, 2097, 1629, 937, 489, 5724, 26, 2097, 709, 14, 16, 14, 16, 14, 1960, 937, 489, 2435, 26, 298, 1364, 13, 8815, 13, 11564, 2, 489, 6895, 292, 63, 466, 26, 298, 7764, 13, 711, 13, 460, 13, 719, 2, 489, 6895, 292, 63, 3266, 26, 298, 20354, 17, 15, 18, 2, 489, 366, 9468, 63, 1562, 26, 298, 709, 14, 16, 14, 17, 14, 4893, 2, 489, 366, 9468, 63, 719, 26, 298, 1081, 2, 199, 2344, 199, 199, 9677, 275, 1449, 199, 3, 3758, 372, 1338, 199, 2344, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
cryptobanana/ansible
lib/ansible/modules/cloud/google/gcp_healthcheck.py
49
15554
#!/usr/bin/python # Copyright 2017 Google Inc. # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: gcp_healthcheck version_added: "2.4" short_description: Create, Update or Destroy a Healthcheck. description: - Create, Update or Destroy a Healthcheck. Currently only HTTP and HTTPS Healthchecks are supported. Healthchecks are used to monitor individual instances, managed instance groups and/or backend services. Healtchecks are reusable. - Visit U(https://cloud.google.com/compute/docs/load-balancing/health-checks) for an overview of Healthchecks on GCP. - See U(https://cloud.google.com/compute/docs/reference/latest/httpHealthChecks) for API details on HTTP Healthchecks. - See U(https://cloud.google.com/compute/docs/reference/latest/httpsHealthChecks) for more details on the HTTPS Healtcheck API. requirements: - "python >= 2.6" - "google-api-python-client >= 1.6.2" - "google-auth >= 0.9.0" - "google-auth-httplib2 >= 0.0.2" notes: - Only supports HTTP and HTTPS Healthchecks currently. author: - "Tom Melendez (@supertom) <tom@supertom.com>" options: check_interval: description: - How often (in seconds) to send a health check. required: false default: 5 healthcheck_name: description: - Name of the Healthcheck. required: true healthcheck_type: description: - Type of Healthcheck. required: true choices: ["HTTP", "HTTPS"] host_header: description: - The value of the host header in the health check request. If left empty, the public IP on behalf of which this health check is performed will be used. required: true default: "" port: description: - The TCP port number for the health check request. The default value is 443 for HTTPS and 80 for HTTP. required: false request_path: description: - The request path of the HTTPS health check request. required: false default: "/" state: description: State of the Healthcheck. required: true choices: ["present", "absent"] timeout: description: - How long (in seconds) to wait for a response before claiming failure. It is invalid for timeout to have a greater value than check_interval. required: false default: 5 unhealthy_threshold: description: - A so-far healthy instance will be marked unhealthy after this many consecutive failures. required: false default: 2 healthy_threshold: description: - A so-far unhealthy instance will be marked healthy after this many consecutive successes. required: false default: 2 service_account_email: description: - service account email required: false default: null service_account_permissions: version_added: "2.0" description: - service account permissions (see U(https://cloud.google.com/sdk/gcloud/reference/compute/instances/create), --scopes section for detailed information) required: false default: null choices: [ "bigquery", "cloud-platform", "compute-ro", "compute-rw", "useraccounts-ro", "useraccounts-rw", "datastore", "logging-write", "monitoring", "sql-admin", "storage-full", "storage-ro", "storage-rw", "taskqueue", "userinfo-email" ] credentials_file: description: - Path to the JSON file associated with the service account email default: null required: false project_id: description: - Your GCP project ID required: false default: null ''' EXAMPLES = ''' - name: Create Minimum HealthCheck gcp_healthcheck: service_account_email: "{{ service_account_email }}" credentials_file: "{{ credentials_file }}" project_id: "{{ project_id }}" healthcheck_name: my-healthcheck healthcheck_type: HTTP state: present - name: Create HTTP HealthCheck gcp_healthcheck: service_account_email: "{{ service_account_email }}" credentials_file: "{{ credentials_file }}" project_id: "{{ project_id }}" healthcheck_name: my-healthcheck healthcheck_type: HTTP host: my-host request_path: /hc check_interval: 10 timeout: 30 unhealthy_threshhold: 2 healthy_threshhold: 1 state: present - name: Create HTTPS HealthCheck gcp_healthcheck: service_account_email: "{{ service_account_email }}" credentials_file: "{{ credentials_file }}" project_id: "{{ project_id }}" healthcheck_name: "{{ https_healthcheck }}" healthcheck_type: HTTPS host_header: my-host request_path: /hc check_interval: 5 timeout: 5 unhealthy_threshold: 2 healthy_threshold: 1 state: present ''' RETURN = ''' state: description: state of the Healthcheck returned: Always. type: str sample: present healthcheck_name: description: Name of the Healthcheck returned: Always type: str sample: my-url-map healthcheck_type: description: Type of the Healthcheck returned: Always type: str sample: HTTP healthcheck: description: GCP Healthcheck dictionary returned: Always. Refer to GCP documentation for detailed field descriptions. type: dict sample: { "name": "my-hc", "port": 443, "requestPath": "/foo" } ''' from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.gcp import get_google_api_client, GCPUtils USER_AGENT_PRODUCT = 'ansible-healthcheck' USER_AGENT_VERSION = '0.0.1' def _validate_healthcheck_params(params): """ Validate healthcheck params. Simple validation has already assumed by AnsibleModule. :param params: Ansible dictionary containing configuration. :type params: ``dict`` :return: True or raises ValueError :rtype: ``bool`` or `class:ValueError` """ if params['timeout'] > params['check_interval']: raise ValueError("timeout (%s) is greater than check_interval (%s)" % ( params['timeout'], params['check_interval'])) return (True, '') def _build_healthcheck_dict(params): """ Reformat services in Ansible Params for GCP. :param params: Params from AnsibleModule object :type params: ``dict`` :param project_id: The GCP project ID. :type project_id: ``str`` :return: dictionary suitable for submission to GCP HealthCheck (HTTP/HTTPS) API. :rtype ``dict`` """ gcp_dict = GCPUtils.params_to_gcp_dict(params, 'healthcheck_name') if 'timeout' in gcp_dict: gcp_dict['timeoutSec'] = gcp_dict['timeout'] del gcp_dict['timeout'] if 'checkInterval' in gcp_dict: gcp_dict['checkIntervalSec'] = gcp_dict['checkInterval'] del gcp_dict['checkInterval'] if 'hostHeader' in gcp_dict: gcp_dict['host'] = gcp_dict['hostHeader'] del gcp_dict['hostHeader'] if 'healthcheckType' in gcp_dict: del gcp_dict['healthcheckType'] return gcp_dict def _get_req_resource(client, resource_type): if resource_type == 'HTTPS': return (client.httpsHealthChecks(), 'httpsHealthCheck') else: return (client.httpHealthChecks(), 'httpHealthCheck') def get_healthcheck(client, name, project_id=None, resource_type='HTTP'): """ Get a Healthcheck from GCP. :param client: An initialized GCE Compute Disovery resource. :type client: :class: `googleapiclient.discovery.Resource` :param name: Name of the Url Map. :type name: ``str`` :param project_id: The GCP project ID. :type project_id: ``str`` :return: A dict resp from the respective GCP 'get' request. :rtype: ``dict`` """ try: resource, entity_name = _get_req_resource(client, resource_type) args = {'project': project_id, entity_name: name} req = resource.get(**args) return GCPUtils.execute_api_client_req(req, raise_404=False) except: raise def create_healthcheck(client, params, project_id, resource_type='HTTP'): """ Create a new Healthcheck. :param client: An initialized GCE Compute Disovery resource. :type client: :class: `googleapiclient.discovery.Resource` :param params: Dictionary of arguments from AnsibleModule. :type params: ``dict`` :return: Tuple with changed status and response dict :rtype: ``tuple`` in the format of (bool, dict) """ gcp_dict = _build_healthcheck_dict(params) try: resource, _ = _get_req_resource(client, resource_type) args = {'project': project_id, 'body': gcp_dict} req = resource.insert(**args) return_data = GCPUtils.execute_api_client_req(req, client, raw=False) if not return_data: return_data = get_healthcheck(client, name=params['healthcheck_name'], project_id=project_id) return (True, return_data) except: raise def delete_healthcheck(client, name, project_id, resource_type='HTTP'): """ Delete a Healthcheck. :param client: An initialized GCE Compute Disover resource. :type client: :class: `googleapiclient.discovery.Resource` :param name: Name of the Url Map. :type name: ``str`` :param project_id: The GCP project ID. :type project_id: ``str`` :return: Tuple with changed status and response dict :rtype: ``tuple`` in the format of (bool, dict) """ try: resource, entity_name = _get_req_resource(client, resource_type) args = {'project': project_id, entity_name: name} req = resource.delete(**args) return_data = GCPUtils.execute_api_client_req(req, client) return (True, return_data) except: raise def update_healthcheck(client, healthcheck, params, name, project_id, resource_type='HTTP'): """ Update a Healthcheck. If the healthcheck has not changed, the update will not occur. :param client: An initialized GCE Compute Disovery resource. :type client: :class: `googleapiclient.discovery.Resource` :param healthcheck: Name of the Url Map. :type healthcheck: ``dict`` :param params: Dictionary of arguments from AnsibleModule. :type params: ``dict`` :param name: Name of the Url Map. :type name: ``str`` :param project_id: The GCP project ID. :type project_id: ``str`` :return: Tuple with changed status and response dict :rtype: ``tuple`` in the format of (bool, dict) """ gcp_dict = _build_healthcheck_dict(params) ans = GCPUtils.are_params_equal(healthcheck, gcp_dict) if ans: return (False, 'no update necessary') try: resource, entity_name = _get_req_resource(client, resource_type) args = {'project': project_id, entity_name: name, 'body': gcp_dict} req = resource.update(**args) return_data = GCPUtils.execute_api_client_req( req, client=client, raw=False) return (True, return_data) except: raise def main(): module = AnsibleModule(argument_spec=dict( healthcheck_name=dict(required=True), healthcheck_type=dict(required=True, choices=['HTTP', 'HTTPS']), request_path=dict(required=False, default='/'), check_interval=dict(required=False, type='int', default=5), healthy_threshold=dict(required=False, type='int', default=2), unhealthy_threshold=dict(required=False, type='int', default=2), host_header=dict(required=False, type='str', default=''), timeout=dict(required=False, type='int', default=5), port=dict(required=False, type='int'), state=dict(choices=['absent', 'present'], default='present'), service_account_email=dict(), service_account_permissions=dict(type='list'), credentials_file=dict(), project_id=dict(), ), ) client, conn_params = get_google_api_client(module, 'compute', user_agent_product=USER_AGENT_PRODUCT, user_agent_version=USER_AGENT_VERSION) params = {} params['healthcheck_name'] = module.params.get('healthcheck_name') params['healthcheck_type'] = module.params.get('healthcheck_type') params['request_path'] = module.params.get('request_path') params['check_interval'] = module.params.get('check_interval') params['healthy_threshold'] = module.params.get('healthy_threshold') params['unhealthy_threshold'] = module.params.get('unhealthy_threshold') params['host_header'] = module.params.get('host_header') params['timeout'] = module.params.get('timeout') params['port'] = module.params.get('port', None) params['state'] = module.params.get('state') if not params['port']: params['port'] = 80 if params['healthcheck_type'] == 'HTTPS': params['port'] = 443 try: _validate_healthcheck_params(params) except Exception as e: module.fail_json(msg=e.message, changed=False) changed = False json_output = {'state': params['state']} healthcheck = get_healthcheck(client, name=params['healthcheck_name'], project_id=conn_params['project_id'], resource_type=params['healthcheck_type']) if not healthcheck: if params['state'] == 'absent': # Doesn't exist in GCE, and state==absent. changed = False module.fail_json( msg="Cannot delete unknown healthcheck: %s" % (params['healthcheck_name'])) else: # Create changed, json_output['healthcheck'] = create_healthcheck(client, params=params, project_id=conn_params['project_id'], resource_type=params['healthcheck_type']) elif params['state'] == 'absent': # Delete changed, json_output['healthcheck'] = delete_healthcheck(client, name=params['healthcheck_name'], project_id=conn_params['project_id'], resource_type=params['healthcheck_type']) else: changed, json_output['healthcheck'] = update_healthcheck(client, healthcheck=healthcheck, params=params, name=params['healthcheck_name'], project_id=conn_params['project_id'], resource_type=params['healthcheck_type']) json_output['changed'] = changed json_output.update(params) module.exit_json(**json_output) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 9708, 4475, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 22088, 63, 27941, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 3612, 63, 1802, 26, 2790, 12, 6162, 503, 20547, 4813, 282, 5311, 6130, 1074, 14, 199, 1802, 26, 272, 446, 2790, 12, 6162, 503, 20547, 4813, 282, 5311, 6130, 1074, 14, 13550, 1454, 3101, 436, 489, 14147, 5311, 6130, 8625, 787, 3748, 14, 5311, 6130, 8625, 787, 1202, 370, 8372, 489, 8212, 4454, 12, 12883, 1256, 4652, 436, 15, 269, 4865, 489, 8500, 14, 5311, 4478, 8625, 787, 295, 14418, 14, 272, 446, 29614, 489, 738, 8, 2859, 921, 4091, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 912, 13, 30260, 15, 9665, 13, 8625, 9, 489, 367, 376, 23503, 402, 5311, 6130, 8625, 641, 30902, 14, 272, 446, 1666, 489, 738, 8, 2859, 921, 4091, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 4443, 15, 7410, 15, 1014, 18850, 11834, 9, 367, 489, 3261, 2436, 641, 3101, 5311, 6130, 8625, 14, 272, 446, 1666, 489, 738, 8, 2859, 921, 4091, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 4443, 15, 7410, 15, 2859, 18850, 11834, 9, 489, 367, 1655, 2436, 641, 314, 14147, 5311, 4478, 1074, 3261, 14, 199, 7538, 26, 523, 446, 298, 1548, 2356, 499, 14, 22, 2, 523, 446, 298, 3098, 13, 1246, 13, 1548, 13, 1258, 2356, 413, 14, 22, 14, 18, 2, 523, 446, 298, 3098, 13, 1178, 2356, 378, 14, 25, 14, 16, 2, 523, 446, 298, 3098, 13, 1178, 13, 12942, 18, 2356, 378, 14, 16, 14, 18, 2, 199, 5983, 26, 523, 446, 5972, 5171, 3101, 436, 14147, 5311, 6130, 8625, 5544, 14, 199, 2502, 26, 523, 446, 298, 52, 676, 3194, 552, 271, 90, 8593, 4792, 3151, 9, 665, 3151, 32, 4792, 3151, 14, 957, 4335, 199, 1419, 26, 523, 1104, 63, 4284, 26, 272, 1369, 26, 2126, 446, 7494, 14115, 334, 262, 4696, 9, 370, 3222, 282, 13822, 1104, 14, 272, 1415, 26, 3055, 272, 849, 26, 959, 523, 13822, 1074, 63, 354, 26, 272, 1369, 26, 2126, 446, 2812, 402, 314, 5311, 6130, 1074, 14, 272, 1415, 26, 2549, 523, 13822, 1074, 63, 466, 26, 272, 1369, 26, 2126, 446, 2434, 402, 5311, 6130, 1074, 14, 272, 1415, 26, 2549, 272, 3415, 26, 2097, 2856, 401, 298, 14921, 937, 523, 1591, 63, 1291, 26, 272, 1369, 26, 2126, 446, 710, 574, 402, 314, 1591, 1406, 315, 314, 13822, 1104, 1056, 14, 982, 3602, 268, 2701, 12, 314, 4575, 3531, 641, 506, 10220, 402, 1314, 642, 13822, 268, 1104, 365, 10585, 911, 506, 1202, 14, 272, 1415, 26, 2549, 272, 849, 26, 3087, 523, 1844, 26, 272, 1369, 26, 2126, 446, 710, 13488, 1844, 1329, 367, 314, 13822, 1104, 1056, 14, 710, 849, 574, 365, 268, 23865, 367, 14147, 436, 5939, 367, 3101, 14, 272, 1415, 26, 3055, 523, 1056, 63, 515, 26, 272, 1369, 26, 2126, 446, 710, 1056, 931, 402, 314, 14147, 13822, 1104, 1056, 14, 272, 1415, 26, 3055, 272, 849, 26, 10609, 523, 1174, 26, 272, 1369, 26, 8511, 402, 314, 5311, 6130, 1074, 14, 272, 1415, 26, 2549, 272, 3415, 26, 2097, 1881, 401, 298, 5575, 937, 523, 2653, 26, 272, 1369, 26, 2126, 446, 7494, 1846, 334, 262, 4696, 9, 370, 3618, 367, 282, 1177, 2544, 22498, 316, 268, 5988, 14, 2779, 365, 3866, 367, 2653, 268, 370, 1172, 282, 8932, 574, 2419, 1104, 63, 4284, 14, 272, 1415, 26, 3055, 272, 849, 26, 959, 523, 625, 29584, 63, 7227, 26, 272, 1369, 26, 2126, 446, 437, 880, 13, 15315, 13822, 89, 1256, 911, 506, 11584, 625, 29584, 2410, 642, 268, 5002, 23376, 9081, 14, 272, 1415, 26, 3055, 272, 849, 26, 499, 523, 13822, 89, 63, 7227, 26, 272, 1369, 26, 2126, 446, 437, 880, 13, 15315, 625, 29584, 1256, 911, 506, 11584, 13822, 89, 2410, 642, 268, 5002, 23376, 24830, 14, 272, 1415, 26, 3055, 272, 849, 26, 499, 523, 2435, 63, 2048, 63, 2123, 26, 272, 1369, 26, 489, 446, 2435, 2933, 3031, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2435, 63, 2048, 63, 6060, 26, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 272, 1369, 26, 489, 446, 2435, 2933, 3443, 334, 3239, 267, 738, 8, 2859, 921, 4091, 14, 3098, 14, 957, 15, 9277, 15, 71, 4091, 15, 4443, 15, 3357, 15, 5990, 15, 981, 395, 267, 1553, 14129, 3420, 367, 16212, 2556, 9, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 3415, 26, 359, 489, 298, 23256, 401, 298, 4091, 13, 3246, 401, 298, 3357, 13, 293, 401, 298, 3357, 13, 13057, 401, 489, 298, 751, 8370, 13, 293, 401, 298, 751, 8370, 13, 13057, 401, 298, 11450, 401, 298, 4806, 13, 952, 401, 489, 298, 20554, 401, 298, 3009, 13, 2113, 401, 298, 3494, 13, 2861, 401, 298, 3494, 13, 293, 401, 489, 298, 3494, 13, 13057, 401, 298, 1765, 1825, 401, 298, 751, 815, 13, 2123, 2, 272, 1622, 523, 6235, 63, 493, 26, 272, 1369, 26, 489, 446, 6912, 370, 314, 4840, 570, 4568, 543, 314, 2435, 2933, 3031, 272, 849, 26, 2973, 272, 1415, 26, 3055, 523, 2199, 63, 344, 26, 272, 1369, 26, 489, 446, 19519, 30902, 2199, 2870, 272, 1415, 26, 3055, 272, 849, 26, 2973, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 2790, 22466, 5311, 6130, 1799, 523, 22088, 63, 27941, 26, 272, 2435, 63, 2048, 63, 2123, 26, 7370, 2435, 63, 2048, 63, 2123, 7820, 272, 6235, 63, 493, 26, 7370, 6235, 63, 493, 7820, 272, 2199 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 9708, 4475, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 22088, 63, 27941, 199, 1023, 63, 3270, 26, 298, 18, 14, 20, 2, 199, 3612, 63, 1802, 26, 2790, 12, 6162, 503, 20547, 4813, 282, 5311, 6130, 1074, 14, 199, 1802, 26, 272, 446, 2790, 12, 6162, 503, 20547, 4813, 282, 5311, 6130, 1074, 14, 13550, 1454, 3101, 436, 489, 14147, 5311, 6130, 8625, 787, 3748, 14, 5311, 6130, 8625, 787, 1202, 370, 8372, 489, 8212, 4454, 12, 12883, 1256, 4652, 436, 15, 269, 4865, 489, 8500, 14, 5311, 4478, 8625, 787, 295, 14418, 14, 272, 446, 29614, 489, 738, 8, 2859, 921, 4091, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 912, 13, 30260, 15, 9665, 13, 8625, 9, 489, 367, 376, 23503, 402, 5311, 6130, 8625, 641, 30902, 14, 272, 446, 1666, 489, 738, 8, 2859, 921, 4091, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 4443, 15, 7410, 15, 1014, 18850, 11834, 9, 367, 489, 3261, 2436, 641, 3101, 5311, 6130, 8625, 14, 272, 446, 1666, 489, 738, 8, 2859, 921, 4091, 14, 3098, 14, 957, 15, 3357, 15, 4757, 15, 4443, 15, 7410, 15, 2859, 18850, 11834, 9, 489, 367, 1655, 2436, 641, 314, 14147, 5311, 4478, 1074, 3261, 14, 199, 7538, 26, 523, 446, 298, 1548, 2356, 499, 14, 22, 2, 523, 446, 298, 3098, 13, 1246, 13, 1548, 13, 1258, 2356, 413, 14, 22, 14, 18, 2, 523, 446, 298, 3098, 13, 1178, 2356, 378, 14, 25, 14, 16, 2, 523, 446, 298, 3098, 13, 1178, 13, 12942, 18, 2356, 378, 14, 16, 14, 18, 2, 199, 5983, 26, 523, 446, 5972, 5171, 3101, 436, 14147, 5311, 6130, 8625, 5544, 14, 199, 2502, 26, 523, 446, 298, 52, 676, 3194, 552, 271, 90, 8593, 4792, 3151, 9, 665, 3151, 32, 4792, 3151, 14, 957, 4335, 199, 1419, 26, 523, 1104, 63, 4284, 26, 272, 1369, 26, 2126, 446, 7494, 14115, 334, 262, 4696, 9, 370, 3222, 282, 13822, 1104, 14, 272, 1415, 26, 3055, 272, 849, 26, 959, 523, 13822, 1074, 63, 354, 26, 272, 1369, 26, 2126, 446, 2812, 402, 314, 5311, 6130, 1074, 14, 272, 1415, 26, 2549, 523, 13822, 1074, 63, 466, 26, 272, 1369, 26, 2126, 446, 2434, 402, 5311, 6130, 1074, 14, 272, 1415, 26, 2549, 272, 3415, 26, 2097, 2856, 401, 298, 14921, 937, 523, 1591, 63, 1291, 26, 272, 1369, 26, 2126, 446, 710, 574, 402, 314, 1591, 1406, 315, 314, 13822, 1104, 1056, 14, 982, 3602, 268, 2701, 12, 314, 4575, 3531, 641, 506, 10220, 402, 1314, 642, 13822, 268, 1104, 365, 10585, 911, 506, 1202, 14, 272, 1415, 26, 2549, 272, 849, 26, 3087, 523, 1844, 26, 272, 1369, 26, 2126, 446, 710, 13488, 1844, 1329, 367, 314, 13822, 1104, 1056, 14, 710, 849, 574, 365, 268, 23865, 367, 14147, 436, 5939, 367, 3101, 14, 272, 1415, 26, 3055, 523, 1056, 63, 515, 26, 272, 1369, 26, 2126, 446, 710, 1056, 931, 402, 314, 14147, 13822, 1104, 1056, 14, 272, 1415, 26, 3055, 272, 849, 26, 10609, 523, 1174, 26, 272, 1369, 26, 8511, 402, 314, 5311, 6130, 1074, 14, 272, 1415, 26, 2549, 272, 3415, 26, 2097, 1881, 401, 298, 5575, 937, 523, 2653, 26, 272, 1369, 26, 2126, 446, 7494, 1846, 334, 262, 4696, 9, 370, 3618, 367, 282, 1177, 2544, 22498, 316, 268, 5988, 14, 2779, 365, 3866, 367, 2653, 268, 370, 1172, 282, 8932, 574, 2419, 1104, 63, 4284, 14, 272, 1415, 26, 3055, 272, 849, 26, 959, 523, 625, 29584, 63, 7227, 26, 272, 1369, 26, 2126, 446, 437, 880, 13, 15315, 13822, 89, 1256, 911, 506, 11584, 625, 29584, 2410, 642, 268, 5002, 23376, 9081, 14, 272, 1415, 26, 3055, 272, 849, 26, 499, 523, 13822, 89, 63, 7227, 26, 272, 1369, 26, 2126, 446, 437, 880, 13, 15315, 625, 29584, 1256, 911, 506, 11584, 13822, 89, 2410, 642, 268, 5002, 23376, 24830, 14, 272, 1415, 26, 3055, 272, 849, 26, 499, 523, 2435, 63, 2048, 63, 2123, 26, 272, 1369, 26, 489, 446, 2435, 2933, 3031, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 2435, 63, 2048, 63, 6060, 26, 272, 1015, 63, 3270, 26, 298, 18, 14, 16, 2, 272, 1369, 26, 489, 446, 2435, 2933, 3443, 334, 3239, 267, 738, 8, 2859, 921, 4091, 14, 3098, 14, 957, 15, 9277, 15, 71, 4091, 15, 4443, 15, 3357, 15, 5990, 15, 981, 395, 267, 1553, 14129, 3420, 367, 16212, 2556, 9, 272, 1415, 26, 3055, 272, 849, 26, 2973, 272, 3415, 26, 359, 489, 298, 23256, 401, 298, 4091, 13, 3246, 401, 298, 3357, 13, 293, 401, 298, 3357, 13, 13057, 401, 489, 298, 751, 8370, 13, 293, 401, 298, 751, 8370, 13, 13057, 401, 298, 11450, 401, 298, 4806, 13, 952, 401, 489, 298, 20554, 401, 298, 3009, 13, 2113, 401, 298, 3494, 13, 2861, 401, 298, 3494, 13, 293, 401, 489, 298, 3494, 13, 13057, 401, 298, 1765, 1825, 401, 298, 751, 815, 13, 2123, 2, 272, 1622, 523, 6235, 63, 493, 26, 272, 1369, 26, 489, 446, 6912, 370, 314, 4840, 570, 4568, 543, 314, 2435, 2933, 3031, 272, 849, 26, 2973, 272, 1415, 26, 3055, 523, 2199, 63, 344, 26, 272, 1369, 26, 489, 446, 19519, 30902, 2199, 2870, 272, 1415, 26, 3055, 272, 849, 26, 2973, 199, 2344, 199, 199, 8918, 275, 1449, 199, 13, 536, 26, 2790, 22466, 5311, 6130, 1799, 523, 22088, 63, 27941, 26, 272, 2435, 63, 2048, 63, 2123, 26, 7370, 2435, 63, 2048, 63, 2123, 7820, 272, 6235, 63, 493, 26, 7370, 6235, 63, 493, 7820, 272, 2199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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__.py
381
1084
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from makohtml2html import parseNode # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 26834, 1360, 18, 1360, 492, 2198, 1716, 4388, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 8664, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 26834, 1360, 18, 1360, 492, 2198, 1716, 4388, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ianmabie/uberpy
venv/lib/python2.7/site-packages/pip/_vendor/cachecontrol/heuristics.py
374
4053
import calendar import time from email.utils import formatdate, parsedate, parsedate_tz from datetime import datetime, timedelta TIME_FMT = "%a, %d %b %Y %H:%M:%S GMT" def expire_after(delta, date=None): date = date or datetime.now() return date + delta def datetime_to_header(dt): return formatdate(calendar.timegm(dt.timetuple())) class BaseHeuristic(object): def warning(self, response): """ Return a valid 1xx warning header value describing the cache adjustments. The response is provided too allow warnings like 113 http://tools.ietf.org/html/rfc7234#section-5.5.4 where we need to explicitly say response is over 24 hours old. """ return '110 - "Response is Stale"' def update_headers(self, response): """Update the response headers with any new headers. NOTE: This SHOULD always include some Warning header to signify that the response was cached by the client, not by way of the provided headers. """ return {} def apply(self, response): warning_header_value = self.warning(response) response.headers.update(self.update_headers(response)) if warning_header_value is not None: response.headers.update({'Warning': warning_header_value}) return response class OneDayCache(BaseHeuristic): """ Cache the response by providing an expires 1 day in the future. """ def update_headers(self, response): headers = {} if 'expires' not in response.headers: date = parsedate(response.headers['date']) expires = expire_after(timedelta(days=1), date=datetime(*date[:6])) headers['expires'] = datetime_to_header(expires) headers['cache-control'] = 'public' return headers class ExpiresAfter(BaseHeuristic): """ Cache **all** requests for a defined time period. """ def __init__(self, **kw): self.delta = timedelta(**kw) def update_headers(self, response): expires = expire_after(self.delta) return { 'expires': datetime_to_header(expires), 'cache-control': 'public', } def warning(self, response): tmpl = '110 - Automatically cached for %s. Response might be stale' return tmpl % self.delta class LastModified(BaseHeuristic): """ If there is no Expires header already, fall back on Last-Modified using the heuristic from http://tools.ietf.org/html/rfc7234#section-4.2.2 to calculate a reasonable value. Firefox also does something like this per https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching_FAQ http://lxr.mozilla.org/mozilla-release/source/netwerk/protocol/http/nsHttpResponseHead.cpp#397 Unlike mozilla we limit this to 24-hr. """ cacheable_by_default_statuses = set([ 200, 203, 204, 206, 300, 301, 404, 405, 410, 414, 501 ]) def update_headers(self, resp): headers = resp.headers if 'expires' in headers: return {} if 'cache-control' in headers and headers['cache-control'] != 'public': return {} if resp.status not in self.cacheable_by_default_statuses: return {} if 'date' not in headers or 'last-modified' not in headers: return {} date = calendar.timegm(parsedate_tz(headers['date'])) last_modified = parsedate(headers['last-modified']) if date is None or last_modified is None: return {} now = time.time() current_age = max(0, now - date) delta = date - calendar.timegm(last_modified) freshness_lifetime = max(0, min(delta / 10, 24 * 3600)) if freshness_lifetime <= current_age: return {} expires = date + freshness_lifetime return {'expires': time.strftime(TIME_FMT, time.gmtime(expires))} def warning(self, resp): return None
mit
[ 646, 11234, 199, 646, 900, 199, 199, 504, 3031, 14, 1208, 492, 1475, 602, 12, 2198, 602, 12, 2198, 602, 63, 3903, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 199, 4961, 63, 22831, 275, 2071, 65, 12, 450, 68, 450, 66, 450, 57, 450, 40, 2689, 45, 2689, 51, 19152, 2, 421, 199, 318, 16667, 63, 4399, 8, 3136, 12, 1434, 29, 403, 304, 272, 1434, 275, 1434, 503, 2197, 14, 2131, 342, 272, 372, 1434, 435, 5762, 421, 199, 318, 2197, 63, 475, 63, 1291, 8, 3583, 304, 272, 372, 1475, 602, 8, 8183, 14, 521, 13844, 8, 3583, 14, 22309, 4059, 421, 199, 533, 3523, 1966, 20911, 8, 785, 304, 339, 347, 5721, 8, 277, 12, 1177, 304, 267, 408, 267, 1432, 282, 1686, 413, 2154, 5721, 1406, 574, 13660, 314, 2581, 267, 11311, 1470, 14, 398, 710, 1177, 365, 2741, 4634, 2040, 3598, 2839, 24073, 267, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 2819, 1082, 3, 2792, 13, 21, 14, 21, 14, 20, 2382, 781, 1929, 267, 370, 7662, 14722, 1177, 365, 1806, 5504, 10857, 2269, 14, 267, 408, 267, 372, 283, 6019, 446, 298, 2364, 365, 7083, 274, 4507, 339, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 408, 4152, 314, 1177, 2323, 543, 1263, 892, 2323, 14, 398, 6944, 26, 961, 428, 31909, 3544, 2387, 2005, 15902, 1406, 370, 1598, 2070, 2021, 626, 314, 1177, 1990, 6328, 701, 314, 1890, 12, 440, 1598, 701, 4340, 402, 314, 2741, 2323, 14, 267, 408, 267, 372, 1052, 339, 347, 4838, 8, 277, 12, 1177, 304, 267, 5721, 63, 1291, 63, 585, 275, 291, 14, 3764, 8, 1310, 9, 267, 1177, 14, 2139, 14, 873, 8, 277, 14, 873, 63, 2139, 8, 1310, 430, 267, 340, 5721, 63, 1291, 63, 585, 365, 440, 488, 26, 288, 1177, 14, 2139, 14, 873, 3252, 3849, 356, 5721, 63, 1291, 63, 585, 1552, 267, 372, 1177, 421, 199, 533, 7309, 12631, 4437, 8, 1563, 1966, 20911, 304, 272, 408, 272, 11977, 314, 1177, 701, 13070, 376, 12261, 413, 5382, 315, 314, 272, 6466, 14, 272, 408, 272, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 2323, 275, 1052, 398, 340, 283, 12342, 7, 440, 315, 1177, 14, 2139, 26, 288, 1434, 275, 2198, 602, 8, 1310, 14, 2139, 459, 602, 1105, 288, 12261, 275, 16667, 63, 4399, 8, 7473, 8, 4899, 29, 17, 395, 3521, 1434, 29, 2083, 2031, 602, 1491, 22, 2459, 288, 2323, 459, 12342, 418, 275, 2197, 63, 475, 63, 1291, 8, 12342, 9, 288, 2323, 459, 1637, 13, 2785, 418, 275, 283, 3455, 7, 267, 372, 2323, 421, 199, 533, 1316, 1038, 470, 10881, 8, 1563, 1966, 20911, 304, 272, 408, 272, 11977, 1011, 452, 538, 4145, 367, 282, 3247, 900, 6247, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 291, 14, 3136, 275, 6871, 3682, 829, 9, 339, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 12261, 275, 16667, 63, 4399, 8, 277, 14, 3136, 9, 267, 372, 469, 288, 283, 12342, 356, 2197, 63, 475, 63, 1291, 8, 12342, 395, 288, 283, 1637, 13, 2785, 356, 283, 3455, 297, 267, 789, 339, 347, 5721, 8, 277, 12, 1177, 304, 267, 9675, 275, 283, 6019, 446, 9195, 17174, 6328, 367, 450, 83, 14, 7232, 5594, 506, 20149, 7, 267, 372, 9675, 450, 291, 14, 3136, 421, 199, 533, 15237, 11911, 8, 1563, 1966, 20911, 304, 272, 408, 272, 982, 2337, 365, 949, 1316, 1038, 470, 1406, 2575, 12, 11264, 1771, 641, 15237, 13, 11911, 272, 1808, 314, 25332, 687, 272, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 2819, 1082, 3, 2792, 13, 20, 14, 18, 14, 18, 272, 370, 8671, 282, 23255, 574, 14, 339, 24584, 2597, 1630, 6020, 2839, 642, 1126, 272, 4178, 921, 11071, 14, 12102, 14, 1308, 15, 287, 13, 1668, 15, 4757, 15, 5926, 15, 2856, 15, 35, 23302, 63, 2078, 49, 272, 1455, 921, 76, 15775, 14, 12102, 14, 1308, 15, 12102, 13, 3221, 15, 1365, 15, 846, 2135, 75, 15, 3922, 15, 1014, 15, 561, 16287, 11664, 14, 5910, 3, 13145, 272, 25059, 1303, 6956, 781, 2304, 642, 370, 5504, 13, 6271, 14, 272, 408, 272, 2581, 461, 63, 991, 63, 885, 63, 17084, 275, 663, 779, 267, 1926, 12, 29202, 12, 14785, 12, 26761, 12, 9601, 12, 19660, 12, 7901, 12, 25766, 12, 32321, 12, 841, 1079, 12, 28606, 272, 4794, 339, 347, 1678, 63, 2139, 8, 277, 12, 3085, 304, 267, 2323, 275, 3085, 14, 2139, 398, 340, 283, 12342, 7, 315, 2323, 26, 288, 372, 1052, 398, 340, 283, 1637, 13, 2785, 7, 315, 2323, 436, 2323, 459, 1637, 13, 2785, 418, 1137, 283, 3455, 356, 288, 372, 1052, 398, 340, 3085, 14, 1205, 440, 315, 291, 14, 1637, 461, 63, 991, 63, 885, 63, 17084, 26, 288, 372, 1052, 398, 340, 283, 602, 7, 440, 315, 2323, 503, 283, 2019, 13, 5540, 7, 440, 315, 2323, 26, 288, 372, 1052, 398, 1434, 275, 11234, 14, 521, 13844, 8, 1122, 602, 63, 3903, 8, 2139, 459, 602, 5156, 267, 2061, 63, 5540, 275, 2198, 602, 8, 2139, 459, 2019, 13, 5540, 1105, 267, 340, 1434, 365, 488, 503, 2061, 63, 5540, 365, 488, 26, 288, 372, 1052, 398, 3063, 275, 900, 14, 521, 342, 267, 1453, 63, 474, 275, 1390, 8, 16, 12, 3063, 446, 1434, 9, 267, 5762, 275, 1434, 446, 11234, 14, 521, 13844, 8, 2019, 63, 5540, 9, 267, 17480, 4171, 63, 27674, 275, 1390, 8, 16, 12, 1748, 8, 3136, 1182, 1616, 12, 5504, 627, 15751, 430, 267, 340, 17480, 4171, 63, 27674, 2695, 1453, 63, 474, 26, 288, 372, 1052, 398, 12261, 275, 1434, 435, 17480, 4171, 63, 27674, 267, 372, 791, 12342, 356, 900, 14, 6205, 8, 4961, 63, 22831, 12, 900, 14, 22227, 8, 12342, 430, 93, 339, 347, 5721, 8, 277, 12, 3085, 304, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 11234, 199, 646, 900, 199, 199, 504, 3031, 14, 1208, 492, 1475, 602, 12, 2198, 602, 12, 2198, 602, 63, 3903, 199, 199, 504, 2197, 492, 2197, 12, 6871, 199, 199, 4961, 63, 22831, 275, 2071, 65, 12, 450, 68, 450, 66, 450, 57, 450, 40, 2689, 45, 2689, 51, 19152, 2, 421, 199, 318, 16667, 63, 4399, 8, 3136, 12, 1434, 29, 403, 304, 272, 1434, 275, 1434, 503, 2197, 14, 2131, 342, 272, 372, 1434, 435, 5762, 421, 199, 318, 2197, 63, 475, 63, 1291, 8, 3583, 304, 272, 372, 1475, 602, 8, 8183, 14, 521, 13844, 8, 3583, 14, 22309, 4059, 421, 199, 533, 3523, 1966, 20911, 8, 785, 304, 339, 347, 5721, 8, 277, 12, 1177, 304, 267, 408, 267, 1432, 282, 1686, 413, 2154, 5721, 1406, 574, 13660, 314, 2581, 267, 11311, 1470, 14, 398, 710, 1177, 365, 2741, 4634, 2040, 3598, 2839, 24073, 267, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 2819, 1082, 3, 2792, 13, 21, 14, 21, 14, 20, 2382, 781, 1929, 267, 370, 7662, 14722, 1177, 365, 1806, 5504, 10857, 2269, 14, 267, 408, 267, 372, 283, 6019, 446, 298, 2364, 365, 7083, 274, 4507, 339, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 408, 4152, 314, 1177, 2323, 543, 1263, 892, 2323, 14, 398, 6944, 26, 961, 428, 31909, 3544, 2387, 2005, 15902, 1406, 370, 1598, 2070, 2021, 626, 314, 1177, 1990, 6328, 701, 314, 1890, 12, 440, 1598, 701, 4340, 402, 314, 2741, 2323, 14, 267, 408, 267, 372, 1052, 339, 347, 4838, 8, 277, 12, 1177, 304, 267, 5721, 63, 1291, 63, 585, 275, 291, 14, 3764, 8, 1310, 9, 267, 1177, 14, 2139, 14, 873, 8, 277, 14, 873, 63, 2139, 8, 1310, 430, 267, 340, 5721, 63, 1291, 63, 585, 365, 440, 488, 26, 288, 1177, 14, 2139, 14, 873, 3252, 3849, 356, 5721, 63, 1291, 63, 585, 1552, 267, 372, 1177, 421, 199, 533, 7309, 12631, 4437, 8, 1563, 1966, 20911, 304, 272, 408, 272, 11977, 314, 1177, 701, 13070, 376, 12261, 413, 5382, 315, 314, 272, 6466, 14, 272, 408, 272, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 2323, 275, 1052, 398, 340, 283, 12342, 7, 440, 315, 1177, 14, 2139, 26, 288, 1434, 275, 2198, 602, 8, 1310, 14, 2139, 459, 602, 1105, 288, 12261, 275, 16667, 63, 4399, 8, 7473, 8, 4899, 29, 17, 395, 3521, 1434, 29, 2083, 2031, 602, 1491, 22, 2459, 288, 2323, 459, 12342, 418, 275, 2197, 63, 475, 63, 1291, 8, 12342, 9, 288, 2323, 459, 1637, 13, 2785, 418, 275, 283, 3455, 7, 267, 372, 2323, 421, 199, 533, 1316, 1038, 470, 10881, 8, 1563, 1966, 20911, 304, 272, 408, 272, 11977, 1011, 452, 538, 4145, 367, 282, 3247, 900, 6247, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1011, 829, 304, 267, 291, 14, 3136, 275, 6871, 3682, 829, 9, 339, 347, 1678, 63, 2139, 8, 277, 12, 1177, 304, 267, 12261, 275, 16667, 63, 4399, 8, 277, 14, 3136, 9, 267, 372, 469, 288, 283, 12342, 356, 2197, 63, 475, 63, 1291, 8, 12342, 395, 288, 283, 1637, 13, 2785, 356, 283, 3455, 297, 267, 789, 339, 347, 5721, 8, 277, 12, 1177, 304, 267, 9675, 275, 283, 6019, 446, 9195, 17174, 6328, 367, 450, 83, 14, 7232, 5594, 506, 20149, 7, 267, 372, 9675, 450, 291, 14, 3136, 421, 199, 533, 15237, 11911, 8, 1563, 1966, 20911, 304, 272, 408, 272, 982, 2337, 365, 949, 1316, 1038, 470, 1406, 2575, 12, 11264, 1771, 641, 15237, 13, 11911, 272, 1808, 314, 25332, 687, 272, 1455, 921, 2537, 14, 15799, 14, 1308, 15, 1360, 15, 8973, 2819, 1082, 3, 2792, 13, 20, 14, 18, 14, 18, 272, 370, 8671, 282, 23255, 574, 14, 339, 24584, 2597, 1630, 6020, 2839, 642, 1126, 272, 4178, 921, 11071, 14, 12102, 14, 1308, 15, 287, 13, 1668, 15, 4757, 15, 5926, 15, 2856, 15, 35, 23302, 63, 2078, 49, 272, 1455, 921, 76, 15775, 14, 12102, 14, 1308, 15, 12102, 13, 3221, 15, 1365, 15, 846, 2135, 75, 15, 3922, 15, 1014, 15, 561, 16287, 11664, 14, 5910, 3, 13145, 272, 25059, 1303, 6956, 781, 2304, 642, 370, 5504, 13, 6271, 14, 272, 408, 272, 2581, 461, 63, 991, 63, 885, 63, 17084, 275, 663, 779, 267, 1926, 12, 29202, 12, 14785, 12, 26761, 12, 9601, 12, 19660, 12, 7901, 12, 25766, 12, 32321, 12, 841, 1079, 12, 28606, 272, 4794, 339, 347, 1678, 63, 2139, 8, 277, 12, 3085, 304, 267, 2323, 275, 3085, 14, 2139, 398, 340, 283, 12342, 7, 315, 2323, 26, 288, 372, 1052, 398, 340, 283, 1637, 13, 2785, 7, 315, 2323, 436, 2323, 459, 1637, 13, 2785, 418, 1137, 283, 3455, 356, 288, 372, 1052, 398, 340, 3085, 14, 1205, 440, 315, 291, 14, 1637, 461, 63, 991, 63, 885, 63, 17084, 26, 288, 372, 1052, 398, 340, 283, 602, 7, 440, 315, 2323, 503, 283, 2019, 13, 5540, 7, 440, 315, 2323, 26, 288, 372, 1052, 398, 1434, 275, 11234, 14, 521, 13844, 8, 1122, 602, 63, 3903, 8, 2139, 459, 602, 5156, 267, 2061, 63, 5540, 275, 2198, 602, 8, 2139, 459, 2019, 13, 5540, 1105, 267, 340, 1434, 365, 488, 503, 2061, 63, 5540, 365, 488, 26, 288, 372, 1052, 398, 3063, 275, 900, 14, 521, 342, 267, 1453, 63, 474, 275, 1390, 8, 16, 12, 3063, 446, 1434, 9, 267, 5762, 275, 1434, 446, 11234, 14, 521, 13844, 8, 2019, 63, 5540, 9, 267, 17480, 4171, 63, 27674, 275, 1390, 8, 16, 12, 1748, 8, 3136, 1182, 1616, 12, 5504, 627, 15751, 430, 267, 340, 17480, 4171, 63, 27674, 2695, 1453, 63, 474, 26, 288, 372, 1052, 398, 12261, 275, 1434, 435, 17480, 4171, 63, 27674, 267, 372, 791, 12342, 356, 900, 14, 6205, 8, 4961, 63, 22831, 12, 900, 14, 22227, 8, 12342, 430, 93, 339, 347, 5721, 8, 277, 12, 3085, 304, 267, 372, 488, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
aravindalwan/unyque
unyque/rdimension.py
1
3726
'''Representation of a random variable used in stochastic collocation''' __copyright__ = 'Copyright (C) 2011 Aravind Alwan' __license__ = ''' This file is part of UnyQuE. UnyQuE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. UnyQuE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. For a copy of the GNU General Public License, please see <http://www.gnu.org/licenses/>. ''' class RandomDimension(object): '''Random dimension object that encapsulates the operations along one of the dimensions in random space, which corresponds to one of the random variables ''' kmax = 0 nodes = None def __init__(self, bound): self._bound = bound @classmethod def set_maximum_interp_level(cls, value): cls.kmax = value cls._init_nodes() @classmethod def _init_nodes(cls): '''Initialize nodes in a hierarchical fashion as a list of sublists, where each sublist contains the nodes added at the corresponding level ''' cls.nodes = [] if cls.kmax > 0: cls.nodes.append([0.5]) if cls.kmax > 1: cls.nodes.append([0.0, 1.0]) if cls.kmax > 2: for k in xrange(3, cls.kmax+1): cls.nodes.append([ (1.0 + 2.0*j)/(2**(k-1)) for j in xrange(2**(k-2))]) def get_node(self, level, idx, normalized = False): '''Return the scaled coordinates of a node at the given level and index ''' if normalized: return self.nodes[level-1][idx] else: lo = self._bound[0] hi = self._bound[1] return lo + (hi-lo)*self.nodes[level-1][idx] @classmethod def _interpolate(cls, pt1, x2): '''Evaluate basis function centered at pt1, at x2. pt1 has to be a tuple of the form (level, index) that specifies the interpolation level and the index of the node at that level. x2 is any float value between 0 and 1, specifying the location where the basis function is to be evaluated. ''' level1, idx1 = pt1 x1 = cls.nodes[level1-1][idx1] if level1 == 1: return 1.0 else: m = 2**(level1-1) + 1 # Number of nodes at this level return (abs(x1-x2) < 1./(m-1)) * (1. - (m-1)*abs(x1-x2)) def interpolate(self, pt1, x): '''Evaluate basis function centered at pt1, at the location x. This method scales x to be in [0,1] and calls _interpolate to get the actual interpolated value ''' lo = self._bound[0] hi = self._bound[1] if lo <= x <= hi: return self._interpolate(pt1, float(x-lo)/float(hi-lo)) else: return 0. def get_basis_function(self, pt): '''Return bounds of the piece-wise linear basis function centered at pt. ''' lo = self._bound[0] hi = self._bound[1] level, idx = pt if level == 1: return (lo, hi, pt) elif level == 2: lo = (lo + hi)/2 if idx == 1 else lo hi = (lo + hi)/2 if idx == 0 else hi return (lo, hi, pt) else: m = 2**(level-1) + 1 # Number of nodes at this level x = lo + (hi-lo)*self.nodes[level-1][idx] return (x-(hi-lo)/(m-1), x+(hi-lo)/(m-1), pt)
gpl-3.0
[ 2344, 20609, 402, 282, 2196, 1750, 1202, 315, 26123, 21913, 1048, 1985, 2344, 199, 199, 363, 7307, 363, 275, 283, 7384, 334, 35, 9, 7760, 437, 345, 86, 688, 4580, 20444, 7, 199, 199, 363, 1682, 363, 275, 1449, 199, 2765, 570, 365, 1777, 402, 1910, 89, 2371, 37, 14, 199, 199, 1358, 89, 2371, 37, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 1358, 89, 2371, 37, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 1858, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 12, 8749, 1937, 199, 28, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 2344, 199, 199, 533, 9571, 17905, 8, 785, 304, 272, 1449, 3883, 6240, 909, 626, 22667, 15409, 314, 5331, 3180, 1373, 402, 314, 272, 7365, 315, 2196, 4601, 12, 1314, 13718, 370, 1373, 402, 314, 2196, 2860, 272, 1449, 339, 1022, 988, 275, 378, 272, 3380, 275, 488, 339, 347, 636, 826, 721, 277, 12, 3914, 304, 267, 291, 423, 3556, 275, 3914, 339, 768, 3744, 272, 347, 663, 63, 11555, 63, 14252, 63, 1896, 8, 1886, 12, 574, 304, 267, 843, 14, 75, 988, 275, 574, 267, 843, 423, 826, 63, 2415, 342, 339, 768, 3744, 272, 347, 485, 826, 63, 2415, 8, 1886, 304, 267, 1449, 9345, 3380, 315, 282, 24787, 32285, 465, 282, 769, 402, 1007, 6717, 12, 267, 2382, 1924, 27007, 3509, 314, 3380, 3483, 737, 314, 5226, 2166, 267, 1449, 267, 843, 14, 2415, 275, 942, 267, 340, 843, 14, 75, 988, 690, 378, 26, 288, 843, 14, 2415, 14, 740, 779, 16, 14, 21, 566, 267, 340, 843, 14, 75, 988, 690, 413, 26, 288, 843, 14, 2415, 14, 740, 779, 16, 14, 16, 12, 413, 14, 16, 566, 267, 340, 843, 14, 75, 988, 690, 499, 26, 288, 367, 1022, 315, 4945, 8, 19, 12, 843, 14, 75, 988, 11, 17, 304, 355, 843, 14, 2415, 14, 740, 779, 717, 334, 17, 14, 16, 435, 499, 14, 16, 10, 74, 15136, 18, 14192, 75, 13, 17, 430, 367, 1335, 315, 4945, 8, 18, 14192, 75, 13, 18, 18229, 339, 347, 664, 63, 932, 8, 277, 12, 2166, 12, 4280, 12, 9657, 275, 756, 304, 267, 1449, 1767, 314, 17923, 8983, 402, 282, 1031, 737, 314, 1627, 2166, 436, 1478, 267, 1449, 398, 340, 9657, 26, 288, 372, 291, 14, 2415, 59, 1896, 13, 17, 1527, 2996, 61, 267, 587, 26, 288, 560, 275, 291, 423, 3556, 59, 16, 61, 288, 13759, 275, 291, 423, 3556, 59, 17, 61, 288, 372, 560, 435, 334, 5812, 13, 320, 3342, 277, 14, 2415, 59, 1896, 13, 17, 1527, 2996, 61, 339, 768, 3744, 272, 347, 485, 21294, 8, 1886, 12, 10063, 17, 12, 671, 18, 304, 267, 1449, 25002, 5597, 805, 23903, 737, 10063, 17, 12, 737, 671, 18, 14, 10063, 17, 965, 370, 506, 282, 267, 2008, 402, 314, 1824, 334, 1896, 12, 1478, 9, 626, 9314, 314, 14046, 2166, 267, 436, 314, 1478, 402, 314, 1031, 737, 626, 2166, 14, 671, 18, 365, 1263, 2069, 574, 3382, 267, 378, 436, 413, 12, 9176, 314, 2909, 2382, 314, 5597, 805, 365, 370, 506, 267, 13006, 14, 267, 1449, 398, 2166, 17, 12, 4280, 17, 275, 10063, 17, 267, 671, 17, 275, 843, 14, 2415, 59, 1896, 17, 13, 17, 1527, 2996, 17, 61, 398, 340, 2166, 17, 508, 413, 26, 288, 372, 413, 14, 16, 267, 587, 26, 288, 333, 275, 499, 14192, 1896, 17, 13, 17, 9, 435, 413, 327, 4860, 402, 3380, 737, 642, 2166, 288, 372, 334, 2101, 8, 88, 17, 13, 88, 18, 9, 665, 413, 14, 7985, 77, 13, 17, 430, 627, 334, 17, 14, 446, 334, 77, 13, 17, 3342, 2101, 8, 88, 17, 13, 88, 18, 430, 339, 347, 28884, 8, 277, 12, 10063, 17, 12, 671, 304, 267, 1449, 25002, 5597, 805, 23903, 737, 10063, 17, 12, 737, 314, 2909, 671, 14, 961, 267, 1083, 29823, 671, 370, 506, 315, 359, 16, 12, 17, 61, 436, 4882, 485, 21294, 370, 664, 314, 3503, 267, 23005, 972, 574, 267, 1449, 398, 560, 275, 291, 423, 3556, 59, 16, 61, 267, 13759, 275, 291, 423, 3556, 59, 17, 61, 267, 340, 560, 2695, 671, 2695, 13759, 26, 288, 372, 291, 423, 21294, 8, 541, 17, 12, 2069, 8, 88, 13, 320, 2447, 1609, 8, 5812, 13, 320, 430, 267, 587, 26, 288, 372, 378, 14, 339, 347, 664, 63, 19220, 63, 1593, 8, 277, 12, 10063, 304, 267, 1449, 1767, 10461, 402, 314, 14854, 13, 2605, 7798, 5597, 805, 23903, 737, 10063, 14, 267, 1449, 398, 560, 275, 291, 423, 3556, 59, 16, 61, 267, 13759, 275, 291, 423, 3556, 59, 17, 61, 267, 2166, 12, 4280, 275, 10063, 398, 340, 2166, 508, 413, 26, 288, 372, 334, 320, 12, 13759, 12, 10063, 9, 267, 916, 2166, 508, 499, 26, 288, 560, 275, 334, 320, 435, 13759, 2447, 18, 340, 4280, 508, 413, 587, 560, 288, 13759, 275, 334, 320, 435, 13759, 2447, 18, 340, 4280, 508, 378, 587, 13759, 288, 372, 334, 320, 12, 13759, 12, 10063, 9, 267, 587, 26, 288, 333, 275, 499, 14192, 1896, 13, 17, 9, 435, 413, 327, 4860, 402, 3380, 737, 642, 2166, 288, 671, 275, 560, 435, 334, 5812, 13, 320, 3342, 277, 14, 2415, 59, 1896, 13, 17, 1527, 2996, 61, 288, 372, 334, 88, 15426, 5812, 13, 320, 15136, 77, 13, 17, 395, 671, 15622, 5812, 13, 320, 15136, 77, 13, 17, 395, 10063, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 20609, 402, 282, 2196, 1750, 1202, 315, 26123, 21913, 1048, 1985, 2344, 199, 199, 363, 7307, 363, 275, 283, 7384, 334, 35, 9, 7760, 437, 345, 86, 688, 4580, 20444, 7, 199, 199, 363, 1682, 363, 275, 1449, 199, 2765, 570, 365, 1777, 402, 1910, 89, 2371, 37, 14, 199, 199, 1358, 89, 2371, 37, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 390, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 1589, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 8, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 199, 1358, 89, 2371, 37, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 7911, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 31461, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 17732, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 199, 1858, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 12, 8749, 1937, 199, 28, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 2344, 199, 199, 533, 9571, 17905, 8, 785, 304, 272, 1449, 3883, 6240, 909, 626, 22667, 15409, 314, 5331, 3180, 1373, 402, 314, 272, 7365, 315, 2196, 4601, 12, 1314, 13718, 370, 1373, 402, 314, 2196, 2860, 272, 1449, 339, 1022, 988, 275, 378, 272, 3380, 275, 488, 339, 347, 636, 826, 721, 277, 12, 3914, 304, 267, 291, 423, 3556, 275, 3914, 339, 768, 3744, 272, 347, 663, 63, 11555, 63, 14252, 63, 1896, 8, 1886, 12, 574, 304, 267, 843, 14, 75, 988, 275, 574, 267, 843, 423, 826, 63, 2415, 342, 339, 768, 3744, 272, 347, 485, 826, 63, 2415, 8, 1886, 304, 267, 1449, 9345, 3380, 315, 282, 24787, 32285, 465, 282, 769, 402, 1007, 6717, 12, 267, 2382, 1924, 27007, 3509, 314, 3380, 3483, 737, 314, 5226, 2166, 267, 1449, 267, 843, 14, 2415, 275, 942, 267, 340, 843, 14, 75, 988, 690, 378, 26, 288, 843, 14, 2415, 14, 740, 779, 16, 14, 21, 566, 267, 340, 843, 14, 75, 988, 690, 413, 26, 288, 843, 14, 2415, 14, 740, 779, 16, 14, 16, 12, 413, 14, 16, 566, 267, 340, 843, 14, 75, 988, 690, 499, 26, 288, 367, 1022, 315, 4945, 8, 19, 12, 843, 14, 75, 988, 11, 17, 304, 355, 843, 14, 2415, 14, 740, 779, 717, 334, 17, 14, 16, 435, 499, 14, 16, 10, 74, 15136, 18, 14192, 75, 13, 17, 430, 367, 1335, 315, 4945, 8, 18, 14192, 75, 13, 18, 18229, 339, 347, 664, 63, 932, 8, 277, 12, 2166, 12, 4280, 12, 9657, 275, 756, 304, 267, 1449, 1767, 314, 17923, 8983, 402, 282, 1031, 737, 314, 1627, 2166, 436, 1478, 267, 1449, 398, 340, 9657, 26, 288, 372, 291, 14, 2415, 59, 1896, 13, 17, 1527, 2996, 61, 267, 587, 26, 288, 560, 275, 291, 423, 3556, 59, 16, 61, 288, 13759, 275, 291, 423, 3556, 59, 17, 61, 288, 372, 560, 435, 334, 5812, 13, 320, 3342, 277, 14, 2415, 59, 1896, 13, 17, 1527, 2996, 61, 339, 768, 3744, 272, 347, 485, 21294, 8, 1886, 12, 10063, 17, 12, 671, 18, 304, 267, 1449, 25002, 5597, 805, 23903, 737, 10063, 17, 12, 737, 671, 18, 14, 10063, 17, 965, 370, 506, 282, 267, 2008, 402, 314, 1824, 334, 1896, 12, 1478, 9, 626, 9314, 314, 14046, 2166, 267, 436, 314, 1478, 402, 314, 1031, 737, 626, 2166, 14, 671, 18, 365, 1263, 2069, 574, 3382, 267, 378, 436, 413, 12, 9176, 314, 2909, 2382, 314, 5597, 805, 365, 370, 506, 267, 13006, 14, 267, 1449, 398, 2166, 17, 12, 4280, 17, 275, 10063, 17, 267, 671, 17, 275, 843, 14, 2415, 59, 1896, 17, 13, 17, 1527, 2996, 17, 61, 398, 340, 2166, 17, 508, 413, 26, 288, 372, 413, 14, 16, 267, 587, 26, 288, 333, 275, 499, 14192, 1896, 17, 13, 17, 9, 435, 413, 327, 4860, 402, 3380, 737, 642, 2166, 288, 372, 334, 2101, 8, 88, 17, 13, 88, 18, 9, 665, 413, 14, 7985, 77, 13, 17, 430, 627, 334, 17, 14, 446, 334, 77, 13, 17, 3342, 2101, 8, 88, 17, 13, 88, 18, 430, 339, 347, 28884, 8, 277, 12, 10063, 17, 12, 671, 304, 267, 1449, 25002, 5597, 805, 23903, 737, 10063, 17, 12, 737, 314, 2909, 671, 14, 961, 267, 1083, 29823, 671, 370, 506, 315, 359, 16, 12, 17, 61, 436, 4882, 485, 21294, 370, 664, 314, 3503, 267, 23005, 972, 574, 267, 1449, 398, 560, 275, 291, 423, 3556, 59, 16, 61, 267, 13759, 275, 291, 423, 3556, 59, 17, 61, 267, 340, 560, 2695, 671, 2695, 13759, 26, 288, 372, 291, 423, 21294, 8, 541, 17, 12, 2069, 8, 88, 13, 320, 2447, 1609, 8, 5812, 13, 320, 430, 267, 587, 26, 288, 372, 378, 14, 339, 347, 664, 63, 19220, 63, 1593, 8, 277, 12, 10063, 304, 267, 1449, 1767, 10461, 402, 314, 14854, 13, 2605, 7798, 5597, 805, 23903, 737, 10063, 14, 267, 1449, 398, 560, 275, 291, 423, 3556, 59, 16, 61, 267, 13759, 275, 291, 423, 3556, 59, 17, 61, 267, 2166, 12, 4280, 275, 10063, 398, 340, 2166, 508, 413, 26, 288, 372, 334, 320, 12, 13759, 12, 10063, 9, 267, 916, 2166, 508, 499, 26, 288, 560, 275, 334, 320, 435, 13759, 2447, 18, 340, 4280, 508, 413, 587, 560, 288, 13759, 275, 334, 320, 435, 13759, 2447, 18, 340, 4280, 508, 378, 587, 13759, 288, 372, 334, 320, 12, 13759, 12, 10063, 9, 267, 587, 26, 288, 333, 275, 499, 14192, 1896, 13, 17, 9, 435, 413, 327, 4860, 402, 3380, 737, 642, 2166, 288, 671, 275, 560, 435, 334, 5812, 13, 320, 3342, 277, 14, 2415, 59, 1896, 13, 17, 1527, 2996, 61, 288, 372, 334, 88, 15426, 5812, 13, 320, 15136, 77, 13, 17, 395, 671, 15622, 5812, 13, 320, 15136, 77, 13, 17, 395, 10063, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
trunca/enigma2
lib/python/Components/Renderer/Watchew.py
15
2831
## Now FTA-render ;) import math from Renderer import Renderer from skin import parseColor from enigma import eCanvas, eSize, gRGB, eRect from Components.VariableText import VariableText from Components.config import config class Watchew(Renderer): def __init__(self): Renderer.__init__(self) self.fColor = gRGB(255, 255, 255, 0) self.bColor = gRGB(0, 0, 0, 255) self.numval = -1 GUI_WIDGET = eCanvas def applySkin(self, desktop, parent): attribs = [] for (attrib, what,) in self.skinAttributes: if (attrib == 'foregroundColor'): self.fColor = parseColor(what) elif (attrib == 'backgroundColor'): self.bColor = parseColor(what) else: attribs.append((attrib, what)) self.skinAttributes = attribs return Renderer.applySkin(self, desktop, parent) def calculate(self, w, r, m): a = (w * 6) z = (math.pi / 180) x = int(round((r * math.sin((a * z))))) y = int(round((r * math.cos((a * z))))) return ((m + x),(m - y)) def hand(self): width = self.instance.size().width() height = self.instance.size().height() r = (min(width, height) / 2) (endX, endY,) = self.calculate(self.numval, r, r) self.draw_line(r, r, endX, endY) def draw_line(self, x0, y0, x1, y1): steep = (abs((y1 - y0)) > abs((x1 - x0))) if steep: x0,y0 = y0,x0 x1,y1 = y1,x1 if (x0 > x1): x0,x1 = x1,x0 y0,y1 = y1,y0 if (y0 < y1): ystep = 1 else: ystep = -1 deltax = (x1 - x0) deltay = abs((y1 - y0)) error = (-deltax / 2) y = y0 for x in range(x0, (x1 + 1)): if steep: self.instance.fillRect(eRect(y, x, 3, 3), self.fColor) else: self.instance.fillRect(eRect(x, y, 3, 3), self.fColor) error = (error + deltay) if (error > 0): y = (y + ystep) error = (error - deltax) def changed(self, what): sss = self.source.value if (what[0] == self.CHANGED_CLEAR): pass elif self.instance: self.instance.show() if (self.numval != sss): self.numval = sss self.instance.clear(self.bColor) self.hand() def postWidgetCreate(self, instance): def parseSize(str): (x, y,) = str.split(',') return eSize(int(x), int(y)) for (attrib, value,) in self.skinAttributes: if ((attrib == 'size') and self.instance.setSize(parseSize(value))): pass self.instance.clear(self.bColor)
gpl-2.0
[ 309, 7356, 481, 6166, 13, 3352, 8700, 9, 199, 646, 3473, 221, 199, 504, 10055, 5813, 492, 10055, 5813, 221, 199, 504, 28337, 492, 2198, 4117, 221, 199, 504, 655, 27021, 492, 325, 15174, 12, 325, 2320, 12, 486, 12067, 12, 325, 8252, 221, 199, 504, 17823, 14, 2773, 1872, 492, 4905, 1872, 221, 199, 504, 17823, 14, 888, 492, 1101, 221, 199, 533, 29075, 546, 8, 11355, 304, 339, 347, 636, 826, 721, 277, 304, 267, 10055, 5813, 855, 826, 721, 277, 9, 267, 291, 14, 70, 4117, 275, 486, 12067, 8, 2299, 12, 5450, 12, 5450, 12, 378, 9, 267, 291, 14, 66, 4117, 275, 486, 12067, 8, 16, 12, 378, 12, 378, 12, 5450, 9, 267, 291, 14, 1507, 637, 275, 446, 17, 339, 17160, 63, 9845, 2970, 275, 325, 15174, 339, 347, 4838, 14194, 262, 8, 277, 12, 19763, 12, 1676, 304, 267, 737, 19577, 275, 942, 267, 367, 334, 6640, 12, 4052, 4258, 315, 291, 14, 16409, 5379, 26, 288, 340, 334, 6640, 508, 283, 23801, 4117, 735, 355, 291, 14, 70, 4117, 275, 2198, 4117, 8, 10058, 9, 288, 916, 334, 6640, 508, 283, 7451, 4117, 735, 355, 291, 14, 66, 4117, 275, 2198, 4117, 8, 10058, 9, 288, 587, 26, 355, 737, 19577, 14, 740, 1332, 6640, 12, 4052, 430, 267, 291, 14, 16409, 5379, 275, 737, 19577, 267, 372, 10055, 5813, 14, 4998, 14194, 262, 8, 277, 12, 19763, 12, 1676, 9, 339, 347, 8671, 8, 277, 12, 336, 12, 519, 12, 333, 304, 267, 282, 275, 334, 87, 627, 1227, 9, 267, 1315, 275, 334, 3442, 14, 1038, 1182, 13576, 9, 267, 671, 275, 1109, 8, 2363, 1332, 82, 627, 3473, 14, 5911, 1332, 65, 627, 1315, 430, 1724, 267, 612, 275, 1109, 8, 2363, 1332, 82, 627, 3473, 14, 5197, 1332, 65, 627, 1315, 430, 1724, 267, 372, 3666, 77, 435, 671, 11865, 77, 446, 612, 430, 339, 347, 4926, 8, 277, 304, 267, 3462, 275, 291, 14, 842, 14, 890, 1252, 2063, 342, 267, 4569, 275, 291, 14, 842, 14, 890, 1252, 3333, 342, 267, 519, 275, 334, 827, 8, 2063, 12, 4569, 9, 1182, 499, 9, 267, 334, 500, 56, 12, 1284, 57, 4258, 275, 291, 14, 12063, 8, 277, 14, 1507, 637, 12, 519, 12, 519, 9, 267, 291, 14, 5485, 63, 604, 8, 82, 12, 519, 12, 1284, 56, 12, 1284, 57, 9, 339, 347, 5954, 63, 604, 8, 277, 12, 671, 16, 12, 612, 16, 12, 671, 17, 12, 612, 17, 304, 267, 20345, 1545, 275, 334, 2101, 1332, 89, 17, 446, 612, 16, 430, 690, 2853, 1332, 88, 17, 446, 671, 16, 1724, 267, 340, 20345, 1545, 26, 288, 671, 16, 12, 89, 16, 275, 612, 16, 12, 88, 16, 288, 671, 17, 12, 89, 17, 275, 612, 17, 12, 88, 17, 267, 340, 334, 88, 16, 690, 671, 17, 304, 288, 671, 16, 12, 88, 17, 275, 671, 17, 12, 88, 16, 288, 612, 16, 12, 89, 17, 275, 612, 17, 12, 89, 16, 267, 340, 334, 89, 16, 665, 612, 17, 304, 288, 19205, 2852, 275, 413, 267, 587, 26, 288, 19205, 2852, 275, 446, 17, 267, 2150, 5530, 275, 334, 88, 17, 446, 671, 16, 9, 267, 5762, 89, 275, 2853, 1332, 89, 17, 446, 612, 16, 430, 267, 1125, 275, 5868, 3136, 88, 1182, 499, 9, 267, 612, 275, 612, 16, 267, 367, 671, 315, 1425, 8, 88, 16, 12, 334, 88, 17, 435, 413, 2298, 288, 340, 20345, 1545, 26, 355, 291, 14, 842, 14, 4498, 8252, 8, 69, 8252, 8, 89, 12, 671, 12, 650, 12, 650, 395, 291, 14, 70, 4117, 9, 288, 587, 26, 355, 291, 14, 842, 14, 4498, 8252, 8, 69, 8252, 8, 88, 12, 612, 12, 650, 12, 650, 395, 291, 14, 70, 4117, 9, 288, 1125, 275, 334, 705, 435, 5762, 89, 9, 288, 340, 334, 705, 690, 378, 304, 355, 612, 275, 334, 89, 435, 19205, 2852, 9, 355, 1125, 275, 334, 705, 446, 2150, 5530, 9, 339, 347, 2896, 8, 277, 12, 4052, 304, 267, 308, 385, 275, 291, 14, 1365, 14, 585, 267, 340, 334, 10058, 59, 16, 61, 508, 291, 14, 21488, 63, 20706, 304, 288, 986, 267, 916, 291, 14, 842, 26, 288, 291, 14, 842, 14, 2384, 342, 288, 340, 334, 277, 14, 1507, 637, 1137, 308, 385, 304, 355, 291, 14, 1507, 637, 275, 308, 385, 355, 291, 14, 842, 14, 3584, 8, 277, 14, 66, 4117, 9, 355, 291, 14, 6868, 342, 339, 347, 2963, 3339, 2499, 8, 277, 12, 1256, 304, 398, 347, 2198, 2320, 8, 495, 304, 288, 334, 88, 12, 612, 4258, 275, 620, 14, 1294, 11917, 288, 372, 325, 2320, 8, 442, 8, 88, 395, 1109, 8, 89, 430, 267, 367, 334, 6640, 12, 574, 4258, 315, 291, 14, 16409, 5379, 26, 288, 340, 3666, 6640, 508, 283, 890, 358, 436, 291, 14, 842, 14, 21735, 8, 1122, 2320, 8, 585, 15206, 355, 986, 267, 291, 14, 842, 14, 3584, 8, 277, 14, 66, 4117, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 7356, 481, 6166, 13, 3352, 8700, 9, 199, 646, 3473, 221, 199, 504, 10055, 5813, 492, 10055, 5813, 221, 199, 504, 28337, 492, 2198, 4117, 221, 199, 504, 655, 27021, 492, 325, 15174, 12, 325, 2320, 12, 486, 12067, 12, 325, 8252, 221, 199, 504, 17823, 14, 2773, 1872, 492, 4905, 1872, 221, 199, 504, 17823, 14, 888, 492, 1101, 221, 199, 533, 29075, 546, 8, 11355, 304, 339, 347, 636, 826, 721, 277, 304, 267, 10055, 5813, 855, 826, 721, 277, 9, 267, 291, 14, 70, 4117, 275, 486, 12067, 8, 2299, 12, 5450, 12, 5450, 12, 378, 9, 267, 291, 14, 66, 4117, 275, 486, 12067, 8, 16, 12, 378, 12, 378, 12, 5450, 9, 267, 291, 14, 1507, 637, 275, 446, 17, 339, 17160, 63, 9845, 2970, 275, 325, 15174, 339, 347, 4838, 14194, 262, 8, 277, 12, 19763, 12, 1676, 304, 267, 737, 19577, 275, 942, 267, 367, 334, 6640, 12, 4052, 4258, 315, 291, 14, 16409, 5379, 26, 288, 340, 334, 6640, 508, 283, 23801, 4117, 735, 355, 291, 14, 70, 4117, 275, 2198, 4117, 8, 10058, 9, 288, 916, 334, 6640, 508, 283, 7451, 4117, 735, 355, 291, 14, 66, 4117, 275, 2198, 4117, 8, 10058, 9, 288, 587, 26, 355, 737, 19577, 14, 740, 1332, 6640, 12, 4052, 430, 267, 291, 14, 16409, 5379, 275, 737, 19577, 267, 372, 10055, 5813, 14, 4998, 14194, 262, 8, 277, 12, 19763, 12, 1676, 9, 339, 347, 8671, 8, 277, 12, 336, 12, 519, 12, 333, 304, 267, 282, 275, 334, 87, 627, 1227, 9, 267, 1315, 275, 334, 3442, 14, 1038, 1182, 13576, 9, 267, 671, 275, 1109, 8, 2363, 1332, 82, 627, 3473, 14, 5911, 1332, 65, 627, 1315, 430, 1724, 267, 612, 275, 1109, 8, 2363, 1332, 82, 627, 3473, 14, 5197, 1332, 65, 627, 1315, 430, 1724, 267, 372, 3666, 77, 435, 671, 11865, 77, 446, 612, 430, 339, 347, 4926, 8, 277, 304, 267, 3462, 275, 291, 14, 842, 14, 890, 1252, 2063, 342, 267, 4569, 275, 291, 14, 842, 14, 890, 1252, 3333, 342, 267, 519, 275, 334, 827, 8, 2063, 12, 4569, 9, 1182, 499, 9, 267, 334, 500, 56, 12, 1284, 57, 4258, 275, 291, 14, 12063, 8, 277, 14, 1507, 637, 12, 519, 12, 519, 9, 267, 291, 14, 5485, 63, 604, 8, 82, 12, 519, 12, 1284, 56, 12, 1284, 57, 9, 339, 347, 5954, 63, 604, 8, 277, 12, 671, 16, 12, 612, 16, 12, 671, 17, 12, 612, 17, 304, 267, 20345, 1545, 275, 334, 2101, 1332, 89, 17, 446, 612, 16, 430, 690, 2853, 1332, 88, 17, 446, 671, 16, 1724, 267, 340, 20345, 1545, 26, 288, 671, 16, 12, 89, 16, 275, 612, 16, 12, 88, 16, 288, 671, 17, 12, 89, 17, 275, 612, 17, 12, 88, 17, 267, 340, 334, 88, 16, 690, 671, 17, 304, 288, 671, 16, 12, 88, 17, 275, 671, 17, 12, 88, 16, 288, 612, 16, 12, 89, 17, 275, 612, 17, 12, 89, 16, 267, 340, 334, 89, 16, 665, 612, 17, 304, 288, 19205, 2852, 275, 413, 267, 587, 26, 288, 19205, 2852, 275, 446, 17, 267, 2150, 5530, 275, 334, 88, 17, 446, 671, 16, 9, 267, 5762, 89, 275, 2853, 1332, 89, 17, 446, 612, 16, 430, 267, 1125, 275, 5868, 3136, 88, 1182, 499, 9, 267, 612, 275, 612, 16, 267, 367, 671, 315, 1425, 8, 88, 16, 12, 334, 88, 17, 435, 413, 2298, 288, 340, 20345, 1545, 26, 355, 291, 14, 842, 14, 4498, 8252, 8, 69, 8252, 8, 89, 12, 671, 12, 650, 12, 650, 395, 291, 14, 70, 4117, 9, 288, 587, 26, 355, 291, 14, 842, 14, 4498, 8252, 8, 69, 8252, 8, 88, 12, 612, 12, 650, 12, 650, 395, 291, 14, 70, 4117, 9, 288, 1125, 275, 334, 705, 435, 5762, 89, 9, 288, 340, 334, 705, 690, 378, 304, 355, 612, 275, 334, 89, 435, 19205, 2852, 9, 355, 1125, 275, 334, 705, 446, 2150, 5530, 9, 339, 347, 2896, 8, 277, 12, 4052, 304, 267, 308, 385, 275, 291, 14, 1365, 14, 585, 267, 340, 334, 10058, 59, 16, 61, 508, 291, 14, 21488, 63, 20706, 304, 288, 986, 267, 916, 291, 14, 842, 26, 288, 291, 14, 842, 14, 2384, 342, 288, 340, 334, 277, 14, 1507, 637, 1137, 308, 385, 304, 355, 291, 14, 1507, 637, 275, 308, 385, 355, 291, 14, 842, 14, 3584, 8, 277, 14, 66, 4117, 9, 355, 291, 14, 6868, 342, 339, 347, 2963, 3339, 2499, 8, 277, 12, 1256, 304, 398, 347, 2198, 2320, 8, 495, 304, 288, 334, 88, 12, 612, 4258, 275, 620, 14, 1294, 11917, 288, 372, 325, 2320, 8, 442, 8, 88, 395, 1109, 8, 89, 430, 267, 367, 334, 6640, 12, 574, 4258, 315, 291, 14, 16409, 5379, 26, 288, 340, 3666, 6640, 508, 283, 890, 358, 436, 291, 14, 842, 14, 21735, 8, 1122, 2320, 8, 585, 15206, 355, 986, 267, 291, 14, 842, 14, 3584, 8, 277, 14, 66, 4117, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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process from .ffmpeg import FFmpegPostProcessor from ..utils import ( check_executable, encodeArgument, encodeFilename, PostProcessingError, prepend_extension, shell_quote ) class EmbedThumbnailPPError(PostProcessingError): pass class EmbedThumbnailPP(FFmpegPostProcessor): def __init__(self, downloader=None, already_have_thumbnail=False): super(EmbedThumbnailPP, self).__init__(downloader) self._already_have_thumbnail = already_have_thumbnail def run(self, info): filename = info['filepath'] temp_filename = prepend_extension(filename, 'temp') if not info.get('thumbnails'): raise EmbedThumbnailPPError('Thumbnail was not found. Nothing to do.') thumbnail_filename = info['thumbnails'][-1]['filename'] if not os.path.exists(encodeFilename(thumbnail_filename)): self._downloader.report_warning( 'Skipping embedding the thumbnail because the file is missing.') return [], info if info['ext'] == 'mp3': options = [ '-c', 'copy', '-map', '0', '-map', '1', '-metadata:s:v', 'title="Album cover"', '-metadata:s:v', 'comment="Cover (Front)"'] self._downloader.to_screen('[ffmpeg] Adding thumbnail to "%s"' % filename) self.run_ffmpeg_multiple_files([filename, thumbnail_filename], temp_filename, options) if not self._already_have_thumbnail: os.remove(encodeFilename(thumbnail_filename)) os.remove(encodeFilename(filename)) os.rename(encodeFilename(temp_filename), encodeFilename(filename)) elif info['ext'] in ['m4a', 'mp4']: if not check_executable('AtomicParsley', ['-v']): raise EmbedThumbnailPPError('AtomicParsley was not found. Please install.') cmd = [encodeFilename('AtomicParsley', True), encodeFilename(filename, True), encodeArgument('--artwork'), encodeFilename(thumbnail_filename, True), encodeArgument('-o'), encodeFilename(temp_filename, True)] self._downloader.to_screen('[atomicparsley] Adding thumbnail to "%s"' % filename) if self._downloader.params.get('verbose', False): self._downloader.to_screen('[debug] AtomicParsley command line: %s' % shell_quote(cmd)) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate() if p.returncode != 0: msg = stderr.decode('utf-8', 'replace').strip() raise EmbedThumbnailPPError(msg) if not self._already_have_thumbnail: os.remove(encodeFilename(thumbnail_filename)) # for formats that don't support thumbnails (like 3gp) AtomicParsley # won't create to the temporary file if b'No changes' in stdout: self._downloader.report_warning('The file format doesn\'t support embedding a thumbnail') else: os.remove(encodeFilename(filename)) os.rename(encodeFilename(temp_filename), encodeFilename(filename)) else: raise EmbedThumbnailPPError('Only mp3 and m4a/mp4 are supported for thumbnail embedding for now.') return [], info
mit
[ 3, 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 421, 199, 646, 747, 199, 646, 3873, 199, 199, 504, 1275, 27648, 492, 25046, 16801, 6564, 10438, 199, 199, 504, 2508, 1208, 492, 334, 272, 1104, 63, 5904, 12, 272, 3752, 5201, 12, 272, 3752, 8117, 12, 272, 7711, 9589, 547, 12, 272, 18213, 63, 3435, 12, 272, 5218, 63, 3513, 199, 9, 421, 199, 533, 24297, 2719, 5820, 7701, 547, 8, 6564, 9589, 547, 304, 272, 986, 421, 199, 533, 24297, 2719, 5820, 7701, 8, 1665, 16801, 6564, 10438, 304, 272, 347, 636, 826, 721, 277, 12, 3224, 3422, 29, 403, 12, 2575, 63, 7804, 63, 8311, 29, 797, 304, 267, 1613, 8, 13200, 2719, 5820, 7701, 12, 291, 2843, 826, 721, 22846, 9, 267, 291, 423, 14039, 63, 7804, 63, 8311, 275, 2575, 63, 7804, 63, 8311, 339, 347, 1255, 8, 277, 12, 2256, 304, 267, 1788, 275, 2256, 459, 7218, 418, 267, 2388, 63, 1501, 275, 18213, 63, 3435, 8, 1501, 12, 283, 808, 358, 398, 340, 440, 2256, 14, 362, 360, 8311, 83, 735, 288, 746, 24297, 2719, 5820, 7701, 547, 360, 2719, 5820, 1990, 440, 1911, 14, 20550, 370, 886, 2659, 398, 10062, 63, 1501, 275, 2256, 459, 8311, 83, 31942, 17, 2733, 1501, 418, 398, 340, 440, 747, 14, 515, 14, 2444, 8, 2143, 8117, 8, 8311, 63, 1501, 2298, 288, 291, 423, 22846, 14, 3070, 63, 3764, 8, 355, 283, 18297, 12452, 314, 10062, 2952, 314, 570, 365, 4124, 2659, 288, 372, 990, 2256, 398, 340, 2256, 459, 832, 418, 508, 283, 311, 19, 356, 288, 1511, 275, 359, 355, 2475, 67, 297, 283, 1574, 297, 2475, 1130, 297, 283, 16, 297, 2475, 1130, 297, 283, 17, 297, 355, 2475, 2343, 26, 83, 26, 86, 297, 283, 1213, 628, 26369, 8486, 6949, 2475, 2343, 26, 83, 26, 86, 297, 283, 3349, 628, 31048, 334, 17607, 2924, 418, 953, 291, 423, 22846, 14, 475, 63, 5410, 11894, 27648, 61, 12934, 10062, 370, 2071, 83, 4507, 450, 1788, 9, 953, 291, 14, 1065, 63, 27648, 63, 6048, 63, 1725, 779, 1501, 12, 10062, 63, 1501, 467, 2388, 63, 1501, 12, 1511, 9, 953, 340, 440, 291, 423, 14039, 63, 7804, 63, 8311, 26, 355, 747, 14, 2168, 8, 2143, 8117, 8, 8311, 63, 1501, 430, 288, 747, 14, 2168, 8, 2143, 8117, 8, 1501, 430, 288, 747, 14, 8165, 8, 2143, 8117, 8, 808, 63, 1501, 395, 3752, 8117, 8, 1501, 430, 398, 916, 2256, 459, 832, 418, 315, 788, 77, 20, 65, 297, 283, 311, 20, 2565, 288, 340, 440, 1104, 63, 5904, 360, 31931, 1262, 83, 15515, 297, 11573, 86, 9090, 355, 746, 24297, 2719, 5820, 7701, 547, 360, 31931, 1262, 83, 15515, 1990, 440, 1911, 14, 7754, 3907, 2659, 953, 2088, 275, 359, 2143, 8117, 360, 31931, 1262, 83, 15515, 297, 715, 395, 673, 3752, 8117, 8, 1501, 12, 715, 395, 673, 3752, 5201, 4517, 580, 800, 659, 673, 3752, 8117, 8, 8311, 63, 1501, 12, 715, 395, 673, 3752, 5201, 3654, 79, 659, 673, 3752, 8117, 8, 808, 63, 1501, 12, 715, 1874, 953, 291, 423, 22846, 14, 475, 63, 5410, 11894, 10910, 21152, 15515, 61, 12934, 10062, 370, 2071, 83, 4507, 450, 1788, 9, 953, 340, 291, 423, 22846, 14, 1162, 14, 362, 360, 3832, 297, 756, 304, 355, 291, 423, 22846, 14, 475, 63, 5410, 11894, 1757, 61, 18840, 530, 1262, 83, 15515, 1414, 1004, 26, 450, 83, 7, 450, 5218, 63, 3513, 8, 1760, 430, 953, 299, 275, 3873, 14, 7942, 8, 1760, 12, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 9, 288, 3839, 12, 4635, 275, 299, 14, 10664, 342, 953, 340, 299, 14, 9913, 1137, 378, 26, 355, 1499, 275, 4635, 14, 2708, 360, 1624, 13, 24, 297, 283, 1814, 1959, 1913, 342, 355, 746, 24297, 2719, 5820, 7701, 547, 8, 1328, 9, 953, 340, 440, 291, 423, 14039, 63, 7804, 63, 8311, 26, 355, 747, 14, 2168, 8, 2143, 8117, 8, 8311, 63, 1501, 430, 288, 327, 367, 6752, 626, 2793, 1133, 2291, 10062, 83, 334, 2930, 650, 4927, 9, 18840, 530, 1262, 83, 15515, 288, 327, 7859, 1133, 1218, 370, 314, 7937, 570, 288, 340, 330, 7, 1944, 4493, 7, 315, 3839, 26, 355, 291, 423, 22846, 14, 3070, 63, 3764, 360, 1918, 570, 1475, 3181, 3985, 84, 2291, 12452, 282, 10062, 358, 288, 587, 26, 355, 747, 14, 2168, 8, 2143, 8117, 8, 1501, 430, 355, 747, 14, 8165, 8, 2143, 8117, 8, 808, 63, 1501, 395, 3752, 8117, 8, 1501, 430, 267, 587, 26, 288, 746, 24297, 2719, 5820, 7701, 547, 360, 5903, 6118, 19, 436, 333, 20, 65, 15, 311, 20, 787, 3748, 367, 10062, 12452, 367, 3063, 2659, 398, 372, 990, 2256, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2803, 26, 2774, 13, 24, 199, 504, 636, 2443, 363, 492, 2649, 63, 5955, 421, 199, 646, 747, 199, 646, 3873, 199, 199, 504, 1275, 27648, 492, 25046, 16801, 6564, 10438, 199, 199, 504, 2508, 1208, 492, 334, 272, 1104, 63, 5904, 12, 272, 3752, 5201, 12, 272, 3752, 8117, 12, 272, 7711, 9589, 547, 12, 272, 18213, 63, 3435, 12, 272, 5218, 63, 3513, 199, 9, 421, 199, 533, 24297, 2719, 5820, 7701, 547, 8, 6564, 9589, 547, 304, 272, 986, 421, 199, 533, 24297, 2719, 5820, 7701, 8, 1665, 16801, 6564, 10438, 304, 272, 347, 636, 826, 721, 277, 12, 3224, 3422, 29, 403, 12, 2575, 63, 7804, 63, 8311, 29, 797, 304, 267, 1613, 8, 13200, 2719, 5820, 7701, 12, 291, 2843, 826, 721, 22846, 9, 267, 291, 423, 14039, 63, 7804, 63, 8311, 275, 2575, 63, 7804, 63, 8311, 339, 347, 1255, 8, 277, 12, 2256, 304, 267, 1788, 275, 2256, 459, 7218, 418, 267, 2388, 63, 1501, 275, 18213, 63, 3435, 8, 1501, 12, 283, 808, 358, 398, 340, 440, 2256, 14, 362, 360, 8311, 83, 735, 288, 746, 24297, 2719, 5820, 7701, 547, 360, 2719, 5820, 1990, 440, 1911, 14, 20550, 370, 886, 2659, 398, 10062, 63, 1501, 275, 2256, 459, 8311, 83, 31942, 17, 2733, 1501, 418, 398, 340, 440, 747, 14, 515, 14, 2444, 8, 2143, 8117, 8, 8311, 63, 1501, 2298, 288, 291, 423, 22846, 14, 3070, 63, 3764, 8, 355, 283, 18297, 12452, 314, 10062, 2952, 314, 570, 365, 4124, 2659, 288, 372, 990, 2256, 398, 340, 2256, 459, 832, 418, 508, 283, 311, 19, 356, 288, 1511, 275, 359, 355, 2475, 67, 297, 283, 1574, 297, 2475, 1130, 297, 283, 16, 297, 2475, 1130, 297, 283, 17, 297, 355, 2475, 2343, 26, 83, 26, 86, 297, 283, 1213, 628, 26369, 8486, 6949, 2475, 2343, 26, 83, 26, 86, 297, 283, 3349, 628, 31048, 334, 17607, 2924, 418, 953, 291, 423, 22846, 14, 475, 63, 5410, 11894, 27648, 61, 12934, 10062, 370, 2071, 83, 4507, 450, 1788, 9, 953, 291, 14, 1065, 63, 27648, 63, 6048, 63, 1725, 779, 1501, 12, 10062, 63, 1501, 467, 2388, 63, 1501, 12, 1511, 9, 953, 340, 440, 291, 423, 14039, 63, 7804, 63, 8311, 26, 355, 747, 14, 2168, 8, 2143, 8117, 8, 8311, 63, 1501, 430, 288, 747, 14, 2168, 8, 2143, 8117, 8, 1501, 430, 288, 747, 14, 8165, 8, 2143, 8117, 8, 808, 63, 1501, 395, 3752, 8117, 8, 1501, 430, 398, 916, 2256, 459, 832, 418, 315, 788, 77, 20, 65, 297, 283, 311, 20, 2565, 288, 340, 440, 1104, 63, 5904, 360, 31931, 1262, 83, 15515, 297, 11573, 86, 9090, 355, 746, 24297, 2719, 5820, 7701, 547, 360, 31931, 1262, 83, 15515, 1990, 440, 1911, 14, 7754, 3907, 2659, 953, 2088, 275, 359, 2143, 8117, 360, 31931, 1262, 83, 15515, 297, 715, 395, 673, 3752, 8117, 8, 1501, 12, 715, 395, 673, 3752, 5201, 4517, 580, 800, 659, 673, 3752, 8117, 8, 8311, 63, 1501, 12, 715, 395, 673, 3752, 5201, 3654, 79, 659, 673, 3752, 8117, 8, 808, 63, 1501, 12, 715, 1874, 953, 291, 423, 22846, 14, 475, 63, 5410, 11894, 10910, 21152, 15515, 61, 12934, 10062, 370, 2071, 83, 4507, 450, 1788, 9, 953, 340, 291, 423, 22846, 14, 1162, 14, 362, 360, 3832, 297, 756, 304, 355, 291, 423, 22846, 14, 475, 63, 5410, 11894, 1757, 61, 18840, 530, 1262, 83, 15515, 1414, 1004, 26, 450, 83, 7, 450, 5218, 63, 3513, 8, 1760, 430, 953, 299, 275, 3873, 14, 7942, 8, 1760, 12, 3839, 29, 5781, 14, 6089, 12, 4635, 29, 5781, 14, 6089, 9, 288, 3839, 12, 4635, 275, 299, 14, 10664, 342, 953, 340, 299, 14, 9913, 1137, 378, 26, 355, 1499, 275, 4635, 14, 2708, 360, 1624, 13, 24, 297, 283, 1814, 1959, 1913, 342, 355, 746, 24297, 2719, 5820, 7701, 547, 8, 1328, 9, 953, 340, 440, 291, 423, 14039, 63, 7804, 63, 8311, 26, 355, 747, 14, 2168, 8, 2143, 8117, 8, 8311, 63, 1501, 430, 288, 327, 367, 6752, 626, 2793, 1133, 2291, 10062, 83, 334, 2930, 650, 4927, 9, 18840, 530, 1262, 83, 15515, 288, 327, 7859, 1133, 1218, 370, 314, 7937, 570, 288, 340, 330, 7, 1944, 4493, 7, 315, 3839, 26, 355, 291, 423, 22846, 14, 3070, 63, 3764, 360, 1918, 570, 1475, 3181, 3985, 84, 2291, 12452, 282, 10062, 358, 288, 587, 26, 355, 747, 14, 2168, 8, 2143, 8117, 8, 1501, 430, 355, 747, 14, 8165, 8, 2143, 8117, 8, 808, 63, 1501, 395, 3752, 8117, 8, 1501, 430, 267, 587, 26, 288, 746, 24297, 2719, 5820, 7701, 547, 360, 5903, 6118, 19, 436, 333, 20, 65, 15, 311, 20, 787, 3748, 367, 10062, 12452, 367, 3063, 2659, 398, 372, 990, 2256, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
debugger22/sympy
sympy/physics/quantum/operatorordering.py
98
11547
"""Functions for reordering operator expressions.""" import warnings from sympy import Add, Mul, Pow, Integer from sympy.core.compatibility import range from sympy.physics.quantum import Operator, Commutator, AntiCommutator from sympy.physics.quantum.boson import BosonOp from sympy.physics.quantum.fermion import FermionOp __all__ = [ 'normal_order', 'normal_ordered_form' ] def _expand_powers(factors): """ Helper function for normal_ordered_form and normal_order: Expand a power expression to a multiplication expression so that that the expression can be handled by the normal ordering functions. """ new_factors = [] for factor in factors.args: if (isinstance(factor, Pow) and isinstance(factor.args[1], Integer) and factor.args[1] > 0): for n in range(factor.args[1]): new_factors.append(factor.args[0]) else: new_factors.append(factor) return new_factors def _normal_ordered_form_factor(product, independent=False, recursive_limit=10, _recursive_depth=0): """ Helper function for normal_ordered_form_factor: Write multiplication expression with bosonic or fermionic operators on normally ordered form, using the bosonic and fermionic commutation relations. The resulting operator expression is equivalent to the argument, but will in general be a sum of operator products instead of a simple product. """ factors = _expand_powers(product) new_factors = [] n = 0 while n < len(factors) - 1: if isinstance(factors[n], BosonOp): # boson if not isinstance(factors[n + 1], BosonOp): new_factors.append(factors[n]) elif factors[n].is_annihilation == factors[n + 1].is_annihilation: if (independent and str(factors[n].name) > str(factors[n + 1].name)): new_factors.append(factors[n + 1]) new_factors.append(factors[n]) n += 1 else: new_factors.append(factors[n]) elif not factors[n].is_annihilation: new_factors.append(factors[n]) else: if factors[n + 1].is_annihilation: new_factors.append(factors[n]) else: if factors[n].args[0] != factors[n + 1].args[0]: if independent: c = 0 else: c = Commutator(factors[n], factors[n + 1]) new_factors.append(factors[n + 1] * factors[n] + c) else: c = Commutator(factors[n], factors[n + 1]) new_factors.append( factors[n + 1] * factors[n] + c.doit()) n += 1 elif isinstance(factors[n], FermionOp): # fermion if not isinstance(factors[n + 1], FermionOp): new_factors.append(factors[n]) elif factors[n].is_annihilation == factors[n + 1].is_annihilation: if (independent and str(factors[n].name) > str(factors[n + 1].name)): new_factors.append(factors[n + 1]) new_factors.append(factors[n]) n += 1 else: new_factors.append(factors[n]) elif not factors[n].is_annihilation: new_factors.append(factors[n]) else: if factors[n + 1].is_annihilation: new_factors.append(factors[n]) else: if factors[n].args[0] != factors[n + 1].args[0]: if independent: c = 0 else: c = AntiCommutator(factors[n], factors[n + 1]) new_factors.append(-factors[n + 1] * factors[n] + c) else: c = AntiCommutator(factors[n], factors[n + 1]) new_factors.append( -factors[n + 1] * factors[n] + c.doit()) n += 1 elif isinstance(factors[n], Operator): if isinstance(factors[n + 1], (BosonOp, FermionOp)): new_factors.append(factors[n + 1]) new_factors.append(factors[n]) n += 1 else: new_factors.append(factors[n]) else: new_factors.append(factors[n]) n += 1 if n == len(factors) - 1: new_factors.append(factors[-1]) if new_factors == factors: return product else: expr = Mul(*new_factors).expand() return normal_ordered_form(expr, recursive_limit=recursive_limit, _recursive_depth=_recursive_depth + 1, independent=independent) def _normal_ordered_form_terms(expr, independent=False, recursive_limit=10, _recursive_depth=0): """ Helper function for normal_ordered_form: loop through each term in an addition expression and call _normal_ordered_form_factor to perform the factor to an normally ordered expression. """ new_terms = [] for term in expr.args: if isinstance(term, Mul): new_term = _normal_ordered_form_factor( term, recursive_limit=recursive_limit, _recursive_depth=_recursive_depth, independent=independent) new_terms.append(new_term) else: new_terms.append(term) return Add(*new_terms) def normal_ordered_form(expr, independent=False, recursive_limit=10, _recursive_depth=0): """Write an expression with bosonic or fermionic operators on normal ordered form, where each term is normally ordered. Note that this normal ordered form is equivalent to the original expression. Parameters ========== expr : expression The expression write on normal ordered form. recursive_limit : int (default 10) The number of allowed recursive applications of the function. Examples ======== >>> from sympy.physics.quantum import Dagger >>> from sympy.physics.quantum.boson import BosonOp >>> from sympy.physics.quantum.operatorordering import normal_ordered_form >>> a = BosonOp("a") >>> normal_ordered_form(a * Dagger(a)) 1 + Dagger(a)*a """ if _recursive_depth > recursive_limit: warnings.warn("Too many recursions, aborting") return expr if isinstance(expr, Add): return _normal_ordered_form_terms(expr, recursive_limit=recursive_limit, _recursive_depth=_recursive_depth, independent=independent) elif isinstance(expr, Mul): return _normal_ordered_form_factor(expr, recursive_limit=recursive_limit, _recursive_depth=_recursive_depth, independent=independent) else: return expr def _normal_order_factor(product, recursive_limit=10, _recursive_depth=0): """ Helper function for normal_order: Normal order a multiplication expression with bosonic or fermionic operators. In general the resulting operator expression will not be equivalent to original product. """ factors = _expand_powers(product) n = 0 new_factors = [] while n < len(factors) - 1: if (isinstance(factors[n], BosonOp) and factors[n].is_annihilation): # boson if not isinstance(factors[n + 1], BosonOp): new_factors.append(factors[n]) else: if factors[n + 1].is_annihilation: new_factors.append(factors[n]) else: if factors[n].args[0] != factors[n + 1].args[0]: new_factors.append(factors[n + 1] * factors[n]) else: new_factors.append(factors[n + 1] * factors[n]) n += 1 elif (isinstance(factors[n], FermionOp) and factors[n].is_annihilation): # fermion if not isinstance(factors[n + 1], FermionOp): new_factors.append(factors[n]) else: if factors[n + 1].is_annihilation: new_factors.append(factors[n]) else: if factors[n].args[0] != factors[n + 1].args[0]: new_factors.append(-factors[n + 1] * factors[n]) else: new_factors.append(-factors[n + 1] * factors[n]) n += 1 else: new_factors.append(factors[n]) n += 1 if n == len(factors) - 1: new_factors.append(factors[-1]) if new_factors == factors: return product else: expr = Mul(*new_factors).expand() return normal_order(expr, recursive_limit=recursive_limit, _recursive_depth=_recursive_depth + 1) def _normal_order_terms(expr, recursive_limit=10, _recursive_depth=0): """ Helper function for normal_order: look through each term in an addition expression and call _normal_order_factor to perform the normal ordering on the factors. """ new_terms = [] for term in expr.args: if isinstance(term, Mul): new_term = _normal_order_factor(term, recursive_limit=recursive_limit, _recursive_depth=_recursive_depth) new_terms.append(new_term) else: new_terms.append(term) return Add(*new_terms) def normal_order(expr, recursive_limit=10, _recursive_depth=0): """Normal order an expression with bosonic or fermionic operators. Note that this normal order is not equivalent to the original expression, but the creation and annihilation operators in each term in expr is reordered so that the expression becomes normal ordered. Parameters ========== expr : expression The expression to normal order. recursive_limit : int (default 10) The number of allowed recursive applications of the function. Examples ======== >>> from sympy.physics.quantum import Dagger >>> from sympy.physics.quantum.boson import BosonOp >>> from sympy.physics.quantum.operatorordering import normal_order >>> a = BosonOp("a") >>> normal_order(a * Dagger(a)) Dagger(a)*a """ if _recursive_depth > recursive_limit: warnings.warn("Too many recursions, aborting") return expr if isinstance(expr, Add): return _normal_order_terms(expr, recursive_limit=recursive_limit, _recursive_depth=_recursive_depth) elif isinstance(expr, Mul): return _normal_order_factor(expr, recursive_limit=recursive_limit, _recursive_depth=_recursive_depth) else: return expr
bsd-3-clause
[ 624, 13967, 367, 295, 7128, 4182, 8455, 1041, 199, 199, 646, 3598, 199, 199, 504, 5840, 492, 2654, 12, 22578, 12, 510, 583, 12, 7225, 199, 504, 5840, 14, 1018, 14, 15390, 492, 1425, 199, 504, 5840, 14, 24724, 14, 25999, 492, 11013, 12, 7046, 337, 707, 12, 1626, 280, 5150, 337, 707, 199, 504, 5840, 14, 24724, 14, 25999, 14, 656, 834, 492, 699, 736, 265, 4619, 199, 504, 5840, 14, 24724, 14, 25999, 14, 2412, 77, 1636, 492, 481, 281, 77, 1636, 4619, 199, 199, 363, 452, 363, 275, 359, 272, 283, 3302, 63, 1648, 297, 272, 283, 3302, 63, 8235, 63, 964, 7, 199, 61, 421, 199, 318, 485, 4441, 63, 8278, 1192, 8, 16125, 304, 272, 408, 272, 11642, 805, 367, 3293, 63, 8235, 63, 964, 436, 3293, 63, 1648, 26, 18890, 282, 272, 7074, 3965, 370, 282, 24638, 3965, 880, 626, 626, 314, 272, 3965, 883, 506, 8860, 701, 314, 3293, 7794, 3423, 14, 272, 408, 339, 892, 63, 16125, 275, 942, 272, 367, 6535, 315, 17704, 14, 589, 26, 267, 340, 334, 6074, 8, 4778, 12, 510, 583, 9, 355, 436, 1228, 8, 4778, 14, 589, 59, 17, 467, 7225, 9, 355, 436, 6535, 14, 589, 59, 17, 61, 690, 378, 304, 288, 367, 302, 315, 1425, 8, 4778, 14, 589, 59, 17, 4682, 355, 892, 63, 16125, 14, 740, 8, 4778, 14, 589, 59, 16, 566, 267, 587, 26, 288, 892, 63, 16125, 14, 740, 8, 4778, 9, 339, 372, 892, 63, 16125, 421, 199, 318, 485, 3302, 63, 8235, 63, 964, 63, 4778, 8, 2558, 12, 12717, 29, 797, 12, 9133, 63, 3097, 29, 709, 12, 1816, 485, 9931, 63, 4631, 29, 16, 304, 272, 408, 272, 11642, 805, 367, 3293, 63, 8235, 63, 964, 63, 4778, 26, 6990, 24638, 272, 3965, 543, 330, 736, 12732, 503, 289, 281, 77, 1636, 530, 10211, 641, 12252, 7741, 1824, 12, 272, 1808, 314, 330, 736, 12732, 436, 289, 281, 77, 1636, 530, 1923, 10326, 16109, 14, 710, 9183, 272, 4182, 3965, 365, 7353, 370, 314, 1423, 12, 1325, 911, 315, 8605, 506, 272, 282, 3089, 402, 4182, 7585, 3140, 402, 282, 3486, 3336, 14, 272, 408, 339, 17704, 275, 485, 4441, 63, 8278, 1192, 8, 2558, 9, 339, 892, 63, 16125, 275, 942, 272, 302, 275, 378, 272, 1830, 302, 665, 822, 8, 16125, 9, 446, 413, 26, 398, 340, 1228, 8, 16125, 59, 78, 467, 699, 736, 265, 4619, 304, 288, 327, 330, 736, 265, 288, 340, 440, 1228, 8, 16125, 59, 78, 435, 413, 467, 699, 736, 265, 4619, 304, 355, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 953, 916, 17704, 59, 78, 1055, 374, 63, 1189, 24278, 13696, 508, 17704, 59, 78, 435, 413, 1055, 374, 63, 1189, 24278, 13696, 26, 355, 340, 334, 26083, 436, 717, 620, 8, 16125, 59, 78, 1055, 354, 9, 690, 620, 8, 16125, 59, 78, 435, 413, 1055, 354, 2298, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 435, 413, 566, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 490, 302, 847, 413, 355, 587, 26, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 953, 916, 440, 17704, 59, 78, 1055, 374, 63, 1189, 24278, 13696, 26, 355, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 953, 587, 26, 355, 340, 17704, 59, 78, 435, 413, 1055, 374, 63, 1189, 24278, 13696, 26, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 355, 587, 26, 490, 340, 17704, 59, 78, 1055, 589, 59, 16, 61, 1137, 17704, 59, 78, 435, 413, 1055, 589, 59, 16, 2189, 717, 340, 12717, 26, 1169, 286, 275, 378, 717, 587, 26, 1169, 286, 275, 7046, 337, 707, 8, 16125, 59, 78, 467, 17704, 59, 78, 435, 413, 566, 717, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 435, 413, 61, 627, 17704, 59, 78, 61, 435, 286, 9, 490, 587, 26, 717, 286, 275, 7046, 337, 707, 8, 16125, 59, 78, 467, 17704, 59, 78, 435, 413, 566, 717, 892, 63, 16125, 14, 740, 8, 1169, 17704, 59, 78, 435, 413, 61, 627, 17704, 59, 78, 61, 435, 286, 14, 19014, 1012, 490, 302, 847, 413, 398, 916, 1228, 8, 16125, 59, 78, 467, 481, 281, 77, 1636, 4619, 304, 288, 327, 289, 281, 77, 1636, 288, 340, 440, 1228, 8, 16125, 59, 78, 435, 413, 467, 481, 281, 77, 1636, 4619, 304, 355, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 953, 916, 17704, 59, 78, 1055, 374, 63, 1189, 24278, 13696, 508, 17704, 59, 78, 435, 413, 1055, 374, 63, 1189, 24278, 13696, 26, 355, 340, 334, 26083, 436, 717, 620, 8, 16125, 59, 78, 1055, 354, 9, 690, 620, 8, 16125, 59, 78, 435, 413, 1055, 354, 2298, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 435, 413, 566, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 490, 302, 847, 413, 355, 587, 26, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 953, 916, 440, 17704, 59, 78, 1055, 374, 63, 1189, 24278, 13696, 26, 355, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 953, 587, 26, 355, 340, 17704, 59, 78, 435, 413, 1055, 374, 63, 1189, 24278, 13696, 26, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 355, 587, 26, 490, 340, 17704, 59, 78, 1055, 589, 59, 16, 61, 1137, 17704, 59, 78, 435, 413, 1055, 589, 59, 16, 2189, 717, 340, 12717, 26, 1169, 286, 275, 378, 717, 587, 26, 1169, 286, 275, 1626, 280, 5150, 337, 707, 8, 16125, 59, 78, 467, 17704, 59, 78, 435, 413, 566, 717, 892, 63, 16125, 14, 740, 2801, 16125, 59, 78, 435, 413, 61, 627, 17704, 59, 78, 61, 435, 286, 9, 490, 587, 26, 717, 286, 275, 1626, 280, 5150, 337, 707, 8, 16125, 59, 78, 467, 17704, 59, 78, 435, 413, 566, 717, 892, 63, 16125, 14, 740, 8, 1169, 446, 16125, 59, 78, 435, 413, 61, 627, 17704, 59, 78, 61, 435, 286, 14, 19014, 1012, 490, 302, 847, 413, 398, 916, 1228, 8 ]
[ 13967, 367, 295, 7128, 4182, 8455, 1041, 199, 199, 646, 3598, 199, 199, 504, 5840, 492, 2654, 12, 22578, 12, 510, 583, 12, 7225, 199, 504, 5840, 14, 1018, 14, 15390, 492, 1425, 199, 504, 5840, 14, 24724, 14, 25999, 492, 11013, 12, 7046, 337, 707, 12, 1626, 280, 5150, 337, 707, 199, 504, 5840, 14, 24724, 14, 25999, 14, 656, 834, 492, 699, 736, 265, 4619, 199, 504, 5840, 14, 24724, 14, 25999, 14, 2412, 77, 1636, 492, 481, 281, 77, 1636, 4619, 199, 199, 363, 452, 363, 275, 359, 272, 283, 3302, 63, 1648, 297, 272, 283, 3302, 63, 8235, 63, 964, 7, 199, 61, 421, 199, 318, 485, 4441, 63, 8278, 1192, 8, 16125, 304, 272, 408, 272, 11642, 805, 367, 3293, 63, 8235, 63, 964, 436, 3293, 63, 1648, 26, 18890, 282, 272, 7074, 3965, 370, 282, 24638, 3965, 880, 626, 626, 314, 272, 3965, 883, 506, 8860, 701, 314, 3293, 7794, 3423, 14, 272, 408, 339, 892, 63, 16125, 275, 942, 272, 367, 6535, 315, 17704, 14, 589, 26, 267, 340, 334, 6074, 8, 4778, 12, 510, 583, 9, 355, 436, 1228, 8, 4778, 14, 589, 59, 17, 467, 7225, 9, 355, 436, 6535, 14, 589, 59, 17, 61, 690, 378, 304, 288, 367, 302, 315, 1425, 8, 4778, 14, 589, 59, 17, 4682, 355, 892, 63, 16125, 14, 740, 8, 4778, 14, 589, 59, 16, 566, 267, 587, 26, 288, 892, 63, 16125, 14, 740, 8, 4778, 9, 339, 372, 892, 63, 16125, 421, 199, 318, 485, 3302, 63, 8235, 63, 964, 63, 4778, 8, 2558, 12, 12717, 29, 797, 12, 9133, 63, 3097, 29, 709, 12, 1816, 485, 9931, 63, 4631, 29, 16, 304, 272, 408, 272, 11642, 805, 367, 3293, 63, 8235, 63, 964, 63, 4778, 26, 6990, 24638, 272, 3965, 543, 330, 736, 12732, 503, 289, 281, 77, 1636, 530, 10211, 641, 12252, 7741, 1824, 12, 272, 1808, 314, 330, 736, 12732, 436, 289, 281, 77, 1636, 530, 1923, 10326, 16109, 14, 710, 9183, 272, 4182, 3965, 365, 7353, 370, 314, 1423, 12, 1325, 911, 315, 8605, 506, 272, 282, 3089, 402, 4182, 7585, 3140, 402, 282, 3486, 3336, 14, 272, 408, 339, 17704, 275, 485, 4441, 63, 8278, 1192, 8, 2558, 9, 339, 892, 63, 16125, 275, 942, 272, 302, 275, 378, 272, 1830, 302, 665, 822, 8, 16125, 9, 446, 413, 26, 398, 340, 1228, 8, 16125, 59, 78, 467, 699, 736, 265, 4619, 304, 288, 327, 330, 736, 265, 288, 340, 440, 1228, 8, 16125, 59, 78, 435, 413, 467, 699, 736, 265, 4619, 304, 355, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 953, 916, 17704, 59, 78, 1055, 374, 63, 1189, 24278, 13696, 508, 17704, 59, 78, 435, 413, 1055, 374, 63, 1189, 24278, 13696, 26, 355, 340, 334, 26083, 436, 717, 620, 8, 16125, 59, 78, 1055, 354, 9, 690, 620, 8, 16125, 59, 78, 435, 413, 1055, 354, 2298, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 435, 413, 566, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 490, 302, 847, 413, 355, 587, 26, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 953, 916, 440, 17704, 59, 78, 1055, 374, 63, 1189, 24278, 13696, 26, 355, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 953, 587, 26, 355, 340, 17704, 59, 78, 435, 413, 1055, 374, 63, 1189, 24278, 13696, 26, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 355, 587, 26, 490, 340, 17704, 59, 78, 1055, 589, 59, 16, 61, 1137, 17704, 59, 78, 435, 413, 1055, 589, 59, 16, 2189, 717, 340, 12717, 26, 1169, 286, 275, 378, 717, 587, 26, 1169, 286, 275, 7046, 337, 707, 8, 16125, 59, 78, 467, 17704, 59, 78, 435, 413, 566, 717, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 435, 413, 61, 627, 17704, 59, 78, 61, 435, 286, 9, 490, 587, 26, 717, 286, 275, 7046, 337, 707, 8, 16125, 59, 78, 467, 17704, 59, 78, 435, 413, 566, 717, 892, 63, 16125, 14, 740, 8, 1169, 17704, 59, 78, 435, 413, 61, 627, 17704, 59, 78, 61, 435, 286, 14, 19014, 1012, 490, 302, 847, 413, 398, 916, 1228, 8, 16125, 59, 78, 467, 481, 281, 77, 1636, 4619, 304, 288, 327, 289, 281, 77, 1636, 288, 340, 440, 1228, 8, 16125, 59, 78, 435, 413, 467, 481, 281, 77, 1636, 4619, 304, 355, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 953, 916, 17704, 59, 78, 1055, 374, 63, 1189, 24278, 13696, 508, 17704, 59, 78, 435, 413, 1055, 374, 63, 1189, 24278, 13696, 26, 355, 340, 334, 26083, 436, 717, 620, 8, 16125, 59, 78, 1055, 354, 9, 690, 620, 8, 16125, 59, 78, 435, 413, 1055, 354, 2298, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 435, 413, 566, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 490, 302, 847, 413, 355, 587, 26, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 953, 916, 440, 17704, 59, 78, 1055, 374, 63, 1189, 24278, 13696, 26, 355, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 953, 587, 26, 355, 340, 17704, 59, 78, 435, 413, 1055, 374, 63, 1189, 24278, 13696, 26, 490, 892, 63, 16125, 14, 740, 8, 16125, 59, 78, 566, 355, 587, 26, 490, 340, 17704, 59, 78, 1055, 589, 59, 16, 61, 1137, 17704, 59, 78, 435, 413, 1055, 589, 59, 16, 2189, 717, 340, 12717, 26, 1169, 286, 275, 378, 717, 587, 26, 1169, 286, 275, 1626, 280, 5150, 337, 707, 8, 16125, 59, 78, 467, 17704, 59, 78, 435, 413, 566, 717, 892, 63, 16125, 14, 740, 2801, 16125, 59, 78, 435, 413, 61, 627, 17704, 59, 78, 61, 435, 286, 9, 490, 587, 26, 717, 286, 275, 1626, 280, 5150, 337, 707, 8, 16125, 59, 78, 467, 17704, 59, 78, 435, 413, 566, 717, 892, 63, 16125, 14, 740, 8, 1169, 446, 16125, 59, 78, 435, 413, 61, 627, 17704, 59, 78,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
gaddman/ansible
lib/ansible/modules/network/f5/bigiq_regkey_pool.py
3
12432
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (c) 2017 F5 Networks Inc. # GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'certified'} DOCUMENTATION = r''' --- module: bigiq_regkey_pool short_description: Manages registration key pools on BIG-IQ description: - Manages registration key (regkey) pools on a BIG-IQ. These pools function as a container in-which you will add lists of registration keys. To add registration keys, use the C(bigiq_regkey_license) module. version_added: 2.5 options: name: description: - Specifies the name of the registration key pool. - You must be mindful to name your registration pools unique names. While BIG-IQ does not require this, this module does. If you do not do this, the behavior of the module is undefined and you may end up putting licenses in the wrong registration key pool. required: True description: description: - A description to attach to the pool. state: description: - The state of the regkey pool on the system. - When C(present), guarantees that the pool exists. - When C(absent), removes the pool, and the licenses it contains, from the system. default: present choices: - absent - present requirements: - BIG-IQ >= 5.3.0 extends_documentation_fragment: f5 author: - Tim Rupp (@caphrim007) ''' EXAMPLES = r''' - name: Create a registration key (regkey) pool to hold individual device licenses bigiq_regkey_pool: name: foo-pool state: present provider: user: admin password: secret server: lb.mydomain.com delegate_to: localhost ''' RETURN = r''' description: description: New description of the regkey pool. returned: changed type: string sample: My description ''' from ansible.module_utils.basic import AnsibleModule try: from library.module_utils.network.f5.bigiq import F5RestClient from library.module_utils.network.f5.common import F5ModuleError from library.module_utils.network.f5.common import AnsibleF5Parameters from library.module_utils.network.f5.common import f5_argument_spec except ImportError: from ansible.module_utils.network.f5.bigiq import F5RestClient from ansible.module_utils.network.f5.common import F5ModuleError from ansible.module_utils.network.f5.common import AnsibleF5Parameters from ansible.module_utils.network.f5.common import f5_argument_spec class Parameters(AnsibleF5Parameters): api_map = { } api_attributes = [ 'description' ] returnables = [ 'description' ] updatables = [ 'description' ] def to_return(self): result = {} try: for returnable in self.returnables: result[returnable] = getattr(self, returnable) result = self._filter_params(result) except Exception: pass return result class ModuleParameters(Parameters): @property def uuid(self): """Returns UUID of a given name Will search for a given name and return the first one returned to us. If no name, and therefore no ID, is found, will return the string "none". The string "none" is returned because if we were to return the None value, it would cause the license loading code to append a None string to the URI; essentially asking the remote device for its collection (which we dont want and which would cause the SDK to return an False error. :return: """ collection = self.read_current_from_device() resource = next((x for x in collection if x.name == self._values['name']), None) if resource: return resource.id else: return "none" def read_current_from_device(self): uri = "https://{0}:{1}/mgmt/cm/device/licensing/pool/regkey/licenses".format( self.client.provider['server'], self.client.provider['server_port'], ) resp = self.client.api.get(uri) try: response = resp.json() except ValueError as ex: raise F5ModuleError(str(ex)) if 'code' in response and response['code'] == 400: if 'message' in response: raise F5ModuleError(response['message']) else: raise F5ModuleError(resp.content) if 'items' not in response: return [] result = [ApiParameters(params=r) for r in response['items']] return result class ApiParameters(Parameters): @property def uuid(self): return self._values['id'] class Changes(Parameters): pass class ReportableChanges(Changes): pass class UsableChanges(Changes): pass class Difference(object): def __init__(self, want, have=None): self.want = want self.have = have def compare(self, param): try: result = getattr(self, param) return result except AttributeError: return self.__default(param) def __default(self, param): attr1 = getattr(self.want, param) try: attr2 = getattr(self.have, param) if attr1 != attr2: return attr1 except AttributeError: return attr1 class ModuleManager(object): def __init__(self, *args, **kwargs): self.module = kwargs.get('module', None) self.client = kwargs.get('client', None) self.client = F5RestClient(**self.module.params) self.want = ModuleParameters(client=self.client, params=self.module.params) self.have = ApiParameters() self.changes = UsableChanges() def _set_changed_options(self): changed = {} for key in Parameters.returnables: if getattr(self.want, key) is not None: changed[key] = getattr(self.want, key) if changed: self.changes = UsableChanges(params=changed) def _update_changed_options(self): diff = Difference(self.want, self.have) updatables = Parameters.updatables changed = dict() for k in updatables: change = diff.compare(k) if change is None: continue else: if isinstance(change, dict): changed.update(change) else: changed[k] = change if changed: self.changes = Changes(params=changed) return True return False def should_update(self): result = self._update_changed_options() if result: return True return False def exec_module(self): changed = False result = dict() state = self.want.state if state == "present": changed = self.present() elif state == "absent": changed = self.absent() reportable = ReportableChanges(params=self.changes.to_return()) changes = reportable.to_return() result.update(**changes) result.update(dict(changed=changed)) self._announce_deprecations(result) return result def _announce_deprecations(self, result): warnings = result.pop('__warnings', []) for warning in warnings: self.module.deprecate( msg=warning['msg'], version=warning['version'] ) def present(self): if self.exists(): return self.update() else: return self.create() def exists(self): uri = "https://{0}:{1}/mgmt/cm/device/licensing/pool/regkey/licenses/{2}".format( self.client.provider['server'], self.client.provider['server_port'], self.want.uuid, ) resp = self.client.api.get(uri) try: response = resp.json() except ValueError: return False if resp.status == 404 or 'code' in response and response['code'] == 404: return False return True def update(self): self.have = self.read_current_from_device() if not self.should_update(): return False if self.module.check_mode: return True self.update_on_device() return True def remove(self): if self.module.check_mode: return True self.remove_from_device() if self.exists(): raise F5ModuleError("Failed to delete the resource.") return True def create(self): self._set_changed_options() if self.module.check_mode: return True self.create_on_device() return True def create_on_device(self): params = self.want.api_params() params['name'] = self.want.name uri = "https://{0}:{1}/mgmt/cm/device/licensing/pool/regkey/licenses/".format( self.client.provider['server'], self.client.provider['server_port'], ) resp = self.client.api.post(uri, json=params) try: response = resp.json() except ValueError as ex: raise F5ModuleError(str(ex)) if 'code' in response and response['code'] in [400, 403]: if 'message' in response: raise F5ModuleError(response['message']) else: raise F5ModuleError(resp.content) def update_on_device(self): params = self.changes.api_params() uri = "https://{0}:{1}/mgmt/cm/device/licensing/pool/regkey/licenses/{2}".format( self.client.provider['server'], self.client.provider['server_port'], self.want.uuid ) resp = self.client.api.patch(uri, json=params) try: response = resp.json() except ValueError as ex: raise F5ModuleError(str(ex)) if 'code' in response and response['code'] == 400: if 'message' in response: raise F5ModuleError(response['message']) else: raise F5ModuleError(resp.content) def absent(self): if self.exists(): return self.remove() return False def remove_from_device(self): uri = "https://{0}:{1}/mgmt/cm/device/licensing/pool/regkey/licenses/{2}".format( self.client.provider['server'], self.client.provider['server_port'], self.want.uuid ) resp = self.client.api.delete(uri) if resp.status == 200: return True def read_current_from_device(self): uri = "https://{0}:{1}/mgmt/cm/device/licensing/pool/regkey/licenses/{2}".format( self.client.provider['server'], self.client.provider['server_port'], self.want.uuid ) resp = self.client.api.get(uri) try: response = resp.json() except ValueError as ex: raise F5ModuleError(str(ex)) if 'code' in response and response['code'] == 400: if 'message' in response: raise F5ModuleError(response['message']) else: raise F5ModuleError(resp.content) return ApiParameters(params=response) class ArgumentSpec(object): def __init__(self): self.supports_check_mode = True argument_spec = dict( name=dict(required=True), description=dict(), state=dict( default='present', choices=['absent', 'present'] ) ) self.argument_spec = {} self.argument_spec.update(f5_argument_spec) self.argument_spec.update(argument_spec) def main(): spec = ArgumentSpec() module = AnsibleModule( argument_spec=spec.argument_spec, supports_check_mode=spec.supports_check_mode, ) try: mm = ModuleManager(module=module) results = mm.exec_module() module.exit_json(**results) except F5ModuleError as ex: module.fail_json(msg=str(ex)) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 9708, 481, 21, 17138, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 2247, 8981, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 7282, 9962, 63, 1135, 498, 63, 2293, 199, 3612, 63, 1802, 26, 21612, 10991, 790, 20092, 641, 16524, 13, 23559, 199, 1802, 26, 523, 446, 21612, 10991, 790, 334, 1135, 498, 9, 20092, 641, 282, 16524, 13, 23559, 14, 5723, 20092, 805, 465, 272, 282, 3970, 315, 13, 6777, 1265, 911, 1050, 5548, 402, 10991, 2883, 14, 4005, 1050, 10991, 272, 2883, 12, 675, 314, 445, 8, 5076, 9962, 63, 1135, 498, 63, 1682, 9, 859, 14, 199, 1023, 63, 3270, 26, 499, 14, 21, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 11015, 314, 536, 402, 314, 10991, 790, 4203, 14, 489, 446, 2047, 1471, 506, 25169, 1893, 370, 536, 2195, 10991, 20092, 3747, 1561, 14, 22117, 267, 16524, 13, 23559, 1630, 440, 4409, 642, 12, 642, 859, 1630, 14, 982, 1265, 886, 440, 886, 642, 12, 267, 314, 5953, 402, 314, 859, 365, 10942, 436, 1265, 1443, 1284, 1536, 32670, 267, 12378, 315, 314, 6835, 10991, 790, 4203, 14, 272, 1415, 26, 715, 523, 1369, 26, 272, 1369, 26, 489, 446, 437, 1369, 370, 6554, 370, 314, 4203, 14, 523, 1174, 26, 272, 1369, 26, 489, 446, 710, 1174, 402, 314, 1295, 498, 4203, 641, 314, 2656, 14, 489, 446, 3979, 445, 8, 1881, 395, 12072, 397, 626, 314, 4203, 3495, 14, 489, 446, 3979, 445, 8, 5575, 395, 14185, 314, 4203, 12, 436, 314, 12378, 652, 3509, 12, 687, 314, 267, 2656, 14, 272, 849, 26, 3451, 272, 3415, 26, 489, 446, 9552, 489, 446, 3451, 199, 7538, 26, 523, 446, 16524, 13, 23559, 2356, 959, 14, 19, 14, 16, 199, 11036, 63, 9970, 63, 7677, 26, 289, 21, 199, 2502, 26, 523, 446, 26244, 820, 384, 80, 8593, 2874, 72, 31898, 8255, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2790, 282, 10991, 790, 334, 1135, 498, 9, 4203, 370, 10266, 8212, 2243, 12378, 523, 7282, 9962, 63, 1135, 498, 63, 2293, 26, 272, 536, 26, 3925, 13, 2293, 272, 1174, 26, 3451, 272, 5022, 26, 489, 922, 26, 4628, 489, 2505, 26, 7565, 489, 1654, 26, 11104, 14, 30945, 14, 957, 523, 13080, 63, 475, 26, 11667, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 1802, 26, 523, 1369, 26, 7053, 1369, 402, 314, 1295, 498, 4203, 14, 523, 2138, 26, 2896, 523, 730, 26, 1059, 523, 2690, 26, 4932, 1369, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 199, 893, 26, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 5076, 9962, 492, 481, 21, 13726, 3041, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 2622, 38, 21, 5976, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 289, 21, 63, 2094, 63, 1650, 199, 2590, 3545, 26, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 5076, 9962, 492, 481, 21, 13726, 3041, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 2622, 38, 21, 5976, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 289, 21, 63, 2094, 63, 1650, 421, 199, 533, 3897, 8, 10047, 38, 21, 5976, 304, 272, 2986, 63, 1130, 275, 469, 339, 789, 339, 2986, 63, 2987, 275, 359, 267, 283, 1802, 7, 272, 1622, 339, 372, 5921, 275, 359, 267, 283, 1802, 7, 272, 1622, 339, 1536, 4616, 5921, 275, 359, 267, 283, 1802, 7, 272, 1622, 339, 347, 370, 63, 1107, 8, 277, 304, 267, 754, 275, 1052, 267, 862, 26, 288, 367, 372, 461, 315, 291, 14, 1107, 5921, 26, 355, 754, 59, 1107, 461, 61, 275, 2519, 8, 277, 12, 372, 461, 9, 288, 754, 275, 291, 423, 1541, 63, 1162, 8, 1099, 9, 267, 871, 2186, 26, 288, 986, 267, 372, 754, 421, 199, 533, 5673, 5976, 8, 5976, 304, 272, 768, 1829, 272, 347, 5377, 8, 277, 304, 267, 408, 3407, 11134, 402, 282, 1627, 536, 398, 12823, 2754, 367, 282, 1627, 536, 436, 372, 314, 1642, 1373, 2138, 370, 2739, 14, 982, 949, 536, 12, 267, 436, 16119, 949, 2870, 12, 365, 1911, 12, 911, 372, 314, 1059, 298, 3592, 1674, 710, 1059, 298, 3592, 2, 267, 365, 2138, 2952, 340, 781, 4898, 370, 372, 314, 488, 574, 12, 652, 3955, 7675, 314, 267, 4190, 8697, 1233, 370, 5666, 282, 488, 1059, 370, 314, 9022, 27, 28891, 7198, 316, 314, 267, 3982, 2243, 367, 2399, 3245, 334, 6777, 781, 21542, 2934, 436, 1314, 3955, 7675, 314, 15610, 267, 370, 372, 376, 756, 1125, 14, 398, 520, 1107, 26, 267, 408, 267, 3245, 275, 291, 14, 739, 63, 1818, 63, 504, 63, 1782, 342, 267, 2073, 275, 2163, 1332, 88, 367, 671, 315, 3245, 340, 671, 14, 354, 508, 291, 423, 1459, 459, 354, 3815, 488, 9, 267, 340, 2073, 26, 288, 372, 2073, 14, 344, 267, 587, 26, 288, 372, 298, 3592, 2, 339, 347, 1586, 63, 1818, 63, 504, 63, 1782, 8, 277, 304, 267, 5108, 275, 298, 2859, 20193, 16, 16495, 17, 5995, 9752, 15, 4400, 15, 1782, 15, 606 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 199, 3, 1898, 334, 67, 9, 9708, 481, 21, 17138, 3277, 14, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 2247, 8981, 936, 199, 199, 8948, 275, 519, 2344, 199, 2595, 199, 578, 26, 7282, 9962, 63, 1135, 498, 63, 2293, 199, 3612, 63, 1802, 26, 21612, 10991, 790, 20092, 641, 16524, 13, 23559, 199, 1802, 26, 523, 446, 21612, 10991, 790, 334, 1135, 498, 9, 20092, 641, 282, 16524, 13, 23559, 14, 5723, 20092, 805, 465, 272, 282, 3970, 315, 13, 6777, 1265, 911, 1050, 5548, 402, 10991, 2883, 14, 4005, 1050, 10991, 272, 2883, 12, 675, 314, 445, 8, 5076, 9962, 63, 1135, 498, 63, 1682, 9, 859, 14, 199, 1023, 63, 3270, 26, 499, 14, 21, 199, 1419, 26, 523, 536, 26, 272, 1369, 26, 489, 446, 11015, 314, 536, 402, 314, 10991, 790, 4203, 14, 489, 446, 2047, 1471, 506, 25169, 1893, 370, 536, 2195, 10991, 20092, 3747, 1561, 14, 22117, 267, 16524, 13, 23559, 1630, 440, 4409, 642, 12, 642, 859, 1630, 14, 982, 1265, 886, 440, 886, 642, 12, 267, 314, 5953, 402, 314, 859, 365, 10942, 436, 1265, 1443, 1284, 1536, 32670, 267, 12378, 315, 314, 6835, 10991, 790, 4203, 14, 272, 1415, 26, 715, 523, 1369, 26, 272, 1369, 26, 489, 446, 437, 1369, 370, 6554, 370, 314, 4203, 14, 523, 1174, 26, 272, 1369, 26, 489, 446, 710, 1174, 402, 314, 1295, 498, 4203, 641, 314, 2656, 14, 489, 446, 3979, 445, 8, 1881, 395, 12072, 397, 626, 314, 4203, 3495, 14, 489, 446, 3979, 445, 8, 5575, 395, 14185, 314, 4203, 12, 436, 314, 12378, 652, 3509, 12, 687, 314, 267, 2656, 14, 272, 849, 26, 3451, 272, 3415, 26, 489, 446, 9552, 489, 446, 3451, 199, 7538, 26, 523, 446, 16524, 13, 23559, 2356, 959, 14, 19, 14, 16, 199, 11036, 63, 9970, 63, 7677, 26, 289, 21, 199, 2502, 26, 523, 446, 26244, 820, 384, 80, 8593, 2874, 72, 31898, 8255, 9, 199, 2344, 199, 199, 8918, 275, 519, 2344, 199, 13, 536, 26, 2790, 282, 10991, 790, 334, 1135, 498, 9, 4203, 370, 10266, 8212, 2243, 12378, 523, 7282, 9962, 63, 1135, 498, 63, 2293, 26, 272, 536, 26, 3925, 13, 2293, 272, 1174, 26, 3451, 272, 5022, 26, 489, 922, 26, 4628, 489, 2505, 26, 7565, 489, 1654, 26, 11104, 14, 30945, 14, 957, 523, 13080, 63, 475, 26, 11667, 199, 2344, 199, 199, 9677, 275, 519, 2344, 199, 1802, 26, 523, 1369, 26, 7053, 1369, 402, 314, 1295, 498, 4203, 14, 523, 2138, 26, 2896, 523, 730, 26, 1059, 523, 2690, 26, 4932, 1369, 199, 2344, 199, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 199, 893, 26, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 5076, 9962, 492, 481, 21, 13726, 3041, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 2622, 38, 21, 5976, 272, 687, 3555, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 289, 21, 63, 2094, 63, 1650, 199, 2590, 3545, 26, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 5076, 9962, 492, 481, 21, 13726, 3041, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 481, 21, 12232, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 2622, 38, 21, 5976, 272, 687, 3242, 14, 578, 63, 1208, 14, 1200, 14, 70, 21, 14, 2330, 492, 289, 21, 63, 2094, 63, 1650, 421, 199, 533, 3897, 8, 10047, 38, 21, 5976, 304, 272, 2986, 63, 1130, 275, 469, 339, 789, 339, 2986, 63, 2987, 275, 359, 267, 283, 1802, 7, 272, 1622, 339, 372, 5921, 275, 359, 267, 283, 1802, 7, 272, 1622, 339, 1536, 4616, 5921, 275, 359, 267, 283, 1802, 7, 272, 1622, 339, 347, 370, 63, 1107, 8, 277, 304, 267, 754, 275, 1052, 267, 862, 26, 288, 367, 372, 461, 315, 291, 14, 1107, 5921, 26, 355, 754, 59, 1107, 461, 61, 275, 2519, 8, 277, 12, 372, 461, 9, 288, 754, 275, 291, 423, 1541, 63, 1162, 8, 1099, 9, 267, 871, 2186, 26, 288, 986, 267, 372, 754, 421, 199, 533, 5673, 5976, 8, 5976, 304, 272, 768, 1829, 272, 347, 5377, 8, 277, 304, 267, 408, 3407, 11134, 402, 282, 1627, 536, 398, 12823, 2754, 367, 282, 1627, 536, 436, 372, 314, 1642, 1373, 2138, 370, 2739, 14, 982, 949, 536, 12, 267, 436, 16119, 949, 2870, 12, 365, 1911, 12, 911, 372, 314, 1059, 298, 3592, 1674, 710, 1059, 298, 3592, 2, 267, 365, 2138, 2952, 340, 781, 4898, 370, 372, 314, 488, 574, 12, 652, 3955, 7675, 314, 267, 4190, 8697, 1233, 370, 5666, 282, 488, 1059, 370, 314, 9022, 27, 28891, 7198, 316, 314, 267, 3982, 2243, 367, 2399, 3245, 334, 6777, 781, 21542, 2934, 436, 1314, 3955, 7675, 314, 15610, 267, 370, 372, 376, 756, 1125, 14, 398, 520, 1107, 26, 267, 408, 267, 3245, 275, 291, 14, 739, 63, 1818, 63, 504, 63, 1782, 342, 267, 2073, 275, 2163, 1332, 88, 367, 671, 315, 3245, 340, 671, 14, 354, 508, 291, 423, 1459, 459, 354, 3815, 488, 9, 267, 340, 2073, 26, 288, 372, 2073, 14, 344, 267, 587, 26, 288, 372, 298, 3592, 2, 339, 347, 1586, 63, 1818, 63, 504, 63, 1782, 8, 277, 304, 267, 5108, 275, 298, 2859, 20193, 16, 16495, 17, 5995, 9752, 15, 4400, 15, 1782, 15, 606, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
nomadcube/scikit-learn
examples/bicluster/plot_spectral_coclustering.py
276
1736
""" ============================================== A demo of the Spectral Co-Clustering algorithm ============================================== This example demonstrates how to generate a dataset and bicluster it using the the Spectral Co-Clustering algorithm. The dataset is generated using the ``make_biclusters`` function, which creates a matrix of small values and implants bicluster with large values. The rows and columns are then shuffled and passed to the Spectral Co-Clustering algorithm. Rearranging the shuffled matrix to make biclusters contiguous shows how accurately the algorithm found the biclusters. """ print(__doc__) # Author: Kemal Eren <kemal@kemaleren.com> # License: BSD 3 clause import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import make_biclusters from sklearn.datasets import samples_generator as sg from sklearn.cluster.bicluster import SpectralCoclustering from sklearn.metrics import consensus_score data, rows, columns = make_biclusters( shape=(300, 300), n_clusters=5, noise=5, shuffle=False, random_state=0) plt.matshow(data, cmap=plt.cm.Blues) plt.title("Original dataset") data, row_idx, col_idx = sg._shuffle(data, random_state=0) plt.matshow(data, cmap=plt.cm.Blues) plt.title("Shuffled dataset") model = SpectralCoclustering(n_clusters=5, random_state=0) model.fit(data) score = consensus_score(model.biclusters_, (rows[:, row_idx], columns[:, col_idx])) print("consensus score: {:.3f}".format(score)) fit_data = data[np.argsort(model.row_labels_)] fit_data = fit_data[:, np.argsort(model.column_labels_)] plt.matshow(fit_data, cmap=plt.cm.Blues) plt.title("After biclustering; rearranged to show biclusters") plt.show()
bsd-3-clause
[ 624, 199, 2486, 17224, 199, 33, 14779, 402, 314, 428, 15832, 1849, 13, 31174, 5563, 199, 2486, 17224, 199, 199, 2765, 2893, 23789, 31216, 4212, 370, 3550, 282, 4789, 436, 12111, 4201, 652, 199, 4941, 314, 314, 428, 15832, 1849, 13, 31174, 5563, 14, 199, 199, 1918, 4789, 365, 4046, 1808, 314, 1124, 1875, 63, 4492, 9170, 1040, 805, 12, 1314, 199, 28219, 282, 3634, 402, 7425, 1338, 436, 11512, 2285, 12111, 4201, 543, 7031, 199, 1459, 14, 710, 4730, 436, 4362, 787, 2066, 28126, 1146, 436, 3032, 370, 314, 199, 51, 15832, 1849, 13, 31174, 5563, 14, 799, 5250, 8544, 314, 28126, 1146, 3634, 370, 199, 1875, 12111, 9170, 26611, 13703, 4212, 1066, 895, 13824, 314, 5563, 1911, 199, 1589, 12111, 9170, 14, 199, 199, 624, 199, 1361, 3460, 1301, 3368, 199, 199, 3, 6529, 26, 25645, 2174, 662, 828, 665, 415, 2174, 32, 415, 17667, 828, 14, 957, 30, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 2680, 465, 980, 199, 504, 8027, 492, 1134, 2798, 465, 4488, 199, 199, 504, 6357, 14, 12281, 492, 1852, 63, 4492, 9170, 199, 504, 6357, 14, 12281, 492, 5845, 63, 4679, 465, 12578, 199, 504, 6357, 14, 4201, 14, 4492, 4201, 492, 428, 15832, 967, 25802, 199, 504, 6357, 14, 6759, 492, 406, 31664, 63, 3397, 199, 199, 576, 12, 4730, 12, 4362, 275, 1852, 63, 4492, 9170, 8, 272, 2215, 2687, 5863, 12, 9601, 395, 302, 63, 9170, 29, 21, 12, 11145, 29, 21, 12, 272, 13031, 29, 797, 12, 2196, 63, 929, 29, 16, 9, 199, 199, 6003, 14, 569, 2384, 8, 576, 12, 14920, 29, 6003, 14, 4400, 14, 24613, 10138, 9, 199, 6003, 14, 1213, 480, 17286, 4789, 531, 199, 199, 576, 12, 1962, 63, 2996, 12, 1048, 63, 2996, 275, 12578, 423, 11777, 8, 576, 12, 2196, 63, 929, 29, 16, 9, 199, 6003, 14, 569, 2384, 8, 576, 12, 14920, 29, 6003, 14, 4400, 14, 24613, 10138, 9, 199, 6003, 14, 1213, 480, 2662, 3043, 1146, 4789, 531, 199, 199, 1238, 275, 428, 15832, 967, 25802, 8, 78, 63, 9170, 29, 21, 12, 2196, 63, 929, 29, 16, 9, 199, 1238, 14, 3269, 8, 576, 9, 199, 3397, 275, 406, 31664, 63, 3397, 8, 1238, 14, 4492, 9170, 3131, 717, 334, 3838, 3981, 1962, 63, 2996, 467, 4362, 3981, 1048, 63, 2996, 2459, 199, 199, 1361, 480, 388, 31664, 5396, 26, 469, 14010, 19, 70, 5469, 908, 8, 3397, 430, 199, 199, 3269, 63, 576, 275, 666, 59, 1590, 14, 20188, 8, 1238, 14, 1143, 63, 3512, 63, 1874, 199, 3269, 63, 576, 275, 5542, 63, 576, 3981, 980, 14, 20188, 8, 1238, 14, 2301, 63, 3512, 63, 1874, 199, 199, 6003, 14, 569, 2384, 8, 3269, 63, 576, 12, 14920, 29, 6003, 14, 4400, 14, 24613, 10138, 9, 199, 6003, 14, 1213, 480, 10881, 12111, 25802, 27, 295, 285, 1842, 68, 370, 2498, 12111, 9170, 531, 199, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 199, 2486, 17224, 199, 33, 14779, 402, 314, 428, 15832, 1849, 13, 31174, 5563, 199, 2486, 17224, 199, 199, 2765, 2893, 23789, 31216, 4212, 370, 3550, 282, 4789, 436, 12111, 4201, 652, 199, 4941, 314, 314, 428, 15832, 1849, 13, 31174, 5563, 14, 199, 199, 1918, 4789, 365, 4046, 1808, 314, 1124, 1875, 63, 4492, 9170, 1040, 805, 12, 1314, 199, 28219, 282, 3634, 402, 7425, 1338, 436, 11512, 2285, 12111, 4201, 543, 7031, 199, 1459, 14, 710, 4730, 436, 4362, 787, 2066, 28126, 1146, 436, 3032, 370, 314, 199, 51, 15832, 1849, 13, 31174, 5563, 14, 799, 5250, 8544, 314, 28126, 1146, 3634, 370, 199, 1875, 12111, 9170, 26611, 13703, 4212, 1066, 895, 13824, 314, 5563, 1911, 199, 1589, 12111, 9170, 14, 199, 199, 624, 199, 1361, 3460, 1301, 3368, 199, 199, 3, 6529, 26, 25645, 2174, 662, 828, 665, 415, 2174, 32, 415, 17667, 828, 14, 957, 30, 199, 3, 844, 26, 6289, 650, 8502, 199, 199, 646, 2680, 465, 980, 199, 504, 8027, 492, 1134, 2798, 465, 4488, 199, 199, 504, 6357, 14, 12281, 492, 1852, 63, 4492, 9170, 199, 504, 6357, 14, 12281, 492, 5845, 63, 4679, 465, 12578, 199, 504, 6357, 14, 4201, 14, 4492, 4201, 492, 428, 15832, 967, 25802, 199, 504, 6357, 14, 6759, 492, 406, 31664, 63, 3397, 199, 199, 576, 12, 4730, 12, 4362, 275, 1852, 63, 4492, 9170, 8, 272, 2215, 2687, 5863, 12, 9601, 395, 302, 63, 9170, 29, 21, 12, 11145, 29, 21, 12, 272, 13031, 29, 797, 12, 2196, 63, 929, 29, 16, 9, 199, 199, 6003, 14, 569, 2384, 8, 576, 12, 14920, 29, 6003, 14, 4400, 14, 24613, 10138, 9, 199, 6003, 14, 1213, 480, 17286, 4789, 531, 199, 199, 576, 12, 1962, 63, 2996, 12, 1048, 63, 2996, 275, 12578, 423, 11777, 8, 576, 12, 2196, 63, 929, 29, 16, 9, 199, 6003, 14, 569, 2384, 8, 576, 12, 14920, 29, 6003, 14, 4400, 14, 24613, 10138, 9, 199, 6003, 14, 1213, 480, 2662, 3043, 1146, 4789, 531, 199, 199, 1238, 275, 428, 15832, 967, 25802, 8, 78, 63, 9170, 29, 21, 12, 2196, 63, 929, 29, 16, 9, 199, 1238, 14, 3269, 8, 576, 9, 199, 3397, 275, 406, 31664, 63, 3397, 8, 1238, 14, 4492, 9170, 3131, 717, 334, 3838, 3981, 1962, 63, 2996, 467, 4362, 3981, 1048, 63, 2996, 2459, 199, 199, 1361, 480, 388, 31664, 5396, 26, 469, 14010, 19, 70, 5469, 908, 8, 3397, 430, 199, 199, 3269, 63, 576, 275, 666, 59, 1590, 14, 20188, 8, 1238, 14, 1143, 63, 3512, 63, 1874, 199, 3269, 63, 576, 275, 5542, 63, 576, 3981, 980, 14, 20188, 8, 1238, 14, 2301, 63, 3512, 63, 1874, 199, 199, 6003, 14, 569, 2384, 8, 3269, 63, 576, 12, 14920, 29, 6003, 14, 4400, 14, 24613, 10138, 9, 199, 6003, 14, 1213, 480, 10881, 12111, 25802, 27, 295, 285, 1842, 68, 370, 2498, 12111, 9170, 531, 199, 199, 6003, 14, 2384, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
chrisspen/dtree
dtree.py
1
68634
""" 2012.1.24 CKS Algorithms for building and using a decision tree for classification or regression. """ from __future__ import print_function from collections import defaultdict from decimal import Decimal from pprint import pprint import copy import csv import math from math import pi import os import random import re import unittest import pickle VERSION = (2, 0, 0) __version__ = '.'.join(map(str, VERSION)) # Traditional entropy. ENTROPY1 = 'entropy1' # Modified entropy that penalizes universally unique values. ENTROPY2 = 'entropy2' # Modified entropy that penalizes universally unique values # as well as features with large numbers of values. ENTROPY3 = 'entropy3' DISCRETE_METRICS = [ ENTROPY1, ENTROPY2, ENTROPY3, ] # Simple statistical variance, the measure of how far a set of numbers # is spread out. VARIANCE1 = 'variance1' # Like ENTROPY2, is the variance weighted to penalize attributes with # universally unique values. VARIANCE2 = 'variance2' CONTINUOUS_METRICS = [ VARIANCE1, VARIANCE2, ] DEFAULT_DISCRETE_METRIC = ENTROPY1 DEFAULT_CONTINUOUS_METRIC = VARIANCE1 # Methods for aggregating the predictions of trees in a forest. EQUAL_MEAN = 'equal-mean' WEIGHTED_MEAN = 'weighted-mean' BEST = 'best' AGGREGATION_METHODS = [ EQUAL_MEAN, WEIGHTED_MEAN, BEST, ] # Forest growth algorithms. GROW_RANDOM = 'random' GROW_AUTO_MINI_BATCH = 'auto-mini-batch' GROW_AUTO_INCREMENTAL = 'auto-incremental' GROW_METHODS = [ GROW_RANDOM, GROW_AUTO_MINI_BATCH, GROW_AUTO_INCREMENTAL, ] # Data format names. ATTR_TYPE_NOMINAL = NOM = 'nominal' ATTR_TYPE_DISCRETE = DIS = 'discrete' ATTR_TYPE_CONTINUOUS = CON = 'continuous' ATTR_MODE_CLASS = CLS = 'class' ATTR_HEADER_PATTERN = re.compile("([^,:]+):(nominal|discrete|continuous)(?::(class))?") def get_mean(seq): """ Batch mean calculation. """ return sum(seq)/float(len(seq)) def get_variance(seq): """ Batch variance calculation. """ m = get_mean(seq) return sum((v-m)**2 for v in seq)/float(len(seq)) def standard_deviation(seq): return math.sqrt(get_variance(seq)) def mean_absolute_error(seq, correct): """ Batch mean absolute error calculation. """ assert len(seq) == len(correct) diffs = [abs(a-b) for a, b in zip(seq, correct)] return sum(diffs)/float(len(diffs)) def normalize(seq): """ Scales each number in the sequence so that the sum of all numbers equals 1. """ s = float(sum(seq)) return [v/s for v in seq] def erfcc(x): """ Complementary error function. """ z = abs(x) t = 1. / (1. + 0.5*z) r = t * math.exp(-z*z-1.26551223+t*(1.00002368+t*(.37409196+ t*(.09678418+t*(-.18628806+t*(.27886807+ t*(-1.13520398+t*(1.48851587+t*(-.82215223+ t*.17087277))))))))) if (x >= 0.): return r else: return 2. - r def normcdf(x, mu, sigma): """ Describes the probability that a real-valued random variable X with a given probability distribution will be found at a value less than or equal to X in a normal distribution. http://en.wikipedia.org/wiki/Cumulative_distribution_function """ t = x-mu y = 0.5*erfcc(-t/(sigma*math.sqrt(2.0))) if y > 1.0: y = 1.0 return y def normpdf(x, mu, sigma): """ Describes the relative likelihood that a real-valued random variable X will take on a given value. http://en.wikipedia.org/wiki/Probability_density_function """ u = (x-mu)/abs(sigma) y = (1/(math.sqrt(2*pi)*abs(sigma)))*math.exp(-u*u/2) return y def normdist(x, mu, sigma, f=True): if f: y = normcdf(x, mu, sigma) else: y = normpdf(x, mu, sigma) return y def normrange(x1, x2, mu, sigma, f=True): p1 = normdist(x1, mu, sigma, f) p2 = normdist(x2, mu, sigma, f) return abs(p1-p2) def cmp(a, b): # pylint: disable=redefined-builtin return (a > b) - (a < b) class DDist: """ Incrementally tracks the probability distribution of discrete elements. """ def __init__(self, seq=None): self.clear() if seq: for k in seq: self.counts[k] += 1 self.total += 1 def __cmp__(self, other): if not isinstance(other, type(self)): return NotImplemented return cmp( (frozenset(self.counts.items()), self.total), (frozenset(other.counts.items()), other.total) ) def __eq__(self, other): if not isinstance(other, type(self)): return NotImplemented return (frozenset(self.counts.items()), self.total) == \ (frozenset(other.counts.items()), other.total) def __getitem__(self, k): """ Returns the probability for the given element. """ cnt = 0 if k in self.counts: cnt = self.counts[k] return cnt/float(self.total) def __hash__(self): return hash((frozenset(self.counts.items()), self.total)) def __repr__(self): s = [] for k, prob in self.probs: s.append("%s=%s" % (k, prob)) return "<%s %s>" % (type(self).__name__, ', '.join(s)) def add(self, k, count=1): """ Increments the count for the given element. """ self.counts[k] += count self.total += count @property def best(self): """ Returns the element with the highest probability. """ b = (-1e999999, None) for k, c in self.counts.items(): b = max(b, (c, k)) return b[1] @property def best_prob(self): probs = self.probs if not probs: return best = -1e999999 for _, prob in probs: best = max(best, prob) return best def clear(self): self.counts = defaultdict(int) self.total = 0 def copy(self): return copy.deepcopy(self) @property def count(self): """ The total number of samples forming this distribution. """ return self.total def keys(self): return self.counts.keys() @property def probs(self): """ Returns a list of probabilities for all elements in the form [(value1,prob1),(value2,prob2),...]. """ return [ (k, self.counts[k]/float(self.total)) for k in self.counts.keys() ] def update(self, dist): """ Adds the given distribution's counts to the current distribution. """ assert isinstance(dist, DDist) for k, c in dist.counts.items(): self.counts[k] += c self.total += dist.total class CDist: """ Incrementally tracks the probability distribution of continuous numbers. """ def __init__(self, seq=None, mean=None, var=None, stdev=None): self.clear() if mean is not None: self.mean_sum = mean self.mean_count = 1 if var is not None: self.last_variance = var self.mean_count = 1 if stdev is not None: self.last_variance = stdev**2 self.mean_count = 1 if seq: for n in seq: self += n def clear(self): self.mean_sum = 0 self.mean_count = 0 self.last_variance = 0 def copy(self): return copy.deepcopy(self) def __repr__(self): return "<%s mean=%s variance=%s>" % (type(self).__name__, self.mean, self.variance) def __iadd__(self, value): last_mean = self.mean self.mean_sum += value self.mean_count += 1 if last_mean is not None: self.last_variance = self.last_variance \ + (value - last_mean)*(value - self.mean) return self @property def count(self): """ The total number of samples forming this distribution. """ return self.mean_count @property def mean(self): if self.mean_count: return self.mean_sum/float(self.mean_count) @property def variance(self): if self.mean_count: return self.last_variance/float(self.mean_count) @property def standard_deviation(self): var = self.variance if var is None: return return math.sqrt(var) def probability_lt(self, x): """ Returns the probability of a random variable being less than the given value. """ if self.mean is None: return return normdist(x=x, mu=self.mean, sigma=self.standard_deviation) def probability_in(self, a, b): """ Returns the probability of a random variable falling between the given values. """ if self.mean is None: return p1 = normdist(x=a, mu=self.mean, sigma=self.standard_deviation) p2 = normdist(x=b, mu=self.mean, sigma=self.standard_deviation) return abs(p1 - p2) def probability_gt(self, x): """ Returns the probability of a random variable being greater than the given value. """ if self.mean is None: return p = normdist(x=x, mu=self.mean, sigma=self.standard_deviation) return 1-p def entropy(data, class_attr=None, method=DEFAULT_DISCRETE_METRIC): """ Calculates the entropy of the attribute attr in given data set data. Parameters: data<dict|list> := if dict, treated as value counts of the given attribute name if list, treated as a raw list from which the value counts will be generated attr<string> := the name of the class attribute """ assert (class_attr is None and isinstance(data, dict)) or (class_attr is not None and isinstance(data, list)) if isinstance(data, dict): counts = data else: counts = defaultdict(float) # {attr:count} for record in data: # Note: A missing attribute is treated like an attribute with a value # of None, representing the attribute is "irrelevant". counts[record.get(class_attr)] += 1.0 len_data = float(sum(cnt for _, cnt in counts.items())) n = max(2, len(counts)) total = float(sum(counts.values())) assert total, "There must be at least one non-zero count." if method == ENTROPY1: return -sum((count/len_data)*math.log(count/len_data, n) for count in counts.values() if count) elif method == ENTROPY2: return -sum((count/len_data)*math.log(count/len_data, n) for count in counts.values() if count) - ((len(counts)-1)/float(total)) elif method == ENTROPY3: return -sum((count/len_data)*math.log(count/len_data, n) for count in counts.values() if count) - 100*((len(counts)-1)/float(total)) else: raise Exception("Unknown entropy method %s." % method) def entropy_variance(data, class_attr=None, method=DEFAULT_CONTINUOUS_METRIC): """ Calculates the variance fo a continuous class attribute, to be used as an entropy metric. """ assert method in CONTINUOUS_METRICS, "Unknown entropy variance metric: %s" % (method,) assert (class_attr is None and isinstance(data, dict)) or (class_attr is not None and isinstance(data, list)) if isinstance(data, dict): lst = data else: lst = [record.get(class_attr) for record in data] return get_variance(lst) def get_gain(data, attr, class_attr, method=DEFAULT_DISCRETE_METRIC, only_sub=0, prefer_fewer_values=False, entropy_func=None): """ Calculates the information gain (reduction in entropy) that would result by splitting the data on the chosen attribute (attr). Parameters: prefer_fewer_values := Weights the gain by the count of the attribute's unique values. If multiple attributes have the same gain, but one has slightly fewer attributes, this will cause the one with fewer attributes to be preferred. """ entropy_func = entropy_func or entropy val_freq = defaultdict(float) subset_entropy = 0.0 # Calculate the frequency of each of the values in the target attribute for record in data: val_freq[record.get(attr)] += 1.0 # Calculate the sum of the entropy for each subset of records weighted # by their probability of occuring in the training set. for val in val_freq.keys(): val_prob = val_freq[val] / sum(val_freq.values()) data_subset = [record for record in data if record.get(attr) == val] e = entropy_func(data_subset, class_attr, method=method) subset_entropy += val_prob * e if only_sub: return subset_entropy # Subtract the entropy of the chosen attribute from the entropy of the # whole data set with respect to the target attribute (and return it) main_entropy = entropy_func(data, class_attr, method=method) # Prefer gains on attributes with fewer values. if prefer_fewer_values: return ((main_entropy - subset_entropy), 1./len(val_freq)) else: return (main_entropy - subset_entropy) def gain_variance(*args, **kwargs): """ Calculates information gain using variance as the comparison metric. """ return get_gain(entropy_func=entropy_variance, *args, **kwargs) def majority_value(data, class_attr): """ Creates a list of all values in the target attribute for each record in the data list object, and returns the value that appears in this list the most frequently. """ if is_continuous(data[0][class_attr]): return CDist(seq=[record[class_attr] for record in data]) else: return most_frequent([record[class_attr] for record in data]) def most_frequent(lst): """ Returns the item that appears most frequently in the given list. """ lst = lst[:] highest_freq = 0 most_freq = None for val in unique(lst): if lst.count(val) > highest_freq: most_freq = val highest_freq = lst.count(val) return most_freq def unique(lst): """ Returns a list made up of the unique values found in lst. i.e., it removes the redundant values in lst. """ lst = lst[:] unique_lst = [] # Cycle through the list and add each value to the unique list only once. for item in lst: if unique_lst.count(item) <= 0: unique_lst.append(item) # Return the list with all redundant values removed. return unique_lst def get_values(data, attr): """ Creates a list of values in the chosen attribut for each record in data, prunes out all of the redundant values, and return the list. """ return unique([record[attr] for record in data]) def choose_attribute(data, attributes, class_attr, fitness, method): """ Cycles through all the attributes and returns the attribute with the highest information gain (or lowest entropy). """ best = (-1e999999, None) for attr in attributes: if attr == class_attr: continue gain = fitness(data, attr, class_attr, method=method) best = max(best, (gain, attr)) return best[1] def is_continuous(v): return isinstance(v, (float, Decimal)) def create_decision_tree(data, attributes, class_attr, fitness_func, wrapper, **kwargs): """ Returns a new decision tree based on the examples given. """ split_attr = kwargs.get('split_attr', None) split_val = kwargs.get('split_val', None) assert class_attr not in attributes node = None data = list(data) if isinstance(data, Data) else data if wrapper.is_continuous_class: stop_value = CDist(seq=[r[class_attr] for r in data]) # For a continuous class case, stop if all the remaining records have # a variance below the given threshold. stop = wrapper.leaf_threshold is not None \ and stop_value.variance <= wrapper.leaf_threshold else: stop_value = DDist(seq=[r[class_attr] for r in data]) # For a discrete class, stop if all remaining records have the same # classification. stop = len(stop_value.counts) <= 1 if not data or len(attributes) <= 0: # If the dataset is empty or the attributes list is empty, return the # default value. The target attribute is not in the attributes list, so # we need not subtract 1 to account for the target attribute. if wrapper: wrapper.leaf_count += 1 return stop_value elif stop: # If all the records in the dataset have the same classification, # return that classification. if wrapper: wrapper.leaf_count += 1 return stop_value else: # Choose the next best attribute to best classify our data best = choose_attribute( data, attributes, class_attr, fitness_func, method=wrapper.metric) # Create a new decision tree/node with the best attribute and an empty # dictionary object--we'll fill that up next. node = Node(tree=wrapper, attr_name=best) node.n += len(data) # Create a new decision tree/sub-node for each of the values in the # best attribute field for val in get_values(data, best): # Create a subtree for the current value under the "best" field subtree = create_decision_tree( [r for r in data if r[best] == val], [attr for attr in attributes if attr != best], class_attr, fitness_func, split_attr=best, split_val=val, wrapper=wrapper) # Add the new subtree to the empty dictionary object in our new # tree/node we just created. if isinstance(subtree, Node): node._branches[val] = subtree elif isinstance(subtree, (CDist, DDist)): node.set_leaf_dist(attr_value=val, dist=subtree) else: raise Exception("Unknown subtree type: %s" % (type(subtree),)) return node class Data: """ Parses, validates and iterates over tabular data in a file or an generic iterator. This does not store the actual data rows. It only stores the row schema. """ def __init__(self, inp, order=None, types=None, modes=None): self.header_types = types or {} # {attr_name:type} self.header_modes = modes or {} # {attr_name:mode} if isinstance(order, str): order = order.split(',') self.header_order = order or [] # [attr_name,...] # Validate header type. if isinstance(self.header_types, (tuple, list)): assert self.header_order, 'If header type names were not given, an explicit order must be specified.' assert len(self.header_types) == len(self.header_order), 'Header order length must match header type length.' self.header_types = dict(zip(self.header_order, self.header_types)) self.filename = None self.data = None if isinstance(inp, str): filename = inp assert os.path.isfile(filename), "File \"%s\" does not exist." % filename self.filename = filename else: assert self.header_types, "No attribute types specified." assert self.header_modes, "No attribute modes specified." self.data = inp self._class_attr_name = None if self.header_modes: for k, v in self.header_modes.items(): if v != CLS: continue self._class_attr_name = k break assert self._class_attr_name, "No class attribute specified." def copy_no_data(self): """ Returns a copy of the object without any data. """ return type(self)( [], order=list(self.header_modes), types=self.header_types.copy(), modes=self.header_modes.copy()) def __len__(self): if self.filename: return max(0, open(self.filename).read().strip().count('\n')) elif hasattr(self.data, '__len__'): return len(self.data) def __bool__(self): return bool(len(self)) __nonzero__ = __bool__ @property def class_attribute_name(self): return self._class_attr_name @property def attribute_names(self): self._read_header() return [ n for n in self.header_types.keys() if n != self._class_attr_name ] def get_attribute_type(self, name): if not self.header_types: self._read_header() return self.header_types[name] @property def is_continuous_class(self): self._read_header() return self.get_attribute_type(self._class_attr_name) == ATTR_TYPE_CONTINUOUS def is_valid(self, name, value): """ Returns true if the given value matches the type for the given name according to the schema. Returns false otherwise. """ if name not in self.header_types: return False t = self.header_types[name] if t == ATTR_TYPE_DISCRETE: return isinstance(value, int) elif t == ATTR_TYPE_CONTINUOUS: return isinstance(value, (float, Decimal)) return True def _read_header(self): """ When a CSV file is given, extracts header information the file. Otherwise, this header data must be explicitly given when the object is instantiated. """ if not self.filename or self.header_types: return rows = csv.reader(open(self.filename)) header = next(rows) self.header_types = {} # {attr_name:type} self._class_attr_name = None self.header_order = [] # [attr_name,...] for el in header: matches = ATTR_HEADER_PATTERN.findall(el) assert matches, "Invalid header element: %s" % (el,) el_name, el_type, el_mode = matches[0] el_name = el_name.strip() self.header_order.append(el_name) self.header_types[el_name] = el_type if el_mode == ATTR_MODE_CLASS: assert self._class_attr_name is None, "Multiple class attributes are not supported." self._class_attr_name = el_name else: assert self.header_types[el_name] != ATTR_TYPE_CONTINUOUS, "Non-class continuous attributes are not supported." assert self._class_attr_name, "A class attribute must be specified." def validate_row(self, row): """ Ensure each element in the row matches the schema. """ clean_row = {} if isinstance(row, (tuple, list)): assert self.header_order, "No attribute order specified." assert len(row) == len(self.header_order), "Row length does not match header length." itr = zip(self.header_order, row) else: assert isinstance(row, dict) itr = row.items() for el_name, el_value in itr: if self.header_types[el_name] == ATTR_TYPE_DISCRETE: clean_row[el_name] = int(el_value) elif self.header_types[el_name] == ATTR_TYPE_CONTINUOUS: clean_row[el_name] = float(el_value) else: clean_row[el_name] = el_value return clean_row def _get_iterator(self): if self.filename: self._read_header() itr = csv.reader(open(self.filename)) next(itr) # Skip header. return itr return self.data def __iter__(self): for row in self._get_iterator(): if not row: continue yield self.validate_row(row) def split(self, ratio=0.5, leave_one_out=False): """ Returns two Data instances, containing the data randomly split between the two according to the given ratio. The first instance will contain the ratio of data specified. The second instance will contain the remaining ratio of data. If leave_one_out is True, the ratio will be ignored and the first instance will contain exactly one record for each class label, and the second instance will contain all remaining data. """ a_labels = set() a = self.copy_no_data() b = self.copy_no_data() for row in self: if leave_one_out and not self.is_continuous_class: label = row[self.class_attribute_name] if label not in a_labels: a_labels.add(label) a.data.append(row) else: b.data.append(row) elif not a: a.data.append(row) elif not b: b.data.append(row) elif random.random() <= ratio: a.data.append(row) else: b.data.append(row) return a, b USE_NEAREST = 'use_nearest' MISSING_VALUE_POLICIES = set([ USE_NEAREST, ]) def _get_dd_int(): return defaultdict(int) def _get_dd_dd_int(): return defaultdict(_get_dd_int) def _get_dd_cdist(): return defaultdict(CDist) class NodeNotReadyToPredict(Exception): pass class Node: """ Represents a specific split or branch in the tree. """ def __init__(self, tree, attr_name=None): # The number of samples this node has been trained on. self.n = 0 # A reference to the container tree instance. self._tree = tree # The splitting attribute at this node. self.attr_name = attr_name #### Discrete values. # Counts of each observed attribute value, used to calculate an # attribute value's probability. # {attr_name:{attr_value:count}} self._attr_value_counts = defaultdict(_get_dd_int) # {attr_name:total} self._attr_value_count_totals = defaultdict(int) # Counts of each observed class value and attribute value in # combination, used to calculate an attribute value's entropy. # {attr_name:{attr_value:{class_value:count}}} self._attr_class_value_counts = defaultdict(_get_dd_dd_int) #### Continuous values. # Counts of each observed class value, used to calculate a class # value's probability. # {class_value:count} self._class_ddist = DDist() # {attr_name:{attr_value:CDist(variance)}} self._attr_value_cdist = defaultdict(_get_dd_cdist) self._class_cdist = CDist() self._branches = {} # {v:Node} def __getitem__(self, attr_name): assert attr_name == self.attr_name branches = self._branches.copy() for value in self.get_values(attr_name): if value in branches: continue if self.tree.data.is_continuous_class: branches[value] = self._attr_value_cdist[self.attr_name][value].copy() else: branches[value] = self.get_value_ddist(self.attr_name, value) return branches def _get_attribute_value_for_node(self, record): """ Gets the closest value for the current node's attribute matching the given record. """ # Abort if this node has not get split on an attribute. if self.attr_name is None: return # Otherwise, lookup the attribute value for this node in the given record. attr = self.attr_name attr_value = record[attr] attr_values = self.get_values(attr) if attr_value in attr_values: return attr_value else: # The value of the attribute in the given record does not directly # map to any previously known values, so apply a missing value # policy. policy = self.tree.missing_value_policy.get(attr) assert policy, "No missing value policy specified for attribute %s." % (attr,) if policy == USE_NEAREST: # Use the value that the tree has seen that's also has the # smallest Euclidean distance to the actual value. assert self.tree.data.header_types[attr] in (ATTR_TYPE_DISCRETE, ATTR_TYPE_CONTINUOUS), "The use-nearest policy is invalid for nominal types." nearest = (1e999999, None) for _value in attr_values: nearest = min(nearest, (abs(_value - attr_value), _value)) _, nearest_value = nearest return nearest_value else: raise Exception("Unknown missing value policy: %s" % (policy,)) @property def attributes(self): return self._attr_value_counts.keys() def get_values(self, attr_name): """ Retrieves the unique set of values seen for the given attribute at this node. """ ret = list(self._attr_value_cdist[attr_name].keys()) \ + list(self._attr_value_counts[attr_name].keys()) \ + list(self._branches.keys()) ret = set(ret) return ret @property def is_continuous_class(self): return self._tree.is_continuous_class def get_best_splitting_attr(self): """ Returns the name of the attribute with the highest gain. """ best = (-1e999999, None) for attr in self.attributes: best = max(best, (self.get_gain(attr), attr)) best_gain, best_attr = best return best_attr def get_entropy(self, attr_name=None, attr_value=None): """ Calculates the entropy of a specific attribute/value combination. """ is_con = self.tree.data.is_continuous_class if is_con: if attr_name is None: # Calculate variance of class attribute. var = self._class_cdist.variance else: # Calculate variance of the given attribute. var = self._attr_value_cdist[attr_name][attr_value].variance if self.tree.metric == VARIANCE1 or attr_name is None: return var elif self.tree.metric == VARIANCE2: unique_value_count = len(self._attr_value_counts[attr_name]) attr_total = float(self._attr_value_count_totals[attr_name]) return var*(unique_value_count/attr_total) else: if attr_name is None: # The total number of times this attr/value pair has been seen. total = float(self._class_ddist.total) # The total number of times each class value has been seen for # this attr/value pair. counts = self._class_ddist.counts # The total number of unique values seen for this attribute. unique_value_count = len(self._class_ddist.counts) # The total number of times this attribute has been seen. attr_total = total else: total = float(self._attr_value_counts[attr_name][attr_value]) counts = self._attr_class_value_counts[attr_name][attr_value] unique_value_count = len(self._attr_value_counts[attr_name]) attr_total = float(self._attr_value_count_totals[attr_name]) assert total, "There must be at least one non-zero count." n = max(2, len(counts)) if self._tree.metric == ENTROPY1: # Traditional entropy. return -sum( (count/total)*math.log(count/total, n) for count in counts.values() ) elif self._tree.metric == ENTROPY2: # Modified entropy that down-weights universally unique values. # e.g. If the number of unique attribute values equals the total # count of the attribute, then it has the maximum amount of unique # values. return -sum( (count/total)*math.log(count/total, n) for count in counts.values() ) + (unique_value_count/attr_total) elif self._tree.metric == ENTROPY3: # Modified entropy that down-weights universally unique values # as well as features with large numbers of values. return -sum( (count/total)*math.log(count/total, n) for count in counts.values() ) + 100*(unique_value_count/attr_total) def get_gain(self, attr_name): """ Calculates the information gain from splitting on the given attribute. """ subset_entropy = 0.0 for value in self._attr_value_counts[attr_name].keys(): value_prob = self.get_value_prob(attr_name, value) e = self.get_entropy(attr_name, value) subset_entropy += value_prob * e return (self.main_entropy - subset_entropy) def get_value_ddist(self, attr_name, attr_value): """ Returns the class value probability distribution of the given attribute value. """ assert not self.tree.data.is_continuous_class, "Discrete distributions are only maintained for discrete class types." ddist = DDist() cls_counts = self._attr_class_value_counts[attr_name][attr_value] for cls_value, cls_count in cls_counts.items(): ddist.add(cls_value, count=cls_count) return ddist def get_value_prob(self, attr_name, value): """ Returns the value probability of the given attribute at this node. """ if attr_name not in self._attr_value_count_totals: return n = self._attr_value_counts[attr_name][value] d = self._attr_value_count_totals[attr_name] return n/float(d) @property def main_entropy(self): """ Calculates the overall entropy of the class attribute. """ return self.get_entropy() def predict(self, record, depth=0): """ Returns the estimated value of the class attribute for the given record. """ # Check if we're ready to predict. if not self.ready_to_predict: raise NodeNotReadyToPredict # Lookup attribute value. attr_value = self._get_attribute_value_for_node(record) # Propagate decision to leaf node. if self.attr_name: if attr_value in self._branches: try: return self._branches[attr_value].predict(record, depth=depth+1) except NodeNotReadyToPredict: #TODO:allow re-raise if user doesn't want an intermediate prediction? pass # Otherwise make decision at current node. if self.attr_name: if self._tree.data.is_continuous_class: return self._attr_value_cdist[self.attr_name][attr_value].copy() else: return self.get_value_ddist(self.attr_name, attr_value) elif self._tree.data.is_continuous_class: # Make decision at current node, which may be a true leaf node # or an incomplete branch in a tree currently being built. assert self._class_cdist is not None return self._class_cdist.copy() else: return self._class_ddist.copy() @property def ready_to_predict(self): return self.n > 0 @property def ready_to_split(self): """ Returns true if this node is ready to branch off additional nodes. Returns false otherwise. """ # Never split if we're a leaf that predicts adequately. threshold = self._tree.leaf_threshold if self._tree.data.is_continuous_class: var = self._class_cdist.variance if var is not None and threshold is not None and var <= threshold: return False else: best_prob = self._class_ddist.best_prob if best_prob is not None and threshold is not None and best_prob >= threshold: return False return self._tree.auto_grow \ and not self.attr_name \ and self.n >= self._tree.splitting_n def set_leaf_dist(self, attr_value, dist): """ Sets the probability distribution at a leaf node. """ assert self.attr_name assert self.tree.data.is_valid(self.attr_name, attr_value), "Value %s is invalid for attribute %s." % (attr_value, self.attr_name) if self.is_continuous_class: assert isinstance(dist, CDist) assert self.attr_name self._attr_value_cdist[self.attr_name][attr_value] = dist.copy() else: assert isinstance(dist, DDist) # {attr_name:{attr_value:count}} self._attr_value_counts[self.attr_name][attr_value] += 1 # {attr_name:total} self._attr_value_count_totals[self.attr_name] += 1 # {attr_name:{attr_value:{class_value:count}}} for cls_value, cls_count in dist.counts.items(): self._attr_class_value_counts[self.attr_name][attr_value][cls_value] += cls_count def to_dict(self): if self.attr_name: # Show a value's branch, whether it's a leaf or another node. ret = {self.attr_name:{}} # {attr_name:{attr_value:dist or node}} values = self.get_values(self.attr_name) for attr_value in values: if attr_value in self._branches: ret[self.attr_name][attr_value] = self._branches[attr_value].to_dict() elif self._tree.data.is_continuous_class: ret[self.attr_name][attr_value] = self._attr_value_cdist[self.attr_name][attr_value].copy() else: ret[self.attr_name][attr_value] = self.get_value_ddist(self.attr_name, attr_value) return ret elif self.tree.data.is_continuous_class: # Otherwise we're at a continuous leaf node. return self._class_cdist.copy() else: # Or a discrete leaf node. return self._class_ddist.copy() @property def tree(self): return self._tree def train(self, record): """ Incrementally update the statistics at this node. """ self.n += 1 class_attr = self.tree.data.class_attribute_name class_value = record[class_attr] # Update class statistics. is_con = self.tree.data.is_continuous_class if is_con: # For a continuous class. self._class_cdist += class_value else: # For a discrete class. self._class_ddist.add(class_value) # Update attribute statistics. for an, av in record.items(): if an == class_attr: continue self._attr_value_counts[an][av] += 1 self._attr_value_count_totals[an] += 1 if is_con: self._attr_value_cdist[an][av] += class_value else: self._attr_class_value_counts[an][av][class_value] += 1 # Decide if branch should split on an attribute. if self.ready_to_split: self.attr_name = self.get_best_splitting_attr() self.tree.leaf_count -= 1 for av in self._attr_value_counts[self.attr_name]: self._branches[av] = Node(tree=self.tree) self.tree.leaf_count += 1 # If we've split, then propagate the update to appropriate sub-branch. if self.attr_name: key = record[self.attr_name] del record[self.attr_name] self._branches[key].train(record) class Tree: """ Represents a single grown or built decision tree. """ def __init__(self, data, **kwargs): assert isinstance(data, Data) self._data = data # Root splitting node. # This can be traversed via [name1][value1][name2][value2]... self._tree = Node(self) # The mean absolute error. self.mae = CDist() self._mae_clean = True # Set the metric used to calculate the information gain after an attribute split. if self.data.is_continuous_class: self.metric = kwargs.get('metric', DEFAULT_CONTINUOUS_METRIC) assert self.metric in CONTINUOUS_METRICS else: self.metric = kwargs.get('metric', DEFAULT_DISCRETE_METRIC) assert self.metric in DISCRETE_METRICS # Set metric to splitting nodes after a sample threshold has been met. self.splitting_n = kwargs.get('splitting_n', 100) # Declare the policy for handling missing values for each attribute. self.missing_value_policy = {} # Allow the tree to automatically grow and split after an update(). self.auto_grow = kwargs.get('auto_grow', False) # Determine the threshold at which further splitting is unnecessary # if enough accuracy has been achieved. if self.data.is_continuous_class: # Zero variance is the default continuous stopping criteria. self.leaf_threshold = kwargs.get('leaf_threshold', 0.0) else: # A 100% probability is the default discrete stopping criteria. self.leaf_threshold = kwargs.get('leaf_threshold', 1.0) # The total number of leaf nodes. self.leaf_count = 0 # The total number of samples trained on. self.sample_count = 0 ### Used for forests. # The prediction accuracy on held-out samples. self.out_of_bag_accuracy = CDist() # Samples not given to the tree for training with which the # out-of-bag accuracy is calculated from. self._out_of_bag_samples = [] # The mean absolute error for predictions on out-of-bag samples. self._out_of_bag_mae = CDist() self._out_of_bag_mae_clean = True def __getitem__(self, attr_name): return self.tree[attr_name] @classmethod def build(cls, data, *args, **kwargs): """ Constructs a classification or regression tree in a single batch by analyzing the given data. """ assert isinstance(data, Data) if data.is_continuous_class: fitness_func = gain_variance else: fitness_func = get_gain t = cls(data=data, *args, **kwargs) t._data = data t.sample_count = len(data) t._tree = create_decision_tree( data=data, attributes=data.attribute_names, class_attr=data.class_attribute_name, fitness_func=fitness_func, wrapper=t, ) return t @property def data(self): return self._data @property def is_continuous_class(self): return self.data.is_continuous_class @classmethod def load(cls, fn): tree = pickle.load(open(fn)) assert isinstance(tree, cls), "Invalid pickle." return tree @property def out_of_bag_mae(self): """ Returns the mean absolute error for predictions on the out-of-bag samples. """ if not self._out_of_bag_mae_clean: try: self._out_of_bag_mae = self.test(self.out_of_bag_samples) self._out_of_bag_mae_clean = True except NodeNotReadyToPredict: return return self._out_of_bag_mae.copy() @property def out_of_bag_samples(self): """ Returns the out-of-bag samples list, inside a wrapper to keep track of modifications. """ #TODO:replace with more a generic pass-through wrapper? class O: def __init__(self, tree): self.tree = tree def __len__(self): return len(self.tree._out_of_bag_samples) def append(self, v): self.tree._out_of_bag_mae_clean = False return self.tree._out_of_bag_samples.append(v) def pop(self, v): self.tree._out_of_bag_mae_clean = False return self.tree._out_of_bag_samples.pop(v) def __iter__(self): for _ in self.tree._out_of_bag_samples: yield _ return O(self) def predict(self, record): record = record.copy() return self._tree.predict(record) def save(self, fn): pickle.dump(self, open(fn, 'w')) def set_missing_value_policy(self, policy, target_attr_name=None): """ Sets the behavior for one or all attributes to use when traversing the tree using a query vector and it encounters a branch that does not exist. """ assert policy in MISSING_VALUE_POLICIES, "Unknown policy: %s" % (policy,) for attr_name in self.data.attribute_names: if target_attr_name is not None and target_attr_name != attr_name: continue self.missing_value_policy[attr_name] = policy def test(self, data): """ Iterates over the data, classifying or regressing each element and then finally returns the classification accuracy or mean-absolute-error. """ is_cont = self._data.is_continuous_class agg = CDist() for record in data: actual_value = self.predict(record) expected_value = record[self._data.class_attribute_name] if is_cont: assert isinstance(actual_value, CDist) actual_value = actual_value.mean agg += abs(actual_value - expected_value) else: assert isinstance(actual_value, DDist) agg += actual_value.best == expected_value return agg def to_dict(self): return self._tree.to_dict() @property def tree(self): return self._tree def train(self, record): """ Incrementally updates the tree with the given sample record. """ assert self.data.class_attribute_name in record, "The class attribute must be present in the record." record = record.copy() self.sample_count += 1 self.tree.train(record) def _get_defaultdict_cdist(): return defaultdict(CDist) class Forest: def __init__(self, data, tree_kwargs=None, **kwargs): assert isinstance(data, Data) self._data = data # The population of trees. self.trees = [] # Arguments that will be passed to each tree during init. self.tree_kwargs = tree_kwargs or {} self.grow_method = kwargs.get('grow_method', GROW_RANDOM) assert self.grow_method in GROW_METHODS, "Growth method %s is not supported." % (self.grow_method,) # The number of trees in the forest. self.size = kwargs.get('size', 10) # The ratio of training samples given to each tree. # The rest are held to test tree accuracy. self.sample_ratio = kwargs.get('sample_ratio', 0.9) # The maximum number of out of bag samples to store in each tree. self.max_out_of_bag_samples = kwargs.get('max_out_of_bag_samples', 1000) # The method for how we consolidate each tree's prediction into # a single prediction. self.weighting_method = kwargs.get('weighting_method', Forest.mean_oob_mae_weight) # The criteria defining how and when old trees are removed from the # forest and replaced by new trees. # This is a callable that is given a list of all the current trees # and returns a list of trees that should be removed. self.fell_method = kwargs.get('fell_method', None) def _fell_trees(self): """ Removes trees from the forest according to the specified fell method. """ if callable(self.fell_method): for tree in self.fell_method(list(self.trees)): self.trees.remove(tree) def _get_best_prediction(self, record, train=True): """ Gets the prediction from the tree with the lowest mean absolute error. """ if not self.trees: return best = (+1e999999, None) for tree in self.trees: best = min(best, (tree.mae.mean, tree)) _, best_tree = best prediction, tree_mae = best_tree.predict(record, train=train) return prediction.mean @staticmethod def best_oob_mae_weight(trees): """ Returns weights so that the tree with smallest out-of-bag mean absolute error """ best = (+1e999999, None) for tree in trees: oob_mae = tree.out_of_bag_mae if oob_mae is None or oob_mae.mean is None: continue best = min(best, (oob_mae.mean, tree)) best_mae, best_tree = best if best_tree is None: return return [(1.0, best_tree)] @staticmethod def mean_oob_mae_weight(trees): """ Returns weights proportional to the out-of-bag mean absolute error for each tree. """ weights = [] active_trees = [] for tree in trees: oob_mae = tree.out_of_bag_mae if oob_mae is None or oob_mae.mean is None: continue weights.append(oob_mae.mean) active_trees.append(tree) if not active_trees: return weights = normalize(weights) return zip(weights, active_trees) def _grow_trees(self): """ Adds new trees to the forest according to the specified growth method. """ if self.grow_method == GROW_AUTO_INCREMENTAL: self.tree_kwargs['auto_grow'] = True while len(self.trees) < self.size: self.trees.append(Tree(data=self.data, **self.tree_kwargs)) @property def data(self): return self._data def predict(self, record): """ Attempts to predict the value of the class attribute by aggregating the predictions of each tree. Parameters: weighting_formula := a callable that takes a list of trees and returns a list of weights. """ # Get raw predictions. # {tree:raw prediction} predictions = {} for tree in self.trees: _p = tree.predict(record) if _p is None: continue if isinstance(_p, CDist): if _p.mean is None: continue elif isinstance(_p, DDist): if not _p.count: continue predictions[tree] = _p if not predictions: return # Normalize weights and aggregate final prediction. weights = self.weighting_method(predictions.keys()) if not weights: return if self.data.is_continuous_class: # Merge continuous class predictions. total = sum(w*predictions[tree].mean for w, tree in weights) else: # Merge discrete class predictions. total = DDist() for weight, tree in weights: prediction = predictions[tree] for cls_value, cls_prob in prediction.probs: total.add(cls_value, cls_prob*weight) return total def set_missing_value_policy(self, policy, target_attr_name=None): for tree in self.trees: tree.set_missing_value_policy(policy, target_attr_name) def test(self, data): """ Iterates over the data, classifying or regressing each element and then finally returns the classification accuracy or mean-absolute-error. """ is_cont = self.data.is_continuous_class agg = CDist() for record in data: actual_value = self.predict(record) if actual_value is None: continue expected_value = record[self._data.class_attribute_name] if is_cont: assert isinstance(actual_value, CDist), \ "Invalid prediction type: %s" % (type(actual_value),) actual_value = actual_value.mean agg += abs(actual_value - expected_value) else: assert isinstance(actual_value, DDist), \ "Invalid prediction type: %s" % (type(actual_value),) agg += actual_value.best == expected_value return agg def train(self, record): """ Updates the trees with the given training record. """ self._fell_trees() self._grow_trees() for tree in self.trees: if random.random() < self.sample_ratio: tree.train(record) else: tree.out_of_bag_samples.append(record) while len(tree.out_of_bag_samples) > self.max_out_of_bag_samples: tree.out_of_bag_samples.pop(0) class Test(unittest.TestCase): def test_stat(self): print('Testing statistics classes...') nums = range(1, 10) s = CDist() seen = [] for n in nums: seen.append(n) s += n print('mean:', s.mean) print('variance:', get_variance(seen)) print('variance:', s.variance) self.assertAlmostEqual(s.mean, get_mean(nums), 1) self.assertAlmostEqual(s.variance, get_variance(nums), 2) self.assertEqual(s.count, 9) self.assertAlmostEqual(s.probability_lt(s.mean-s.standard_deviation*6), 0.0, 5) self.assertAlmostEqual(s.probability_lt(s.mean+s.standard_deviation*6), 1.0, 5) self.assertAlmostEqual(s.probability_gt(s.mean-s.standard_deviation*6), 1.0, 5) self.assertAlmostEqual(s.probability_gt(s.mean+s.standard_deviation*6), 0.0, 5) self.assertAlmostEqual(s.probability_in(s.mean, 50), 0.5, 5) d1 = DDist(['a', 'b', 'a', 'a', 'b']) d2 = DDist(['a', 'b', 'a', 'a', 'b']) d3 = DDist(['a', 'b', 'a', 'a', 'b', 'c']) self.assertEqual(d1, d2) self.assertNotEqual(d1, d3) self.assertNotEqual(d2, d3) self.assertEqual(d1.best, 'a') self.assertEqual(d1.best_prob, 3/5.) self.assertEqual(d2.best, 'a') self.assertEqual(d3.best, 'a') print('Done.') def test_data(self): print('Testing data class...') # Load data from a file. data = Data('rdata1') self.assertEqual(len(data), 16) data = list(Data('rdata1')) self.assertEqual(len(data), 16) # Load data from memory or some other arbitrary source. data = """a,b,c,d,cls 1,1,1,1,a 1,1,1,2,a 1,1,2,3,a 1,1,2,4,a 1,2,3,5,a 1,2,3,6,a 1,2,4,7,a 1,2,4,8,a 2,3,5,1,b 2,3,5,2,b 2,3,6,3,b 2,3,6,4,b 2,4,7,5,b 2,4,7,6,b 2,4,8,7,b 2,4,8,8,b""".strip().split('\n') rows = list(csv.DictReader(data)) self.assertEqual(len(rows), 16) rows = Data( [r.split(',') for r in data[1:]], order=['a', 'b', 'c', 'd', 'cls'], types=dict(a=DIS, b=DIS, c=DIS, d=DIS, cls=NOM), modes=dict(cls=CLS)) self.assertEqual(len(rows), 16) self.assertEqual(len(list(rows)), 16) for row in rows: print(row) a, b = rows.split(ratio=0.1) self.assertEqual(len(rows), len(a)+len(b)) print('-'*80) print('a:') for row in a: print(row) print('-'*80) print('b:') for row in b: print(row) print('Done.') def test_batch_tree(self): print('Testing batch tree...') # If we set no leaf threshold for a continuous class # then there will be the same number of leaf nodes # as there are number of records. t = Tree.build(Data('rdata2')) self.assertEqual(type(t), Tree) print("Tree:") pprint(t.to_dict(), indent=4) self.assertEqual(set(t._tree['b'].keys()), set([1, 2, 3, 4])) result = t.test(Data('rdata1')) self.assertEqual(type(result), CDist) print('MAE:', result.mean) self.assertAlmostEqual(result.mean, 0.001368, 5) self.assertEqual(t.leaf_count, 16) # If we set a leaf threshold, then this will limit the number of leaf # nodes created, speeding up prediction, at the expense of increasing # the mean absolute error. t = Tree.build(Data('rdata2'), leaf_threshold=0.0005) print("Tree:") pprint(t.to_dict(), indent=4) print(t._tree['b'].keys()) self.assertEqual(t._tree.get_values('b'), set([1, 2, 3, 4])) result = t.test(Data('rdata1')) print('MAE:', result.mean) self.assertAlmostEqual(result.mean, 0.00623, 5) self.assertEqual(t.leaf_count, 10) t = Tree.build(Data('cdata1')) print("Tree:") self.assertEqual(t['Age']['36 - 55'].attr_name, 'Marital Status') self.assertEqual(t['Age']['36 - 55']\ .get_values('Marital Status'), set(['single', 'married'])) self.assertEqual(set(t['Age'].keys()), set(['< 18', '18 - 35', '36 - 55', '> 55'])) self.assertEqual(t['Age']['18 - 35'].best, 'won\'t buy') self.assertEqual(t['Age']['36 - 55']['Marital Status']['single'].best, 'will buy') d = t.to_dict() pprint(d, indent=4) result = t.test(Data('cdata1')) print('Accuracy:', result.mean) self.assertAlmostEqual(result.mean, 1.0, 5) t = Tree.build(Data('cdata2')) pprint(t.to_dict(), indent=4) result = t.test(Data('cdata2')) print('Accuracy:', result.mean) self.assertAlmostEqual(result.mean, 1.0, 5) result = t.test(Data('cdata3')) print('Accuracy:', result.mean) self.assertAlmostEqual(result.mean, 0.75, 5) # Send it a corpus that's purposefully difficult to predict. t = Tree.build(Data('cdata4')) pprint(t.to_dict(), indent=4) result = t.test(Data('cdata4')) print('Accuracy:', result.mean) self.assertAlmostEqual(result.mean, 0.5, 5) # Send it a case it's never seen. with self.assertRaises(AssertionError): # By default, it should throw an exception because it hasn't been # given a policy for resolving unseen attribute value. t.predict(dict(a=1, b=2, c=3, d=4)) # But if we tell it to use the nearest value, then it should pass. t.set_missing_value_policy(USE_NEAREST) result = t.predict(dict(a=1, b=2, c=3, d=4)) print(result) print('Done.') def test_online_tree(self): print('Testing online tree...') rdata3 = Data('rdata3') rdata3_lst = list(rdata3) cdata2 = Data('cdata2') cdata2_lst = list(cdata2) cdata5 = Data('cdata5') cdata5_lst = list(cdata5) tree = Tree(cdata2, metric=ENTROPY1) for row in cdata2: tree.train(row) node = tree._tree attr_gains = [(node.get_gain(attr_name), attr_name) for attr_name in node.attributes] attr_gains.sort() # With traditional entropy, a b and c all evenly divide the class # and therefore have the same gain, even though all three # have different value frequencies. self.assertEqual(attr_gains, [(0.0, 'd'), (1.0, 'a'), (1.0, 'b'), (1.0, 'c')]) tree = Tree(cdata2, metric=ENTROPY2) for row in cdata2: tree.train(row) self.assertEqual(set(node.attributes), set(['a', 'b', 'c', 'd'])) node = tree._tree attr_gains = [(node.get_gain(attr_name), attr_name) for attr_name in node.attributes] attr_gains.sort() # With entropy metric 2, attributes that have fewer unique values # will have a slightly greater gain relative to attributes with more # unique values. self.assertEqual(attr_gains, [(-0.375, 'd'), (0.625, 'c'), (0.875, 'b'), (1.0, 'a')]) tree = Tree(rdata3, metric=VARIANCE1) for row in rdata3: tree.train(row) node = tree._tree self.assertEqual(set(node.attributes), set(['a', 'b', 'c', 'd'])) attr_gains = [(node.get_gain(attr_name), attr_name) for attr_name in node.attributes] attr_gains.sort() # With entropy metric 2, attributes that have fewer unique values # will have a slightly greater gain relative to attributes with more # unique values. self.assertEqual([v for _, v in attr_gains], ['d', 'a', 'b', 'c']) tree = Tree(rdata3, metric=VARIANCE2) for row in rdata3: tree.train(row) node = tree._tree self.assertEqual(set(node.attributes), set(['a', 'b', 'c', 'd'])) attr_gains = [(node.get_gain(attr_name), attr_name) for attr_name in node.attributes] attr_gains.sort() # With entropy metric 2, attributes that have fewer unique values # will have a slightly greater gain relative to attributes with more # unique values. self.assertEqual([v for _, v in attr_gains], ['d', 'c', 'b', 'a']) # Incrementally grow a classification tree. print("-"*80) print("Incrementally growing classification tree...") tree = Tree(cdata5, metric=ENTROPY2, splitting_n=17, auto_grow=True) for row in cdata5: tree.train(row) acc = tree.test(cdata5) print('Initial accuracy:', acc.mean) self.assertEqual(acc.mean, 0.25) # Update tree several times to give leaf nodes potential time to split. for _ in range(5): for row in cdata5: #print(row tree.train(row) acc = tree.test(cdata5) print('Accuracy:', acc.mean) print('Final tree:') pprint(tree.to_dict(), indent=4) # Confirm no more nodes have split, since the optimal split has # already been found and the tree is fully grown. self.assertEqual(tree['b'][1].ready_to_split, False) self.assertEqual(tree['b'][1]._branches, {}) # Test accuracy of fully grown tree. acc = tree.test(cdata5) self.assertEqual(acc.mean, 1.0) # Incrementally grow a regression tree. print("-"*80) print("Incrementally growing regression tree...") tree = Tree(rdata3, metric=VARIANCE2, splitting_n=17, auto_grow=True, leaf_threshold=0.0) for row in rdata3: tree.train(row) mae = tree.test(rdata3) print('Initial MAE:', mae.mean) self.assertAlmostEqual(mae.mean, 0.4, 5) for _ in range(20): for row in rdata3: tree.train(row) mae = tree.test(rdata3) print('MAE:', mae.mean) print("Final tree:") pprint(tree.to_dict(), indent=4) self.assertEqual(mae.mean, 0.0) print('Done.') def test_forest(self): print('Testing forest...') print('Growing forest incrementally...') cdata2 = Data('cdata2') cdata2_lst = list(cdata2) # Incrementally train and test the forest on the same data. forest = Forest( data=cdata2, size=10, # Grow 10 trees. sample_ratio=0.8, # Train each tree on 80% of all records. grow_method=GROW_AUTO_INCREMENTAL, # Incrementally grow each tree. weighting_method=Forest.mean_oob_mae_weight, tree_kwargs=dict(metric=ENTROPY2), ) mae = None for _ in range(10): for row in cdata2_lst: forest.train(row) mae = forest.test(cdata2_lst) print('Forest MAE:', mae.mean) self.assertEqual(mae.mean, 1.0) trees = list(forest.trees) trees.sort(key=lambda t: t.out_of_bag_mae.mean) print('Best tree:') pprint(trees[-1].to_dict(), indent=4) self.assertEqual(trees[-1].auto_grow, True) print('Done.') def test_milksets(self): try: from milksets import wine, yeast # pylint: disable=import-outside-toplevel except ImportError: print('Skipping milkset tests because milksets is not installed.') print('Run `sudo pip install milksets` and rerun these tests.') return def leave_one_out(all_data, metric=None): test_data, train_data = all_data.split(leave_one_out=True) tree = Tree.build(train_data, metric=metric) tree.set_missing_value_policy(USE_NEAREST) result = tree.test(test_data) return result.mean def cross_validate(all_data, epoches=10, test_ratio=0.25, metric=None): accuracies = [] for epoche in range(epoches): test_data, train_data = all_data.split(ratio=test_ratio) tree = Tree.build(train_data, metric=metric) tree.set_missing_value_policy(USE_NEAREST) result = tree.test(test_data) accuracies.append(result.mean) return sum(accuracies)/float(len(accuracies)) # Load wine dataset. # Each record has 13 continuous features # and one discrete class containing 2 unique values. print('Loading UCI wine data...') wine_data = Data( [list(a)+[b] for a, b in zip(*wine.load())], order=map(str, range(13))+['cls'], types=[CON]*13 + [DIS], modes=dict(cls=CLS)) self.assertEqual(len(wine_data), 178) self.assertEqual(len(list(wine_data)), 178) # Load yeast dataset. # Each record has 8 continuous features # and one discrete class containing 10 values. print('Loading UCI yeast data...') yeast_data = Data( [list(a)+[b] for a, b in zip(*yeast.load())], order=map(str, range(8))+['cls'], types=[CON]*8 + [DIS], modes=dict(cls=CLS)) self.assertEqual(len(yeast_data), 1484) self.assertEqual(len(list(yeast_data)), 1484) acc = leave_one_out(wine_data, metric=ENTROPY1) print('Wine leave-one-out accuracy: %0.2f' % (acc,)) acc = cross_validate(wine_data, metric=ENTROPY1, test_ratio=0.01, epoches=25) print('Wine cross-validated accuracy: %0.2f' % (acc,)) acc = leave_one_out(yeast_data, metric=ENTROPY1) print('Yeast leave-one-out accuracy: %0.2f' % (acc,)) acc = cross_validate(yeast_data, metric=ENTROPY1, test_ratio=0.005, epoches=25) print('Yeast cross-validated accuracy: %0.2f' % (acc,)) def test_entropy(self): # Lopsided distribution with mostly all events in one group # is low entropy. self.assertAlmostEqual(entropy({+1:10, -1:10, 0:980}), 0.1018576) # Everything in one group is 0 entropy. self.assertAlmostEqual(entropy({0:1000}), 0.0) # Everything equally divided is highest entropy. self.assertAlmostEqual(entropy({+1:500, -1:500}), 1.0) data1 = {+1:1, -1:1}#,0:200-2} data2 = {+1:100, -1:100} # Entropy1 doesn't care about size. e11 = entropy(data1, method=ENTROPY1) e21 = entropy(data2, method=ENTROPY1) self.assertEqual(e11, 1.0) self.assertEqual(e11, e21) # Entropy2 takes size into account. e12 = entropy(data1, method=ENTROPY2) e22 = entropy(data2, method=ENTROPY2) self.assertEqual(e12, 0.5) self.assertEqual(e22, 0.995) # Entropy3 takes large numbers of values into account, but otherwise ignores size. e13 = entropy(data1, method=ENTROPY3) e23 = entropy(data2, method=ENTROPY3) self.assertEqual(e13, -49.0) self.assertEqual(e23, 0.5) if __name__ == '__main__': unittest.main()
lgpl-3.0
[ 624, 199, 7409, 14, 17, 14, 1194, 445, 19982, 199, 2439, 12719, 367, 10015, 436, 1808, 282, 14692, 3123, 367, 12505, 503, 10864, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 5055, 492, 10018, 199, 504, 6107, 492, 6345, 199, 504, 10933, 492, 10933, 199, 646, 1331, 199, 646, 7392, 199, 646, 3473, 199, 504, 3473, 492, 6682, 199, 646, 747, 199, 646, 2196, 199, 646, 295, 199, 646, 2882, 199, 646, 5927, 199, 199, 4612, 275, 334, 18, 12, 378, 12, 378, 9, 199, 363, 1023, 363, 275, 15671, 904, 8, 1130, 8, 495, 12, 15945, 430, 199, 199, 3, 12643, 2603, 19490, 14, 199, 1309, 1092, 4521, 17, 275, 283, 10435, 17, 7, 199, 199, 3, 22016, 19490, 626, 12374, 279, 6491, 625, 4380, 83, 1183, 3747, 1338, 14, 199, 1309, 1092, 4521, 18, 275, 283, 10435, 18, 7, 199, 199, 3, 22016, 19490, 626, 12374, 279, 6491, 625, 4380, 83, 1183, 3747, 1338, 199, 3, 465, 5521, 465, 4534, 543, 7031, 5579, 402, 1338, 14, 199, 1309, 1092, 4521, 19, 275, 283, 10435, 19, 7, 199, 199, 6178, 2944, 5248, 63, 30476, 275, 359, 272, 32526, 1092, 4521, 17, 12, 272, 32526, 1092, 4521, 18, 12, 272, 32526, 1092, 4521, 19, 12, 199, 61, 199, 199, 3, 5870, 8753, 270, 2652, 11773, 12, 314, 9775, 402, 4212, 12474, 282, 663, 402, 5579, 199, 3, 365, 308, 8984, 734, 14, 199, 12349, 7140, 17, 275, 283, 6221, 17, 7, 199, 199, 3, 16485, 32526, 1092, 4521, 18, 12, 365, 314, 11773, 14609, 370, 12374, 279, 794, 3004, 543, 199, 3, 625, 4380, 83, 1183, 3747, 1338, 14, 199, 12349, 7140, 18, 275, 283, 6221, 18, 7, 199, 199, 26663, 32504, 63, 30476, 275, 359, 272, 30098, 7140, 17, 12, 272, 30098, 7140, 18, 12, 199, 61, 199, 199, 3472, 63, 6178, 2944, 5248, 63, 20141, 275, 32526, 1092, 4521, 17, 199, 3472, 63, 26663, 32504, 63, 20141, 275, 30098, 7140, 17, 199, 199, 3, 17653, 367, 10454, 1958, 314, 7914, 402, 14416, 315, 282, 27882, 14, 199, 16352, 63, 31840, 275, 283, 1452, 13, 3670, 7, 199, 25100, 1149, 63, 31840, 275, 283, 13522, 13, 3670, 7, 199, 34, 1719, 275, 283, 7010, 7, 199, 14083, 5616, 2594, 63, 18383, 275, 359, 272, 17152, 63, 31840, 12, 272, 644, 37, 2830, 1149, 63, 31840, 12, 272, 699, 1719, 12, 199, 61, 199, 199, 3, 21684, 270, 20772, 273, 18036, 14, 199, 39, 11415, 63, 27644, 10462, 275, 283, 2355, 7, 199, 39, 11415, 63, 13883, 63, 4896, 41, 63, 20813, 275, 283, 2495, 13, 18000, 13, 2912, 7, 199, 39, 11415, 63, 13883, 63, 568, 31431, 748, 275, 283, 2495, 13, 23760, 7, 199, 39, 11415, 63, 18383, 275, 359, 272, 598, 11415, 63, 27644, 10462, 12, 272, 598, 11415, 63, 13883, 63, 4896, 41, 63, 20813, 12, 272, 598, 11415, 63, 13883, 63, 568, 31431, 748, 12, 199, 61, 199, 199, 3, 3918, 1475, 1561, 14, 199, 5280, 63, 2711, 63, 2826, 4896, 748, 275, 4825, 45, 275, 283, 15998, 1582, 7, 199, 5280, 63, 2711, 63, 6178, 2944, 5248, 275, 7587, 275, 283, 23591, 7, 199, 5280, 63, 2711, 63, 26663, 32504, 275, 1868, 275, 283, 23458, 7, 199, 5280, 63, 6963, 63, 6885, 275, 445, 5296, 275, 283, 533, 7, 199, 5280, 63, 7311, 63, 10764, 275, 295, 14, 2014, 480, 7059, 12, 26, 2807, 304, 8, 15998, 1582, 92, 23591, 92, 23458, 18168, 447, 8, 533, 430, 18582, 199, 199, 318, 664, 63, 3670, 8, 3610, 304, 272, 408, 272, 17206, 4615, 15232, 14, 272, 408, 272, 372, 3089, 8, 3610, 2447, 1609, 8, 552, 8, 3610, 430, 199, 199, 318, 664, 63, 6221, 8, 3610, 304, 272, 408, 272, 17206, 11773, 15232, 14, 272, 408, 272, 333, 275, 664, 63, 3670, 8, 3610, 9, 272, 372, 3089, 1332, 86, 13, 77, 6422, 18, 367, 373, 315, 5412, 2447, 1609, 8, 552, 8, 3610, 430, 199, 199, 318, 4465, 63, 271, 12337, 8, 3610, 304, 272, 372, 3473, 14, 5079, 8, 362, 63, 6221, 8, 3610, 430, 199, 199, 318, 4615, 63, 6116, 63, 705, 8, 3610, 12, 3211, 304, 272, 408, 272, 17206, 4615, 3679, 1125, 15232, 14, 272, 408, 272, 702, 822, 8, 3610, 9, 508, 822, 8, 4525, 9, 272, 14981, 275, 359, 2101, 8, 65, 13, 66, 9, 367, 282, 12, 330, 315, 3482, 8, 3610, 12, 3211, 1874, 272, 372, 3089, 8, 17418, 2447, 1609, 8, 552, 8, 17418, 430, 199, 199, 318, 7666, 8, 3610, 304, 272, 408, 272, 22869, 83, 1924, 1329, 315, 314, 3414, 880, 626, 314, 3089, 402, 1006, 5579, 18527, 413, 14, 272, 408, 272, 308, 275, 2069, 8, 1838, 8, 3610, 430, 272, 372, 359, 86, 15, 83, 367, 373, 315, 5412, 61, 199, 199, 318, 9266, 70, 2055, 8, 88, 304, 272, 408, 272, 12515, 434, 695, 1125, 805, 14, 272, 408, 272, 1315, 275, 2853, 8, 88, 9, 272, 307, 275, 413, 14, 1182, 334, 17, 14, 435, 378, 14, 21, 10, 90, 9, 272, 519, 275, 307, 627, 3473, 14, 1474, 2801, 90, 10, 90, 13, 17, 14, 1479, 1229, 713, 1789, 11, 84, 5830, 17, 14, 993, 10008, 24, 11, 84, 5830, 14, 9880, 1643, 10800, 11, 267, 307, 5830, 14, 1643, 1822, 1349, 1085, 11, 84, 27436, 14, 11656, 1651, 11901, 11, 84, 5830, 14, 13909, 1184, 11369, 11, 267, 307, 27436, 17, 14, 8312, 1165, 13944, 11, 84, 5830, 17, 14, 11926, 28082, 1555, 11, 84, 27436, 14, 10228, 1046, 11583, 11, 267, 307, 4856, 11010, 1555, 9963, 7845, 430, 1724, 272, 340, 334, 88, 2356, 378, 14, 304, 267, 372, 519, 272, 587, 26, 267, 372, 499, 14, 446, 519, 199, 199, 318, 6316, 10790, 8, 88, 12, 8504, 12, 10819, 304, 272, 408, 272, 28571, 11562, 314, 12224, 626, 282, 3363, 13, 16611, 2196, 1750, 1323, 543, 282, 1627, 272, 12224, 4084, 911, 506, 1911, 737, 282, 574, 6656, 2419, 503, 4472, 370, 1323, 272, 315, 282, 3293, 4084, 14, 339, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 35, 453, 16813, 63, 4972, 63, 1593, 272, 408, 272, 307 ]
[ 199, 7409, 14, 17, 14, 1194, 445, 19982, 199, 2439, 12719, 367, 10015, 436, 1808, 282, 14692, 3123, 367, 12505, 503, 10864, 14, 199, 624, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 5055, 492, 10018, 199, 504, 6107, 492, 6345, 199, 504, 10933, 492, 10933, 199, 646, 1331, 199, 646, 7392, 199, 646, 3473, 199, 504, 3473, 492, 6682, 199, 646, 747, 199, 646, 2196, 199, 646, 295, 199, 646, 2882, 199, 646, 5927, 199, 199, 4612, 275, 334, 18, 12, 378, 12, 378, 9, 199, 363, 1023, 363, 275, 15671, 904, 8, 1130, 8, 495, 12, 15945, 430, 199, 199, 3, 12643, 2603, 19490, 14, 199, 1309, 1092, 4521, 17, 275, 283, 10435, 17, 7, 199, 199, 3, 22016, 19490, 626, 12374, 279, 6491, 625, 4380, 83, 1183, 3747, 1338, 14, 199, 1309, 1092, 4521, 18, 275, 283, 10435, 18, 7, 199, 199, 3, 22016, 19490, 626, 12374, 279, 6491, 625, 4380, 83, 1183, 3747, 1338, 199, 3, 465, 5521, 465, 4534, 543, 7031, 5579, 402, 1338, 14, 199, 1309, 1092, 4521, 19, 275, 283, 10435, 19, 7, 199, 199, 6178, 2944, 5248, 63, 30476, 275, 359, 272, 32526, 1092, 4521, 17, 12, 272, 32526, 1092, 4521, 18, 12, 272, 32526, 1092, 4521, 19, 12, 199, 61, 199, 199, 3, 5870, 8753, 270, 2652, 11773, 12, 314, 9775, 402, 4212, 12474, 282, 663, 402, 5579, 199, 3, 365, 308, 8984, 734, 14, 199, 12349, 7140, 17, 275, 283, 6221, 17, 7, 199, 199, 3, 16485, 32526, 1092, 4521, 18, 12, 365, 314, 11773, 14609, 370, 12374, 279, 794, 3004, 543, 199, 3, 625, 4380, 83, 1183, 3747, 1338, 14, 199, 12349, 7140, 18, 275, 283, 6221, 18, 7, 199, 199, 26663, 32504, 63, 30476, 275, 359, 272, 30098, 7140, 17, 12, 272, 30098, 7140, 18, 12, 199, 61, 199, 199, 3472, 63, 6178, 2944, 5248, 63, 20141, 275, 32526, 1092, 4521, 17, 199, 3472, 63, 26663, 32504, 63, 20141, 275, 30098, 7140, 17, 199, 199, 3, 17653, 367, 10454, 1958, 314, 7914, 402, 14416, 315, 282, 27882, 14, 199, 16352, 63, 31840, 275, 283, 1452, 13, 3670, 7, 199, 25100, 1149, 63, 31840, 275, 283, 13522, 13, 3670, 7, 199, 34, 1719, 275, 283, 7010, 7, 199, 14083, 5616, 2594, 63, 18383, 275, 359, 272, 17152, 63, 31840, 12, 272, 644, 37, 2830, 1149, 63, 31840, 12, 272, 699, 1719, 12, 199, 61, 199, 199, 3, 21684, 270, 20772, 273, 18036, 14, 199, 39, 11415, 63, 27644, 10462, 275, 283, 2355, 7, 199, 39, 11415, 63, 13883, 63, 4896, 41, 63, 20813, 275, 283, 2495, 13, 18000, 13, 2912, 7, 199, 39, 11415, 63, 13883, 63, 568, 31431, 748, 275, 283, 2495, 13, 23760, 7, 199, 39, 11415, 63, 18383, 275, 359, 272, 598, 11415, 63, 27644, 10462, 12, 272, 598, 11415, 63, 13883, 63, 4896, 41, 63, 20813, 12, 272, 598, 11415, 63, 13883, 63, 568, 31431, 748, 12, 199, 61, 199, 199, 3, 3918, 1475, 1561, 14, 199, 5280, 63, 2711, 63, 2826, 4896, 748, 275, 4825, 45, 275, 283, 15998, 1582, 7, 199, 5280, 63, 2711, 63, 6178, 2944, 5248, 275, 7587, 275, 283, 23591, 7, 199, 5280, 63, 2711, 63, 26663, 32504, 275, 1868, 275, 283, 23458, 7, 199, 5280, 63, 6963, 63, 6885, 275, 445, 5296, 275, 283, 533, 7, 199, 5280, 63, 7311, 63, 10764, 275, 295, 14, 2014, 480, 7059, 12, 26, 2807, 304, 8, 15998, 1582, 92, 23591, 92, 23458, 18168, 447, 8, 533, 430, 18582, 199, 199, 318, 664, 63, 3670, 8, 3610, 304, 272, 408, 272, 17206, 4615, 15232, 14, 272, 408, 272, 372, 3089, 8, 3610, 2447, 1609, 8, 552, 8, 3610, 430, 199, 199, 318, 664, 63, 6221, 8, 3610, 304, 272, 408, 272, 17206, 11773, 15232, 14, 272, 408, 272, 333, 275, 664, 63, 3670, 8, 3610, 9, 272, 372, 3089, 1332, 86, 13, 77, 6422, 18, 367, 373, 315, 5412, 2447, 1609, 8, 552, 8, 3610, 430, 199, 199, 318, 4465, 63, 271, 12337, 8, 3610, 304, 272, 372, 3473, 14, 5079, 8, 362, 63, 6221, 8, 3610, 430, 199, 199, 318, 4615, 63, 6116, 63, 705, 8, 3610, 12, 3211, 304, 272, 408, 272, 17206, 4615, 3679, 1125, 15232, 14, 272, 408, 272, 702, 822, 8, 3610, 9, 508, 822, 8, 4525, 9, 272, 14981, 275, 359, 2101, 8, 65, 13, 66, 9, 367, 282, 12, 330, 315, 3482, 8, 3610, 12, 3211, 1874, 272, 372, 3089, 8, 17418, 2447, 1609, 8, 552, 8, 17418, 430, 199, 199, 318, 7666, 8, 3610, 304, 272, 408, 272, 22869, 83, 1924, 1329, 315, 314, 3414, 880, 626, 314, 3089, 402, 1006, 5579, 18527, 413, 14, 272, 408, 272, 308, 275, 2069, 8, 1838, 8, 3610, 430, 272, 372, 359, 86, 15, 83, 367, 373, 315, 5412, 61, 199, 199, 318, 9266, 70, 2055, 8, 88, 304, 272, 408, 272, 12515, 434, 695, 1125, 805, 14, 272, 408, 272, 1315, 275, 2853, 8, 88, 9, 272, 307, 275, 413, 14, 1182, 334, 17, 14, 435, 378, 14, 21, 10, 90, 9, 272, 519, 275, 307, 627, 3473, 14, 1474, 2801, 90, 10, 90, 13, 17, 14, 1479, 1229, 713, 1789, 11, 84, 5830, 17, 14, 993, 10008, 24, 11, 84, 5830, 14, 9880, 1643, 10800, 11, 267, 307, 5830, 14, 1643, 1822, 1349, 1085, 11, 84, 27436, 14, 11656, 1651, 11901, 11, 84, 5830, 14, 13909, 1184, 11369, 11, 267, 307, 27436, 17, 14, 8312, 1165, 13944, 11, 84, 5830, 17, 14, 11926, 28082, 1555, 11, 84, 27436, 14, 10228, 1046, 11583, 11, 267, 307, 4856, 11010, 1555, 9963, 7845, 430, 1724, 272, 340, 334, 88, 2356, 378, 14, 304, 267, 372, 519, 272, 587, 26, 267, 372, 499, 14, 446, 519, 199, 199, 318, 6316, 10790, 8, 88, 12, 8504, 12, 10819, 304, 272, 408, 272, 28571, 11562, 314, 12224, 626, 282, 3363, 13, 16611, 2196, 1750, 1323, 543, 282, 1627, 272, 12224, 4084, 911, 506, 1911, 737, 282, 574, 6656, 2419, 503, 4472, 370, 1323, 272, 315, 282, 3293, 4084, 14, 339, 1455, 921, 287, 14, 13961, 14, 1308, 15, 6797, 15, 35, 453, 16813, 63, 4972, 63, 1593, 272, 408, 272, 307, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
endlessm/chromium-browser
native_client/pnacl/driver/pnacl-readelf.py
2
3751
#!/usr/bin/python # Copyright (c) 2012 The Native Client Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from __future__ import print_function from driver_env import env from driver_log import Log import driver_tools import filetype EXTRA_ENV = { 'INPUTS': '', 'FLAGS': '', } PATTERNS = [ ( '(-.*)', "env.append('FLAGS', $0)"), ( '(.*)', "env.append('INPUTS', pathtools.normalize($0))"), ] def main(argv): env.update(EXTRA_ENV) driver_tools.ParseArgs(argv, PATTERNS) inputs = env.get('INPUTS') if len(inputs) == 0: Log.Fatal("No input files given") for infile in inputs: driver_tools.CheckPathLength(infile) env.push() env.set('input', infile) if filetype.IsLLVMBitcode(infile): # Hack to support newlib build. # Newlib determines whether the toolchain supports .init_array, etc., by # compiling a small test and looking for a specific section tidbit using # "readelf -S". Since pnacl compiles to bitcode, readelf isn't available. # (there is a line: "if ${READELF} -S conftest | grep -e INIT_ARRAY" # in newlib's configure file). # TODO(sehr): we may want to implement a whole readelf on bitcode. flags = env.get('FLAGS') if len(flags) == 1 and flags[0] == '-S': print('INIT_ARRAY') return 0 Log.Fatal('Cannot handle pnacl-readelf %s' % str(argv)) return 1 driver_tools.Run('"${READELF}" ${FLAGS} ${input}') env.pop() # only reached in case of no errors return 0 def get_help(unused_argv): return """ Usage: %s <option(s)> elf-file(s) Display information about the contents of ELF format files Options are: -a --all Equivalent to: -h -l -S -s -r -d -V -A -I -h --file-header Display the ELF file header -l --program-headers Display the program headers --segments An alias for --program-headers -S --section-headers Display the sections' header --sections An alias for --section-headers -g --section-groups Display the section groups -t --section-details Display the section details -e --headers Equivalent to: -h -l -S -s --syms Display the symbol table --symbols An alias for --syms -n --notes Display the core notes (if present) -r --relocs Display the relocations (if present) -u --unwind Display the unwind info (if present) -d --dynamic Display the dynamic section (if present) -V --version-info Display the version sections (if present) -A --arch-specific Display architecture specific information (if any). -c --archive-index Display the symbol/file index in an archive -D --use-dynamic Use the dynamic section info when displaying symbols -x --hex-dump=<number|name> Dump the contents of section <number|name> as bytes -p --string-dump=<number|name> Dump the contents of section <number|name> as strings -R --relocated-dump=<number|name> Dump the contents of section <number|name> as relocated bytes -w[lLiaprmfFsoR] or --debug-dump[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=str,=loc,=Ranges] Display the contents of DWARF2 debug sections -I --histogram Display histogram of bucket list lengths -W --wide Allow output width to exceed 80 characters @<file> Read options from <file> -H --help Display this information -v --version Display the version number of readelf """ % env.getone('SCRIPT_NAME')
bsd-3-clause
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1898, 334, 67, 9, 6029, 710, 653, 1905, 6810, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 5253, 63, 1813, 492, 2589, 199, 504, 5253, 63, 793, 492, 5297, 199, 646, 5253, 63, 2537, 199, 646, 26245, 199, 199, 18555, 63, 9984, 275, 469, 523, 283, 7321, 51, 356, 258, 3260, 523, 283, 4831, 356, 420, 3260, 199, 93, 199, 199, 2805, 1157, 2709, 275, 359, 523, 334, 283, 2801, 2795, 3196, 259, 298, 1813, 14, 740, 360, 4831, 297, 2672, 16, 13185, 523, 334, 8189, 2795, 3196, 258, 298, 1813, 14, 740, 360, 7321, 51, 297, 931, 2537, 14, 7721, 22187, 16, 430, 1288, 199, 61, 199, 199, 318, 2446, 8, 3020, 304, 523, 2589, 14, 873, 8, 18555, 63, 9984, 9, 523, 5253, 63, 2537, 14, 4003, 6213, 8, 3020, 12, 31467, 1157, 2709, 9, 523, 4153, 275, 2589, 14, 362, 360, 7321, 51, 358, 523, 340, 822, 8, 3711, 9, 508, 378, 26, 272, 5297, 14, 19507, 480, 1944, 1324, 1584, 1627, 531, 819, 367, 14734, 315, 4153, 26, 272, 5253, 63, 2537, 14, 1799, 2042, 4625, 8, 13880, 9, 272, 2589, 14, 5335, 342, 272, 2589, 14, 409, 360, 1210, 297, 14734, 9, 272, 340, 26245, 14, 1831, 4464, 54, 4567, 390, 600, 8, 13880, 304, 489, 327, 30802, 370, 2291, 892, 773, 1900, 14, 489, 327, 7053, 773, 16756, 3775, 314, 22689, 5171, 1275, 826, 63, 1144, 12, 5423, 2020, 701, 489, 327, 1013, 5662, 282, 7425, 511, 436, 10023, 367, 282, 2488, 3420, 3367, 697, 390, 1808, 489, 327, 298, 8273, 271, 276, 446, 51, 1674, 9336, 299, 7745, 6555, 83, 370, 4546, 600, 12, 295, 9587, 276, 5712, 1133, 2808, 14, 489, 327, 334, 16990, 365, 282, 1004, 26, 298, 692, 10839, 24345, 4424, 38, 93, 446, 51, 3743, 396, 1204, 20595, 446, 69, 20199, 63, 12322, 2, 489, 327, 315, 892, 773, 1159, 7908, 570, 680, 489, 327, 3254, 8, 261, 6271, 304, 781, 1443, 2934, 370, 5669, 282, 8852, 295, 9587, 276, 641, 4546, 600, 14, 489, 3285, 275, 2589, 14, 362, 360, 4831, 358, 489, 340, 822, 8, 2469, 9, 508, 413, 436, 3285, 59, 16, 61, 508, 2475, 51, 356, 267, 870, 360, 8727, 63, 12322, 358, 267, 372, 378, 489, 5297, 14, 19507, 360, 6612, 2429, 299, 7745, 13, 8273, 271, 276, 450, 83, 7, 450, 620, 8, 3020, 430, 489, 372, 413, 272, 5253, 63, 2537, 14, 2540, 14088, 10545, 24345, 4424, 38, 7063, 10839, 4831, 93, 10839, 1210, 12216, 272, 2589, 14, 1935, 342, 819, 327, 1454, 13075, 315, 1930, 402, 949, 2552, 523, 372, 378, 199, 199, 318, 664, 63, 3437, 8, 8618, 63, 3020, 304, 523, 372, 408, 199, 7692, 26, 450, 83, 665, 1422, 8, 83, 13032, 325, 276, 13, 493, 8, 83, 9, 199, 12175, 2556, 3595, 314, 4072, 402, 662, 15965, 1475, 1584, 199, 8394, 787, 26, 523, 446, 65, 1553, 452, 5185, 24228, 370, 26, 446, 72, 446, 76, 446, 51, 446, 83, 446, 82, 446, 68, 446, 54, 446, 33, 446, 41, 523, 446, 72, 1553, 493, 13, 1291, 755, 12175, 314, 662, 15965, 570, 1406, 523, 446, 76, 1553, 6815, 13, 2139, 257, 12175, 314, 2240, 2323, 1362, 1553, 13879, 3515, 1626, 5162, 367, 1553, 6815, 13, 2139, 523, 446, 51, 1553, 2792, 13, 2139, 257, 12175, 314, 10189, 7, 1406, 1362, 1553, 7786, 3515, 1626, 5162, 367, 1553, 2792, 13, 2139, 523, 446, 71, 1553, 2792, 13, 2634, 259, 12175, 314, 3420, 4652, 523, 446, 84, 1553, 2792, 13, 5087, 257, 12175, 314, 3420, 2436, 523, 446, 69, 1553, 2139, 3698, 24228, 370, 26, 446, 72, 446, 76, 446, 51, 523, 446, 83, 1553, 13807, 4519, 12175, 314, 5272, 1817, 489, 1553, 7450, 3515, 1626, 5162, 367, 1553, 13807, 523, 446, 78, 1553, 5983, 3777, 12175, 314, 6170, 12681, 334, 692, 3451, 9, 523, 446, 82, 1553, 264, 15781, 3322, 12175, 314, 295, 8022, 334, 692, 3451, 9, 523, 446, 85, 1553, 324, 11530, 3322, 12175, 314, 625, 11530, 2256, 334, 692, 3451, 9, 523, 446, 68, 1553, 7764, 3698, 12175, 314, 8336, 3420, 334, 692, 3451, 9, 523, 446, 54, 1553, 1023, 13, 815, 420, 12175, 314, 1015, 10189, 334, 692, 3451, 9, 523, 446, 33, 1553, 1047, 13, 6100, 258, 12175, 15931, 2488, 2556, 334, 692, 1263, 680, 523, 446, 67, 1553, 6404, 13, 1080, 258, 12175, 314, 5272, 15, 493, 1478, 315, 376, 6359, 523, 446, 36, 1553, 1180, 13, 7764, 755, 3645, 314, 8336, 3420, 2256, 1380, 20589, 6698, 523, 446, 88, 1553, 4097, 13, 2724, 18987, 1955, 92, 354, 30, 586, 19460, 314, 4072, 402, 3420, 665, 1955, 92, 354, 30, 465, 2783, 523, 446, 80, 1553, 875, 13, 2724, 18987, 1955, 92, 354, 30, 586, 19460, 314, 4072, 402, 3420, 665, 1955, 92, 354, 30, 465, 3326, 523, 446, 50, 1553, 264, 13340, 13, 2724, 18987, 1955, 92, 354, 30, 586, 19460, 314, 4072, 402, 3420, 665, 1955, 92, 354, 30, 465, 295, 13340, 2783, 523, 446, 87, 59, 76, 13009, 439, 5682, 70, 38, 1152, 50, 61, 503, 523, 1553, 1757, 13, 2724, 59, 29, 1773, 604, 12, 29, 16167, 604, 12, 29, 815, 12, 29, 31349, 12, 29, 5645, 1247, 12, 29, 5605, 83, 12, 29, 11300, 12, 29, 8444, 12, 29, 495, 12, 29, 2102, 12, 29, 23019, 61, 586, 12175, 314, 4072, 402, 577, 2982, 38, 18, 3105, 10189, 523, 446, 41, 1553, 14805, 260, 12175, 15379, 402, 5315, 769, 17464, 523, 446, 55, 1553, 13062, 4519, 9812, 1072, 3462, 370, 24068, 5939, 4110, 523, 768, 28, 493, 30, 4483, 5574, 1511, 687, 665, 493, 30, 523, 446, 40, 1553, 3437, 4519, 12175, 642, 2556, 523, 446, 86, 1553, 1023, 3698, 12175, 314, 1015, 1329, 402, 295, 9587, 276, 199, 199, 624, 450, 2589, 14, 362, 368, 360, 10484, 63, 2339, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1898, 334, 67, 9, 6029, 710, 653, 1905, 6810, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 504, 5253, 63, 1813, 492, 2589, 199, 504, 5253, 63, 793, 492, 5297, 199, 646, 5253, 63, 2537, 199, 646, 26245, 199, 199, 18555, 63, 9984, 275, 469, 523, 283, 7321, 51, 356, 258, 3260, 523, 283, 4831, 356, 420, 3260, 199, 93, 199, 199, 2805, 1157, 2709, 275, 359, 523, 334, 283, 2801, 2795, 3196, 259, 298, 1813, 14, 740, 360, 4831, 297, 2672, 16, 13185, 523, 334, 8189, 2795, 3196, 258, 298, 1813, 14, 740, 360, 7321, 51, 297, 931, 2537, 14, 7721, 22187, 16, 430, 1288, 199, 61, 199, 199, 318, 2446, 8, 3020, 304, 523, 2589, 14, 873, 8, 18555, 63, 9984, 9, 523, 5253, 63, 2537, 14, 4003, 6213, 8, 3020, 12, 31467, 1157, 2709, 9, 523, 4153, 275, 2589, 14, 362, 360, 7321, 51, 358, 523, 340, 822, 8, 3711, 9, 508, 378, 26, 272, 5297, 14, 19507, 480, 1944, 1324, 1584, 1627, 531, 819, 367, 14734, 315, 4153, 26, 272, 5253, 63, 2537, 14, 1799, 2042, 4625, 8, 13880, 9, 272, 2589, 14, 5335, 342, 272, 2589, 14, 409, 360, 1210, 297, 14734, 9, 272, 340, 26245, 14, 1831, 4464, 54, 4567, 390, 600, 8, 13880, 304, 489, 327, 30802, 370, 2291, 892, 773, 1900, 14, 489, 327, 7053, 773, 16756, 3775, 314, 22689, 5171, 1275, 826, 63, 1144, 12, 5423, 2020, 701, 489, 327, 1013, 5662, 282, 7425, 511, 436, 10023, 367, 282, 2488, 3420, 3367, 697, 390, 1808, 489, 327, 298, 8273, 271, 276, 446, 51, 1674, 9336, 299, 7745, 6555, 83, 370, 4546, 600, 12, 295, 9587, 276, 5712, 1133, 2808, 14, 489, 327, 334, 16990, 365, 282, 1004, 26, 298, 692, 10839, 24345, 4424, 38, 93, 446, 51, 3743, 396, 1204, 20595, 446, 69, 20199, 63, 12322, 2, 489, 327, 315, 892, 773, 1159, 7908, 570, 680, 489, 327, 3254, 8, 261, 6271, 304, 781, 1443, 2934, 370, 5669, 282, 8852, 295, 9587, 276, 641, 4546, 600, 14, 489, 3285, 275, 2589, 14, 362, 360, 4831, 358, 489, 340, 822, 8, 2469, 9, 508, 413, 436, 3285, 59, 16, 61, 508, 2475, 51, 356, 267, 870, 360, 8727, 63, 12322, 358, 267, 372, 378, 489, 5297, 14, 19507, 360, 6612, 2429, 299, 7745, 13, 8273, 271, 276, 450, 83, 7, 450, 620, 8, 3020, 430, 489, 372, 413, 272, 5253, 63, 2537, 14, 2540, 14088, 10545, 24345, 4424, 38, 7063, 10839, 4831, 93, 10839, 1210, 12216, 272, 2589, 14, 1935, 342, 819, 327, 1454, 13075, 315, 1930, 402, 949, 2552, 523, 372, 378, 199, 199, 318, 664, 63, 3437, 8, 8618, 63, 3020, 304, 523, 372, 408, 199, 7692, 26, 450, 83, 665, 1422, 8, 83, 13032, 325, 276, 13, 493, 8, 83, 9, 199, 12175, 2556, 3595, 314, 4072, 402, 662, 15965, 1475, 1584, 199, 8394, 787, 26, 523, 446, 65, 1553, 452, 5185, 24228, 370, 26, 446, 72, 446, 76, 446, 51, 446, 83, 446, 82, 446, 68, 446, 54, 446, 33, 446, 41, 523, 446, 72, 1553, 493, 13, 1291, 755, 12175, 314, 662, 15965, 570, 1406, 523, 446, 76, 1553, 6815, 13, 2139, 257, 12175, 314, 2240, 2323, 1362, 1553, 13879, 3515, 1626, 5162, 367, 1553, 6815, 13, 2139, 523, 446, 51, 1553, 2792, 13, 2139, 257, 12175, 314, 10189, 7, 1406, 1362, 1553, 7786, 3515, 1626, 5162, 367, 1553, 2792, 13, 2139, 523, 446, 71, 1553, 2792, 13, 2634, 259, 12175, 314, 3420, 4652, 523, 446, 84, 1553, 2792, 13, 5087, 257, 12175, 314, 3420, 2436, 523, 446, 69, 1553, 2139, 3698, 24228, 370, 26, 446, 72, 446, 76, 446, 51, 523, 446, 83, 1553, 13807, 4519, 12175, 314, 5272, 1817, 489, 1553, 7450, 3515, 1626, 5162, 367, 1553, 13807, 523, 446, 78, 1553, 5983, 3777, 12175, 314, 6170, 12681, 334, 692, 3451, 9, 523, 446, 82, 1553, 264, 15781, 3322, 12175, 314, 295, 8022, 334, 692, 3451, 9, 523, 446, 85, 1553, 324, 11530, 3322, 12175, 314, 625, 11530, 2256, 334, 692, 3451, 9, 523, 446, 68, 1553, 7764, 3698, 12175, 314, 8336, 3420, 334, 692, 3451, 9, 523, 446, 54, 1553, 1023, 13, 815, 420, 12175, 314, 1015, 10189, 334, 692, 3451, 9, 523, 446, 33, 1553, 1047, 13, 6100, 258, 12175, 15931, 2488, 2556, 334, 692, 1263, 680, 523, 446, 67, 1553, 6404, 13, 1080, 258, 12175, 314, 5272, 15, 493, 1478, 315, 376, 6359, 523, 446, 36, 1553, 1180, 13, 7764, 755, 3645, 314, 8336, 3420, 2256, 1380, 20589, 6698, 523, 446, 88, 1553, 4097, 13, 2724, 18987, 1955, 92, 354, 30, 586, 19460, 314, 4072, 402, 3420, 665, 1955, 92, 354, 30, 465, 2783, 523, 446, 80, 1553, 875, 13, 2724, 18987, 1955, 92, 354, 30, 586, 19460, 314, 4072, 402, 3420, 665, 1955, 92, 354, 30, 465, 3326, 523, 446, 50, 1553, 264, 13340, 13, 2724, 18987, 1955, 92, 354, 30, 586, 19460, 314, 4072, 402, 3420, 665, 1955, 92, 354, 30, 465, 295, 13340, 2783, 523, 446, 87, 59, 76, 13009, 439, 5682, 70, 38, 1152, 50, 61, 503, 523, 1553, 1757, 13, 2724, 59, 29, 1773, 604, 12, 29, 16167, 604, 12, 29, 815, 12, 29, 31349, 12, 29, 5645, 1247, 12, 29, 5605, 83, 12, 29, 11300, 12, 29, 8444, 12, 29, 495, 12, 29, 2102, 12, 29, 23019, 61, 586, 12175, 314, 4072, 402, 577, 2982, 38, 18, 3105, 10189, 523, 446, 41, 1553, 14805, 260, 12175, 15379, 402, 5315, 769, 17464, 523, 446, 55, 1553, 13062, 4519, 9812, 1072, 3462, 370, 24068, 5939, 4110, 523, 768, 28, 493, 30, 4483, 5574, 1511, 687, 665, 493, 30, 523, 446, 40, 1553, 3437, 4519, 12175, 642, 2556, 523, 446, 86, 1553, 1023, 3698, 12175, 314, 1015, 1329, 402, 295, 9587, 276, 199, 199, 624, 450, 2589, 14, 362, 368, 360, 10484, 63, 2339, 358, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
kreatorkodi/repository.torrentbr
script.module.urlresolver/lib/urlresolver/plugins/lib/recaptcha_v2.py
1
7299
# -*- coding: utf-8 -*- """ urlresolver XBMC Addon Copyright (C) 2016 tknorris Derived from Shani's LPro Code (https://github.com/Shani-08/ShaniXBMCWork2/blob/master/plugin.video.live.streamspro/unCaptcha.py) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. reusable captcha methods """ import re import os import xbmcgui from urlresolver import common class cInputWindow(xbmcgui.WindowDialog): def __init__(self, *args, **kwargs): bg_image = os.path.join(common.addon_path, 'resources', 'images', 'DialogBack2.png') check_image = os.path.join(common.addon_path, 'resources', 'images', 'checked.png') button_fo = os.path.join(common.kodi.get_path(), 'resources', 'skins', 'Default', 'media', 'button-fo.png') button_nofo = os.path.join(common.kodi.get_path(), 'resources', 'skins', 'Default', 'media', 'button-nofo.png') self.cancelled = False self.chk = [0] * 9 self.chkbutton = [0] * 9 self.chkstate = [False] * 9 imgX, imgY, imgw, imgh = 436, 210, 408, 300 ph, pw = imgh / 3, imgw / 3 x_gap = 70 y_gap = 70 button_gap = 40 button_h = 40 button_y = imgY + imgh + button_gap middle = imgX + (imgw / 2) win_x = imgX - x_gap win_y = imgY - y_gap win_h = imgh + 2 * y_gap + button_h + button_gap win_w = imgw + 2 * x_gap ctrlBackgound = xbmcgui.ControlImage(win_x, win_y, win_w, win_h, bg_image) self.addControl(ctrlBackgound) self.msg = '[COLOR red]%s[/COLOR]' % (kwargs.get('msg')) self.strActionInfo = xbmcgui.ControlLabel(imgX, imgY - 30, imgw, 20, self.msg, 'font13') self.addControl(self.strActionInfo) img = xbmcgui.ControlImage(imgX, imgY, imgw, imgh, kwargs.get('captcha')) self.addControl(img) self.iteration = kwargs.get('iteration') self.strActionInfo = xbmcgui.ControlLabel(imgX, imgY + imgh, imgw, 20, common.i18n('captcha_round') % (str(self.iteration)), 'font40') self.addControl(self.strActionInfo) self.cancelbutton = xbmcgui.ControlButton(middle - 110, button_y, 100, button_h, common.i18n('cancel'), focusTexture=button_fo, noFocusTexture=button_nofo, alignment=2) self.okbutton = xbmcgui.ControlButton(middle + 10, button_y, 100, button_h, common.i18n('ok'), focusTexture=button_fo, noFocusTexture=button_nofo, alignment=2) self.addControl(self.okbutton) self.addControl(self.cancelbutton) for i in xrange(9): row = i / 3 col = i % 3 x_pos = imgX + (pw * col) y_pos = imgY + (ph * row) self.chk[i] = xbmcgui.ControlImage(x_pos, y_pos, pw, ph, check_image) self.addControl(self.chk[i]) self.chk[i].setVisible(False) self.chkbutton[i] = xbmcgui.ControlButton(x_pos, y_pos, pw, ph, str(i + 1), font='font1', focusTexture=button_fo, noFocusTexture=button_nofo) self.addControl(self.chkbutton[i]) for i in xrange(9): row_start = (i / 3) * 3 right = row_start + (i + 1) % 3 left = row_start + (i - 1) % 3 up = (i - 3) % 9 down = (i + 3) % 9 self.chkbutton[i].controlRight(self.chkbutton[right]) self.chkbutton[i].controlLeft(self.chkbutton[left]) if i <= 2: self.chkbutton[i].controlUp(self.okbutton) else: self.chkbutton[i].controlUp(self.chkbutton[up]) if i >= 6: self.chkbutton[i].controlDown(self.okbutton) else: self.chkbutton[i].controlDown(self.chkbutton[down]) self.okbutton.controlLeft(self.cancelbutton) self.okbutton.controlRight(self.cancelbutton) self.cancelbutton.controlLeft(self.okbutton) self.cancelbutton.controlRight(self.okbutton) self.okbutton.controlDown(self.chkbutton[2]) self.okbutton.controlUp(self.chkbutton[8]) self.cancelbutton.controlDown(self.chkbutton[0]) self.cancelbutton.controlUp(self.chkbutton[6]) self.setFocus(self.okbutton) def get(self): self.doModal() self.close() if not self.cancelled: return [i for i in xrange(9) if self.chkstate[i]] def onControl(self, control): if control == self.okbutton and any(self.chkstate): self.close() elif control == self.cancelbutton: self.cancelled = True self.close() else: label = control.getLabel() if label.isnumeric(): index = int(label) - 1 self.chkstate[index] = not self.chkstate[index] self.chk[index].setVisible(self.chkstate[index]) def onAction(self, action): if action == 10: self.cancelled = True self.close() class UnCaptchaReCaptcha: net = common.Net() def processCaptcha(self, key, lang): headers = {'Referer': 'https://www.google.com/recaptcha/api2/demo', 'Accept-Language': lang} html = self.net.http_GET('http://www.google.com/recaptcha/api/fallback?k=%s' % (key), headers=headers).content token = '' iteration = 0 while True: payload = re.findall('"(/recaptcha/api2/payload[^"]+)', html) iteration += 1 message = re.findall('<label[^>]+class="fbc-imageselect-message-text"[^>]*>(.*?)</label>', html) if not message: message = re.findall('<div[^>]+class="fbc-imageselect-message-error">(.*?)</div>', html) if not message: token = re.findall('"this\.select\(\)">(.*?)</textarea>', html)[0] if token: common.log_utils.log_debug('Captcha Success: %s' % (token)) else: common.log_utils.log_debug('Captcha Failed: %s') break else: message = message[0] payload = payload[0] cval = re.findall('name="c"\s+value="([^"]+)', html)[0] captcha_imgurl = 'https://www.google.com%s' % (payload.replace('&amp;', '&')) message = re.sub('</?strong>', '', message) oSolver = cInputWindow(captcha=captcha_imgurl, msg=message, iteration=iteration) captcha_response = oSolver.get() if not captcha_response: break data = {'c': cval, 'response': captcha_response} html = self.net.http_POST("http://www.google.com/recaptcha/api/fallback?k=%s" % (key), form_data=data, headers=headers).content return token
gpl-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 1166, 7717, 1323, 28994, 29366, 272, 1898, 334, 35, 9, 7800, 10157, 6505, 5719, 272, 27731, 687, 5244, 26455, 1159, 491, 919, 5495, 334, 2859, 921, 5031, 14, 957, 15, 2662, 26455, 13, 2036, 15, 2662, 26455, 20806, 7608, 6517, 18, 15, 6582, 15, 4133, 15, 2718, 14, 3722, 14, 6442, 14, 11231, 496, 15, 324, 13519, 9518, 14, 647, 9, 339, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 272, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 272, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 339, 295, 14418, 12162, 9518, 3102, 199, 624, 199, 646, 295, 199, 646, 747, 199, 646, 26418, 199, 504, 1166, 7717, 492, 2863, 199, 199, 533, 286, 3205, 4301, 8, 21382, 5885, 14, 4301, 5619, 304, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 12994, 63, 1569, 275, 747, 14, 515, 14, 904, 8, 2330, 14, 9291, 63, 515, 12, 283, 4435, 297, 283, 4782, 297, 283, 5619, 4540, 18, 14, 4524, 358, 267, 1104, 63, 1569, 275, 747, 14, 515, 14, 904, 8, 2330, 14, 9291, 63, 515, 12, 283, 4435, 297, 283, 4782, 297, 283, 10718, 14, 4524, 358, 267, 5528, 63, 545, 275, 747, 14, 515, 14, 904, 8, 2330, 14, 7697, 328, 14, 362, 63, 515, 1062, 283, 4435, 297, 283, 1339, 3617, 297, 283, 2698, 297, 283, 4603, 297, 283, 3887, 13, 545, 14, 4524, 358, 267, 5528, 63, 889, 545, 275, 747, 14, 515, 14, 904, 8, 2330, 14, 7697, 328, 14, 362, 63, 515, 1062, 283, 4435, 297, 283, 1339, 3617, 297, 283, 2698, 297, 283, 4603, 297, 283, 3887, 13, 889, 545, 14, 4524, 358, 267, 291, 14, 21924, 275, 756, 267, 291, 14, 14823, 275, 359, 16, 61, 627, 1749, 267, 291, 14, 14823, 3887, 275, 359, 16, 61, 627, 1749, 267, 291, 14, 14823, 929, 275, 359, 797, 61, 627, 1749, 398, 6050, 56, 12, 6050, 57, 12, 6050, 87, 12, 3416, 3561, 275, 841, 1344, 12, 26160, 12, 841, 2036, 12, 9601, 267, 3945, 12, 19206, 275, 3416, 3561, 1182, 650, 12, 6050, 87, 1182, 650, 267, 671, 63, 15046, 275, 10045, 267, 612, 63, 15046, 275, 10045, 267, 5528, 63, 15046, 275, 6335, 267, 5528, 63, 72, 275, 6335, 267, 5528, 63, 89, 275, 6050, 57, 435, 3416, 3561, 435, 5528, 63, 15046, 267, 12180, 275, 6050, 56, 435, 334, 4060, 87, 1182, 499, 9, 267, 4747, 63, 88, 275, 6050, 56, 446, 671, 63, 15046, 267, 4747, 63, 89, 275, 6050, 57, 446, 612, 63, 15046, 267, 4747, 63, 72, 275, 3416, 3561, 435, 499, 627, 612, 63, 15046, 435, 5528, 63, 72, 435, 5528, 63, 15046, 267, 4747, 63, 87, 275, 6050, 87, 435, 499, 627, 671, 63, 15046, 398, 15427, 4540, 71, 1034, 275, 26418, 14, 3717, 3491, 8, 2676, 63, 88, 12, 4747, 63, 89, 12, 4747, 63, 87, 12, 4747, 63, 72, 12, 12994, 63, 1569, 9, 267, 291, 14, 525, 3717, 8, 12476, 4540, 71, 1034, 9, 267, 291, 14, 1328, 275, 6730, 7134, 8992, 61, 5, 83, 28787, 7134, 6616, 450, 334, 958, 14, 362, 360, 1328, 1333, 267, 291, 14, 495, 3310, 2354, 275, 26418, 14, 3717, 4314, 8, 4060, 56, 12, 6050, 57, 446, 4233, 12, 6050, 87, 12, 3388, 12, 291, 14, 1328, 12, 283, 4246, 969, 358, 267, 291, 14, 525, 3717, 8, 277, 14, 495, 3310, 2354, 9, 267, 6050, 275, 26418, 14, 3717, 3491, 8, 4060, 56, 12, 6050, 57, 12, 6050, 87, 12, 3416, 3561, 12, 2074, 14, 362, 360, 20559, 1333, 267, 291, 14, 525, 3717, 8, 4060, 9, 267, 291, 14, 12575, 275, 2074, 14, 362, 360, 12575, 358, 267, 291, 14, 495, 3310, 2354, 275, 26418, 14, 3717, 4314, 8, 4060, 56, 12, 6050, 57, 435, 3416, 3561, 12, 6050, 87, 12, 3388, 12, 2863, 14, 73, 1085, 78, 360, 20559, 63, 2363, 358, 450, 334, 495, 8, 277, 14, 12575, 1826, 283, 4246, 2167, 358, 267, 291, 14, 525, 3717, 8, 277, 14, 495, 3310, 2354, 9, 267, 291, 14, 6406, 3887, 275, 26418, 14, 3717, 4259, 8, 14885, 446, 16814, 12, 5528, 63, 89, 12, 2948, 12, 5528, 63, 72, 12, 2863, 14, 73, 1085, 78, 360, 6406, 659, 16470, 17165, 29, 3887, 63, 545, 12, 949, 17310, 17165, 29, 3887, 63, 889, 545, 12, 13177, 29, 18, 9, 267, 291, 14, 745, 3887, 275, 26418, 14, 3717, 4259, 8, 14885, 435, 1616, 12, 5528, 63, 89, 12, 2948, 12, 5528, 63, 72, 12, 2863, 14, 73, 1085, 78, 360, 745, 659, 16470, 17165, 29, 3887, 63, 545, 12, 949, 17310, 17165, 29, 3887, 63, 889, 545, 12, 13177, 29, 18, 9, 267, 291, 14, 525, 3717, 8, 277, 14, 745, 3887, 9, 267, 291, 14, 525, 3717, 8, 277, 14, 6406, 3887, 9, 398, 367, 284, 315, 4945, 8, 25, 304, 288, 1962, 275, 284, 1182, 650, 288, 1048, 275, 284, 450, 650, 288, 671, 63, 1712, 275, 6050, 56, 435, 334, 8796, 627, 1048, 9, 288, 612, 63, 1712, 275, 6050, 57, 435, 334, 838, 627, 1962, 9, 288, 291, 14, 14823, 59, 73, 61, 275, 26418, 14, 3717, 3491, 8, 88, 63, 1712, 12, 612, 63, 1712, 12, 19206, 12, 3945, 12, 1104, 63, 1569, 9, 288, 291, 14, 525, 3717, 8, 277, 14, 14823, 59, 73, 566, 288, 291, 14, 14823, 59, 73, 1055, 32232, 8, 797, 9, 288, 291, 14, 14823, 3887, 59, 73, 61 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 624, 272, 1166, 7717, 1323, 28994, 29366, 272, 1898, 334, 35, 9, 7800, 10157, 6505, 5719, 272, 27731, 687, 5244, 26455, 1159, 491, 919, 5495, 334, 2859, 921, 5031, 14, 957, 15, 2662, 26455, 13, 2036, 15, 2662, 26455, 20806, 7608, 6517, 18, 15, 6582, 15, 4133, 15, 2718, 14, 3722, 14, 6442, 14, 11231, 496, 15, 324, 13519, 9518, 14, 647, 9, 339, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 272, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 272, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 272, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 339, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 272, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 272, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 272, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 339, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 272, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 339, 295, 14418, 12162, 9518, 3102, 199, 624, 199, 646, 295, 199, 646, 747, 199, 646, 26418, 199, 504, 1166, 7717, 492, 2863, 199, 199, 533, 286, 3205, 4301, 8, 21382, 5885, 14, 4301, 5619, 304, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 12994, 63, 1569, 275, 747, 14, 515, 14, 904, 8, 2330, 14, 9291, 63, 515, 12, 283, 4435, 297, 283, 4782, 297, 283, 5619, 4540, 18, 14, 4524, 358, 267, 1104, 63, 1569, 275, 747, 14, 515, 14, 904, 8, 2330, 14, 9291, 63, 515, 12, 283, 4435, 297, 283, 4782, 297, 283, 10718, 14, 4524, 358, 267, 5528, 63, 545, 275, 747, 14, 515, 14, 904, 8, 2330, 14, 7697, 328, 14, 362, 63, 515, 1062, 283, 4435, 297, 283, 1339, 3617, 297, 283, 2698, 297, 283, 4603, 297, 283, 3887, 13, 545, 14, 4524, 358, 267, 5528, 63, 889, 545, 275, 747, 14, 515, 14, 904, 8, 2330, 14, 7697, 328, 14, 362, 63, 515, 1062, 283, 4435, 297, 283, 1339, 3617, 297, 283, 2698, 297, 283, 4603, 297, 283, 3887, 13, 889, 545, 14, 4524, 358, 267, 291, 14, 21924, 275, 756, 267, 291, 14, 14823, 275, 359, 16, 61, 627, 1749, 267, 291, 14, 14823, 3887, 275, 359, 16, 61, 627, 1749, 267, 291, 14, 14823, 929, 275, 359, 797, 61, 627, 1749, 398, 6050, 56, 12, 6050, 57, 12, 6050, 87, 12, 3416, 3561, 275, 841, 1344, 12, 26160, 12, 841, 2036, 12, 9601, 267, 3945, 12, 19206, 275, 3416, 3561, 1182, 650, 12, 6050, 87, 1182, 650, 267, 671, 63, 15046, 275, 10045, 267, 612, 63, 15046, 275, 10045, 267, 5528, 63, 15046, 275, 6335, 267, 5528, 63, 72, 275, 6335, 267, 5528, 63, 89, 275, 6050, 57, 435, 3416, 3561, 435, 5528, 63, 15046, 267, 12180, 275, 6050, 56, 435, 334, 4060, 87, 1182, 499, 9, 267, 4747, 63, 88, 275, 6050, 56, 446, 671, 63, 15046, 267, 4747, 63, 89, 275, 6050, 57, 446, 612, 63, 15046, 267, 4747, 63, 72, 275, 3416, 3561, 435, 499, 627, 612, 63, 15046, 435, 5528, 63, 72, 435, 5528, 63, 15046, 267, 4747, 63, 87, 275, 6050, 87, 435, 499, 627, 671, 63, 15046, 398, 15427, 4540, 71, 1034, 275, 26418, 14, 3717, 3491, 8, 2676, 63, 88, 12, 4747, 63, 89, 12, 4747, 63, 87, 12, 4747, 63, 72, 12, 12994, 63, 1569, 9, 267, 291, 14, 525, 3717, 8, 12476, 4540, 71, 1034, 9, 267, 291, 14, 1328, 275, 6730, 7134, 8992, 61, 5, 83, 28787, 7134, 6616, 450, 334, 958, 14, 362, 360, 1328, 1333, 267, 291, 14, 495, 3310, 2354, 275, 26418, 14, 3717, 4314, 8, 4060, 56, 12, 6050, 57, 446, 4233, 12, 6050, 87, 12, 3388, 12, 291, 14, 1328, 12, 283, 4246, 969, 358, 267, 291, 14, 525, 3717, 8, 277, 14, 495, 3310, 2354, 9, 267, 6050, 275, 26418, 14, 3717, 3491, 8, 4060, 56, 12, 6050, 57, 12, 6050, 87, 12, 3416, 3561, 12, 2074, 14, 362, 360, 20559, 1333, 267, 291, 14, 525, 3717, 8, 4060, 9, 267, 291, 14, 12575, 275, 2074, 14, 362, 360, 12575, 358, 267, 291, 14, 495, 3310, 2354, 275, 26418, 14, 3717, 4314, 8, 4060, 56, 12, 6050, 57, 435, 3416, 3561, 12, 6050, 87, 12, 3388, 12, 2863, 14, 73, 1085, 78, 360, 20559, 63, 2363, 358, 450, 334, 495, 8, 277, 14, 12575, 1826, 283, 4246, 2167, 358, 267, 291, 14, 525, 3717, 8, 277, 14, 495, 3310, 2354, 9, 267, 291, 14, 6406, 3887, 275, 26418, 14, 3717, 4259, 8, 14885, 446, 16814, 12, 5528, 63, 89, 12, 2948, 12, 5528, 63, 72, 12, 2863, 14, 73, 1085, 78, 360, 6406, 659, 16470, 17165, 29, 3887, 63, 545, 12, 949, 17310, 17165, 29, 3887, 63, 889, 545, 12, 13177, 29, 18, 9, 267, 291, 14, 745, 3887, 275, 26418, 14, 3717, 4259, 8, 14885, 435, 1616, 12, 5528, 63, 89, 12, 2948, 12, 5528, 63, 72, 12, 2863, 14, 73, 1085, 78, 360, 745, 659, 16470, 17165, 29, 3887, 63, 545, 12, 949, 17310, 17165, 29, 3887, 63, 889, 545, 12, 13177, 29, 18, 9, 267, 291, 14, 525, 3717, 8, 277, 14, 745, 3887, 9, 267, 291, 14, 525, 3717, 8, 277, 14, 6406, 3887, 9, 398, 367, 284, 315, 4945, 8, 25, 304, 288, 1962, 275, 284, 1182, 650, 288, 1048, 275, 284, 450, 650, 288, 671, 63, 1712, 275, 6050, 56, 435, 334, 8796, 627, 1048, 9, 288, 612, 63, 1712, 275, 6050, 57, 435, 334, 838, 627, 1962, 9, 288, 291, 14, 14823, 59, 73, 61, 275, 26418, 14, 3717, 3491, 8, 88, 63, 1712, 12, 612, 63, 1712,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
histed/pylibnidaqmxMH
nidaqmx/optparse_options.py
16
8570
import os from optparse import OptionGroup def get_method_arguments(methodname, options, kws=None): args = [] if kws is None: kws = {} for name in dir (options): value = getattr (options, name) if name.startswith(methodname) and value is not None: kws[name[len(methodname)+1:]] = value return tuple(args), kws def set_di_options (parser): if os.name == 'posix': parser.run_methods = ['subcommand'] import nidaqmx from nidaqmx.libnidaqmx import make_pattern parser.set_usage ('''\ %prog [options] Description: %prog provides graphical interface to NIDAQmx digital input task. ''') phys_channel_choices = [] for dev in nidaqmx.DigitalInputTask.get_system_devices(): phys_channel_choices.extend(dev.get_digital_input_lines()) pattern = make_pattern(phys_channel_choices) parser.add_option ('--create-channel-lines', type = 'string', help = 'Specify digital lines as a pattern ['+pattern+']. Default: %default.') get_digital_io_options_group (parser, parser) get_di_read_options_group (parser, parser) parser.add_option('--di-task', default = 'print', choices = ['print']) def set_do_options (parser): if os.name == 'posix': parser.run_methods = ['subcommand'] import nidaqmx from nidaqmx.libnidaqmx import make_pattern parser.set_usage ('''\ %prog [options] Description: %prog provides graphical interface to NIDAQmx digital output task. ''') phys_channel_choices = [] for dev in nidaqmx.DigitalOutputTask.get_system_devices(): phys_channel_choices.extend(dev.get_digital_output_lines()) pattern = make_pattern(phys_channel_choices) parser.add_option ('--create-channel-lines', type = 'string', help = 'Specify digital lines as a pattern ['+pattern+']. Default: %default.') get_digital_io_options_group (parser, parser) get_do_write_options_group (parser, parser) parser.add_option('--do-task', default = 'scalar1', choices = ['scalar1', 'scalar0', 'ten', 'tenfive']) parser.add_option ('--do-task-duration', type = 'float', default = 60.0) def set_ai_options (parser): if os.name == 'posix': parser.run_methods = ['subcommand'] import nidaqmx from nidaqmx.libnidaqmx import make_pattern parser.set_usage ('''\ %prog [options] Description: %prog provides graphical interface to NIDAQmx analog input task. ''') ai_phys_channel_choices = [] for dev in nidaqmx.AnalogInputTask.get_system_devices(): ai_phys_channel_choices.extend(dev.get_analog_input_channels()) pattern = make_pattern(ai_phys_channel_choices) parser.add_option ('--create-voltage-channel-phys-channel', type = 'string', help = 'Specify physical channel as a pattern ['+pattern+']. Default: %default.') get_analog_io_options_group (parser, parser) get_ai_read_options_group (parser, parser) parser.add_option('--ai-task', default = 'print', choices = ['print', 'plot', 'show']) parser.add_option_group (get_configure_timing_options_group (parser)) def set_ao_options (parser): if os.name == 'posix': parser.run_methods = ['subcommand'] import nidaqmx from nidaqmx.libnidaqmx import make_pattern parser.set_usage ('''\ %prog [options] Description: %prog provides graphical interface to NIDAQmx analog output task. ''') ao_phys_channel_choices = [] for dev in nidaqmx.AnalogOutputTask.get_system_devices(): ao_phys_channel_choices.extend(dev.get_analog_output_channels()) pattern = make_pattern(ao_phys_channel_choices) parser.add_option ('--create-voltage-channel-phys-channel', type = 'string', help = 'Specify physical channel as a pattern ['+pattern+']. Default: %default.') get_analog_io_options_group(parser, parser, skip_terminal=True) get_ao_write_options_group (parser, parser) parser.add_option('--ao-task', default = 'sin', choices = ['sin']) parser.add_option ('--ao-task-duration', type = 'float', default = 10.0) parser.add_option_group (get_configure_timing_options_group (parser)) def get_configure_timing_options_group(parser, group=None): if group is None: group = OptionGroup(parser, 'Timing options') group.add_option ('--configure-timing-sample-clock-source', type = 'string', default='OnboardClock', ) group.add_option ('--configure-timing-sample-clock-rate', default = 1.0, type = 'float', ) group.add_option ('--configure-timing-sample-clock-active-edge', choices = ['rising','falling'], ) group.add_option ('--configure-timing-sample-clock-sample-mode', default = 'continuous', choices = ['finite','continuous','hwtimed']) group.add_option ('--configure-timing-sample-clock-samples-per-channel', type = 'int' ) return group def get_analog_io_options_group (parser, group=None, skip_terminal=False): if group is None: group = OptionGroup (parser, 'Analog I/O options') group.add_option ('--create-voltage-channel-channel-name', type = 'string') if not skip_terminal: group.add_option ('--create-voltage-channel-terminal', choices = ['default','rse','nrse','diff','pseudodiff']) group.add_option ('--create-voltage-channel-min-val', type = 'float') group.add_option ('--create-voltage-channel-max-val', type = 'float', ) group.add_option ('--create-voltage-channel-units', choices = ['volts', 'custom']) group.add_option ('--create-voltage-channel-custom-scale-name') return group def get_digital_io_options_group (parser, group=None): if group is None: group = OptionGroup (parser, 'Digital I/O options') group.add_option ('--create-channel-name', type = 'string') group.add_option ('--create-channel-grouping', choices = ['per_line', 'for_all_lines'] ) return group def get_ai_read_options_group(parser, group=None): assert group is not None, `group` group.add_option ('--ai-read-samples-per-channel', type = 'int') group.add_option ('--ai-read-timeout', default = 10.0, type = 'float') group.add_option ('--ai-read-fill-mode', choices = ['group_by_scan_number','group_by_channel']) return group def get_di_read_options_group(parser, group=None): assert group is not None, `group` group.add_option ('--di-read-samples-per-channel', type = 'int') group.add_option ('--di-read-timeout', default = 10.0, type = 'float') group.add_option ('--di-read-fill-mode', choices = ['group_by_scan_number','group_by_channel']) return group def get_ao_write_options_group(parser, group=None): assert group is not None, `group` group.add_option ('--ao-write-auto-start', action='store_true') group.add_option ('--no-ao-write-auto-start', dest='ao_write_auto_start', action='store_false') group.add_option ('--ao-write-timeout', default = 10.0, type = 'float') group.add_option ('--ao-write-layout', choices = ['group_by_scan_number','group_by_channel']) return group def get_do_write_options_group(parser, group=None): assert group is not None, `group` group.add_option ('--do-write-auto-start', action='store_true') group.add_option ('--no-do-write-auto-start', dest='do_write_auto_start', action='store_false') group.add_option ('--do-write-timeout', default = 10.0, type = 'float') group.add_option ('--do-write-layout', choices = ['group_by_scan_number','group_by_channel']) return group
bsd-3-clause
[ 199, 646, 747, 199, 504, 8691, 492, 3207, 2448, 199, 199, 318, 664, 63, 765, 63, 4958, 8, 765, 354, 12, 1511, 12, 4775, 83, 29, 403, 304, 272, 1249, 275, 942, 272, 340, 4775, 83, 365, 488, 26, 267, 4775, 83, 275, 1052, 272, 367, 536, 315, 2935, 334, 1419, 304, 267, 574, 275, 2519, 334, 1419, 12, 536, 9, 267, 340, 536, 14, 2460, 8, 765, 354, 9, 436, 574, 365, 440, 488, 26, 288, 4775, 83, 59, 354, 59, 552, 8, 765, 354, 6393, 17, 21316, 275, 574, 272, 372, 2008, 8, 589, 395, 4775, 83, 199, 199, 318, 663, 63, 328, 63, 1419, 334, 2087, 304, 272, 340, 747, 14, 354, 508, 283, 9228, 356, 267, 1798, 14, 1065, 63, 2474, 275, 788, 954, 1531, 418, 339, 492, 302, 29132, 81, 9457, 272, 687, 302, 29132, 81, 9457, 14, 773, 78, 29132, 81, 9457, 492, 1852, 63, 3401, 272, 1798, 14, 409, 63, 3807, 661, 891, 60, 199, 5, 6595, 359, 1419, 61, 199, 199, 5831, 26, 523, 450, 6595, 6571, 3343, 2652, 3217, 370, 653, 998, 20152, 9457, 20545, 1324, 2120, 14, 199, 12310, 272, 3945, 588, 63, 2775, 63, 4577, 275, 942, 272, 367, 4866, 315, 302, 29132, 81, 9457, 14, 32660, 3205, 4476, 14, 362, 63, 2253, 63, 6410, 837, 267, 3945, 588, 63, 2775, 63, 4577, 14, 2880, 8, 2374, 14, 362, 63, 25888, 63, 1210, 63, 1278, 1012, 272, 3851, 275, 1852, 63, 3401, 8, 26827, 63, 2775, 63, 4577, 9, 272, 1798, 14, 525, 63, 1422, 26362, 981, 13, 2775, 13, 1278, 297, 2432, 730, 275, 283, 875, 297, 2432, 1720, 275, 283, 17768, 20545, 2385, 465, 282, 3851, 788, 11, 3401, 11, 2278, 3758, 26, 450, 885, 2659, 272, 664, 63, 25888, 63, 2308, 63, 1419, 63, 923, 334, 2087, 12, 1798, 9, 272, 664, 63, 328, 63, 739, 63, 1419, 63, 923, 334, 2087, 12, 1798, 9, 272, 1798, 14, 525, 63, 1422, 4517, 328, 13, 1765, 297, 1993, 849, 275, 283, 1361, 297, 1993, 3415, 275, 788, 1361, 1105, 199, 199, 318, 663, 63, 1117, 63, 1419, 334, 2087, 304, 272, 340, 747, 14, 354, 508, 283, 9228, 356, 267, 1798, 14, 1065, 63, 2474, 275, 788, 954, 1531, 418, 339, 492, 302, 29132, 81, 9457, 272, 687, 302, 29132, 81, 9457, 14, 773, 78, 29132, 81, 9457, 492, 1852, 63, 3401, 272, 1798, 14, 409, 63, 3807, 661, 891, 60, 199, 5, 6595, 359, 1419, 61, 199, 199, 5831, 26, 523, 450, 6595, 6571, 3343, 2652, 3217, 370, 653, 998, 20152, 9457, 20545, 1072, 2120, 14, 199, 12310, 272, 3945, 588, 63, 2775, 63, 4577, 275, 942, 272, 367, 4866, 315, 302, 29132, 81, 9457, 14, 32660, 2959, 4476, 14, 362, 63, 2253, 63, 6410, 837, 267, 3945, 588, 63, 2775, 63, 4577, 14, 2880, 8, 2374, 14, 362, 63, 25888, 63, 1199, 63, 1278, 1012, 272, 3851, 275, 1852, 63, 3401, 8, 26827, 63, 2775, 63, 4577, 9, 272, 1798, 14, 525, 63, 1422, 26362, 981, 13, 2775, 13, 1278, 297, 2432, 730, 275, 283, 875, 297, 2432, 1720, 275, 283, 17768, 20545, 2385, 465, 282, 3851, 788, 11, 3401, 11, 2278, 3758, 26, 450, 885, 2659, 272, 664, 63, 25888, 63, 2308, 63, 1419, 63, 923, 334, 2087, 12, 1798, 9, 272, 664, 63, 1117, 63, 952, 63, 1419, 63, 923, 334, 2087, 12, 1798, 9, 272, 1798, 14, 525, 63, 1422, 4517, 1117, 13, 1765, 297, 849, 275, 283, 7033, 17, 297, 3415, 275, 788, 7033, 17, 297, 283, 7033, 16, 297, 283, 724, 297, 283, 724, 23702, 1105, 272, 1798, 14, 525, 63, 1422, 26362, 1117, 13, 1765, 13, 5553, 297, 2432, 730, 275, 283, 1609, 297, 2432, 849, 275, 5212, 14, 16, 9, 199, 199, 318, 663, 63, 5789, 63, 1419, 334, 2087, 304, 272, 340, 747, 14, 354, 508, 283, 9228, 356, 267, 1798, 14, 1065, 63, 2474, 275, 788, 954, 1531, 418, 339, 492, 302, 29132, 81, 9457, 272, 687, 302, 29132, 81, 9457, 14, 773, 78, 29132, 81, 9457, 492, 1852, 63, 3401, 272, 1798, 14, 409, 63, 3807, 661, 891, 60, 199, 5, 6595, 359, 1419, 61, 199, 199, 5831, 26, 523, 450, 6595, 6571, 3343, 2652, 3217, 370, 653, 998, 20152, 9457, 20439, 1324, 2120, 14, 199, 12310, 272, 15933, 63, 26827, 63, 2775, 63, 4577, 275, 942, 272, 367, 4866, 315, 302, 29132, 81, 9457, 14, 2493, 2548, 3205, 4476, 14, 362, 63, 2253, 63, 6410, 837, 267, 15933, 63, 26827, 63, 2775, 63, 4577, 14, 2880, 8, 2374, 14, 362, 63, 290, 2548, 63, 1210, 63, 6324, 1012, 272, 3851, 275, 1852, 63, 3401, 8, 5789, 63, 26827, 63, 2775, 63, 4577, 9, 272, 1798, 14, 525, 63, 1422, 26362, 981, 13, 27543, 13, 2775, 13, 26827, 13, 2775, 297, 2432, 730, 275, 283, 875, 297, 2432, 1720, 275, 283, 17768, 14095, 3623, 465, 282, 3851, 788, 11, 3401, 11, 2278, 3758, 26, 450, 885, 2659, 272, 664, 63, 290, 2548, 63, 2308, 63, 1419, 63, 923, 334, 2087, 12, 1798, 9, 272, 664, 63, 5789, 63, 739, 63, 1419, 63, 923, 334, 2087, 12, 1798, 9, 272, 1798, 14, 525, 63, 1422, 4517, 5789, 13, 1765, 297, 1993, 849, 275, 283, 1361, 297, 1993, 3415, 275, 788, 1361, 297, 283, 2798, 297, 283, 2384, 1105, 272, 1798, 14, 525, 63, 1422, 63, 923, 334, 362, 63, 6472, 63, 14639, 63, 1419, 63, 923, 334, 2087, 430, 199, 199, 318, 663, 63, 8035, 63, 1419, 334, 2087, 304, 272, 340, 747, 14, 354, 508, 283, 9228, 356, 267, 1798, 14, 1065, 63, 2474, 275, 788, 954, 1531, 418, 339, 492, 302, 29132, 81, 9457, 272, 687, 302, 29132, 81, 9457, 14, 773, 78, 29132, 81, 9457, 492, 1852, 63, 3401, 339, 1798, 14, 409, 63, 3807, 661, 891, 60, 199, 5, 6595, 359, 1419, 61, 199, 199, 5831, 26, 523, 450, 6595, 6571, 3343, 2652, 3217, 370, 653, 998, 20152, 9457, 20439, 1072, 2120, 14, 199, 12310, 272, 282, 79, 63, 26827, 63, 2775, 63, 4577, 275, 942, 272, 367, 4866, 315, 302, 29132, 81, 9457, 14, 2493, 2548, 2959, 4476, 14, 362, 63, 2253, 63, 6410, 837 ]
[ 646, 747, 199, 504, 8691, 492, 3207, 2448, 199, 199, 318, 664, 63, 765, 63, 4958, 8, 765, 354, 12, 1511, 12, 4775, 83, 29, 403, 304, 272, 1249, 275, 942, 272, 340, 4775, 83, 365, 488, 26, 267, 4775, 83, 275, 1052, 272, 367, 536, 315, 2935, 334, 1419, 304, 267, 574, 275, 2519, 334, 1419, 12, 536, 9, 267, 340, 536, 14, 2460, 8, 765, 354, 9, 436, 574, 365, 440, 488, 26, 288, 4775, 83, 59, 354, 59, 552, 8, 765, 354, 6393, 17, 21316, 275, 574, 272, 372, 2008, 8, 589, 395, 4775, 83, 199, 199, 318, 663, 63, 328, 63, 1419, 334, 2087, 304, 272, 340, 747, 14, 354, 508, 283, 9228, 356, 267, 1798, 14, 1065, 63, 2474, 275, 788, 954, 1531, 418, 339, 492, 302, 29132, 81, 9457, 272, 687, 302, 29132, 81, 9457, 14, 773, 78, 29132, 81, 9457, 492, 1852, 63, 3401, 272, 1798, 14, 409, 63, 3807, 661, 891, 60, 199, 5, 6595, 359, 1419, 61, 199, 199, 5831, 26, 523, 450, 6595, 6571, 3343, 2652, 3217, 370, 653, 998, 20152, 9457, 20545, 1324, 2120, 14, 199, 12310, 272, 3945, 588, 63, 2775, 63, 4577, 275, 942, 272, 367, 4866, 315, 302, 29132, 81, 9457, 14, 32660, 3205, 4476, 14, 362, 63, 2253, 63, 6410, 837, 267, 3945, 588, 63, 2775, 63, 4577, 14, 2880, 8, 2374, 14, 362, 63, 25888, 63, 1210, 63, 1278, 1012, 272, 3851, 275, 1852, 63, 3401, 8, 26827, 63, 2775, 63, 4577, 9, 272, 1798, 14, 525, 63, 1422, 26362, 981, 13, 2775, 13, 1278, 297, 2432, 730, 275, 283, 875, 297, 2432, 1720, 275, 283, 17768, 20545, 2385, 465, 282, 3851, 788, 11, 3401, 11, 2278, 3758, 26, 450, 885, 2659, 272, 664, 63, 25888, 63, 2308, 63, 1419, 63, 923, 334, 2087, 12, 1798, 9, 272, 664, 63, 328, 63, 739, 63, 1419, 63, 923, 334, 2087, 12, 1798, 9, 272, 1798, 14, 525, 63, 1422, 4517, 328, 13, 1765, 297, 1993, 849, 275, 283, 1361, 297, 1993, 3415, 275, 788, 1361, 1105, 199, 199, 318, 663, 63, 1117, 63, 1419, 334, 2087, 304, 272, 340, 747, 14, 354, 508, 283, 9228, 356, 267, 1798, 14, 1065, 63, 2474, 275, 788, 954, 1531, 418, 339, 492, 302, 29132, 81, 9457, 272, 687, 302, 29132, 81, 9457, 14, 773, 78, 29132, 81, 9457, 492, 1852, 63, 3401, 272, 1798, 14, 409, 63, 3807, 661, 891, 60, 199, 5, 6595, 359, 1419, 61, 199, 199, 5831, 26, 523, 450, 6595, 6571, 3343, 2652, 3217, 370, 653, 998, 20152, 9457, 20545, 1072, 2120, 14, 199, 12310, 272, 3945, 588, 63, 2775, 63, 4577, 275, 942, 272, 367, 4866, 315, 302, 29132, 81, 9457, 14, 32660, 2959, 4476, 14, 362, 63, 2253, 63, 6410, 837, 267, 3945, 588, 63, 2775, 63, 4577, 14, 2880, 8, 2374, 14, 362, 63, 25888, 63, 1199, 63, 1278, 1012, 272, 3851, 275, 1852, 63, 3401, 8, 26827, 63, 2775, 63, 4577, 9, 272, 1798, 14, 525, 63, 1422, 26362, 981, 13, 2775, 13, 1278, 297, 2432, 730, 275, 283, 875, 297, 2432, 1720, 275, 283, 17768, 20545, 2385, 465, 282, 3851, 788, 11, 3401, 11, 2278, 3758, 26, 450, 885, 2659, 272, 664, 63, 25888, 63, 2308, 63, 1419, 63, 923, 334, 2087, 12, 1798, 9, 272, 664, 63, 1117, 63, 952, 63, 1419, 63, 923, 334, 2087, 12, 1798, 9, 272, 1798, 14, 525, 63, 1422, 4517, 1117, 13, 1765, 297, 849, 275, 283, 7033, 17, 297, 3415, 275, 788, 7033, 17, 297, 283, 7033, 16, 297, 283, 724, 297, 283, 724, 23702, 1105, 272, 1798, 14, 525, 63, 1422, 26362, 1117, 13, 1765, 13, 5553, 297, 2432, 730, 275, 283, 1609, 297, 2432, 849, 275, 5212, 14, 16, 9, 199, 199, 318, 663, 63, 5789, 63, 1419, 334, 2087, 304, 272, 340, 747, 14, 354, 508, 283, 9228, 356, 267, 1798, 14, 1065, 63, 2474, 275, 788, 954, 1531, 418, 339, 492, 302, 29132, 81, 9457, 272, 687, 302, 29132, 81, 9457, 14, 773, 78, 29132, 81, 9457, 492, 1852, 63, 3401, 272, 1798, 14, 409, 63, 3807, 661, 891, 60, 199, 5, 6595, 359, 1419, 61, 199, 199, 5831, 26, 523, 450, 6595, 6571, 3343, 2652, 3217, 370, 653, 998, 20152, 9457, 20439, 1324, 2120, 14, 199, 12310, 272, 15933, 63, 26827, 63, 2775, 63, 4577, 275, 942, 272, 367, 4866, 315, 302, 29132, 81, 9457, 14, 2493, 2548, 3205, 4476, 14, 362, 63, 2253, 63, 6410, 837, 267, 15933, 63, 26827, 63, 2775, 63, 4577, 14, 2880, 8, 2374, 14, 362, 63, 290, 2548, 63, 1210, 63, 6324, 1012, 272, 3851, 275, 1852, 63, 3401, 8, 5789, 63, 26827, 63, 2775, 63, 4577, 9, 272, 1798, 14, 525, 63, 1422, 26362, 981, 13, 27543, 13, 2775, 13, 26827, 13, 2775, 297, 2432, 730, 275, 283, 875, 297, 2432, 1720, 275, 283, 17768, 14095, 3623, 465, 282, 3851, 788, 11, 3401, 11, 2278, 3758, 26, 450, 885, 2659, 272, 664, 63, 290, 2548, 63, 2308, 63, 1419, 63, 923, 334, 2087, 12, 1798, 9, 272, 664, 63, 5789, 63, 739, 63, 1419, 63, 923, 334, 2087, 12, 1798, 9, 272, 1798, 14, 525, 63, 1422, 4517, 5789, 13, 1765, 297, 1993, 849, 275, 283, 1361, 297, 1993, 3415, 275, 788, 1361, 297, 283, 2798, 297, 283, 2384, 1105, 272, 1798, 14, 525, 63, 1422, 63, 923, 334, 362, 63, 6472, 63, 14639, 63, 1419, 63, 923, 334, 2087, 430, 199, 199, 318, 663, 63, 8035, 63, 1419, 334, 2087, 304, 272, 340, 747, 14, 354, 508, 283, 9228, 356, 267, 1798, 14, 1065, 63, 2474, 275, 788, 954, 1531, 418, 339, 492, 302, 29132, 81, 9457, 272, 687, 302, 29132, 81, 9457, 14, 773, 78, 29132, 81, 9457, 492, 1852, 63, 3401, 339, 1798, 14, 409, 63, 3807, 661, 891, 60, 199, 5, 6595, 359, 1419, 61, 199, 199, 5831, 26, 523, 450, 6595, 6571, 3343, 2652, 3217, 370, 653, 998, 20152, 9457, 20439, 1072, 2120, 14, 199, 12310, 272, 282, 79, 63, 26827, 63, 2775, 63, 4577, 275, 942, 272, 367, 4866, 315, 302, 29132, 81, 9457, 14, 2493, 2548, 2959, 4476, 14, 362, 63, 2253, 63, 6410, 837, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
compbrain/dexcom_reader
dexcom_reader/database_records.py
2
6109
import crc16 import constants import struct import util import binascii class BaseDatabaseRecord(object): FORMAT = None @classmethod def _CheckFormat(cls): if cls.FORMAT is None or not cls.FORMAT: raise NotImplementedError("Subclasses of %s need to define FORMAT" % cls.__name__) @classmethod def _ClassFormat(cls): cls._CheckFormat() return struct.Struct(cls.FORMAT) @classmethod def _ClassSize(cls): return cls._ClassFormat().size @property def FMT(self): self._CheckFormat() return _ClassFormat() @property def SIZE(self): return self._ClassSize() @property def crc(self): return self.data[-1] def __init__(self, data, raw_data): self.raw_data = raw_data self.data = data self.check_crc() def check_crc(self): local_crc = self.calculate_crc() if local_crc != self.crc: raise constants.CrcError('Could not parse %s' % self.__class__.__name__) def dump(self): return ''.join('\\x%02x' % ord(c) for c in self.raw_data) def calculate_crc(self): return crc16.crc16(self.raw_data[:-2]) @classmethod def Create(cls, data, record_counter): offset = record_counter * cls._ClassSize() raw_data = data[offset:offset + cls._ClassSize()] unpacked_data = cls._ClassFormat().unpack(raw_data) return cls(unpacked_data, raw_data) class GenericTimestampedRecord(BaseDatabaseRecord): FIELDS = [ ] BASE_FIELDS = [ 'system_time', 'display_time' ] @property def system_time(self): return util.ReceiverTimeToTime(self.data[0]) @property def display_time(self): return util.ReceiverTimeToTime(self.data[1]) def to_dict (self): d = dict( ) for k in self.BASE_FIELDS + self.FIELDS: d[k] = getattr(self, k) if callable(getattr(d[k], 'isoformat', None)): d[k] = d[k].isoformat( ) return d class GenericXMLRecord(GenericTimestampedRecord): FORMAT = '<II490sH' @property def xmldata(self): data = self.data[2].replace("\x00", "") return data class InsertionRecord(GenericTimestampedRecord): FORMAT = '<3IcH' @property def insertion_time(self): return util.ReceiverTimeToTime(self.data[2]) @property def session_state(self): states = [None, 'REMOVED', 'EXPIRED', 'RESIDUAL_DEVIATION', 'COUNTS_DEVIATION', 'SECOND_SESSION', 'OFF_TIME_LOSS', 'STARTED', 'BAD_TRANSMITTER', 'MANUFACTURING_MODE'] return states[ord(self.data[3])] def __repr__(self): return '%s: state=%s' % (self.display_time, self.session_state) class Calibration(GenericTimestampedRecord): @property def raw(self): return binascii.hexlify(bytearray(self.data)) def __repr__(self): return '%s: CAL SET:%s' % (self.display_time, self.raw) class MeterRecord(GenericTimestampedRecord): FORMAT = '<2IHIH' @property def meter_glucose(self): return self.data[2] @property def meter_time(self): return util.ReceiverTimeToTime(self.data[3]) def __repr__(self): return '%s: Meter BG:%s' % (self.display_time, self.meter_glucose) class EventRecord(GenericTimestampedRecord): # sys_time,display_time,glucose,meter_time,crc FORMAT = '<2I2c2IH' @property def event_type(self): event_types = [None, 'CARBS', 'INSULIN', 'HEALTH', 'EXCERCISE', 'MAX_VALUE'] return event_types[ord(self.data[2])] @property def event_sub_type(self): subtypes = {'HEALTH': [None, 'ILLNESS', 'STRESS', 'HIGH_SYMPTOMS', 'LOW_SYMTOMS', 'CYCLE', 'ALCOHOL'], 'EXCERCISE': [None, 'LIGHT', 'MEDIUM', 'HEAVY', 'MAX_VALUE']} if self.event_type in subtypes: return subtypes[self.event_type][ord(self.data[3])] @property def display_time(self): return util.ReceiverTimeToTime(self.data[4]) @property def event_value(self): value = self.data[5] if self.event_type == 'INSULIN': value = value / 100.0 return value def __repr__(self): return '%s: event_type=%s sub_type=%s value=%s' % (self.display_time, self.event_type, self.event_sub_type, self.event_value) class SensorRecord(GenericTimestampedRecord): # uint, uint, uint, uint, ushort # (system_seconds, display_seconds, unfiltered, filtered, rssi, crc) FORMAT = '<2IIIHH' # (unfiltered, filtered, rssi) FIELDS = ['unfiltered', 'filtered', 'rssi'] @property def unfiltered(self): return self.data[2] @property def filtered(self): return self.data[3] @property def rssi(self): return self.data[3] """ def to_dict (self): return dict(display_time=self.display_time.isoformat( ) , system_time=self.system_time.isoformat( ) , unfiltered=self.unfiltered , filtered=self.filtered , rssi=self.rssi ) """ class EGVRecord(GenericTimestampedRecord): # uint, uint, ushort, byte, ushort # (system_seconds, display_seconds, glucose, trend_arrow, crc) FIELDS = ['glucose', 'trend_arrow'] FORMAT = '<2IHcH' @property def full_glucose(self): return self.data[2] @property def full_trend(self): return self.data[3] @property def display_only(self): return bool(self.full_glucose & constants.EGV_DISPLAY_ONLY_MASK) @property def glucose(self): return self.full_glucose & constants.EGV_VALUE_MASK @property def glucose_special_meaning(self): if self.glucose in constants.SPECIAL_GLUCOSE_VALUES: return constants.SPECIAL_GLUCOSE_VALUES[self.glucose] @property def is_special(self): return self.glucose_special_meaning is not None @property def trend_arrow(self): arrow_value = ord(self.full_trend) & constants.EGV_TREND_ARROW_MASK return constants.TREND_ARROW_VALUES[arrow_value] def __repr__(self): if self.is_special: return '%s: %s' % (self.display_time, self.glucose_special_meaning) else: return '%s: CGM BG:%s (%s) DO:%s' % (self.display_time, self.glucose, self.trend_arrow, self.display_only)
mit
[ 646, 18080, 975, 199, 646, 5262, 199, 646, 2702, 199, 646, 4884, 199, 646, 14755, 421, 199, 533, 29103, 5433, 8, 785, 304, 523, 11295, 619, 275, 488, 819, 768, 3744, 523, 347, 485, 1799, 3484, 8, 1886, 304, 272, 340, 843, 14, 4807, 365, 488, 503, 440, 843, 14, 4807, 26, 489, 746, 4279, 480, 2610, 2888, 402, 450, 83, 1929, 370, 5627, 11295, 619, 2, 1816, 450, 843, 855, 354, 3368, 819, 768, 3744, 523, 347, 485, 2543, 3484, 8, 1886, 304, 272, 843, 423, 1799, 3484, 342, 272, 372, 2702, 14, 4836, 8, 1886, 14, 4807, 9, 819, 768, 3744, 523, 347, 485, 2543, 2320, 8, 1886, 304, 272, 372, 843, 423, 2543, 3484, 1252, 890, 819, 768, 1829, 523, 347, 481, 5747, 8, 277, 304, 272, 291, 423, 1799, 3484, 342, 272, 372, 485, 2543, 3484, 342, 819, 768, 1829, 523, 347, 32289, 8, 277, 304, 272, 372, 291, 423, 2543, 2320, 342, 819, 768, 1829, 523, 347, 18080, 8, 277, 304, 272, 372, 291, 14, 576, 1988, 17, 61, 819, 347, 636, 826, 721, 277, 12, 666, 12, 3066, 63, 576, 304, 272, 291, 14, 1773, 63, 576, 275, 3066, 63, 576, 272, 291, 14, 576, 275, 666, 272, 291, 14, 1074, 63, 13258, 342, 819, 347, 1104, 63, 13258, 8, 277, 304, 272, 2257, 63, 13258, 275, 291, 14, 12063, 63, 13258, 342, 272, 340, 2257, 63, 13258, 1137, 291, 14, 13258, 26, 489, 746, 5262, 14, 35, 1195, 547, 360, 6531, 440, 2198, 450, 83, 7, 450, 291, 855, 533, 4914, 354, 3368, 819, 347, 5461, 8, 277, 304, 272, 372, 6522, 904, 11671, 88, 5, 996, 88, 7, 450, 6206, 8, 67, 9, 367, 286, 315, 291, 14, 1773, 63, 576, 9, 819, 347, 8671, 63, 13258, 8, 277, 304, 272, 372, 18080, 975, 14, 13258, 975, 8, 277, 14, 1773, 63, 576, 4439, 18, 566, 819, 768, 3744, 523, 347, 2790, 8, 1886, 12, 666, 12, 2777, 63, 5337, 304, 272, 3268, 275, 2777, 63, 5337, 627, 843, 423, 2543, 2320, 342, 272, 3066, 63, 576, 275, 666, 59, 2743, 26, 2743, 435, 843, 423, 2543, 2320, 5106, 272, 23389, 63, 576, 275, 843, 423, 2543, 3484, 1252, 5301, 8, 1773, 63, 576, 9, 272, 372, 843, 8, 24497, 63, 576, 12, 3066, 63, 576, 9, 421, 199, 533, 8307, 10239, 379, 5433, 8, 1563, 7243, 5433, 304, 523, 15435, 2901, 3177, 275, 359, 1622, 523, 19721, 63, 12767, 275, 359, 283, 2253, 63, 521, 297, 283, 2918, 63, 521, 7, 1622, 523, 768, 1829, 523, 347, 2656, 63, 521, 8, 277, 304, 272, 372, 4884, 14, 21800, 1366, 1378, 1366, 8, 277, 14, 576, 59, 16, 566, 819, 768, 1829, 523, 347, 2929, 63, 521, 8, 277, 304, 272, 372, 4884, 14, 21800, 1366, 1378, 1366, 8, 277, 14, 576, 59, 17, 566, 8330, 347, 370, 63, 807, 334, 277, 304, 272, 366, 275, 1211, 8, 776, 272, 367, 1022, 315, 291, 14, 5825, 63, 12767, 435, 291, 14, 12767, 26, 489, 366, 59, 75, 61, 275, 2519, 8, 277, 12, 1022, 9, 489, 340, 4550, 8, 5675, 8, 68, 59, 75, 467, 283, 17070, 297, 488, 2298, 267, 366, 59, 75, 61, 275, 366, 59, 75, 1055, 17070, 8, 776, 272, 372, 366, 199, 199, 533, 8307, 4317, 5433, 8, 9417, 10239, 379, 5433, 304, 523, 11295, 619, 275, 2650, 8921, 26410, 83, 40, 7, 819, 768, 1829, 523, 347, 2748, 576, 8, 277, 304, 272, 666, 275, 291, 14, 576, 59, 18, 1055, 1814, 4582, 88, 383, 401, 6899, 272, 372, 666, 421, 199, 533, 1010, 4535, 5433, 8, 9417, 10239, 379, 5433, 304, 523, 11295, 619, 275, 2650, 19, 41, 67, 40, 7, 819, 768, 1829, 523, 347, 22470, 63, 521, 8, 277, 304, 272, 372, 4884, 14, 21800, 1366, 1378, 1366, 8, 277, 14, 576, 59, 18, 566, 819, 768, 1829, 523, 347, 2351, 63, 929, 8, 277, 304, 272, 6363, 275, 359, 403, 12, 283, 907, 2679, 14112, 297, 283, 25632, 7387, 297, 283, 3830, 998, 13841, 63, 13260, 41, 2594, 297, 1598, 283, 8760, 51, 63, 13260, 41, 2594, 297, 283, 24236, 63, 12763, 297, 283, 7517, 63, 4961, 63, 28010, 297, 1598, 283, 32385, 297, 283, 9439, 63, 17433, 4029, 649, 1157, 297, 283, 6588, 53, 18164, 1230, 1206, 63, 6963, 418, 272, 372, 6363, 59, 2181, 8, 277, 14, 576, 59, 19, 12457, 819, 347, 636, 2722, 721, 277, 304, 272, 372, 1543, 83, 26, 221, 1174, 2458, 83, 7, 450, 334, 277, 14, 2918, 63, 521, 12, 291, 14, 1730, 63, 929, 9, 421, 199, 533, 8256, 1892, 1754, 8, 9417, 10239, 379, 5433, 304, 523, 768, 1829, 523, 347, 3066, 8, 277, 304, 272, 372, 14755, 14, 20677, 8, 20108, 8, 277, 14, 576, 430, 819, 347, 636, 2722, 721, 277, 304, 272, 372, 1543, 83, 26, 445, 748, 11543, 2689, 83, 7, 450, 334, 277, 14, 2918, 63, 521, 12, 291, 14, 1773, 9, 199, 199, 533, 3194, 351, 5433, 8, 9417, 10239, 379, 5433, 304, 523, 11295, 619, 275, 2650, 18, 41, 11183, 40, 7, 819, 768, 1829, 523, 347, 21247, 63, 27191, 331, 261, 8, 277, 304, 272, 372, 291, 14, 576, 59, 18, 61, 819, 768, 1829, 523, 347, 21247, 63, 521, 8, 277, 304, 272, 372, 4884, 14, 21800, 1366, 1378, 1366, 8, 277, 14, 576, 59, 19, 566, 819, 347, 636, 2722, 721, 277, 304, 272, 372, 1543, 83, 26, 3194, 351, 699, 39, 2689, 83, 7, 450, 334, 277, 14, 2918, 63, 521, 12, 291, 14, 10011, 63, 27191, 331, 261, 9, 421, 199, 533, 6763, 5433, 8, 9417, 10239, 379, 5433, 304, 523, 327, 984, 63, 521, 12, 2918, 63, 521, 12, 27191, 331, 261, 12, 10011, 63, 521, 12, 13258, 523, 11295, 619, 275, 2650, 18, 41, 18, 67, 18, 19824, 7, 819, 768, 1829, 523, 347, 1566, 63, 466, 8, 277, 304, 272, 1566, 63, 1313, 275, 359, 403, 12, 283, 35, 8611, 51, 297, 283, 10789, 1293, 568, 297, 283, 1645, 748, 2080, 297, 283, 1438, 35, 540, 3553, 899, 297, 490, 283, 4283, 63, 7041, 418, 272, 372, 1566, 63, 1313, 59 ]
[ 18080, 975, 199, 646, 5262, 199, 646, 2702, 199, 646, 4884, 199, 646, 14755, 421, 199, 533, 29103, 5433, 8, 785, 304, 523, 11295, 619, 275, 488, 819, 768, 3744, 523, 347, 485, 1799, 3484, 8, 1886, 304, 272, 340, 843, 14, 4807, 365, 488, 503, 440, 843, 14, 4807, 26, 489, 746, 4279, 480, 2610, 2888, 402, 450, 83, 1929, 370, 5627, 11295, 619, 2, 1816, 450, 843, 855, 354, 3368, 819, 768, 3744, 523, 347, 485, 2543, 3484, 8, 1886, 304, 272, 843, 423, 1799, 3484, 342, 272, 372, 2702, 14, 4836, 8, 1886, 14, 4807, 9, 819, 768, 3744, 523, 347, 485, 2543, 2320, 8, 1886, 304, 272, 372, 843, 423, 2543, 3484, 1252, 890, 819, 768, 1829, 523, 347, 481, 5747, 8, 277, 304, 272, 291, 423, 1799, 3484, 342, 272, 372, 485, 2543, 3484, 342, 819, 768, 1829, 523, 347, 32289, 8, 277, 304, 272, 372, 291, 423, 2543, 2320, 342, 819, 768, 1829, 523, 347, 18080, 8, 277, 304, 272, 372, 291, 14, 576, 1988, 17, 61, 819, 347, 636, 826, 721, 277, 12, 666, 12, 3066, 63, 576, 304, 272, 291, 14, 1773, 63, 576, 275, 3066, 63, 576, 272, 291, 14, 576, 275, 666, 272, 291, 14, 1074, 63, 13258, 342, 819, 347, 1104, 63, 13258, 8, 277, 304, 272, 2257, 63, 13258, 275, 291, 14, 12063, 63, 13258, 342, 272, 340, 2257, 63, 13258, 1137, 291, 14, 13258, 26, 489, 746, 5262, 14, 35, 1195, 547, 360, 6531, 440, 2198, 450, 83, 7, 450, 291, 855, 533, 4914, 354, 3368, 819, 347, 5461, 8, 277, 304, 272, 372, 6522, 904, 11671, 88, 5, 996, 88, 7, 450, 6206, 8, 67, 9, 367, 286, 315, 291, 14, 1773, 63, 576, 9, 819, 347, 8671, 63, 13258, 8, 277, 304, 272, 372, 18080, 975, 14, 13258, 975, 8, 277, 14, 1773, 63, 576, 4439, 18, 566, 819, 768, 3744, 523, 347, 2790, 8, 1886, 12, 666, 12, 2777, 63, 5337, 304, 272, 3268, 275, 2777, 63, 5337, 627, 843, 423, 2543, 2320, 342, 272, 3066, 63, 576, 275, 666, 59, 2743, 26, 2743, 435, 843, 423, 2543, 2320, 5106, 272, 23389, 63, 576, 275, 843, 423, 2543, 3484, 1252, 5301, 8, 1773, 63, 576, 9, 272, 372, 843, 8, 24497, 63, 576, 12, 3066, 63, 576, 9, 421, 199, 533, 8307, 10239, 379, 5433, 8, 1563, 7243, 5433, 304, 523, 15435, 2901, 3177, 275, 359, 1622, 523, 19721, 63, 12767, 275, 359, 283, 2253, 63, 521, 297, 283, 2918, 63, 521, 7, 1622, 523, 768, 1829, 523, 347, 2656, 63, 521, 8, 277, 304, 272, 372, 4884, 14, 21800, 1366, 1378, 1366, 8, 277, 14, 576, 59, 16, 566, 819, 768, 1829, 523, 347, 2929, 63, 521, 8, 277, 304, 272, 372, 4884, 14, 21800, 1366, 1378, 1366, 8, 277, 14, 576, 59, 17, 566, 8330, 347, 370, 63, 807, 334, 277, 304, 272, 366, 275, 1211, 8, 776, 272, 367, 1022, 315, 291, 14, 5825, 63, 12767, 435, 291, 14, 12767, 26, 489, 366, 59, 75, 61, 275, 2519, 8, 277, 12, 1022, 9, 489, 340, 4550, 8, 5675, 8, 68, 59, 75, 467, 283, 17070, 297, 488, 2298, 267, 366, 59, 75, 61, 275, 366, 59, 75, 1055, 17070, 8, 776, 272, 372, 366, 199, 199, 533, 8307, 4317, 5433, 8, 9417, 10239, 379, 5433, 304, 523, 11295, 619, 275, 2650, 8921, 26410, 83, 40, 7, 819, 768, 1829, 523, 347, 2748, 576, 8, 277, 304, 272, 666, 275, 291, 14, 576, 59, 18, 1055, 1814, 4582, 88, 383, 401, 6899, 272, 372, 666, 421, 199, 533, 1010, 4535, 5433, 8, 9417, 10239, 379, 5433, 304, 523, 11295, 619, 275, 2650, 19, 41, 67, 40, 7, 819, 768, 1829, 523, 347, 22470, 63, 521, 8, 277, 304, 272, 372, 4884, 14, 21800, 1366, 1378, 1366, 8, 277, 14, 576, 59, 18, 566, 819, 768, 1829, 523, 347, 2351, 63, 929, 8, 277, 304, 272, 6363, 275, 359, 403, 12, 283, 907, 2679, 14112, 297, 283, 25632, 7387, 297, 283, 3830, 998, 13841, 63, 13260, 41, 2594, 297, 1598, 283, 8760, 51, 63, 13260, 41, 2594, 297, 283, 24236, 63, 12763, 297, 283, 7517, 63, 4961, 63, 28010, 297, 1598, 283, 32385, 297, 283, 9439, 63, 17433, 4029, 649, 1157, 297, 283, 6588, 53, 18164, 1230, 1206, 63, 6963, 418, 272, 372, 6363, 59, 2181, 8, 277, 14, 576, 59, 19, 12457, 819, 347, 636, 2722, 721, 277, 304, 272, 372, 1543, 83, 26, 221, 1174, 2458, 83, 7, 450, 334, 277, 14, 2918, 63, 521, 12, 291, 14, 1730, 63, 929, 9, 421, 199, 533, 8256, 1892, 1754, 8, 9417, 10239, 379, 5433, 304, 523, 768, 1829, 523, 347, 3066, 8, 277, 304, 272, 372, 14755, 14, 20677, 8, 20108, 8, 277, 14, 576, 430, 819, 347, 636, 2722, 721, 277, 304, 272, 372, 1543, 83, 26, 445, 748, 11543, 2689, 83, 7, 450, 334, 277, 14, 2918, 63, 521, 12, 291, 14, 1773, 9, 199, 199, 533, 3194, 351, 5433, 8, 9417, 10239, 379, 5433, 304, 523, 11295, 619, 275, 2650, 18, 41, 11183, 40, 7, 819, 768, 1829, 523, 347, 21247, 63, 27191, 331, 261, 8, 277, 304, 272, 372, 291, 14, 576, 59, 18, 61, 819, 768, 1829, 523, 347, 21247, 63, 521, 8, 277, 304, 272, 372, 4884, 14, 21800, 1366, 1378, 1366, 8, 277, 14, 576, 59, 19, 566, 819, 347, 636, 2722, 721, 277, 304, 272, 372, 1543, 83, 26, 3194, 351, 699, 39, 2689, 83, 7, 450, 334, 277, 14, 2918, 63, 521, 12, 291, 14, 10011, 63, 27191, 331, 261, 9, 421, 199, 533, 6763, 5433, 8, 9417, 10239, 379, 5433, 304, 523, 327, 984, 63, 521, 12, 2918, 63, 521, 12, 27191, 331, 261, 12, 10011, 63, 521, 12, 13258, 523, 11295, 619, 275, 2650, 18, 41, 18, 67, 18, 19824, 7, 819, 768, 1829, 523, 347, 1566, 63, 466, 8, 277, 304, 272, 1566, 63, 1313, 275, 359, 403, 12, 283, 35, 8611, 51, 297, 283, 10789, 1293, 568, 297, 283, 1645, 748, 2080, 297, 283, 1438, 35, 540, 3553, 899, 297, 490, 283, 4283, 63, 7041, 418, 272, 372, 1566, 63, 1313, 59, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
nixcloud/linux-odroid
tools/perf/scripts/python/futex-contention.py
1997
1508
# futex contention # (c) 2010, Arnaldo Carvalho de Melo <acme@redhat.com> # Licensed under the terms of the GNU GPL License version 2 # # Translation of: # # http://sourceware.org/systemtap/wiki/WSFutexContention # # to perf python scripting. # # Measures futex contention import os, sys sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from Util import * process_names = {} thread_thislock = {} thread_blocktime = {} lock_waits = {} # long-lived stats on (tid,lock) blockage elapsed time process_names = {} # long-lived pid-to-execname mapping def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, callchain, nr, uaddr, op, val, utime, uaddr2, val3): cmd = op & FUTEX_CMD_MASK if cmd != FUTEX_WAIT: return # we don't care about originators of WAKE events process_names[tid] = comm thread_thislock[tid] = uaddr thread_blocktime[tid] = nsecs(s, ns) def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, callchain, nr, ret): if thread_blocktime.has_key(tid): elapsed = nsecs(s, ns) - thread_blocktime[tid] add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed) del thread_blocktime[tid] del thread_thislock[tid] def trace_begin(): print "Press control+C to stop and show the summary" def trace_end(): for (tid, lock) in lock_waits: min, max, avg, count = lock_waits[tid, lock] print "%s[%d] lock %x contended %d times, %d avg ns" % \ (process_names[tid], tid, lock, count, avg)
gpl-2.0
[ 3, 289, 18173, 406, 9553, 199, 3, 334, 67, 9, 7129, 12, 1952, 78, 279, 1117, 14243, 637, 526, 477, 3194, 320, 665, 18107, 32, 17164, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 25224, 402, 26, 199, 3, 199, 3, 1455, 921, 1365, 1068, 14, 1308, 15, 2253, 16609, 15, 6797, 15, 5035, 38, 18173, 714, 9553, 199, 3, 199, 3, 370, 8582, 2366, 2884, 316, 14, 199, 3, 199, 3, 3194, 305, 1482, 289, 18173, 406, 9553, 199, 199, 646, 747, 12, 984, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 1994, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 504, 21248, 492, 627, 199, 199, 1412, 63, 1247, 275, 1052, 199, 2671, 63, 3749, 831, 275, 1052, 199, 2671, 63, 1457, 521, 275, 1052, 199, 199, 831, 63, 758, 1405, 275, 1052, 327, 1846, 13, 317, 1354, 5020, 641, 334, 5700, 12, 831, 9, 1853, 474, 14439, 900, 199, 1412, 63, 1247, 275, 1052, 327, 1846, 13, 317, 1354, 4422, 13, 475, 13, 1628, 354, 4412, 199, 199, 318, 19473, 363, 1274, 63, 4200, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1240, 4429, 12, 1585, 420, 14762, 12, 399, 2697, 12, 1687, 12, 1139, 12, 399, 521, 12, 399, 2697, 18, 12, 1139, 19, 304, 199, 198, 1760, 275, 1687, 1253, 481, 934, 1438, 63, 9744, 63, 12880, 199, 198, 692, 2088, 1137, 481, 934, 1438, 63, 12458, 26, 507, 198, 1107, 327, 781, 2793, 1133, 10296, 3595, 6330, 2750, 402, 644, 22339, 4474, 421, 198, 1412, 63, 1247, 59, 5700, 61, 275, 1923, 199, 198, 2671, 63, 3749, 831, 59, 5700, 61, 275, 399, 2697, 199, 198, 2671, 63, 1457, 521, 59, 5700, 61, 275, 13781, 8, 83, 12, 700, 9, 199, 199, 318, 19473, 363, 1274, 63, 2224, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1240, 4429, 12, 1585, 258, 14762, 12, 2203, 304, 199, 198, 692, 2462, 63, 1457, 521, 14, 1989, 63, 498, 8, 5700, 304, 507, 198, 16691, 275, 13781, 8, 83, 12, 700, 9, 446, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 525, 63, 3200, 8, 831, 63, 758, 1405, 12, 334, 5700, 12, 2462, 63, 3749, 831, 59, 5700, 2522, 14439, 9, 507, 198, 2264, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 2264, 2462, 63, 3749, 831, 59, 5700, 61, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 509, 334, 5700, 12, 4650, 9, 315, 4650, 63, 758, 1405, 26, 507, 198, 827, 12, 1390, 12, 12402, 12, 2338, 275, 4650, 63, 758, 1405, 59, 5700, 12, 4650, 61, 507, 198, 1361, 2071, 83, 9722, 68, 61, 4650, 450, 88, 406, 6943, 450, 68, 5431, 12, 450, 68, 12402, 700, 2, 450, 971, 686, 420, 334, 1412, 63, 1247, 59, 5700, 467, 11559, 12, 4650, 12, 2338, 12, 12402, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 289, 18173, 406, 9553, 199, 3, 334, 67, 9, 7129, 12, 1952, 78, 279, 1117, 14243, 637, 526, 477, 3194, 320, 665, 18107, 32, 17164, 14, 957, 30, 199, 3, 3909, 1334, 314, 2895, 402, 314, 1664, 14629, 844, 1015, 499, 199, 3, 199, 3, 25224, 402, 26, 199, 3, 199, 3, 1455, 921, 1365, 1068, 14, 1308, 15, 2253, 16609, 15, 6797, 15, 5035, 38, 18173, 714, 9553, 199, 3, 199, 3, 370, 8582, 2366, 2884, 316, 14, 199, 3, 199, 3, 3194, 305, 1482, 289, 18173, 406, 9553, 199, 199, 646, 747, 12, 984, 199, 1274, 14, 515, 14, 740, 8, 736, 14, 2314, 459, 17038, 63, 10276, 63, 3243, 418, 435, 1994, 6429, 15, 1548, 15, 12387, 13, 3921, 13, 9562, 15, 773, 15, 12387, 15, 3921, 358, 199, 504, 21248, 492, 627, 199, 199, 1412, 63, 1247, 275, 1052, 199, 2671, 63, 3749, 831, 275, 1052, 199, 2671, 63, 1457, 521, 275, 1052, 199, 199, 831, 63, 758, 1405, 275, 1052, 327, 1846, 13, 317, 1354, 5020, 641, 334, 5700, 12, 831, 9, 1853, 474, 14439, 900, 199, 1412, 63, 1247, 275, 1052, 327, 1846, 13, 317, 1354, 4422, 13, 475, 13, 1628, 354, 4412, 199, 199, 318, 19473, 363, 1274, 63, 4200, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1240, 4429, 12, 1585, 420, 14762, 12, 399, 2697, 12, 1687, 12, 1139, 12, 399, 521, 12, 399, 2697, 18, 12, 1139, 19, 304, 199, 198, 1760, 275, 1687, 1253, 481, 934, 1438, 63, 9744, 63, 12880, 199, 198, 692, 2088, 1137, 481, 934, 1438, 63, 12458, 26, 507, 198, 1107, 327, 781, 2793, 1133, 10296, 3595, 6330, 2750, 402, 644, 22339, 4474, 421, 198, 1412, 63, 1247, 59, 5700, 61, 275, 1923, 199, 198, 2671, 63, 3749, 831, 59, 5700, 61, 275, 399, 2697, 199, 198, 2671, 63, 1457, 521, 59, 5700, 61, 275, 13781, 8, 83, 12, 700, 9, 199, 199, 318, 19473, 363, 1274, 63, 2224, 63, 70, 18173, 8, 1430, 12, 11216, 12, 5033, 12, 308, 12, 700, 12, 11559, 12, 1923, 12, 1240, 4429, 12, 1585, 258, 14762, 12, 2203, 304, 199, 198, 692, 2462, 63, 1457, 521, 14, 1989, 63, 498, 8, 5700, 304, 507, 198, 16691, 275, 13781, 8, 83, 12, 700, 9, 446, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 525, 63, 3200, 8, 831, 63, 758, 1405, 12, 334, 5700, 12, 2462, 63, 3749, 831, 59, 5700, 2522, 14439, 9, 507, 198, 2264, 2462, 63, 1457, 521, 59, 5700, 61, 507, 198, 2264, 2462, 63, 3749, 831, 59, 5700, 61, 199, 199, 318, 3307, 63, 5037, 837, 199, 198, 1361, 298, 14414, 3304, 11, 35, 370, 3631, 436, 2498, 314, 6212, 2, 199, 199, 318, 3307, 63, 500, 837, 199, 198, 509, 334, 5700, 12, 4650, 9, 315, 4650, 63, 758, 1405, 26, 507, 198, 827, 12, 1390, 12, 12402, 12, 2338, 275, 4650, 63, 758, 1405, 59, 5700, 12, 4650, 61, 507, 198, 1361, 2071, 83, 9722, 68, 61, 4650, 450, 88, 406, 6943, 450, 68, 5431, 12, 450, 68, 12402, 700, 2, 450, 971, 686, 420, 334, 1412, 63, 1247, 59, 5700, 467, 11559, 12, 4650, 12, 2338, 12, 12402, 9, 421, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
MA3STR0/python-instagram
instagram/client.py
33
8778
from . import oauth2 from .bind import bind_method from .models import MediaShortcode, Media, User, Location, Tag, Comment, Relationship MEDIA_ACCEPT_PARAMETERS = ["count", "max_id"] SEARCH_ACCEPT_PARAMETERS = ["q", "count"] SUPPORTED_FORMATS = ['json'] class InstagramAPI(oauth2.OAuth2API): host = "api.instagram.com" base_path = "/v1" access_token_field = "access_token" authorize_url = "https://api.instagram.com/oauth/authorize" access_token_url = "https://api.instagram.com/oauth/access_token" protocol = "https" api_name = "Instagram" x_ratelimit_remaining = None x_ratelimit = None def __init__(self, *args, **kwargs): format = kwargs.get('format', 'json') if format in SUPPORTED_FORMATS: self.format = format else: raise Exception("Unsupported format") super(InstagramAPI, self).__init__(**kwargs) media_popular = bind_method( path="/media/popular", accepts_parameters=MEDIA_ACCEPT_PARAMETERS, root_class=Media) media_search = bind_method( path="/media/search", accepts_parameters=SEARCH_ACCEPT_PARAMETERS + ['lat', 'lng', 'min_timestamp', 'max_timestamp', 'distance'], root_class=Media) media_shortcode = bind_method( path="/media/shortcode/{shortcode}", accepts_parameters=['shortcode'], response_type="entry", root_class=MediaShortcode, exclude_format=True) media_likes = bind_method( path="/media/{media_id}/likes", accepts_parameters=['media_id'], root_class=User) like_media = bind_method( path="/media/{media_id}/likes", method="POST", signature=True, accepts_parameters=['media_id'], response_type="empty") unlike_media = bind_method( path="/media/{media_id}/likes", method="DELETE", signature=True, accepts_parameters=['media_id'], response_type="empty") create_media_comment = bind_method( path="/media/{media_id}/comments", method="POST", signature=True, accepts_parameters=['media_id', 'text'], response_type="empty", root_class=Comment) delete_comment = bind_method( path="/media/{media_id}/comments/{comment_id}", method="DELETE", signature=True, accepts_parameters=['media_id', 'comment_id'], response_type="empty") media_comments = bind_method( path="/media/{media_id}/comments", method="GET", accepts_parameters=['media_id'], response_type="list", root_class=Comment) media = bind_method( path="/media/{media_id}", accepts_parameters=['media_id'], response_type="entry", root_class=Media) user_media_feed = bind_method( path="/users/self/feed", accepts_parameters=MEDIA_ACCEPT_PARAMETERS, root_class=Media, paginates=True) user_liked_media = bind_method( path="/users/self/media/liked", accepts_parameters=MEDIA_ACCEPT_PARAMETERS, root_class=Media, paginates=True) user_recent_media = bind_method( path="/users/{user_id}/media/recent", accepts_parameters=MEDIA_ACCEPT_PARAMETERS + ['user_id', 'min_id', 'max_timestamp', 'min_timestamp'], root_class=Media, paginates=True) user_search = bind_method( path="/users/search", accepts_parameters=SEARCH_ACCEPT_PARAMETERS, root_class=User) user_follows = bind_method( path="/users/{user_id}/follows", accepts_parameters=["user_id"], paginates=True, root_class=User) user_followed_by = bind_method( path="/users/{user_id}/followed-by", accepts_parameters=["user_id"], paginates=True, root_class=User) user = bind_method( path="/users/{user_id}", accepts_parameters=["user_id"], root_class=User, response_type="entry") location_recent_media = bind_method( path="/locations/{location_id}/media/recent", accepts_parameters=MEDIA_ACCEPT_PARAMETERS + ['location_id'], root_class=Media, paginates=True) location_search = bind_method( path="/locations/search", accepts_parameters=SEARCH_ACCEPT_PARAMETERS + ['lat', 'lng', 'foursquare_id', 'foursquare_v2_id'], root_class=Location) location = bind_method( path="/locations/{location_id}", accepts_parameters=["location_id"], root_class=Location, response_type="entry") geography_recent_media = bind_method( path="/geographies/{geography_id}/media/recent", accepts_parameters=MEDIA_ACCEPT_PARAMETERS + ["geography_id"], root_class=Media, paginates=True) tag_recent_media = bind_method( path="/tags/{tag_name}/media/recent", accepts_parameters=['count', 'max_tag_id', 'tag_name'], root_class=Media, paginates=True) tag_search = bind_method( path="/tags/search", accepts_parameters=SEARCH_ACCEPT_PARAMETERS, root_class=Tag, paginates=True) tag = bind_method( path="/tags/{tag_name}", accepts_parameters=["tag_name"], root_class=Tag, response_type="entry") user_incoming_requests = bind_method( path="/users/self/requested-by", root_class=User) change_user_relationship = bind_method( method="POST", path="/users/{user_id}/relationship", signature=True, root_class=Relationship, accepts_parameters=["user_id", "action"], paginates=True, requires_target_user=True, response_type="entry") user_relationship = bind_method( method="GET", path="/users/{user_id}/relationship", root_class=Relationship, accepts_parameters=["user_id"], paginates=False, requires_target_user=True, response_type="entry") def _make_relationship_shortcut(action): def _inner(self, *args, **kwargs): return self.change_user_relationship(user_id=kwargs.get("user_id"), action=action) return _inner follow_user = _make_relationship_shortcut('follow') unfollow_user = _make_relationship_shortcut('unfollow') block_user = _make_relationship_shortcut('block') unblock_user = _make_relationship_shortcut('unblock') approve_user_request = _make_relationship_shortcut('approve') ignore_user_request = _make_relationship_shortcut('ignore') def _make_subscription_action(method, include=None, exclude=None): accepts_parameters = ["object", "aspect", "object_id", # Optional if subscribing to all users "callback_url", "lat", # Geography "lng", # Geography "radius", # Geography "verify_token"] if include: accepts_parameters.extend(include) if exclude: accepts_parameters = [x for x in accepts_parameters if x not in exclude] signature = False if method == 'GET' else True return bind_method( path="/subscriptions", method=method, accepts_parameters=accepts_parameters, include_secret=True, objectify_response=False, signature=signature, ) create_subscription = _make_subscription_action('POST') list_subscriptions = _make_subscription_action('GET') delete_subscriptions = _make_subscription_action('DELETE', exclude=['object_id'], include=['id'])
bsd-3-clause
[ 504, 1275, 492, 9725, 18, 199, 504, 1275, 3409, 492, 5398, 63, 765, 199, 504, 1275, 992, 492, 12300, 10039, 600, 12, 12300, 12, 2876, 12, 12625, 12, 8053, 12, 6819, 12, 23230, 3319, 199, 199, 13669, 63, 13089, 63, 24014, 275, 2097, 835, 401, 298, 988, 63, 344, 937, 199, 15962, 63, 13089, 63, 24014, 275, 2097, 81, 401, 298, 835, 937, 199, 199, 15925, 63, 14019, 275, 788, 1001, 418, 421, 199, 533, 14089, 32208, 3735, 8, 6126, 18, 14, 12906, 18, 3735, 304, 339, 1591, 275, 298, 1246, 14, 3615, 32208, 14, 957, 2, 272, 1300, 63, 515, 275, 3286, 86, 17, 2, 272, 2879, 63, 1418, 63, 698, 275, 298, 2732, 63, 1418, 2, 272, 20210, 63, 633, 275, 298, 2859, 921, 1246, 14, 3615, 32208, 14, 957, 15, 6126, 15, 14204, 2, 272, 2879, 63, 1418, 63, 633, 275, 298, 2859, 921, 1246, 14, 3615, 32208, 14, 957, 15, 6126, 15, 2732, 63, 1418, 2, 272, 4113, 275, 298, 2859, 2, 272, 2986, 63, 354, 275, 298, 10083, 32208, 2, 272, 671, 63, 1866, 3097, 63, 11266, 221, 275, 488, 272, 671, 63, 1866, 3097, 275, 488, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1475, 275, 2074, 14, 362, 360, 908, 297, 283, 1001, 358, 267, 340, 1475, 315, 32501, 63, 14019, 26, 288, 291, 14, 908, 275, 1475, 267, 587, 26, 288, 746, 2186, 480, 12647, 1475, 531, 267, 1613, 8, 10083, 32208, 3735, 12, 291, 2843, 826, 14155, 958, 9, 339, 5898, 63, 1935, 2238, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 15, 1935, 2238, 401, 355, 11479, 63, 3214, 29, 13669, 63, 13089, 63, 24014, 12, 355, 1738, 63, 533, 29, 11398, 9, 339, 5898, 63, 1733, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 15, 1733, 401, 355, 11479, 63, 3214, 29, 15962, 63, 13089, 63, 24014, 435, 788, 4452, 297, 283, 23829, 297, 283, 827, 63, 3954, 297, 283, 988, 63, 3954, 297, 283, 5590, 995, 355, 1738, 63, 533, 29, 11398, 9, 339, 5898, 63, 3612, 600, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 15, 3612, 600, 5321, 3612, 600, 10750, 355, 11479, 63, 3214, 2968, 3612, 600, 995, 355, 1177, 63, 466, 628, 2373, 401, 355, 1738, 63, 533, 29, 11398, 10039, 600, 12, 355, 5760, 63, 908, 29, 549, 9, 2378, 5898, 63, 29572, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 5995, 29572, 401, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 995, 355, 1738, 63, 533, 29, 1899, 9, 339, 2839, 63, 4603, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 5995, 29572, 401, 355, 1083, 628, 4030, 401, 355, 4955, 29, 549, 12, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 995, 355, 1177, 63, 466, 628, 1667, 531, 339, 29750, 63, 4603, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 5995, 29572, 401, 355, 1083, 628, 7014, 401, 355, 4955, 29, 549, 12, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 995, 355, 1177, 63, 466, 628, 1667, 531, 339, 1218, 63, 4603, 63, 3349, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 5995, 6223, 401, 355, 1083, 628, 4030, 401, 355, 4955, 29, 549, 12, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 297, 283, 505, 995, 355, 1177, 63, 466, 628, 1667, 401, 355, 1738, 63, 533, 29, 7488, 9, 339, 3145, 63, 3349, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 5995, 6223, 5321, 3349, 63, 344, 10750, 355, 1083, 628, 7014, 401, 355, 4955, 29, 549, 12, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 297, 283, 3349, 63, 344, 995, 355, 1177, 63, 466, 628, 1667, 531, 339, 5898, 63, 6223, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 5995, 6223, 401, 355, 1083, 628, 2970, 401, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 995, 355, 1177, 63, 466, 628, 513, 401, 355, 1738, 63, 533, 29, 7488, 9, 339, 5898, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 10750, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 995, 355, 1177, 63, 466, 628, 2373, 401, 355, 1738, 63, 533, 29, 11398, 9, 339, 922, 63, 4603, 63, 3871, 275, 5398, 63, 765, 8, 355, 931, 9555, 3707, 15, 277, 15, 3871, 401, 355, 11479, 63, 3214, 29, 13669, 63, 13089, 63, 24014, 12, 355, 1738, 63, 533, 29, 11398, 12, 355, 9881, 262, 2335, 29, 549, 9, 339, 922, 63, 317, 25503, 63, 4603, 275, 5398, 63, 765, 8, 355, 931, 9555, 3707, 15, 277, 15, 4603, 15, 317, 25503, 401, 355, 11479, 63, 3214, 29, 13669, 63, 13089, 63, 24014, 12, 355, 1738, 63, 533, 29, 11398, 12, 355, 9881, 262, 2335, 29, 549, 9, 339, 922, 63, 14951, 63, 4603, 275, 5398, 63, 765, 8, 355, 931, 9555, 3707, 5321, 751, 63, 344, 5995, 4603, 15, 14951, 401, 355, 11479, 63, 3214, 29, 13669, 63, 13089, 63, 24014, 435, 788, 751, 63, 344, 297, 283, 827, 63, 344, 297, 283, 988, 63, 3954, 297, 283, 827, 63, 3954, 995, 355, 1738, 63, 533, 29, 11398, 12, 355, 9881, 262, 2335, 29, 549, 9, 339, 922, 63, 1733, 275, 5398, 63, 765, 8, 355, 931, 9555, 3707, 15, 1733, 401, 355, 11479, 63, 3214, 29, 15962, 63, 13089, 63, 24014, 12, 355, 1738, 63, 533, 29, 1899, 9, 339, 922, 63, 7207, 83, 275, 5398, 63, 765, 8, 355, 931, 9555, 3707, 5321, 751, 63, 344, 5995, 7207, 83, 401, 355, 11479, 63, 3214, 6270, 751, 63, 344, 2255, 355, 9881, 262, 2335, 29, 549, 12, 355, 1738, 63, 533, 29, 1899, 9, 339, 922, 63, 7207, 379, 63, 991, 275, 5398, 63, 765, 8, 355, 931, 9555, 3707, 5321, 751, 63, 344, 5995, 7207, 379, 13, 991, 401, 355, 11479, 63, 3214, 6270, 751, 63, 344, 2255, 355, 9881, 262, 2335, 29, 549, 12, 355, 1738, 63, 533, 29, 1899, 9, 339, 922, 275, 5398, 63, 765, 8, 355, 931, 9555 ]
[ 1275, 492, 9725, 18, 199, 504, 1275, 3409, 492, 5398, 63, 765, 199, 504, 1275, 992, 492, 12300, 10039, 600, 12, 12300, 12, 2876, 12, 12625, 12, 8053, 12, 6819, 12, 23230, 3319, 199, 199, 13669, 63, 13089, 63, 24014, 275, 2097, 835, 401, 298, 988, 63, 344, 937, 199, 15962, 63, 13089, 63, 24014, 275, 2097, 81, 401, 298, 835, 937, 199, 199, 15925, 63, 14019, 275, 788, 1001, 418, 421, 199, 533, 14089, 32208, 3735, 8, 6126, 18, 14, 12906, 18, 3735, 304, 339, 1591, 275, 298, 1246, 14, 3615, 32208, 14, 957, 2, 272, 1300, 63, 515, 275, 3286, 86, 17, 2, 272, 2879, 63, 1418, 63, 698, 275, 298, 2732, 63, 1418, 2, 272, 20210, 63, 633, 275, 298, 2859, 921, 1246, 14, 3615, 32208, 14, 957, 15, 6126, 15, 14204, 2, 272, 2879, 63, 1418, 63, 633, 275, 298, 2859, 921, 1246, 14, 3615, 32208, 14, 957, 15, 6126, 15, 2732, 63, 1418, 2, 272, 4113, 275, 298, 2859, 2, 272, 2986, 63, 354, 275, 298, 10083, 32208, 2, 272, 671, 63, 1866, 3097, 63, 11266, 221, 275, 488, 272, 671, 63, 1866, 3097, 275, 488, 339, 347, 636, 826, 721, 277, 12, 627, 589, 12, 1011, 958, 304, 267, 1475, 275, 2074, 14, 362, 360, 908, 297, 283, 1001, 358, 267, 340, 1475, 315, 32501, 63, 14019, 26, 288, 291, 14, 908, 275, 1475, 267, 587, 26, 288, 746, 2186, 480, 12647, 1475, 531, 267, 1613, 8, 10083, 32208, 3735, 12, 291, 2843, 826, 14155, 958, 9, 339, 5898, 63, 1935, 2238, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 15, 1935, 2238, 401, 355, 11479, 63, 3214, 29, 13669, 63, 13089, 63, 24014, 12, 355, 1738, 63, 533, 29, 11398, 9, 339, 5898, 63, 1733, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 15, 1733, 401, 355, 11479, 63, 3214, 29, 15962, 63, 13089, 63, 24014, 435, 788, 4452, 297, 283, 23829, 297, 283, 827, 63, 3954, 297, 283, 988, 63, 3954, 297, 283, 5590, 995, 355, 1738, 63, 533, 29, 11398, 9, 339, 5898, 63, 3612, 600, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 15, 3612, 600, 5321, 3612, 600, 10750, 355, 11479, 63, 3214, 2968, 3612, 600, 995, 355, 1177, 63, 466, 628, 2373, 401, 355, 1738, 63, 533, 29, 11398, 10039, 600, 12, 355, 5760, 63, 908, 29, 549, 9, 2378, 5898, 63, 29572, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 5995, 29572, 401, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 995, 355, 1738, 63, 533, 29, 1899, 9, 339, 2839, 63, 4603, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 5995, 29572, 401, 355, 1083, 628, 4030, 401, 355, 4955, 29, 549, 12, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 995, 355, 1177, 63, 466, 628, 1667, 531, 339, 29750, 63, 4603, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 5995, 29572, 401, 355, 1083, 628, 7014, 401, 355, 4955, 29, 549, 12, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 995, 355, 1177, 63, 466, 628, 1667, 531, 339, 1218, 63, 4603, 63, 3349, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 5995, 6223, 401, 355, 1083, 628, 4030, 401, 355, 4955, 29, 549, 12, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 297, 283, 505, 995, 355, 1177, 63, 466, 628, 1667, 401, 355, 1738, 63, 533, 29, 7488, 9, 339, 3145, 63, 3349, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 5995, 6223, 5321, 3349, 63, 344, 10750, 355, 1083, 628, 7014, 401, 355, 4955, 29, 549, 12, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 297, 283, 3349, 63, 344, 995, 355, 1177, 63, 466, 628, 1667, 531, 339, 5898, 63, 6223, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 5995, 6223, 401, 355, 1083, 628, 2970, 401, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 995, 355, 1177, 63, 466, 628, 513, 401, 355, 1738, 63, 533, 29, 7488, 9, 339, 5898, 275, 5398, 63, 765, 8, 355, 931, 9555, 4603, 5321, 4603, 63, 344, 10750, 355, 11479, 63, 3214, 2968, 4603, 63, 344, 995, 355, 1177, 63, 466, 628, 2373, 401, 355, 1738, 63, 533, 29, 11398, 9, 339, 922, 63, 4603, 63, 3871, 275, 5398, 63, 765, 8, 355, 931, 9555, 3707, 15, 277, 15, 3871, 401, 355, 11479, 63, 3214, 29, 13669, 63, 13089, 63, 24014, 12, 355, 1738, 63, 533, 29, 11398, 12, 355, 9881, 262, 2335, 29, 549, 9, 339, 922, 63, 317, 25503, 63, 4603, 275, 5398, 63, 765, 8, 355, 931, 9555, 3707, 15, 277, 15, 4603, 15, 317, 25503, 401, 355, 11479, 63, 3214, 29, 13669, 63, 13089, 63, 24014, 12, 355, 1738, 63, 533, 29, 11398, 12, 355, 9881, 262, 2335, 29, 549, 9, 339, 922, 63, 14951, 63, 4603, 275, 5398, 63, 765, 8, 355, 931, 9555, 3707, 5321, 751, 63, 344, 5995, 4603, 15, 14951, 401, 355, 11479, 63, 3214, 29, 13669, 63, 13089, 63, 24014, 435, 788, 751, 63, 344, 297, 283, 827, 63, 344, 297, 283, 988, 63, 3954, 297, 283, 827, 63, 3954, 995, 355, 1738, 63, 533, 29, 11398, 12, 355, 9881, 262, 2335, 29, 549, 9, 339, 922, 63, 1733, 275, 5398, 63, 765, 8, 355, 931, 9555, 3707, 15, 1733, 401, 355, 11479, 63, 3214, 29, 15962, 63, 13089, 63, 24014, 12, 355, 1738, 63, 533, 29, 1899, 9, 339, 922, 63, 7207, 83, 275, 5398, 63, 765, 8, 355, 931, 9555, 3707, 5321, 751, 63, 344, 5995, 7207, 83, 401, 355, 11479, 63, 3214, 6270, 751, 63, 344, 2255, 355, 9881, 262, 2335, 29, 549, 12, 355, 1738, 63, 533, 29, 1899, 9, 339, 922, 63, 7207, 379, 63, 991, 275, 5398, 63, 765, 8, 355, 931, 9555, 3707, 5321, 751, 63, 344, 5995, 7207, 379, 13, 991, 401, 355, 11479, 63, 3214, 6270, 751, 63, 344, 2255, 355, 9881, 262, 2335, 29, 549, 12, 355, 1738, 63, 533, 29, 1899, 9, 339, 922, 275, 5398, 63, 765, 8, 355, 931, 9555, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
mandiant/ioc_writer
ioc_writer/scripts/iocdump.py
1
2104
# iocdump.py # # Copyright 2016 FireEye # Licensed under the Apache 2.0 license. Developed for Mandiant by William # Gibb. # # Mandiant licenses this file to you under the Apache License, Version # 2.0 (the "License"); you may not use this file except in compliance with the # License. You may obtain a copy of the License at: # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. See the License for the specific language governing # permissions and limitations under the License. # # Allows for the upgrade of OpenIOC 1.0 IOCs to OpenIOC 1.1 format # # Stdlib from __future__ import print_function import argparse import logging import os import sys # Third Party code # Custom Code from ..managers import IOCManager log = logging.getLogger(__name__) def main(options): if not options.verbose: logging.disable(logging.DEBUG) iocm = IOCManager() for i in options.input: iocm.insert(i) for ioc_obj in iocm.iocs.values(): if options.hide_params: ioc_obj.display_params = False print(ioc_obj) def makeargpaser(): parser = argparse.ArgumentParser(description="Display a textual representation of an IOC or directory of IOCs") parser.add_argument('input', type=str, nargs='+', help='Input files or folders') parser.add_argument('-n', '--no-params', dest='hide_params', default=False, action='store_true', help='Do not display parameters attached to an IOC.') parser.add_argument('-v', '--verbose', dest='verbose', default=False, action='store_true', help='Enable verbose output') return parser def _main(): logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s [%(filename)s:%(funcName)s]') p = makeargpaser() opts = p.parse_args() main(opts) if __name__ == '__main__': _main()
apache-2.0
[ 3, 284, 679, 2724, 14, 647, 199, 3, 199, 3, 1898, 7800, 15967, 37, 8048, 199, 3, 3909, 1334, 314, 3668, 499, 14, 16, 4190, 14, 221, 1487, 27813, 367, 4688, 328, 867, 701, 644, 8148, 455, 199, 3, 598, 1892, 66, 14, 199, 3, 199, 3, 4688, 328, 867, 12378, 642, 570, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 199, 3, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 199, 3, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 26, 199, 3, 199, 3, 263, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 199, 3, 3443, 436, 4204, 1334, 314, 844, 14, 199, 3, 199, 3, 22819, 367, 314, 10754, 402, 3232, 2090, 35, 413, 14, 16, 5004, 13912, 370, 3232, 2090, 35, 413, 14, 17, 1475, 199, 3, 199, 3, 20992, 773, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 7534, 199, 646, 2050, 199, 646, 747, 199, 646, 984, 199, 3, 31079, 2235, 369, 1233, 199, 3, 8388, 5495, 199, 504, 2508, 16259, 492, 5004, 35, 2988, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 318, 2446, 8, 1419, 304, 272, 340, 440, 1511, 14, 3832, 26, 267, 2050, 14, 5993, 8, 4806, 14, 5287, 9, 272, 284, 679, 77, 275, 5004, 35, 2988, 342, 272, 367, 284, 315, 1511, 14, 1210, 26, 267, 284, 679, 77, 14, 3176, 8, 73, 9, 272, 367, 284, 679, 63, 1113, 315, 284, 679, 77, 14, 73, 14851, 14, 1459, 837, 267, 340, 1511, 14, 8191, 63, 1162, 26, 288, 284, 679, 63, 1113, 14, 2918, 63, 1162, 275, 756, 267, 870, 8, 73, 679, 63, 1113, 9, 199, 199, 318, 1852, 1273, 387, 332, 837, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 628, 7687, 282, 25884, 6025, 402, 376, 5004, 35, 503, 2082, 402, 5004, 13912, 531, 272, 1798, 14, 525, 63, 2094, 360, 1210, 297, 730, 29, 495, 12, 9237, 534, 7386, 717, 1720, 534, 3205, 1584, 503, 16533, 358, 272, 1798, 14, 525, 63, 2094, 3654, 78, 297, 2850, 889, 13, 1162, 297, 2053, 534, 8191, 63, 1162, 297, 849, 29, 797, 12, 1595, 534, 1617, 63, 2052, 297, 717, 1720, 534, 2585, 440, 2929, 2633, 10102, 370, 376, 5004, 35, 2659, 272, 1798, 14, 525, 63, 2094, 3654, 86, 297, 2850, 3832, 297, 2053, 534, 3832, 297, 849, 29, 797, 12, 1595, 534, 1617, 63, 2052, 297, 717, 1720, 534, 6476, 3376, 1072, 358, 272, 372, 1798, 421, 199, 318, 485, 973, 837, 272, 2050, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 12, 1475, 29342, 18331, 9, 83, 2818, 20056, 9, 83, 2818, 1188, 9, 83, 359, 2840, 1501, 9, 83, 19648, 1532, 985, 9, 83, 10374, 272, 299, 275, 1852, 1273, 387, 332, 342, 272, 3999, 275, 299, 14, 1122, 63, 589, 342, 272, 2446, 8, 3291, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 485, 973, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 284, 679, 2724, 14, 647, 199, 3, 199, 3, 1898, 7800, 15967, 37, 8048, 199, 3, 3909, 1334, 314, 3668, 499, 14, 16, 4190, 14, 221, 1487, 27813, 367, 4688, 328, 867, 701, 644, 8148, 455, 199, 3, 598, 1892, 66, 14, 199, 3, 199, 3, 4688, 328, 867, 12378, 642, 570, 370, 1265, 1334, 314, 3668, 844, 12, 3394, 199, 3, 499, 14, 16, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 199, 3, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 26, 199, 3, 199, 3, 263, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 199, 3, 2478, 14, 221, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 199, 3, 3443, 436, 4204, 1334, 314, 844, 14, 199, 3, 199, 3, 22819, 367, 314, 10754, 402, 3232, 2090, 35, 413, 14, 16, 5004, 13912, 370, 3232, 2090, 35, 413, 14, 17, 1475, 199, 3, 199, 3, 20992, 773, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 646, 7534, 199, 646, 2050, 199, 646, 747, 199, 646, 984, 199, 3, 31079, 2235, 369, 1233, 199, 3, 8388, 5495, 199, 504, 2508, 16259, 492, 5004, 35, 2988, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 199, 199, 318, 2446, 8, 1419, 304, 272, 340, 440, 1511, 14, 3832, 26, 267, 2050, 14, 5993, 8, 4806, 14, 5287, 9, 272, 284, 679, 77, 275, 5004, 35, 2988, 342, 272, 367, 284, 315, 1511, 14, 1210, 26, 267, 284, 679, 77, 14, 3176, 8, 73, 9, 272, 367, 284, 679, 63, 1113, 315, 284, 679, 77, 14, 73, 14851, 14, 1459, 837, 267, 340, 1511, 14, 8191, 63, 1162, 26, 288, 284, 679, 63, 1113, 14, 2918, 63, 1162, 275, 756, 267, 870, 8, 73, 679, 63, 1113, 9, 199, 199, 318, 1852, 1273, 387, 332, 837, 272, 1798, 275, 7534, 14, 10730, 8, 1802, 628, 7687, 282, 25884, 6025, 402, 376, 5004, 35, 503, 2082, 402, 5004, 13912, 531, 272, 1798, 14, 525, 63, 2094, 360, 1210, 297, 730, 29, 495, 12, 9237, 534, 7386, 717, 1720, 534, 3205, 1584, 503, 16533, 358, 272, 1798, 14, 525, 63, 2094, 3654, 78, 297, 2850, 889, 13, 1162, 297, 2053, 534, 8191, 63, 1162, 297, 849, 29, 797, 12, 1595, 534, 1617, 63, 2052, 297, 717, 1720, 534, 2585, 440, 2929, 2633, 10102, 370, 376, 5004, 35, 2659, 272, 1798, 14, 525, 63, 2094, 3654, 86, 297, 2850, 3832, 297, 2053, 534, 3832, 297, 849, 29, 797, 12, 1595, 534, 1617, 63, 2052, 297, 717, 1720, 534, 6476, 3376, 1072, 358, 272, 372, 1798, 421, 199, 318, 485, 973, 837, 272, 2050, 14, 19602, 8, 1896, 29, 4806, 14, 5287, 12, 1475, 29342, 18331, 9, 83, 2818, 20056, 9, 83, 2818, 1188, 9, 83, 359, 2840, 1501, 9, 83, 19648, 1532, 985, 9, 83, 10374, 272, 299, 275, 1852, 1273, 387, 332, 342, 272, 3999, 275, 299, 14, 1122, 63, 589, 342, 272, 2446, 8, 3291, 9, 199, 199, 692, 636, 354, 363, 508, 2560, 973, 3706, 272, 485, 973, 342, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
ingenioustechie/zamboni
mkt/zadmin/forms.py
19
4020
from django import forms from django.conf import settings import commonware.log import happyforms LOGGER_NAME = 'z.zadmin' log = commonware.log.getLogger(LOGGER_NAME) class DevMailerForm(happyforms.Form): _choices = [('apps', 'Developers of active apps (not add-ons)'), ('free_apps_region_enabled', 'Developers of free apps and new region enabled'), ('free_apps_region_disabled', 'Developers of free apps with new regions disabled'), ('payments', 'Developers of non-deleted apps (not add-ons) with payments'), ('payments_region_enabled', 'Developers of apps with payments and new regions enabled'), ('payments_region_disabled', 'Developers of apps with payments and new regions disabled'), ('desktop_apps', 'Developers of non-deleted apps supported on desktop')] recipients = forms.ChoiceField(choices=_choices, required=True) subject = forms.CharField(widget=forms.TextInput(attrs=dict(size='100')), required=True) preview_only = forms.BooleanField(initial=True, required=False, label=u'Log emails instead of sending') message = forms.CharField(widget=forms.Textarea, required=True) class YesImSure(happyforms.Form): yes = forms.BooleanField(required=True, label="Yes, I'm sure") class GenerateErrorForm(happyforms.Form): error = forms.ChoiceField(choices=( ['zerodivisionerror', 'Zero Division Error (will email)'], ['iorequesterror', 'IORequest Error (no email)'], ['heka_statsd', 'Heka statsd message'], ['heka_json', 'Heka JSON message'], ['heka_cef', 'Heka CEF message'], ['heka_sentry', 'Heka Sentry message'], ['amo_cef', 'AMO CEF message'], )) def explode(self): error = self.cleaned_data.get('error') if error == 'zerodivisionerror': 1 / 0 elif error == 'iorequesterror': class IOError(Exception): pass raise IOError('request data read error') elif error == 'heka_cef': environ = {'REMOTE_ADDR': '127.0.0.1', 'HTTP_HOST': '127.0.0.1', 'PATH_INFO': '/', 'REQUEST_METHOD': 'GET', 'HTTP_USER_AGENT': 'MySuperBrowser'} config = {'cef.version': '0', 'cef.vendor': 'Mozilla', 'cef.device_version': '3', 'cef.product': 'zamboni', 'cef': True} settings.HEKA.cef('xx\nx|xx\rx', 5, environ, config, username='me', ext1='ok=ok', ext2='ok\\ok', logger_info='settings.HEKA') elif error == 'heka_statsd': settings.HEKA.incr(name=LOGGER_NAME) elif error == 'heka_json': settings.HEKA.heka(type="heka_json", fields={'foo': 'bar', 'secret': 42, 'logger_type': 'settings.HEKA'}) elif error == 'heka_sentry': # These are local variables only used # by Sentry's frame hacking magic. # They won't be referenced which may trigger flake8 # errors. heka_conf = settings.HEKA_CONF # NOQA active_heka_conf = settings.HEKA._config # NOQA try: 1 / 0 except: settings.HEKA.raven('heka_sentry error triggered') elif error == 'amo_cef': from mkt.site.utils import log_cef env = {'REMOTE_ADDR': '127.0.0.1', 'HTTP_HOST': '127.0.0.1', 'PATH_INFO': '/', 'REQUEST_METHOD': 'GET', 'HTTP_USER_AGENT': 'MySuperBrowser'} log_cef(settings.STATSD_PREFIX, 6, env) class PriceTiersForm(happyforms.Form): prices = forms.FileField()
bsd-3-clause
[ 504, 1639, 492, 4513, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 646, 2863, 1068, 14, 793, 199, 646, 394, 18869, 3351, 421, 199, 10186, 63, 2339, 275, 283, 90, 14, 90, 2113, 7, 199, 793, 275, 2863, 1068, 14, 793, 14, 5572, 8, 10186, 63, 2339, 9, 421, 199, 533, 29314, 11903, 3566, 2821, 8, 72, 18869, 3351, 14, 2821, 304, 272, 485, 4577, 275, 4274, 5181, 297, 283, 31032, 83, 402, 4702, 8686, 334, 1397, 1050, 13, 4654, 11218, 355, 661, 4624, 63, 5181, 63, 4551, 63, 3827, 297, 326, 283, 31032, 83, 402, 2867, 8686, 436, 892, 4897, 5223, 659, 355, 661, 4624, 63, 5181, 63, 4551, 63, 7011, 297, 326, 283, 31032, 83, 402, 2867, 8686, 543, 892, 16150, 6980, 659, 355, 661, 31432, 297, 326, 283, 31032, 83, 402, 2222, 13, 6062, 8686, 334, 1397, 1050, 13, 4654, 9, 543, 8633, 1470, 659, 355, 661, 31432, 63, 4551, 63, 3827, 297, 326, 283, 31032, 83, 402, 8686, 543, 8633, 1470, 436, 892, 16150, 5223, 659, 355, 661, 31432, 63, 4551, 63, 7011, 297, 326, 283, 31032, 83, 402, 8686, 543, 8633, 1470, 436, 892, 16150, 6980, 659, 355, 661, 14487, 63, 5181, 297, 326, 283, 31032, 83, 402, 2222, 13, 6062, 8686, 3748, 641, 19763, 5440, 272, 19255, 275, 4513, 14, 15792, 8, 4577, 3699, 4577, 12, 1415, 29, 549, 9, 272, 5420, 275, 4513, 14, 2183, 8, 3440, 29, 3351, 14, 18362, 8, 3288, 29, 807, 8, 890, 534, 1960, 3855, 2892, 1415, 29, 549, 9, 272, 19653, 63, 2118, 275, 4513, 14, 5036, 8, 2747, 29, 549, 12, 1415, 29, 797, 12, 4228, 1768, 29, 85, 7, 2445, 14931, 3140, 402, 10209, 358, 272, 1245, 275, 4513, 14, 2183, 8, 3440, 29, 3351, 14, 1872, 6789, 12, 1415, 29, 549, 9, 421, 199, 533, 29715, 16221, 51, 608, 8, 72, 18869, 3351, 14, 2821, 304, 272, 9456, 275, 4513, 14, 5036, 8, 2427, 29, 549, 12, 1768, 628, 12555, 12, 473, 6704, 3238, 531, 421, 199, 533, 7958, 547, 2821, 8, 72, 18869, 3351, 14, 2821, 304, 272, 1125, 275, 4513, 14, 15792, 8, 4577, 2687, 267, 788, 4262, 25035, 705, 297, 283, 8681, 3757, 2317, 4520, 334, 14117, 3031, 9, 995, 267, 788, 73, 720, 18246, 451, 297, 283, 2090, 2017, 4520, 334, 889, 3031, 9, 995, 267, 788, 426, 7351, 63, 3200, 68, 297, 283, 1966, 7351, 5020, 68, 1245, 995, 267, 788, 426, 7351, 63, 1001, 297, 283, 1966, 7351, 4840, 1245, 995, 267, 788, 426, 7351, 63, 29308, 297, 283, 1966, 7351, 445, 14153, 1245, 995, 267, 788, 426, 7351, 63, 3870, 297, 283, 1966, 7351, 428, 2373, 1245, 995, 267, 788, 4393, 63, 29308, 297, 283, 1156, 47, 445, 14153, 1245, 995, 272, 5082, 339, 347, 15868, 271, 8, 277, 304, 267, 1125, 275, 291, 14, 8275, 63, 576, 14, 362, 360, 705, 358, 398, 340, 1125, 508, 283, 4262, 25035, 705, 356, 288, 413, 1182, 378, 267, 916, 1125, 508, 283, 73, 720, 18246, 451, 356, 288, 1021, 5925, 8, 1726, 304, 355, 986, 288, 746, 5925, 360, 1069, 666, 1586, 1125, 358, 267, 916, 1125, 508, 283, 426, 7351, 63, 29308, 356, 288, 6160, 275, 791, 16058, 63, 7803, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 283, 2856, 63, 5449, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 2432, 283, 3243, 63, 4531, 356, 17220, 283, 6780, 63, 9977, 356, 283, 2970, 297, 2432, 283, 2856, 63, 3791, 63, 14565, 356, 283, 5713, 11823, 11930, 936, 953, 1101, 275, 791, 29308, 14, 1023, 356, 283, 16, 297, 1993, 283, 29308, 14, 9884, 356, 283, 22285, 297, 1993, 283, 29308, 14, 1782, 63, 1023, 356, 283, 19, 297, 1993, 283, 29308, 14, 2558, 356, 283, 90, 11020, 265, 73, 297, 1993, 283, 29308, 356, 715, 93, 953, 2202, 14, 1645, 19606, 14, 29308, 360, 2154, 60, 7343, 92, 2154, 60, 6872, 297, 959, 12, 6160, 12, 1101, 12, 2892, 3434, 534, 278, 297, 1599, 17, 534, 745, 29, 745, 297, 1599, 18, 534, 745, 1103, 745, 297, 2892, 2512, 63, 815, 534, 1751, 14, 1645, 19606, 358, 267, 916, 1125, 508, 283, 426, 7351, 63, 3200, 68, 356, 288, 2202, 14, 1645, 19606, 14, 19362, 8, 354, 29, 10186, 63, 2339, 9, 267, 916, 1125, 508, 283, 426, 7351, 63, 1001, 356, 288, 2202, 14, 1645, 19606, 14, 426, 7351, 8, 466, 628, 426, 7351, 63, 1001, 401, 3044, 1504, 3713, 1421, 356, 283, 1700, 297, 283, 4731, 356, 5685, 12, 4318, 283, 2921, 63, 466, 356, 283, 1751, 14, 1645, 19606, 3071, 398, 916, 1125, 508, 283, 426, 7351, 63, 3870, 356, 288, 327, 5723, 787, 2257, 2860, 1454, 1202, 288, 327, 701, 428, 2373, 1159, 2787, 11176, 316, 10628, 14, 288, 327, 9322, 7859, 1133, 506, 11812, 1314, 1443, 6804, 27510, 24, 288, 327, 2552, 14, 288, 946, 7351, 63, 2190, 275, 2202, 14, 1645, 19606, 63, 3103, 221, 327, 20432, 288, 4702, 63, 426, 7351, 63, 2190, 275, 2202, 14, 1645, 19606, 423, 888, 221, 327, 20432, 288, 862, 26, 355, 413, 1182, 378, 288, 871, 26, 355, 2202, 14, 1645, 19606, 14, 345, 1856, 360, 426, 7351, 63, 3870, 1125, 15572, 358, 267, 916, 1125, 508, 283, 4393, 63, 29308, 356, 288, 687, 21825, 14, 2124, 14, 1208, 492, 943, 63, 29308, 288, 2589, 275, 791, 16058, 63, 7803, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 283, 2856, 63, 5449, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 673, 283, 3243, 63, 4531, 356, 17220, 283, 6780, 63, 9977, 356, 283, 2970, 297, 673, 283, 2856, 63, 3791, 63, 14565, 356, 283, 5713, 11823, 11930, 936, 288, 943, 63, 29308, 8, 1751, 14, 4315, 3693, 63, 6351, 12, 1227, 12, 2589, 9, 421, 199, 533, 20276, 22731, 1192, 2821, 8, 72, 18869, 3351, 14, 2821, 304, 272, 1979, 823, 275, 4513, 14, 23252, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1639, 492, 4513, 199, 504, 1639, 14, 2190, 492, 2202, 199, 199, 646, 2863, 1068, 14, 793, 199, 646, 394, 18869, 3351, 421, 199, 10186, 63, 2339, 275, 283, 90, 14, 90, 2113, 7, 199, 793, 275, 2863, 1068, 14, 793, 14, 5572, 8, 10186, 63, 2339, 9, 421, 199, 533, 29314, 11903, 3566, 2821, 8, 72, 18869, 3351, 14, 2821, 304, 272, 485, 4577, 275, 4274, 5181, 297, 283, 31032, 83, 402, 4702, 8686, 334, 1397, 1050, 13, 4654, 11218, 355, 661, 4624, 63, 5181, 63, 4551, 63, 3827, 297, 326, 283, 31032, 83, 402, 2867, 8686, 436, 892, 4897, 5223, 659, 355, 661, 4624, 63, 5181, 63, 4551, 63, 7011, 297, 326, 283, 31032, 83, 402, 2867, 8686, 543, 892, 16150, 6980, 659, 355, 661, 31432, 297, 326, 283, 31032, 83, 402, 2222, 13, 6062, 8686, 334, 1397, 1050, 13, 4654, 9, 543, 8633, 1470, 659, 355, 661, 31432, 63, 4551, 63, 3827, 297, 326, 283, 31032, 83, 402, 8686, 543, 8633, 1470, 436, 892, 16150, 5223, 659, 355, 661, 31432, 63, 4551, 63, 7011, 297, 326, 283, 31032, 83, 402, 8686, 543, 8633, 1470, 436, 892, 16150, 6980, 659, 355, 661, 14487, 63, 5181, 297, 326, 283, 31032, 83, 402, 2222, 13, 6062, 8686, 3748, 641, 19763, 5440, 272, 19255, 275, 4513, 14, 15792, 8, 4577, 3699, 4577, 12, 1415, 29, 549, 9, 272, 5420, 275, 4513, 14, 2183, 8, 3440, 29, 3351, 14, 18362, 8, 3288, 29, 807, 8, 890, 534, 1960, 3855, 2892, 1415, 29, 549, 9, 272, 19653, 63, 2118, 275, 4513, 14, 5036, 8, 2747, 29, 549, 12, 1415, 29, 797, 12, 4228, 1768, 29, 85, 7, 2445, 14931, 3140, 402, 10209, 358, 272, 1245, 275, 4513, 14, 2183, 8, 3440, 29, 3351, 14, 1872, 6789, 12, 1415, 29, 549, 9, 421, 199, 533, 29715, 16221, 51, 608, 8, 72, 18869, 3351, 14, 2821, 304, 272, 9456, 275, 4513, 14, 5036, 8, 2427, 29, 549, 12, 1768, 628, 12555, 12, 473, 6704, 3238, 531, 421, 199, 533, 7958, 547, 2821, 8, 72, 18869, 3351, 14, 2821, 304, 272, 1125, 275, 4513, 14, 15792, 8, 4577, 2687, 267, 788, 4262, 25035, 705, 297, 283, 8681, 3757, 2317, 4520, 334, 14117, 3031, 9, 995, 267, 788, 73, 720, 18246, 451, 297, 283, 2090, 2017, 4520, 334, 889, 3031, 9, 995, 267, 788, 426, 7351, 63, 3200, 68, 297, 283, 1966, 7351, 5020, 68, 1245, 995, 267, 788, 426, 7351, 63, 1001, 297, 283, 1966, 7351, 4840, 1245, 995, 267, 788, 426, 7351, 63, 29308, 297, 283, 1966, 7351, 445, 14153, 1245, 995, 267, 788, 426, 7351, 63, 3870, 297, 283, 1966, 7351, 428, 2373, 1245, 995, 267, 788, 4393, 63, 29308, 297, 283, 1156, 47, 445, 14153, 1245, 995, 272, 5082, 339, 347, 15868, 271, 8, 277, 304, 267, 1125, 275, 291, 14, 8275, 63, 576, 14, 362, 360, 705, 358, 398, 340, 1125, 508, 283, 4262, 25035, 705, 356, 288, 413, 1182, 378, 267, 916, 1125, 508, 283, 73, 720, 18246, 451, 356, 288, 1021, 5925, 8, 1726, 304, 355, 986, 288, 746, 5925, 360, 1069, 666, 1586, 1125, 358, 267, 916, 1125, 508, 283, 426, 7351, 63, 29308, 356, 288, 6160, 275, 791, 16058, 63, 7803, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 283, 2856, 63, 5449, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 2432, 283, 3243, 63, 4531, 356, 17220, 283, 6780, 63, 9977, 356, 283, 2970, 297, 2432, 283, 2856, 63, 3791, 63, 14565, 356, 283, 5713, 11823, 11930, 936, 953, 1101, 275, 791, 29308, 14, 1023, 356, 283, 16, 297, 1993, 283, 29308, 14, 9884, 356, 283, 22285, 297, 1993, 283, 29308, 14, 1782, 63, 1023, 356, 283, 19, 297, 1993, 283, 29308, 14, 2558, 356, 283, 90, 11020, 265, 73, 297, 1993, 283, 29308, 356, 715, 93, 953, 2202, 14, 1645, 19606, 14, 29308, 360, 2154, 60, 7343, 92, 2154, 60, 6872, 297, 959, 12, 6160, 12, 1101, 12, 2892, 3434, 534, 278, 297, 1599, 17, 534, 745, 29, 745, 297, 1599, 18, 534, 745, 1103, 745, 297, 2892, 2512, 63, 815, 534, 1751, 14, 1645, 19606, 358, 267, 916, 1125, 508, 283, 426, 7351, 63, 3200, 68, 356, 288, 2202, 14, 1645, 19606, 14, 19362, 8, 354, 29, 10186, 63, 2339, 9, 267, 916, 1125, 508, 283, 426, 7351, 63, 1001, 356, 288, 2202, 14, 1645, 19606, 14, 426, 7351, 8, 466, 628, 426, 7351, 63, 1001, 401, 3044, 1504, 3713, 1421, 356, 283, 1700, 297, 283, 4731, 356, 5685, 12, 4318, 283, 2921, 63, 466, 356, 283, 1751, 14, 1645, 19606, 3071, 398, 916, 1125, 508, 283, 426, 7351, 63, 3870, 356, 288, 327, 5723, 787, 2257, 2860, 1454, 1202, 288, 327, 701, 428, 2373, 1159, 2787, 11176, 316, 10628, 14, 288, 327, 9322, 7859, 1133, 506, 11812, 1314, 1443, 6804, 27510, 24, 288, 327, 2552, 14, 288, 946, 7351, 63, 2190, 275, 2202, 14, 1645, 19606, 63, 3103, 221, 327, 20432, 288, 4702, 63, 426, 7351, 63, 2190, 275, 2202, 14, 1645, 19606, 423, 888, 221, 327, 20432, 288, 862, 26, 355, 413, 1182, 378, 288, 871, 26, 355, 2202, 14, 1645, 19606, 14, 345, 1856, 360, 426, 7351, 63, 3870, 1125, 15572, 358, 267, 916, 1125, 508, 283, 4393, 63, 29308, 356, 288, 687, 21825, 14, 2124, 14, 1208, 492, 943, 63, 29308, 288, 2589, 275, 791, 16058, 63, 7803, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 283, 2856, 63, 5449, 356, 283, 4195, 14, 16, 14, 16, 14, 17, 297, 673, 283, 3243, 63, 4531, 356, 17220, 283, 6780, 63, 9977, 356, 283, 2970, 297, 673, 283, 2856, 63, 3791, 63, 14565, 356, 283, 5713, 11823, 11930, 936, 288, 943, 63, 29308, 8, 1751, 14, 4315, 3693, 63, 6351, 12, 1227, 12, 2589, 9, 421, 199, 533, 20276, 22731, 1192, 2821, 8, 72, 18869, 3351, 14, 2821, 304, 272, 1979, 823, 275, 4513, 14, 23252, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
kidaa/pySDC
examples/fenics_advection_diffusion_1d/TransferClass.py
3
2365
from __future__ import division from pySDC.Transfer import transfer from pySDC.datatype_classes.fenics_mesh import fenics_mesh,rhs_fenics_mesh import dolfin as df class mesh_to_mesh_fenics(transfer): """ Custon transfer class, implements Transfer.py This implementation can restrict and prolong between fenics meshes Attributes: fine: reference to the fine level coarse: reference to the coarse level init_f: number of variables on the fine level (whatever init represents there) init_c: number of variables on the coarse level (whatever init represents there) """ def __init__(self,fine_level,coarse_level,params): """ Initialization routine Args: fine_level: fine level connected with the transfer operations (passed to parent) coarse_level: coarse level connected with the transfer operations (passed to parent) params: parameters for the transfer operators """ # invoke super initialization super(mesh_to_mesh_fenics,self).__init__(fine_level,coarse_level,params) pass def restrict_space(self,F): """ Restriction implementation Args: F: the fine level data (easier to access than via the fine attribute) """ if isinstance(F,fenics_mesh): u_coarse = fenics_mesh(self.init_c) u_coarse.values = df.interpolate(F.values,u_coarse.V) elif isinstance(F,rhs_fenics_mesh): u_coarse = rhs_fenics_mesh(self.init_c) u_coarse.impl.values = df.interpolate(F.impl.values,u_coarse.impl.V) u_coarse.expl.values = df.interpolate(F.expl.values,u_coarse.expl.V) return u_coarse def prolong_space(self,G): """ Prolongation implementation Args: G: the coarse level data (easier to access than via the coarse attribute) """ if isinstance(G,fenics_mesh): u_fine = fenics_mesh(self.init_f) u_fine.values = df.interpolate(G.values,u_fine.V) elif isinstance(G,rhs_fenics_mesh): u_fine = rhs_fenics_mesh(self.init_f) u_fine.impl.values = df.interpolate(G.impl.values,u_fine.impl.V) u_fine.expl.values = df.interpolate(G.expl.values,u_fine.expl.V) return u_fine
bsd-2-clause
[ 504, 636, 2443, 363, 492, 4629, 199, 199, 504, 1134, 3693, 35, 14, 11761, 492, 9307, 199, 504, 1134, 3693, 35, 14, 14184, 63, 2888, 14, 70, 287, 2932, 63, 6480, 492, 289, 287, 2932, 63, 6480, 12, 12071, 63, 70, 287, 2932, 63, 6480, 199, 199, 646, 886, 276, 262, 465, 4051, 199, 199, 533, 9364, 63, 475, 63, 6480, 63, 70, 287, 2932, 8, 9609, 304, 272, 408, 272, 445, 833, 265, 9307, 1021, 12, 9031, 27507, 14, 647, 339, 961, 4514, 883, 18152, 436, 557, 2809, 3382, 289, 287, 2932, 9364, 397, 339, 9382, 26, 267, 15701, 26, 3659, 370, 314, 15701, 2166, 267, 512, 30672, 26, 3659, 370, 314, 512, 30672, 2166, 267, 4205, 63, 70, 26, 1329, 402, 2860, 641, 314, 15701, 2166, 334, 26517, 4205, 8469, 2337, 9, 267, 4205, 63, 67, 26, 1329, 402, 2860, 641, 314, 512, 30672, 2166, 334, 26517, 4205, 8469, 2337, 9, 272, 408, 339, 347, 636, 826, 721, 277, 12, 70, 1132, 63, 1896, 12, 331, 30672, 63, 1896, 12, 1162, 304, 267, 408, 267, 6026, 2072, 12981, 398, 3033, 26, 288, 15701, 63, 1896, 26, 15701, 2166, 8539, 543, 314, 9307, 5331, 334, 12070, 370, 1676, 9, 288, 512, 30672, 63, 1896, 26, 512, 30672, 2166, 8539, 543, 314, 9307, 5331, 334, 12070, 370, 1676, 9, 288, 1862, 26, 2633, 367, 314, 9307, 10211, 267, 408, 398, 327, 12677, 1613, 11097, 267, 1613, 8, 6480, 63, 475, 63, 6480, 63, 70, 287, 2932, 12, 277, 2843, 826, 721, 70, 1132, 63, 1896, 12, 331, 30672, 63, 1896, 12, 1162, 9, 398, 986, 339, 347, 18152, 63, 2638, 8, 277, 12, 38, 304, 267, 408, 267, 32491, 414, 4514, 398, 3033, 26, 288, 481, 26, 314, 15701, 2166, 666, 334, 69, 305, 4446, 370, 2879, 2419, 4799, 314, 15701, 2225, 9, 267, 408, 398, 340, 1228, 8, 38, 12, 70, 287, 2932, 63, 6480, 304, 288, 399, 63, 331, 30672, 275, 289, 287, 2932, 63, 6480, 8, 277, 14, 826, 63, 67, 9, 288, 399, 63, 331, 30672, 14, 1459, 275, 4051, 14, 21294, 8, 38, 14, 1459, 12, 85, 63, 331, 30672, 14, 54, 9, 267, 916, 1228, 8, 38, 12, 12071, 63, 70, 287, 2932, 63, 6480, 304, 288, 399, 63, 331, 30672, 275, 9085, 63, 70, 287, 2932, 63, 6480, 8, 277, 14, 826, 63, 67, 9, 288, 399, 63, 331, 30672, 14, 5472, 14, 1459, 275, 4051, 14, 21294, 8, 38, 14, 5472, 14, 1459, 12, 85, 63, 331, 30672, 14, 5472, 14, 54, 9, 288, 399, 63, 331, 30672, 14, 476, 1168, 14, 1459, 275, 4051, 14, 21294, 8, 38, 14, 476, 1168, 14, 1459, 12, 85, 63, 331, 30672, 14, 476, 1168, 14, 54, 9, 398, 372, 399, 63, 331, 30672, 339, 347, 557, 2809, 63, 2638, 8, 277, 12, 39, 304, 267, 408, 267, 2165, 2809, 425, 4514, 398, 3033, 26, 288, 598, 26, 314, 512, 30672, 2166, 666, 334, 69, 305, 4446, 370, 2879, 2419, 4799, 314, 512, 30672, 2225, 9, 267, 408, 398, 340, 1228, 8, 39, 12, 70, 287, 2932, 63, 6480, 304, 288, 399, 63, 70, 1132, 275, 289, 287, 2932, 63, 6480, 8, 277, 14, 826, 63, 70, 9, 288, 399, 63, 70, 1132, 14, 1459, 275, 4051, 14, 21294, 8, 39, 14, 1459, 12, 85, 63, 70, 1132, 14, 54, 9, 267, 916, 1228, 8, 39, 12, 12071, 63, 70, 287, 2932, 63, 6480, 304, 288, 399, 63, 70, 1132, 275, 9085, 63, 70, 287, 2932, 63, 6480, 8, 277, 14, 826, 63, 70, 9, 288, 399, 63, 70, 1132, 14, 5472, 14, 1459, 275, 4051, 14, 21294, 8, 39, 14, 5472, 14, 1459, 12, 85, 63, 70, 1132, 14, 5472, 14, 54, 9, 288, 399, 63, 70, 1132, 14, 476, 1168, 14, 1459, 275, 4051, 14, 21294, 8, 39, 14, 476, 1168, 14, 1459, 12, 85, 63, 70, 1132, 14, 476, 1168, 14, 54, 9, 398, 372, 399, 63, 70, 1132, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 636, 2443, 363, 492, 4629, 199, 199, 504, 1134, 3693, 35, 14, 11761, 492, 9307, 199, 504, 1134, 3693, 35, 14, 14184, 63, 2888, 14, 70, 287, 2932, 63, 6480, 492, 289, 287, 2932, 63, 6480, 12, 12071, 63, 70, 287, 2932, 63, 6480, 199, 199, 646, 886, 276, 262, 465, 4051, 199, 199, 533, 9364, 63, 475, 63, 6480, 63, 70, 287, 2932, 8, 9609, 304, 272, 408, 272, 445, 833, 265, 9307, 1021, 12, 9031, 27507, 14, 647, 339, 961, 4514, 883, 18152, 436, 557, 2809, 3382, 289, 287, 2932, 9364, 397, 339, 9382, 26, 267, 15701, 26, 3659, 370, 314, 15701, 2166, 267, 512, 30672, 26, 3659, 370, 314, 512, 30672, 2166, 267, 4205, 63, 70, 26, 1329, 402, 2860, 641, 314, 15701, 2166, 334, 26517, 4205, 8469, 2337, 9, 267, 4205, 63, 67, 26, 1329, 402, 2860, 641, 314, 512, 30672, 2166, 334, 26517, 4205, 8469, 2337, 9, 272, 408, 339, 347, 636, 826, 721, 277, 12, 70, 1132, 63, 1896, 12, 331, 30672, 63, 1896, 12, 1162, 304, 267, 408, 267, 6026, 2072, 12981, 398, 3033, 26, 288, 15701, 63, 1896, 26, 15701, 2166, 8539, 543, 314, 9307, 5331, 334, 12070, 370, 1676, 9, 288, 512, 30672, 63, 1896, 26, 512, 30672, 2166, 8539, 543, 314, 9307, 5331, 334, 12070, 370, 1676, 9, 288, 1862, 26, 2633, 367, 314, 9307, 10211, 267, 408, 398, 327, 12677, 1613, 11097, 267, 1613, 8, 6480, 63, 475, 63, 6480, 63, 70, 287, 2932, 12, 277, 2843, 826, 721, 70, 1132, 63, 1896, 12, 331, 30672, 63, 1896, 12, 1162, 9, 398, 986, 339, 347, 18152, 63, 2638, 8, 277, 12, 38, 304, 267, 408, 267, 32491, 414, 4514, 398, 3033, 26, 288, 481, 26, 314, 15701, 2166, 666, 334, 69, 305, 4446, 370, 2879, 2419, 4799, 314, 15701, 2225, 9, 267, 408, 398, 340, 1228, 8, 38, 12, 70, 287, 2932, 63, 6480, 304, 288, 399, 63, 331, 30672, 275, 289, 287, 2932, 63, 6480, 8, 277, 14, 826, 63, 67, 9, 288, 399, 63, 331, 30672, 14, 1459, 275, 4051, 14, 21294, 8, 38, 14, 1459, 12, 85, 63, 331, 30672, 14, 54, 9, 267, 916, 1228, 8, 38, 12, 12071, 63, 70, 287, 2932, 63, 6480, 304, 288, 399, 63, 331, 30672, 275, 9085, 63, 70, 287, 2932, 63, 6480, 8, 277, 14, 826, 63, 67, 9, 288, 399, 63, 331, 30672, 14, 5472, 14, 1459, 275, 4051, 14, 21294, 8, 38, 14, 5472, 14, 1459, 12, 85, 63, 331, 30672, 14, 5472, 14, 54, 9, 288, 399, 63, 331, 30672, 14, 476, 1168, 14, 1459, 275, 4051, 14, 21294, 8, 38, 14, 476, 1168, 14, 1459, 12, 85, 63, 331, 30672, 14, 476, 1168, 14, 54, 9, 398, 372, 399, 63, 331, 30672, 339, 347, 557, 2809, 63, 2638, 8, 277, 12, 39, 304, 267, 408, 267, 2165, 2809, 425, 4514, 398, 3033, 26, 288, 598, 26, 314, 512, 30672, 2166, 666, 334, 69, 305, 4446, 370, 2879, 2419, 4799, 314, 512, 30672, 2225, 9, 267, 408, 398, 340, 1228, 8, 39, 12, 70, 287, 2932, 63, 6480, 304, 288, 399, 63, 70, 1132, 275, 289, 287, 2932, 63, 6480, 8, 277, 14, 826, 63, 70, 9, 288, 399, 63, 70, 1132, 14, 1459, 275, 4051, 14, 21294, 8, 39, 14, 1459, 12, 85, 63, 70, 1132, 14, 54, 9, 267, 916, 1228, 8, 39, 12, 12071, 63, 70, 287, 2932, 63, 6480, 304, 288, 399, 63, 70, 1132, 275, 9085, 63, 70, 287, 2932, 63, 6480, 8, 277, 14, 826, 63, 70, 9, 288, 399, 63, 70, 1132, 14, 5472, 14, 1459, 275, 4051, 14, 21294, 8, 39, 14, 5472, 14, 1459, 12, 85, 63, 70, 1132, 14, 5472, 14, 54, 9, 288, 399, 63, 70, 1132, 14, 476, 1168, 14, 1459, 275, 4051, 14, 21294, 8, 39, 14, 476, 1168, 14, 1459, 12, 85, 63, 70, 1132, 14, 476, 1168, 14, 54, 9, 398, 372, 399, 63, 70, 1132, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
adamkh/micropython
tests/wipy/time.py
67
2937
import time DAYS_PER_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def is_leap(year): return (year % 4) == 0 def test(): seconds = 0 wday = 5 # Jan 1, 2000 was a Saturday for year in range(2000, 2049): print("Testing %d" % year) yday = 1 for month in range(1, 13): if month == 2 and is_leap(year): DAYS_PER_MONTH[2] = 29 else: DAYS_PER_MONTH[2] = 28 for day in range(1, DAYS_PER_MONTH[month] + 1): secs = time.mktime((year, month, day, 0, 0, 0, 0, 0)) if secs != seconds: print("mktime failed for %d-%02d-%02d got %d expected %d" % (year, month, day, secs, seconds)) tuple = time.localtime(seconds) secs = time.mktime(tuple) if secs != seconds: print("localtime failed for %d-%02d-%02d got %d expected %d" % (year, month, day, secs, seconds)) return seconds += 86400 if yday != tuple[7]: print("locatime for %d-%02d-%02d got yday %d, expecting %d" % (year, month, day, tuple[7], yday)) return if wday != tuple[6]: print("locatime for %d-%02d-%02d got wday %d, expecting %d" % (year, month, day, tuple[6], wday)) return yday += 1 wday = (wday + 1) % 7 def spot_test(seconds, expected_time): actual_time = time.localtime(seconds) for i in range(len(actual_time)): if actual_time[i] != expected_time[i]: print("time.localtime(", seconds, ") returned", actual_time, "expecting", expected_time) return print("time.localtime(", seconds, ") returned", actual_time, "(pass)") test() spot_test( 0, (2000, 1, 1, 0, 0, 0, 5, 1)) spot_test( 1, (2000, 1, 1, 0, 0, 1, 5, 1)) spot_test( 59, (2000, 1, 1, 0, 0, 59, 5, 1)) spot_test( 60, (2000, 1, 1, 0, 1, 0, 5, 1)) spot_test( 3599, (2000, 1, 1, 0, 59, 59, 5, 1)) spot_test( 3600, (2000, 1, 1, 1, 0, 0, 5, 1)) spot_test( -1, (1999, 12, 31, 23, 59, 59, 4, 365)) spot_test( 447549467, (2014, 3, 7, 23, 17, 47, 4, 66)) spot_test( -940984933, (1970, 3, 7, 23, 17, 47, 5, 66)) spot_test(-1072915199, (1966, 1, 1, 0, 0, 1, 5, 1)) spot_test(-1072915200, (1966, 1, 1, 0, 0, 0, 5, 1)) spot_test(-1072915201, (1965, 12, 31, 23, 59, 59, 4, 365)) t1 = time.time() time.sleep(2) t2 = time.time() print(abs(time.ticks_diff(t1, t2) -2) <= 1) t1 = time.ticks_ms() time.sleep_ms(50) t2 = time.ticks_ms() print(abs(time.ticks_diff(t1, t2)- 50) <= 1) t1 = time.ticks_us() time.sleep_us(1000) t2 = time.ticks_us() print(time.ticks_diff(t1, t2) < 1500) print(time.ticks_diff(time.ticks_cpu(), time.ticks_cpu()) < 16384)
mit
[ 646, 900, 199, 199, 25683, 63, 4227, 63, 16413, 275, 359, 16, 12, 7105, 12, 7294, 12, 7105, 12, 4233, 12, 7105, 12, 4233, 12, 7105, 12, 7105, 12, 4233, 12, 7105, 12, 4233, 12, 7105, 61, 199, 199, 318, 365, 63, 28764, 8, 3403, 304, 272, 372, 334, 3403, 450, 841, 9, 508, 378, 199, 199, 318, 511, 837, 272, 4696, 275, 378, 272, 336, 2977, 275, 959, 259, 327, 17474, 413, 12, 12293, 1990, 282, 428, 292, 300, 2977, 272, 367, 5361, 315, 1425, 8, 8269, 12, 499, 12809, 304, 267, 870, 480, 9029, 450, 68, 2, 450, 5361, 9, 267, 612, 2977, 275, 413, 267, 367, 5794, 315, 1425, 8, 17, 12, 4944, 304, 288, 340, 5794, 508, 499, 436, 365, 63, 28764, 8, 3403, 304, 355, 577, 3448, 51, 63, 4227, 63, 16413, 59, 18, 61, 275, 7349, 288, 587, 26, 355, 577, 3448, 51, 63, 4227, 63, 16413, 59, 18, 61, 275, 7294, 288, 367, 5382, 315, 1425, 8, 17, 12, 577, 3448, 51, 63, 4227, 63, 16413, 59, 4482, 61, 435, 413, 304, 355, 20091, 275, 900, 14, 23456, 1332, 3403, 12, 5794, 12, 5382, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 430, 355, 340, 20091, 1137, 4696, 26, 490, 870, 480, 23456, 3405, 367, 450, 68, 3295, 996, 68, 3295, 996, 68, 4788, 450, 68, 1420, 450, 68, 2, 450, 334, 3403, 12, 5794, 12, 5382, 12, 20091, 12, 4696, 430, 355, 2008, 275, 900, 14, 15198, 8, 4515, 9, 355, 20091, 275, 900, 14, 23456, 8, 2960, 9, 355, 340, 20091, 1137, 4696, 26, 490, 870, 480, 15198, 3405, 367, 450, 68, 3295, 996, 68, 3295, 996, 68, 4788, 450, 68, 1420, 450, 68, 2, 450, 334, 3403, 12, 5794, 12, 5382, 12, 20091, 12, 4696, 430, 490, 372, 355, 4696, 847, 31200, 355, 340, 612, 2977, 1137, 2008, 59, 23, 2189, 490, 870, 480, 320, 696, 521, 367, 450, 68, 3295, 996, 68, 3295, 996, 68, 4788, 612, 2977, 450, 68, 12, 21055, 450, 68, 2, 450, 334, 3403, 12, 5794, 12, 5382, 12, 2008, 59, 23, 467, 612, 2977, 430, 490, 372, 355, 340, 336, 2977, 1137, 2008, 59, 22, 2189, 490, 870, 480, 320, 696, 521, 367, 450, 68, 3295, 996, 68, 3295, 996, 68, 4788, 336, 2977, 450, 68, 12, 21055, 450, 68, 2, 450, 334, 3403, 12, 5794, 12, 5382, 12, 2008, 59, 22, 467, 336, 2977, 430, 490, 372, 355, 612, 2977, 847, 413, 355, 336, 2977, 275, 334, 87, 2977, 435, 413, 9, 450, 1520, 199, 199, 318, 23226, 63, 396, 8, 4515, 12, 1420, 63, 521, 304, 272, 3503, 63, 521, 275, 900, 14, 15198, 8, 4515, 9, 272, 367, 284, 315, 1425, 8, 552, 8, 6514, 63, 521, 2298, 267, 340, 3503, 63, 521, 59, 73, 61, 1137, 1420, 63, 521, 59, 73, 2189, 288, 870, 480, 521, 14, 15198, 11854, 4696, 12, 6099, 2138, 401, 3503, 63, 521, 12, 298, 4921, 316, 401, 1420, 63, 521, 9, 288, 372, 272, 870, 480, 521, 14, 15198, 11854, 4696, 12, 6099, 2138, 401, 3503, 63, 521, 12, 7340, 1529, 6320, 199, 199, 396, 342, 199, 15185, 63, 396, 8, 3515, 378, 12, 221, 334, 8269, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 378, 12, 221, 378, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 8, 3515, 413, 12, 221, 334, 8269, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 378, 12, 221, 413, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 8, 260, 8155, 12, 221, 334, 8269, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 378, 12, 8155, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 8, 260, 5212, 12, 221, 334, 8269, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 413, 12, 221, 378, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 8, 755, 8685, 1020, 12, 221, 334, 8269, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 8155, 12, 8155, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 8, 755, 15751, 12, 221, 334, 8269, 12, 221, 413, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 378, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 8, 260, 446, 17, 12, 221, 334, 16278, 12, 3144, 12, 7105, 12, 6546, 12, 8155, 12, 8155, 12, 841, 12, 28046, 430, 199, 15185, 63, 396, 8, 221, 841, 2417, 1477, 2635, 1822, 12, 221, 334, 7280, 12, 221, 650, 12, 221, 1520, 12, 6546, 12, 5557, 12, 10954, 12, 841, 12, 221, 14157, 430, 199, 15185, 63, 396, 8, 446, 2635, 1643, 14866, 1153, 12, 221, 334, 21740, 12, 221, 650, 12, 221, 1520, 12, 6546, 12, 5557, 12, 10954, 12, 959, 12, 221, 14157, 430, 199, 15185, 63, 396, 2801, 7555, 1398, 1046, 7155, 12, 221, 334, 1167, 1272, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 378, 12, 221, 413, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 2801, 7555, 1398, 1046, 1840, 12, 221, 334, 1167, 1272, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 378, 12, 221, 378, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 2801, 7555, 1398, 1046, 1797, 12, 221, 334, 1167, 2182, 12, 3144, 12, 7105, 12, 6546, 12, 8155, 12, 8155, 12, 841, 12, 28046, 430, 199, 199, 84, 17, 275, 900, 14, 521, 342, 199, 521, 14, 4532, 8, 18, 9, 199, 84, 18, 275, 900, 14, 521, 342, 199, 1361, 8, 2101, 8, 521, 14, 10406, 63, 3028, 8, 84, 17, 12, 307, 18, 9, 446, 18, 9, 2695, 413, 9, 199, 199, 84, 17, 275, 900, 14, 10406, 63, 706, 342, 199, 521, 14, 4532, 63, 706, 8, 1400, 9, 199, 84, 18, 275, 900, 14, 10406, 63, 706, 342, 199, 1361, 8, 2101, 8, 521, 14, 10406, 63, 3028, 8, 84, 17, 12, 307, 18, 7216, 5238, 9, 2695, 413, 9, 199, 199, 84, 17, 275, 900, 14, 10406, 63, 527, 342, 199, 521, 14, 4532, 63, 527, 8, 5279, 9, 199 ]
[ 900, 199, 199, 25683, 63, 4227, 63, 16413, 275, 359, 16, 12, 7105, 12, 7294, 12, 7105, 12, 4233, 12, 7105, 12, 4233, 12, 7105, 12, 7105, 12, 4233, 12, 7105, 12, 4233, 12, 7105, 61, 199, 199, 318, 365, 63, 28764, 8, 3403, 304, 272, 372, 334, 3403, 450, 841, 9, 508, 378, 199, 199, 318, 511, 837, 272, 4696, 275, 378, 272, 336, 2977, 275, 959, 259, 327, 17474, 413, 12, 12293, 1990, 282, 428, 292, 300, 2977, 272, 367, 5361, 315, 1425, 8, 8269, 12, 499, 12809, 304, 267, 870, 480, 9029, 450, 68, 2, 450, 5361, 9, 267, 612, 2977, 275, 413, 267, 367, 5794, 315, 1425, 8, 17, 12, 4944, 304, 288, 340, 5794, 508, 499, 436, 365, 63, 28764, 8, 3403, 304, 355, 577, 3448, 51, 63, 4227, 63, 16413, 59, 18, 61, 275, 7349, 288, 587, 26, 355, 577, 3448, 51, 63, 4227, 63, 16413, 59, 18, 61, 275, 7294, 288, 367, 5382, 315, 1425, 8, 17, 12, 577, 3448, 51, 63, 4227, 63, 16413, 59, 4482, 61, 435, 413, 304, 355, 20091, 275, 900, 14, 23456, 1332, 3403, 12, 5794, 12, 5382, 12, 378, 12, 378, 12, 378, 12, 378, 12, 378, 430, 355, 340, 20091, 1137, 4696, 26, 490, 870, 480, 23456, 3405, 367, 450, 68, 3295, 996, 68, 3295, 996, 68, 4788, 450, 68, 1420, 450, 68, 2, 450, 334, 3403, 12, 5794, 12, 5382, 12, 20091, 12, 4696, 430, 355, 2008, 275, 900, 14, 15198, 8, 4515, 9, 355, 20091, 275, 900, 14, 23456, 8, 2960, 9, 355, 340, 20091, 1137, 4696, 26, 490, 870, 480, 15198, 3405, 367, 450, 68, 3295, 996, 68, 3295, 996, 68, 4788, 450, 68, 1420, 450, 68, 2, 450, 334, 3403, 12, 5794, 12, 5382, 12, 20091, 12, 4696, 430, 490, 372, 355, 4696, 847, 31200, 355, 340, 612, 2977, 1137, 2008, 59, 23, 2189, 490, 870, 480, 320, 696, 521, 367, 450, 68, 3295, 996, 68, 3295, 996, 68, 4788, 612, 2977, 450, 68, 12, 21055, 450, 68, 2, 450, 334, 3403, 12, 5794, 12, 5382, 12, 2008, 59, 23, 467, 612, 2977, 430, 490, 372, 355, 340, 336, 2977, 1137, 2008, 59, 22, 2189, 490, 870, 480, 320, 696, 521, 367, 450, 68, 3295, 996, 68, 3295, 996, 68, 4788, 336, 2977, 450, 68, 12, 21055, 450, 68, 2, 450, 334, 3403, 12, 5794, 12, 5382, 12, 2008, 59, 22, 467, 336, 2977, 430, 490, 372, 355, 612, 2977, 847, 413, 355, 336, 2977, 275, 334, 87, 2977, 435, 413, 9, 450, 1520, 199, 199, 318, 23226, 63, 396, 8, 4515, 12, 1420, 63, 521, 304, 272, 3503, 63, 521, 275, 900, 14, 15198, 8, 4515, 9, 272, 367, 284, 315, 1425, 8, 552, 8, 6514, 63, 521, 2298, 267, 340, 3503, 63, 521, 59, 73, 61, 1137, 1420, 63, 521, 59, 73, 2189, 288, 870, 480, 521, 14, 15198, 11854, 4696, 12, 6099, 2138, 401, 3503, 63, 521, 12, 298, 4921, 316, 401, 1420, 63, 521, 9, 288, 372, 272, 870, 480, 521, 14, 15198, 11854, 4696, 12, 6099, 2138, 401, 3503, 63, 521, 12, 7340, 1529, 6320, 199, 199, 396, 342, 199, 15185, 63, 396, 8, 3515, 378, 12, 221, 334, 8269, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 378, 12, 221, 378, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 8, 3515, 413, 12, 221, 334, 8269, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 378, 12, 221, 413, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 8, 260, 8155, 12, 221, 334, 8269, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 378, 12, 8155, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 8, 260, 5212, 12, 221, 334, 8269, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 413, 12, 221, 378, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 8, 755, 8685, 1020, 12, 221, 334, 8269, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 8155, 12, 8155, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 8, 755, 15751, 12, 221, 334, 8269, 12, 221, 413, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 378, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 8, 260, 446, 17, 12, 221, 334, 16278, 12, 3144, 12, 7105, 12, 6546, 12, 8155, 12, 8155, 12, 841, 12, 28046, 430, 199, 15185, 63, 396, 8, 221, 841, 2417, 1477, 2635, 1822, 12, 221, 334, 7280, 12, 221, 650, 12, 221, 1520, 12, 6546, 12, 5557, 12, 10954, 12, 841, 12, 221, 14157, 430, 199, 15185, 63, 396, 8, 446, 2635, 1643, 14866, 1153, 12, 221, 334, 21740, 12, 221, 650, 12, 221, 1520, 12, 6546, 12, 5557, 12, 10954, 12, 959, 12, 221, 14157, 430, 199, 15185, 63, 396, 2801, 7555, 1398, 1046, 7155, 12, 221, 334, 1167, 1272, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 378, 12, 221, 413, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 2801, 7555, 1398, 1046, 1840, 12, 221, 334, 1167, 1272, 12, 221, 413, 12, 221, 413, 12, 221, 378, 12, 221, 378, 12, 221, 378, 12, 959, 12, 257, 413, 430, 199, 15185, 63, 396, 2801, 7555, 1398, 1046, 1797, 12, 221, 334, 1167, 2182, 12, 3144, 12, 7105, 12, 6546, 12, 8155, 12, 8155, 12, 841, 12, 28046, 430, 199, 199, 84, 17, 275, 900, 14, 521, 342, 199, 521, 14, 4532, 8, 18, 9, 199, 84, 18, 275, 900, 14, 521, 342, 199, 1361, 8, 2101, 8, 521, 14, 10406, 63, 3028, 8, 84, 17, 12, 307, 18, 9, 446, 18, 9, 2695, 413, 9, 199, 199, 84, 17, 275, 900, 14, 10406, 63, 706, 342, 199, 521, 14, 4532, 63, 706, 8, 1400, 9, 199, 84, 18, 275, 900, 14, 10406, 63, 706, 342, 199, 1361, 8, 2101, 8, 521, 14, 10406, 63, 3028, 8, 84, 17, 12, 307, 18, 7216, 5238, 9, 2695, 413, 9, 199, 199, 84, 17, 275, 900, 14, 10406, 63, 527, 342, 199, 521, 14, 4532, 63, 527, 8, 5279, 9, 199, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
txomon/pytest
testing/python/collect.py
1
53514
# -*- coding: utf-8 -*- import os import sys import textwrap import _pytest._code import pytest from _pytest.main import EXIT_NOTESTSCOLLECTED from _pytest.nodes import Collector from _pytest.warnings import SHOW_PYTEST_WARNINGS_ARG class TestModule(object): def test_failing_import(self, testdir): modcol = testdir.getmodulecol("import alksdjalskdjalkjals") pytest.raises(Collector.CollectError, modcol.collect) def test_import_duplicate(self, testdir): a = testdir.mkdir("a") b = testdir.mkdir("b") p = a.ensure("test_whatever.py") p.pyimport() del sys.modules["test_whatever"] b.ensure("test_whatever.py") result = testdir.runpytest() result.stdout.fnmatch_lines( [ "*import*mismatch*", "*imported*test_whatever*", "*%s*" % a.join("test_whatever.py"), "*not the same*", "*%s*" % b.join("test_whatever.py"), "*HINT*", ] ) def test_import_prepend_append(self, testdir, monkeypatch): syspath = list(sys.path) monkeypatch.setattr(sys, "path", syspath) root1 = testdir.mkdir("root1") root2 = testdir.mkdir("root2") root1.ensure("x456.py") root2.ensure("x456.py") p = root2.join("test_x456.py") monkeypatch.syspath_prepend(str(root1)) p.write( textwrap.dedent( """\ import x456 def test(): assert x456.__file__.startswith({!r}) """.format( str(root2) ) ) ) with root2.as_cwd(): reprec = testdir.inline_run("--import-mode=append") reprec.assertoutcome(passed=0, failed=1) reprec = testdir.inline_run() reprec.assertoutcome(passed=1) def test_syntax_error_in_module(self, testdir): modcol = testdir.getmodulecol("this is a syntax error") pytest.raises(modcol.CollectError, modcol.collect) pytest.raises(modcol.CollectError, modcol.collect) def test_module_considers_pluginmanager_at_import(self, testdir): modcol = testdir.getmodulecol("pytest_plugins='xasdlkj',") pytest.raises(ImportError, lambda: modcol.obj) def test_invalid_test_module_name(self, testdir): a = testdir.mkdir("a") a.ensure("test_one.part1.py") result = testdir.runpytest("-rw") result.stdout.fnmatch_lines( [ "ImportError while importing test module*test_one.part1*", "Hint: make sure your test modules/packages have valid Python names.", ] ) @pytest.mark.parametrize("verbose", [0, 1, 2]) def test_show_traceback_import_error(self, testdir, verbose): """Import errors when collecting modules should display the traceback (#1976). With low verbosity we omit pytest and internal modules, otherwise show all traceback entries. """ testdir.makepyfile( foo_traceback_import_error=""" from bar_traceback_import_error import NOT_AVAILABLE """, bar_traceback_import_error="", ) testdir.makepyfile( """ import foo_traceback_import_error """ ) args = ("-v",) * verbose result = testdir.runpytest(*args) result.stdout.fnmatch_lines( [ "ImportError while importing test module*", "Traceback:", "*from bar_traceback_import_error import NOT_AVAILABLE", "*cannot import name *NOT_AVAILABLE*", ] ) assert result.ret == 2 stdout = result.stdout.str() for name in ("_pytest", os.path.join("py", "_path")): if verbose == 2: assert name in stdout else: assert name not in stdout def test_show_traceback_import_error_unicode(self, testdir): """Check test modules collected which raise ImportError with unicode messages are handled properly (#2336). """ testdir.makepyfile( u""" # -*- coding: utf-8 -*- raise ImportError(u'Something bad happened ☺') """ ) result = testdir.runpytest() result.stdout.fnmatch_lines( [ "ImportError while importing test module*", "Traceback:", "*raise ImportError*Something bad happened*", ] ) assert result.ret == 2 class TestClass(object): def test_class_with_init_warning(self, testdir): testdir.makepyfile( """ class TestClass1(object): def __init__(self): pass """ ) result = testdir.runpytest("-rw") result.stdout.fnmatch_lines( [ "*cannot collect test class 'TestClass1' because it has a __init__ constructor" ] ) def test_class_subclassobject(self, testdir): testdir.getmodulecol( """ class test(object): pass """ ) result = testdir.runpytest() result.stdout.fnmatch_lines(["*collected 0*"]) def test_static_method(self, testdir): """Support for collecting staticmethod tests (#2528, #2699)""" testdir.getmodulecol( """ import pytest class Test(object): @staticmethod def test_something(): pass @pytest.fixture def fix(self): return 1 @staticmethod def test_fix(fix): assert fix == 1 """ ) result = testdir.runpytest() result.stdout.fnmatch_lines(["*collected 2 items*", "*2 passed in*"]) def test_setup_teardown_class_as_classmethod(self, testdir): testdir.makepyfile( test_mod1=""" class TestClassMethod(object): @classmethod def setup_class(cls): pass def test_1(self): pass @classmethod def teardown_class(cls): pass """ ) result = testdir.runpytest() result.stdout.fnmatch_lines(["*1 passed*"]) def test_issue1035_obj_has_getattr(self, testdir): modcol = testdir.getmodulecol( """ class Chameleon(object): def __getattr__(self, name): return True chameleon = Chameleon() """ ) colitems = modcol.collect() assert len(colitems) == 0 def test_issue1579_namedtuple(self, testdir): testdir.makepyfile( """ import collections TestCase = collections.namedtuple('TestCase', ['a']) """ ) result = testdir.runpytest("-rw") result.stdout.fnmatch_lines( "*cannot collect test class 'TestCase' " "because it has a __new__ constructor*" ) def test_issue2234_property(self, testdir): testdir.makepyfile( """ class TestCase(object): @property def prop(self): raise NotImplementedError() """ ) result = testdir.runpytest() assert result.ret == EXIT_NOTESTSCOLLECTED @pytest.mark.filterwarnings( "ignore:usage of Generator.Function is deprecated, please use pytest.Function instead" ) class TestGenerator(object): def test_generative_functions(self, testdir): modcol = testdir.getmodulecol( """ def func1(arg, arg2): assert arg == arg2 def test_gen(): yield func1, 17, 3*5 yield func1, 42, 6*7 """ ) colitems = modcol.collect() assert len(colitems) == 1 gencol = colitems[0] assert isinstance(gencol, pytest.Generator) gencolitems = gencol.collect() assert len(gencolitems) == 2 assert isinstance(gencolitems[0], pytest.Function) assert isinstance(gencolitems[1], pytest.Function) assert gencolitems[0].name == "[0]" assert gencolitems[0].obj.__name__ == "func1" def test_generative_methods(self, testdir): modcol = testdir.getmodulecol( """ def func1(arg, arg2): assert arg == arg2 class TestGenMethods(object): def test_gen(self): yield func1, 17, 3*5 yield func1, 42, 6*7 """ ) gencol = modcol.collect()[0].collect()[0].collect()[0] assert isinstance(gencol, pytest.Generator) gencolitems = gencol.collect() assert len(gencolitems) == 2 assert isinstance(gencolitems[0], pytest.Function) assert isinstance(gencolitems[1], pytest.Function) assert gencolitems[0].name == "[0]" assert gencolitems[0].obj.__name__ == "func1" def test_generative_functions_with_explicit_names(self, testdir): modcol = testdir.getmodulecol( """ def func1(arg, arg2): assert arg == arg2 def test_gen(): yield "seventeen", func1, 17, 3*5 yield "fortytwo", func1, 42, 6*7 """ ) colitems = modcol.collect() assert len(colitems) == 1 gencol = colitems[0] assert isinstance(gencol, pytest.Generator) gencolitems = gencol.collect() assert len(gencolitems) == 2 assert isinstance(gencolitems[0], pytest.Function) assert isinstance(gencolitems[1], pytest.Function) assert gencolitems[0].name == "['seventeen']" assert gencolitems[0].obj.__name__ == "func1" assert gencolitems[1].name == "['fortytwo']" assert gencolitems[1].obj.__name__ == "func1" def test_generative_functions_unique_explicit_names(self, testdir): # generative modcol = testdir.getmodulecol( """ def func(): pass def test_gen(): yield "name", func yield "name", func """ ) colitems = modcol.collect() assert len(colitems) == 1 gencol = colitems[0] assert isinstance(gencol, pytest.Generator) pytest.raises(ValueError, "gencol.collect()") def test_generative_methods_with_explicit_names(self, testdir): modcol = testdir.getmodulecol( """ def func1(arg, arg2): assert arg == arg2 class TestGenMethods(object): def test_gen(self): yield "m1", func1, 17, 3*5 yield "m2", func1, 42, 6*7 """ ) gencol = modcol.collect()[0].collect()[0].collect()[0] assert isinstance(gencol, pytest.Generator) gencolitems = gencol.collect() assert len(gencolitems) == 2 assert isinstance(gencolitems[0], pytest.Function) assert isinstance(gencolitems[1], pytest.Function) assert gencolitems[0].name == "['m1']" assert gencolitems[0].obj.__name__ == "func1" assert gencolitems[1].name == "['m2']" assert gencolitems[1].obj.__name__ == "func1" def test_order_of_execution_generator_same_codeline(self, testdir, tmpdir): o = testdir.makepyfile( """ from __future__ import print_function def test_generative_order_of_execution(): import py, pytest test_list = [] expected_list = list(range(6)) def list_append(item): test_list.append(item) def assert_order_of_execution(): print('expected order', expected_list) print('but got ', test_list) assert test_list == expected_list for i in expected_list: yield list_append, i yield assert_order_of_execution """ ) reprec = testdir.inline_run(o, SHOW_PYTEST_WARNINGS_ARG) passed, skipped, failed = reprec.countoutcomes() assert passed == 7 assert not skipped and not failed def test_order_of_execution_generator_different_codeline(self, testdir): o = testdir.makepyfile( """ from __future__ import print_function def test_generative_tests_different_codeline(): import py, pytest test_list = [] expected_list = list(range(3)) def list_append_2(): test_list.append(2) def list_append_1(): test_list.append(1) def list_append_0(): test_list.append(0) def assert_order_of_execution(): print('expected order', expected_list) print('but got ', test_list) assert test_list == expected_list yield list_append_0 yield list_append_1 yield list_append_2 yield assert_order_of_execution """ ) reprec = testdir.inline_run(o, SHOW_PYTEST_WARNINGS_ARG) passed, skipped, failed = reprec.countoutcomes() assert passed == 4 assert not skipped and not failed def test_setupstate_is_preserved_134(self, testdir): # yield-based tests are messy wrt to setupstate because # during collection they already invoke setup functions # and then again when they are run. For now, we want to make sure # that the old 1.3.4 behaviour is preserved such that all # yielded functions all share the same "self" instance that # has been used during collection. o = testdir.makepyfile( """ setuplist = [] class TestClass(object): def setup_method(self, func): #print "setup_method", self, func setuplist.append(self) self.init = 42 def teardown_method(self, func): self.init = None def test_func1(self): pass def test_func2(self): yield self.func2 yield self.func2 def func2(self): assert self.init def test_setuplist(): # once for test_func2 during collection # once for test_func1 during test run # once for test_func2 during test run #print setuplist assert len(setuplist) == 3, len(setuplist) assert setuplist[0] == setuplist[2], setuplist assert setuplist[1] != setuplist[2], setuplist """ ) reprec = testdir.inline_run(o, "-v", SHOW_PYTEST_WARNINGS_ARG) passed, skipped, failed = reprec.countoutcomes() assert passed == 4 assert not skipped and not failed class TestFunction(object): @pytest.fixture def ignore_parametrized_marks_args(self): """Provides arguments to pytester.runpytest() to ignore the warning about marks being applied directly to parameters. """ return ("-W", "ignore:Applying marks directly to parameters") def test_getmodulecollector(self, testdir): item = testdir.getitem("def test_func(): pass") modcol = item.getparent(pytest.Module) assert isinstance(modcol, pytest.Module) assert hasattr(modcol.obj, "test_func") @pytest.mark.filterwarnings("default") def test_function_as_object_instance_ignored(self, testdir): testdir.makepyfile( """ class A(object): def __call__(self, tmpdir): 0/0 test_a = A() """ ) result = testdir.runpytest() result.stdout.fnmatch_lines( [ "collected 0 items", "*test_function_as_object_instance_ignored.py:2: " "*cannot collect 'test_a' because it is not a function.", ] ) def test_function_equality(self, testdir, tmpdir): from _pytest.fixtures import FixtureManager config = testdir.parseconfigure() session = testdir.Session(config) session._fixturemanager = FixtureManager(session) def func1(): pass def func2(): pass f1 = pytest.Function( name="name", parent=session, config=config, args=(1,), callobj=func1 ) assert f1 == f1 f2 = pytest.Function(name="name", config=config, callobj=func2, parent=session) assert f1 != f2 def test_issue197_parametrize_emptyset(self, testdir): testdir.makepyfile( """ import pytest @pytest.mark.parametrize('arg', []) def test_function(arg): pass """ ) reprec = testdir.inline_run() reprec.assertoutcome(skipped=1) def test_single_tuple_unwraps_values(self, testdir): testdir.makepyfile( """ import pytest @pytest.mark.parametrize(('arg',), [(1,)]) def test_function(arg): assert arg == 1 """ ) reprec = testdir.inline_run() reprec.assertoutcome(passed=1) def test_issue213_parametrize_value_no_equal(self, testdir): testdir.makepyfile( """ import pytest class A(object): def __eq__(self, other): raise ValueError("not possible") @pytest.mark.parametrize('arg', [A()]) def test_function(arg): assert arg.__class__.__name__ == "A" """ ) reprec = testdir.inline_run("--fulltrace") reprec.assertoutcome(passed=1) def test_parametrize_with_non_hashable_values(self, testdir): """Test parametrization with non-hashable values.""" testdir.makepyfile( """ archival_mapping = { '1.0': {'tag': '1.0'}, '1.2.2a1': {'tag': 'release-1.2.2a1'}, } import pytest @pytest.mark.parametrize('key value'.split(), archival_mapping.items()) def test_archival_to_version(key, value): assert key in archival_mapping assert value == archival_mapping[key] """ ) rec = testdir.inline_run() rec.assertoutcome(passed=2) def test_parametrize_with_non_hashable_values_indirect(self, testdir): """Test parametrization with non-hashable values with indirect parametrization.""" testdir.makepyfile( """ archival_mapping = { '1.0': {'tag': '1.0'}, '1.2.2a1': {'tag': 'release-1.2.2a1'}, } import pytest @pytest.fixture def key(request): return request.param @pytest.fixture def value(request): return request.param @pytest.mark.parametrize('key value'.split(), archival_mapping.items(), indirect=True) def test_archival_to_version(key, value): assert key in archival_mapping assert value == archival_mapping[key] """ ) rec = testdir.inline_run() rec.assertoutcome(passed=2) def test_parametrize_overrides_fixture(self, testdir): """Test parametrization when parameter overrides existing fixture with same name.""" testdir.makepyfile( """ import pytest @pytest.fixture def value(): return 'value' @pytest.mark.parametrize('value', ['overridden']) def test_overridden_via_param(value): assert value == 'overridden' @pytest.mark.parametrize('somevalue', ['overridden']) def test_not_overridden(value, somevalue): assert value == 'value' assert somevalue == 'overridden' @pytest.mark.parametrize('other,value', [('foo', 'overridden')]) def test_overridden_via_multiparam(other, value): assert other == 'foo' assert value == 'overridden' """ ) rec = testdir.inline_run() rec.assertoutcome(passed=3) def test_parametrize_overrides_parametrized_fixture(self, testdir): """Test parametrization when parameter overrides existing parametrized fixture with same name.""" testdir.makepyfile( """ import pytest @pytest.fixture(params=[1, 2]) def value(request): return request.param @pytest.mark.parametrize('value', ['overridden']) def test_overridden_via_param(value): assert value == 'overridden' """ ) rec = testdir.inline_run() rec.assertoutcome(passed=1) def test_parametrize_overrides_indirect_dependency_fixture(self, testdir): """Test parametrization when parameter overrides a fixture that a test indirectly depends on""" testdir.makepyfile( """ import pytest fix3_instantiated = False @pytest.fixture def fix1(fix2): return fix2 + '1' @pytest.fixture def fix2(fix3): return fix3 + '2' @pytest.fixture def fix3(): global fix3_instantiated fix3_instantiated = True return '3' @pytest.mark.parametrize('fix2', ['2']) def test_it(fix1): assert fix1 == '21' assert not fix3_instantiated """ ) rec = testdir.inline_run() rec.assertoutcome(passed=1) @pytest.mark.filterwarnings("ignore:Applying marks directly to parameters") def test_parametrize_with_mark(self, testdir): items = testdir.getitems( """ import pytest @pytest.mark.foo @pytest.mark.parametrize('arg', [ 1, pytest.mark.bar(pytest.mark.baz(2)) ]) def test_function(arg): pass """ ) keywords = [item.keywords for item in items] assert ( "foo" in keywords[0] and "bar" not in keywords[0] and "baz" not in keywords[0] ) assert "foo" in keywords[1] and "bar" in keywords[1] and "baz" in keywords[1] def test_function_equality_with_callspec(self, testdir, tmpdir): items = testdir.getitems( """ import pytest @pytest.mark.parametrize('arg', [1,2]) def test_function(arg): pass """ ) assert items[0] != items[1] assert not (items[0] == items[1]) def test_pyfunc_call(self, testdir): item = testdir.getitem("def test_func(): raise ValueError") config = item.config class MyPlugin1(object): def pytest_pyfunc_call(self, pyfuncitem): raise ValueError class MyPlugin2(object): def pytest_pyfunc_call(self, pyfuncitem): return True config.pluginmanager.register(MyPlugin1()) config.pluginmanager.register(MyPlugin2()) config.hook.pytest_runtest_setup(item=item) config.hook.pytest_pyfunc_call(pyfuncitem=item) def test_multiple_parametrize(self, testdir): modcol = testdir.getmodulecol( """ import pytest @pytest.mark.parametrize('x', [0, 1]) @pytest.mark.parametrize('y', [2, 3]) def test1(x, y): pass """ ) colitems = modcol.collect() assert colitems[0].name == "test1[2-0]" assert colitems[1].name == "test1[2-1]" assert colitems[2].name == "test1[3-0]" assert colitems[3].name == "test1[3-1]" def test_issue751_multiple_parametrize_with_ids(self, testdir): modcol = testdir.getmodulecol( """ import pytest @pytest.mark.parametrize('x', [0], ids=['c']) @pytest.mark.parametrize('y', [0, 1], ids=['a', 'b']) class Test(object): def test1(self, x, y): pass def test2(self, x, y): pass """ ) colitems = modcol.collect()[0].collect()[0].collect() assert colitems[0].name == "test1[a-c]" assert colitems[1].name == "test1[b-c]" assert colitems[2].name == "test2[a-c]" assert colitems[3].name == "test2[b-c]" def test_parametrize_skipif(self, testdir, ignore_parametrized_marks_args): testdir.makepyfile( """ import pytest m = pytest.mark.skipif('True') @pytest.mark.parametrize('x', [0, 1, m(2)]) def test_skip_if(x): assert x < 2 """ ) result = testdir.runpytest(*ignore_parametrized_marks_args) result.stdout.fnmatch_lines("* 2 passed, 1 skipped in *") def test_parametrize_skip(self, testdir, ignore_parametrized_marks_args): testdir.makepyfile( """ import pytest m = pytest.mark.skip('') @pytest.mark.parametrize('x', [0, 1, m(2)]) def test_skip(x): assert x < 2 """ ) result = testdir.runpytest(*ignore_parametrized_marks_args) result.stdout.fnmatch_lines("* 2 passed, 1 skipped in *") def test_parametrize_skipif_no_skip(self, testdir, ignore_parametrized_marks_args): testdir.makepyfile( """ import pytest m = pytest.mark.skipif('False') @pytest.mark.parametrize('x', [0, 1, m(2)]) def test_skipif_no_skip(x): assert x < 2 """ ) result = testdir.runpytest(*ignore_parametrized_marks_args) result.stdout.fnmatch_lines("* 1 failed, 2 passed in *") def test_parametrize_xfail(self, testdir, ignore_parametrized_marks_args): testdir.makepyfile( """ import pytest m = pytest.mark.xfail('True') @pytest.mark.parametrize('x', [0, 1, m(2)]) def test_xfail(x): assert x < 2 """ ) result = testdir.runpytest(*ignore_parametrized_marks_args) result.stdout.fnmatch_lines("* 2 passed, 1 xfailed in *") def test_parametrize_passed(self, testdir, ignore_parametrized_marks_args): testdir.makepyfile( """ import pytest m = pytest.mark.xfail('True') @pytest.mark.parametrize('x', [0, 1, m(2)]) def test_xfail(x): pass """ ) result = testdir.runpytest(*ignore_parametrized_marks_args) result.stdout.fnmatch_lines("* 2 passed, 1 xpassed in *") def test_parametrize_xfail_passed(self, testdir, ignore_parametrized_marks_args): testdir.makepyfile( """ import pytest m = pytest.mark.xfail('False') @pytest.mark.parametrize('x', [0, 1, m(2)]) def test_passed(x): pass """ ) result = testdir.runpytest(*ignore_parametrized_marks_args) result.stdout.fnmatch_lines("* 3 passed in *") def test_function_original_name(self, testdir): items = testdir.getitems( """ import pytest @pytest.mark.parametrize('arg', [1,2]) def test_func(arg): pass """ ) assert [x.originalname for x in items] == ["test_func", "test_func"] class TestSorting(object): def test_check_equality(self, testdir): modcol = testdir.getmodulecol( """ def test_pass(): pass def test_fail(): assert 0 """ ) fn1 = testdir.collect_by_name(modcol, "test_pass") assert isinstance(fn1, pytest.Function) fn2 = testdir.collect_by_name(modcol, "test_pass") assert isinstance(fn2, pytest.Function) assert fn1 == fn2 assert fn1 != modcol if sys.version_info < (3, 0): assert cmp(fn1, fn2) == 0 # NOQA assert hash(fn1) == hash(fn2) fn3 = testdir.collect_by_name(modcol, "test_fail") assert isinstance(fn3, pytest.Function) assert not (fn1 == fn3) assert fn1 != fn3 for fn in fn1, fn2, fn3: assert fn != 3 assert fn != modcol assert fn != [1, 2, 3] assert [1, 2, 3] != fn assert modcol != fn def test_allow_sane_sorting_for_decorators(self, testdir): modcol = testdir.getmodulecol( """ def dec(f): g = lambda: f(2) g.place_as = f return g def test_b(y): pass test_b = dec(test_b) def test_a(y): pass test_a = dec(test_a) """ ) colitems = modcol.collect() assert len(colitems) == 2 assert [item.name for item in colitems] == ["test_b", "test_a"] class TestConftestCustomization(object): def test_pytest_pycollect_module(self, testdir): testdir.makeconftest( """ import pytest class MyModule(pytest.Module): pass def pytest_pycollect_makemodule(path, parent): if path.basename == "test_xyz.py": return MyModule(path, parent) """ ) testdir.makepyfile("def test_some(): pass") testdir.makepyfile(test_xyz="def test_func(): pass") result = testdir.runpytest("--collect-only") result.stdout.fnmatch_lines(["*<Module*test_pytest*", "*<MyModule*xyz*"]) def test_customized_pymakemodule_issue205_subdir(self, testdir): b = testdir.mkdir("a").mkdir("b") b.join("conftest.py").write( textwrap.dedent( """\ import pytest @pytest.hookimpl(hookwrapper=True) def pytest_pycollect_makemodule(): outcome = yield mod = outcome.get_result() mod.obj.hello = "world" """ ) ) b.join("test_module.py").write( textwrap.dedent( """\ def test_hello(): assert hello == "world" """ ) ) reprec = testdir.inline_run() reprec.assertoutcome(passed=1) def test_customized_pymakeitem(self, testdir): b = testdir.mkdir("a").mkdir("b") b.join("conftest.py").write( textwrap.dedent( """\ import pytest @pytest.hookimpl(hookwrapper=True) def pytest_pycollect_makeitem(): outcome = yield if outcome.excinfo is None: result = outcome.get_result() if result: for func in result: func._some123 = "world" """ ) ) b.join("test_module.py").write( textwrap.dedent( """\ import pytest @pytest.fixture() def obj(request): return request.node._some123 def test_hello(obj): assert obj == "world" """ ) ) reprec = testdir.inline_run() reprec.assertoutcome(passed=1) def test_pytest_pycollect_makeitem(self, testdir): testdir.makeconftest( """ import pytest class MyFunction(pytest.Function): pass def pytest_pycollect_makeitem(collector, name, obj): if name == "some": return MyFunction(name, collector) """ ) testdir.makepyfile("def some(): pass") result = testdir.runpytest("--collect-only") result.stdout.fnmatch_lines(["*MyFunction*some*"]) def test_makeitem_non_underscore(self, testdir, monkeypatch): modcol = testdir.getmodulecol("def _hello(): pass") values = [] monkeypatch.setattr( pytest.Module, "makeitem", lambda self, name, obj: values.append(name) ) values = modcol.collect() assert "_hello" not in values def test_issue2369_collect_module_fileext(self, testdir): """Ensure we can collect files with weird file extensions as Python modules (#2369)""" # We'll implement a little finder and loader to import files containing # Python source code whose file extension is ".narf". testdir.makeconftest( """ import sys, os, imp from _pytest.python import Module class Loader(object): def load_module(self, name): return imp.load_source(name, name + ".narf") class Finder(object): def find_module(self, name, path=None): if os.path.exists(name + ".narf"): return Loader() sys.meta_path.append(Finder()) def pytest_collect_file(path, parent): if path.ext == ".narf": return Module(path, parent)""" ) testdir.makefile( ".narf", """\ def test_something(): assert 1 + 1 == 2""", ) # Use runpytest_subprocess, since we're futzing with sys.meta_path. result = testdir.runpytest_subprocess() result.stdout.fnmatch_lines("*1 passed*") def test_setup_only_available_in_subdir(testdir): sub1 = testdir.mkpydir("sub1") sub2 = testdir.mkpydir("sub2") sub1.join("conftest.py").write( textwrap.dedent( """\ import pytest def pytest_runtest_setup(item): assert item.fspath.purebasename == "test_in_sub1" def pytest_runtest_call(item): assert item.fspath.purebasename == "test_in_sub1" def pytest_runtest_teardown(item): assert item.fspath.purebasename == "test_in_sub1" """ ) ) sub2.join("conftest.py").write( textwrap.dedent( """\ import pytest def pytest_runtest_setup(item): assert item.fspath.purebasename == "test_in_sub2" def pytest_runtest_call(item): assert item.fspath.purebasename == "test_in_sub2" def pytest_runtest_teardown(item): assert item.fspath.purebasename == "test_in_sub2" """ ) ) sub1.join("test_in_sub1.py").write("def test_1(): pass") sub2.join("test_in_sub2.py").write("def test_2(): pass") result = testdir.runpytest("-v", "-s") result.assert_outcomes(passed=2) def test_modulecol_roundtrip(testdir): modcol = testdir.getmodulecol("pass", withinit=False) trail = modcol.nodeid newcol = modcol.session.perform_collect([trail], genitems=0)[0] assert modcol.name == newcol.name class TestTracebackCutting(object): def test_skip_simple(self): excinfo = pytest.raises(pytest.skip.Exception, 'pytest.skip("xxx")') assert excinfo.traceback[-1].frame.code.name == "skip" assert excinfo.traceback[-1].ishidden() def test_traceback_argsetup(self, testdir): testdir.makeconftest( """ import pytest @pytest.fixture def hello(request): raise ValueError("xyz") """ ) p = testdir.makepyfile("def test(hello): pass") result = testdir.runpytest(p) assert result.ret != 0 out = result.stdout.str() assert "xyz" in out assert "conftest.py:5: ValueError" in out numentries = out.count("_ _ _") # separator for traceback entries assert numentries == 0 result = testdir.runpytest("--fulltrace", p) out = result.stdout.str() assert "conftest.py:5: ValueError" in out numentries = out.count("_ _ _ _") # separator for traceback entries assert numentries > 3 def test_traceback_error_during_import(self, testdir): testdir.makepyfile( """ x = 1 x = 2 x = 17 asd """ ) result = testdir.runpytest() assert result.ret != 0 out = result.stdout.str() assert "x = 1" not in out assert "x = 2" not in out result.stdout.fnmatch_lines([" *asd*", "E*NameError*"]) result = testdir.runpytest("--fulltrace") out = result.stdout.str() assert "x = 1" in out assert "x = 2" in out result.stdout.fnmatch_lines([">*asd*", "E*NameError*"]) def test_traceback_filter_error_during_fixture_collection(self, testdir): """integration test for issue #995. """ testdir.makepyfile( """ import pytest def fail_me(func): ns = {} exec('def w(): raise ValueError("fail me")', ns) return ns['w'] @pytest.fixture(scope='class') @fail_me def fail_fixture(): pass def test_failing_fixture(fail_fixture): pass """ ) result = testdir.runpytest() assert result.ret != 0 out = result.stdout.str() assert "INTERNALERROR>" not in out result.stdout.fnmatch_lines(["*ValueError: fail me*", "* 1 error in *"]) def test_filter_traceback_generated_code(self): """test that filter_traceback() works with the fact that py.code.Code.path attribute might return an str object. In this case, one of the entries on the traceback was produced by dynamically generated code. See: https://bitbucket.org/pytest-dev/py/issues/71 This fixes #995. """ from _pytest.python import filter_traceback try: ns = {} exec("def foo(): raise ValueError", ns) ns["foo"]() except ValueError: _, _, tb = sys.exc_info() tb = _pytest._code.Traceback(tb) assert isinstance(tb[-1].path, str) assert not filter_traceback(tb[-1]) def test_filter_traceback_path_no_longer_valid(self, testdir): """test that filter_traceback() works with the fact that py.code.Code.path attribute might return an str object. In this case, one of the files in the traceback no longer exists. This fixes #1133. """ from _pytest.python import filter_traceback testdir.syspathinsert() testdir.makepyfile( filter_traceback_entry_as_str=""" def foo(): raise ValueError """ ) try: import filter_traceback_entry_as_str filter_traceback_entry_as_str.foo() except ValueError: _, _, tb = sys.exc_info() testdir.tmpdir.join("filter_traceback_entry_as_str.py").remove() tb = _pytest._code.Traceback(tb) assert isinstance(tb[-1].path, str) assert filter_traceback(tb[-1]) class TestReportInfo(object): def test_itemreport_reportinfo(self, testdir, linecomp): testdir.makeconftest( """ import pytest class MyFunction(pytest.Function): def reportinfo(self): return "ABCDE", 42, "custom" def pytest_pycollect_makeitem(collector, name, obj): if name == "test_func": return MyFunction(name, parent=collector) """ ) item = testdir.getitem("def test_func(): pass") item.config.pluginmanager.getplugin("runner") assert item.location == ("ABCDE", 42, "custom") def test_func_reportinfo(self, testdir): item = testdir.getitem("def test_func(): pass") fspath, lineno, modpath = item.reportinfo() assert fspath == item.fspath assert lineno == 0 assert modpath == "test_func" def test_class_reportinfo(self, testdir): modcol = testdir.getmodulecol( """ # lineno 0 class TestClass(object): def test_hello(self): pass """ ) classcol = testdir.collect_by_name(modcol, "TestClass") fspath, lineno, msg = classcol.reportinfo() assert fspath == modcol.fspath assert lineno == 1 assert msg == "TestClass" @pytest.mark.filterwarnings( "ignore:usage of Generator.Function is deprecated, please use pytest.Function instead" ) def test_generator_reportinfo(self, testdir): modcol = testdir.getmodulecol( """ # lineno 0 def test_gen(): def check(x): assert x yield check, 3 """ ) gencol = testdir.collect_by_name(modcol, "test_gen") fspath, lineno, modpath = gencol.reportinfo() assert fspath == modcol.fspath assert lineno == 1 assert modpath == "test_gen" genitem = gencol.collect()[0] fspath, lineno, modpath = genitem.reportinfo() assert fspath == modcol.fspath assert lineno == 2 assert modpath == "test_gen[0]" """ def test_func(): pass def test_genfunc(): def check(x): pass yield check, 3 class TestClass(object): def test_method(self): pass """ def test_reportinfo_with_nasty_getattr(self, testdir): # https://github.com/pytest-dev/pytest/issues/1204 modcol = testdir.getmodulecol( """ # lineno 0 class TestClass(object): def __getattr__(self, name): return "this is not an int" def test_foo(self): pass """ ) classcol = testdir.collect_by_name(modcol, "TestClass") instance = classcol.collect()[0] fspath, lineno, msg = instance.reportinfo() def test_customized_python_discovery(testdir): testdir.makeini( """ [pytest] python_files=check_*.py python_classes=Check python_functions=check """ ) p = testdir.makepyfile( """ def check_simple(): pass class CheckMyApp(object): def check_meth(self): pass """ ) p2 = p.new(basename=p.basename.replace("test", "check")) p.move(p2) result = testdir.runpytest("--collect-only", "-s") result.stdout.fnmatch_lines( ["*check_customized*", "*check_simple*", "*CheckMyApp*", "*check_meth*"] ) result = testdir.runpytest() assert result.ret == 0 result.stdout.fnmatch_lines(["*2 passed*"]) def test_customized_python_discovery_functions(testdir): testdir.makeini( """ [pytest] python_functions=_test """ ) testdir.makepyfile( """ def _test_underscore(): pass """ ) result = testdir.runpytest("--collect-only", "-s") result.stdout.fnmatch_lines(["*_test_underscore*"]) result = testdir.runpytest() assert result.ret == 0 result.stdout.fnmatch_lines(["*1 passed*"]) def test_collector_attributes(testdir): testdir.makeconftest( """ import pytest def pytest_pycollect_makeitem(collector): assert collector.Function == pytest.Function assert collector.Class == pytest.Class assert collector.Instance == pytest.Instance assert collector.Module == pytest.Module """ ) testdir.makepyfile( """ def test_hello(): pass """ ) result = testdir.runpytest(SHOW_PYTEST_WARNINGS_ARG) result.stdout.fnmatch_lines(["*1 passed*"]) def test_customize_through_attributes(testdir): testdir.makeconftest( """ import pytest class MyFunction(pytest.Function): pass class MyInstance(pytest.Instance): Function = MyFunction class MyClass(pytest.Class): Instance = MyInstance def pytest_pycollect_makeitem(collector, name, obj): if name.startswith("MyTestClass"): return MyClass(name, parent=collector) """ ) testdir.makepyfile( """ class MyTestClass(object): def test_hello(self): pass """ ) result = testdir.runpytest("--collect-only", SHOW_PYTEST_WARNINGS_ARG) result.stdout.fnmatch_lines(["*MyClass*", "*MyFunction*test_hello*"]) def test_unorderable_types(testdir): testdir.makepyfile( """ class TestJoinEmpty(object): pass def make_test(): class Test(object): pass Test.__name__ = "TestFoo" return Test TestFoo = make_test() """ ) result = testdir.runpytest() assert "TypeError" not in result.stdout.str() assert result.ret == EXIT_NOTESTSCOLLECTED def test_collect_functools_partial(testdir): """ Test that collection of functools.partial object works, and arguments to the wrapped functions are dealt correctly (see #811). """ testdir.makepyfile( """ import functools import pytest @pytest.fixture def fix1(): return 'fix1' @pytest.fixture def fix2(): return 'fix2' def check1(i, fix1): assert i == 2 assert fix1 == 'fix1' def check2(fix1, i): assert i == 2 assert fix1 == 'fix1' def check3(fix1, i, fix2): assert i == 2 assert fix1 == 'fix1' assert fix2 == 'fix2' test_ok_1 = functools.partial(check1, i=2) test_ok_2 = functools.partial(check1, i=2, fix1='fix1') test_ok_3 = functools.partial(check1, 2) test_ok_4 = functools.partial(check2, i=2) test_ok_5 = functools.partial(check3, i=2) test_ok_6 = functools.partial(check3, i=2, fix1='fix1') test_fail_1 = functools.partial(check2, 2) test_fail_2 = functools.partial(check3, 2) """ ) result = testdir.inline_run() result.assertoutcome(passed=6, failed=2) @pytest.mark.filterwarnings("default") def test_dont_collect_non_function_callable(testdir): """Test for issue https://github.com/pytest-dev/pytest/issues/331 In this case an INTERNALERROR occurred trying to report the failure of a test like this one because py test failed to get the source lines. """ testdir.makepyfile( """ class Oh(object): def __call__(self): pass test_a = Oh() def test_real(): pass """ ) result = testdir.runpytest("-rw") result.stdout.fnmatch_lines( [ "*collected 1 item*", "*test_dont_collect_non_function_callable.py:2: *cannot collect 'test_a' because it is not a function*", "*1 passed, 1 warnings in *", ] ) def test_class_injection_does_not_break_collection(testdir): """Tests whether injection during collection time will terminate testing. In this case the error should not occur if the TestClass itself is modified during collection time, and the original method list is still used for collection. """ testdir.makeconftest( """ from test_inject import TestClass def pytest_generate_tests(metafunc): TestClass.changed_var = {} """ ) testdir.makepyfile( test_inject=''' class TestClass(object): def test_injection(self): """Test being parametrized.""" pass ''' ) result = testdir.runpytest() assert ( "RuntimeError: dictionary changed size during iteration" not in result.stdout.str() ) result.stdout.fnmatch_lines(["*1 passed*"]) def test_syntax_error_with_non_ascii_chars(testdir): """Fix decoding issue while formatting SyntaxErrors during collection (#578) """ testdir.makepyfile( u""" # -*- coding: UTF-8 -*- ☃ """ ) result = testdir.runpytest() result.stdout.fnmatch_lines(["*ERROR collecting*", "*SyntaxError*", "*1 error in*"]) def test_skip_duplicates_by_default(testdir): """Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609) Ignore duplicate directories. """ a = testdir.mkdir("a") fh = a.join("test_a.py") fh.write( textwrap.dedent( """\ import pytest def test_real(): pass """ ) ) result = testdir.runpytest(a.strpath, a.strpath) result.stdout.fnmatch_lines(["*collected 1 item*"]) def test_keep_duplicates(testdir): """Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609) Use --keep-duplicates to collect tests from duplicate directories. """ a = testdir.mkdir("a") fh = a.join("test_a.py") fh.write( textwrap.dedent( """\ import pytest def test_real(): pass """ ) ) result = testdir.runpytest("--keep-duplicates", a.strpath, a.strpath) result.stdout.fnmatch_lines(["*collected 2 item*"]) def test_package_collection_infinite_recursion(testdir): testdir.copy_example("collect/package_infinite_recursion") result = testdir.runpytest() result.stdout.fnmatch_lines("*1 passed*") def test_package_collection_init_given_as_argument(testdir): """Regression test for #3749""" p = testdir.copy_example("collect/package_init_given_as_arg") result = testdir.runpytest(p / "pkg" / "__init__.py") result.stdout.fnmatch_lines("*1 passed*") def test_package_with_modules(testdir): """ . └── root ├── __init__.py ├── sub1 │ ├── __init__.py │ └── sub1_1 │ ├── __init__.py │ └── test_in_sub1.py └── sub2 └── test └── test_in_sub2.py """ root = testdir.mkpydir("root") sub1 = root.mkdir("sub1") sub1.ensure("__init__.py") sub1_test = sub1.mkdir("sub1_1") sub1_test.ensure("__init__.py") sub2 = root.mkdir("sub2") sub2_test = sub2.mkdir("sub2") sub1_test.join("test_in_sub1.py").write("def test_1(): pass") sub2_test.join("test_in_sub2.py").write("def test_2(): pass") # Execute from . result = testdir.runpytest("-v", "-s") result.assert_outcomes(passed=2) # Execute from . with one argument "root" result = testdir.runpytest("-v", "-s", "root") result.assert_outcomes(passed=2) # Chdir into package's root and execute with no args root.chdir() result = testdir.runpytest("-v", "-s") result.assert_outcomes(passed=2) def test_package_ordering(testdir): """ . └── root ├── Test_root.py ├── __init__.py ├── sub1 │ ├── Test_sub1.py │ └── __init__.py └── sub2 └── test └── test_sub2.py """ testdir.makeini( """ [pytest] python_files=*.py """ ) root = testdir.mkpydir("root") sub1 = root.mkdir("sub1") sub1.ensure("__init__.py") sub2 = root.mkdir("sub2") sub2_test = sub2.mkdir("sub2") root.join("Test_root.py").write("def test_1(): pass") sub1.join("Test_sub1.py").write("def test_2(): pass") sub2_test.join("test_sub2.py").write("def test_3(): pass") # Execute from . result = testdir.runpytest("-v", "-s") result.assert_outcomes(passed=3)
mit
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 747, 199, 646, 984, 199, 646, 13390, 199, 199, 646, 485, 4462, 423, 600, 199, 646, 4613, 199, 504, 485, 4462, 14, 973, 492, 3651, 649, 63, 4609, 1719, 51, 23037, 1149, 199, 504, 485, 4462, 14, 2415, 492, 3626, 3283, 199, 504, 485, 4462, 14, 5451, 492, 428, 16210, 63, 4521, 2864, 63, 17449, 3881, 63, 11611, 421, 199, 533, 1379, 2377, 8, 785, 304, 272, 347, 511, 63, 25299, 63, 646, 8, 277, 12, 7368, 304, 267, 3413, 761, 275, 7368, 14, 362, 578, 761, 480, 646, 741, 75, 3893, 74, 279, 1339, 18256, 4878, 74, 2551, 531, 267, 4613, 14, 3536, 8, 12852, 14, 25023, 547, 12, 3413, 761, 14, 7112, 9, 339, 347, 511, 63, 646, 63, 11081, 8, 277, 12, 7368, 304, 267, 282, 275, 7368, 14, 8215, 480, 65, 531, 267, 330, 275, 7368, 14, 8215, 480, 66, 531, 267, 299, 275, 282, 14, 7505, 480, 396, 63, 26517, 14, 647, 531, 267, 299, 14, 647, 646, 342, 267, 2150, 984, 14, 3112, 905, 396, 63, 26517, 937, 267, 330, 14, 7505, 480, 396, 63, 26517, 14, 647, 531, 267, 754, 275, 7368, 14, 19889, 342, 267, 754, 14, 2703, 14, 15359, 63, 1278, 8, 288, 359, 355, 8969, 646, 10, 20759, 14421, 355, 8969, 17932, 10, 396, 63, 26517, 14421, 355, 8969, 5, 83, 12469, 450, 282, 14, 904, 480, 396, 63, 26517, 14, 647, 1288, 355, 8969, 1397, 314, 2011, 14421, 355, 8969, 5, 83, 12469, 450, 330, 14, 904, 480, 396, 63, 26517, 14, 647, 1288, 355, 8969, 32456, 14421, 288, 1622, 267, 776, 339, 347, 511, 63, 646, 63, 20637, 63, 740, 8, 277, 12, 7368, 12, 17309, 304, 267, 984, 515, 275, 769, 8, 1274, 14, 515, 9, 267, 17309, 14, 10202, 8, 1274, 12, 298, 515, 401, 984, 515, 9, 267, 1738, 17, 275, 7368, 14, 8215, 480, 1231, 17, 531, 267, 1738, 18, 275, 7368, 14, 8215, 480, 1231, 18, 531, 267, 1738, 17, 14, 7505, 480, 88, 11419, 14, 647, 531, 267, 1738, 18, 14, 7505, 480, 88, 11419, 14, 647, 531, 267, 299, 275, 1738, 18, 14, 904, 480, 396, 63, 88, 11419, 14, 647, 531, 267, 17309, 14, 1274, 515, 63, 20637, 8, 495, 8, 1231, 17, 430, 267, 299, 14, 952, 8, 288, 13390, 14, 14674, 8, 355, 9638, 355, 492, 671, 11419, 355, 347, 511, 837, 490, 702, 671, 11419, 855, 493, 4343, 2460, 2561, 1, 82, 1552, 355, 30512, 908, 8, 490, 620, 8, 1231, 18, 9, 355, 776, 288, 776, 267, 776, 267, 543, 1738, 18, 14, 305, 63, 6525, 837, 288, 22571, 275, 7368, 14, 6460, 63, 1065, 6739, 646, 13, 632, 29, 740, 531, 288, 22571, 14, 479, 17502, 8, 12070, 29, 16, 12, 3405, 29, 17, 9, 288, 22571, 275, 7368, 14, 6460, 63, 1065, 342, 288, 22571, 14, 479, 17502, 8, 12070, 29, 17, 9, 339, 347, 511, 63, 7093, 63, 705, 63, 262, 63, 578, 8, 277, 12, 7368, 304, 267, 3413, 761, 275, 7368, 14, 362, 578, 761, 480, 3749, 365, 282, 6302, 1125, 531, 267, 4613, 14, 3536, 8, 1494, 761, 14, 25023, 547, 12, 3413, 761, 14, 7112, 9, 267, 4613, 14, 3536, 8, 1494, 761, 14, 25023, 547, 12, 3413, 761, 14, 7112, 9, 339, 347, 511, 63, 578, 63, 388, 338, 7735, 63, 2718, 2609, 63, 292, 63, 646, 8, 277, 12, 7368, 304, 267, 3413, 761, 275, 7368, 14, 362, 578, 761, 480, 4462, 63, 5265, 534, 88, 305, 5030, 25775, 297, 531, 267, 4613, 14, 3536, 8, 17825, 12, 2400, 26, 3413, 761, 14, 1113, 9, 339, 347, 511, 63, 3197, 63, 396, 63, 578, 63, 354, 8, 277, 12, 7368, 304, 267, 282, 275, 7368, 14, 8215, 480, 65, 531, 267, 282, 14, 7505, 480, 396, 63, 368, 14, 2064, 17, 14, 647, 531, 267, 754, 275, 7368, 14, 19889, 6096, 13057, 531, 267, 754, 14, 2703, 14, 15359, 63, 1278, 8, 288, 359, 355, 298, 17825, 1830, 16306, 511, 859, 10, 396, 63, 368, 14, 2064, 17, 14421, 355, 298, 20891, 26, 1852, 3238, 2195, 511, 4621, 15, 5154, 1172, 1686, 2018, 1561, 4765, 288, 1622, 267, 776, 339, 768, 4462, 14, 1657, 14, 10396, 480, 3832, 401, 359, 16, 12, 413, 12, 499, 566, 272, 347, 511, 63, 2384, 63, 6894, 63, 646, 63, 705, 8, 277, 12, 7368, 12, 3376, 304, 267, 408, 6295, 2552, 1380, 32223, 4621, 1077, 2929, 314, 5190, 15196, 1167, 2114, 680, 398, 8777, 6465, 8661, 781, 19413, 4613, 436, 5007, 4621, 12, 4257, 2498, 1006, 5190, 4811, 14, 267, 408, 267, 7368, 14, 17358, 8, 288, 3925, 63, 6894, 63, 646, 63, 705, 11916, 2049, 687, 4681, 63, 6894, 63, 646, 63, 705, 492, 2845, 63, 17377, 1779, 10327, 288, 4681, 63, 6894, 63, 646, 63, 705, 8772, 267, 776, 267, 7368, 14, 17358, 8, 288, 408, 2049, 492, 3925, 63, 6894, 63, 646, 63, 705, 267, 408, 267, 776, 267, 1249, 275, 19372, 86, 26360, 627, 3376, 267, 754, 275, 7368, 14, 19889, 2031, 589, 9, 267, 754, 14, 2703, 14, 15359, 63, 1278, 8, 288, 359, 355, 298, 17825, 1830, 16306, 511, 859, 14421, 355, 298, 15905, 6783, 355, 8969, 504, 4681, 63, 6894, 63, 646, 63, 705, 492, 2845, 63, 17377, 401, 355, 8969, 11250, 492, 536, 627, 4609, 63, 17377, 14421, 288, 1622, 267, 776, 267, 702, 754, 14, 3292, 508, 499, 398, 3839, 275, 754, 14, 2703, 14, 495, 342, 267, 367, 536, 315, 1689, 63, 4462, 401, 747, 14, 515, 14, 904, 480, 647, 401, 2668, 515, 14150, 288, 340, 3376, 508, 499, 26, 355, 702, 536, 315, 3839, 288, 587, 26, 355, 702, 536, 440, 315, 3839, 339, 347, 511, 63, 2384, 63, 6894, 63, 646, 63, 705, 63, 2975, 8, 277, 12, 7368, 304, 267, 408, 1799, 511, 4621, 13736, 1314, 746, 3545, 543, 2649, 3788, 267, 787, 8860, 7684, 15196, 10034, 22, 680, 267, 408, 267, 7368, 14, 17358, 8, 288, 399, 624, 288, 327, 1882, 2803, 26, 2774, 13, 24, 1882, 288, 746, 3545, 8, 85, 7, 20641, 4875, 21056, 22410, 247, 119 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 646, 747, 199, 646, 984, 199, 646, 13390, 199, 199, 646, 485, 4462, 423, 600, 199, 646, 4613, 199, 504, 485, 4462, 14, 973, 492, 3651, 649, 63, 4609, 1719, 51, 23037, 1149, 199, 504, 485, 4462, 14, 2415, 492, 3626, 3283, 199, 504, 485, 4462, 14, 5451, 492, 428, 16210, 63, 4521, 2864, 63, 17449, 3881, 63, 11611, 421, 199, 533, 1379, 2377, 8, 785, 304, 272, 347, 511, 63, 25299, 63, 646, 8, 277, 12, 7368, 304, 267, 3413, 761, 275, 7368, 14, 362, 578, 761, 480, 646, 741, 75, 3893, 74, 279, 1339, 18256, 4878, 74, 2551, 531, 267, 4613, 14, 3536, 8, 12852, 14, 25023, 547, 12, 3413, 761, 14, 7112, 9, 339, 347, 511, 63, 646, 63, 11081, 8, 277, 12, 7368, 304, 267, 282, 275, 7368, 14, 8215, 480, 65, 531, 267, 330, 275, 7368, 14, 8215, 480, 66, 531, 267, 299, 275, 282, 14, 7505, 480, 396, 63, 26517, 14, 647, 531, 267, 299, 14, 647, 646, 342, 267, 2150, 984, 14, 3112, 905, 396, 63, 26517, 937, 267, 330, 14, 7505, 480, 396, 63, 26517, 14, 647, 531, 267, 754, 275, 7368, 14, 19889, 342, 267, 754, 14, 2703, 14, 15359, 63, 1278, 8, 288, 359, 355, 8969, 646, 10, 20759, 14421, 355, 8969, 17932, 10, 396, 63, 26517, 14421, 355, 8969, 5, 83, 12469, 450, 282, 14, 904, 480, 396, 63, 26517, 14, 647, 1288, 355, 8969, 1397, 314, 2011, 14421, 355, 8969, 5, 83, 12469, 450, 330, 14, 904, 480, 396, 63, 26517, 14, 647, 1288, 355, 8969, 32456, 14421, 288, 1622, 267, 776, 339, 347, 511, 63, 646, 63, 20637, 63, 740, 8, 277, 12, 7368, 12, 17309, 304, 267, 984, 515, 275, 769, 8, 1274, 14, 515, 9, 267, 17309, 14, 10202, 8, 1274, 12, 298, 515, 401, 984, 515, 9, 267, 1738, 17, 275, 7368, 14, 8215, 480, 1231, 17, 531, 267, 1738, 18, 275, 7368, 14, 8215, 480, 1231, 18, 531, 267, 1738, 17, 14, 7505, 480, 88, 11419, 14, 647, 531, 267, 1738, 18, 14, 7505, 480, 88, 11419, 14, 647, 531, 267, 299, 275, 1738, 18, 14, 904, 480, 396, 63, 88, 11419, 14, 647, 531, 267, 17309, 14, 1274, 515, 63, 20637, 8, 495, 8, 1231, 17, 430, 267, 299, 14, 952, 8, 288, 13390, 14, 14674, 8, 355, 9638, 355, 492, 671, 11419, 355, 347, 511, 837, 490, 702, 671, 11419, 855, 493, 4343, 2460, 2561, 1, 82, 1552, 355, 30512, 908, 8, 490, 620, 8, 1231, 18, 9, 355, 776, 288, 776, 267, 776, 267, 543, 1738, 18, 14, 305, 63, 6525, 837, 288, 22571, 275, 7368, 14, 6460, 63, 1065, 6739, 646, 13, 632, 29, 740, 531, 288, 22571, 14, 479, 17502, 8, 12070, 29, 16, 12, 3405, 29, 17, 9, 288, 22571, 275, 7368, 14, 6460, 63, 1065, 342, 288, 22571, 14, 479, 17502, 8, 12070, 29, 17, 9, 339, 347, 511, 63, 7093, 63, 705, 63, 262, 63, 578, 8, 277, 12, 7368, 304, 267, 3413, 761, 275, 7368, 14, 362, 578, 761, 480, 3749, 365, 282, 6302, 1125, 531, 267, 4613, 14, 3536, 8, 1494, 761, 14, 25023, 547, 12, 3413, 761, 14, 7112, 9, 267, 4613, 14, 3536, 8, 1494, 761, 14, 25023, 547, 12, 3413, 761, 14, 7112, 9, 339, 347, 511, 63, 578, 63, 388, 338, 7735, 63, 2718, 2609, 63, 292, 63, 646, 8, 277, 12, 7368, 304, 267, 3413, 761, 275, 7368, 14, 362, 578, 761, 480, 4462, 63, 5265, 534, 88, 305, 5030, 25775, 297, 531, 267, 4613, 14, 3536, 8, 17825, 12, 2400, 26, 3413, 761, 14, 1113, 9, 339, 347, 511, 63, 3197, 63, 396, 63, 578, 63, 354, 8, 277, 12, 7368, 304, 267, 282, 275, 7368, 14, 8215, 480, 65, 531, 267, 282, 14, 7505, 480, 396, 63, 368, 14, 2064, 17, 14, 647, 531, 267, 754, 275, 7368, 14, 19889, 6096, 13057, 531, 267, 754, 14, 2703, 14, 15359, 63, 1278, 8, 288, 359, 355, 298, 17825, 1830, 16306, 511, 859, 10, 396, 63, 368, 14, 2064, 17, 14421, 355, 298, 20891, 26, 1852, 3238, 2195, 511, 4621, 15, 5154, 1172, 1686, 2018, 1561, 4765, 288, 1622, 267, 776, 339, 768, 4462, 14, 1657, 14, 10396, 480, 3832, 401, 359, 16, 12, 413, 12, 499, 566, 272, 347, 511, 63, 2384, 63, 6894, 63, 646, 63, 705, 8, 277, 12, 7368, 12, 3376, 304, 267, 408, 6295, 2552, 1380, 32223, 4621, 1077, 2929, 314, 5190, 15196, 1167, 2114, 680, 398, 8777, 6465, 8661, 781, 19413, 4613, 436, 5007, 4621, 12, 4257, 2498, 1006, 5190, 4811, 14, 267, 408, 267, 7368, 14, 17358, 8, 288, 3925, 63, 6894, 63, 646, 63, 705, 11916, 2049, 687, 4681, 63, 6894, 63, 646, 63, 705, 492, 2845, 63, 17377, 1779, 10327, 288, 4681, 63, 6894, 63, 646, 63, 705, 8772, 267, 776, 267, 7368, 14, 17358, 8, 288, 408, 2049, 492, 3925, 63, 6894, 63, 646, 63, 705, 267, 408, 267, 776, 267, 1249, 275, 19372, 86, 26360, 627, 3376, 267, 754, 275, 7368, 14, 19889, 2031, 589, 9, 267, 754, 14, 2703, 14, 15359, 63, 1278, 8, 288, 359, 355, 298, 17825, 1830, 16306, 511, 859, 14421, 355, 298, 15905, 6783, 355, 8969, 504, 4681, 63, 6894, 63, 646, 63, 705, 492, 2845, 63, 17377, 401, 355, 8969, 11250, 492, 536, 627, 4609, 63, 17377, 14421, 288, 1622, 267, 776, 267, 702, 754, 14, 3292, 508, 499, 398, 3839, 275, 754, 14, 2703, 14, 495, 342, 267, 367, 536, 315, 1689, 63, 4462, 401, 747, 14, 515, 14, 904, 480, 647, 401, 2668, 515, 14150, 288, 340, 3376, 508, 499, 26, 355, 702, 536, 315, 3839, 288, 587, 26, 355, 702, 536, 440, 315, 3839, 339, 347, 511, 63, 2384, 63, 6894, 63, 646, 63, 705, 63, 2975, 8, 277, 12, 7368, 304, 267, 408, 1799, 511, 4621, 13736, 1314, 746, 3545, 543, 2649, 3788, 267, 787, 8860, 7684, 15196, 10034, 22, 680, 267, 408, 267, 7368, 14, 17358, 8, 288, 399, 624, 288, 327, 1882, 2803, 26, 2774, 13, 24, 1882, 288, 746, 3545, 8, 85, 7, 20641, 4875, 21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1, 1, 1, 1, 1, 1, 1 ]
nhomar/odoo-mirror
addons/base_report_designer/plugin/openerp_report_designer/bin/script/About.py
293
3815
######################################################################### # # Copyright (c) 2003-2004 Danny Brewer d29583@groovegarden.com # Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>). # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # See: http://www.gnu.org/licenses/lgpl.html # ############################################################################# import uno from com.sun.star.task import XJobExecutor if __name__<>'package': from lib.gui import * class About(unohelper.Base, XJobExecutor): def __init__(self, ctx): self.ctx = ctx self.module = "openerp_report" self.version = "0.1" self.win = DBModalDialog(60, 50, 175, 115, "About Odoo Report Designer") fdBigFont = createUnoStruct("com.sun.star.awt.FontDescriptor") fdBigFont.Width = 20 fdBigFont.Height = 25 fdBigFont.Weight = 120 fdBigFont.Family= 3 oLabelTitle1 = self.win.addFixedText("lblTitle1", 1, 1, 35, 30) oLabelTitle1.Model.TextColor = 16056320 oLabelTitle1.Model.FontDescriptor = fdBigFont oLabelTitle1.Model.FontRelief = 1 oLabelTitle1.Text = "Open" oLabelTitle2 = self.win.addFixedText("lblTitle2", 35, 1, 30, 30) oLabelTitle2.Model.TextColor = 1 oLabelTitle2.Model.FontDescriptor = fdBigFont oLabelTitle2.Model.FontRelief = 1 oLabelTitle2.Text = "ERP" oLabelProdDesc = self.win.addFixedText("lblProdDesc", 1, 30, 173, 75) oLabelProdDesc.Model.TextColor = 1 fdBigFont.Width = 10 fdBigFont.Height = 11 fdBigFont.Weight = 76 oLabelProdDesc.Model.FontDescriptor = fdBigFont oLabelProdDesc.Model.Align = 1 oLabelProdDesc.Model.FontRelief = 1 oLabelProdDesc.Model.MultiLine = True oLabelProdDesc.Text = "This package helps you to create or modify\nreports in Odoo. Once connected to the\nserver, you can design your template of reports\nusing fields and expressions and browsing the\ncomplete structure of Odoo object database." oLabelFooter = self.win.addFixedText("lblFooter", -1, -1, 173, 25) oLabelFooter.Model.TextColor = 255 #oLabelFooter.Model.BackgroundColor = 1 oLabelFooter.Model.Border = 2 oLabelFooter.Model.BorderColor = 255 fdBigFont.Width = 8 fdBigFont.Height = 9 fdBigFont.Weight = 100 oLabelFooter.Model.FontDescriptor = fdBigFont oLabelFooter.Model.Align = 1 oLabelFooter.Model.FontRelief = 1 oLabelFooter.Model.MultiLine = True sMessage = "Odoo Report Designer v1.0 \nCopyright 2007-TODAY Tiny sprl \nThis product is free software, under the GNU Affero General Public License." oLabelFooter.Text = sMessage self.win.doModalDialog("",None) if __name__<>"package" and __name__=="__main__": About(None) elif __name__=="package": g_ImplementationHelper.addImplementation( About, "org.openoffice.openerp.report.about", ("com.sun.star.task.Job",),) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3949, 3, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 13004, 13, 15431, 577, 1189, 89, 699, 264, 2135, 366, 1398, 16793, 32, 23260, 79, 432, 23909, 848, 14, 957, 199, 3, 221, 1898, 334, 35, 9, 8353, 13, 6542, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 10121, 199, 3, 199, 3, 221, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 221, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 221, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 221, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 221, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 221, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 3, 199, 3, 221, 1666, 26, 221, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 199, 3, 199, 31635, 199, 199, 646, 625, 79, 199, 504, 2414, 14, 11846, 14, 7848, 14, 1765, 492, 1323, 6694, 16752, 199, 199, 692, 636, 354, 363, 28, 3524, 2491, 356, 272, 687, 1973, 14, 5885, 492, 627, 199, 199, 533, 25225, 8, 324, 79, 3676, 14, 1563, 12, 1323, 6694, 16752, 304, 272, 347, 636, 826, 721, 277, 12, 4027, 304, 267, 291, 14, 3799, 258, 275, 4027, 267, 291, 14, 578, 221, 275, 298, 11267, 63, 3070, 2, 267, 291, 14, 1023, 275, 298, 16, 14, 17, 2, 267, 291, 14, 2676, 275, 6249, 23689, 5619, 8, 2259, 12, 5238, 12, 27306, 12, 22560, 12, 298, 18816, 28935, 11774, 1487, 25399, 531, 398, 6111, 7279, 6986, 275, 1218, 53, 889, 4836, 480, 957, 14, 11846, 14, 7848, 14, 65, 9115, 14, 6986, 4311, 531, 267, 6111, 7279, 6986, 14, 6216, 275, 3388, 267, 6111, 7279, 6986, 14, 8436, 275, 5661, 267, 6111, 7279, 6986, 14, 16359, 275, 13960, 267, 6111, 7279, 6986, 14, 16345, 29, 650, 398, 312, 4314, 6888, 17, 275, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 6888, 17, 401, 413, 12, 413, 12, 8685, 12, 4233, 9, 267, 312, 4314, 6888, 17, 14, 1685, 14, 1872, 4117, 275, 21235, 1367, 12122, 267, 312, 4314, 6888, 17, 14, 1685, 14, 6986, 4311, 275, 6111, 7279, 6986, 267, 312, 4314, 6888, 17, 14, 1685, 14, 6986, 497, 317, 2829, 275, 413, 267, 312, 4314, 6888, 17, 14, 1872, 275, 298, 4299, 2, 398, 312, 4314, 6888, 18, 275, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 6888, 18, 401, 8685, 12, 413, 12, 4233, 12, 4233, 9, 267, 312, 4314, 6888, 18, 14, 1685, 14, 1872, 4117, 275, 413, 267, 312, 4314, 6888, 18, 14, 1685, 14, 6986, 4311, 275, 6111, 7279, 6986, 267, 312, 4314, 6888, 18, 14, 1685, 14, 6986, 497, 317, 2829, 275, 413, 267, 312, 4314, 6888, 18, 14, 1872, 275, 298, 6758, 2, 398, 312, 4314, 30966, 9921, 275, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 30966, 9921, 401, 413, 12, 4233, 12, 413, 2898, 12, 13098, 9, 267, 312, 4314, 30966, 9921, 14, 1685, 14, 1872, 4117, 275, 413, 267, 6111, 7279, 6986, 14, 6216, 275, 1616, 267, 6111, 7279, 6986, 14, 8436, 275, 4119, 267, 6111, 7279, 6986, 14, 16359, 275, 14646, 267, 312, 4314, 30966, 9921, 14, 1685, 14, 6986, 4311, 275, 6111, 7279, 6986, 267, 312, 4314, 30966, 9921, 14, 1685, 14, 9497, 275, 413, 267, 312, 4314, 30966, 9921, 14, 1685, 14, 6986, 497, 317, 2829, 275, 413, 267, 312, 4314, 30966, 9921, 14, 1685, 14, 3947, 3049, 275, 715, 267, 312, 4314, 30966, 9921, 14, 1872, 275, 298, 2765, 221, 2559, 221, 22577, 221, 1265, 221, 370, 221, 1218, 221, 503, 221, 2811, 60, 78, 15629, 221, 315, 221, 28935, 14, 221, 19468, 221, 8539, 221, 370, 221, 314, 60, 78, 1000, 12, 1265, 883, 12899, 2195, 1978, 402, 13924, 60, 78, 4941, 1504, 221, 436, 8455, 221, 436, 221, 330, 1143, 1044, 314, 60, 78, 4883, 5523, 402, 28935, 909, 3050, 2122, 398, 312, 4314, 5686, 351, 275, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 5686, 351, 401, 446, 17, 12, 446, 17, 12, 413, 2898, 12, 5661, 9, 267, 312, 4314, 5686, 351, 14, 1685, 14, 1872, 4117, 275, 5450, 267, 327, 79, 4314, 5686, 351, 14, 1685, 14, 14148, 4117, 275, 413, 267, 312, 4314, 5686, 351, 14, 1685, 14, 22590, 275, 499, 267, 312, 4314, 5686, 351, 14, 1685, 14, 22590, 4117, 275, 5450, 267, 6111, 7279, 6986, 14, 6216, 275, 1695, 267, 6111, 7279, 6986, 14, 8436, 275, 1749, 267, 6111, 7279, 6986, 14, 16359, 275, 2948, 267, 312, 4314, 5686, 351, 14, 1685, 14, 6986, 4311, 275, 6111, 7279, 6986, 267, 312, 4314, 5686, 351, 14, 1685, 14, 9497, 275, 413, 267, 312, 4314, 5686, 351, 14, 1685, 14, 6986, 497, 317, 2829, 275, 413, 267, 312, 4314, 5686, 351, 14, 1685, 14, 3947, 3049, 275, 715, 267, 308, 2209, 275, 298, 47, 16766, 11774, 1487, 25399, 373, 17, 14, 16, 971, 78, 7384, 10219, 13, 2566, 11655, 11947, 2249, 4308, 971, 78, 2765, 3336, 365, 2867, 2032, 12, 1334, 314, 1664, 4265, 1696, 1684, 844, 2122, 267, 312, 4314, 5686, 351, 14, 1872, 275, 308, 2209, 398, 291, 14, 2676, 14, 1117, 23689, 5619, 12398, 403, 9, 199, 199, 692, 636, 354, 363, 28, 4335, 2491, 2, 436, 636, 354, 363, 11800, 363, 973, 5727, 272, 25225, 8, 403, 9, 199, 4164, 636, 354, 363, 11800, 2491, 582, 272, 486, 63, 7921, 4433, 14, 525, 7921, 8, 25225, 12, 298, 1308, 14 ]
[ 3, 199, 3, 199, 3, 221, 1898, 334, 67, 9, 13004, 13, 15431, 577, 1189, 89, 699, 264, 2135, 366, 1398, 16793, 32, 23260, 79, 432, 23909, 848, 14, 957, 199, 3, 221, 1898, 334, 35, 9, 8353, 13, 6542, 7653, 13950, 8642, 1014, 921, 11267, 14, 957, 10121, 199, 3, 199, 3, 221, 961, 3555, 365, 2867, 2032, 27, 1265, 883, 3604, 652, 436, 15, 269, 199, 3, 221, 2811, 652, 1334, 314, 2895, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 221, 844, 465, 3267, 701, 314, 2868, 2290, 2752, 27, 1902, 199, 3, 221, 1015, 499, 14, 17, 402, 314, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 221, 961, 3555, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 221, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 221, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 1664, 199, 3, 221, 6401, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 221, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 6401, 1696, 1684, 199, 3, 221, 844, 3180, 543, 642, 3555, 27, 340, 440, 12, 2218, 370, 314, 2868, 2290, 199, 3, 221, 2752, 12, 3277, 2020, 8026, 11236, 14259, 12, 12066, 11844, 12, 8226, 12, 4828, 221, 11315, 13, 10067, 221, 8217, 199, 3, 199, 3, 221, 1666, 26, 221, 1455, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 9783, 1168, 14, 1360, 199, 3, 199, 31635, 199, 199, 646, 625, 79, 199, 504, 2414, 14, 11846, 14, 7848, 14, 1765, 492, 1323, 6694, 16752, 199, 199, 692, 636, 354, 363, 28, 3524, 2491, 356, 272, 687, 1973, 14, 5885, 492, 627, 199, 199, 533, 25225, 8, 324, 79, 3676, 14, 1563, 12, 1323, 6694, 16752, 304, 272, 347, 636, 826, 721, 277, 12, 4027, 304, 267, 291, 14, 3799, 258, 275, 4027, 267, 291, 14, 578, 221, 275, 298, 11267, 63, 3070, 2, 267, 291, 14, 1023, 275, 298, 16, 14, 17, 2, 267, 291, 14, 2676, 275, 6249, 23689, 5619, 8, 2259, 12, 5238, 12, 27306, 12, 22560, 12, 298, 18816, 28935, 11774, 1487, 25399, 531, 398, 6111, 7279, 6986, 275, 1218, 53, 889, 4836, 480, 957, 14, 11846, 14, 7848, 14, 65, 9115, 14, 6986, 4311, 531, 267, 6111, 7279, 6986, 14, 6216, 275, 3388, 267, 6111, 7279, 6986, 14, 8436, 275, 5661, 267, 6111, 7279, 6986, 14, 16359, 275, 13960, 267, 6111, 7279, 6986, 14, 16345, 29, 650, 398, 312, 4314, 6888, 17, 275, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 6888, 17, 401, 413, 12, 413, 12, 8685, 12, 4233, 9, 267, 312, 4314, 6888, 17, 14, 1685, 14, 1872, 4117, 275, 21235, 1367, 12122, 267, 312, 4314, 6888, 17, 14, 1685, 14, 6986, 4311, 275, 6111, 7279, 6986, 267, 312, 4314, 6888, 17, 14, 1685, 14, 6986, 497, 317, 2829, 275, 413, 267, 312, 4314, 6888, 17, 14, 1872, 275, 298, 4299, 2, 398, 312, 4314, 6888, 18, 275, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 6888, 18, 401, 8685, 12, 413, 12, 4233, 12, 4233, 9, 267, 312, 4314, 6888, 18, 14, 1685, 14, 1872, 4117, 275, 413, 267, 312, 4314, 6888, 18, 14, 1685, 14, 6986, 4311, 275, 6111, 7279, 6986, 267, 312, 4314, 6888, 18, 14, 1685, 14, 6986, 497, 317, 2829, 275, 413, 267, 312, 4314, 6888, 18, 14, 1872, 275, 298, 6758, 2, 398, 312, 4314, 30966, 9921, 275, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 30966, 9921, 401, 413, 12, 4233, 12, 413, 2898, 12, 13098, 9, 267, 312, 4314, 30966, 9921, 14, 1685, 14, 1872, 4117, 275, 413, 267, 6111, 7279, 6986, 14, 6216, 275, 1616, 267, 6111, 7279, 6986, 14, 8436, 275, 4119, 267, 6111, 7279, 6986, 14, 16359, 275, 14646, 267, 312, 4314, 30966, 9921, 14, 1685, 14, 6986, 4311, 275, 6111, 7279, 6986, 267, 312, 4314, 30966, 9921, 14, 1685, 14, 9497, 275, 413, 267, 312, 4314, 30966, 9921, 14, 1685, 14, 6986, 497, 317, 2829, 275, 413, 267, 312, 4314, 30966, 9921, 14, 1685, 14, 3947, 3049, 275, 715, 267, 312, 4314, 30966, 9921, 14, 1872, 275, 298, 2765, 221, 2559, 221, 22577, 221, 1265, 221, 370, 221, 1218, 221, 503, 221, 2811, 60, 78, 15629, 221, 315, 221, 28935, 14, 221, 19468, 221, 8539, 221, 370, 221, 314, 60, 78, 1000, 12, 1265, 883, 12899, 2195, 1978, 402, 13924, 60, 78, 4941, 1504, 221, 436, 8455, 221, 436, 221, 330, 1143, 1044, 314, 60, 78, 4883, 5523, 402, 28935, 909, 3050, 2122, 398, 312, 4314, 5686, 351, 275, 291, 14, 2676, 14, 525, 9515, 1872, 480, 18842, 5686, 351, 401, 446, 17, 12, 446, 17, 12, 413, 2898, 12, 5661, 9, 267, 312, 4314, 5686, 351, 14, 1685, 14, 1872, 4117, 275, 5450, 267, 327, 79, 4314, 5686, 351, 14, 1685, 14, 14148, 4117, 275, 413, 267, 312, 4314, 5686, 351, 14, 1685, 14, 22590, 275, 499, 267, 312, 4314, 5686, 351, 14, 1685, 14, 22590, 4117, 275, 5450, 267, 6111, 7279, 6986, 14, 6216, 275, 1695, 267, 6111, 7279, 6986, 14, 8436, 275, 1749, 267, 6111, 7279, 6986, 14, 16359, 275, 2948, 267, 312, 4314, 5686, 351, 14, 1685, 14, 6986, 4311, 275, 6111, 7279, 6986, 267, 312, 4314, 5686, 351, 14, 1685, 14, 9497, 275, 413, 267, 312, 4314, 5686, 351, 14, 1685, 14, 6986, 497, 317, 2829, 275, 413, 267, 312, 4314, 5686, 351, 14, 1685, 14, 3947, 3049, 275, 715, 267, 308, 2209, 275, 298, 47, 16766, 11774, 1487, 25399, 373, 17, 14, 16, 971, 78, 7384, 10219, 13, 2566, 11655, 11947, 2249, 4308, 971, 78, 2765, 3336, 365, 2867, 2032, 12, 1334, 314, 1664, 4265, 1696, 1684, 844, 2122, 267, 312, 4314, 5686, 351, 14, 1872, 275, 308, 2209, 398, 291, 14, 2676, 14, 1117, 23689, 5619, 12398, 403, 9, 199, 199, 692, 636, 354, 363, 28, 4335, 2491, 2, 436, 636, 354, 363, 11800, 363, 973, 5727, 272, 25225, 8, 403, 9, 199, 4164, 636, 354, 363, 11800, 2491, 582, 272, 486, 63, 7921, 4433, 14, 525, 7921, 8, 25225, 12, 298, 1308, 14, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
axbaretto/beam
sdks/python/apache_beam/io/gcp/datastore/v1/datastoreio_test.py
1
12457
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # pytype: skip-file from __future__ import absolute_import from __future__ import division from __future__ import print_function import sys import unittest from builtins import map from builtins import range from builtins import zip from mock import MagicMock from mock import call from mock import patch # Protect against environments where datastore library is not available. # pylint: disable=wrong-import-order, wrong-import-position, ungrouped-imports try: from google.cloud.proto.datastore.v1 import datastore_pb2 from apache_beam.io.gcp.datastore.v1 import fake_datastore from apache_beam.io.gcp.datastore.v1 import helper from google.cloud.proto.datastore.v1 import query_pb2 from apache_beam.io.gcp.datastore.v1 import query_splitter from apache_beam.io.gcp.datastore.v1 import util from apache_beam.io.gcp.datastore.v1.datastoreio import ReadFromDatastore from apache_beam.io.gcp.datastore.v1.datastoreio import WriteToDatastore from apache_beam.io.gcp.datastore.v1.datastoreio import _Mutate from google.protobuf import timestamp_pb2 from googledatastore import helper as datastore_helper except (ImportError, TypeError): datastore_pb2 = None # pylint: enable=wrong-import-order, wrong-import-position, ungrouped-imports class DatastoreioTest(unittest.TestCase): _PROJECT = 'project' _KIND = 'kind' _NAMESPACE = 'namespace' @unittest.skipIf( sys.version_info[0] == 3, 'v1/datastoreio does not support Python 3 TODO: BEAM-4543') @unittest.skipIf(datastore_pb2 is None, 'GCP dependencies are not installed') def setUp(self): self._mock_datastore = MagicMock() self._query = query_pb2.Query() self._query.kind.add().name = self._KIND self._WRITE_BATCH_INITIAL_SIZE = util.WRITE_BATCH_INITIAL_SIZE def get_timestamp(self): return timestamp_pb2.Timestamp(seconds=1234) def test_get_estimated_size_bytes_without_namespace(self): entity_bytes = 100 timestamp = self.get_timestamp() self.check_estimated_size_bytes(entity_bytes, timestamp) def test_get_estimated_size_bytes_with_namespace(self): entity_bytes = 100 timestamp = self.get_timestamp() self.check_estimated_size_bytes(entity_bytes, timestamp, self._NAMESPACE) def test_SplitQueryFn_with_num_splits(self): with patch.object(helper, 'get_datastore', return_value=self._mock_datastore): num_splits = 23 def fake_get_splits(datastore, query, num_splits, partition=None): return self.split_query(query, num_splits) with patch.object(query_splitter, 'get_splits', side_effect=fake_get_splits): split_query_fn = ReadFromDatastore.SplitQueryFn( self._PROJECT, self._query, None, num_splits) split_query_fn.start_bundle() returned_split_queries = [] for split_query in split_query_fn.process(self._query): returned_split_queries.append(split_query) self.assertEqual(len(returned_split_queries), num_splits) self.assertEqual(0, len(self._mock_datastore.run_query.call_args_list)) self.verify_unique_keys(returned_split_queries) def test_SplitQueryFn_without_num_splits(self): with patch.object(helper, 'get_datastore', return_value=self._mock_datastore): # Force SplitQueryFn to compute the number of query splits num_splits = 0 expected_num_splits = 23 entity_bytes = ( expected_num_splits * ReadFromDatastore._DEFAULT_BUNDLE_SIZE_BYTES) with patch.object(ReadFromDatastore, 'get_estimated_size_bytes', return_value=entity_bytes): def fake_get_splits(datastore, query, num_splits, partition=None): return self.split_query(query, num_splits) with patch.object(query_splitter, 'get_splits', side_effect=fake_get_splits): split_query_fn = ReadFromDatastore.SplitQueryFn( self._PROJECT, self._query, None, num_splits) split_query_fn.start_bundle() returned_split_queries = [] for split_query in split_query_fn.process(self._query): returned_split_queries.append(split_query) self.assertEqual(len(returned_split_queries), expected_num_splits) self.assertEqual( 0, len(self._mock_datastore.run_query.call_args_list)) self.verify_unique_keys(returned_split_queries) def test_SplitQueryFn_with_query_limit(self): """A test that verifies no split is performed when the query has a limit.""" with patch.object(helper, 'get_datastore', return_value=self._mock_datastore): self._query.limit.value = 3 split_query_fn = ReadFromDatastore.SplitQueryFn( self._PROJECT, self._query, None, 4) split_query_fn.start_bundle() returned_split_queries = [] for split_query in split_query_fn.process(self._query): returned_split_queries.append(split_query) self.assertEqual(1, len(returned_split_queries)) self.assertEqual(0, len(self._mock_datastore.method_calls)) def test_SplitQueryFn_with_exception(self): """A test that verifies that no split is performed when failures occur.""" with patch.object(helper, 'get_datastore', return_value=self._mock_datastore): # Force SplitQueryFn to compute the number of query splits num_splits = 0 expected_num_splits = 1 entity_bytes = ( expected_num_splits * ReadFromDatastore._DEFAULT_BUNDLE_SIZE_BYTES) with patch.object(ReadFromDatastore, 'get_estimated_size_bytes', return_value=entity_bytes): with patch.object(query_splitter, 'get_splits', side_effect=ValueError("Testing query split error")): split_query_fn = ReadFromDatastore.SplitQueryFn( self._PROJECT, self._query, None, num_splits) split_query_fn.start_bundle() returned_split_queries = [] for split_query in split_query_fn.process(self._query): returned_split_queries.append(split_query) self.assertEqual(len(returned_split_queries), expected_num_splits) self.assertEqual(returned_split_queries[0][1], self._query) self.assertEqual( 0, len(self._mock_datastore.run_query.call_args_list)) self.verify_unique_keys(returned_split_queries) def test_DatastoreWriteFn_with_empty_batch(self): self.check_DatastoreWriteFn(0) def test_DatastoreWriteFn_with_one_batch(self): num_entities_to_write = self._WRITE_BATCH_INITIAL_SIZE * 1 - 50 self.check_DatastoreWriteFn(num_entities_to_write) def test_DatastoreWriteFn_with_multiple_batches(self): num_entities_to_write = self._WRITE_BATCH_INITIAL_SIZE * 3 + 50 self.check_DatastoreWriteFn(num_entities_to_write) def test_DatastoreWriteFn_with_batch_size_exact_multiple(self): num_entities_to_write = self._WRITE_BATCH_INITIAL_SIZE * 2 self.check_DatastoreWriteFn(num_entities_to_write) def test_DatastoreWriteFn_with_dynamic_batch_sizes(self): num_entities_to_write = self._WRITE_BATCH_INITIAL_SIZE * 3 + 50 self.check_DatastoreWriteFn( num_entities_to_write, use_fixed_batch_size=False) def check_DatastoreWriteFn(self, num_entities, use_fixed_batch_size=True): """A helper function to test DatastoreWriteFn.""" with patch.object(helper, 'get_datastore', return_value=self._mock_datastore): entities = [ e.entity for e in fake_datastore.create_entities(num_entities) ] expected_mutations = list( map(WriteToDatastore.to_upsert_mutation, entities)) actual_mutations = [] self._mock_datastore.commit.side_effect = ( fake_datastore.create_commit(actual_mutations)) fixed_batch_size = None if use_fixed_batch_size: fixed_batch_size = self._WRITE_BATCH_INITIAL_SIZE datastore_write_fn = _Mutate.DatastoreWriteFn( self._PROJECT, fixed_batch_size=fixed_batch_size) datastore_write_fn.start_bundle() for mutation in expected_mutations: datastore_write_fn.process(mutation) datastore_write_fn.finish_bundle() self.assertEqual(actual_mutations, expected_mutations) if use_fixed_batch_size: self.assertEqual( (num_entities - 1) // self._WRITE_BATCH_INITIAL_SIZE + 1, self._mock_datastore.commit.call_count) else: self._mock_datastore.commit.assert_called() def test_DatastoreWriteLargeEntities(self): """100*100kB entities gets split over two Commit RPCs.""" with patch.object(helper, 'get_datastore', return_value=self._mock_datastore): entities = [e.entity for e in fake_datastore.create_entities(100)] datastore_write_fn = _Mutate.DatastoreWriteFn( self._PROJECT, fixed_batch_size=self._WRITE_BATCH_INITIAL_SIZE) datastore_write_fn.start_bundle() for entity in entities: datastore_helper.add_properties( entity, {'large': u'A' * 100000}, exclude_from_indexes=True) datastore_write_fn.process(WriteToDatastore.to_upsert_mutation(entity)) datastore_write_fn.finish_bundle() self.assertEqual(2, self._mock_datastore.commit.call_count) def verify_unique_keys(self, queries): """A helper function that verifies if all the queries have unique keys.""" keys, _ = zip(*queries) keys = set(keys) self.assertEqual(len(keys), len(queries)) def check_estimated_size_bytes(self, entity_bytes, timestamp, namespace=None): """A helper method to test get_estimated_size_bytes""" timestamp_req = helper.make_request( self._PROJECT, namespace, helper.make_latest_timestamp_query(namespace)) timestamp_resp = self.make_stats_response( {'timestamp': datastore_helper.from_timestamp(timestamp)}) kind_stat_req = helper.make_request( self._PROJECT, namespace, helper.make_kind_stats_query( namespace, self._query.kind[0].name, datastore_helper.micros_from_timestamp(timestamp))) kind_stat_resp = self.make_stats_response({'entity_bytes': entity_bytes}) def fake_run_query(req): if req == timestamp_req: return timestamp_resp elif req == kind_stat_req: return kind_stat_resp else: print(kind_stat_req) raise ValueError("Unknown req: %s" % req) self._mock_datastore.run_query.side_effect = fake_run_query self.assertEqual( entity_bytes, ReadFromDatastore.get_estimated_size_bytes( self._PROJECT, namespace, self._query, self._mock_datastore)) self.assertEqual( self._mock_datastore.run_query.call_args_list, [call(timestamp_req), call(kind_stat_req)]) def make_stats_response(self, property_map): resp = datastore_pb2.RunQueryResponse() entity_result = resp.batch.entity_results.add() datastore_helper.add_properties(entity_result.entity, property_map) return resp def split_query(self, query, num_splits): """Generate dummy query splits.""" split_queries = [] for _ in range(0, num_splits): q = query_pb2.Query() q.CopyFrom(query) split_queries.append(q) return split_queries if __name__ == '__main__': unittest.main()
apache-2.0
[ 3, 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 3, 1134, 466, 26, 3372, 13, 493, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 984, 199, 646, 2882, 199, 504, 12963, 492, 2341, 199, 504, 12963, 492, 1425, 199, 504, 12963, 492, 3482, 199, 199, 504, 1683, 492, 10079, 199, 504, 1683, 492, 1240, 199, 504, 1683, 492, 3371, 199, 199, 3, 2165, 5302, 6169, 22196, 2382, 12007, 3555, 365, 440, 2808, 14, 199, 3, 4287, 26, 3507, 29, 10603, 13, 646, 13, 1648, 12, 6835, 13, 646, 13, 3124, 12, 625, 22674, 13, 12775, 199, 893, 26, 523, 687, 6233, 14, 4091, 14, 2625, 14, 11450, 14, 86, 17, 492, 12007, 63, 3317, 18, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 492, 4026, 63, 11450, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 492, 5922, 523, 687, 6233, 14, 4091, 14, 2625, 14, 11450, 14, 86, 17, 492, 1827, 63, 3317, 18, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 492, 1827, 63, 25234, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 492, 4884, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 14, 11450, 2308, 492, 5574, 2532, 30444, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 14, 11450, 2308, 492, 6990, 1378, 30444, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 14, 11450, 2308, 492, 485, 22539, 323, 523, 687, 6233, 14, 7204, 492, 4913, 63, 3317, 18, 523, 687, 6233, 11450, 492, 5922, 465, 12007, 63, 3676, 199, 2590, 334, 17825, 12, 3146, 304, 523, 12007, 63, 3317, 18, 275, 488, 199, 3, 4287, 26, 4756, 29, 10603, 13, 646, 13, 1648, 12, 6835, 13, 646, 13, 3124, 12, 625, 22674, 13, 12775, 421, 199, 533, 3918, 1617, 2308, 774, 8, 2796, 14, 1746, 304, 523, 485, 10797, 275, 283, 1715, 7, 523, 485, 43, 3192, 275, 283, 5091, 7, 523, 485, 13001, 275, 283, 3251, 7, 819, 768, 2796, 14, 15118, 8, 489, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 12, 489, 283, 86, 17, 15, 11450, 2308, 1630, 440, 2291, 2018, 650, 3254, 26, 6262, 1156, 13, 12383, 19, 358, 523, 768, 2796, 14, 15118, 8, 11450, 63, 3317, 18, 365, 488, 12, 283, 39, 2890, 5124, 787, 440, 4903, 358, 523, 347, 3613, 8, 277, 304, 272, 291, 423, 1805, 63, 11450, 275, 10079, 342, 272, 291, 423, 1131, 275, 1827, 63, 3317, 18, 14, 3227, 342, 272, 291, 423, 1131, 14, 5091, 14, 525, 1252, 354, 275, 291, 423, 43, 3192, 272, 291, 423, 10387, 63, 20813, 63, 13768, 63, 4305, 275, 4884, 14, 10387, 63, 20813, 63, 13768, 63, 4305, 819, 347, 664, 63, 3954, 8, 277, 304, 272, 372, 4913, 63, 3317, 18, 14, 10239, 8, 4515, 29, 4321, 9, 819, 347, 511, 63, 362, 63, 597, 12754, 63, 890, 63, 2394, 63, 7395, 63, 3251, 8, 277, 304, 272, 4642, 63, 2394, 275, 2948, 272, 4913, 275, 291, 14, 362, 63, 3954, 342, 272, 291, 14, 1074, 63, 597, 12754, 63, 890, 63, 2394, 8, 4502, 63, 2394, 12, 4913, 9, 819, 347, 511, 63, 362, 63, 597, 12754, 63, 890, 63, 2394, 63, 1045, 63, 3251, 8, 277, 304, 272, 4642, 63, 2394, 275, 2948, 272, 4913, 275, 291, 14, 362, 63, 3954, 342, 272, 291, 14, 1074, 63, 597, 12754, 63, 890, 63, 2394, 8, 4502, 63, 2394, 12, 4913, 12, 291, 423, 13001, 9, 819, 347, 511, 63, 8862, 3227, 9656, 63, 1045, 63, 1507, 63, 16508, 8, 277, 304, 272, 543, 3371, 14, 785, 8, 3676, 12, 1993, 283, 362, 63, 11450, 297, 1993, 372, 63, 585, 29, 277, 423, 1805, 63, 11450, 304, 489, 1967, 63, 16508, 275, 6546, 2541, 347, 4026, 63, 362, 63, 16508, 8, 11450, 12, 1827, 12, 1967, 63, 16508, 12, 6484, 29, 403, 304, 267, 372, 291, 14, 1294, 63, 1131, 8, 1131, 12, 1967, 63, 16508, 9, 2541, 543, 3371, 14, 785, 8, 1131, 63, 25234, 12, 717, 283, 362, 63, 16508, 297, 717, 5366, 63, 5881, 29, 3183, 63, 362, 63, 16508, 304, 398, 3715, 63, 1131, 63, 2324, 275, 5574, 2532, 30444, 14, 8862, 3227, 9656, 8, 288, 291, 423, 10797, 12, 291, 423, 1131, 12, 488, 12, 1967, 63, 16508, 9, 267, 3715, 63, 1131, 63, 2324, 14, 928, 63, 6469, 342, 267, 2138, 63, 1294, 63, 10590, 275, 942, 267, 367, 3715, 63, 1131, 315, 3715, 63, 1131, 63, 2324, 14, 1412, 8, 277, 423, 1131, 304, 881, 2138, 63, 1294, 63, 10590, 14, 740, 8, 1294, 63, 1131, 9, 398, 291, 14, 629, 8, 552, 8, 19065, 63, 1294, 63, 10590, 395, 1967, 63, 16508, 9, 267, 291, 14, 629, 8, 16, 12, 822, 8, 277, 423, 1805, 63, 11450, 14, 1065, 63, 1131, 14, 1250, 63, 589, 63, 513 ]
[ 199, 3, 3909, 370, 314, 3668, 2290, 2752, 334, 14950, 9, 1334, 1373, 503, 1655, 199, 3, 11615, 4190, 14024, 14, 221, 1666, 314, 12840, 570, 1854, 543, 199, 3, 642, 1736, 367, 4722, 2556, 12602, 4248, 12715, 14, 199, 3, 710, 14857, 12378, 642, 570, 370, 2047, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 199, 3, 334, 1589, 298, 3761, 3547, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 199, 3, 314, 844, 14, 221, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 259, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 199, 3, 1134, 466, 26, 3372, 13, 493, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 984, 199, 646, 2882, 199, 504, 12963, 492, 2341, 199, 504, 12963, 492, 1425, 199, 504, 12963, 492, 3482, 199, 199, 504, 1683, 492, 10079, 199, 504, 1683, 492, 1240, 199, 504, 1683, 492, 3371, 199, 199, 3, 2165, 5302, 6169, 22196, 2382, 12007, 3555, 365, 440, 2808, 14, 199, 3, 4287, 26, 3507, 29, 10603, 13, 646, 13, 1648, 12, 6835, 13, 646, 13, 3124, 12, 625, 22674, 13, 12775, 199, 893, 26, 523, 687, 6233, 14, 4091, 14, 2625, 14, 11450, 14, 86, 17, 492, 12007, 63, 3317, 18, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 492, 4026, 63, 11450, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 492, 5922, 523, 687, 6233, 14, 4091, 14, 2625, 14, 11450, 14, 86, 17, 492, 1827, 63, 3317, 18, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 492, 1827, 63, 25234, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 492, 4884, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 14, 11450, 2308, 492, 5574, 2532, 30444, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 14, 11450, 2308, 492, 6990, 1378, 30444, 523, 687, 17098, 63, 14529, 14, 2308, 14, 20622, 14, 11450, 14, 86, 17, 14, 11450, 2308, 492, 485, 22539, 323, 523, 687, 6233, 14, 7204, 492, 4913, 63, 3317, 18, 523, 687, 6233, 11450, 492, 5922, 465, 12007, 63, 3676, 199, 2590, 334, 17825, 12, 3146, 304, 523, 12007, 63, 3317, 18, 275, 488, 199, 3, 4287, 26, 4756, 29, 10603, 13, 646, 13, 1648, 12, 6835, 13, 646, 13, 3124, 12, 625, 22674, 13, 12775, 421, 199, 533, 3918, 1617, 2308, 774, 8, 2796, 14, 1746, 304, 523, 485, 10797, 275, 283, 1715, 7, 523, 485, 43, 3192, 275, 283, 5091, 7, 523, 485, 13001, 275, 283, 3251, 7, 819, 768, 2796, 14, 15118, 8, 489, 984, 14, 1023, 63, 815, 59, 16, 61, 508, 650, 12, 489, 283, 86, 17, 15, 11450, 2308, 1630, 440, 2291, 2018, 650, 3254, 26, 6262, 1156, 13, 12383, 19, 358, 523, 768, 2796, 14, 15118, 8, 11450, 63, 3317, 18, 365, 488, 12, 283, 39, 2890, 5124, 787, 440, 4903, 358, 523, 347, 3613, 8, 277, 304, 272, 291, 423, 1805, 63, 11450, 275, 10079, 342, 272, 291, 423, 1131, 275, 1827, 63, 3317, 18, 14, 3227, 342, 272, 291, 423, 1131, 14, 5091, 14, 525, 1252, 354, 275, 291, 423, 43, 3192, 272, 291, 423, 10387, 63, 20813, 63, 13768, 63, 4305, 275, 4884, 14, 10387, 63, 20813, 63, 13768, 63, 4305, 819, 347, 664, 63, 3954, 8, 277, 304, 272, 372, 4913, 63, 3317, 18, 14, 10239, 8, 4515, 29, 4321, 9, 819, 347, 511, 63, 362, 63, 597, 12754, 63, 890, 63, 2394, 63, 7395, 63, 3251, 8, 277, 304, 272, 4642, 63, 2394, 275, 2948, 272, 4913, 275, 291, 14, 362, 63, 3954, 342, 272, 291, 14, 1074, 63, 597, 12754, 63, 890, 63, 2394, 8, 4502, 63, 2394, 12, 4913, 9, 819, 347, 511, 63, 362, 63, 597, 12754, 63, 890, 63, 2394, 63, 1045, 63, 3251, 8, 277, 304, 272, 4642, 63, 2394, 275, 2948, 272, 4913, 275, 291, 14, 362, 63, 3954, 342, 272, 291, 14, 1074, 63, 597, 12754, 63, 890, 63, 2394, 8, 4502, 63, 2394, 12, 4913, 12, 291, 423, 13001, 9, 819, 347, 511, 63, 8862, 3227, 9656, 63, 1045, 63, 1507, 63, 16508, 8, 277, 304, 272, 543, 3371, 14, 785, 8, 3676, 12, 1993, 283, 362, 63, 11450, 297, 1993, 372, 63, 585, 29, 277, 423, 1805, 63, 11450, 304, 489, 1967, 63, 16508, 275, 6546, 2541, 347, 4026, 63, 362, 63, 16508, 8, 11450, 12, 1827, 12, 1967, 63, 16508, 12, 6484, 29, 403, 304, 267, 372, 291, 14, 1294, 63, 1131, 8, 1131, 12, 1967, 63, 16508, 9, 2541, 543, 3371, 14, 785, 8, 1131, 63, 25234, 12, 717, 283, 362, 63, 16508, 297, 717, 5366, 63, 5881, 29, 3183, 63, 362, 63, 16508, 304, 398, 3715, 63, 1131, 63, 2324, 275, 5574, 2532, 30444, 14, 8862, 3227, 9656, 8, 288, 291, 423, 10797, 12, 291, 423, 1131, 12, 488, 12, 1967, 63, 16508, 9, 267, 3715, 63, 1131, 63, 2324, 14, 928, 63, 6469, 342, 267, 2138, 63, 1294, 63, 10590, 275, 942, 267, 367, 3715, 63, 1131, 315, 3715, 63, 1131, 63, 2324, 14, 1412, 8, 277, 423, 1131, 304, 881, 2138, 63, 1294, 63, 10590, 14, 740, 8, 1294, 63, 1131, 9, 398, 291, 14, 629, 8, 552, 8, 19065, 63, 1294, 63, 10590, 395, 1967, 63, 16508, 9, 267, 291, 14, 629, 8, 16, 12, 822, 8, 277, 423, 1805, 63, 11450, 14, 1065, 63, 1131, 14, 1250, 63, 589, 63, 513, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
garbled1/ansible
lib/ansible/modules/network/nxos/nxos_vxlan_vtep_vni.py
22
12128
#!/usr/bin/python # # This file is part of Ansible # # Ansible is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Ansible is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see <http://www.gnu.org/licenses/>. # ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'network'} DOCUMENTATION = ''' --- module: nxos_vxlan_vtep_vni extends_documentation_fragment: nxos version_added: "2.2" short_description: Creates a Virtual Network Identifier member (VNI) description: - Creates a Virtual Network Identifier member (VNI) for an NVE overlay interface. author: Gabriele Gerbino (@GGabriele) notes: - Tested against NXOSv 7.3.(0)D1(1) on VIRL - default, where supported, restores params default value. options: interface: description: - Interface name for the VXLAN Network Virtualization Endpoint. required: true vni: description: - ID of the Virtual Network Identifier. required: true assoc_vrf: description: - This attribute is used to identify and separate processing VNIs that are associated with a VRF and used for routing. The VRF and VNI specified with this command must match the configuration of the VNI under the VRF. required: false choices: ['true','false'] default: null ingress_replication: description: - Specifies mechanism for host reachability advertisement. required: false choices: ['bgp','static'] default: null multicast_group: description: - The multicast group (range) of the VNI. Valid values are string and keyword 'default'. required: false default: null peer_list: description: - Set the ingress-replication static peer list. Valid values are an array, a space-separated string of ip addresses, or the keyword 'default'. required: false default: null suppress_arp: description: - Suppress arp under layer 2 VNI. required: false choices: ['true','false'] default: null state: description: - Determines whether the config should be present or not on the device. required: false default: present choices: ['present','absent'] ''' EXAMPLES = ''' - nxos_vxlan_vtep_vni: interface: nve1 vni: 6000 ingress_replication: default ''' RETURN = ''' commands: description: commands sent to the device returned: always type: list sample: ["interface nve1", "member vni 6000"] ''' import re from ansible.module_utils.nxos import get_config, load_config from ansible.module_utils.nxos import nxos_argument_spec, check_args from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.netcfg import CustomNetworkConfig BOOL_PARAMS = [ 'assoc_vrf', 'suppress_arp', ] PARAM_TO_COMMAND_KEYMAP = { 'assoc_vrf': 'associate-vrf', 'interface': 'interface', 'vni': 'member vni', 'ingress_replication': 'ingress-replication protocol', 'multicast_group': 'mcast-group', 'peer_list': 'peer-ip', 'suppress_arp': 'suppress-arp' } def get_value(arg, config, module): command = PARAM_TO_COMMAND_KEYMAP[arg] command_val_re = re.compile(r'(?:{0}\s)(?P<value>.*)$'.format(command), re.M) if arg in BOOL_PARAMS: command_re = re.compile(r'\s+{0}\s*$'.format(command), re.M) value = False if command_re.search(config): value = True elif arg == 'peer_list': has_command_val = command_val_re.findall(config, re.M) value = [] if has_command_val: value = has_command_val else: value = '' has_command_val = command_val_re.search(config, re.M) if has_command_val: value = has_command_val.group('value') return value def check_interface(module, netcfg): config = str(netcfg) has_interface = re.search(r'(?:interface nve)(?P<value>.*)$', config, re.M) value = '' if has_interface: value = 'nve{0}'.format(has_interface.group('value')) return value def get_existing(module, args): existing = {} netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) interface_exist = check_interface(module, netcfg) if interface_exist: parents = ['interface {0}'.format(interface_exist)] temp_config = netcfg.get_section(parents) if 'member vni {0} associate-vrf'.format(module.params['vni']) in temp_config: parents.append('member vni {0} associate-vrf'.format(module.params['vni'])) config = netcfg.get_section(parents) elif "member vni {0}".format(module.params['vni']) in temp_config: parents.append('member vni {0}'.format(module.params['vni'])) config = netcfg.get_section(parents) else: config = {} if config: for arg in args: if arg not in ['interface', 'vni']: existing[arg] = get_value(arg, config, module) existing['interface'] = interface_exist existing['vni'] = module.params['vni'] return existing, interface_exist def apply_key_map(key_map, table): new_dict = {} for key, value in table.items(): new_key = key_map.get(key) if new_key: new_dict[new_key] = value return new_dict def state_present(module, existing, proposed, candidate): commands = list() proposed_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, proposed) existing_commands = apply_key_map(PARAM_TO_COMMAND_KEYMAP, existing) for key, value in proposed_commands.items(): if key == 'associate-vrf': command = 'member vni {0} {1}'.format(module.params['vni'], key) if not value: command = 'no {0}'.format(command) commands.append(command) elif key == 'peer-ip' and value != 'default': for peer in value: commands.append('{0} {1}'.format(key, peer)) elif key == 'mcast-group' and value != existing_commands.get(key): commands.append('no {0}'.format(key)) commands.append('{0} {1}'.format(key, value)) elif value is True: commands.append(key) elif value is False: commands.append('no {0}'.format(key)) elif value == 'default': if existing_commands.get(key): existing_value = existing_commands.get(key) if key == 'peer-ip': for peer in existing_value: commands.append('no {0} {1}'.format(key, peer)) else: commands.append('no {0} {1}'.format(key, existing_value)) else: if key.replace(' ', '_').replace('-', '_') in BOOL_PARAMS: commands.append('no {0}'.format(key.lower())) else: command = '{0} {1}'.format(key, value.lower()) commands.append(command) if commands: vni_command = 'member vni {0}'.format(module.params['vni']) ingress_replication_command = 'ingress-replication protocol static' interface_command = 'interface {0}'.format(module.params['interface']) if ingress_replication_command in commands: static_level_cmds = [cmd for cmd in commands if 'peer' in cmd] parents = [interface_command, vni_command, ingress_replication_command] candidate.add(static_level_cmds, parents=parents) commands = [cmd for cmd in commands if 'peer' not in cmd] if vni_command in commands: parents = [interface_command] commands.remove(vni_command) if module.params['assoc_vrf'] is None: parents.append(vni_command) candidate.add(commands, parents=parents) def state_absent(module, existing, proposed, candidate): if existing['assoc_vrf']: commands = ['no member vni {0} associate-vrf'.format( module.params['vni'])] else: commands = ['no member vni {0}'.format(module.params['vni'])] parents = ['interface {0}'.format(module.params['interface'])] candidate.add(commands, parents=parents) def main(): argument_spec = dict( interface=dict(required=True, type='str'), vni=dict(required=True, type='str'), assoc_vrf=dict(required=False, type='bool'), multicast_group=dict(required=False, type='str'), peer_list=dict(required=False, type='list'), suppress_arp=dict(required=False, type='bool'), ingress_replication=dict(required=False, type='str', choices=['bgp', 'static', 'default']), state=dict(choices=['present', 'absent'], default='present', required=False), ) argument_spec.update(nxos_argument_spec) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) warnings = list() check_args(module, warnings) result = {'changed': False, 'commands': [], 'warnings': warnings} if module.params['assoc_vrf']: mutually_exclusive_params = ['multicast_group', 'suppress_arp', 'ingress_replication'] for param in mutually_exclusive_params: if module.params[param]: module.fail_json(msg='assoc_vrf cannot be used with ' '{0} param'.format(param)) if module.params['peer_list']: if module.params['ingress_replication'] != 'static': module.fail_json(msg='ingress_replication=static is required ' 'when using peer_list param') else: peer_list = module.params['peer_list'] if peer_list[0] == 'default': module.params['peer_list'] = 'default' else: stripped_peer_list = map(str.strip, peer_list) module.params['peer_list'] = stripped_peer_list state = module.params['state'] args = PARAM_TO_COMMAND_KEYMAP.keys() existing, interface_exist = get_existing(module, args) if state == 'present': if not interface_exist: module.fail_json(msg="The proposed NVE interface does not exist. Use nxos_interface to create it first.") elif interface_exist != module.params['interface']: module.fail_json(msg='Only 1 NVE interface is allowed on the switch.') elif state == 'absent': if interface_exist != module.params['interface']: module.exit_json(**result) elif existing and existing['vni'] != module.params['vni']: module.fail_json( msg="ERROR: VNI delete failed: Could not find vni node for {0}".format(module.params['vni']), existing_vni=existing['vni'] ) proposed_args = dict((k, v) for k, v in module.params.items() if v is not None and k in args) proposed = {} for key, value in proposed_args.items(): if key != 'interface' and existing.get(key) != value: proposed[key] = value candidate = CustomNetworkConfig(indent=3) if state == 'present': state_present(module, existing, proposed, candidate) elif existing and state == 'absent': state_absent(module, existing, proposed, candidate) if candidate: candidate = candidate.items_text() result['changed'] = True result['commands'] = candidate if not module.check_mode: load_config(module, candidate) module.exit_json(**result) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 1200, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 22072, 63, 18843, 1502, 63, 86, 2852, 63, 6002, 73, 199, 11036, 63, 9970, 63, 7677, 26, 22072, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 3612, 63, 1802, 26, 10560, 282, 13311, 7220, 23285, 3653, 334, 54, 16730, 9, 199, 1802, 26, 523, 446, 10560, 282, 13311, 7220, 23285, 3653, 334, 54, 16730, 9, 367, 376, 653, 2524, 272, 24393, 3217, 14, 199, 2502, 26, 598, 371, 322, 8081, 22261, 1393, 79, 8593, 2916, 371, 322, 8081, 9, 199, 5983, 26, 523, 446, 30568, 6169, 653, 56, 3100, 86, 1520, 14, 19, 14, 8, 16, 9, 36, 17, 8, 17, 9, 641, 812, 41, 2431, 523, 446, 849, 12, 2382, 3748, 12, 4618, 7944, 1862, 849, 574, 14, 199, 1419, 26, 523, 3217, 26, 272, 1369, 26, 489, 446, 14816, 536, 367, 314, 812, 56, 10825, 7220, 13311, 2072, 9599, 1403, 14, 272, 1415, 26, 2549, 523, 373, 8445, 26, 272, 1369, 26, 489, 446, 2870, 402, 314, 13311, 7220, 23285, 14, 272, 1415, 26, 2549, 523, 22149, 63, 11863, 26, 272, 1369, 26, 489, 446, 961, 2225, 365, 1202, 370, 10405, 436, 7396, 6661, 812, 46, 1831, 267, 626, 787, 4568, 543, 282, 812, 11778, 436, 1202, 367, 14870, 14, 710, 812, 11778, 267, 436, 812, 16730, 2013, 543, 642, 1414, 1471, 1336, 314, 2897, 267, 402, 314, 812, 16730, 1334, 314, 812, 11778, 14, 272, 1415, 26, 3055, 272, 3415, 26, 788, 2052, 1673, 3910, 418, 272, 849, 26, 2973, 523, 315, 3313, 63, 17144, 26, 272, 1369, 26, 489, 446, 11015, 14729, 367, 1591, 12276, 3616, 19613, 261, 434, 14, 272, 1415, 26, 3055, 272, 3415, 26, 788, 10132, 1673, 1986, 418, 272, 849, 26, 2973, 523, 28321, 63, 923, 26, 272, 1369, 26, 489, 446, 710, 28321, 1572, 334, 1842, 9, 402, 314, 812, 16730, 14, 4821, 1338, 787, 267, 1059, 436, 4252, 283, 885, 1370, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 9104, 63, 513, 26, 272, 1369, 26, 489, 446, 2494, 314, 315, 3313, 13, 17144, 2955, 9104, 769, 14, 4821, 1338, 267, 787, 376, 1625, 12, 282, 4601, 13, 12794, 1059, 402, 3384, 7149, 12, 267, 503, 314, 4252, 283, 885, 1370, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 15678, 63, 12868, 26, 272, 1369, 26, 489, 446, 26602, 26262, 1334, 4045, 499, 812, 16730, 14, 272, 1415, 26, 3055, 272, 3415, 26, 788, 2052, 1673, 3910, 418, 272, 849, 26, 2973, 523, 1174, 26, 272, 1369, 26, 489, 446, 22391, 3775, 314, 1101, 1077, 506, 3451, 503, 440, 267, 641, 314, 2243, 14, 272, 1415, 26, 3055, 272, 849, 26, 3451, 272, 3415, 26, 788, 1881, 1673, 5575, 418, 199, 2344, 199, 8918, 275, 1449, 199, 13, 22072, 63, 18843, 1502, 63, 86, 2852, 63, 6002, 73, 26, 272, 3217, 26, 302, 432, 17, 272, 373, 8445, 26, 1227, 1493, 272, 315, 3313, 63, 17144, 26, 849, 199, 2344, 199, 199, 9677, 275, 1449, 199, 4405, 26, 272, 1369, 26, 3718, 4847, 370, 314, 2243, 272, 2138, 26, 3544, 272, 730, 26, 769, 272, 2690, 26, 2097, 3266, 302, 432, 17, 401, 298, 1114, 373, 8445, 1227, 1493, 937, 199, 2344, 199, 199, 646, 295, 199, 504, 3242, 14, 578, 63, 1208, 14, 17982, 492, 664, 63, 888, 12, 2248, 63, 888, 199, 504, 3242, 14, 578, 63, 1208, 14, 17982, 492, 22072, 63, 2094, 63, 1650, 12, 1104, 63, 589, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 846, 4128, 492, 8388, 4491, 2028, 199, 199, 16026, 63, 17978, 275, 359, 272, 283, 16824, 63, 11863, 297, 272, 283, 17381, 63, 12868, 297, 199, 61, 199, 7258, 63, 2566, 63, 10761, 63, 3078, 5443, 275, 469, 272, 283, 16824, 63, 11863, 356, 283, 16021, 13, 11863, 297, 272, 283, 3266, 356, 283, 3266, 297, 272, 283, 6002, 73, 356, 283, 1114, 373, 8445, 297, 272, 283, 24390, 63, 17144, 356, 283, 24390, 13, 17144, 4113, 297, 272, 283, 23797, 63, 923, 356, 283, 77, 2931, 13, 923, 297, 272, 283, 7866, 63, 513, 356, 283, 7866, 13, 711, 297, 272, 283, 17381, 63, 12868, 356, 283, 17381, 13, 12868, 7, 199, 93, 421, 199, 318, 664, 63, 585, 8, 1273, 12, 1101, 12, 859, 304, 272, 1414, 275, 16565, 63, 2566, 63, 10761, 63, 3078, 5443, 59, 1273, 61, 272, 1414, 63, 637, 63, 264, 275, 295, 14, 2014, 8, 82, 20459, 91, 16, 4988, 83, 18168, 48, 28, 585, 26343, 4, 1370, 908, 8, 1531, 395, 295, 14, 45, 9, 339, 340, 1680, 315, 25849, 63, 17978, 26, 267, 1414, 63, 264, 275, 295, 14, 2014, 8, 82, 1154, 83, 11, 91, 16, 4988, 83, 10, 4, 1370, 908, 8, 1531, 395, 295, 14, 45, 9, 267, 574, 275, 756, 267, 340, 1414, 63, 264, 14, 1733, 8, 888, 304, 288, 574, 275, 715, 272, 916, 1680 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 961, 570, 365, 1777, 402, 2622, 199, 3, 199, 3, 2622, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 652, 1334, 314, 2895, 402, 314, 1664, 1696, 1684, 844, 465, 3267, 701, 199, 3, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 844, 12, 503, 199, 3, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 2622, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 1664, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 1696, 1684, 844, 199, 3, 3180, 543, 2622, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 1200, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 22072, 63, 18843, 1502, 63, 86, 2852, 63, 6002, 73, 199, 11036, 63, 9970, 63, 7677, 26, 22072, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 3612, 63, 1802, 26, 10560, 282, 13311, 7220, 23285, 3653, 334, 54, 16730, 9, 199, 1802, 26, 523, 446, 10560, 282, 13311, 7220, 23285, 3653, 334, 54, 16730, 9, 367, 376, 653, 2524, 272, 24393, 3217, 14, 199, 2502, 26, 598, 371, 322, 8081, 22261, 1393, 79, 8593, 2916, 371, 322, 8081, 9, 199, 5983, 26, 523, 446, 30568, 6169, 653, 56, 3100, 86, 1520, 14, 19, 14, 8, 16, 9, 36, 17, 8, 17, 9, 641, 812, 41, 2431, 523, 446, 849, 12, 2382, 3748, 12, 4618, 7944, 1862, 849, 574, 14, 199, 1419, 26, 523, 3217, 26, 272, 1369, 26, 489, 446, 14816, 536, 367, 314, 812, 56, 10825, 7220, 13311, 2072, 9599, 1403, 14, 272, 1415, 26, 2549, 523, 373, 8445, 26, 272, 1369, 26, 489, 446, 2870, 402, 314, 13311, 7220, 23285, 14, 272, 1415, 26, 2549, 523, 22149, 63, 11863, 26, 272, 1369, 26, 489, 446, 961, 2225, 365, 1202, 370, 10405, 436, 7396, 6661, 812, 46, 1831, 267, 626, 787, 4568, 543, 282, 812, 11778, 436, 1202, 367, 14870, 14, 710, 812, 11778, 267, 436, 812, 16730, 2013, 543, 642, 1414, 1471, 1336, 314, 2897, 267, 402, 314, 812, 16730, 1334, 314, 812, 11778, 14, 272, 1415, 26, 3055, 272, 3415, 26, 788, 2052, 1673, 3910, 418, 272, 849, 26, 2973, 523, 315, 3313, 63, 17144, 26, 272, 1369, 26, 489, 446, 11015, 14729, 367, 1591, 12276, 3616, 19613, 261, 434, 14, 272, 1415, 26, 3055, 272, 3415, 26, 788, 10132, 1673, 1986, 418, 272, 849, 26, 2973, 523, 28321, 63, 923, 26, 272, 1369, 26, 489, 446, 710, 28321, 1572, 334, 1842, 9, 402, 314, 812, 16730, 14, 4821, 1338, 787, 267, 1059, 436, 4252, 283, 885, 1370, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 9104, 63, 513, 26, 272, 1369, 26, 489, 446, 2494, 314, 315, 3313, 13, 17144, 2955, 9104, 769, 14, 4821, 1338, 267, 787, 376, 1625, 12, 282, 4601, 13, 12794, 1059, 402, 3384, 7149, 12, 267, 503, 314, 4252, 283, 885, 1370, 272, 1415, 26, 3055, 272, 849, 26, 2973, 523, 15678, 63, 12868, 26, 272, 1369, 26, 489, 446, 26602, 26262, 1334, 4045, 499, 812, 16730, 14, 272, 1415, 26, 3055, 272, 3415, 26, 788, 2052, 1673, 3910, 418, 272, 849, 26, 2973, 523, 1174, 26, 272, 1369, 26, 489, 446, 22391, 3775, 314, 1101, 1077, 506, 3451, 503, 440, 267, 641, 314, 2243, 14, 272, 1415, 26, 3055, 272, 849, 26, 3451, 272, 3415, 26, 788, 1881, 1673, 5575, 418, 199, 2344, 199, 8918, 275, 1449, 199, 13, 22072, 63, 18843, 1502, 63, 86, 2852, 63, 6002, 73, 26, 272, 3217, 26, 302, 432, 17, 272, 373, 8445, 26, 1227, 1493, 272, 315, 3313, 63, 17144, 26, 849, 199, 2344, 199, 199, 9677, 275, 1449, 199, 4405, 26, 272, 1369, 26, 3718, 4847, 370, 314, 2243, 272, 2138, 26, 3544, 272, 730, 26, 769, 272, 2690, 26, 2097, 3266, 302, 432, 17, 401, 298, 1114, 373, 8445, 1227, 1493, 937, 199, 2344, 199, 199, 646, 295, 199, 504, 3242, 14, 578, 63, 1208, 14, 17982, 492, 664, 63, 888, 12, 2248, 63, 888, 199, 504, 3242, 14, 578, 63, 1208, 14, 17982, 492, 22072, 63, 2094, 63, 1650, 12, 1104, 63, 589, 199, 504, 3242, 14, 578, 63, 1208, 14, 4316, 492, 6953, 199, 504, 3242, 14, 578, 63, 1208, 14, 846, 4128, 492, 8388, 4491, 2028, 199, 199, 16026, 63, 17978, 275, 359, 272, 283, 16824, 63, 11863, 297, 272, 283, 17381, 63, 12868, 297, 199, 61, 199, 7258, 63, 2566, 63, 10761, 63, 3078, 5443, 275, 469, 272, 283, 16824, 63, 11863, 356, 283, 16021, 13, 11863, 297, 272, 283, 3266, 356, 283, 3266, 297, 272, 283, 6002, 73, 356, 283, 1114, 373, 8445, 297, 272, 283, 24390, 63, 17144, 356, 283, 24390, 13, 17144, 4113, 297, 272, 283, 23797, 63, 923, 356, 283, 77, 2931, 13, 923, 297, 272, 283, 7866, 63, 513, 356, 283, 7866, 13, 711, 297, 272, 283, 17381, 63, 12868, 356, 283, 17381, 13, 12868, 7, 199, 93, 421, 199, 318, 664, 63, 585, 8, 1273, 12, 1101, 12, 859, 304, 272, 1414, 275, 16565, 63, 2566, 63, 10761, 63, 3078, 5443, 59, 1273, 61, 272, 1414, 63, 637, 63, 264, 275, 295, 14, 2014, 8, 82, 20459, 91, 16, 4988, 83, 18168, 48, 28, 585, 26343, 4, 1370, 908, 8, 1531, 395, 295, 14, 45, 9, 339, 340, 1680, 315, 25849, 63, 17978, 26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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
tayebzaidi/snova_analysis
Miscellaneous/typ1a_features.py
1
2252
import matplotlib.pyplot as plt import scipy.interpolate as scinterp import numpy as np import peakfinding import peak_original import smoothing import plotter import random import readin import sys import os if __name__== '__main__': Mbdata = [] delM15data = [] path = "/Users/zaidi/Documents/REU/restframe/" filenames = os.listdir(path) random.shuffle(filenames) for filename in filenames: current_file = os.path.join(path, filename) data= readin.readin_SNrest(filename) indB = np.where((data.band == 'B')) Bdata = data[indB] Bdata = np.sort(Bdata) if len(Bdata.phase) > 3: spl = scinterp.UnivariateSpline(Bdata.phase, Bdata.mag) spl.set_smoothing_factor(2./len(Bdata.phase)) phase_new = np.arange(Bdata.phase[0], Bdata.phase[-1], 1) mag_new = spl(phase_new) maxp, minp = peak_original.peakdet(mag_new, 0.5, phase_new) if len(minp) > 0 and minp[0][0] < 5 and minp[0][0] > -5: Mb = minp[0][1] delM15 = minp[0][1] - spl(minp[0][0]+15) Mbdata.append(Mb) delM15data.append(delM15) if delM15 > 0 or delM15 < -5: print minp print filename print spl(minp[0][0] + 15) fig = plt.figure(1) ax = fig.add_subplot(1,1,1) ax.plot(phase_new, mag_new) ax.plot(Bdata.phase, Bdata.mag) if len(minp) > 0: ax.scatter(minp[:,0],minp[:,1]) plt.show(fig) ''' maxp, minp = peakfinding.peakdetect(mag_new, phase_new, 200, 1.5) if len(minp) > 0: print minp print filename fig = plt.figure(1) ax = fig.add_subplot(1,1,1) #ax.scatter(minp[:,0], minp[:,1],'bo') #ax.plot(Bdata.phase, Bdata.mag) #plt.show(fig) ''' #interp = smoothing.Interpolate1D(data.phase print Mbdata print delM15data fig = plt.figure(2) ax = fig.add_subplot(1,1,1) ax.scatter(Mbdata, delM15data) plt.show(fig)
gpl-3.0
[ 646, 8027, 14, 13563, 465, 4488, 199, 646, 7026, 14, 21294, 465, 4061, 14252, 199, 646, 2680, 465, 980, 199, 646, 21441, 1623, 316, 199, 646, 21441, 63, 5043, 199, 646, 308, 22610, 199, 646, 5137, 351, 199, 646, 2196, 199, 646, 1586, 262, 199, 646, 984, 199, 646, 747, 199, 199, 692, 636, 354, 363, 389, 2560, 973, 3706, 272, 603, 66, 576, 275, 942, 272, 2150, 45, 1046, 576, 275, 942, 272, 931, 275, 3286, 12117, 15, 90, 5789, 328, 15, 26872, 15, 907, 53, 15, 3911, 1943, 6687, 272, 6203, 275, 747, 14, 7374, 8, 515, 9, 272, 2196, 14, 11777, 8, 10309, 9, 272, 367, 1788, 315, 6203, 26, 267, 1453, 63, 493, 275, 747, 14, 515, 14, 904, 8, 515, 12, 1788, 9, 267, 666, 29, 1586, 262, 14, 739, 262, 63, 8199, 3911, 8, 1501, 9, 267, 7654, 34, 275, 980, 14, 4509, 1332, 576, 14, 7877, 508, 283, 34, 1333, 267, 699, 576, 275, 666, 59, 688, 34, 61, 267, 699, 576, 275, 980, 14, 3191, 8, 34, 576, 9, 267, 340, 822, 8, 34, 576, 14, 6971, 9, 690, 650, 26, 288, 23168, 275, 4061, 14252, 14, 1358, 23225, 27558, 8, 34, 576, 14, 6971, 12, 699, 576, 14, 5615, 9, 288, 23168, 14, 409, 63, 83, 22610, 63, 4778, 8, 18, 13186, 552, 8, 34, 576, 14, 6971, 430, 288, 7669, 63, 1222, 275, 980, 14, 5605, 8, 34, 576, 14, 6971, 59, 16, 467, 699, 576, 14, 6971, 1988, 17, 467, 413, 9, 288, 8127, 63, 1222, 275, 23168, 8, 6971, 63, 1222, 9, 288, 1390, 80, 12, 1748, 80, 275, 21441, 63, 5043, 14, 8556, 9886, 8, 5615, 63, 1222, 12, 378, 14, 21, 12, 7669, 63, 1222, 9, 288, 340, 822, 8, 827, 80, 9, 690, 378, 436, 1748, 80, 59, 16, 1527, 16, 61, 665, 959, 436, 1748, 80, 59, 16, 1527, 16, 61, 690, 446, 21, 26, 355, 603, 66, 275, 1748, 80, 59, 16, 1527, 17, 61, 355, 2150, 45, 1046, 275, 1748, 80, 59, 16, 1527, 17, 61, 446, 23168, 8, 827, 80, 59, 16, 1527, 16, 2807, 1046, 9, 355, 603, 66, 576, 14, 740, 8, 16789, 9, 355, 2150, 45, 1046, 576, 14, 740, 8, 2264, 45, 1046, 9, 8892, 340, 2150, 45, 1046, 690, 378, 503, 2150, 45, 1046, 665, 446, 21, 26, 490, 870, 1748, 80, 490, 870, 1788, 490, 870, 23168, 8, 827, 80, 59, 16, 1527, 16, 61, 435, 4114, 9, 490, 6085, 275, 4488, 14, 8941, 8, 17, 9, 490, 2185, 275, 6085, 14, 525, 63, 13334, 8, 17, 12, 17, 12, 17, 9, 490, 2185, 14, 2798, 8, 6971, 63, 1222, 12, 8127, 63, 1222, 9, 490, 2185, 14, 2798, 8, 34, 576, 14, 6971, 12, 699, 576, 14, 5615, 9, 490, 340, 822, 8, 827, 80, 9, 690, 378, 26, 717, 2185, 14, 13512, 8, 827, 80, 3981, 16, 467, 827, 80, 3981, 17, 566, 490, 4488, 14, 2384, 8, 592, 9, 2728, 1449, 267, 1390, 80, 12, 1748, 80, 275, 21441, 1623, 316, 14, 8556, 13552, 8, 5615, 63, 1222, 12, 7669, 63, 1222, 12, 1926, 12, 413, 14, 21, 9, 267, 340, 822, 8, 827, 80, 9, 690, 378, 26, 288, 870, 1748, 80, 288, 870, 1788, 288, 6085, 275, 4488, 14, 8941, 8, 17, 9, 288, 2185, 275, 6085, 14, 525, 63, 13334, 8, 17, 12, 17, 12, 17, 9, 288, 327, 1219, 14, 13512, 8, 827, 80, 3981, 16, 467, 1748, 80, 3981, 17, 26801, 656, 358, 288, 327, 1219, 14, 2798, 8, 34, 576, 14, 6971, 12, 699, 576, 14, 5615, 9, 288, 327, 6003, 14, 2384, 8, 592, 9, 221, 2728, 1449, 267, 327, 14252, 275, 308, 22610, 14, 2620, 14641, 17, 36, 8, 576, 14, 6971, 272, 870, 603, 66, 576, 272, 870, 2150, 45, 1046, 576, 272, 6085, 275, 4488, 14, 8941, 8, 18, 9, 272, 2185, 275, 6085, 14, 525, 63, 13334, 8, 17, 12, 17, 12, 17, 9, 272, 2185, 14, 13512, 8, 16789, 576, 12, 2150, 45, 1046, 576, 9, 272, 4488, 14, 2384, 8, 592, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 8027, 14, 13563, 465, 4488, 199, 646, 7026, 14, 21294, 465, 4061, 14252, 199, 646, 2680, 465, 980, 199, 646, 21441, 1623, 316, 199, 646, 21441, 63, 5043, 199, 646, 308, 22610, 199, 646, 5137, 351, 199, 646, 2196, 199, 646, 1586, 262, 199, 646, 984, 199, 646, 747, 199, 199, 692, 636, 354, 363, 389, 2560, 973, 3706, 272, 603, 66, 576, 275, 942, 272, 2150, 45, 1046, 576, 275, 942, 272, 931, 275, 3286, 12117, 15, 90, 5789, 328, 15, 26872, 15, 907, 53, 15, 3911, 1943, 6687, 272, 6203, 275, 747, 14, 7374, 8, 515, 9, 272, 2196, 14, 11777, 8, 10309, 9, 272, 367, 1788, 315, 6203, 26, 267, 1453, 63, 493, 275, 747, 14, 515, 14, 904, 8, 515, 12, 1788, 9, 267, 666, 29, 1586, 262, 14, 739, 262, 63, 8199, 3911, 8, 1501, 9, 267, 7654, 34, 275, 980, 14, 4509, 1332, 576, 14, 7877, 508, 283, 34, 1333, 267, 699, 576, 275, 666, 59, 688, 34, 61, 267, 699, 576, 275, 980, 14, 3191, 8, 34, 576, 9, 267, 340, 822, 8, 34, 576, 14, 6971, 9, 690, 650, 26, 288, 23168, 275, 4061, 14252, 14, 1358, 23225, 27558, 8, 34, 576, 14, 6971, 12, 699, 576, 14, 5615, 9, 288, 23168, 14, 409, 63, 83, 22610, 63, 4778, 8, 18, 13186, 552, 8, 34, 576, 14, 6971, 430, 288, 7669, 63, 1222, 275, 980, 14, 5605, 8, 34, 576, 14, 6971, 59, 16, 467, 699, 576, 14, 6971, 1988, 17, 467, 413, 9, 288, 8127, 63, 1222, 275, 23168, 8, 6971, 63, 1222, 9, 288, 1390, 80, 12, 1748, 80, 275, 21441, 63, 5043, 14, 8556, 9886, 8, 5615, 63, 1222, 12, 378, 14, 21, 12, 7669, 63, 1222, 9, 288, 340, 822, 8, 827, 80, 9, 690, 378, 436, 1748, 80, 59, 16, 1527, 16, 61, 665, 959, 436, 1748, 80, 59, 16, 1527, 16, 61, 690, 446, 21, 26, 355, 603, 66, 275, 1748, 80, 59, 16, 1527, 17, 61, 355, 2150, 45, 1046, 275, 1748, 80, 59, 16, 1527, 17, 61, 446, 23168, 8, 827, 80, 59, 16, 1527, 16, 2807, 1046, 9, 355, 603, 66, 576, 14, 740, 8, 16789, 9, 355, 2150, 45, 1046, 576, 14, 740, 8, 2264, 45, 1046, 9, 8892, 340, 2150, 45, 1046, 690, 378, 503, 2150, 45, 1046, 665, 446, 21, 26, 490, 870, 1748, 80, 490, 870, 1788, 490, 870, 23168, 8, 827, 80, 59, 16, 1527, 16, 61, 435, 4114, 9, 490, 6085, 275, 4488, 14, 8941, 8, 17, 9, 490, 2185, 275, 6085, 14, 525, 63, 13334, 8, 17, 12, 17, 12, 17, 9, 490, 2185, 14, 2798, 8, 6971, 63, 1222, 12, 8127, 63, 1222, 9, 490, 2185, 14, 2798, 8, 34, 576, 14, 6971, 12, 699, 576, 14, 5615, 9, 490, 340, 822, 8, 827, 80, 9, 690, 378, 26, 717, 2185, 14, 13512, 8, 827, 80, 3981, 16, 467, 827, 80, 3981, 17, 566, 490, 4488, 14, 2384, 8, 592, 9, 2728, 1449, 267, 1390, 80, 12, 1748, 80, 275, 21441, 1623, 316, 14, 8556, 13552, 8, 5615, 63, 1222, 12, 7669, 63, 1222, 12, 1926, 12, 413, 14, 21, 9, 267, 340, 822, 8, 827, 80, 9, 690, 378, 26, 288, 870, 1748, 80, 288, 870, 1788, 288, 6085, 275, 4488, 14, 8941, 8, 17, 9, 288, 2185, 275, 6085, 14, 525, 63, 13334, 8, 17, 12, 17, 12, 17, 9, 288, 327, 1219, 14, 13512, 8, 827, 80, 3981, 16, 467, 1748, 80, 3981, 17, 26801, 656, 358, 288, 327, 1219, 14, 2798, 8, 34, 576, 14, 6971, 12, 699, 576, 14, 5615, 9, 288, 327, 6003, 14, 2384, 8, 592, 9, 221, 2728, 1449, 267, 327, 14252, 275, 308, 22610, 14, 2620, 14641, 17, 36, 8, 576, 14, 6971, 272, 870, 603, 66, 576, 272, 870, 2150, 45, 1046, 576, 272, 6085, 275, 4488, 14, 8941, 8, 18, 9, 272, 2185, 275, 6085, 14, 525, 63, 13334, 8, 17, 12, 17, 12, 17, 9, 272, 2185, 14, 13512, 8, 16789, 576, 12, 2150, 45, 1046, 576, 9, 272, 4488, 14, 2384, 8, 592, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jwren/intellij-community
python/python-features-trainer/resources/learnProjects/python/PyCharmLearningProject/src/warehouse/warehouse.py
9
1037
from util.util import FRUITS class Warehouse: # Fruit name to amount of it in warehouse entry = {} # Apple, banana, etc... def __init__(self) -> None: for fruit in FRUITS: self.entry[fruit] = 0 # fruit name from util.FRUITS (mango, apple...) def add_fruits(self, fruit_name, quantity) -> None: cur_quantity = self.entry.get(fruit_name) if cur_quantity is not None: self.entry[fruit_name] = cur_quantity + quantity else: raise KeyError(f"Not found fruit with name: {fruit_name}") def take_fruit(self, fruit_name) -> bool: cur_quantity = self.entry.get(fruit_name) if cur_quantity is None: raise KeyError(f"Not found fruit with name: {fruit_name}") elif cur_quantity > 0: self.entry[fruit_name] = cur_quantity - 1 return True return False def print_all_fruits(self) -> None: for fruit, quantity in self.entry.items(): print(f"{fruit}: {quantity}")
apache-2.0
[ 504, 4884, 14, 1974, 492, 481, 9500, 5930, 421, 199, 533, 644, 11499, 26, 272, 327, 481, 82, 4993, 536, 370, 5982, 402, 652, 315, 13782, 272, 2397, 275, 1052, 221, 327, 21257, 12, 30354, 6738, 12, 5423, 1396, 339, 347, 636, 826, 721, 277, 9, 1035, 488, 26, 267, 367, 9513, 4993, 315, 481, 9500, 5930, 26, 288, 291, 14, 2373, 59, 4391, 4993, 61, 275, 378, 339, 327, 9513, 4993, 536, 687, 4884, 14, 5372, 53, 5930, 334, 77, 17771, 12, 1145, 274, 11965, 272, 347, 1050, 63, 4391, 85, 1405, 8, 277, 12, 9513, 4993, 63, 354, 12, 12524, 9, 1035, 488, 26, 267, 1094, 63, 10577, 275, 291, 14, 2373, 14, 362, 8, 4391, 4993, 63, 354, 9, 267, 340, 1094, 63, 10577, 365, 440, 488, 26, 288, 291, 14, 2373, 59, 4391, 4993, 63, 354, 61, 275, 1094, 63, 10577, 435, 12524, 267, 587, 26, 288, 746, 4067, 8, 70, 2, 1763, 1911, 9513, 4993, 543, 536, 26, 469, 4391, 4993, 63, 354, 15412, 339, 347, 5452, 63, 4391, 4993, 8, 277, 12, 9513, 4993, 63, 354, 9, 1035, 2155, 26, 267, 1094, 63, 10577, 275, 291, 14, 2373, 14, 362, 8, 4391, 4993, 63, 354, 9, 267, 340, 1094, 63, 10577, 365, 488, 26, 288, 746, 4067, 8, 70, 2, 1763, 1911, 9513, 4993, 543, 536, 26, 469, 4391, 4993, 63, 354, 15412, 267, 916, 1094, 63, 10577, 690, 378, 26, 288, 291, 14, 2373, 59, 4391, 4993, 63, 354, 61, 275, 1094, 63, 10577, 446, 413, 288, 372, 715, 267, 372, 756, 339, 347, 870, 63, 452, 63, 4391, 85, 1405, 8, 277, 9, 1035, 488, 26, 267, 367, 9513, 4993, 12, 12524, 315, 291, 14, 2373, 14, 1744, 837, 288, 870, 8, 70, 14381, 4391, 4993, 9160, 469, 10577, 15412, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 4884, 14, 1974, 492, 481, 9500, 5930, 421, 199, 533, 644, 11499, 26, 272, 327, 481, 82, 4993, 536, 370, 5982, 402, 652, 315, 13782, 272, 2397, 275, 1052, 221, 327, 21257, 12, 30354, 6738, 12, 5423, 1396, 339, 347, 636, 826, 721, 277, 9, 1035, 488, 26, 267, 367, 9513, 4993, 315, 481, 9500, 5930, 26, 288, 291, 14, 2373, 59, 4391, 4993, 61, 275, 378, 339, 327, 9513, 4993, 536, 687, 4884, 14, 5372, 53, 5930, 334, 77, 17771, 12, 1145, 274, 11965, 272, 347, 1050, 63, 4391, 85, 1405, 8, 277, 12, 9513, 4993, 63, 354, 12, 12524, 9, 1035, 488, 26, 267, 1094, 63, 10577, 275, 291, 14, 2373, 14, 362, 8, 4391, 4993, 63, 354, 9, 267, 340, 1094, 63, 10577, 365, 440, 488, 26, 288, 291, 14, 2373, 59, 4391, 4993, 63, 354, 61, 275, 1094, 63, 10577, 435, 12524, 267, 587, 26, 288, 746, 4067, 8, 70, 2, 1763, 1911, 9513, 4993, 543, 536, 26, 469, 4391, 4993, 63, 354, 15412, 339, 347, 5452, 63, 4391, 4993, 8, 277, 12, 9513, 4993, 63, 354, 9, 1035, 2155, 26, 267, 1094, 63, 10577, 275, 291, 14, 2373, 14, 362, 8, 4391, 4993, 63, 354, 9, 267, 340, 1094, 63, 10577, 365, 488, 26, 288, 746, 4067, 8, 70, 2, 1763, 1911, 9513, 4993, 543, 536, 26, 469, 4391, 4993, 63, 354, 15412, 267, 916, 1094, 63, 10577, 690, 378, 26, 288, 291, 14, 2373, 59, 4391, 4993, 63, 354, 61, 275, 1094, 63, 10577, 446, 413, 288, 372, 715, 267, 372, 756, 339, 347, 870, 63, 452, 63, 4391, 85, 1405, 8, 277, 9, 1035, 488, 26, 267, 367, 9513, 4993, 12, 12524, 315, 291, 14, 2373, 14, 1744, 837, 288, 870, 8, 70, 14381, 4391, 4993, 9160, 469, 10577, 15412, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
hackers-terabit/portage
bin/check-implicit-pointer-usage.py
6
2942
#!/usr/bin/python -b # Ripped from HP and updated from Debian # Update by Gentoo to support unicode output # # Copyright (c) 2004 Hewlett-Packard Development Company, L.P. # David Mosberger <davidm@hpl.hp.com> # # Scan standard input for GCC warning messages that are likely to # source of real 64-bit problems. In particular, see whether there # are any implicitly declared functions whose return values are later # interpreted as pointers. Those are almost guaranteed to cause # crashes. # from __future__ import print_function import re import sys implicit_pattern = re.compile("([^:]*):(\d+): warning: implicit declaration " + "of function [`']([^']*)'") pointer_pattern = ( "([^:]*):(\d+): warning: " + "(" + "(assignment" + "|initialization" + "|return" + "|passing arg \d+ of `[^']*'" + "|passing arg \d+ of pointer to function" + ") makes pointer from integer without a cast" + "|" + "cast to pointer from integer of different size)") if sys.hexversion < 0x3000000: # Use encoded byte strings in python-2.x, since the python ebuilds are # known to remove the encodings module when USE=build is enabled (thus # disabling unicode decoding/encoding). The portage module has a # workaround for this, but currently we don't import that here since we # don't want to trigger potential sandbox violations due to stale pyc # files for the portage module. unicode_quote_open = '\xE2\x80\x98' unicode_quote_close = '\xE2\x80\x99' def write(msg): sys.stdout.write(msg) else: unicode_quote_open = '\u2018' unicode_quote_close = '\u2019' def write(msg): sys.stdout.buffer.write(msg.encode('utf_8', 'backslashreplace')) pointer_pattern = re.compile(pointer_pattern) last_implicit_filename = "" last_implicit_linenum = -1 last_implicit_func = "" while True: if sys.hexversion >= 0x3000000: line = sys.stdin.buffer.readline().decode('utf_8', 'replace') else: line = sys.stdin.readline() if not line: break # translate unicode open/close quotes to ascii ones line = line.replace(unicode_quote_open, "`") line = line.replace(unicode_quote_close, "'") m = implicit_pattern.match(line) if m: last_implicit_filename = m.group(1) last_implicit_linenum = int(m.group(2)) last_implicit_func = m.group(3) else: m = pointer_pattern.match(line) if m: pointer_filename = m.group(1) pointer_linenum = int(m.group(2)) if (last_implicit_filename == pointer_filename and last_implicit_linenum == pointer_linenum): write("Function `%s' implicitly converted to pointer at " \ "%s:%d\n" % (last_implicit_func, last_implicit_filename, last_implicit_linenum))
gpl-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 446, 66, 199, 199, 3, 820, 711, 1915, 687, 869, 48, 436, 4588, 687, 30445, 199, 3, 6162, 701, 18870, 7354, 370, 2291, 2649, 1072, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 8353, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 198, 36, 17204, 603, 736, 605, 836, 665, 983, 5017, 77, 32, 72, 1168, 14, 12025, 14, 957, 30, 199, 3, 199, 3, 24833, 4465, 1324, 367, 598, 2571, 5721, 3788, 626, 787, 12060, 370, 199, 3, 1350, 402, 3363, 5049, 13, 2075, 8826, 14, 221, 1010, 6770, 12, 1937, 3775, 2337, 199, 3, 787, 1263, 19796, 14290, 3423, 7447, 372, 1338, 787, 2945, 199, 3, 11922, 465, 21116, 14, 221, 18049, 261, 787, 18871, 17334, 370, 7675, 199, 3, 2467, 9030, 14, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 295, 199, 646, 984, 199, 199, 11886, 63, 3401, 275, 295, 14, 2014, 480, 7059, 2938, 10, 304, 2961, 68, 11, 304, 5721, 26, 9227, 12560, 298, 2892, 435, 298, 1618, 805, 359, 64, 418, 7059, 20445, 3171, 531, 199, 3929, 63, 3401, 275, 334, 272, 298, 7059, 2938, 10, 304, 2961, 68, 11, 304, 5721, 26, 298, 272, 435, 26054, 272, 435, 221, 7340, 10861, 2, 272, 435, 221, 15733, 27876, 2, 272, 435, 221, 15733, 1107, 2, 272, 435, 221, 15733, 29436, 1680, 971, 68, 11, 402, 658, 4735, 20445, 4065, 272, 435, 221, 15733, 29436, 1680, 971, 68, 11, 402, 7849, 370, 805, 2, 272, 435, 221, 6099, 7704, 7849, 687, 3000, 1928, 282, 9106, 2, 272, 435, 15733, 2, 272, 435, 298, 2931, 370, 7849, 687, 3000, 402, 3365, 1568, 6320, 199, 199, 692, 984, 14, 4097, 1023, 665, 378, 88, 19, 3273, 26, 272, 327, 3645, 5737, 3696, 3326, 315, 2366, 13, 18, 14, 88, 12, 3967, 314, 2366, 325, 10838, 787, 272, 327, 6040, 370, 2813, 314, 14134, 859, 1380, 4815, 29, 1506, 365, 5223, 334, 273, 527, 272, 327, 30723, 2649, 15952, 15, 2991, 680, 710, 1844, 474, 859, 965, 282, 272, 327, 18092, 367, 642, 12, 1325, 5544, 781, 2793, 1133, 492, 626, 2348, 3967, 781, 272, 327, 2793, 1133, 2934, 370, 6804, 12330, 19699, 1321, 22938, 7037, 370, 20149, 28968, 272, 327, 1584, 367, 314, 1844, 474, 859, 14, 272, 2649, 63, 3513, 63, 1490, 275, 1557, 6991, 18, 60, 88, 1257, 60, 88, 2905, 7, 272, 2649, 63, 3513, 63, 1600, 275, 1557, 6991, 18, 60, 88, 1257, 60, 88, 1020, 7, 272, 347, 2218, 8, 1328, 304, 267, 984, 14, 2703, 14, 952, 8, 1328, 9, 199, 2836, 26, 272, 2649, 63, 3513, 63, 1490, 275, 1557, 85, 12682, 7, 272, 2649, 63, 3513, 63, 1600, 275, 1557, 85, 14982, 7, 272, 347, 2218, 8, 1328, 304, 267, 984, 14, 2703, 14, 2738, 14, 952, 8, 1328, 14, 2143, 360, 1624, 63, 24, 297, 283, 21509, 1814, 1333, 199, 199, 3929, 63, 3401, 275, 295, 14, 2014, 8, 3929, 63, 3401, 9, 199, 199, 2019, 63, 11886, 63, 1501, 275, 3087, 199, 2019, 63, 11886, 63, 19466, 275, 446, 17, 199, 2019, 63, 11886, 63, 1532, 275, 3087, 199, 199, 6710, 715, 26, 272, 340, 984, 14, 4097, 1023, 2356, 378, 88, 19, 3273, 26, 267, 1004, 275, 984, 14, 6626, 14, 2738, 14, 6407, 1252, 2708, 360, 1624, 63, 24, 297, 283, 1814, 358, 272, 587, 26, 267, 1004, 275, 984, 14, 6626, 14, 6407, 342, 272, 340, 440, 1004, 26, 267, 2059, 272, 327, 9028, 2649, 1551, 15, 1600, 9344, 370, 13294, 7869, 272, 1004, 275, 1004, 14, 1814, 8, 2975, 63, 3513, 63, 1490, 12, 298, 22446, 272, 1004, 275, 1004, 14, 1814, 8, 2975, 63, 3513, 63, 1600, 12, 3546, 531, 272, 333, 275, 9227, 63, 3401, 14, 1431, 8, 604, 9, 272, 340, 333, 26, 267, 2061, 63, 11886, 63, 1501, 275, 333, 14, 923, 8, 17, 9, 267, 2061, 63, 11886, 63, 19466, 275, 1109, 8, 77, 14, 923, 8, 18, 430, 267, 2061, 63, 11886, 63, 1532, 275, 333, 14, 923, 8, 19, 9, 272, 587, 26, 267, 333, 275, 7849, 63, 3401, 14, 1431, 8, 604, 9, 267, 340, 333, 26, 288, 7849, 63, 1501, 275, 333, 14, 923, 8, 17, 9, 288, 7849, 63, 19466, 275, 1109, 8, 77, 14, 923, 8, 18, 430, 288, 340, 334, 2019, 63, 11886, 63, 1501, 508, 7849, 63, 1501, 355, 436, 2061, 63, 11886, 63, 19466, 508, 7849, 63, 19466, 304, 355, 2218, 480, 3481, 18633, 83, 7, 19796, 6702, 370, 7849, 737, 298, 971, 1993, 2071, 83, 2689, 68, 60, 78, 2, 450, 334, 2019, 63, 11886, 63, 1532, 12, 3521, 2061, 63, 11886, 63, 1501, 12, 3521, 2061, 63, 11886, 63, 19466, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1548, 446, 66, 199, 199, 3, 820, 711, 1915, 687, 869, 48, 436, 4588, 687, 30445, 199, 3, 6162, 701, 18870, 7354, 370, 2291, 2649, 1072, 199, 199, 3, 199, 3, 1898, 334, 67, 9, 8353, 27849, 13, 29471, 15290, 15878, 12, 491, 14, 48, 14, 199, 3, 198, 36, 17204, 603, 736, 605, 836, 665, 983, 5017, 77, 32, 72, 1168, 14, 12025, 14, 957, 30, 199, 3, 199, 3, 24833, 4465, 1324, 367, 598, 2571, 5721, 3788, 626, 787, 12060, 370, 199, 3, 1350, 402, 3363, 5049, 13, 2075, 8826, 14, 221, 1010, 6770, 12, 1937, 3775, 2337, 199, 3, 787, 1263, 19796, 14290, 3423, 7447, 372, 1338, 787, 2945, 199, 3, 11922, 465, 21116, 14, 221, 18049, 261, 787, 18871, 17334, 370, 7675, 199, 3, 2467, 9030, 14, 199, 3, 199, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 295, 199, 646, 984, 199, 199, 11886, 63, 3401, 275, 295, 14, 2014, 480, 7059, 2938, 10, 304, 2961, 68, 11, 304, 5721, 26, 9227, 12560, 298, 2892, 435, 298, 1618, 805, 359, 64, 418, 7059, 20445, 3171, 531, 199, 3929, 63, 3401, 275, 334, 272, 298, 7059, 2938, 10, 304, 2961, 68, 11, 304, 5721, 26, 298, 272, 435, 26054, 272, 435, 221, 7340, 10861, 2, 272, 435, 221, 15733, 27876, 2, 272, 435, 221, 15733, 1107, 2, 272, 435, 221, 15733, 29436, 1680, 971, 68, 11, 402, 658, 4735, 20445, 4065, 272, 435, 221, 15733, 29436, 1680, 971, 68, 11, 402, 7849, 370, 805, 2, 272, 435, 221, 6099, 7704, 7849, 687, 3000, 1928, 282, 9106, 2, 272, 435, 15733, 2, 272, 435, 298, 2931, 370, 7849, 687, 3000, 402, 3365, 1568, 6320, 199, 199, 692, 984, 14, 4097, 1023, 665, 378, 88, 19, 3273, 26, 272, 327, 3645, 5737, 3696, 3326, 315, 2366, 13, 18, 14, 88, 12, 3967, 314, 2366, 325, 10838, 787, 272, 327, 6040, 370, 2813, 314, 14134, 859, 1380, 4815, 29, 1506, 365, 5223, 334, 273, 527, 272, 327, 30723, 2649, 15952, 15, 2991, 680, 710, 1844, 474, 859, 965, 282, 272, 327, 18092, 367, 642, 12, 1325, 5544, 781, 2793, 1133, 492, 626, 2348, 3967, 781, 272, 327, 2793, 1133, 2934, 370, 6804, 12330, 19699, 1321, 22938, 7037, 370, 20149, 28968, 272, 327, 1584, 367, 314, 1844, 474, 859, 14, 272, 2649, 63, 3513, 63, 1490, 275, 1557, 6991, 18, 60, 88, 1257, 60, 88, 2905, 7, 272, 2649, 63, 3513, 63, 1600, 275, 1557, 6991, 18, 60, 88, 1257, 60, 88, 1020, 7, 272, 347, 2218, 8, 1328, 304, 267, 984, 14, 2703, 14, 952, 8, 1328, 9, 199, 2836, 26, 272, 2649, 63, 3513, 63, 1490, 275, 1557, 85, 12682, 7, 272, 2649, 63, 3513, 63, 1600, 275, 1557, 85, 14982, 7, 272, 347, 2218, 8, 1328, 304, 267, 984, 14, 2703, 14, 2738, 14, 952, 8, 1328, 14, 2143, 360, 1624, 63, 24, 297, 283, 21509, 1814, 1333, 199, 199, 3929, 63, 3401, 275, 295, 14, 2014, 8, 3929, 63, 3401, 9, 199, 199, 2019, 63, 11886, 63, 1501, 275, 3087, 199, 2019, 63, 11886, 63, 19466, 275, 446, 17, 199, 2019, 63, 11886, 63, 1532, 275, 3087, 199, 199, 6710, 715, 26, 272, 340, 984, 14, 4097, 1023, 2356, 378, 88, 19, 3273, 26, 267, 1004, 275, 984, 14, 6626, 14, 2738, 14, 6407, 1252, 2708, 360, 1624, 63, 24, 297, 283, 1814, 358, 272, 587, 26, 267, 1004, 275, 984, 14, 6626, 14, 6407, 342, 272, 340, 440, 1004, 26, 267, 2059, 272, 327, 9028, 2649, 1551, 15, 1600, 9344, 370, 13294, 7869, 272, 1004, 275, 1004, 14, 1814, 8, 2975, 63, 3513, 63, 1490, 12, 298, 22446, 272, 1004, 275, 1004, 14, 1814, 8, 2975, 63, 3513, 63, 1600, 12, 3546, 531, 272, 333, 275, 9227, 63, 3401, 14, 1431, 8, 604, 9, 272, 340, 333, 26, 267, 2061, 63, 11886, 63, 1501, 275, 333, 14, 923, 8, 17, 9, 267, 2061, 63, 11886, 63, 19466, 275, 1109, 8, 77, 14, 923, 8, 18, 430, 267, 2061, 63, 11886, 63, 1532, 275, 333, 14, 923, 8, 19, 9, 272, 587, 26, 267, 333, 275, 7849, 63, 3401, 14, 1431, 8, 604, 9, 267, 340, 333, 26, 288, 7849, 63, 1501, 275, 333, 14, 923, 8, 17, 9, 288, 7849, 63, 19466, 275, 1109, 8, 77, 14, 923, 8, 18, 430, 288, 340, 334, 2019, 63, 11886, 63, 1501, 508, 7849, 63, 1501, 355, 436, 2061, 63, 11886, 63, 19466, 508, 7849, 63, 19466, 304, 355, 2218, 480, 3481, 18633, 83, 7, 19796, 6702, 370, 7849, 737, 298, 971, 1993, 2071, 83, 2689, 68, 60, 78, 2, 450, 334, 2019, 63, 11886, 63, 1532, 12, 3521, 2061, 63, 11886, 63, 1501, 12, 3521, 2061, 63, 11886, 63, 19466, 430, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
DREAM-ODA-OS/tools
metadata/dimap2eop.py
1
3474
#!/usr/bin/env python #------------------------------------------------------------------------------ # # Extract O&M-EOP metadata document. # # Project: EO Metadata Handling # Authors: Martin Paces <martin.paces@eox.at> # #------------------------------------------------------------------------------- # Copyright (C) 2013 EOX IT Services GmbH # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies of this Software or works derived from this Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. #------------------------------------------------------------------------------- import traceback import sys import os.path from lxml import etree as et from profiles.interfaces import ProfileDimap from profiles.spot6_ortho import ProfileSpot6Ortho from profiles.spot_view import ProfileSpotView from profiles.spot_scene_1a import ProfileSpotScene1a from profiles.pleiades1_ortho import ProfilePleiades1Ortho XML_OPTS = {'pretty_print': True, 'xml_declaration': True, 'encoding': 'utf-8'} PROFILES = ( ProfileSpotScene1a, ProfileSpotView, ProfileSpot6Ortho, ProfilePleiades1Ortho, ) def main(fname): xml = et.parse(fname, et.XMLParser(remove_blank_text=True)) profile = get_profile(xml) print et.tostring(profile.extract_eop_metadata(xml, file_name=fname), **XML_OPTS) def get_profile(xml): for item in PROFILES: if item.check_profile(xml): return item prf = ProfileDimap.get_dimap_profile(xml) if prf is None: raise ValueError("Not a DIMAP XML document!") profile, version = prf raise ValueError("Unsupported DIMAP version %s profile '%s'!"%(version, profile)) #------------------------------------------------------------------------------ if __name__ == "__main__": EXENAME = os.path.basename(sys.argv[0]) DEBUG = False try: XML = sys.argv[1] for arg in sys.argv[2:]: if arg == "DEBUG": DEBUG = True # dump debuging output except IndexError: print >>sys.stderr, "ERROR: %s: Not enough input arguments!"%EXENAME print >>sys.stderr print >>sys.stderr, "Extract EOP XML metadata from DIMAP XML metadata." print >>sys.stderr print >>sys.stderr, "USAGE: %s <input-xml> [DEBUG]"%EXENAME sys.exit(1) if DEBUG: print >>sys.stderr, "input-xml: ", XML try: main(XML) except Exception as exc: print >>sys.stderr, "ERROR: %s: %s "%(EXENAME, exc) if DEBUG: print >>sys.stderr, traceback.format_exc() sys.exit(1)
mit
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 20974, 199, 3, 199, 3, 257, 12892, 593, 6, 45, 13, 37, 1938, 3341, 2213, 14, 199, 3, 199, 3, 7290, 26, 662, 47, 16160, 18405, 2983, 199, 3, 6642, 26, 603, 26788, 10164, 823, 665, 77, 26788, 14, 4285, 32, 69, 19131, 14, 292, 30, 199, 3, 199, 7656, 18964, 199, 3, 1898, 334, 35, 9, 6171, 662, 29544, 473, 52, 21813, 23428, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 3, 6866, 402, 642, 2290, 503, 5419, 7131, 687, 642, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 3, 2334, 4141, 14, 199, 7656, 18964, 199, 199, 646, 5190, 199, 646, 984, 199, 646, 747, 14, 515, 199, 504, 14490, 492, 7559, 465, 10844, 199, 199, 504, 17390, 14, 7436, 492, 14386, 1341, 1130, 199, 504, 17390, 14, 15185, 22, 63, 11297, 79, 492, 14386, 5058, 357, 22, 2844, 273, 79, 199, 504, 17390, 14, 15185, 63, 1345, 492, 14386, 5058, 357, 2768, 199, 504, 17390, 14, 15185, 63, 10436, 63, 17, 65, 492, 14386, 5058, 357, 14216, 17, 65, 199, 504, 17390, 14, 11045, 4674, 3424, 17, 63, 11297, 79, 492, 14386, 48, 274, 4674, 3424, 17, 2844, 273, 79, 199, 199, 4317, 63, 25636, 275, 791, 9118, 63, 1361, 356, 715, 12, 283, 1652, 63, 15477, 356, 715, 12, 283, 2991, 356, 283, 1624, 13, 24, 936, 199, 199, 2514, 9472, 275, 334, 272, 14386, 5058, 357, 14216, 17, 65, 12, 14386, 5058, 357, 2768, 12, 272, 14386, 5058, 357, 22, 2844, 273, 79, 12, 14386, 48, 274, 4674, 3424, 17, 2844, 273, 79, 12, 199, 9, 199, 199, 318, 2446, 8, 5252, 304, 272, 2748, 275, 10844, 14, 1122, 8, 5252, 12, 10844, 14, 4317, 2842, 8, 2168, 63, 2500, 63, 505, 29, 549, 430, 272, 4690, 275, 664, 63, 2913, 8, 1652, 9, 272, 870, 10844, 14, 14028, 8, 2913, 14, 5005, 63, 69, 411, 63, 2343, 8, 1652, 12, 570, 63, 354, 29, 5252, 395, 1011, 4317, 63, 25636, 9, 199, 199, 318, 664, 63, 2913, 8, 1652, 304, 272, 367, 1242, 315, 3611, 9472, 26, 267, 340, 1242, 14, 1074, 63, 2913, 8, 1652, 304, 288, 372, 1242, 272, 299, 3941, 275, 14386, 1341, 1130, 14, 362, 63, 328, 1130, 63, 2913, 8, 1652, 9, 272, 340, 299, 3941, 365, 488, 26, 267, 746, 1722, 480, 1763, 282, 577, 1469, 1282, 4692, 2213, 9124, 272, 4690, 12, 1015, 275, 299, 3941, 272, 746, 1722, 480, 12647, 577, 1469, 1282, 1015, 450, 83, 4690, 1543, 83, 7, 9539, 2840, 1023, 12, 4690, 430, 199, 199, 20974, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 3651, 11536, 275, 747, 14, 515, 14, 4846, 8, 1274, 14, 3020, 59, 16, 566, 272, 10990, 275, 756, 339, 862, 26, 267, 4692, 275, 984, 14, 3020, 59, 17, 61, 267, 367, 1680, 315, 984, 14, 3020, 59, 18, 10688, 288, 340, 1680, 508, 298, 5287, 582, 355, 10990, 275, 715, 327, 5461, 3105, 316, 1072, 339, 871, 7888, 26, 267, 870, 4331, 1274, 14, 3083, 12, 298, 3170, 26, 450, 83, 26, 2832, 8321, 1324, 2368, 1, 6808, 1438, 11536, 267, 870, 4331, 1274, 14, 3083, 267, 870, 4331, 1274, 14, 3083, 12, 298, 12147, 662, 1938, 4692, 3341, 687, 577, 1469, 1282, 4692, 3341, 2122, 267, 870, 4331, 1274, 14, 3083, 267, 870, 4331, 1274, 14, 3083, 12, 298, 20274, 26, 450, 83, 665, 1210, 13, 1652, 30, 359, 5287, 61, 6808, 1438, 11536, 267, 984, 14, 2224, 8, 17, 9, 339, 340, 10990, 26, 267, 870, 4331, 1274, 14, 3083, 12, 298, 1210, 13, 1652, 26, 257, 3872, 4692, 339, 862, 26, 267, 2446, 8, 4317, 9, 272, 871, 2186, 465, 3178, 26, 267, 870, 4331, 1274, 14, 3083, 12, 298, 3170, 26, 450, 83, 26, 450, 83, 11792, 1438, 11536, 12, 3178, 9, 267, 340, 10990, 26, 288, 870, 4331, 1274, 14, 3083, 12, 5190, 14, 908, 63, 2804, 342, 267, 984, 14, 2224, 8, 17, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 20974, 199, 3, 199, 3, 257, 12892, 593, 6, 45, 13, 37, 1938, 3341, 2213, 14, 199, 3, 199, 3, 7290, 26, 662, 47, 16160, 18405, 2983, 199, 3, 6642, 26, 603, 26788, 10164, 823, 665, 77, 26788, 14, 4285, 32, 69, 19131, 14, 292, 30, 199, 3, 199, 7656, 18964, 199, 3, 1898, 334, 35, 9, 6171, 662, 29544, 473, 52, 21813, 23428, 199, 3, 199, 3, 8779, 365, 11882, 10009, 12, 2867, 402, 11204, 12, 370, 1263, 4954, 12408, 282, 1331, 199, 3, 402, 642, 2032, 436, 4568, 3794, 1584, 334, 1589, 298, 10337, 1288, 370, 7962, 199, 3, 315, 314, 2290, 1928, 10588, 12, 5893, 1928, 12305, 314, 4481, 199, 3, 370, 675, 12, 1331, 12, 2811, 12, 5389, 12, 2780, 12, 11207, 12, 13473, 12, 436, 15, 269, 12743, 199, 3, 6866, 402, 314, 2290, 12, 436, 370, 11291, 12103, 370, 12676, 314, 2290, 365, 199, 3, 13985, 370, 886, 880, 12, 5420, 370, 314, 2569, 3704, 26, 199, 3, 199, 3, 710, 3432, 4248, 4245, 436, 642, 4983, 4245, 10989, 506, 5120, 315, 1006, 199, 3, 6866, 402, 642, 2290, 503, 5419, 7131, 687, 642, 2290, 14, 199, 3, 199, 3, 2334, 4141, 2281, 7049, 298, 1179, 2281, 401, 2428, 3408, 1634, 1821, 3826, 12, 7168, 1549, 199, 3, 5292, 12, 6931, 5400, 2845, 5471, 2296, 2334, 2990, 1634, 3169, 12, 199, 3, 3092, 2381, 437, 3115, 3104, 2401, 13229, 14, 1621, 4825, 6461, 7000, 2334, 199, 3, 10610, 1549, 5877, 8164, 6262, 7024, 2381, 1821, 13140, 12, 6736, 1549, 5010, 199, 3, 5603, 12, 7061, 1621, 1261, 9612, 1634, 7066, 12, 7056, 1549, 7334, 12, 7043, 4442, 12, 199, 3, 5738, 1634, 1549, 1621, 11287, 1663, 2334, 4141, 1549, 2334, 4815, 1549, 5010, 13198, 1621, 199, 3, 2334, 4141, 14, 199, 7656, 18964, 199, 199, 646, 5190, 199, 646, 984, 199, 646, 747, 14, 515, 199, 504, 14490, 492, 7559, 465, 10844, 199, 199, 504, 17390, 14, 7436, 492, 14386, 1341, 1130, 199, 504, 17390, 14, 15185, 22, 63, 11297, 79, 492, 14386, 5058, 357, 22, 2844, 273, 79, 199, 504, 17390, 14, 15185, 63, 1345, 492, 14386, 5058, 357, 2768, 199, 504, 17390, 14, 15185, 63, 10436, 63, 17, 65, 492, 14386, 5058, 357, 14216, 17, 65, 199, 504, 17390, 14, 11045, 4674, 3424, 17, 63, 11297, 79, 492, 14386, 48, 274, 4674, 3424, 17, 2844, 273, 79, 199, 199, 4317, 63, 25636, 275, 791, 9118, 63, 1361, 356, 715, 12, 283, 1652, 63, 15477, 356, 715, 12, 283, 2991, 356, 283, 1624, 13, 24, 936, 199, 199, 2514, 9472, 275, 334, 272, 14386, 5058, 357, 14216, 17, 65, 12, 14386, 5058, 357, 2768, 12, 272, 14386, 5058, 357, 22, 2844, 273, 79, 12, 14386, 48, 274, 4674, 3424, 17, 2844, 273, 79, 12, 199, 9, 199, 199, 318, 2446, 8, 5252, 304, 272, 2748, 275, 10844, 14, 1122, 8, 5252, 12, 10844, 14, 4317, 2842, 8, 2168, 63, 2500, 63, 505, 29, 549, 430, 272, 4690, 275, 664, 63, 2913, 8, 1652, 9, 272, 870, 10844, 14, 14028, 8, 2913, 14, 5005, 63, 69, 411, 63, 2343, 8, 1652, 12, 570, 63, 354, 29, 5252, 395, 1011, 4317, 63, 25636, 9, 199, 199, 318, 664, 63, 2913, 8, 1652, 304, 272, 367, 1242, 315, 3611, 9472, 26, 267, 340, 1242, 14, 1074, 63, 2913, 8, 1652, 304, 288, 372, 1242, 272, 299, 3941, 275, 14386, 1341, 1130, 14, 362, 63, 328, 1130, 63, 2913, 8, 1652, 9, 272, 340, 299, 3941, 365, 488, 26, 267, 746, 1722, 480, 1763, 282, 577, 1469, 1282, 4692, 2213, 9124, 272, 4690, 12, 1015, 275, 299, 3941, 272, 746, 1722, 480, 12647, 577, 1469, 1282, 1015, 450, 83, 4690, 1543, 83, 7, 9539, 2840, 1023, 12, 4690, 430, 199, 199, 20974, 199, 199, 692, 636, 354, 363, 508, 4396, 973, 5727, 272, 3651, 11536, 275, 747, 14, 515, 14, 4846, 8, 1274, 14, 3020, 59, 16, 566, 272, 10990, 275, 756, 339, 862, 26, 267, 4692, 275, 984, 14, 3020, 59, 17, 61, 267, 367, 1680, 315, 984, 14, 3020, 59, 18, 10688, 288, 340, 1680, 508, 298, 5287, 582, 355, 10990, 275, 715, 327, 5461, 3105, 316, 1072, 339, 871, 7888, 26, 267, 870, 4331, 1274, 14, 3083, 12, 298, 3170, 26, 450, 83, 26, 2832, 8321, 1324, 2368, 1, 6808, 1438, 11536, 267, 870, 4331, 1274, 14, 3083, 267, 870, 4331, 1274, 14, 3083, 12, 298, 12147, 662, 1938, 4692, 3341, 687, 577, 1469, 1282, 4692, 3341, 2122, 267, 870, 4331, 1274, 14, 3083, 267, 870, 4331, 1274, 14, 3083, 12, 298, 20274, 26, 450, 83, 665, 1210, 13, 1652, 30, 359, 5287, 61, 6808, 1438, 11536, 267, 984, 14, 2224, 8, 17, 9, 339, 340, 10990, 26, 267, 870, 4331, 1274, 14, 3083, 12, 298, 1210, 13, 1652, 26, 257, 3872, 4692, 339, 862, 26, 267, 2446, 8, 4317, 9, 272, 871, 2186, 465, 3178, 26, 267, 870, 4331, 1274, 14, 3083, 12, 298, 3170, 26, 450, 83, 26, 450, 83, 11792, 1438, 11536, 12, 3178, 9, 267, 340, 10990, 26, 288, 870, 4331, 1274, 14, 3083, 12, 5190, 14, 908, 63, 2804, 342, 267, 984, 14, 2224, 8, 17, 9, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
jhawkesworth/ansible
lib/ansible/modules/cloud/univention/udm_user.py
37
18102
#!/usr/bin/python # -*- coding: UTF-8 -*- # Copyright: (c) 2016, Adfinis SyGroup AG # Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch> # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function __metaclass__ = type ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} DOCUMENTATION = ''' --- module: udm_user version_added: "2.2" author: - Tobias Rüetschi (@keachi) short_description: Manage posix users on a univention corporate server description: - "This module allows to manage posix users on a univention corporate server (UCS). It uses the python API of the UCS to create a new object or edit it." requirements: - Python >= 2.6 options: state: default: "present" choices: [ present, absent ] description: - Whether the user is present or not. username: required: true description: - User name aliases: ['name'] firstname: description: - First name. Required if C(state=present). lastname: description: - Last name. Required if C(state=present). password: description: - Password. Required if C(state=present). birthday: description: - Birthday city: description: - City of users business address. country: description: - Country of users business address. department_number: description: - Department number of users business address. aliases: [ departmentNumber ] description: description: - Description (not gecos) display_name: description: - Display name (not gecos) aliases: [ displayName ] email: default: [] description: - A list of e-mail addresses. employee_number: description: - Employee number aliases: [ employeeNumber ] employee_type: description: - Employee type aliases: [ employeeType ] gecos: description: - GECOS groups: default: [] description: - "POSIX groups, the LDAP DNs of the groups will be found with the LDAP filter for each group as $GROUP: C((&(objectClass=posixGroup)(cn=$GROUP)))." home_share: description: - "Home NFS share. Must be a LDAP DN, e.g. C(cn=home,cn=shares,ou=school,dc=example,dc=com)." aliases: [ homeShare ] home_share_path: description: - Path to home NFS share, inside the homeShare. aliases: [ homeSharePath ] home_telephone_number: default: [] description: - List of private telephone numbers. aliases: [ homeTelephoneNumber ] homedrive: description: - Windows home drive, e.g. C("H:"). mail_alternative_address: default: [] description: - List of alternative e-mail addresses. aliases: [ mailAlternativeAddress ] mail_home_server: description: - FQDN of mail server aliases: [ mailHomeServer ] mail_primary_address: description: - Primary e-mail address aliases: [ mailPrimaryAddress ] mobile_telephone_number: default: [] description: - Mobile phone number aliases: [ mobileTelephoneNumber ] organisation: description: - Organisation aliases: [ organization ] override_pw_history: type: bool default: 'no' description: - Override password history aliases: [ overridePWHistory ] override_pw_length: type: bool default: 'no' description: - Override password check aliases: [ overridePWLength ] pager_telephonenumber: default: [] description: - List of pager telephone numbers. aliases: [ pagerTelephonenumber ] phone: description: - List of telephone numbers. postcode: description: - Postal code of users business address. primary_group: default: cn=Domain Users,cn=groups,$LDAP_BASE_DN description: - Primary group. This must be the group LDAP DN. aliases: [ primaryGroup ] profilepath: description: - Windows profile directory pwd_change_next_login: choices: [ '0', '1' ] description: - Change password on next login. aliases: [ pwdChangeNextLogin ] room_number: description: - Room number of users business address. aliases: [ roomNumber ] samba_privileges: description: - "Samba privilege, like allow printer administration, do domain join." aliases: [ sambaPrivileges ] samba_user_workstations: description: - Allow the authentication only on this Microsoft Windows host. aliases: [ sambaUserWorkstations ] sambahome: description: - Windows home path, e.g. C('\\\\$FQDN\\$USERNAME'). scriptpath: description: - Windows logon script. secretary: default: [] description: - A list of superiors as LDAP DNs. serviceprovider: default: [] description: - Enable user for the following service providers. shell: default: '/bin/bash' description: - Login shell street: description: - Street of users business address. title: description: - Title, e.g. C(Prof.). unixhome: default: '/home/$USERNAME' description: - Unix home directory userexpiry: default: Today + 1 year description: - Account expiry date, e.g. C(1999-12-31). position: default: '' description: - "Define the whole position of users object inside the LDAP tree, e.g. C(cn=employee,cn=users,ou=school,dc=example,dc=com)." update_password: default: always description: - "C(always) will update passwords if they differ. C(on_create) will only set the password for newly created users." version_added: "2.3" ou: default: '' description: - "Organizational Unit inside the LDAP Base DN, e.g. C(school) for LDAP OU C(ou=school,dc=example,dc=com)." subpath: default: 'cn=users' description: - "LDAP subpath inside the organizational unit, e.g. C(cn=teachers,cn=users) for LDAP container C(cn=teachers,cn=users,dc=example,dc=com)." ''' EXAMPLES = ''' # Create a user on a UCS - udm_user: name: FooBar password: secure_password firstname: Foo lastname: Bar # Create a user with the DN # C(uid=foo,cn=teachers,cn=users,ou=school,dc=school,dc=example,dc=com) - udm_user: name: foo password: secure_password firstname: Foo lastname: Bar ou: school subpath: 'cn=teachers,cn=users' # or define the position - udm_user: name: foo password: secure_password firstname: Foo lastname: Bar position: 'cn=teachers,cn=users,ou=school,dc=school,dc=example,dc=com' ''' RETURN = '''# ''' import crypt from datetime import date, timedelta from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.univention_umc import ( umc_module_for_add, umc_module_for_edit, ldap_search, base_dn, ) def main(): expiry = date.strftime(date.today() + timedelta(days=365), "%Y-%m-%d") module = AnsibleModule( argument_spec=dict( birthday=dict(default=None, type='str'), city=dict(default=None, type='str'), country=dict(default=None, type='str'), department_number=dict(default=None, type='str', aliases=['departmentNumber']), description=dict(default=None, type='str'), display_name=dict(default=None, type='str', aliases=['displayName']), email=dict(default=[''], type='list'), employee_number=dict(default=None, type='str', aliases=['employeeNumber']), employee_type=dict(default=None, type='str', aliases=['employeeType']), firstname=dict(default=None, type='str'), gecos=dict(default=None, type='str'), groups=dict(default=[], type='list'), home_share=dict(default=None, type='str', aliases=['homeShare']), home_share_path=dict(default=None, type='str', aliases=['homeSharePath']), home_telephone_number=dict(default=[], type='list', aliases=['homeTelephoneNumber']), homedrive=dict(default=None, type='str'), lastname=dict(default=None, type='str'), mail_alternative_address=dict(default=[], type='list', aliases=['mailAlternativeAddress']), mail_home_server=dict(default=None, type='str', aliases=['mailHomeServer']), mail_primary_address=dict(default=None, type='str', aliases=['mailPrimaryAddress']), mobile_telephone_number=dict(default=[], type='list', aliases=['mobileTelephoneNumber']), organisation=dict(default=None, type='str', aliases=['organization']), overridePWHistory=dict(default=False, type='bool', aliases=['override_pw_history']), overridePWLength=dict(default=False, type='bool', aliases=['override_pw_length']), pager_telephonenumber=dict(default=[], type='list', aliases=['pagerTelephonenumber']), password=dict(default=None, type='str', no_log=True), phone=dict(default=[], type='list'), postcode=dict(default=None, type='str'), primary_group=dict(default=None, type='str', aliases=['primaryGroup']), profilepath=dict(default=None, type='str'), pwd_change_next_login=dict(default=None, type='str', choices=['0', '1'], aliases=['pwdChangeNextLogin']), room_number=dict(default=None, type='str', aliases=['roomNumber']), samba_privileges=dict(default=[], type='list', aliases=['sambaPrivileges']), samba_user_workstations=dict(default=[], type='list', aliases=['sambaUserWorkstations']), sambahome=dict(default=None, type='str'), scriptpath=dict(default=None, type='str'), secretary=dict(default=[], type='list'), serviceprovider=dict(default=[''], type='list'), shell=dict(default='/bin/bash', type='str'), street=dict(default=None, type='str'), title=dict(default=None, type='str'), unixhome=dict(default=None, type='str'), userexpiry=dict(default=expiry, type='str'), username=dict(required=True, aliases=['name'], type='str'), position=dict(default='', type='str'), update_password=dict(default='always', choices=['always', 'on_create'], type='str'), ou=dict(default='', type='str'), subpath=dict(default='cn=users', type='str'), state=dict(default='present', choices=['present', 'absent'], type='str') ), supports_check_mode=True, required_if=([ ('state', 'present', ['firstname', 'lastname', 'password']) ]) ) username = module.params['username'] position = module.params['position'] ou = module.params['ou'] subpath = module.params['subpath'] state = module.params['state'] changed = False diff = None users = list(ldap_search( '(&(objectClass=posixAccount)(uid={0}))'.format(username), attr=['uid'] )) if position != '': container = position else: if ou != '': ou = 'ou={0},'.format(ou) if subpath != '': subpath = '{0},'.format(subpath) container = '{0}{1}{2}'.format(subpath, ou, base_dn()) user_dn = 'uid={0},{1}'.format(username, container) exists = bool(len(users)) if state == 'present': try: if not exists: obj = umc_module_for_add('users/user', container) else: obj = umc_module_for_edit('users/user', user_dn) if module.params['displayName'] is None: module.params['displayName'] = '{0} {1}'.format( module.params['firstname'], module.params['lastname'] ) if module.params['unixhome'] is None: module.params['unixhome'] = '/home/{0}'.format( module.params['username'] ) for k in obj.keys(): if (k != 'password' and k != 'groups' and k != 'overridePWHistory' and k in module.params and module.params[k] is not None): obj[k] = module.params[k] # handle some special values obj['e-mail'] = module.params['email'] password = module.params['password'] if obj['password'] is None: obj['password'] = password if module.params['update_password'] == 'always': old_password = obj['password'].split('}', 2)[1] if crypt.crypt(password, old_password) != old_password: obj['overridePWHistory'] = module.params['overridePWHistory'] obj['overridePWLength'] = module.params['overridePWLength'] obj['password'] = password diff = obj.diff() if exists: for k in obj.keys(): if obj.hasChanged(k): changed = True else: changed = True if not module.check_mode: if not exists: obj.create() elif changed: obj.modify() except Exception: module.fail_json( msg="Creating/editing user {0} in {1} failed".format( username, container ) ) try: groups = module.params['groups'] if groups: filter = '(&(objectClass=posixGroup)(|(cn={0})))'.format( ')(cn='.join(groups) ) group_dns = list(ldap_search(filter, attr=['dn'])) for dn in group_dns: grp = umc_module_for_edit('groups/group', dn[0]) if user_dn not in grp['users']: grp['users'].append(user_dn) if not module.check_mode: grp.modify() changed = True except Exception: module.fail_json( msg="Adding groups to user {0} failed".format(username) ) if state == 'absent' and exists: try: obj = umc_module_for_edit('users/user', user_dn) if not module.check_mode: obj.remove() changed = True except Exception: module.fail_json( msg="Removing user {0} failed".format(username) ) module.exit_json( changed=changed, username=username, diff=diff, container=container ) if __name__ == '__main__': main()
gpl-3.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 7800, 12, 437, 1587, 262, 374, 5515, 2448, 26787, 199, 3, 377, 2873, 2241, 820, 310, 8716, 13175, 665, 475, 8160, 14, 431, 1086, 13175, 32, 350, 2408, 374, 13, 1786, 923, 14, 335, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 399, 6428, 63, 751, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 2502, 26, 199, 13, 377, 2873, 2241, 820, 17709, 8716, 13175, 8593, 415, 1225, 73, 9, 199, 3612, 63, 1802, 26, 14944, 10694, 4390, 641, 282, 625, 1496, 296, 1970, 7314, 323, 1654, 199, 1802, 26, 272, 446, 298, 2765, 859, 6127, 370, 9635, 10694, 4390, 641, 282, 625, 1496, 296, 1970, 7314, 323, 2126, 1654, 334, 21269, 680, 2126, 2779, 4440, 314, 2366, 3261, 402, 314, 21884, 370, 1218, 282, 892, 909, 503, 5283, 652, 2122, 199, 7538, 26, 272, 446, 2018, 2356, 499, 14, 22, 199, 1419, 26, 272, 1174, 26, 267, 849, 26, 298, 1881, 2, 267, 3415, 26, 359, 3451, 12, 9552, 1622, 267, 1369, 26, 288, 446, 7480, 314, 922, 365, 3451, 503, 440, 14, 272, 3434, 26, 267, 1415, 26, 2549, 267, 1369, 26, 288, 446, 2876, 536, 267, 5481, 26, 788, 354, 418, 272, 1642, 354, 26, 267, 1369, 26, 288, 446, 7758, 536, 14, 11105, 340, 445, 8, 929, 29, 1881, 680, 272, 2061, 354, 26, 267, 1369, 26, 288, 446, 15237, 536, 14, 11105, 340, 445, 8, 929, 29, 1881, 680, 272, 2505, 26, 267, 1369, 26, 288, 446, 13635, 14, 11105, 340, 445, 8, 929, 29, 1881, 680, 272, 21036, 2977, 26, 267, 1369, 26, 288, 446, 699, 8244, 2977, 272, 14492, 26, 267, 1369, 26, 288, 446, 14753, 402, 4390, 26440, 2287, 14, 272, 9023, 26, 267, 1369, 26, 288, 446, 19453, 402, 4390, 26440, 2287, 14, 272, 27669, 63, 1955, 26, 267, 1369, 26, 288, 446, 1487, 12493, 1329, 402, 4390, 26440, 2287, 14, 267, 5481, 26, 359, 27669, 3259, 1622, 272, 1369, 26, 267, 1369, 26, 288, 446, 11994, 334, 1397, 2312, 5197, 9, 272, 2929, 63, 354, 26, 267, 1369, 26, 288, 446, 12175, 536, 334, 1397, 2312, 5197, 9, 267, 5481, 26, 359, 2929, 985, 1622, 272, 3031, 26, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 437, 769, 402, 325, 13, 1198, 7149, 14, 272, 15778, 63, 1955, 26, 267, 1369, 26, 288, 446, 24089, 1329, 267, 5481, 26, 359, 15778, 3259, 1622, 272, 15778, 63, 466, 26, 267, 1369, 26, 288, 446, 24089, 730, 267, 5481, 26, 359, 15778, 804, 1622, 272, 2312, 5197, 26, 267, 1369, 26, 288, 446, 8991, 1439, 51, 272, 4652, 26, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 298, 16399, 4652, 12, 314, 20717, 577, 2438, 402, 314, 4652, 911, 506, 1911, 543, 314, 2049, 20717, 2457, 367, 1924, 1572, 465, 2672, 7823, 26, 2049, 445, 1332, 6, 8, 785, 2543, 29, 9228, 2448, 5130, 6413, 28617, 7823, 430, 17617, 272, 5629, 63, 6251, 26, 267, 1369, 26, 288, 446, 298, 12054, 653, 7079, 8663, 14, 9498, 506, 282, 20717, 24842, 12, 325, 14, 71, 14, 2049, 445, 8, 6413, 29, 4219, 12, 6413, 29, 18318, 12, 810, 29, 23194, 12, 3833, 29, 2694, 12, 3833, 29, 957, 17617, 267, 5481, 26, 359, 5629, 18713, 1622, 272, 5629, 63, 6251, 63, 515, 26, 267, 1369, 26, 288, 446, 6912, 370, 5629, 653, 7079, 8663, 12, 6272, 314, 5629, 18713, 14, 267, 5481, 26, 359, 5629, 18713, 2042, 1622, 272, 5629, 63, 15253, 9339, 63, 1955, 26, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 3820, 402, 5726, 14001, 9339, 5579, 14, 267, 5481, 26, 359, 5629, 24944, 9339, 3259, 1622, 272, 5629, 9541, 26, 267, 1369, 26, 288, 446, 5417, 5629, 12912, 12, 325, 14, 71, 14, 445, 480, 40, 26, 3471, 272, 6016, 63, 19389, 63, 1562, 26, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 3820, 402, 13943, 325, 13, 1198, 7149, 14, 267, 5481, 26, 359, 6016, 19978, 1905, 1476, 1622, 272, 6016, 63, 4219, 63, 1000, 26, 267, 1369, 26, 288, 446, 481, 49, 10872, 402, 6016, 1654, 267, 5481, 26, 359, 6016, 12054, 3120, 1622, 272, 6016, 63, 3327, 63, 1562, 26, 267, 1369, 26, 288, 446, 26710, 325, 13, 1198, 2287, 267, 5481, 26, 359, 6016, 14908, 1476, 1622, 272, 21305, 63, 15253, 9339, 63, 1955, 26, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 29724, 14617, 1329, 267, 5481, 26, 359, 21305, 24944, 9339, 3259, 1622, 272, 5981, 13181, 26, 267, 1369, 26, 288, 446, 13125, 13181, 267, 5481, 26, 359, 13237, 1622, 272, 4278, 63, 8796, 63, 5570, 26, 267, 730, 26, 2155, 267, 849, 26, 283, 889, 7, 267, 1369, 26, 288, 446, 11041, 2505, 7994, 267, 5481, 26, 359, 4278, 48, 9792, 3745, 1622, 272, 4278, 63, 8796, 63, 1267, 26, 267, 730, 26, 2155, 267, 849, 26, 283, 889, 7, 267, 1369, 26, 288, 446, 11041, 2505, 1104, 267, 5481, 26, 359, 4278, 10780, 4625, 1622, 272, 26581, 63, 15253, 838, 265, 287, 884, 26, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 3820, 402, 26581, 14001, 9339, 5579, 14, 267, 5481, 26, 359, 26581, 24944, 838, 265, 287, 884, 1622, 272, 14617, 26, 267, 1369, 26, 288, 446, 3820, 402, 14001, 9339, 5579, 14, 272, 2963, 600, 26, 267, 1369, 26, 288, 446, 7711, 279, 1233, 402, 4390, 26440, 2287, 14, 272, 5062, 63, 923, 26, 267, 849, 26, 20087, 29, 7705, 20123, 12, 6413, 29, 2634, 31891, 19534, 63, 5825, 63, 10872 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 1882, 2803, 26, 9094, 13, 24, 1882, 199, 199, 3, 1898, 26, 334, 67, 9, 7800, 12, 437, 1587, 262, 374, 5515, 2448, 26787, 199, 3, 377, 2873, 2241, 820, 310, 8716, 13175, 665, 475, 8160, 14, 431, 1086, 13175, 32, 350, 2408, 374, 13, 1786, 923, 14, 335, 30, 199, 3, 1664, 1696, 1684, 844, 373, 19, 14, 16, 11, 334, 3239, 9685, 503, 4178, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 15, 11692, 13, 19, 14, 16, 14, 2424, 9, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 12, 4629, 12, 870, 63, 1593, 199, 363, 6577, 363, 275, 730, 421, 199, 8490, 63, 8314, 275, 791, 2343, 63, 1023, 356, 283, 17, 14, 17, 297, 490, 283, 1205, 356, 788, 7780, 995, 490, 283, 4946, 63, 991, 356, 283, 9387, 936, 421, 199, 8948, 275, 1449, 199, 2595, 199, 578, 26, 399, 6428, 63, 751, 199, 1023, 63, 3270, 26, 298, 18, 14, 18, 2, 199, 2502, 26, 199, 13, 377, 2873, 2241, 820, 17709, 8716, 13175, 8593, 415, 1225, 73, 9, 199, 3612, 63, 1802, 26, 14944, 10694, 4390, 641, 282, 625, 1496, 296, 1970, 7314, 323, 1654, 199, 1802, 26, 272, 446, 298, 2765, 859, 6127, 370, 9635, 10694, 4390, 641, 282, 625, 1496, 296, 1970, 7314, 323, 2126, 1654, 334, 21269, 680, 2126, 2779, 4440, 314, 2366, 3261, 402, 314, 21884, 370, 1218, 282, 892, 909, 503, 5283, 652, 2122, 199, 7538, 26, 272, 446, 2018, 2356, 499, 14, 22, 199, 1419, 26, 272, 1174, 26, 267, 849, 26, 298, 1881, 2, 267, 3415, 26, 359, 3451, 12, 9552, 1622, 267, 1369, 26, 288, 446, 7480, 314, 922, 365, 3451, 503, 440, 14, 272, 3434, 26, 267, 1415, 26, 2549, 267, 1369, 26, 288, 446, 2876, 536, 267, 5481, 26, 788, 354, 418, 272, 1642, 354, 26, 267, 1369, 26, 288, 446, 7758, 536, 14, 11105, 340, 445, 8, 929, 29, 1881, 680, 272, 2061, 354, 26, 267, 1369, 26, 288, 446, 15237, 536, 14, 11105, 340, 445, 8, 929, 29, 1881, 680, 272, 2505, 26, 267, 1369, 26, 288, 446, 13635, 14, 11105, 340, 445, 8, 929, 29, 1881, 680, 272, 21036, 2977, 26, 267, 1369, 26, 288, 446, 699, 8244, 2977, 272, 14492, 26, 267, 1369, 26, 288, 446, 14753, 402, 4390, 26440, 2287, 14, 272, 9023, 26, 267, 1369, 26, 288, 446, 19453, 402, 4390, 26440, 2287, 14, 272, 27669, 63, 1955, 26, 267, 1369, 26, 288, 446, 1487, 12493, 1329, 402, 4390, 26440, 2287, 14, 267, 5481, 26, 359, 27669, 3259, 1622, 272, 1369, 26, 267, 1369, 26, 288, 446, 11994, 334, 1397, 2312, 5197, 9, 272, 2929, 63, 354, 26, 267, 1369, 26, 288, 446, 12175, 536, 334, 1397, 2312, 5197, 9, 267, 5481, 26, 359, 2929, 985, 1622, 272, 3031, 26, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 437, 769, 402, 325, 13, 1198, 7149, 14, 272, 15778, 63, 1955, 26, 267, 1369, 26, 288, 446, 24089, 1329, 267, 5481, 26, 359, 15778, 3259, 1622, 272, 15778, 63, 466, 26, 267, 1369, 26, 288, 446, 24089, 730, 267, 5481, 26, 359, 15778, 804, 1622, 272, 2312, 5197, 26, 267, 1369, 26, 288, 446, 8991, 1439, 51, 272, 4652, 26, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 298, 16399, 4652, 12, 314, 20717, 577, 2438, 402, 314, 4652, 911, 506, 1911, 543, 314, 2049, 20717, 2457, 367, 1924, 1572, 465, 2672, 7823, 26, 2049, 445, 1332, 6, 8, 785, 2543, 29, 9228, 2448, 5130, 6413, 28617, 7823, 430, 17617, 272, 5629, 63, 6251, 26, 267, 1369, 26, 288, 446, 298, 12054, 653, 7079, 8663, 14, 9498, 506, 282, 20717, 24842, 12, 325, 14, 71, 14, 2049, 445, 8, 6413, 29, 4219, 12, 6413, 29, 18318, 12, 810, 29, 23194, 12, 3833, 29, 2694, 12, 3833, 29, 957, 17617, 267, 5481, 26, 359, 5629, 18713, 1622, 272, 5629, 63, 6251, 63, 515, 26, 267, 1369, 26, 288, 446, 6912, 370, 5629, 653, 7079, 8663, 12, 6272, 314, 5629, 18713, 14, 267, 5481, 26, 359, 5629, 18713, 2042, 1622, 272, 5629, 63, 15253, 9339, 63, 1955, 26, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 3820, 402, 5726, 14001, 9339, 5579, 14, 267, 5481, 26, 359, 5629, 24944, 9339, 3259, 1622, 272, 5629, 9541, 26, 267, 1369, 26, 288, 446, 5417, 5629, 12912, 12, 325, 14, 71, 14, 445, 480, 40, 26, 3471, 272, 6016, 63, 19389, 63, 1562, 26, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 3820, 402, 13943, 325, 13, 1198, 7149, 14, 267, 5481, 26, 359, 6016, 19978, 1905, 1476, 1622, 272, 6016, 63, 4219, 63, 1000, 26, 267, 1369, 26, 288, 446, 481, 49, 10872, 402, 6016, 1654, 267, 5481, 26, 359, 6016, 12054, 3120, 1622, 272, 6016, 63, 3327, 63, 1562, 26, 267, 1369, 26, 288, 446, 26710, 325, 13, 1198, 2287, 267, 5481, 26, 359, 6016, 14908, 1476, 1622, 272, 21305, 63, 15253, 9339, 63, 1955, 26, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 29724, 14617, 1329, 267, 5481, 26, 359, 21305, 24944, 9339, 3259, 1622, 272, 5981, 13181, 26, 267, 1369, 26, 288, 446, 13125, 13181, 267, 5481, 26, 359, 13237, 1622, 272, 4278, 63, 8796, 63, 5570, 26, 267, 730, 26, 2155, 267, 849, 26, 283, 889, 7, 267, 1369, 26, 288, 446, 11041, 2505, 7994, 267, 5481, 26, 359, 4278, 48, 9792, 3745, 1622, 272, 4278, 63, 8796, 63, 1267, 26, 267, 730, 26, 2155, 267, 849, 26, 283, 889, 7, 267, 1369, 26, 288, 446, 11041, 2505, 1104, 267, 5481, 26, 359, 4278, 10780, 4625, 1622, 272, 26581, 63, 15253, 838, 265, 287, 884, 26, 267, 849, 26, 942, 267, 1369, 26, 288, 446, 3820, 402, 26581, 14001, 9339, 5579, 14, 267, 5481, 26, 359, 26581, 24944, 838, 265, 287, 884, 1622, 272, 14617, 26, 267, 1369, 26, 288, 446, 3820, 402, 14001, 9339, 5579, 14, 272, 2963, 600, 26, 267, 1369, 26, 288, 446, 7711, 279, 1233, 402, 4390, 26440, 2287, 14, 272, 5062, 63, 923, 26, 267, 849, 26, 20087, 29, 7705, 20123, 12, 6413, 29, 2634, 31891, 19534, 63, 5825, 63, 10872, 0 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, 1 ]
jalexvig/tensorflow
tensorflow/python/kernel_tests/matrix_inverse_op_test.py
43
7575
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== """Tests for tensorflow.ops.math_ops.matrix_inverse.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np from tensorflow.python.client import session from tensorflow.python.framework import constant_op from tensorflow.python.framework import ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import linalg_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import random_ops from tensorflow.python.ops import variables from tensorflow.python.platform import test class InverseOpTest(test.TestCase): def _verifyInverse(self, x, np_type): for adjoint in False, True: y = x.astype(np_type) with self.test_session(use_gpu=True): # Verify that x^{-1} * x == Identity matrix. inv = linalg_ops.matrix_inverse(y, adjoint=adjoint) tf_ans = math_ops.matmul(inv, y, adjoint_b=adjoint) np_ans = np.identity(y.shape[-1]) if x.ndim > 2: tiling = list(y.shape) tiling[-2:] = [1, 1] np_ans = np.tile(np_ans, tiling) out = tf_ans.eval() self.assertAllClose(np_ans, out, rtol=1e-4, atol=1e-3) self.assertShapeEqual(y, tf_ans) def _verifyInverseReal(self, x): for np_type in [np.float32, np.float64]: self._verifyInverse(x, np_type) def _verifyInverseComplex(self, x): for np_type in [np.complex64, np.complex128]: self._verifyInverse(x, np_type) def _makeBatch(self, matrix1, matrix2): matrix_batch = np.concatenate( [np.expand_dims(matrix1, 0), np.expand_dims(matrix2, 0)]) matrix_batch = np.tile(matrix_batch, [2, 3, 1, 1]) return matrix_batch def testNonsymmetric(self): # 2x2 matrices matrix1 = np.array([[1., 2.], [3., 4.]]) matrix2 = np.array([[1., 3.], [3., 5.]]) self._verifyInverseReal(matrix1) self._verifyInverseReal(matrix2) # A multidimensional batch of 2x2 matrices self._verifyInverseReal(self._makeBatch(matrix1, matrix2)) # Complex matrix1 = matrix1.astype(np.complex64) matrix1 += 1j * matrix1 matrix2 = matrix2.astype(np.complex64) matrix2 += 1j * matrix2 self._verifyInverseComplex(matrix1) self._verifyInverseComplex(matrix2) # Complex batch self._verifyInverseComplex(self._makeBatch(matrix1, matrix2)) def testSymmetricPositiveDefinite(self): # 2x2 matrices matrix1 = np.array([[2., 1.], [1., 2.]]) matrix2 = np.array([[3., -1.], [-1., 3.]]) self._verifyInverseReal(matrix1) self._verifyInverseReal(matrix2) # A multidimensional batch of 2x2 matrices self._verifyInverseReal(self._makeBatch(matrix1, matrix2)) # Complex matrix1 = matrix1.astype(np.complex64) matrix1 += 1j * matrix1 matrix2 = matrix2.astype(np.complex64) matrix2 += 1j * matrix2 self._verifyInverseComplex(matrix1) self._verifyInverseComplex(matrix2) # Complex batch self._verifyInverseComplex(self._makeBatch(matrix1, matrix2)) def testNonSquareMatrix(self): # When the inverse of a non-square matrix is attempted we should return # an error with self.assertRaises(ValueError): linalg_ops.matrix_inverse(np.array([[1., 2., 3.], [3., 4., 5.]])) def testWrongDimensions(self): # The input to the inverse should be at least a 2-dimensional tensor. tensor3 = constant_op.constant([1., 2.]) with self.assertRaises(ValueError): linalg_ops.matrix_inverse(tensor3) def testNotInvertible(self): # The input should be invertible. with self.test_session(): with self.assertRaisesOpError("Input is not invertible."): # All rows of the matrix below add to zero. tensor3 = constant_op.constant([[1., 0., -1.], [-1., 1., 0.], [0., -1., 1.]]) linalg_ops.matrix_inverse(tensor3).eval() def testEmpty(self): self._verifyInverseReal(np.empty([0, 2, 2])) self._verifyInverseReal(np.empty([2, 0, 0])) def testRandomSmallAndLarge(self): np.random.seed(42) for dtype in np.float32, np.float64, np.complex64, np.complex128: for batch_dims in [(), (1,), (3,), (2, 2)]: for size in 8, 31, 32: shape = batch_dims + (size, size) matrix = np.random.uniform( low=-1.0, high=1.0, size=np.prod(shape)).reshape(shape).astype(dtype) self._verifyInverseReal(matrix) def testConcurrentExecutesWithoutError(self): with self.test_session(use_gpu=True) as sess: all_ops = [] for adjoint_ in True, False: matrix1 = random_ops.random_normal([5, 5], seed=42) matrix2 = random_ops.random_normal([5, 5], seed=42) inv1 = linalg_ops.matrix_inverse(matrix1, adjoint=adjoint_) inv2 = linalg_ops.matrix_inverse(matrix2, adjoint=adjoint_) all_ops += [inv1, inv2] inv = sess.run(all_ops) self.assertAllEqual(inv[0], inv[1]) self.assertAllEqual(inv[2], inv[3]) class MatrixInverseBenchmark(test.Benchmark): shapes = [ (4, 4), (10, 10), (16, 16), (101, 101), (256, 256), (1000, 1000), (1024, 1024), (2048, 2048), (513, 4, 4), (513, 16, 16), (513, 256, 256), ] def _GenerateMatrix(self, shape): batch_shape = shape[:-2] shape = shape[-2:] assert shape[0] == shape[1] n = shape[0] matrix = np.ones(shape).astype(np.float32) / ( 2.0 * n) + np.diag(np.ones(n).astype(np.float32)) return variables.Variable(np.tile(matrix, batch_shape + (1, 1))) def benchmarkMatrixInverseOp(self): for adjoint in False, True: for shape in self.shapes: with ops.Graph().as_default(), \ session.Session() as sess, \ ops.device("/cpu:0"): matrix = self._GenerateMatrix(shape) inv = linalg_ops.matrix_inverse(matrix, adjoint=adjoint) variables.global_variables_initializer().run() self.run_op_benchmark( sess, control_flow_ops.group(inv), min_iters=25, name="matrix_inverse_cpu_{shape}_adjoint_{adjoint}".format( shape=shape, adjoint=adjoint)) if test.is_gpu_available(True): with ops.Graph().as_default(), \ session.Session() as sess, \ ops.device("/gpu:0"): matrix = self._GenerateMatrix(shape) inv = linalg_ops.matrix_inverse(matrix, adjoint=adjoint) variables.global_variables_initializer().run() self.run_op_benchmark( sess, control_flow_ops.group(inv), min_iters=25, name="matrix_inverse_gpu_{shape}_adjoint_{adjoint}".format( shape=shape, adjoint=adjoint)) if __name__ == "__main__": test.main()
apache-2.0
[ 3, 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 3228, 14, 1483, 14, 3442, 63, 1483, 14, 3642, 63, 11668, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 16727, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 1010, 2077, 4619, 774, 8, 396, 14, 1746, 304, 819, 347, 485, 4712, 28274, 8, 277, 12, 671, 12, 980, 63, 466, 304, 272, 367, 24132, 315, 756, 12, 715, 26, 489, 612, 275, 671, 14, 6041, 8, 1590, 63, 466, 9, 489, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 549, 304, 267, 327, 7635, 626, 671, 25997, 17, 93, 627, 671, 508, 22034, 3634, 14, 267, 4572, 275, 16727, 63, 1483, 14, 3642, 63, 11668, 8, 89, 12, 24132, 29, 26055, 9, 267, 2833, 63, 796, 275, 3473, 63, 1483, 14, 14465, 8, 5350, 12, 612, 12, 24132, 63, 66, 29, 26055, 9, 267, 980, 63, 796, 275, 980, 14, 5582, 8, 89, 14, 1392, 1988, 17, 566, 267, 340, 671, 14, 8322, 690, 499, 26, 881, 221, 2270, 316, 275, 769, 8, 89, 14, 1392, 9, 881, 221, 2270, 316, 1988, 18, 2938, 275, 359, 17, 12, 413, 61, 881, 980, 63, 796, 275, 980, 14, 7172, 8, 1590, 63, 796, 12, 221, 2270, 316, 9, 267, 734, 275, 2833, 63, 796, 14, 2579, 342, 267, 291, 14, 7260, 8, 1590, 63, 796, 12, 734, 12, 10561, 29, 17, 69, 13, 20, 12, 9543, 29, 17, 69, 13, 19, 9, 267, 291, 14, 479, 7238, 591, 8, 89, 12, 2833, 63, 796, 9, 819, 347, 485, 4712, 28274, 10099, 8, 277, 12, 671, 304, 272, 367, 980, 63, 466, 315, 359, 1590, 14, 1609, 708, 12, 980, 14, 1609, 772, 2189, 489, 291, 423, 4712, 28274, 8, 88, 12, 980, 63, 466, 9, 819, 347, 485, 4712, 28274, 14500, 8, 277, 12, 671, 304, 272, 367, 980, 63, 466, 315, 359, 1590, 14, 5254, 772, 12, 980, 14, 5254, 3933, 2189, 489, 291, 423, 4712, 28274, 8, 88, 12, 980, 63, 466, 9, 819, 347, 485, 1875, 8842, 8, 277, 12, 3634, 17, 12, 3634, 18, 304, 272, 3634, 63, 2912, 275, 980, 14, 13433, 8, 267, 359, 1590, 14, 4441, 63, 5380, 8, 3642, 17, 12, 378, 395, 268, 980, 14, 4441, 63, 5380, 8, 3642, 18, 12, 378, 3948, 272, 3634, 63, 2912, 275, 980, 14, 7172, 8, 3642, 63, 2912, 12, 359, 18, 12, 650, 12, 413, 12, 413, 566, 272, 372, 3634, 63, 2912, 819, 347, 511, 6932, 18422, 8, 277, 304, 272, 327, 499, 88, 18, 12627, 272, 3634, 17, 275, 980, 14, 1144, 4038, 17, 2020, 499, 8333, 359, 19, 2020, 841, 19450, 272, 3634, 18, 275, 980, 14, 1144, 4038, 17, 2020, 650, 8333, 359, 19, 2020, 959, 19450, 272, 291, 423, 4712, 28274, 10099, 8, 3642, 17, 9, 272, 291, 423, 4712, 28274, 10099, 8, 3642, 18, 9, 272, 327, 437, 3510, 13014, 3522, 402, 499, 88, 18, 12627, 272, 291, 423, 4712, 28274, 10099, 8, 277, 423, 1875, 8842, 8, 3642, 17, 12, 3634, 18, 430, 272, 327, 19178, 272, 3634, 17, 275, 3634, 17, 14, 6041, 8, 1590, 14, 5254, 772, 9, 272, 3634, 17, 847, 413, 74, 627, 3634, 17, 272, 3634, 18, 275, 3634, 18, 14, 6041, 8, 1590, 14, 5254, 772, 9, 272, 3634, 18, 847, 413, 74, 627, 3634, 18, 272, 291, 423, 4712, 28274, 14500, 8, 3642, 17, 9, 272, 291, 423, 4712, 28274, 14500, 8, 3642, 18, 9, 272, 327, 19178, 3522, 272, 291, 423, 4712, 28274, 14500, 8, 277, 423, 1875, 8842, 8, 3642, 17, 12, 3634, 18, 430, 819, 347, 511, 16594, 5165, 6951, 872, 8005, 8, 277, 304, 272, 327, 499, 88, 18, 12627, 272, 3634, 17, 275, 980, 14, 1144, 4038, 18, 2020, 413, 8333, 359, 17, 2020, 499, 19450, 272, 3634, 18, 275, 980, 14, 1144, 4038, 19, 2020, 446, 17, 8333, 5243, 17, 2020, 650, 19450, 272, 291, 423, 4712, 28274, 10099, 8, 3642, 17, 9, 272, 291, 423, 4712, 28274, 10099, 8, 3642, 18, 9, 272, 327, 437, 3510, 13014, 3522, 402, 499, 88, 18, 12627, 272, 291, 423, 4712, 28274, 10099, 8, 277, 423, 1875, 8842, 8, 3642, 17, 12, 3634, 18, 430, 272, 327, 19178, 272, 3634, 17, 275, 3634, 17, 14, 6041, 8, 1590, 14, 5254, 772, 9, 272, 3634, 17, 847, 413, 74, 627, 3634, 17, 272, 3634, 18, 275, 3634, 18, 14, 6041, 8, 1590, 14, 5254, 772, 9, 272, 3634, 18, 847, 413, 74, 627, 3634, 18, 272, 291, 423, 4712, 28274, 14500, 8, 3642, 17, 9, 272, 291, 423, 4712, 28274, 14500, 8, 3642, 18, 9, 272, 327 ]
[ 1898, 6900, 710, 9134, 6642, 14, 2900, 5924, 5702, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 11148, 199, 624, 2925, 367, 3228, 14, 1483, 14, 3442, 63, 1483, 14, 3642, 63, 11668, 1041, 199, 199, 504, 636, 2443, 363, 492, 3679, 63, 646, 199, 504, 636, 2443, 363, 492, 4629, 199, 504, 636, 2443, 363, 492, 870, 63, 1593, 199, 199, 646, 2680, 465, 980, 199, 199, 504, 3228, 14, 1548, 14, 1258, 492, 2351, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4413, 63, 411, 199, 504, 3228, 14, 1548, 14, 4857, 492, 4156, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3304, 63, 1659, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 16727, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 3473, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2196, 63, 1483, 199, 504, 3228, 14, 1548, 14, 1483, 492, 2860, 199, 504, 3228, 14, 1548, 14, 3246, 492, 511, 421, 199, 533, 1010, 2077, 4619, 774, 8, 396, 14, 1746, 304, 819, 347, 485, 4712, 28274, 8, 277, 12, 671, 12, 980, 63, 466, 304, 272, 367, 24132, 315, 756, 12, 715, 26, 489, 612, 275, 671, 14, 6041, 8, 1590, 63, 466, 9, 489, 543, 291, 14, 396, 63, 1730, 8, 1180, 63, 6477, 29, 549, 304, 267, 327, 7635, 626, 671, 25997, 17, 93, 627, 671, 508, 22034, 3634, 14, 267, 4572, 275, 16727, 63, 1483, 14, 3642, 63, 11668, 8, 89, 12, 24132, 29, 26055, 9, 267, 2833, 63, 796, 275, 3473, 63, 1483, 14, 14465, 8, 5350, 12, 612, 12, 24132, 63, 66, 29, 26055, 9, 267, 980, 63, 796, 275, 980, 14, 5582, 8, 89, 14, 1392, 1988, 17, 566, 267, 340, 671, 14, 8322, 690, 499, 26, 881, 221, 2270, 316, 275, 769, 8, 89, 14, 1392, 9, 881, 221, 2270, 316, 1988, 18, 2938, 275, 359, 17, 12, 413, 61, 881, 980, 63, 796, 275, 980, 14, 7172, 8, 1590, 63, 796, 12, 221, 2270, 316, 9, 267, 734, 275, 2833, 63, 796, 14, 2579, 342, 267, 291, 14, 7260, 8, 1590, 63, 796, 12, 734, 12, 10561, 29, 17, 69, 13, 20, 12, 9543, 29, 17, 69, 13, 19, 9, 267, 291, 14, 479, 7238, 591, 8, 89, 12, 2833, 63, 796, 9, 819, 347, 485, 4712, 28274, 10099, 8, 277, 12, 671, 304, 272, 367, 980, 63, 466, 315, 359, 1590, 14, 1609, 708, 12, 980, 14, 1609, 772, 2189, 489, 291, 423, 4712, 28274, 8, 88, 12, 980, 63, 466, 9, 819, 347, 485, 4712, 28274, 14500, 8, 277, 12, 671, 304, 272, 367, 980, 63, 466, 315, 359, 1590, 14, 5254, 772, 12, 980, 14, 5254, 3933, 2189, 489, 291, 423, 4712, 28274, 8, 88, 12, 980, 63, 466, 9, 819, 347, 485, 1875, 8842, 8, 277, 12, 3634, 17, 12, 3634, 18, 304, 272, 3634, 63, 2912, 275, 980, 14, 13433, 8, 267, 359, 1590, 14, 4441, 63, 5380, 8, 3642, 17, 12, 378, 395, 268, 980, 14, 4441, 63, 5380, 8, 3642, 18, 12, 378, 3948, 272, 3634, 63, 2912, 275, 980, 14, 7172, 8, 3642, 63, 2912, 12, 359, 18, 12, 650, 12, 413, 12, 413, 566, 272, 372, 3634, 63, 2912, 819, 347, 511, 6932, 18422, 8, 277, 304, 272, 327, 499, 88, 18, 12627, 272, 3634, 17, 275, 980, 14, 1144, 4038, 17, 2020, 499, 8333, 359, 19, 2020, 841, 19450, 272, 3634, 18, 275, 980, 14, 1144, 4038, 17, 2020, 650, 8333, 359, 19, 2020, 959, 19450, 272, 291, 423, 4712, 28274, 10099, 8, 3642, 17, 9, 272, 291, 423, 4712, 28274, 10099, 8, 3642, 18, 9, 272, 327, 437, 3510, 13014, 3522, 402, 499, 88, 18, 12627, 272, 291, 423, 4712, 28274, 10099, 8, 277, 423, 1875, 8842, 8, 3642, 17, 12, 3634, 18, 430, 272, 327, 19178, 272, 3634, 17, 275, 3634, 17, 14, 6041, 8, 1590, 14, 5254, 772, 9, 272, 3634, 17, 847, 413, 74, 627, 3634, 17, 272, 3634, 18, 275, 3634, 18, 14, 6041, 8, 1590, 14, 5254, 772, 9, 272, 3634, 18, 847, 413, 74, 627, 3634, 18, 272, 291, 423, 4712, 28274, 14500, 8, 3642, 17, 9, 272, 291, 423, 4712, 28274, 14500, 8, 3642, 18, 9, 272, 327, 19178, 3522, 272, 291, 423, 4712, 28274, 14500, 8, 277, 423, 1875, 8842, 8, 3642, 17, 12, 3634, 18, 430, 819, 347, 511, 16594, 5165, 6951, 872, 8005, 8, 277, 304, 272, 327, 499, 88, 18, 12627, 272, 3634, 17, 275, 980, 14, 1144, 4038, 18, 2020, 413, 8333, 359, 17, 2020, 499, 19450, 272, 3634, 18, 275, 980, 14, 1144, 4038, 19, 2020, 446, 17, 8333, 5243, 17, 2020, 650, 19450, 272, 291, 423, 4712, 28274, 10099, 8, 3642, 17, 9, 272, 291, 423, 4712, 28274, 10099, 8, 3642, 18, 9, 272, 327, 437, 3510, 13014, 3522, 402, 499, 88, 18, 12627, 272, 291, 423, 4712, 28274, 10099, 8, 277, 423, 1875, 8842, 8, 3642, 17, 12, 3634, 18, 430, 272, 327, 19178, 272, 3634, 17, 275, 3634, 17, 14, 6041, 8, 1590, 14, 5254, 772, 9, 272, 3634, 17, 847, 413, 74, 627, 3634, 17, 272, 3634, 18, 275, 3634, 18, 14, 6041, 8, 1590, 14, 5254, 772, 9, 272, 3634, 18, 847, 413, 74, 627, 3634, 18, 272, 291, 423, 4712, 28274, 14500, 8, 3642, 17, 9, 272, 291, 423, 4712, 28274, 14500, 8, 3642, 18, 9, 272, 327, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
billbrod/spatial-frequency-preferences
sfp/image_computable.py
1
6815
#!/usr/bin/python """code to help run the image-computable version of the model we're using this primarily to check the effect of vignetting, but this does make our project image-computable (though it's a linear model and so will fail in some trivial cases) """ import itertools import argparse import numpy as np import pandas as pd import pyrtools as pt from scipy import interpolate def upsample(signal, target_shape): """upsample a signal to target_shape this uses scipy's interpolate.interp2d (and so will end up with a smoothed signal) """ x = np.linspace(-(signal.shape[0]-1)/2, (signal.shape[0]-1)/2, num=signal.shape[0]) y = np.linspace(-(signal.shape[1]-1)/2, (signal.shape[1]-1)/2, num=signal.shape[1]) f = interpolate.interp2d(x, y, signal) x = np.linspace(-(signal.shape[0]-1)/2, (signal.shape[0]-1)/2, num=target_shape[0]) y = np.linspace(-(signal.shape[1]-1)/2, (signal.shape[1]-1)/2, num=target_shape[1]) return f(x,y) def calc_energy_and_filters(stim, stim_df, n_orientations=6, save_path_template=None): """this creates the energy and filter arrays We assume the stimuli have natural groups, here indexed by the "class_idx" column in stim_df, and all stimuli within these groups should be considered the same stimuli, that is, we sum the energy across all of them. for the spatial frequency project, these are the different phases of the gratings (because of how we structure our experiment, we estimate a response amplitude to all phases together). Note that this will take a while to run (~10 or 20 minutes). Since it only needs to run once per experiment, didn't bother to make it efficient at all. The outputs will also be very large, totalling about 11GB Parameters ---------- stim : np.ndarray The stimuli to produce energy for. Should have shape (n, *img_size), where n is the number of total stimuli. stim_df : pd.DataFrame The DataFrame describing the stimuli. Must contain the column "class_idx", which indexes the different stimulus classes (see above) n_orientations : int the number of orientations in the steerable pyramid. 6 is the number used to model fMRI voxels in Roth, Z. N., Heeger, D., & Merriam, E. (2018). Stimulus vignetting and orientation selectivity in human visual cortex. bioRxiv. save_path_template : str or None the template string for the save path we'll use for energy and filters. should end in .npy and contain one %s, which we'll replace with "energy" and "filters". Returns ------- energy : np.ndarray energy has shape (stim_df.class_idx.nunique(), max_ht, n_orientations, *img_size) and contains the energy (square and absolute value the complex valued output of SteerablePyramidFreq; equivalently, square and sum the output of the quadrature pair of filters that make up the pyramid) for each image, at each scale and orientation. the energy has all been upsampled to the size of the initial image. filters : np.ndarray filters has shape (max_ht, n_orientations, *img_size) and is the fourier transform of the filters at each scale and orientation, zero-padded so they all have the same size. we only have one set of filters (instead of one per stimulus class) because the same pyramid was used for each of them; we ensure this by getting the filters for each stimulus class and checking that they're individually equal to the average across classes. """ img_size = stim.shape[1:] # this computation comes from the SteerablePyramidFreq code max_ht = int(np.floor(np.log2(min(img_size))) - 2) energy = np.zeros((stim_df.class_idx.nunique(), max_ht, n_orientations, *img_size), dtype=np.float32) filters = np.zeros_like(energy) for i, g in stim_df.groupby('class_idx'): idx = g.index filled_filters = False for j in idx: pyr = pt.pyramids.SteerablePyramidFreq(stim[j], order=n_orientations-1, is_complex=True) for k, l in itertools.product(range(max_ht), range(n_orientations)): energy[int(i), k, l, :, :] += upsample(np.abs(pyr.pyr_coeffs[(k, l)])**2, img_size) # we only want to run this once per stimulus class if not filled_filters: if k > 0: lomask = pyr._lomasks[k-1] else: lomask = pyr._lo0mask filt = pyr._anglemasks[k][l] * pyr._himasks[k] * lomask pad_num = [] for m in range(2): pad_num.append([(img_size[m] - filt.shape[m])//2, (img_size[m] - filt.shape[m])//2]) if filt.shape[m] + 2*pad_num[m][0] != img_size[m]: pad_num[m][0] += img_size[m] - (filt.shape[m] + 2*pad_num[m][0]) filters[int(i), k, l, :, :] = np.pad(filt, pad_num, 'constant', constant_values=0) filled_filters = True filter_mean = np.mean(filters, 0) for i in range(filters.shape[0]): if not(np.allclose(filter_mean, filters[i,:,:,:,:])): raise Exception("Something has gone terribly wrong, the filters for stim class %d are different than the rest!" % i) filters = filter_mean if save_path_template is not None: np.save(save_path_template % "energy", energy) np.save(save_path_template % "filters", filters) return energy, filters if __name__ == '__main__': parser = argparse.ArgumentParser( description=("Calculate and save the energy for each stimulus class, as well as the Fourier" " transform of the filters of the steerable pyramid we use to get this. For " "use with image-computable version of this model"), formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("stimuli", help=("Path to the stimulus .npy file.")) parser.add_argument("stimuli_description_df", help=("Path to the stimulus description dataframe .csv file.")) parser.add_argument("save_path_template", help=("Path template (with .npy extension) where we'll save the results. " "Should contain one %s.")) parser.add_argument('--n_orientations', '-n', default=6, type=int, help=("The number of orientations in the steerable pyramid used here.")) args = vars(parser.parse_args()) stim = np.load(args.pop('stimuli')) stim_df = pd.read_csv(args.pop('stimuli_description_df')) calc_energy_and_filters(stim, stim_df, **args)
mit
[ 3381, 2647, 15, 1393, 15, 1548, 199, 624, 600, 370, 1720, 1255, 314, 1834, 13, 863, 2964, 1015, 402, 314, 1402, 199, 199, 1129, 3984, 1808, 642, 1979, 30468, 370, 1104, 314, 7763, 402, 373, 528, 846, 1337, 12, 1325, 642, 1630, 1852, 4154, 2199, 199, 1569, 13, 863, 2964, 334, 15401, 652, 1159, 282, 7798, 1402, 436, 880, 911, 2449, 315, 2005, 28586, 5560, 9, 199, 199, 624, 199, 646, 7975, 199, 646, 7534, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 646, 1134, 82, 2537, 465, 10063, 199, 504, 7026, 492, 28884, 421, 199, 318, 1536, 3271, 8, 4653, 12, 1347, 63, 1392, 304, 272, 408, 384, 3271, 282, 4673, 370, 1347, 63, 1392, 339, 642, 4440, 7026, 1159, 28884, 14, 14252, 18, 68, 334, 460, 880, 911, 1284, 1536, 543, 282, 19608, 379, 4673, 9, 272, 408, 272, 671, 275, 980, 14, 11649, 2801, 8, 4653, 14, 1392, 59, 16, 11285, 17, 2447, 18, 12, 334, 4653, 14, 1392, 59, 16, 11285, 17, 2447, 18, 12, 1967, 29, 4653, 14, 1392, 59, 16, 566, 272, 612, 275, 980, 14, 11649, 2801, 8, 4653, 14, 1392, 59, 17, 11285, 17, 2447, 18, 12, 334, 4653, 14, 1392, 59, 17, 11285, 17, 2447, 18, 12, 1967, 29, 4653, 14, 1392, 59, 17, 566, 272, 289, 275, 28884, 14, 14252, 18, 68, 8, 88, 12, 612, 12, 4673, 9, 272, 671, 275, 980, 14, 11649, 2801, 8, 4653, 14, 1392, 59, 16, 11285, 17, 2447, 18, 12, 334, 4653, 14, 1392, 59, 16, 11285, 17, 2447, 18, 12, 1967, 29, 1375, 63, 1392, 59, 16, 566, 272, 612, 275, 980, 14, 11649, 2801, 8, 4653, 14, 1392, 59, 17, 11285, 17, 2447, 18, 12, 334, 4653, 14, 1392, 59, 17, 11285, 17, 2447, 18, 12, 1967, 29, 1375, 63, 1392, 59, 17, 566, 272, 372, 289, 8, 88, 12, 89, 9, 421, 199, 318, 12831, 63, 8443, 63, 460, 63, 4273, 8, 31739, 12, 29965, 63, 1587, 12, 302, 63, 19676, 1298, 29, 22, 12, 3354, 63, 515, 63, 1160, 29, 403, 304, 272, 408, 3749, 8491, 314, 12304, 436, 2457, 6572, 339, 2136, 5534, 314, 29965, 13987, 1172, 19981, 4652, 12, 2348, 15235, 701, 314, 298, 533, 63, 2996, 2, 2763, 315, 29965, 63, 1587, 12, 272, 436, 1006, 29965, 13987, 4453, 3520, 4652, 1077, 506, 8652, 314, 2011, 29965, 13987, 12, 626, 365, 12, 781, 3089, 314, 272, 12304, 9371, 1006, 402, 3062, 14, 367, 314, 11469, 9857, 2199, 12, 3520, 787, 314, 3365, 22587, 402, 272, 314, 7192, 292, 780, 334, 20684, 402, 4212, 781, 5523, 4154, 11805, 12, 781, 14497, 282, 1177, 30727, 370, 272, 1006, 22587, 10451, 680, 339, 3390, 626, 642, 911, 5452, 282, 1830, 370, 1255, 31742, 709, 503, 3388, 9395, 680, 9336, 652, 1454, 4839, 370, 1255, 5403, 272, 1126, 11805, 12, 9980, 1133, 26962, 370, 1852, 652, 13402, 737, 1006, 14, 710, 4704, 911, 2597, 506, 7437, 7031, 12, 272, 12657, 26039, 3595, 4119, 6487, 339, 3897, 272, 4143, 272, 29965, 520, 980, 14, 8237, 267, 710, 29965, 13987, 370, 7389, 12304, 367, 14, 7719, 1172, 2215, 334, 78, 12, 627, 4060, 63, 890, 395, 2382, 302, 365, 314, 1329, 4960, 402, 3141, 29965, 13987, 14, 272, 29965, 63, 1587, 520, 6454, 14, 9205, 267, 710, 10071, 13660, 314, 29965, 13987, 14, 9498, 1395, 314, 2763, 298, 533, 63, 2996, 401, 1314, 10507, 4960, 314, 3365, 29965, 15909, 3992, 334, 3239, 3432, 9, 272, 302, 63, 19676, 1298, 520, 1109, 267, 314, 1329, 402, 25626, 1298, 315, 314, 20345, 281, 461, 30704, 14, 1227, 365, 314, 1329, 1202, 370, 1402, 289, 45, 6129, 267, 14164, 88, 18099, 315, 6848, 273, 12, 3107, 14, 653, 2020, 869, 1024, 836, 12, 577, 2020, 1253, 18880, 322, 455, 12, 662, 14, 334, 12682, 680, 428, 2906, 15909, 373, 528, 846, 1337, 436, 4960, 16774, 542, 10251, 4191, 315, 11779, 13104, 1970, 3858, 14, 28897, 13840, 1003, 14, 272, 3354, 63, 515, 63, 1160, 520, 620, 503, 488, 267, 314, 1978, 1059, 367, 314, 3354, 931, 781, 7171, 675, 367, 12304, 436, 4766, 14, 1077, 1284, 315, 1275, 20245, 4960, 436, 1395, 1373, 450, 83, 12, 1314, 781, 7171, 3350, 543, 298, 8443, 2, 436, 298, 4273, 1674, 339, 1803, 272, 5514, 272, 12304, 520, 980, 14, 8237, 267, 12304, 965, 2215, 334, 31739, 63, 1587, 14, 533, 63, 2996, 14, 78, 3235, 1062, 1390, 63, 517, 12, 302, 63, 19676, 1298, 12, 627, 4060, 63, 890, 9, 436, 4960, 3509, 314, 12304, 334, 9646, 436, 3679, 574, 314, 6114, 574, 68, 1072, 402, 4960, 17854, 281, 461, 2713, 20785, 13875, 27, 7353, 590, 12, 12386, 436, 3089, 314, 1072, 402, 314, 16744, 30985, 4092, 402, 4960, 4766, 626, 1852, 1536, 314, 30704, 9, 367, 1924, 1834, 12, 737, 1924, 4666, 436, 16774, 14, 314, 12304, 267, 965, 1006, 2757, 1536, 25042, 370, 314, 1568, 402, 314, 2536, 1834, 14, 272, 4766, 520, 980, 14, 8237, 267, 4766, 965, 2215, 334, 988, 63, 517, 12, 302, 63, 19676, 1298, 12, 627, 4060, 63, 890, 9, 436, 365, 314, 11648, 4446, 5793, 402, 314, 4960, 4766, 737, 1924, 4666, 436, 16774, 12, 4697, 13, 25201, 880, 2985, 1006, 1172, 314, 2011, 1568, 14, 781, 1454, 4960, 1172, 1373, 663, 402, 4766, 334, 23145, 402, 1373, 1126, 29965, 15909, 1021, 9, 2952, 314, 2011, 30704, 1990, 4960, 1202, 367, 1924, 402, 3062, 27, 781, 4868, 642, 701, 10232, 314, 4766, 367, 1924, 29965, 15909, 1021, 436, 4960, 7907, 626, 2985, 3984, 7814, 3163, 4472, 370, 314, 8095, 9371, 3992, 14, 339, 408, 272, 6050, 63, 890, 275, 29965, 14, 1392, 59, 17, 2938, 272, 327, 642, 14009, 12477, 687, 314, 17854, 281, 461, 2713, 20785, 13875, 1233, 272, 1390, 63, 517, 275, 1109, 8, 1590, 14, 11289, 8, 1590, 14, 793, 18, 8, 827, 8, 4060, 63, 890, 1724, 446, 499, 9, 272, 12304, 275, 980, 14, 4250, 1332, 31739, 63, 1587, 14, 533, 63, 2996, 14, 78, 3235, 1062, 1390, 63, 517, 12, 302, 63, 19676, 1298, 12, 627, 4060, 63, 890, 395, 1993, 2152, 29, 1590, 14, 1609, 708, 9, 272, 4766, 275, 980, 14, 4250 ]
[ 2647, 15, 1393, 15, 1548, 199, 624, 600, 370, 1720, 1255, 314, 1834, 13, 863, 2964, 1015, 402, 314, 1402, 199, 199, 1129, 3984, 1808, 642, 1979, 30468, 370, 1104, 314, 7763, 402, 373, 528, 846, 1337, 12, 1325, 642, 1630, 1852, 4154, 2199, 199, 1569, 13, 863, 2964, 334, 15401, 652, 1159, 282, 7798, 1402, 436, 880, 911, 2449, 315, 2005, 28586, 5560, 9, 199, 199, 624, 199, 646, 7975, 199, 646, 7534, 199, 646, 2680, 465, 980, 199, 646, 10634, 465, 6454, 199, 646, 1134, 82, 2537, 465, 10063, 199, 504, 7026, 492, 28884, 421, 199, 318, 1536, 3271, 8, 4653, 12, 1347, 63, 1392, 304, 272, 408, 384, 3271, 282, 4673, 370, 1347, 63, 1392, 339, 642, 4440, 7026, 1159, 28884, 14, 14252, 18, 68, 334, 460, 880, 911, 1284, 1536, 543, 282, 19608, 379, 4673, 9, 272, 408, 272, 671, 275, 980, 14, 11649, 2801, 8, 4653, 14, 1392, 59, 16, 11285, 17, 2447, 18, 12, 334, 4653, 14, 1392, 59, 16, 11285, 17, 2447, 18, 12, 1967, 29, 4653, 14, 1392, 59, 16, 566, 272, 612, 275, 980, 14, 11649, 2801, 8, 4653, 14, 1392, 59, 17, 11285, 17, 2447, 18, 12, 334, 4653, 14, 1392, 59, 17, 11285, 17, 2447, 18, 12, 1967, 29, 4653, 14, 1392, 59, 17, 566, 272, 289, 275, 28884, 14, 14252, 18, 68, 8, 88, 12, 612, 12, 4673, 9, 272, 671, 275, 980, 14, 11649, 2801, 8, 4653, 14, 1392, 59, 16, 11285, 17, 2447, 18, 12, 334, 4653, 14, 1392, 59, 16, 11285, 17, 2447, 18, 12, 1967, 29, 1375, 63, 1392, 59, 16, 566, 272, 612, 275, 980, 14, 11649, 2801, 8, 4653, 14, 1392, 59, 17, 11285, 17, 2447, 18, 12, 334, 4653, 14, 1392, 59, 17, 11285, 17, 2447, 18, 12, 1967, 29, 1375, 63, 1392, 59, 17, 566, 272, 372, 289, 8, 88, 12, 89, 9, 421, 199, 318, 12831, 63, 8443, 63, 460, 63, 4273, 8, 31739, 12, 29965, 63, 1587, 12, 302, 63, 19676, 1298, 29, 22, 12, 3354, 63, 515, 63, 1160, 29, 403, 304, 272, 408, 3749, 8491, 314, 12304, 436, 2457, 6572, 339, 2136, 5534, 314, 29965, 13987, 1172, 19981, 4652, 12, 2348, 15235, 701, 314, 298, 533, 63, 2996, 2, 2763, 315, 29965, 63, 1587, 12, 272, 436, 1006, 29965, 13987, 4453, 3520, 4652, 1077, 506, 8652, 314, 2011, 29965, 13987, 12, 626, 365, 12, 781, 3089, 314, 272, 12304, 9371, 1006, 402, 3062, 14, 367, 314, 11469, 9857, 2199, 12, 3520, 787, 314, 3365, 22587, 402, 272, 314, 7192, 292, 780, 334, 20684, 402, 4212, 781, 5523, 4154, 11805, 12, 781, 14497, 282, 1177, 30727, 370, 272, 1006, 22587, 10451, 680, 339, 3390, 626, 642, 911, 5452, 282, 1830, 370, 1255, 31742, 709, 503, 3388, 9395, 680, 9336, 652, 1454, 4839, 370, 1255, 5403, 272, 1126, 11805, 12, 9980, 1133, 26962, 370, 1852, 652, 13402, 737, 1006, 14, 710, 4704, 911, 2597, 506, 7437, 7031, 12, 272, 12657, 26039, 3595, 4119, 6487, 339, 3897, 272, 4143, 272, 29965, 520, 980, 14, 8237, 267, 710, 29965, 13987, 370, 7389, 12304, 367, 14, 7719, 1172, 2215, 334, 78, 12, 627, 4060, 63, 890, 395, 2382, 302, 365, 314, 1329, 4960, 402, 3141, 29965, 13987, 14, 272, 29965, 63, 1587, 520, 6454, 14, 9205, 267, 710, 10071, 13660, 314, 29965, 13987, 14, 9498, 1395, 314, 2763, 298, 533, 63, 2996, 401, 1314, 10507, 4960, 314, 3365, 29965, 15909, 3992, 334, 3239, 3432, 9, 272, 302, 63, 19676, 1298, 520, 1109, 267, 314, 1329, 402, 25626, 1298, 315, 314, 20345, 281, 461, 30704, 14, 1227, 365, 314, 1329, 1202, 370, 1402, 289, 45, 6129, 267, 14164, 88, 18099, 315, 6848, 273, 12, 3107, 14, 653, 2020, 869, 1024, 836, 12, 577, 2020, 1253, 18880, 322, 455, 12, 662, 14, 334, 12682, 680, 428, 2906, 15909, 373, 528, 846, 1337, 436, 4960, 16774, 542, 10251, 4191, 315, 11779, 13104, 1970, 3858, 14, 28897, 13840, 1003, 14, 272, 3354, 63, 515, 63, 1160, 520, 620, 503, 488, 267, 314, 1978, 1059, 367, 314, 3354, 931, 781, 7171, 675, 367, 12304, 436, 4766, 14, 1077, 1284, 315, 1275, 20245, 4960, 436, 1395, 1373, 450, 83, 12, 1314, 781, 7171, 3350, 543, 298, 8443, 2, 436, 298, 4273, 1674, 339, 1803, 272, 5514, 272, 12304, 520, 980, 14, 8237, 267, 12304, 965, 2215, 334, 31739, 63, 1587, 14, 533, 63, 2996, 14, 78, 3235, 1062, 1390, 63, 517, 12, 302, 63, 19676, 1298, 12, 627, 4060, 63, 890, 9, 436, 4960, 3509, 314, 12304, 334, 9646, 436, 3679, 574, 314, 6114, 574, 68, 1072, 402, 4960, 17854, 281, 461, 2713, 20785, 13875, 27, 7353, 590, 12, 12386, 436, 3089, 314, 1072, 402, 314, 16744, 30985, 4092, 402, 4960, 4766, 626, 1852, 1536, 314, 30704, 9, 367, 1924, 1834, 12, 737, 1924, 4666, 436, 16774, 14, 314, 12304, 267, 965, 1006, 2757, 1536, 25042, 370, 314, 1568, 402, 314, 2536, 1834, 14, 272, 4766, 520, 980, 14, 8237, 267, 4766, 965, 2215, 334, 988, 63, 517, 12, 302, 63, 19676, 1298, 12, 627, 4060, 63, 890, 9, 436, 365, 314, 11648, 4446, 5793, 402, 314, 4960, 4766, 737, 1924, 4666, 436, 16774, 12, 4697, 13, 25201, 880, 2985, 1006, 1172, 314, 2011, 1568, 14, 781, 1454, 4960, 1172, 1373, 663, 402, 4766, 334, 23145, 402, 1373, 1126, 29965, 15909, 1021, 9, 2952, 314, 2011, 30704, 1990, 4960, 1202, 367, 1924, 402, 3062, 27, 781, 4868, 642, 701, 10232, 314, 4766, 367, 1924, 29965, 15909, 1021, 436, 4960, 7907, 626, 2985, 3984, 7814, 3163, 4472, 370, 314, 8095, 9371, 3992, 14, 339, 408, 272, 6050, 63, 890, 275, 29965, 14, 1392, 59, 17, 2938, 272, 327, 642, 14009, 12477, 687, 314, 17854, 281, 461, 2713, 20785, 13875, 1233, 272, 1390, 63, 517, 275, 1109, 8, 1590, 14, 11289, 8, 1590, 14, 793, 18, 8, 827, 8, 4060, 63, 890, 1724, 446, 499, 9, 272, 12304, 275, 980, 14, 4250, 1332, 31739, 63, 1587, 14, 533, 63, 2996, 14, 78, 3235, 1062, 1390, 63, 517, 12, 302, 63, 19676, 1298, 12, 627, 4060, 63, 890, 395, 1993, 2152, 29, 1590, 14, 1609, 708, 9, 272, 4766, 275, 980, 14, 4250, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ritchyteam/odoo
addons/point_of_sale/wizard/pos_confirm.py
343
2403
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## from openerp.osv import osv class pos_confirm(osv.osv_memory): _name = 'pos.confirm' _description = 'Post POS Journal Entries' def action_confirm(self, cr, uid, ids, context=None): order_obj = self.pool.get('pos.order') ids = order_obj.search(cr, uid, [('state','=','paid')], context=context) for order in order_obj.browse(cr, uid, ids, context=context): todo = True for line in order.statement_ids: if line.statement_id.state != 'confirm': todo = False break if todo: order.signal_workflow('done') # Check if there is orders to reconcile their invoices ids = order_obj.search(cr, uid, [('state','=','invoiced'),('invoice_id.state','=','open')], context=context) for order in order_obj.browse(cr, uid, ids, context=context): invoice = order.invoice_id data_lines = [x.id for x in invoice.move_id.line_id if x.account_id.id == invoice.account_id.id] for st in order.statement_ids: for move in st.move_ids: data_lines += [x.id for x in move.line_id if x.account_id.id == invoice.account_id.id] self.pool.get('account.move.line').reconcile(cr, uid, data_lines, context=context) return {} # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
agpl-3.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9506, 421, 199, 533, 2086, 63, 9548, 8, 4795, 14, 4795, 63, 4844, 304, 272, 485, 354, 275, 283, 1712, 14, 9548, 7, 272, 485, 1802, 275, 283, 6564, 510, 3100, 22142, 23450, 1996, 7, 339, 347, 1595, 63, 9548, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 1865, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 1712, 14, 1648, 358, 267, 2762, 275, 1865, 63, 1113, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 929, 1673, 29511, 16555, 2665, 1067, 29, 1100, 9, 267, 367, 1865, 315, 1865, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 11386, 275, 715, 288, 367, 1004, 315, 1865, 14, 6242, 63, 1580, 26, 355, 340, 1004, 14, 6242, 63, 344, 14, 929, 1137, 283, 9548, 356, 490, 11386, 275, 756, 490, 2059, 288, 340, 11386, 26, 355, 1865, 14, 4653, 63, 8856, 360, 4456, 358, 398, 327, 2670, 340, 2337, 365, 15460, 370, 26053, 441, 3932, 26175, 267, 2762, 275, 1865, 63, 1113, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 929, 1673, 29511, 25614, 8157, 5404, 63, 344, 14, 929, 1673, 29511, 1490, 2665, 1067, 29, 1100, 9, 267, 367, 1865, 315, 1865, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 8485, 275, 1865, 14, 5404, 63, 344, 288, 666, 63, 1278, 275, 359, 88, 14, 344, 367, 671, 315, 8485, 14, 1185, 63, 344, 14, 604, 63, 344, 340, 671, 14, 2048, 63, 344, 14, 344, 508, 8485, 14, 2048, 63, 344, 14, 344, 61, 288, 367, 410, 315, 1865, 14, 6242, 63, 1580, 26, 355, 367, 4057, 315, 410, 14, 1185, 63, 1580, 26, 490, 666, 63, 1278, 847, 359, 88, 14, 344, 367, 671, 315, 4057, 14, 604, 63, 344, 340, 671, 14, 2048, 63, 344, 14, 344, 508, 8485, 14, 2048, 63, 344, 14, 344, 61, 490, 291, 14, 2293, 14, 362, 360, 2048, 14, 1185, 14, 604, 1959, 18403, 8, 1556, 12, 1747, 12, 666, 63, 1278, 12, 1067, 29, 1100, 9, 267, 372, 1052, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 4605, 199, 3, 199, 3, 259, 7653, 12, 3232, 5800, 8259, 9274, 199, 3, 259, 1898, 334, 35, 9, 8353, 13, 6542, 11947, 12361, 8642, 1014, 921, 9864, 14, 1235, 10121, 199, 3, 199, 3, 259, 961, 2240, 365, 2867, 2032, 26, 1265, 883, 3604, 652, 436, 15, 269, 2811, 199, 3, 259, 652, 1334, 314, 2895, 402, 314, 1664, 4265, 1696, 1684, 844, 465, 199, 3, 259, 3267, 701, 314, 2868, 2290, 2752, 12, 1902, 1015, 650, 402, 314, 199, 3, 259, 844, 12, 503, 334, 292, 2195, 945, 9, 1263, 2945, 1015, 14, 199, 3, 199, 3, 259, 961, 2240, 365, 1854, 315, 314, 3661, 626, 652, 911, 506, 2997, 12, 199, 3, 259, 1325, 2428, 1821, 3408, 27, 1928, 2755, 314, 2478, 3750, 402, 199, 3, 259, 3169, 503, 3092, 2381, 437, 3115, 3104, 14, 221, 1666, 314, 199, 3, 259, 1664, 4265, 1696, 1684, 844, 367, 1655, 2436, 14, 199, 3, 199, 3, 259, 2047, 1077, 1172, 3086, 282, 1331, 402, 314, 1664, 4265, 1696, 1684, 844, 199, 3, 259, 3180, 543, 642, 2240, 14, 221, 982, 440, 12, 1937, 665, 1014, 921, 1544, 14, 3689, 14, 1308, 15, 2383, 4743, 199, 3, 199, 4605, 199, 199, 504, 5166, 14, 4795, 492, 9506, 421, 199, 533, 2086, 63, 9548, 8, 4795, 14, 4795, 63, 4844, 304, 272, 485, 354, 275, 283, 1712, 14, 9548, 7, 272, 485, 1802, 275, 283, 6564, 510, 3100, 22142, 23450, 1996, 7, 339, 347, 1595, 63, 9548, 8, 277, 12, 2467, 12, 1747, 12, 2762, 12, 1067, 29, 403, 304, 267, 1865, 63, 1113, 275, 291, 14, 2293, 14, 362, 360, 1712, 14, 1648, 358, 267, 2762, 275, 1865, 63, 1113, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 929, 1673, 29511, 16555, 2665, 1067, 29, 1100, 9, 267, 367, 1865, 315, 1865, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 11386, 275, 715, 288, 367, 1004, 315, 1865, 14, 6242, 63, 1580, 26, 355, 340, 1004, 14, 6242, 63, 344, 14, 929, 1137, 283, 9548, 356, 490, 11386, 275, 756, 490, 2059, 288, 340, 11386, 26, 355, 1865, 14, 4653, 63, 8856, 360, 4456, 358, 398, 327, 2670, 340, 2337, 365, 15460, 370, 26053, 441, 3932, 26175, 267, 2762, 275, 1865, 63, 1113, 14, 1733, 8, 1556, 12, 1747, 12, 4274, 929, 1673, 29511, 25614, 8157, 5404, 63, 344, 14, 929, 1673, 29511, 1490, 2665, 1067, 29, 1100, 9, 267, 367, 1865, 315, 1865, 63, 1113, 14, 4570, 8, 1556, 12, 1747, 12, 2762, 12, 1067, 29, 1100, 304, 288, 8485, 275, 1865, 14, 5404, 63, 344, 288, 666, 63, 1278, 275, 359, 88, 14, 344, 367, 671, 315, 8485, 14, 1185, 63, 344, 14, 604, 63, 344, 340, 671, 14, 2048, 63, 344, 14, 344, 508, 8485, 14, 2048, 63, 344, 14, 344, 61, 288, 367, 410, 315, 1865, 14, 6242, 63, 1580, 26, 355, 367, 4057, 315, 410, 14, 1185, 63, 1580, 26, 490, 666, 63, 1278, 847, 359, 88, 14, 344, 367, 671, 315, 4057, 14, 604, 63, 344, 340, 671, 14, 2048, 63, 344, 14, 344, 508, 8485, 14, 2048, 63, 344, 14, 344, 61, 490, 291, 14, 2293, 14, 362, 360, 2048, 14, 1185, 14, 604, 1959, 18403, 8, 1556, 12, 1747, 12, 666, 63, 1278, 12, 1067, 29, 1100, 9, 267, 372, 1052, 199, 199, 3, 6695, 26, 10379, 26, 10558, 26, 6492, 29, 20, 26, 10503, 29, 20, 26, 10425, 29, 20, 26, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
Bysmyyr/chromium-crosswalk
content/test/gpu/gpu_tests/gpu_test_base.py
19
6203
# Copyright 2015 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import logging from telemetry import benchmark as benchmark_module from telemetry.page import page as page_module from telemetry.page import page_test from telemetry.page import shared_page_state as shared_page_state_module from telemetry.testing import fakes from gpu_tests import exception_formatter from gpu_tests import gpu_test_expectations class TestBase(benchmark_module.Benchmark): """Base classes for all GPU tests in this directory. Implements support for per-page test expectations.""" def __init__(self, max_failures=None): super(TestBase, self).__init__(max_failures=max_failures) self._cached_expectations = None def GetExpectations(self): """Returns the expectations that apply to this test.""" if not self._cached_expectations: self._cached_expectations = self._CreateExpectations() if not isinstance(self._cached_expectations, gpu_test_expectations.GpuTestExpectations): raise Exception('gpu_test_base requires use of GpuTestExpectations') return self._cached_expectations def _CreateExpectations(self): # By default, creates an empty GpuTestExpectations object. Override # this in subclasses to set up test-specific expectations. Must # return an instance of GpuTestExpectations or a subclass. # # Do not call this directly. Call GetExpectations where necessary. return gpu_test_expectations.GpuTestExpectations() # Provides a single subclass of PageTest in case it's useful in the # future. class ValidatorBase(page_test.PageTest): def __init__(self, needs_browser_restart_after_each_page=False, clear_cache_before_each_run=False): super(ValidatorBase, self).__init__( needs_browser_restart_after_each_page=\ needs_browser_restart_after_each_page, clear_cache_before_each_run=clear_cache_before_each_run) def ValidateAndMeasurePage(self, page, tab, result): pass def _CanRunOnBrowser(browser_info, page): expectations = page.GetExpectations() return expectations.GetExpectationForPage( browser_info.browser, page) != 'skip' def RunStoryWithRetries(cls, shared_page_state, results): page = shared_page_state.current_page expectations = page.GetExpectations() expectation = 'pass' if expectations: expectation = expectations.GetExpectationForPage( shared_page_state.browser, page) if expectation == 'skip': raise Exception( 'Skip expectations should have been handled in CanRunOnBrowser') try: super(cls, shared_page_state).RunStory(results) except Exception: if expectation == 'pass': raise elif expectation == 'fail': msg = 'Expected exception while running %s' % page.display_name exception_formatter.PrintFormattedException(msg=msg) return if expectation != 'flaky': logging.warning( 'Unknown expectation %s while handling exception for %s', expectation, page.display_name) raise # Flaky tests are handled here. num_retries = expectations.GetFlakyRetriesForPage( shared_page_state.browser, page) if not num_retries: # Re-raise the exception. raise # Re-run the test up to |num_retries| times. for ii in xrange(0, num_retries): print 'FLAKY TEST FAILURE, retrying: ' + page.display_name try: super(cls, shared_page_state).RunStory(results) break except Exception: # Squelch any exceptions from any but the last retry. if ii == num_retries - 1: raise else: if expectation == 'fail': logging.warning( '%s was expected to fail, but passed.\n', page.display_name) class GpuSharedPageState(shared_page_state_module.SharedPageState): def CanRunOnBrowser(self, browser_info, page): return _CanRunOnBrowser(browser_info, page) def RunStory(self, results): RunStoryWithRetries(GpuSharedPageState, self, results) # TODO(kbr): re-evaluate the need for this SharedPageState # subclass. It's only used by the WebGL conformance suite. class DesktopGpuSharedPageState( shared_page_state_module.SharedDesktopPageState): def CanRunOnBrowser(self, browser_info, page): return _CanRunOnBrowser(browser_info, page) def RunStory(self, results): RunStoryWithRetries(DesktopGpuSharedPageState, self, results) class FakeGpuSharedPageState(fakes.FakeSharedPageState): def CanRunOnBrowser(self, browser_info, page): return _CanRunOnBrowser(browser_info, page) def RunStory(self, results): RunStoryWithRetries(FakeGpuSharedPageState, self, results) class PageBase(page_module.Page): # The convention is that pages subclassing this class must be # configured with the test expectations. def __init__(self, url, page_set=None, base_dir=None, name='', shared_page_state_class=GpuSharedPageState, make_javascript_deterministic=True, expectations=None): super(PageBase, self).__init__( url=url, page_set=page_set, base_dir=base_dir, name=name, shared_page_state_class=shared_page_state_class, make_javascript_deterministic=make_javascript_deterministic) # Disable automatic garbage collection to reduce the test's cycle time. self._collect_garbage_before_run = False # TODO(kbr): this is fragile -- if someone needs to independently # derive a new independent SharedPageState subclass which handles # skip expectations, this code will have to be updated. assert issubclass( shared_page_state_class, (GpuSharedPageState, DesktopGpuSharedPageState, FakeGpuSharedPageState)), \ 'shared_page_state_class must be one which handles skip expectations' # TODO(kbr): this is fragile -- if someone changes the # shared_page_state_class to something that doesn't handle skip # expectations, then they'll hit the exception in # RunStoryWithRetries, above. Need to rethink. self._expectations = expectations def GetExpectations(self): return self._expectations
bsd-3-clause
[ 3, 1898, 6900, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2050, 199, 199, 504, 17298, 492, 12338, 465, 12338, 63, 578, 199, 504, 17298, 14, 1606, 492, 2034, 465, 2034, 63, 578, 199, 504, 17298, 14, 1606, 492, 2034, 63, 396, 199, 504, 17298, 14, 1606, 492, 5709, 63, 1606, 63, 929, 465, 5709, 63, 1606, 63, 929, 63, 578, 199, 504, 17298, 14, 4776, 492, 14063, 199, 199, 504, 21758, 63, 2219, 492, 1919, 63, 8911, 199, 504, 21758, 63, 2219, 492, 21758, 63, 396, 63, 15752, 199, 199, 533, 1379, 1563, 8, 11861, 63, 578, 14, 18644, 304, 523, 408, 1563, 3992, 367, 1006, 18613, 2295, 315, 642, 2082, 14, 24664, 523, 2291, 367, 1126, 13, 1606, 511, 21851, 1041, 819, 347, 636, 826, 721, 277, 12, 1390, 63, 9968, 29, 403, 304, 272, 1613, 8, 14440, 12, 291, 2843, 826, 721, 988, 63, 9968, 29, 988, 63, 9968, 9, 272, 291, 423, 5245, 63, 15752, 275, 488, 819, 347, 2372, 31323, 8, 277, 304, 272, 408, 3407, 314, 21851, 626, 4838, 370, 642, 511, 1041, 272, 340, 440, 291, 423, 5245, 63, 15752, 26, 489, 291, 423, 5245, 63, 15752, 275, 291, 423, 2499, 31323, 342, 272, 340, 440, 1228, 8, 277, 423, 5245, 63, 15752, 12, 1993, 21758, 63, 396, 63, 15752, 14, 39, 3165, 774, 31323, 304, 489, 746, 2186, 360, 6477, 63, 396, 63, 1095, 5074, 675, 402, 598, 3165, 774, 31323, 358, 272, 372, 291, 423, 5245, 63, 15752, 819, 347, 485, 2499, 31323, 8, 277, 304, 272, 327, 4885, 849, 12, 8491, 376, 2701, 598, 3165, 774, 31323, 909, 14, 11041, 272, 327, 642, 315, 9180, 370, 663, 1536, 511, 13, 6100, 21851, 14, 9498, 272, 327, 372, 376, 1256, 402, 598, 3165, 774, 31323, 503, 282, 5516, 14, 272, 327, 272, 327, 4226, 440, 1240, 642, 5370, 14, 6523, 2372, 31323, 2382, 5784, 14, 272, 372, 21758, 63, 396, 63, 15752, 14, 39, 3165, 774, 31323, 342, 421, 199, 3, 21552, 282, 2849, 5516, 402, 10331, 774, 315, 1930, 652, 1159, 2997, 315, 314, 199, 3, 6466, 14, 199, 533, 4821, 707, 1563, 8, 1606, 63, 396, 14, 3276, 774, 304, 523, 347, 636, 826, 721, 277, 12, 2049, 4839, 63, 5750, 63, 10506, 63, 4399, 63, 10885, 63, 1606, 29, 797, 12, 2049, 5436, 63, 1637, 63, 5182, 63, 10885, 63, 1065, 29, 797, 304, 272, 1613, 8, 8640, 1563, 12, 291, 2843, 826, 721, 489, 4839, 63, 5750, 63, 10506, 63, 4399, 63, 10885, 63, 1606, 9529, 267, 4839, 63, 5750, 63, 10506, 63, 4399, 63, 10885, 63, 1606, 12, 489, 5436, 63, 1637, 63, 5182, 63, 10885, 63, 1065, 29, 3584, 63, 1637, 63, 5182, 63, 10885, 63, 1065, 9, 819, 347, 12134, 3325, 18611, 3276, 8, 277, 12, 2034, 12, 5174, 12, 754, 304, 272, 986, 199, 199, 318, 485, 6049, 2540, 3314, 11930, 8, 5750, 63, 815, 12, 2034, 304, 523, 21851, 275, 2034, 14, 1002, 31323, 342, 523, 372, 21851, 14, 1002, 13495, 425, 1858, 3276, 8, 272, 7042, 63, 815, 14, 5750, 12, 2034, 9, 1137, 283, 2759, 7, 199, 199, 318, 3378, 25120, 3007, 32720, 8, 1886, 12, 5709, 63, 1606, 63, 929, 12, 2058, 304, 523, 2034, 275, 5709, 63, 1606, 63, 929, 14, 1818, 63, 1606, 523, 21851, 275, 2034, 14, 1002, 31323, 342, 523, 17513, 275, 283, 1529, 7, 523, 340, 21851, 26, 272, 17513, 275, 21851, 14, 1002, 13495, 425, 1858, 3276, 8, 489, 5709, 63, 1606, 63, 929, 14, 5750, 12, 2034, 9, 523, 340, 17513, 508, 283, 2759, 356, 272, 746, 2186, 8, 489, 283, 7738, 21851, 1077, 1172, 2757, 8860, 315, 6855, 2540, 3314, 11930, 358, 523, 862, 26, 272, 1613, 8, 1886, 12, 5709, 63, 1606, 63, 929, 680, 2540, 25120, 8, 2604, 9, 523, 871, 2186, 26, 272, 340, 17513, 508, 283, 1529, 356, 489, 746, 272, 916, 17513, 508, 283, 1633, 356, 489, 1499, 275, 283, 6964, 1919, 1830, 3879, 450, 83, 7, 450, 2034, 14, 2918, 63, 354, 489, 1919, 63, 8911, 14, 5375, 31602, 1726, 8, 1328, 29, 1328, 9, 489, 372, 272, 340, 17513, 1137, 283, 14163, 10562, 356, 489, 2050, 14, 3764, 8, 267, 283, 5912, 17513, 450, 83, 1830, 7252, 1919, 367, 450, 83, 297, 267, 17513, 12, 2034, 14, 2918, 63, 354, 9, 489, 746, 272, 327, 481, 416, 10562, 2295, 787, 8860, 2348, 14, 272, 1967, 63, 10937, 275, 21851, 14, 1002, 38, 416, 10562, 32720, 1858, 3276, 8, 489, 5709, 63, 1606, 63, 929, 14, 5750, 12, 2034, 9, 272, 340, 440, 1967, 63, 10937, 26, 489, 327, 799, 13, 3730, 314, 1919, 14, 489, 746, 272, 327, 799, 13, 1065, 314, 511, 1536, 370, 1204, 1507, 63, 10937, 92, 5431, 14, 272, 367, 15393, 315, 4945, 8, 16, 12, 1967, 63, 10937, 304, 489, 870, 283, 3143, 7872, 57, 7393, 10341, 3942, 12, 7269, 316, 26, 283, 435, 2034, 14, 2918, 63, 354, 489, 862, 26, 267, 1613, 8, 1886, 12, 5709, 63, 1606, 63, 929, 680, 2540, 25120, 8, 2604, 9, 267, 2059, 489, 871, 2186, 26, 267, 327, 428, 544, 76, 335, 1263, 4967, 687, 1263, 1325, 314, 2061, 7269, 14, 267, 340, 15393, 508, 1967, 63, 10937, 446, 413, 26, 881, 746, 523, 587, 26, 272, 340, 17513, 508, 283, 1633, 356, 489, 2050, 14, 3764, 8, 881, 1543, 83, 1990, 1420, 370, 2449, 12, 1325, 3032, 3134, 78, 297, 2034, 14, 2918, 63, 354, 9, 199, 199, 533, 598, 3165, 12197, 3276, 2223, 8, 5555, 63, 1606, 63, 929, 63, 578, 14, 12197, 3276, 2223, 304, 523, 347, 6855, 2540, 3314, 11930, 8, 277, 12, 7042, 63, 815, 12, 2034, 304, 272, 372, 485, 6049, 2540, 3314, 11930, 8, 5750, 63, 815, 12, 2034, 9, 819, 347, 3378, 25120, 8, 277, 12, 2058, 304, 272, 3378, 25120, 3007, 32720, 8, 39, 3165, 12197, 3276, 2223, 12, 291, 12, 2058, 9, 421, 199, 3, 3254, 8, 75, 3289, 304, 295, 13, 7383, 314, 1929, 367 ]
[ 1898, 6900, 710, 12051, 6642, 14, 2900, 4481, 4644, 14, 199, 3, 3645, 402, 642, 1350, 1233, 365, 10413, 701, 282, 6289, 13, 2487, 4190, 626, 883, 506, 199, 3, 1911, 315, 314, 5113, 570, 14, 199, 199, 646, 2050, 199, 199, 504, 17298, 492, 12338, 465, 12338, 63, 578, 199, 504, 17298, 14, 1606, 492, 2034, 465, 2034, 63, 578, 199, 504, 17298, 14, 1606, 492, 2034, 63, 396, 199, 504, 17298, 14, 1606, 492, 5709, 63, 1606, 63, 929, 465, 5709, 63, 1606, 63, 929, 63, 578, 199, 504, 17298, 14, 4776, 492, 14063, 199, 199, 504, 21758, 63, 2219, 492, 1919, 63, 8911, 199, 504, 21758, 63, 2219, 492, 21758, 63, 396, 63, 15752, 199, 199, 533, 1379, 1563, 8, 11861, 63, 578, 14, 18644, 304, 523, 408, 1563, 3992, 367, 1006, 18613, 2295, 315, 642, 2082, 14, 24664, 523, 2291, 367, 1126, 13, 1606, 511, 21851, 1041, 819, 347, 636, 826, 721, 277, 12, 1390, 63, 9968, 29, 403, 304, 272, 1613, 8, 14440, 12, 291, 2843, 826, 721, 988, 63, 9968, 29, 988, 63, 9968, 9, 272, 291, 423, 5245, 63, 15752, 275, 488, 819, 347, 2372, 31323, 8, 277, 304, 272, 408, 3407, 314, 21851, 626, 4838, 370, 642, 511, 1041, 272, 340, 440, 291, 423, 5245, 63, 15752, 26, 489, 291, 423, 5245, 63, 15752, 275, 291, 423, 2499, 31323, 342, 272, 340, 440, 1228, 8, 277, 423, 5245, 63, 15752, 12, 1993, 21758, 63, 396, 63, 15752, 14, 39, 3165, 774, 31323, 304, 489, 746, 2186, 360, 6477, 63, 396, 63, 1095, 5074, 675, 402, 598, 3165, 774, 31323, 358, 272, 372, 291, 423, 5245, 63, 15752, 819, 347, 485, 2499, 31323, 8, 277, 304, 272, 327, 4885, 849, 12, 8491, 376, 2701, 598, 3165, 774, 31323, 909, 14, 11041, 272, 327, 642, 315, 9180, 370, 663, 1536, 511, 13, 6100, 21851, 14, 9498, 272, 327, 372, 376, 1256, 402, 598, 3165, 774, 31323, 503, 282, 5516, 14, 272, 327, 272, 327, 4226, 440, 1240, 642, 5370, 14, 6523, 2372, 31323, 2382, 5784, 14, 272, 372, 21758, 63, 396, 63, 15752, 14, 39, 3165, 774, 31323, 342, 421, 199, 3, 21552, 282, 2849, 5516, 402, 10331, 774, 315, 1930, 652, 1159, 2997, 315, 314, 199, 3, 6466, 14, 199, 533, 4821, 707, 1563, 8, 1606, 63, 396, 14, 3276, 774, 304, 523, 347, 636, 826, 721, 277, 12, 2049, 4839, 63, 5750, 63, 10506, 63, 4399, 63, 10885, 63, 1606, 29, 797, 12, 2049, 5436, 63, 1637, 63, 5182, 63, 10885, 63, 1065, 29, 797, 304, 272, 1613, 8, 8640, 1563, 12, 291, 2843, 826, 721, 489, 4839, 63, 5750, 63, 10506, 63, 4399, 63, 10885, 63, 1606, 9529, 267, 4839, 63, 5750, 63, 10506, 63, 4399, 63, 10885, 63, 1606, 12, 489, 5436, 63, 1637, 63, 5182, 63, 10885, 63, 1065, 29, 3584, 63, 1637, 63, 5182, 63, 10885, 63, 1065, 9, 819, 347, 12134, 3325, 18611, 3276, 8, 277, 12, 2034, 12, 5174, 12, 754, 304, 272, 986, 199, 199, 318, 485, 6049, 2540, 3314, 11930, 8, 5750, 63, 815, 12, 2034, 304, 523, 21851, 275, 2034, 14, 1002, 31323, 342, 523, 372, 21851, 14, 1002, 13495, 425, 1858, 3276, 8, 272, 7042, 63, 815, 14, 5750, 12, 2034, 9, 1137, 283, 2759, 7, 199, 199, 318, 3378, 25120, 3007, 32720, 8, 1886, 12, 5709, 63, 1606, 63, 929, 12, 2058, 304, 523, 2034, 275, 5709, 63, 1606, 63, 929, 14, 1818, 63, 1606, 523, 21851, 275, 2034, 14, 1002, 31323, 342, 523, 17513, 275, 283, 1529, 7, 523, 340, 21851, 26, 272, 17513, 275, 21851, 14, 1002, 13495, 425, 1858, 3276, 8, 489, 5709, 63, 1606, 63, 929, 14, 5750, 12, 2034, 9, 523, 340, 17513, 508, 283, 2759, 356, 272, 746, 2186, 8, 489, 283, 7738, 21851, 1077, 1172, 2757, 8860, 315, 6855, 2540, 3314, 11930, 358, 523, 862, 26, 272, 1613, 8, 1886, 12, 5709, 63, 1606, 63, 929, 680, 2540, 25120, 8, 2604, 9, 523, 871, 2186, 26, 272, 340, 17513, 508, 283, 1529, 356, 489, 746, 272, 916, 17513, 508, 283, 1633, 356, 489, 1499, 275, 283, 6964, 1919, 1830, 3879, 450, 83, 7, 450, 2034, 14, 2918, 63, 354, 489, 1919, 63, 8911, 14, 5375, 31602, 1726, 8, 1328, 29, 1328, 9, 489, 372, 272, 340, 17513, 1137, 283, 14163, 10562, 356, 489, 2050, 14, 3764, 8, 267, 283, 5912, 17513, 450, 83, 1830, 7252, 1919, 367, 450, 83, 297, 267, 17513, 12, 2034, 14, 2918, 63, 354, 9, 489, 746, 272, 327, 481, 416, 10562, 2295, 787, 8860, 2348, 14, 272, 1967, 63, 10937, 275, 21851, 14, 1002, 38, 416, 10562, 32720, 1858, 3276, 8, 489, 5709, 63, 1606, 63, 929, 14, 5750, 12, 2034, 9, 272, 340, 440, 1967, 63, 10937, 26, 489, 327, 799, 13, 3730, 314, 1919, 14, 489, 746, 272, 327, 799, 13, 1065, 314, 511, 1536, 370, 1204, 1507, 63, 10937, 92, 5431, 14, 272, 367, 15393, 315, 4945, 8, 16, 12, 1967, 63, 10937, 304, 489, 870, 283, 3143, 7872, 57, 7393, 10341, 3942, 12, 7269, 316, 26, 283, 435, 2034, 14, 2918, 63, 354, 489, 862, 26, 267, 1613, 8, 1886, 12, 5709, 63, 1606, 63, 929, 680, 2540, 25120, 8, 2604, 9, 267, 2059, 489, 871, 2186, 26, 267, 327, 428, 544, 76, 335, 1263, 4967, 687, 1263, 1325, 314, 2061, 7269, 14, 267, 340, 15393, 508, 1967, 63, 10937, 446, 413, 26, 881, 746, 523, 587, 26, 272, 340, 17513, 508, 283, 1633, 356, 489, 2050, 14, 3764, 8, 881, 1543, 83, 1990, 1420, 370, 2449, 12, 1325, 3032, 3134, 78, 297, 2034, 14, 2918, 63, 354, 9, 199, 199, 533, 598, 3165, 12197, 3276, 2223, 8, 5555, 63, 1606, 63, 929, 63, 578, 14, 12197, 3276, 2223, 304, 523, 347, 6855, 2540, 3314, 11930, 8, 277, 12, 7042, 63, 815, 12, 2034, 304, 272, 372, 485, 6049, 2540, 3314, 11930, 8, 5750, 63, 815, 12, 2034, 9, 819, 347, 3378, 25120, 8, 277, 12, 2058, 304, 272, 3378, 25120, 3007, 32720, 8, 39, 3165, 12197, 3276, 2223, 12, 291, 12, 2058, 9, 421, 199, 3, 3254, 8, 75, 3289, 304, 295, 13, 7383, 314, 1929, 367, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
GoogleCloudPlatform/python-compat-runtime
appengine-compat/exported_appengine_sdk/google/appengine/ext/mapreduce/api/map_job/map_job_control.py
10
7129
#!/usr/bin/env python # # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # """User API for controlling Map job execution.""" from google.appengine.api import taskqueue from google.appengine.datastore import datastore_rpc from google.appengine.ext import db from google.appengine.ext.mapreduce import model from google.appengine.ext.mapreduce import util from google.appengine.ext.mapreduce.api.map_job import map_job_config class Job(object): """The job submitter's view of the job. The class allows user to submit a job, control a submitted job, query its state and result. """ RUNNING = "running" FAILED = model.MapreduceState.RESULT_FAILED ABORTED = model.MapreduceState.RESULT_ABORTED SUCCESS = model.MapreduceState.RESULT_SUCCESS STATUS_ENUM = [RUNNING, FAILED, ABORTED, SUCCESS] def __init__(self, state=None): """Init the job instance representing the job with id job_id. Do not directly call this method. Use class methods to construct new instances. Args: state: model.MapreduceState. """ self._state = state self.job_config = map_job_config.JobConfig._to_map_job_config( state.mapreduce_spec, queue_name=state.mapreduce_spec.params.get("queue_name")) @classmethod def get_job_by_id(cls, job_id=None): """Gets the job instance representing the job with id job_id. Args: job_id: a job id, job_config.job_id, of a submitted job. Returns: A Job instance for job_id. """ state = cls.__get_state_by_id(job_id) return cls(state) def get_status(self): """Get status enum. Returns: One of the status enum. """ self.__update_state() if self._state.active: return self.RUNNING else: return self._state.result_status def abort(self): """Aborts the job.""" model.MapreduceControl.abort(self.job_config.job_id) def get_counters(self): """Get counters from this job. When a job is running, counter values won't be very accurate. Returns: An iterator that returns (counter_name, value) pairs of type (basestring, int) """ self.__update_state() return self._state.counters_map.counters.iteritems() def get_counter(self, counter_name, default=0): """Get the value of the named counter from this job. When a job is running, counter values won't be very accurate. Args: counter_name: name of the counter in string. default: default value if the counter doesn't exist. Returns: Value in int of the named counter. """ self.__update_state() return self._state.counters_map.get(counter_name, default) def get_outputs(self): """Get outputs of this job. Should only call if status is SUCCESS. Yields: Iterators, one for each shard. Each iterator is from the argument of map_job.output_writer.commit_output. """ assert self.SUCCESS == self.get_status() ss = model.ShardState.find_all_by_mapreduce_state(self._state) for s in ss: yield iter(s.writer_state.get("outs", [])) @classmethod def submit(cls, job_config, in_xg_transaction=False): """Submit the job to run. Args: job_config: an instance of map_job.MapJobConfig. in_xg_transaction: controls what transaction scope to use to start this MR job. If True, there has to be an already opened cross-group transaction scope. MR will use one entity group from it. If False, MR will create an independent transaction to start the job regardless of any existing transaction scopes. Returns: a Job instance representing the submitted job. """ cls.__validate_job_config(job_config) mapper_spec = job_config._get_mapper_spec() mapreduce_params = job_config._get_mr_params() mapreduce_spec = model.MapreduceSpec( job_config.job_name, job_config.job_id, mapper_spec.to_json(), mapreduce_params, util._obj_to_path(job_config._hooks_cls)) if in_xg_transaction: propagation = db.MANDATORY else: propagation = db.INDEPENDENT state = None @db.transactional(propagation=propagation) def _txn(): state = cls.__create_and_save_state(job_config, mapreduce_spec) cls.__add_kickoff_task(job_config, mapreduce_spec) return state state = _txn() return cls(state) def __update_state(self): """Fetches most up to date state from db.""" if self._state.active: self._state = self.__get_state_by_id(self.job_config.job_id) @classmethod def __get_state_by_id(cls, job_id): """Get job state by id. Args: job_id: job id. Returns: model.MapreduceState for the job. Raises: ValueError: if the job state is missing. """ state = model.MapreduceState.get_by_job_id(job_id) if state is None: raise ValueError("Job state for job %s is missing." % job_id) return state @classmethod def __validate_job_config(cls, job_config): job_config.input_reader_cls.validate(job_config) if job_config.output_writer_cls: job_config.output_writer_cls.validate(job_config._get_mapper_spec()) @classmethod def __create_and_save_state(cls, job_config, mapreduce_spec): """Save map job state to datastore. Save state to datastore so that UI can see it immediately. Args: job_config: map_job.JobConfig. mapreduce_spec: model.MapreduceSpec. Returns: model.MapreduceState for this job. """ state = model.MapreduceState.create_new(job_config.job_id) state.mapreduce_spec = mapreduce_spec state.active = True state.active_shards = 0 state.app_id = job_config._app config = datastore_rpc.Configuration(force_writes=job_config._force_writes) state.put(config=config) return state @classmethod def __add_kickoff_task(cls, job_config, mapreduce_spec): """Add kickoff task to taskqueue. Args: job_config: map_job.JobConfig. mapreduce_spec: model.MapreduceSpec, """ params = {"mapreduce_id": job_config.job_id} kickoff_task = taskqueue.Task( url=job_config._base_path + "/kickoffjob_callback/" + job_config.job_id, headers=util._get_task_headers(job_config.job_id), params=params) if job_config._hooks_cls: hooks = job_config._hooks_cls(mapreduce_spec) try: hooks.enqueue_kickoff_task(kickoff_task, job_config.queue_name) return except NotImplementedError: pass kickoff_task.add(job_config.queue_name, transactional=True)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 10219, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 624, 1899, 3261, 367, 30350, 9672, 3906, 6451, 1041, 199, 199, 504, 6233, 14, 15358, 14, 1246, 492, 2120, 1825, 199, 504, 6233, 14, 15358, 14, 11450, 492, 12007, 63, 4354, 199, 504, 6233, 14, 15358, 14, 832, 492, 1592, 199, 504, 6233, 14, 15358, 14, 832, 14, 28658, 492, 1402, 199, 504, 6233, 14, 15358, 14, 832, 14, 28658, 492, 4884, 199, 504, 6233, 14, 15358, 14, 832, 14, 28658, 14, 1246, 14, 1130, 63, 2423, 492, 2341, 63, 2423, 63, 888, 28154, 199, 533, 15057, 8, 785, 304, 523, 408, 1918, 3906, 11482, 351, 1159, 2455, 402, 314, 3906, 14, 819, 710, 1021, 6127, 922, 370, 11482, 282, 3906, 12, 3304, 282, 16930, 3906, 12, 523, 1827, 2399, 1174, 436, 754, 14, 523, 408, 819, 21277, 6024, 275, 298, 5720, 2, 523, 26892, 275, 1402, 14, 2956, 5270, 2223, 14, 9517, 63, 12299, 523, 14840, 2596, 1149, 275, 1402, 14, 2956, 5270, 2223, 14, 9517, 63, 27113, 1149, 523, 28364, 275, 1402, 14, 2956, 5270, 2223, 14, 9517, 63, 12779, 819, 18460, 63, 17563, 275, 359, 17305, 12, 26892, 12, 14840, 2596, 1149, 12, 28364, 61, 819, 347, 636, 826, 721, 277, 12, 1174, 29, 403, 304, 272, 408, 9346, 314, 3906, 1256, 6144, 314, 3906, 543, 1305, 3906, 63, 344, 14, 339, 4226, 440, 5370, 1240, 642, 1083, 14, 3645, 1021, 3102, 370, 6982, 272, 892, 4454, 14, 339, 3033, 26, 489, 1174, 26, 1402, 14, 2956, 5270, 2223, 14, 272, 408, 272, 291, 423, 929, 275, 1174, 339, 291, 14, 2423, 63, 888, 275, 2341, 63, 2423, 63, 888, 14, 6694, 2028, 423, 475, 63, 1130, 63, 2423, 63, 888, 8, 267, 1174, 14, 28658, 63, 1650, 12, 267, 4126, 63, 354, 29, 929, 14, 28658, 63, 1650, 14, 1162, 14, 362, 480, 1825, 63, 354, 2237, 819, 768, 3744, 523, 347, 664, 63, 2423, 63, 991, 63, 344, 8, 1886, 12, 3906, 63, 344, 29, 403, 304, 272, 408, 14426, 314, 3906, 1256, 6144, 314, 3906, 543, 1305, 3906, 63, 344, 14, 339, 3033, 26, 489, 3906, 63, 344, 26, 282, 3906, 1305, 12, 3906, 63, 888, 14, 2423, 63, 344, 12, 402, 282, 16930, 3906, 14, 339, 1803, 26, 489, 437, 15057, 1256, 367, 3906, 63, 344, 14, 272, 408, 272, 1174, 275, 843, 855, 362, 63, 929, 63, 991, 63, 344, 8, 2423, 63, 344, 9, 272, 372, 843, 8, 929, 9, 819, 347, 664, 63, 1205, 8, 277, 304, 272, 408, 1002, 2004, 4952, 14, 339, 1803, 26, 489, 7309, 402, 314, 2004, 4952, 14, 272, 408, 272, 291, 855, 873, 63, 929, 342, 272, 340, 291, 423, 929, 14, 2682, 26, 489, 372, 291, 14, 17305, 272, 587, 26, 489, 372, 291, 423, 929, 14, 1099, 63, 1205, 819, 347, 12004, 8, 277, 304, 272, 408, 16682, 83, 314, 3906, 1041, 272, 1402, 14, 2956, 5270, 3717, 14, 13845, 8, 277, 14, 2423, 63, 888, 14, 2423, 63, 344, 9, 819, 347, 664, 63, 16558, 8, 277, 304, 272, 408, 1002, 21272, 687, 642, 3906, 14, 339, 3979, 282, 3906, 365, 3879, 12, 7055, 1338, 7859, 1133, 506, 7437, 23189, 14, 339, 1803, 26, 489, 1626, 6122, 626, 2529, 334, 5337, 63, 354, 12, 574, 9, 6342, 402, 730, 489, 334, 17628, 12, 1109, 9, 272, 408, 272, 291, 855, 873, 63, 929, 342, 272, 372, 291, 423, 929, 14, 16558, 63, 1130, 14, 16558, 14, 4611, 342, 819, 347, 664, 63, 5337, 8, 277, 12, 7055, 63, 354, 12, 849, 29, 16, 304, 272, 408, 1002, 314, 574, 402, 314, 4310, 7055, 687, 642, 3906, 14, 339, 3979, 282, 3906, 365, 3879, 12, 7055, 1338, 7859, 1133, 506, 7437, 23189, 14, 339, 3033, 26, 489, 7055, 63, 354, 26, 536, 402, 314, 7055, 315, 1059, 14, 489, 849, 26, 849, 574, 340, 314, 7055, 3181, 1133, 2187, 14, 339, 1803, 26, 489, 1594, 315, 1109, 402, 314, 4310, 7055, 14, 272, 408, 272, 291, 855, 873, 63, 929, 342, 272, 372, 291, 423, 929, 14, 16558, 63, 1130, 14, 362, 8, 5337, 63, 354, 12, 849, 9, 819, 347, 664, 63, 4467, 8, 277, 304, 272, 408, 1002, 4704, 402, 642, 3906, 14, 339, 7719, 1454, 1240, 340, 2004, 365, 28364, 14, 339, 23771, 83, 26, 489, 11953, 2750, 12, 1373, 367, 1924, 11814, 14, 7048, 6122, 365, 489, 687, 314, 1423, 402, 2341, 63, 2423, 14, 1199, 63, 5491, 14, 3543, 63, 1199, 14, 272, 408, 272, 702, 291, 14, 12779, 508, 291, 14, 362, 63, 1205, 342, 272, 10110, 275, 1402, 14, 20019, 2223, 14, 1623, 63, 452, 63, 991, 63, 28658, 63, 929, 8, 277, 423, 929, 9, 272, 367, 308, 315, 10110, 26, 489, 1995, 2740, 8, 83, 14, 5491, 63, 929, 14, 362, 480, 16816, 401, 15927, 819, 768, 3744, 523, 347, 11482, 8, 1886, 12, 3906, 63, 888, 12, 315, 63, 88, 71, 63, 5945, 29, 797, 304, 272, 408, 17187, 314, 3906, 370, 1255, 14, 339, 3033, 26, 489, 3906, 63, 888, 26, 376, 1256, 402, 2341, 63, 2423, 14, 2956, 6694, 2028, 14, 489, 315, 63, 88, 71, 63, 5945, 26, 13467, 4052, 6008, 4194, 370, 675, 370, 1343, 642, 603, 50, 267, 3906, 14, 982, 715, 12, 2337, 965, 370, 506, 376, 2575, 12123, 8059 ]
[ 2647, 15, 1393, 15, 1813, 2366, 199, 3, 199, 3, 1898, 10219, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 258, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 3, 199, 624, 1899, 3261, 367, 30350, 9672, 3906, 6451, 1041, 199, 199, 504, 6233, 14, 15358, 14, 1246, 492, 2120, 1825, 199, 504, 6233, 14, 15358, 14, 11450, 492, 12007, 63, 4354, 199, 504, 6233, 14, 15358, 14, 832, 492, 1592, 199, 504, 6233, 14, 15358, 14, 832, 14, 28658, 492, 1402, 199, 504, 6233, 14, 15358, 14, 832, 14, 28658, 492, 4884, 199, 504, 6233, 14, 15358, 14, 832, 14, 28658, 14, 1246, 14, 1130, 63, 2423, 492, 2341, 63, 2423, 63, 888, 28154, 199, 533, 15057, 8, 785, 304, 523, 408, 1918, 3906, 11482, 351, 1159, 2455, 402, 314, 3906, 14, 819, 710, 1021, 6127, 922, 370, 11482, 282, 3906, 12, 3304, 282, 16930, 3906, 12, 523, 1827, 2399, 1174, 436, 754, 14, 523, 408, 819, 21277, 6024, 275, 298, 5720, 2, 523, 26892, 275, 1402, 14, 2956, 5270, 2223, 14, 9517, 63, 12299, 523, 14840, 2596, 1149, 275, 1402, 14, 2956, 5270, 2223, 14, 9517, 63, 27113, 1149, 523, 28364, 275, 1402, 14, 2956, 5270, 2223, 14, 9517, 63, 12779, 819, 18460, 63, 17563, 275, 359, 17305, 12, 26892, 12, 14840, 2596, 1149, 12, 28364, 61, 819, 347, 636, 826, 721, 277, 12, 1174, 29, 403, 304, 272, 408, 9346, 314, 3906, 1256, 6144, 314, 3906, 543, 1305, 3906, 63, 344, 14, 339, 4226, 440, 5370, 1240, 642, 1083, 14, 3645, 1021, 3102, 370, 6982, 272, 892, 4454, 14, 339, 3033, 26, 489, 1174, 26, 1402, 14, 2956, 5270, 2223, 14, 272, 408, 272, 291, 423, 929, 275, 1174, 339, 291, 14, 2423, 63, 888, 275, 2341, 63, 2423, 63, 888, 14, 6694, 2028, 423, 475, 63, 1130, 63, 2423, 63, 888, 8, 267, 1174, 14, 28658, 63, 1650, 12, 267, 4126, 63, 354, 29, 929, 14, 28658, 63, 1650, 14, 1162, 14, 362, 480, 1825, 63, 354, 2237, 819, 768, 3744, 523, 347, 664, 63, 2423, 63, 991, 63, 344, 8, 1886, 12, 3906, 63, 344, 29, 403, 304, 272, 408, 14426, 314, 3906, 1256, 6144, 314, 3906, 543, 1305, 3906, 63, 344, 14, 339, 3033, 26, 489, 3906, 63, 344, 26, 282, 3906, 1305, 12, 3906, 63, 888, 14, 2423, 63, 344, 12, 402, 282, 16930, 3906, 14, 339, 1803, 26, 489, 437, 15057, 1256, 367, 3906, 63, 344, 14, 272, 408, 272, 1174, 275, 843, 855, 362, 63, 929, 63, 991, 63, 344, 8, 2423, 63, 344, 9, 272, 372, 843, 8, 929, 9, 819, 347, 664, 63, 1205, 8, 277, 304, 272, 408, 1002, 2004, 4952, 14, 339, 1803, 26, 489, 7309, 402, 314, 2004, 4952, 14, 272, 408, 272, 291, 855, 873, 63, 929, 342, 272, 340, 291, 423, 929, 14, 2682, 26, 489, 372, 291, 14, 17305, 272, 587, 26, 489, 372, 291, 423, 929, 14, 1099, 63, 1205, 819, 347, 12004, 8, 277, 304, 272, 408, 16682, 83, 314, 3906, 1041, 272, 1402, 14, 2956, 5270, 3717, 14, 13845, 8, 277, 14, 2423, 63, 888, 14, 2423, 63, 344, 9, 819, 347, 664, 63, 16558, 8, 277, 304, 272, 408, 1002, 21272, 687, 642, 3906, 14, 339, 3979, 282, 3906, 365, 3879, 12, 7055, 1338, 7859, 1133, 506, 7437, 23189, 14, 339, 1803, 26, 489, 1626, 6122, 626, 2529, 334, 5337, 63, 354, 12, 574, 9, 6342, 402, 730, 489, 334, 17628, 12, 1109, 9, 272, 408, 272, 291, 855, 873, 63, 929, 342, 272, 372, 291, 423, 929, 14, 16558, 63, 1130, 14, 16558, 14, 4611, 342, 819, 347, 664, 63, 5337, 8, 277, 12, 7055, 63, 354, 12, 849, 29, 16, 304, 272, 408, 1002, 314, 574, 402, 314, 4310, 7055, 687, 642, 3906, 14, 339, 3979, 282, 3906, 365, 3879, 12, 7055, 1338, 7859, 1133, 506, 7437, 23189, 14, 339, 3033, 26, 489, 7055, 63, 354, 26, 536, 402, 314, 7055, 315, 1059, 14, 489, 849, 26, 849, 574, 340, 314, 7055, 3181, 1133, 2187, 14, 339, 1803, 26, 489, 1594, 315, 1109, 402, 314, 4310, 7055, 14, 272, 408, 272, 291, 855, 873, 63, 929, 342, 272, 372, 291, 423, 929, 14, 16558, 63, 1130, 14, 362, 8, 5337, 63, 354, 12, 849, 9, 819, 347, 664, 63, 4467, 8, 277, 304, 272, 408, 1002, 4704, 402, 642, 3906, 14, 339, 7719, 1454, 1240, 340, 2004, 365, 28364, 14, 339, 23771, 83, 26, 489, 11953, 2750, 12, 1373, 367, 1924, 11814, 14, 7048, 6122, 365, 489, 687, 314, 1423, 402, 2341, 63, 2423, 14, 1199, 63, 5491, 14, 3543, 63, 1199, 14, 272, 408, 272, 702, 291, 14, 12779, 508, 291, 14, 362, 63, 1205, 342, 272, 10110, 275, 1402, 14, 20019, 2223, 14, 1623, 63, 452, 63, 991, 63, 28658, 63, 929, 8, 277, 423, 929, 9, 272, 367, 308, 315, 10110, 26, 489, 1995, 2740, 8, 83, 14, 5491, 63, 929, 14, 362, 480, 16816, 401, 15927, 819, 768, 3744, 523, 347, 11482, 8, 1886, 12, 3906, 63, 888, 12, 315, 63, 88, 71, 63, 5945, 29, 797, 304, 272, 408, 17187, 314, 3906, 370, 1255, 14, 339, 3033, 26, 489, 3906, 63, 888, 26, 376, 1256, 402, 2341, 63, 2423, 14, 2956, 6694, 2028, 14, 489, 315, 63, 88, 71, 63, 5945, 26, 13467, 4052, 6008, 4194, 370, 675, 370, 1343, 642, 603, 50, 267, 3906, 14, 982, 715, 12, 2337, 965, 370, 506, 376, 2575, 12123, 8059, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
msabramo/kallithea
kallithea/lib/dbmigrate/versions/010_version_1_5_2.py
2
1491
import logging from sqlalchemy import * from kallithea.lib.dbmigrate.migrate import * from kallithea.lib.dbmigrate.migrate.changeset import * from kallithea.model import meta from kallithea.lib.dbmigrate.versions import _reset_base, notify log = logging.getLogger(__name__) def upgrade(migrate_engine): """ Upgrade operations go here. Don't create your own engine; bind migrate_engine to your metadata """ _reset_base(migrate_engine) from kallithea.lib.dbmigrate.schema import db_1_5_2 #========================================================================== # USER LOGS #========================================================================== tbl = db_1_5_2.UserIpMap.__table__ tbl.create() #========================================================================== # REPOSITORIES #========================================================================== tbl = db_1_5_2.Repository.__table__ changeset_cache = Column("changeset_cache", LargeBinary(), nullable=True) # create username column changeset_cache.create(table=tbl) # issue fixups fixups(db_1_5_2, meta.Session) def downgrade(migrate_engine): meta = MetaData() meta.bind = migrate_engine def fixups(models, _SESSION): notify('Upgrading repositories Caches') repositories = models.Repository.getAll() for repo in repositories: print repo repo.update_changeset_cache() _SESSION().commit()
gpl-3.0
[ 646, 2050, 199, 199, 504, 8335, 492, 627, 199, 199, 504, 1022, 279, 317, 1589, 65, 14, 773, 14, 697, 8462, 14, 8462, 492, 627, 199, 504, 1022, 279, 317, 1589, 65, 14, 773, 14, 697, 8462, 14, 8462, 14, 26027, 492, 627, 199, 199, 504, 1022, 279, 317, 1589, 65, 14, 1238, 492, 3404, 199, 504, 1022, 279, 317, 1589, 65, 14, 773, 14, 697, 8462, 14, 6234, 492, 485, 3958, 63, 1095, 12, 11705, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 10754, 8, 8462, 63, 3908, 304, 272, 408, 272, 4949, 4523, 5331, 2621, 2348, 14, 272, 7529, 1133, 1218, 2195, 5705, 6869, 27, 5398, 12810, 63, 3908, 370, 2195, 3341, 272, 408, 272, 485, 3958, 63, 1095, 8, 8462, 63, 3908, 9, 272, 687, 1022, 279, 317, 1589, 65, 14, 773, 14, 697, 8462, 14, 3629, 492, 1592, 63, 17, 63, 21, 63, 18, 272, 32314, 17575, 272, 327, 13044, 5051, 51, 272, 32314, 17575, 272, 19049, 275, 1592, 63, 17, 63, 21, 63, 18, 14, 1899, 6583, 2956, 855, 1224, 363, 272, 19049, 14, 981, 342, 339, 32314, 17575, 272, 327, 5363, 27998, 28743, 272, 32314, 17575, 272, 19049, 275, 1592, 63, 17, 63, 21, 63, 18, 14, 15614, 855, 1224, 363, 272, 23316, 63, 1637, 275, 4996, 480, 26027, 63, 1637, 401, 29095, 6636, 1062, 7854, 29, 549, 9, 272, 327, 1218, 3434, 2763, 272, 23316, 63, 1637, 14, 981, 8, 1224, 29, 14806, 9, 339, 327, 4976, 5325, 15203, 272, 5325, 15203, 8, 697, 63, 17, 63, 21, 63, 18, 12, 3404, 14, 4434, 9, 421, 199, 318, 32498, 8, 8462, 63, 3908, 304, 272, 3404, 275, 24905, 342, 272, 3404, 14, 3409, 275, 12810, 63, 3908, 421, 199, 318, 5325, 15203, 8, 992, 12, 485, 12763, 304, 272, 11705, 360, 1721, 16050, 23737, 445, 1225, 397, 358, 272, 23737, 275, 1709, 14, 15614, 14, 31359, 342, 272, 367, 3831, 315, 23737, 26, 267, 870, 3831, 267, 3831, 14, 873, 63, 26027, 63, 1637, 342, 267, 485, 12763, 1252, 3543, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 2050, 199, 199, 504, 8335, 492, 627, 199, 199, 504, 1022, 279, 317, 1589, 65, 14, 773, 14, 697, 8462, 14, 8462, 492, 627, 199, 504, 1022, 279, 317, 1589, 65, 14, 773, 14, 697, 8462, 14, 8462, 14, 26027, 492, 627, 199, 199, 504, 1022, 279, 317, 1589, 65, 14, 1238, 492, 3404, 199, 504, 1022, 279, 317, 1589, 65, 14, 773, 14, 697, 8462, 14, 6234, 492, 485, 3958, 63, 1095, 12, 11705, 199, 199, 793, 275, 2050, 14, 5572, 3460, 354, 3368, 421, 199, 318, 10754, 8, 8462, 63, 3908, 304, 272, 408, 272, 4949, 4523, 5331, 2621, 2348, 14, 272, 7529, 1133, 1218, 2195, 5705, 6869, 27, 5398, 12810, 63, 3908, 370, 2195, 3341, 272, 408, 272, 485, 3958, 63, 1095, 8, 8462, 63, 3908, 9, 272, 687, 1022, 279, 317, 1589, 65, 14, 773, 14, 697, 8462, 14, 3629, 492, 1592, 63, 17, 63, 21, 63, 18, 272, 32314, 17575, 272, 327, 13044, 5051, 51, 272, 32314, 17575, 272, 19049, 275, 1592, 63, 17, 63, 21, 63, 18, 14, 1899, 6583, 2956, 855, 1224, 363, 272, 19049, 14, 981, 342, 339, 32314, 17575, 272, 327, 5363, 27998, 28743, 272, 32314, 17575, 272, 19049, 275, 1592, 63, 17, 63, 21, 63, 18, 14, 15614, 855, 1224, 363, 272, 23316, 63, 1637, 275, 4996, 480, 26027, 63, 1637, 401, 29095, 6636, 1062, 7854, 29, 549, 9, 272, 327, 1218, 3434, 2763, 272, 23316, 63, 1637, 14, 981, 8, 1224, 29, 14806, 9, 339, 327, 4976, 5325, 15203, 272, 5325, 15203, 8, 697, 63, 17, 63, 21, 63, 18, 12, 3404, 14, 4434, 9, 421, 199, 318, 32498, 8, 8462, 63, 3908, 304, 272, 3404, 275, 24905, 342, 272, 3404, 14, 3409, 275, 12810, 63, 3908, 421, 199, 318, 5325, 15203, 8, 992, 12, 485, 12763, 304, 272, 11705, 360, 1721, 16050, 23737, 445, 1225, 397, 358, 272, 23737, 275, 1709, 14, 15614, 14, 31359, 342, 272, 367, 3831, 315, 23737, 26, 267, 870, 3831, 267, 3831, 14, 873, 63, 26027, 63, 1637, 342, 267, 485, 12763, 1252, 3543, 342, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768,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 0, 0, 0, 0 ]
flyfei/python-for-android
python-build/python-libs/gdata/build/lib/gdata/spreadsheet/__init__.py
147
17942
#!/usr/bin/python # # Copyright (C) 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Contains extensions to Atom objects used with Google Spreadsheets. """ __author__ = 'api.laurabeth@gmail.com (Laura Beth Lincoln)' try: from xml.etree import cElementTree as ElementTree except ImportError: try: import cElementTree as ElementTree except ImportError: try: from xml.etree import ElementTree except ImportError: from elementtree import ElementTree import atom import gdata import re import string # XML namespaces which are often used in Google Spreadsheets entities. GSPREADSHEETS_NAMESPACE = 'http://schemas.google.com/spreadsheets/2006' GSPREADSHEETS_TEMPLATE = '{http://schemas.google.com/spreadsheets/2006}%s' GSPREADSHEETS_EXTENDED_NAMESPACE = ('http://schemas.google.com/spreadsheets' '/2006/extended') GSPREADSHEETS_EXTENDED_TEMPLATE = ('{http://schemas.google.com/spreadsheets' '/2006/extended}%s') class ColCount(atom.AtomBase): """The Google Spreadsheets colCount element """ _tag = 'colCount' _namespace = GSPREADSHEETS_NAMESPACE _children = atom.AtomBase._children.copy() _attributes = atom.AtomBase._attributes.copy() def __init__(self, text=None, extension_elements=None, extension_attributes=None): self.text = text self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} def ColCountFromString(xml_string): return atom.CreateClassFromXMLString(ColCount, xml_string) class RowCount(atom.AtomBase): """The Google Spreadsheets rowCount element """ _tag = 'rowCount' _namespace = GSPREADSHEETS_NAMESPACE _children = atom.AtomBase._children.copy() _attributes = atom.AtomBase._attributes.copy() def __init__(self, text=None, extension_elements=None, extension_attributes=None): self.text = text self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} def RowCountFromString(xml_string): return atom.CreateClassFromXMLString(RowCount, xml_string) class Cell(atom.AtomBase): """The Google Spreadsheets cell element """ _tag = 'cell' _namespace = GSPREADSHEETS_NAMESPACE _children = atom.AtomBase._children.copy() _attributes = atom.AtomBase._attributes.copy() _attributes['row'] = 'row' _attributes['col'] = 'col' _attributes['inputValue'] = 'inputValue' _attributes['numericValue'] = 'numericValue' def __init__(self, text=None, row=None, col=None, inputValue=None, numericValue=None, extension_elements=None, extension_attributes=None): self.text = text self.row = row self.col = col self.inputValue = inputValue self.numericValue = numericValue self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} def CellFromString(xml_string): return atom.CreateClassFromXMLString(Cell, xml_string) class Custom(atom.AtomBase): """The Google Spreadsheets custom element""" _namespace = GSPREADSHEETS_EXTENDED_NAMESPACE _children = atom.AtomBase._children.copy() _attributes = atom.AtomBase._attributes.copy() def __init__(self, column=None, text=None, extension_elements=None, extension_attributes=None): self.column = column # The name of the column self.text = text self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} def _BecomeChildElement(self, tree): new_child = ElementTree.Element('') tree.append(new_child) new_child.tag = '{%s}%s' % (self.__class__._namespace, self.column) self._AddMembersToElementTree(new_child) def _ToElementTree(self): new_tree = ElementTree.Element('{%s}%s' % (self.__class__._namespace, self.column)) self._AddMembersToElementTree(new_tree) return new_tree def _HarvestElementTree(self, tree): namespace_uri, local_tag = string.split(tree.tag[1:], "}", 1) self.column = local_tag # Fill in the instance members from the contents of the XML tree. for child in tree: self._ConvertElementTreeToMember(child) for attribute, value in tree.attrib.iteritems(): self._ConvertElementAttributeToMember(attribute, value) self.text = tree.text def CustomFromString(xml_string): element_tree = ElementTree.fromstring(xml_string) return _CustomFromElementTree(element_tree) def _CustomFromElementTree(element_tree): namespace_uri, local_tag = string.split(element_tree.tag[1:], "}", 1) if namespace_uri == GSPREADSHEETS_EXTENDED_NAMESPACE: new_custom = Custom() new_custom._HarvestElementTree(element_tree) new_custom.column = local_tag return new_custom return None class SpreadsheetsSpreadsheet(gdata.GDataEntry): """A Google Spreadsheets flavor of a Spreadsheet Atom Entry """ _tag = 'entry' _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataEntry._children.copy() _attributes = gdata.GDataEntry._attributes.copy() def __init__(self, author=None, category=None, content=None, contributor=None, atom_id=None, link=None, published=None, rights=None, source=None, summary=None, title=None, control=None, updated=None, text=None, extension_elements=None, extension_attributes=None): self.author = author or [] self.category = category or [] self.content = content self.contributor = contributor or [] self.id = atom_id self.link = link or [] self.published = published self.rights = rights self.source = source self.summary = summary self.control = control self.title = title self.updated = updated self.text = text self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} def SpreadsheetsSpreadsheetFromString(xml_string): return atom.CreateClassFromXMLString(SpreadsheetsSpreadsheet, xml_string) class SpreadsheetsWorksheet(gdata.GDataEntry): """A Google Spreadsheets flavor of a Worksheet Atom Entry """ _tag = 'entry' _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataEntry._children.copy() _attributes = gdata.GDataEntry._attributes.copy() _children['{%s}rowCount' % GSPREADSHEETS_NAMESPACE] = ('row_count', RowCount) _children['{%s}colCount' % GSPREADSHEETS_NAMESPACE] = ('col_count', ColCount) def __init__(self, author=None, category=None, content=None, contributor=None, atom_id=None, link=None, published=None, rights=None, source=None, summary=None, title=None, control=None, updated=None, row_count=None, col_count=None, text=None, extension_elements=None, extension_attributes=None): self.author = author or [] self.category = category or [] self.content = content self.contributor = contributor or [] self.id = atom_id self.link = link or [] self.published = published self.rights = rights self.source = source self.summary = summary self.control = control self.title = title self.updated = updated self.row_count = row_count self.col_count = col_count self.text = text self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} def SpreadsheetsWorksheetFromString(xml_string): return atom.CreateClassFromXMLString(SpreadsheetsWorksheet, xml_string) class SpreadsheetsCell(gdata.BatchEntry): """A Google Spreadsheets flavor of a Cell Atom Entry """ _tag = 'entry' _namespace = atom.ATOM_NAMESPACE _children = gdata.BatchEntry._children.copy() _attributes = gdata.BatchEntry._attributes.copy() _children['{%s}cell' % GSPREADSHEETS_NAMESPACE] = ('cell', Cell) def __init__(self, author=None, category=None, content=None, contributor=None, atom_id=None, link=None, published=None, rights=None, source=None, summary=None, title=None, control=None, updated=None, cell=None, batch_operation=None, batch_id=None, batch_status=None, text=None, extension_elements=None, extension_attributes=None): self.author = author or [] self.category = category or [] self.content = content self.contributor = contributor or [] self.id = atom_id self.link = link or [] self.published = published self.rights = rights self.source = source self.summary = summary self.control = control self.title = title self.batch_operation = batch_operation self.batch_id = batch_id self.batch_status = batch_status self.updated = updated self.cell = cell self.text = text self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} def SpreadsheetsCellFromString(xml_string): return atom.CreateClassFromXMLString(SpreadsheetsCell, xml_string) class SpreadsheetsList(gdata.GDataEntry): """A Google Spreadsheets flavor of a List Atom Entry """ _tag = 'entry' _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataEntry._children.copy() _attributes = gdata.GDataEntry._attributes.copy() def __init__(self, author=None, category=None, content=None, contributor=None, atom_id=None, link=None, published=None, rights=None, source=None, summary=None, title=None, control=None, updated=None, custom=None, text=None, extension_elements=None, extension_attributes=None): self.author = author or [] self.category = category or [] self.content = content self.contributor = contributor or [] self.id = atom_id self.link = link or [] self.published = published self.rights = rights self.source = source self.summary = summary self.control = control self.title = title self.updated = updated self.custom = custom or {} self.text = text self.extension_elements = extension_elements or [] self.extension_attributes = extension_attributes or {} # We need to overwrite _ConvertElementTreeToMember to add special logic to # convert custom attributes to members def _ConvertElementTreeToMember(self, child_tree): # Find the element's tag in this class's list of child members if self.__class__._children.has_key(child_tree.tag): member_name = self.__class__._children[child_tree.tag][0] member_class = self.__class__._children[child_tree.tag][1] # If the class member is supposed to contain a list, make sure the # matching member is set to a list, then append the new member # instance to the list. if isinstance(member_class, list): if getattr(self, member_name) is None: setattr(self, member_name, []) getattr(self, member_name).append(atom._CreateClassFromElementTree( member_class[0], child_tree)) else: setattr(self, member_name, atom._CreateClassFromElementTree(member_class, child_tree)) elif child_tree.tag.find('{%s}' % GSPREADSHEETS_EXTENDED_NAMESPACE) == 0: # If this is in the custom namespace, make add it to the custom dict. name = child_tree.tag[child_tree.tag.index('}')+1:] custom = _CustomFromElementTree(child_tree) if custom: self.custom[name] = custom else: ExtensionContainer._ConvertElementTreeToMember(self, child_tree) # We need to overwtite _AddMembersToElementTree to add special logic to # convert custom members to XML nodes. def _AddMembersToElementTree(self, tree): # Convert the members of this class which are XML child nodes. # This uses the class's _children dictionary to find the members which # should become XML child nodes. member_node_names = [values[0] for tag, values in self.__class__._children.iteritems()] for member_name in member_node_names: member = getattr(self, member_name) if member is None: pass elif isinstance(member, list): for instance in member: instance._BecomeChildElement(tree) else: member._BecomeChildElement(tree) # Convert the members of this class which are XML attributes. for xml_attribute, member_name in self.__class__._attributes.iteritems(): member = getattr(self, member_name) if member is not None: tree.attrib[xml_attribute] = member # Convert all special custom item attributes to nodes for name, custom in self.custom.iteritems(): custom._BecomeChildElement(tree) # Lastly, call the ExtensionContainers's _AddMembersToElementTree to # convert any extension attributes. atom.ExtensionContainer._AddMembersToElementTree(self, tree) def SpreadsheetsListFromString(xml_string): return atom.CreateClassFromXMLString(SpreadsheetsList, xml_string) element_tree = ElementTree.fromstring(xml_string) return _SpreadsheetsListFromElementTree(element_tree) class SpreadsheetsSpreadsheetsFeed(gdata.GDataFeed): """A feed containing Google Spreadsheets Spreadsheets""" _tag = 'feed' _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataFeed._children.copy() _attributes = gdata.GDataFeed._attributes.copy() _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [SpreadsheetsSpreadsheet]) def SpreadsheetsSpreadsheetsFeedFromString(xml_string): return atom.CreateClassFromXMLString(SpreadsheetsSpreadsheetsFeed, xml_string) class SpreadsheetsWorksheetsFeed(gdata.GDataFeed): """A feed containing Google Spreadsheets Spreadsheets""" _tag = 'feed' _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataFeed._children.copy() _attributes = gdata.GDataFeed._attributes.copy() _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [SpreadsheetsWorksheet]) def SpreadsheetsWorksheetsFeedFromString(xml_string): return atom.CreateClassFromXMLString(SpreadsheetsWorksheetsFeed, xml_string) class SpreadsheetsCellsFeed(gdata.BatchFeed): """A feed containing Google Spreadsheets Cells""" _tag = 'feed' _namespace = atom.ATOM_NAMESPACE _children = gdata.BatchFeed._children.copy() _attributes = gdata.BatchFeed._attributes.copy() _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [SpreadsheetsCell]) _children['{%s}rowCount' % GSPREADSHEETS_NAMESPACE] = ('row_count', RowCount) _children['{%s}colCount' % GSPREADSHEETS_NAMESPACE] = ('col_count', ColCount) def __init__(self, author=None, category=None, contributor=None, generator=None, icon=None, atom_id=None, link=None, logo=None, rights=None, subtitle=None, title=None, updated=None, entry=None, total_results=None, start_index=None, items_per_page=None, extension_elements=None, extension_attributes=None, text=None, row_count=None, col_count=None, interrupted=None): gdata.BatchFeed.__init__(self, author=author, category=category, contributor=contributor, generator=generator, icon=icon, atom_id=atom_id, link=link, logo=logo, rights=rights, subtitle=subtitle, title=title, updated=updated, entry=entry, total_results=total_results, start_index=start_index, items_per_page=items_per_page, extension_elements=extension_elements, extension_attributes=extension_attributes, text=text, interrupted=interrupted) self.row_count = row_count self.col_count = col_count def GetBatchLink(self): for link in self.link: if link.rel == 'http://schemas.google.com/g/2005#batch': return link return None def SpreadsheetsCellsFeedFromString(xml_string): return atom.CreateClassFromXMLString(SpreadsheetsCellsFeed, xml_string) class SpreadsheetsListFeed(gdata.GDataFeed): """A feed containing Google Spreadsheets Spreadsheets""" _tag = 'feed' _namespace = atom.ATOM_NAMESPACE _children = gdata.GDataFeed._children.copy() _attributes = gdata.GDataFeed._attributes.copy() _children['{%s}entry' % atom.ATOM_NAMESPACE] = ('entry', [SpreadsheetsList]) def SpreadsheetsListFeedFromString(xml_string): return atom.CreateClassFromXMLString(SpreadsheetsListFeed, xml_string)
apache-2.0
[ 3381, 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 35, 9, 10219, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 6906, 5478, 370, 18840, 2251, 1202, 543, 4475, 428, 12032, 83, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 1246, 14, 416, 300, 7570, 273, 32, 6799, 14, 957, 334, 7833, 12417, 6423, 273, 29730, 761, 78, 3171, 421, 199, 893, 26, 523, 687, 2748, 14, 9464, 492, 286, 15325, 465, 13139, 199, 2590, 3545, 26, 523, 862, 26, 272, 492, 286, 15325, 465, 13139, 523, 871, 3545, 26, 272, 862, 26, 489, 687, 2748, 14, 9464, 492, 13139, 272, 871, 3545, 26, 489, 687, 1819, 2350, 492, 13139, 199, 646, 6222, 199, 646, 11006, 199, 646, 295, 199, 646, 1059, 421, 199, 3, 4692, 10747, 1314, 787, 14115, 1202, 315, 4475, 428, 12032, 83, 9045, 14, 199, 8021, 4225, 1554, 20255, 30416, 63, 13001, 275, 283, 1014, 921, 9482, 14, 3098, 14, 957, 15, 19930, 83, 15, 7968, 7, 199, 8021, 4225, 1554, 20255, 30416, 63, 7433, 275, 5041, 1014, 921, 9482, 14, 3098, 14, 957, 15, 19930, 83, 15, 7968, 22109, 83, 7, 199, 199, 8021, 4225, 1554, 20255, 30416, 63, 27059, 63, 13001, 275, 661, 1014, 921, 9482, 14, 3098, 14, 957, 15, 19930, 83, 7, 2511, 1994, 7968, 15, 10525, 358, 199, 8021, 4225, 1554, 20255, 30416, 63, 27059, 63, 7433, 275, 661, 91, 1014, 921, 9482, 14, 3098, 14, 957, 15, 19930, 83, 7, 3521, 1994, 7968, 15, 10525, 22109, 83, 358, 421, 199, 533, 3626, 2353, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 4475, 428, 12032, 83, 1048, 2353, 1819, 408, 12244, 485, 1450, 275, 283, 761, 2353, 7, 523, 485, 3251, 275, 598, 51, 4225, 1554, 20255, 30416, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 819, 347, 636, 826, 721, 277, 12, 1318, 29, 403, 12, 3329, 63, 5527, 29, 403, 12, 489, 3329, 63, 2987, 29, 403, 304, 272, 291, 14, 505, 275, 1318, 272, 291, 14, 3435, 63, 5527, 275, 3329, 63, 5527, 503, 942, 272, 291, 14, 3435, 63, 2987, 275, 3329, 63, 2987, 503, 1052, 10813, 199, 318, 3626, 2353, 7671, 8, 1652, 63, 875, 304, 523, 372, 6222, 14, 2499, 2543, 2532, 4317, 1558, 8, 2001, 2353, 12, 2748, 63, 875, 9, 421, 199, 533, 15231, 2353, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 4475, 428, 12032, 83, 1962, 2353, 1819, 408, 12244, 485, 1450, 275, 283, 1143, 2353, 7, 523, 485, 3251, 275, 598, 51, 4225, 1554, 20255, 30416, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 819, 347, 636, 826, 721, 277, 12, 1318, 29, 403, 12, 3329, 63, 5527, 29, 403, 12, 489, 3329, 63, 2987, 29, 403, 304, 272, 291, 14, 505, 275, 1318, 272, 291, 14, 3435, 63, 5527, 275, 3329, 63, 5527, 503, 942, 272, 291, 14, 3435, 63, 2987, 275, 3329, 63, 2987, 503, 1052, 199, 199, 318, 15231, 2353, 7671, 8, 1652, 63, 875, 304, 523, 372, 6222, 14, 2499, 2543, 2532, 4317, 1558, 8, 5810, 2353, 12, 2748, 63, 875, 9, 2126, 199, 199, 533, 24834, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 4475, 428, 12032, 83, 4917, 1819, 408, 12244, 485, 1450, 275, 283, 3890, 7, 523, 485, 3251, 275, 598, 51, 4225, 1554, 20255, 30416, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 523, 485, 2987, 459, 1143, 418, 275, 283, 1143, 7, 523, 485, 2987, 459, 761, 418, 275, 283, 761, 7, 523, 485, 2987, 459, 1210, 1110, 418, 275, 283, 1210, 1110, 7, 523, 485, 2987, 459, 6677, 1110, 418, 275, 283, 6677, 1110, 7, 12244, 347, 636, 826, 721, 277, 12, 1318, 29, 403, 12, 1962, 29, 403, 12, 1048, 29, 403, 12, 1324, 1110, 29, 403, 12, 15166, 8950, 1110, 29, 403, 12, 3329, 63, 5527, 29, 403, 12, 3329, 63, 2987, 29, 403, 304, 272, 291, 14, 505, 275, 1318, 272, 291, 14, 1143, 275, 1962, 272, 291, 14, 761, 275, 1048, 272, 291, 14, 1210, 1110, 275, 1324, 1110, 272, 291, 14, 6677, 1110, 275, 8950, 1110, 272, 291, 14, 3435, 63, 5527, 275, 3329, 63, 5527, 503, 942, 272, 291, 14, 3435, 63, 2987, 275, 3329, 63, 2987, 503, 1052, 421, 199, 318, 24834, 7671, 8, 1652, 63, 875, 304, 523, 372, 6222, 14, 2499, 2543, 2532, 4317, 1558, 8, 8108, 12, 2748, 63, 875, 9, 421, 199, 533, 8388, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 4475, 428, 12032, 83, 3537, 1819, 624, 12244, 485, 3251, 275, 598, 51, 4225, 1554, 20255, 30416, 63, 27059, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 819, 347, 636, 826, 721, 277, 12, 2763, 29, 403, 12, 1318, 29, 403, 12, 3329, 63, 5527, 29, 403, 12, 489, 3329, 63, 2987, 29, 403, 304, 272, 291, 14, 2301, 275, 2763, 257, 327, 710, 536, 402, 314, 2763, 272, 291, 14, 505, 275, 1318 ]
[ 2647, 15, 1393, 15, 1548, 199, 3, 199, 3, 1898, 334, 35, 9, 10219, 4475, 3277, 14, 199, 3, 199, 3, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 420, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 4204, 1334, 314, 844, 14, 199, 199, 624, 6906, 5478, 370, 18840, 2251, 1202, 543, 4475, 428, 12032, 83, 14, 199, 624, 199, 199, 363, 2502, 363, 275, 283, 1246, 14, 416, 300, 7570, 273, 32, 6799, 14, 957, 334, 7833, 12417, 6423, 273, 29730, 761, 78, 3171, 421, 199, 893, 26, 523, 687, 2748, 14, 9464, 492, 286, 15325, 465, 13139, 199, 2590, 3545, 26, 523, 862, 26, 272, 492, 286, 15325, 465, 13139, 523, 871, 3545, 26, 272, 862, 26, 489, 687, 2748, 14, 9464, 492, 13139, 272, 871, 3545, 26, 489, 687, 1819, 2350, 492, 13139, 199, 646, 6222, 199, 646, 11006, 199, 646, 295, 199, 646, 1059, 421, 199, 3, 4692, 10747, 1314, 787, 14115, 1202, 315, 4475, 428, 12032, 83, 9045, 14, 199, 8021, 4225, 1554, 20255, 30416, 63, 13001, 275, 283, 1014, 921, 9482, 14, 3098, 14, 957, 15, 19930, 83, 15, 7968, 7, 199, 8021, 4225, 1554, 20255, 30416, 63, 7433, 275, 5041, 1014, 921, 9482, 14, 3098, 14, 957, 15, 19930, 83, 15, 7968, 22109, 83, 7, 199, 199, 8021, 4225, 1554, 20255, 30416, 63, 27059, 63, 13001, 275, 661, 1014, 921, 9482, 14, 3098, 14, 957, 15, 19930, 83, 7, 2511, 1994, 7968, 15, 10525, 358, 199, 8021, 4225, 1554, 20255, 30416, 63, 27059, 63, 7433, 275, 661, 91, 1014, 921, 9482, 14, 3098, 14, 957, 15, 19930, 83, 7, 3521, 1994, 7968, 15, 10525, 22109, 83, 358, 421, 199, 533, 3626, 2353, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 4475, 428, 12032, 83, 1048, 2353, 1819, 408, 12244, 485, 1450, 275, 283, 761, 2353, 7, 523, 485, 3251, 275, 598, 51, 4225, 1554, 20255, 30416, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 819, 347, 636, 826, 721, 277, 12, 1318, 29, 403, 12, 3329, 63, 5527, 29, 403, 12, 489, 3329, 63, 2987, 29, 403, 304, 272, 291, 14, 505, 275, 1318, 272, 291, 14, 3435, 63, 5527, 275, 3329, 63, 5527, 503, 942, 272, 291, 14, 3435, 63, 2987, 275, 3329, 63, 2987, 503, 1052, 10813, 199, 318, 3626, 2353, 7671, 8, 1652, 63, 875, 304, 523, 372, 6222, 14, 2499, 2543, 2532, 4317, 1558, 8, 2001, 2353, 12, 2748, 63, 875, 9, 421, 199, 533, 15231, 2353, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 4475, 428, 12032, 83, 1962, 2353, 1819, 408, 12244, 485, 1450, 275, 283, 1143, 2353, 7, 523, 485, 3251, 275, 598, 51, 4225, 1554, 20255, 30416, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 819, 347, 636, 826, 721, 277, 12, 1318, 29, 403, 12, 3329, 63, 5527, 29, 403, 12, 489, 3329, 63, 2987, 29, 403, 304, 272, 291, 14, 505, 275, 1318, 272, 291, 14, 3435, 63, 5527, 275, 3329, 63, 5527, 503, 942, 272, 291, 14, 3435, 63, 2987, 275, 3329, 63, 2987, 503, 1052, 199, 199, 318, 15231, 2353, 7671, 8, 1652, 63, 875, 304, 523, 372, 6222, 14, 2499, 2543, 2532, 4317, 1558, 8, 5810, 2353, 12, 2748, 63, 875, 9, 2126, 199, 199, 533, 24834, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 4475, 428, 12032, 83, 4917, 1819, 408, 12244, 485, 1450, 275, 283, 3890, 7, 523, 485, 3251, 275, 598, 51, 4225, 1554, 20255, 30416, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 523, 485, 2987, 459, 1143, 418, 275, 283, 1143, 7, 523, 485, 2987, 459, 761, 418, 275, 283, 761, 7, 523, 485, 2987, 459, 1210, 1110, 418, 275, 283, 1210, 1110, 7, 523, 485, 2987, 459, 6677, 1110, 418, 275, 283, 6677, 1110, 7, 12244, 347, 636, 826, 721, 277, 12, 1318, 29, 403, 12, 1962, 29, 403, 12, 1048, 29, 403, 12, 1324, 1110, 29, 403, 12, 15166, 8950, 1110, 29, 403, 12, 3329, 63, 5527, 29, 403, 12, 3329, 63, 2987, 29, 403, 304, 272, 291, 14, 505, 275, 1318, 272, 291, 14, 1143, 275, 1962, 272, 291, 14, 761, 275, 1048, 272, 291, 14, 1210, 1110, 275, 1324, 1110, 272, 291, 14, 6677, 1110, 275, 8950, 1110, 272, 291, 14, 3435, 63, 5527, 275, 3329, 63, 5527, 503, 942, 272, 291, 14, 3435, 63, 2987, 275, 3329, 63, 2987, 503, 1052, 421, 199, 318, 24834, 7671, 8, 1652, 63, 875, 304, 523, 372, 6222, 14, 2499, 2543, 2532, 4317, 1558, 8, 8108, 12, 2748, 63, 875, 9, 421, 199, 533, 8388, 8, 4188, 14, 12097, 1563, 304, 523, 408, 1918, 4475, 428, 12032, 83, 3537, 1819, 624, 12244, 485, 3251, 275, 598, 51, 4225, 1554, 20255, 30416, 63, 27059, 63, 13001, 523, 485, 3223, 275, 6222, 14, 12097, 1563, 423, 3223, 14, 1574, 342, 523, 485, 2987, 275, 6222, 14, 12097, 1563, 423, 2987, 14, 1574, 342, 819, 347, 636, 826, 721, 277, 12, 2763, 29, 403, 12, 1318, 29, 403, 12, 3329, 63, 5527, 29, 403, 12, 489, 3329, 63, 2987, 29, 403, 304, 272, 291, 14, 2301, 275, 2763, 257, 327, 710, 536, 402, 314, 2763, 272, 291, 14, 505, 275, 1318, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
ProjectQ-Framework/ProjectQ
projectq/meta/_loop.py
1
9774
# -*- coding: utf-8 -*- # Copyright 2017 ProjectQ-Framework (www.projectq.ch) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Tools to implement loops. Example: .. code-block:: python with Loop(eng, 4): H | qb Rz(M_PI/3.) | qb """ from copy import deepcopy from projectq.cengines import BasicEngine from projectq.ops import Allocate, Deallocate from ._util import insert_engine, drop_engine_after class QubitManagementError(Exception): """Exception raised when the lifetime of a qubit is problematic within a loop""" class LoopTag: """ Loop meta tag """ def __init__(self, num): self.num = num self.id = LoopTag.loop_tag_id LoopTag.loop_tag_id += 1 def __eq__(self, other): return isinstance(other, LoopTag) and self.id == other.id and self.num == other.num def __ne__(self, other): return not self.__eq__(other) loop_tag_id = 0 class LoopEngine(BasicEngine): """ Stores all commands and, when done, executes them num times if no loop tag handler engine is available. If there is one, it adds a loop_tag to the commands and sends them on. """ def __init__(self, num): """ Initialize a LoopEngine. Args: num (int): Number of loop iterations. """ BasicEngine.__init__(self) self._tag = LoopTag(num) self._cmd_list = [] self._allocated_qubit_ids = set() self._deallocated_qubit_ids = set() # key: qubit id of a local qubit, i.e. a qubit which has been allocated # and deallocated within the loop body. # value: list contain reference to each weakref qubit with this qubit # id either within control_qubits or qubits. self._refs_to_local_qb = dict() self._next_engines_support_loop_tag = False def run(self): """ Apply the loop statements to all stored commands. Unrolls the loop if LoopTag is not supported by any of the following engines, i.e., if .. code-block:: python is_meta_tag_supported(next_engine, LoopTag) == False """ error_message = ( "\n Error. Qubits have been allocated in with " "Loop(eng, num) context,\n which have not " "explicitely been deallocated in the Loop context.\n" "Correct usage:\nwith Loop(eng, 5):\n" " qubit = eng.allocate_qubit()\n" " ...\n" " del qubit[0]\n" ) if not self._next_engines_support_loop_tag: # pylint: disable=too-many-nested-blocks # Unroll the loop # Check that local qubits have been deallocated: if self._deallocated_qubit_ids != self._allocated_qubit_ids: raise QubitManagementError(error_message) if len(self._allocated_qubit_ids) == 0: # No local qubits, just send the circuit num times for i in range(self._tag.num): self.send(deepcopy(self._cmd_list)) else: # Ancilla qubits have been allocated in loop body # For each iteration, allocate and deallocate a new qubit and # replace the qubit id in all commands using it. for i in range(self._tag.num): if i == 0: # Don't change local qubit ids self.send(deepcopy(self._cmd_list)) else: # Change local qubit ids before sending them for refs_loc_qubit in self._refs_to_local_qb.values(): new_qb_id = self.main_engine.get_new_qubit_id() for qubit_ref in refs_loc_qubit: qubit_ref.id = new_qb_id self.send(deepcopy(self._cmd_list)) else: # Next engines support loop tag so no unrolling needed only # check that all qubits have been deallocated which have been # allocated in the loop body if self._deallocated_qubit_ids != self._allocated_qubit_ids: raise QubitManagementError(error_message) def receive(self, command_list): # pylint: disable=too-many-branches """ Receive (and potentially temporarily store) all commands. Add LoopTag to all receiving commands and send to the next engine if a further engine is a LoopTag-handling engine. Otherwise store all commands (to later unroll them). Check that within the loop body, all allocated qubits have also been deallocated. If loop needs to be unrolled and ancilla qubits have been allocated within the loop body, then store a reference all these qubit ids (to change them when unrolling the loop) Args: command_list (list<Command>): List of commands to store and later unroll or, if there is a LoopTag-handling engine, add the LoopTag. """ # pylint: disable=too-many-nested-blocks if self._next_engines_support_loop_tag or self.next_engine.is_meta_tag_supported(LoopTag): # Loop tag is supported, send everything with a LoopTag # Don't check is_meta_tag_supported anymore self._next_engines_support_loop_tag = True if self._tag.num == 0: return for cmd in command_list: if cmd.gate == Allocate: self._allocated_qubit_ids.add(cmd.qubits[0][0].id) elif cmd.gate == Deallocate: self._deallocated_qubit_ids.add(cmd.qubits[0][0].id) cmd.tags.append(self._tag) self.send([cmd]) else: # LoopTag is not supported, save the full loop body self._cmd_list += command_list # Check for all local qubits allocated and deallocated in loop body for cmd in command_list: if cmd.gate == Allocate: self._allocated_qubit_ids.add(cmd.qubits[0][0].id) # Save reference to this local qubit self._refs_to_local_qb[cmd.qubits[0][0].id] = [cmd.qubits[0][0]] elif cmd.gate == Deallocate: self._deallocated_qubit_ids.add(cmd.qubits[0][0].id) # Save reference to this local qubit self._refs_to_local_qb[cmd.qubits[0][0].id].append(cmd.qubits[0][0]) else: # Add a reference to each place a local qubit id is # used as within either control_qubit or qubits for control_qubit in cmd.control_qubits: if control_qubit.id in self._allocated_qubit_ids: self._refs_to_local_qb[control_qubit.id].append(control_qubit) for qureg in cmd.qubits: for qubit in qureg: if qubit.id in self._allocated_qubit_ids: self._refs_to_local_qb[qubit.id].append(qubit) class Loop: """ Loop n times over an entire code block. Example: .. code-block:: python with Loop(eng, 4): # [quantum gates to be executed 4 times] Warning: If the code in the loop contains allocation of qubits, those qubits have to be deleted prior to exiting the 'with Loop()' context. This code is **NOT VALID**: .. code-block:: python with Loop(eng, 4): qb = eng.allocate_qubit() H | qb # qb is still available!!! The **correct way** of handling qubit (de-)allocation is as follows: .. code-block:: python with Loop(eng, 4): qb = eng.allocate_qubit() ... del qb # sends deallocate gate """ def __init__(self, engine, num): """ Enter a looped section. Args: engine: Engine handling the commands (usually MainEngine) num (int): Number of loop iterations Example: .. code-block:: python with Loop(eng, 4): H | qb Rz(M_PI/3.) | qb Raises: TypeError: If number of iterations (num) is not an integer ValueError: If number of iterations (num) is not >= 0 """ self.engine = engine if not isinstance(num, int): raise TypeError("Number of loop iterations must be an int.") if num < 0: raise ValueError("Number of loop iterations must be >=0.") self.num = num self._loop_eng = None def __enter__(self): if self.num != 1: self._loop_eng = LoopEngine(self.num) insert_engine(self.engine, self._loop_eng) def __exit__(self, exc_type, exc_value, exc_traceback): if self.num != 1: # remove loop handler from engine list (i.e. skip it) self._loop_eng.run() self._loop_eng = None drop_engine_after(self.engine)
apache-2.0
[ 3, 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 257, 1898, 9708, 7290, 49, 13, 16442, 334, 1544, 14, 1715, 81, 14, 335, 9, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 755, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 624, 199, 11654, 370, 5669, 17222, 14, 199, 199, 9846, 26, 272, 2508, 1233, 13, 1457, 447, 2366, 398, 543, 18175, 8, 7420, 12, 841, 304, 288, 869, 1204, 1894, 66, 267, 820, 90, 8, 45, 63, 2252, 15, 19, 4959, 1204, 1894, 66, 199, 624, 199, 199, 504, 1331, 492, 14800, 199, 199, 504, 2199, 81, 14, 2497, 18131, 492, 10082, 8524, 199, 504, 2199, 81, 14, 1483, 492, 4580, 6280, 12, 1487, 12991, 199, 504, 13653, 1974, 492, 5518, 63, 3908, 12, 5978, 63, 3908, 63, 4399, 421, 199, 533, 1413, 456, 390, 14552, 547, 8, 1726, 304, 272, 408, 1726, 4915, 1380, 314, 30097, 402, 282, 2173, 2075, 365, 557, 31197, 4453, 282, 4438, 624, 421, 199, 533, 18175, 1931, 26, 272, 408, 272, 18175, 3404, 1947, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1967, 304, 267, 291, 14, 1507, 275, 1967, 267, 291, 14, 344, 275, 18175, 1931, 14, 3813, 63, 1450, 63, 344, 267, 18175, 1931, 14, 3813, 63, 1450, 63, 344, 847, 413, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 1228, 8, 1848, 12, 18175, 1931, 9, 436, 291, 14, 344, 508, 1163, 14, 344, 436, 291, 14, 1507, 508, 1163, 14, 1507, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 855, 4077, 721, 1848, 9, 339, 4438, 63, 1450, 63, 344, 275, 378, 421, 199, 533, 18175, 8524, 8, 6845, 8524, 304, 272, 408, 272, 31299, 1006, 3718, 436, 12, 1380, 4224, 12, 24956, 3062, 1967, 5431, 340, 949, 4438, 1947, 272, 3016, 6869, 365, 2808, 14, 272, 982, 2337, 365, 1373, 12, 652, 9584, 282, 4438, 63, 1450, 370, 314, 3718, 436, 16178, 3062, 641, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1967, 304, 267, 408, 267, 11578, 282, 18175, 8524, 14, 398, 3033, 26, 288, 1967, 334, 442, 304, 4860, 402, 4438, 10615, 14, 267, 408, 267, 10082, 8524, 855, 826, 721, 277, 9, 267, 291, 423, 1450, 275, 18175, 1931, 8, 1507, 9, 267, 291, 423, 1760, 63, 513, 275, 942, 267, 291, 423, 19570, 63, 392, 2075, 63, 1580, 275, 663, 342, 267, 291, 423, 271, 19570, 63, 392, 2075, 63, 1580, 275, 663, 342, 267, 327, 790, 26, 2173, 2075, 1305, 402, 282, 2257, 2173, 2075, 12, 284, 14, 69, 14, 282, 2173, 2075, 1314, 965, 2757, 17659, 267, 327, 420, 436, 7962, 13340, 4453, 314, 4438, 2396, 14, 267, 327, 574, 26, 769, 1395, 3659, 370, 1924, 13852, 2173, 2075, 543, 642, 2173, 2075, 267, 327, 263, 1305, 1902, 4453, 3304, 63, 392, 5609, 503, 2173, 5609, 14, 267, 291, 423, 7655, 63, 475, 63, 1832, 63, 32662, 275, 1211, 342, 267, 291, 423, 2184, 63, 30378, 63, 4058, 63, 3813, 63, 1450, 275, 756, 339, 347, 1255, 8, 277, 304, 267, 408, 267, 14618, 314, 4438, 9834, 370, 1006, 5489, 3718, 14, 398, 1910, 8459, 478, 314, 4438, 340, 18175, 1931, 365, 440, 3748, 701, 1263, 402, 314, 2569, 267, 28156, 12, 284, 14, 69, 2020, 340, 398, 2508, 1233, 13, 1457, 447, 2366, 953, 365, 63, 2024, 63, 1450, 63, 4946, 8, 2184, 63, 3908, 12, 18175, 1931, 9, 508, 756, 267, 408, 267, 1125, 63, 1188, 275, 334, 288, 1867, 78, 4520, 14, 1413, 456, 1405, 1172, 2757, 17659, 315, 543, 298, 288, 298, 7382, 8, 7420, 12, 1967, 9, 1067, 4202, 78, 1314, 1172, 440, 298, 288, 298, 1474, 317, 25171, 590, 2757, 7962, 13340, 315, 314, 18175, 1067, 3134, 78, 2, 288, 298, 19993, 4503, 3427, 78, 1045, 18175, 8, 7420, 12, 959, 17211, 78, 2, 288, 298, 259, 2173, 2075, 275, 20171, 14, 12991, 63, 392, 2075, 17158, 78, 2, 288, 298, 259, 2263, 60, 78, 2, 288, 298, 259, 2150, 2173, 2075, 59, 16, 7272, 78, 2, 267, 776, 267, 340, 440, 291, 423, 2184, 63, 30378, 63, 4058, 63, 3813, 63, 1450, 26, 221, 327, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 6376, 13, 4166, 288, 327, 1910, 2827, 314, 4438, 288, 327, 2670, 626, 2257, 2173, 5609, 1172, 2757, 7962, 13340, 26, 288, 340, 291, 423, 271, 19570, 63, 392, 2075, 63, 1580, 1137, 291, 423, 19570, 63, 392, 2075, 63, 1580, 26, 355, 746, 1413, 456, 390, 14552, 547, 8, 705, 63, 1188, 9, 953, 340, 822, 8, 277, 423, 19570, 63, 392, 2075, 63, 1580, 9, 508, 378, 26, 355, 327, 3091, 2257, 2173, 5609, 12, 2951, 3222, 314, 20304, 1967, 5431, 355, 367, 284, 315, 1425, 8, 277, 423, 1450, 14, 1507, 304, 490, 291, 14, 2254, 8, 8293, 8, 277, 423, 1760, 63, 513, 430, 288, 587, 26, 355, 327, 1626, 67, 6165, 2173, 5609, 1172, 2757, 17659, 315, 4438, 2396, 355, 327, 2104, 1924, 8494, 12, 18310, 436, 7962, 6280, 282, 892, 2173, 2075, 436, 355, 327, 3350, 314, 2173, 2075, 1305, 315, 1006, 3718, 1808, 652, 14, 355, 367, 284, 315, 1425, 8, 277, 423, 1450, 14, 1507, 304, 490, 340, 284, 508, 378, 26, 221, 327, 7529, 1133, 1570, 2257, 2173, 2075, 2762, 717, 291, 14, 2254, 8, 8293, 8, 277, 423, 1760, 63, 513, 430, 490, 587, 26, 717, 327, 7743, 2257, 2173, 2075 ]
[ 1882, 2803, 26, 2774, 13, 24, 1882, 199, 3, 257, 1898, 9708, 7290, 49, 13, 16442, 334, 1544, 14, 1715, 81, 14, 335, 9, 199, 3, 199, 3, 257, 3909, 1334, 314, 3668, 844, 12, 3394, 499, 14, 16, 334, 1589, 298, 3761, 3547, 199, 3, 257, 1265, 1443, 440, 675, 642, 570, 871, 315, 4151, 543, 314, 844, 14, 199, 3, 257, 2047, 1443, 3332, 282, 1331, 402, 314, 844, 737, 199, 3, 199, 3, 755, 1455, 921, 1544, 14, 3796, 14, 1308, 15, 2383, 15, 3961, 13, 18, 14, 16, 199, 3, 199, 3, 257, 4158, 1415, 701, 3964, 4179, 503, 4193, 370, 315, 3575, 12, 2032, 199, 3, 257, 1854, 1334, 314, 844, 365, 1854, 641, 376, 298, 1179, 2281, 2, 4207, 12, 199, 3, 257, 2428, 2990, 1549, 4217, 1634, 1821, 3826, 12, 1902, 4056, 503, 2478, 14, 199, 3, 257, 1666, 314, 844, 367, 314, 2488, 2637, 4210, 3443, 436, 199, 3, 257, 4204, 1334, 314, 844, 14, 199, 624, 199, 11654, 370, 5669, 17222, 14, 199, 199, 9846, 26, 272, 2508, 1233, 13, 1457, 447, 2366, 398, 543, 18175, 8, 7420, 12, 841, 304, 288, 869, 1204, 1894, 66, 267, 820, 90, 8, 45, 63, 2252, 15, 19, 4959, 1204, 1894, 66, 199, 624, 199, 199, 504, 1331, 492, 14800, 199, 199, 504, 2199, 81, 14, 2497, 18131, 492, 10082, 8524, 199, 504, 2199, 81, 14, 1483, 492, 4580, 6280, 12, 1487, 12991, 199, 504, 13653, 1974, 492, 5518, 63, 3908, 12, 5978, 63, 3908, 63, 4399, 421, 199, 533, 1413, 456, 390, 14552, 547, 8, 1726, 304, 272, 408, 1726, 4915, 1380, 314, 30097, 402, 282, 2173, 2075, 365, 557, 31197, 4453, 282, 4438, 624, 421, 199, 533, 18175, 1931, 26, 272, 408, 272, 18175, 3404, 1947, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1967, 304, 267, 291, 14, 1507, 275, 1967, 267, 291, 14, 344, 275, 18175, 1931, 14, 3813, 63, 1450, 63, 344, 267, 18175, 1931, 14, 3813, 63, 1450, 63, 344, 847, 413, 339, 347, 636, 4077, 721, 277, 12, 1163, 304, 267, 372, 1228, 8, 1848, 12, 18175, 1931, 9, 436, 291, 14, 344, 508, 1163, 14, 344, 436, 291, 14, 1507, 508, 1163, 14, 1507, 339, 347, 636, 685, 721, 277, 12, 1163, 304, 267, 372, 440, 291, 855, 4077, 721, 1848, 9, 339, 4438, 63, 1450, 63, 344, 275, 378, 421, 199, 533, 18175, 8524, 8, 6845, 8524, 304, 272, 408, 272, 31299, 1006, 3718, 436, 12, 1380, 4224, 12, 24956, 3062, 1967, 5431, 340, 949, 4438, 1947, 272, 3016, 6869, 365, 2808, 14, 272, 982, 2337, 365, 1373, 12, 652, 9584, 282, 4438, 63, 1450, 370, 314, 3718, 436, 16178, 3062, 641, 14, 272, 408, 339, 347, 636, 826, 721, 277, 12, 1967, 304, 267, 408, 267, 11578, 282, 18175, 8524, 14, 398, 3033, 26, 288, 1967, 334, 442, 304, 4860, 402, 4438, 10615, 14, 267, 408, 267, 10082, 8524, 855, 826, 721, 277, 9, 267, 291, 423, 1450, 275, 18175, 1931, 8, 1507, 9, 267, 291, 423, 1760, 63, 513, 275, 942, 267, 291, 423, 19570, 63, 392, 2075, 63, 1580, 275, 663, 342, 267, 291, 423, 271, 19570, 63, 392, 2075, 63, 1580, 275, 663, 342, 267, 327, 790, 26, 2173, 2075, 1305, 402, 282, 2257, 2173, 2075, 12, 284, 14, 69, 14, 282, 2173, 2075, 1314, 965, 2757, 17659, 267, 327, 420, 436, 7962, 13340, 4453, 314, 4438, 2396, 14, 267, 327, 574, 26, 769, 1395, 3659, 370, 1924, 13852, 2173, 2075, 543, 642, 2173, 2075, 267, 327, 263, 1305, 1902, 4453, 3304, 63, 392, 5609, 503, 2173, 5609, 14, 267, 291, 423, 7655, 63, 475, 63, 1832, 63, 32662, 275, 1211, 342, 267, 291, 423, 2184, 63, 30378, 63, 4058, 63, 3813, 63, 1450, 275, 756, 339, 347, 1255, 8, 277, 304, 267, 408, 267, 14618, 314, 4438, 9834, 370, 1006, 5489, 3718, 14, 398, 1910, 8459, 478, 314, 4438, 340, 18175, 1931, 365, 440, 3748, 701, 1263, 402, 314, 2569, 267, 28156, 12, 284, 14, 69, 2020, 340, 398, 2508, 1233, 13, 1457, 447, 2366, 953, 365, 63, 2024, 63, 1450, 63, 4946, 8, 2184, 63, 3908, 12, 18175, 1931, 9, 508, 756, 267, 408, 267, 1125, 63, 1188, 275, 334, 288, 1867, 78, 4520, 14, 1413, 456, 1405, 1172, 2757, 17659, 315, 543, 298, 288, 298, 7382, 8, 7420, 12, 1967, 9, 1067, 4202, 78, 1314, 1172, 440, 298, 288, 298, 1474, 317, 25171, 590, 2757, 7962, 13340, 315, 314, 18175, 1067, 3134, 78, 2, 288, 298, 19993, 4503, 3427, 78, 1045, 18175, 8, 7420, 12, 959, 17211, 78, 2, 288, 298, 259, 2173, 2075, 275, 20171, 14, 12991, 63, 392, 2075, 17158, 78, 2, 288, 298, 259, 2263, 60, 78, 2, 288, 298, 259, 2150, 2173, 2075, 59, 16, 7272, 78, 2, 267, 776, 267, 340, 440, 291, 423, 2184, 63, 30378, 63, 4058, 63, 3813, 63, 1450, 26, 221, 327, 4287, 26, 3507, 29, 7354, 13, 3479, 13, 6376, 13, 4166, 288, 327, 1910, 2827, 314, 4438, 288, 327, 2670, 626, 2257, 2173, 5609, 1172, 2757, 7962, 13340, 26, 288, 340, 291, 423, 271, 19570, 63, 392, 2075, 63, 1580, 1137, 291, 423, 19570, 63, 392, 2075, 63, 1580, 26, 355, 746, 1413, 456, 390, 14552, 547, 8, 705, 63, 1188, 9, 953, 340, 822, 8, 277, 423, 19570, 63, 392, 2075, 63, 1580, 9, 508, 378, 26, 355, 327, 3091, 2257, 2173, 5609, 12, 2951, 3222, 314, 20304, 1967, 5431, 355, 367, 284, 315, 1425, 8, 277, 423, 1450, 14, 1507, 304, 490, 291, 14, 2254, 8, 8293, 8, 277, 423, 1760, 63, 513, 430, 288, 587, 26, 355, 327, 1626, 67, 6165, 2173, 5609, 1172, 2757, 17659, 315, 4438, 2396, 355, 327, 2104, 1924, 8494, 12, 18310, 436, 7962, 6280, 282, 892, 2173, 2075, 436, 355, 327, 3350, 314, 2173, 2075, 1305, 315, 1006, 3718, 1808, 652, 14, 355, 367, 284, 315, 1425, 8, 277, 423, 1450, 14, 1507, 304, 490, 340, 284, 508, 378, 26, 221, 327, 7529, 1133, 1570, 2257, 2173, 2075, 2762, 717, 291, 14, 2254, 8, 8293, 8, 277, 423, 1760, 63, 513, 430, 490, 587, 26, 717, 327, 7743, 2257, 2173, 2075, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
Zsailer/epistasis
epistasis/models/nonlinear/minimizer.py
2
3564
import inspect import lmfit from lmfit import Parameter, Parameters from abc import ABC, abstractmethod # ---------------------- Abstract Minimizer class ------------------------- class Minimizer(ABC): """Abstract Base Class for function minimizers. Wraps a function. Fits data using the function. Then, that fitted function can be used to transform data. """ def __init__(self, function, **p0): pass @abstractmethod def function(self, x, **params): """Execute function given parameters. """ @abstractmethod def predict(self, x): """Predict y, given x, from the fitted model. """ @abstractmethod def transform(self, x, y): """Method that transforms y onto the x scale using the minimized fit. """ @abstractmethod def fit(self, x, y): """Fit the x, y data using the function. Store fit. """ # ---------------------- Abstract Minimizer class ------------------------- class FunctionMinimizer(Minimizer): """Minimizer object that fits data using a function. """ def __init__(self, function, **p0): # Do some inspection to get the parameters from the nonlinear # function argument list. func_signature = inspect.signature(function) func_params = list(func_signature.parameters.keys()) if func_params[0] != "x": raise Exception("First argument of the nonlinear function must " "be `x`.") # Construct lmfit parameters object self.parameters = Parameters() for p in func_params[1:]: # Get starting value of parameter if given. val = None if p in p0: val = p0[p] # Add parameter. self.parameters.add(name=p, value=val) # Set function self._function = function def function(self, x, *args, **kwargs): """Execute the function.""" return self._function(x, *args, **kwargs) def predict(self, x): """Call function""" return self._function(x, **self.parameters) def transform(self, x, y): """Transform y onto the x scale.""" ymodel = self.predict(x) return (y - ymodel) + x def fit(self, x, y): """Fit the function""" # Store residual steps in case fit fails. last_residual_set = None # Residual function to minimize. def residual(params, func, x, y=None): # Fit model parvals = list(params.values()) ymodel = func(x, *parvals) # Store items in case of error. nonlocal last_residual_set last_residual_set = (params, ymodel) return y - ymodel # Minimize the above residual function. try: self.minimizer = lmfit.minimize( residual, self.parameters, args=[self._function, x], kws={'y': y}) # Point to nonlinear. self.parameters = self.minimizer.params # If fitting fails, print what happened except Exception as e: # if e is ValueError print("ERROR! Some of the transformed phenotypes are invalid.") print("\nParameters:") print("----------") print(last_residual_set[0].pretty_print()) print("\nTransformed phenotypes:") print("----------------------") print(last_residual_set[1]) raise e
unlicense
[ 646, 6485, 199, 646, 24546, 3269, 199, 504, 24546, 3269, 492, 12009, 12, 3897, 199, 199, 504, 13022, 492, 17281, 12, 9006, 765, 199, 199, 3, 10652, 8648, 11836, 10195, 1017, 1793, 1021, 10652, 9960, 199, 199, 533, 10195, 1017, 1793, 8, 8390, 304, 272, 408, 8458, 3523, 8089, 367, 805, 18790, 6315, 14, 339, 644, 8146, 282, 805, 14, 481, 1405, 666, 1808, 314, 805, 14, 9442, 12, 626, 26093, 805, 272, 883, 506, 1202, 370, 5793, 666, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 805, 12, 1011, 80, 16, 304, 267, 986, 339, 768, 10315, 272, 347, 805, 8, 277, 12, 671, 12, 1011, 1162, 304, 267, 408, 12049, 805, 1627, 2633, 14, 267, 408, 339, 768, 10315, 272, 347, 12610, 8, 277, 12, 671, 304, 267, 408, 28240, 612, 12, 1627, 671, 12, 687, 314, 26093, 1402, 14, 267, 408, 339, 768, 10315, 272, 347, 5793, 8, 277, 12, 671, 12, 612, 304, 267, 408, 3767, 626, 18501, 612, 14602, 314, 671, 4666, 1808, 314, 18790, 1759, 5542, 14, 267, 408, 339, 768, 10315, 272, 347, 5542, 8, 277, 12, 671, 12, 612, 304, 267, 408, 13776, 314, 671, 12, 612, 666, 1808, 314, 805, 14, 13874, 5542, 14, 267, 408, 199, 199, 3, 10652, 8648, 11836, 10195, 1017, 1793, 1021, 10652, 9960, 421, 199, 533, 6801, 4649, 1017, 1793, 8, 4649, 1017, 1793, 304, 272, 408, 4649, 1017, 1793, 909, 626, 20147, 666, 1808, 282, 805, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 805, 12, 1011, 80, 16, 304, 267, 327, 4226, 2005, 5261, 10303, 370, 664, 314, 2633, 687, 314, 2222, 6676, 267, 327, 805, 1423, 769, 14, 267, 2562, 63, 5233, 275, 6485, 14, 5233, 8, 1593, 9, 267, 2562, 63, 1162, 275, 769, 8, 1532, 63, 5233, 14, 3214, 14, 1612, 1012, 398, 340, 2562, 63, 1162, 59, 16, 61, 1137, 298, 88, 582, 288, 746, 2186, 480, 7147, 1423, 402, 314, 2222, 6676, 805, 1471, 298, 1169, 298, 1235, 658, 88, 2313, 531, 398, 327, 9215, 24546, 3269, 2633, 909, 267, 291, 14, 3214, 275, 3897, 342, 267, 367, 299, 315, 2562, 63, 1162, 59, 17, 10688, 288, 327, 2372, 6617, 574, 402, 2725, 340, 1627, 14, 288, 1139, 275, 488, 288, 340, 299, 315, 299, 16, 26, 355, 1139, 275, 299, 16, 59, 80, 61, 288, 327, 2654, 2725, 14, 288, 291, 14, 3214, 14, 525, 8, 354, 29, 80, 12, 574, 29, 637, 9, 398, 327, 2494, 805, 267, 291, 423, 1593, 275, 805, 339, 347, 805, 8, 277, 12, 671, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 12049, 314, 805, 1041, 267, 372, 291, 423, 1593, 8, 88, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 12610, 8, 277, 12, 671, 304, 267, 408, 2176, 805, 624, 267, 372, 291, 423, 1593, 8, 88, 12, 1011, 277, 14, 3214, 9, 339, 347, 5793, 8, 277, 12, 671, 12, 612, 304, 267, 408, 6939, 612, 14602, 314, 671, 4666, 1041, 267, 612, 1238, 275, 291, 14, 6892, 8, 88, 9, 267, 372, 334, 89, 446, 612, 1238, 9, 435, 671, 339, 347, 5542, 8, 277, 12, 671, 12, 612, 304, 267, 408, 13776, 314, 805, 624, 267, 327, 13874, 16731, 7124, 315, 1930, 5542, 6918, 14, 267, 2061, 63, 20161, 63, 409, 275, 488, 398, 327, 799, 10969, 805, 370, 24720, 14, 267, 347, 16731, 8, 1162, 12, 2562, 12, 671, 12, 612, 29, 403, 304, 288, 327, 25971, 1402, 288, 623, 3643, 275, 769, 8, 1162, 14, 1459, 1012, 288, 612, 1238, 275, 2562, 8, 88, 12, 627, 462, 3643, 9, 953, 327, 13874, 2974, 315, 1930, 402, 1125, 14, 288, 2222, 1832, 2061, 63, 20161, 63, 409, 288, 2061, 63, 20161, 63, 409, 275, 334, 1162, 12, 612, 1238, 9, 953, 372, 612, 446, 612, 1238, 398, 327, 10195, 11807, 314, 3432, 16731, 805, 14, 267, 862, 26, 288, 291, 14, 827, 1017, 1793, 275, 24546, 3269, 14, 19333, 8, 355, 16731, 12, 355, 291, 14, 3214, 12, 355, 1249, 1524, 277, 423, 1593, 12, 671, 467, 355, 4775, 83, 3713, 89, 356, 612, 1552, 953, 327, 7584, 370, 2222, 6676, 14, 288, 291, 14, 3214, 275, 291, 14, 827, 1017, 1793, 14, 1162, 398, 327, 982, 21774, 6918, 12, 870, 4052, 21056, 267, 871, 2186, 465, 325, 26, 288, 327, 340, 325, 365, 1722, 288, 870, 480, 3170, 1, 6601, 402, 314, 14834, 3945, 287, 27760, 787, 3866, 2685, 288, 870, 4582, 78, 5976, 9107, 288, 870, 480, 9460, 531, 288, 870, 8, 2019, 63, 20161, 63, 409, 59, 16, 1055, 9118, 63, 1361, 1012, 288, 870, 4582, 78, 3188, 6194, 3945, 287, 27760, 9107, 288, 870, 480, 777, 8648, 531, 288, 870, 8, 2019, 63, 20161, 63, 409, 59, 17, 566, 288, 746, 325, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768 ]
[ 6485, 199, 646, 24546, 3269, 199, 504, 24546, 3269, 492, 12009, 12, 3897, 199, 199, 504, 13022, 492, 17281, 12, 9006, 765, 199, 199, 3, 10652, 8648, 11836, 10195, 1017, 1793, 1021, 10652, 9960, 199, 199, 533, 10195, 1017, 1793, 8, 8390, 304, 272, 408, 8458, 3523, 8089, 367, 805, 18790, 6315, 14, 339, 644, 8146, 282, 805, 14, 481, 1405, 666, 1808, 314, 805, 14, 9442, 12, 626, 26093, 805, 272, 883, 506, 1202, 370, 5793, 666, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 805, 12, 1011, 80, 16, 304, 267, 986, 339, 768, 10315, 272, 347, 805, 8, 277, 12, 671, 12, 1011, 1162, 304, 267, 408, 12049, 805, 1627, 2633, 14, 267, 408, 339, 768, 10315, 272, 347, 12610, 8, 277, 12, 671, 304, 267, 408, 28240, 612, 12, 1627, 671, 12, 687, 314, 26093, 1402, 14, 267, 408, 339, 768, 10315, 272, 347, 5793, 8, 277, 12, 671, 12, 612, 304, 267, 408, 3767, 626, 18501, 612, 14602, 314, 671, 4666, 1808, 314, 18790, 1759, 5542, 14, 267, 408, 339, 768, 10315, 272, 347, 5542, 8, 277, 12, 671, 12, 612, 304, 267, 408, 13776, 314, 671, 12, 612, 666, 1808, 314, 805, 14, 13874, 5542, 14, 267, 408, 199, 199, 3, 10652, 8648, 11836, 10195, 1017, 1793, 1021, 10652, 9960, 421, 199, 533, 6801, 4649, 1017, 1793, 8, 4649, 1017, 1793, 304, 272, 408, 4649, 1017, 1793, 909, 626, 20147, 666, 1808, 282, 805, 14, 272, 408, 272, 347, 636, 826, 721, 277, 12, 805, 12, 1011, 80, 16, 304, 267, 327, 4226, 2005, 5261, 10303, 370, 664, 314, 2633, 687, 314, 2222, 6676, 267, 327, 805, 1423, 769, 14, 267, 2562, 63, 5233, 275, 6485, 14, 5233, 8, 1593, 9, 267, 2562, 63, 1162, 275, 769, 8, 1532, 63, 5233, 14, 3214, 14, 1612, 1012, 398, 340, 2562, 63, 1162, 59, 16, 61, 1137, 298, 88, 582, 288, 746, 2186, 480, 7147, 1423, 402, 314, 2222, 6676, 805, 1471, 298, 1169, 298, 1235, 658, 88, 2313, 531, 398, 327, 9215, 24546, 3269, 2633, 909, 267, 291, 14, 3214, 275, 3897, 342, 267, 367, 299, 315, 2562, 63, 1162, 59, 17, 10688, 288, 327, 2372, 6617, 574, 402, 2725, 340, 1627, 14, 288, 1139, 275, 488, 288, 340, 299, 315, 299, 16, 26, 355, 1139, 275, 299, 16, 59, 80, 61, 288, 327, 2654, 2725, 14, 288, 291, 14, 3214, 14, 525, 8, 354, 29, 80, 12, 574, 29, 637, 9, 398, 327, 2494, 805, 267, 291, 423, 1593, 275, 805, 339, 347, 805, 8, 277, 12, 671, 12, 627, 589, 12, 1011, 958, 304, 267, 408, 12049, 314, 805, 1041, 267, 372, 291, 423, 1593, 8, 88, 12, 627, 589, 12, 1011, 958, 9, 339, 347, 12610, 8, 277, 12, 671, 304, 267, 408, 2176, 805, 624, 267, 372, 291, 423, 1593, 8, 88, 12, 1011, 277, 14, 3214, 9, 339, 347, 5793, 8, 277, 12, 671, 12, 612, 304, 267, 408, 6939, 612, 14602, 314, 671, 4666, 1041, 267, 612, 1238, 275, 291, 14, 6892, 8, 88, 9, 267, 372, 334, 89, 446, 612, 1238, 9, 435, 671, 339, 347, 5542, 8, 277, 12, 671, 12, 612, 304, 267, 408, 13776, 314, 805, 624, 267, 327, 13874, 16731, 7124, 315, 1930, 5542, 6918, 14, 267, 2061, 63, 20161, 63, 409, 275, 488, 398, 327, 799, 10969, 805, 370, 24720, 14, 267, 347, 16731, 8, 1162, 12, 2562, 12, 671, 12, 612, 29, 403, 304, 288, 327, 25971, 1402, 288, 623, 3643, 275, 769, 8, 1162, 14, 1459, 1012, 288, 612, 1238, 275, 2562, 8, 88, 12, 627, 462, 3643, 9, 953, 327, 13874, 2974, 315, 1930, 402, 1125, 14, 288, 2222, 1832, 2061, 63, 20161, 63, 409, 288, 2061, 63, 20161, 63, 409, 275, 334, 1162, 12, 612, 1238, 9, 953, 372, 612, 446, 612, 1238, 398, 327, 10195, 11807, 314, 3432, 16731, 805, 14, 267, 862, 26, 288, 291, 14, 827, 1017, 1793, 275, 24546, 3269, 14, 19333, 8, 355, 16731, 12, 355, 291, 14, 3214, 12, 355, 1249, 1524, 277, 423, 1593, 12, 671, 467, 355, 4775, 83, 3713, 89, 356, 612, 1552, 953, 327, 7584, 370, 2222, 6676, 14, 288, 291, 14, 3214, 275, 291, 14, 827, 1017, 1793, 14, 1162, 398, 327, 982, 21774, 6918, 12, 870, 4052, 21056, 267, 871, 2186, 465, 325, 26, 288, 327, 340, 325, 365, 1722, 288, 870, 480, 3170, 1, 6601, 402, 314, 14834, 3945, 287, 27760, 787, 3866, 2685, 288, 870, 4582, 78, 5976, 9107, 288, 870, 480, 9460, 531, 288, 870, 8, 2019, 63, 20161, 63, 409, 59, 16, 1055, 9118, 63, 1361, 1012, 288, 870, 4582, 78, 3188, 6194, 3945, 287, 27760, 9107, 288, 870, 480, 777, 8648, 531, 288, 870, 8, 2019, 63, 20161, 63, 409, 59, 17, 566, 288, 746, 325, 199, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 32768, 0 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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