Best Python code snippet using playwright-python
all_nodes_api.py
Source:all_nodes_api.py
1import bpy2new_mat = bpy.data.materials.get('Test.002')3if not new_mat:4 new_mat = bpy.data.materials.new('Test.002')5 6new_mat.use_nodes = True7node_tree = new_mat.node_tree8nodes = node_tree.nodes9nodes.clear()10 11links = node_tree.links12links.clear()13 14# Nodes :1516new_node = nodes.new(type='NodeFrame')17new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)18new_node.label_size = 2019new_node.location = (0.0, 0.0)20new_node.name = 'Frame'21new_node.select = False22new_node.width = 200.02324new_node = nodes.new(type='ShaderNodeBlackbody')25new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)26new_node.location = (0.0, 0.0)27new_node.name = 'Blackbody'28new_node.select = False29new_node.width = 150.030new_node.inputs[0].default_value = 1500.031new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]3233new_node = nodes.new(type='ShaderNodeClamp')34new_node.clamp_type = 'MINMAX'35new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)36new_node.location = (0.0, 0.0)37new_node.name = 'Clamp'38new_node.select = False39new_node.width = 140.040new_node.inputs[0].default_value = 1.041new_node.inputs[1].default_value = 0.042new_node.inputs[2].default_value = 1.043new_node.outputs[0].default_value = 0.04445new_node = nodes.new(type='ShaderNodeValToRGB')46new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)47cr = new_node.color_ramp48cr.color_mode = 'RGB'49cr.hue_interpolation = 'NEAR'50cr.interpolation = 'LINEAR' 51new_stop = cr.elements.new(0.0)52new_stop.color = [0.0, 0.0, 0.0, 1.0]53new_stop = cr.elements.new(1.0)54new_stop.color = [1.0, 1.0, 1.0, 1.0]55removed_black = removed_white = False56for i in range(len(cr.elements) - 1, -1, -1):57 stop = cr.elements[i]58 if not removed_black and stop.position == 0 and all([stop.color[i] == (0, 0, 0, 1)[i] for i in range(4)]):59 cr.elements.remove(stop)60 removed_black = True61 if not removed_white and stop.position == 1 and all([stop.color[i] == (1, 1, 1, 1)[i] for i in range(4)]):62 cr.elements.remove(stop)63 removed_white = True 64new_node.location = (0.0, 0.0)65new_node.name = 'ColorRamp'66new_node.select = False67new_node.width = 240.068new_node.inputs[0].default_value = 0.569new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]70new_node.outputs[1].default_value = 0.07172new_node = nodes.new(type='ShaderNodeCombineHSV')73new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)74new_node.location = (0.0, 0.0)75new_node.name = 'Combine HSV'76new_node.select = False77new_node.width = 140.078new_node.inputs[0].default_value = 0.079new_node.inputs[1].default_value = 0.080new_node.inputs[2].default_value = 0.081new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]8283new_node = nodes.new(type='ShaderNodeCombineRGB')84new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)85new_node.location = (0.0, 0.0)86new_node.name = 'Combine RGB'87new_node.select = False88new_node.width = 140.089new_node.inputs[0].default_value = 0.090new_node.inputs[1].default_value = 0.091new_node.inputs[2].default_value = 0.092new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]9394new_node = nodes.new(type='ShaderNodeCombineXYZ')95new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)96new_node.location = (0.0, 0.0)97new_node.name = 'Combine XYZ'98new_node.select = False99new_node.width = 140.0100new_node.inputs[0].default_value = 0.0101new_node.inputs[1].default_value = 0.0102new_node.inputs[2].default_value = 0.0103new_node.outputs[0].default_value = [0.0, 0.0, 0.0]104105new_node = nodes.new(type='ShaderNodeMapRange')106new_node.clamp = True107new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)108new_node.interpolation_type = 'LINEAR'109new_node.location = (0.0, 0.0)110new_node.name = 'Map Range'111new_node.select = False112new_node.width = 140.0113new_node.inputs[0].default_value = 1.0114new_node.inputs[1].default_value = 0.0115new_node.inputs[2].default_value = 1.0116new_node.inputs[3].default_value = 0.0117new_node.inputs[4].default_value = 1.0118new_node.inputs[5].default_value = 4.0119new_node.outputs[0].default_value = 0.0120121new_node = nodes.new(type='ShaderNodeMath')122new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)123new_node.location = (0.0, 0.0)124new_node.name = 'Math'125new_node.operation = 'ADD'126new_node.select = False127new_node.use_clamp = False128new_node.width = 140.0129new_node.inputs[0].default_value = 0.5130new_node.inputs[1].default_value = 0.5131new_node.inputs[2].default_value = 0.0132new_node.outputs[0].default_value = 0.0133134new_node = nodes.new(type='ShaderNodeRGBToBW')135new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)136new_node.location = (0.0, 0.0)137new_node.name = 'RGB to BW'138new_node.select = False139new_node.width = 140.0140new_node.inputs[0].default_value = [0.5, 0.5, 0.5, 1.0]141new_node.outputs[0].default_value = 0.0142143new_node = nodes.new(type='ShaderNodeSeparateHSV')144new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)145new_node.location = (0.0, 0.0)146new_node.name = 'Separate HSV'147new_node.select = False148new_node.width = 140.0149new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]150new_node.outputs[0].default_value = 0.0151new_node.outputs[1].default_value = 0.0152new_node.outputs[2].default_value = 0.0153154new_node = nodes.new(type='ShaderNodeSeparateRGB')155new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)156new_node.location = (0.0, 0.0)157new_node.name = 'Separate RGB'158new_node.select = False159new_node.width = 140.0160new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]161new_node.outputs[0].default_value = 0.0162new_node.outputs[1].default_value = 0.0163new_node.outputs[2].default_value = 0.0164165new_node = nodes.new(type='ShaderNodeSeparateXYZ')166new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)167new_node.location = (0.0, 0.0)168new_node.name = 'Separate XYZ'169new_node.select = False170new_node.width = 140.0171new_node.inputs[0].default_value = [0.0, 0.0, 0.0]172new_node.outputs[0].default_value = 0.0173new_node.outputs[1].default_value = 0.0174new_node.outputs[2].default_value = 0.0175176new_node = nodes.new(type='ShaderNodeShaderToRGB')177new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)178new_node.location = (0.0, 0.0)179new_node.name = 'Shader to RGB'180new_node.select = False181new_node.width = 140.0182new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]183new_node.outputs[1].default_value = 0.0184185new_node = nodes.new(type='ShaderNodeVectorMath')186new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)187new_node.location = (0.0, 0.0)188new_node.name = 'Vector Math'189new_node.operation = 'ADD'190new_node.select = False191new_node.width = 140.0192new_node.inputs[0].default_value = [0.0, 0.0, 0.0]193new_node.inputs[1].default_value = [0.0, 0.0, 0.0]194new_node.inputs[2].default_value = [0.0, 0.0, 0.0]195new_node.inputs[3].default_value = 1.0196new_node.outputs[0].default_value = [0.0, 0.0, 0.0]197new_node.outputs[1].default_value = 0.0198199new_node = nodes.new(type='ShaderNodeWavelength')200new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)201new_node.location = (0.0, 0.0)202new_node.name = 'Wavelength'203new_node.select = False204new_node.width = 150.0205new_node.inputs[0].default_value = 500.0206new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]207208new_node = nodes.new(type='ShaderNodeAmbientOcclusion')209new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)210new_node.inside = False211new_node.location = (0.0, 0.0)212new_node.name = 'Ambient Occlusion'213new_node.only_local = False214new_node.samples = 16215new_node.select = False216new_node.width = 140.0217new_node.inputs[0].default_value = [1.0, 1.0, 1.0, 1.0]218new_node.inputs[1].default_value = 1.0219new_node.inputs[2].default_value = [0.0, 0.0, 0.0]220new_node.outputs[0].default_value = [1.0, 1.0, 1.0, 1.0]221new_node.outputs[1].default_value = 0.0222223new_node = nodes.new(type='ShaderNodeAttribute')224new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)225new_node.location = (0.0, 0.0)226new_node.name = 'Attribute'227new_node.select = False228new_node.width = 140.0229new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]230new_node.outputs[1].default_value = [0.0, 0.0, 0.0]231new_node.outputs[2].default_value = 0.0232233new_node = nodes.new(type='ShaderNodeBevel')234new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)235new_node.location = (0.0, 0.0)236new_node.name = 'Bevel'237new_node.samples = 4238new_node.select = False239new_node.width = 140.0240new_node.inputs[0].default_value = 0.05000000074505806241new_node.inputs[1].default_value = [0.0, 0.0, 0.0]242new_node.outputs[0].default_value = [0.0, 0.0, 0.0]243244new_node = nodes.new(type='ShaderNodeCameraData')245new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)246new_node.location = (0.0, 0.0)247new_node.name = 'Camera Data'248new_node.select = False249new_node.width = 140.0250new_node.outputs[0].default_value = [0.0, 0.0, 0.0]251new_node.outputs[1].default_value = 0.0252new_node.outputs[2].default_value = 0.0253254new_node = nodes.new(type='ShaderNodeFresnel')255new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)256new_node.location = (0.0, 0.0)257new_node.name = 'Fresnel'258new_node.select = False259new_node.width = 140.0260new_node.inputs[0].default_value = 1.4500000476837158261new_node.inputs[1].default_value = [0.0, 0.0, 0.0]262new_node.outputs[0].default_value = 0.0263264new_node = nodes.new(type='ShaderNodeNewGeometry')265new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)266new_node.location = (0.0, 0.0)267new_node.name = 'Geometry'268new_node.select = False269new_node.width = 140.0270new_node.outputs[0].default_value = [0.0, 0.0, 0.0]271new_node.outputs[1].default_value = [0.0, 0.0, 0.0]272new_node.outputs[2].default_value = [0.0, 0.0, 0.0]273new_node.outputs[3].default_value = [0.0, 0.0, 0.0]274new_node.outputs[4].default_value = [0.0, 0.0, 0.0]275new_node.outputs[5].default_value = [0.0, 0.0, 0.0]276new_node.outputs[6].default_value = 0.0277new_node.outputs[7].default_value = 0.0278new_node.outputs[8].default_value = 0.0279280new_node = nodes.new(type='NodeGroupInput')281new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)282new_node.location = (0.0, 0.0)283new_node.name = 'Group Input'284new_node.select = False285new_node.width = 140.0286287new_node = nodes.new(type='ShaderNodeHairInfo')288new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)289new_node.location = (0.0, 0.0)290new_node.name = 'Hair Info'291new_node.select = False292new_node.width = 140.0293new_node.outputs[0].default_value = 0.0294new_node.outputs[1].default_value = 0.0295new_node.outputs[2].default_value = 0.0296new_node.outputs[3].default_value = [0.0, 0.0, 0.0]297new_node.outputs[4].default_value = 0.0298299new_node = nodes.new(type='ShaderNodeLayerWeight')300new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)301new_node.location = (0.0, 0.0)302new_node.name = 'Layer Weight'303new_node.select = False304new_node.width = 140.0305new_node.inputs[0].default_value = 0.5306new_node.inputs[1].default_value = [0.0, 0.0, 0.0]307new_node.outputs[0].default_value = 0.0308new_node.outputs[1].default_value = 0.0309310new_node = nodes.new(type='ShaderNodeLightPath')311new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)312new_node.location = (0.0, 0.0)313new_node.name = 'Light Path'314new_node.select = False315new_node.width = 140.0316new_node.outputs[0].default_value = 0.0317new_node.outputs[1].default_value = 0.0318new_node.outputs[2].default_value = 0.0319new_node.outputs[3].default_value = 0.0320new_node.outputs[4].default_value = 0.0321new_node.outputs[5].default_value = 0.0322new_node.outputs[6].default_value = 0.0323new_node.outputs[7].default_value = 0.0324new_node.outputs[8].default_value = 0.0325new_node.outputs[9].default_value = 0.0326new_node.outputs[10].default_value = 0.0327new_node.outputs[11].default_value = 0.0328new_node.outputs[12].default_value = 0.0329330new_node = nodes.new(type='ShaderNodeObjectInfo')331new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)332new_node.location = (0.0, 0.0)333new_node.name = 'Object Info'334new_node.select = False335new_node.width = 140.0336new_node.outputs[0].default_value = [0.0, 0.0, 0.0]337new_node.outputs[1].default_value = [0.0, 0.0, 0.0, 0.0]338new_node.outputs[2].default_value = 0.0339new_node.outputs[3].default_value = 0.0340new_node.outputs[4].default_value = 0.0341342new_node = nodes.new(type='ShaderNodeParticleInfo')343new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)344new_node.location = (0.0, 0.0)345new_node.name = 'Particle Info'346new_node.select = False347new_node.width = 140.0348new_node.outputs[0].default_value = 0.0349new_node.outputs[1].default_value = 0.0350new_node.outputs[2].default_value = 0.0351new_node.outputs[3].default_value = 0.0352new_node.outputs[4].default_value = [0.0, 0.0, 0.0]353new_node.outputs[5].default_value = 0.0354new_node.outputs[6].default_value = [0.0, 0.0, 0.0]355new_node.outputs[7].default_value = [0.0, 0.0, 0.0]356357new_node = nodes.new(type='ShaderNodeRGB')358new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)359new_node.location = (0.0, 0.0)360new_node.name = 'RGB'361new_node.select = False362new_node.width = 140.0363new_node.outputs[0].default_value = [0.5, 0.5, 0.5, 1.0]364365new_node = nodes.new(type='ShaderNodeTangent')366new_node.axis = 'Z'367new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)368new_node.direction_type = 'RADIAL'369new_node.location = (0.0, 0.0)370new_node.name = 'Tangent'371new_node.select = False372new_node.width = 150.0373new_node.outputs[0].default_value = [0.0, 0.0, 0.0]374375new_node = nodes.new(type='ShaderNodeTexCoord')376new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)377new_node.from_instancer = False378new_node.location = (0.0, 0.0)379new_node.name = 'Texture Coordinate'380new_node.object = None381new_node.select = False382new_node.width = 140.0383new_node.outputs[0].default_value = [0.0, 0.0, 0.0]384new_node.outputs[1].default_value = [0.0, 0.0, 0.0]385new_node.outputs[2].default_value = [0.0, 0.0, 0.0]386new_node.outputs[3].default_value = [0.0, 0.0, 0.0]387new_node.outputs[4].default_value = [0.0, 0.0, 0.0]388new_node.outputs[5].default_value = [0.0, 0.0, 0.0]389new_node.outputs[6].default_value = [0.0, 0.0, 0.0]390391new_node = nodes.new(type='ShaderNodeUVAlongStroke')392new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)393new_node.location = (0.0, 0.0)394new_node.name = 'UV Along Stroke'395new_node.select = False396new_node.use_tips = False397new_node.width = 140.0398new_node.outputs[0].default_value = [0.0, 0.0, 0.0]399400new_node = nodes.new(type='ShaderNodeUVMap')401new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)402new_node.from_instancer = False403new_node.location = (0.0, 0.0)404new_node.name = 'UV Map'405new_node.select = False406new_node.width = 150.0407new_node.outputs[0].default_value = [0.0, 0.0, 0.0]408409new_node = nodes.new(type='ShaderNodeValue')410new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)411new_node.location = (0.0, 0.0)412new_node.name = 'Value'413new_node.select = False414new_node.width = 140.0415new_node.outputs[0].default_value = 0.5416417new_node = nodes.new(type='ShaderNodeVertexColor')418new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)419new_node.location = (0.0, 0.0)420new_node.name = 'Vertex Color'421new_node.select = False422new_node.width = 140.0423new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]424new_node.outputs[1].default_value = 0.0425426new_node = nodes.new(type='ShaderNodeVolumeInfo')427new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)428new_node.location = (0.0, 0.0)429new_node.name = 'Volume Info'430new_node.select = False431new_node.width = 140.0432new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]433new_node.outputs[1].default_value = 0.0434new_node.outputs[2].default_value = 0.0435new_node.outputs[3].default_value = 0.0436437new_node = nodes.new(type='ShaderNodeWireframe')438new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)439new_node.location = (0.0, 0.0)440new_node.name = 'Wireframe'441new_node.select = False442new_node.use_pixel_size = False443new_node.width = 140.0444new_node.inputs[0].default_value = 0.009999999776482582445new_node.outputs[0].default_value = 0.0446447new_node = nodes.new(type='NodeReroute')448new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)449new_node.location = (0.0, 0.0)450new_node.name = 'Reroute'451new_node.select = False452new_node.width = 16.0453454new_node = nodes.new(type='ShaderNodeBrightContrast')455new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)456new_node.location = (0.0, 0.0)457new_node.name = 'Bright/Contrast'458new_node.select = False459new_node.width = 140.0460new_node.inputs[0].default_value = [1.0, 1.0, 1.0, 1.0]461new_node.inputs[1].default_value = 0.0462new_node.inputs[2].default_value = 0.0463new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]464465new_node = nodes.new(type='ShaderNodeGamma')466new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)467new_node.location = (0.0, 0.0)468new_node.name = 'Gamma'469new_node.select = False470new_node.width = 140.0471new_node.inputs[0].default_value = [1.0, 1.0, 1.0, 1.0]472new_node.inputs[1].default_value = 1.0473new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]474475new_node = nodes.new(type='ShaderNodeHueSaturation')476new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)477new_node.location = (0.0, 0.0)478new_node.name = 'Hue Saturation Value'479new_node.select = False480new_node.width = 150.0481new_node.inputs[0].default_value = 0.5482new_node.inputs[1].default_value = 1.0483new_node.inputs[2].default_value = 1.0484new_node.inputs[3].default_value = 1.0485new_node.inputs[4].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]486new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]487488new_node = nodes.new(type='ShaderNodeInvert')489new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)490new_node.location = (0.0, 0.0)491new_node.name = 'Invert'492new_node.select = False493new_node.width = 140.0494new_node.inputs[0].default_value = 1.0495new_node.inputs[1].default_value = [0.0, 0.0, 0.0, 1.0]496new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]497498new_node = nodes.new(type='ShaderNodeLightFalloff')499new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)500new_node.location = (0.0, 0.0)501new_node.name = 'Light Falloff'502new_node.select = False503new_node.width = 150.0504new_node.inputs[0].default_value = 100.0505new_node.inputs[1].default_value = 0.0506new_node.outputs[0].default_value = 0.0507new_node.outputs[1].default_value = 0.0508new_node.outputs[2].default_value = 0.0509510new_node = nodes.new(type='ShaderNodeMixRGB')511new_node.blend_type = 'MIX'512new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)513new_node.location = (0.0, 0.0)514new_node.name = 'Mix'515new_node.select = False516new_node.use_alpha = False517new_node.use_clamp = False518new_node.width = 140.0519new_node.inputs[0].default_value = 0.5520new_node.inputs[1].default_value = [0.5, 0.5, 0.5, 1.0]521new_node.inputs[2].default_value = [0.5, 0.5, 0.5, 1.0]522new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]523524new_node = nodes.new(type='ShaderNodeRGBCurve')525new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)526new_node.location = (0.0, 0.0)527map = new_node.mapping528map.clip_max_x = 1.0529map.clip_max_y = 1.0530map.clip_min_x = 0.0531map.clip_min_y = 0.0532map.tone = 'STANDARD'533map.use_clip = True 534map_c = map.curves[0]535map_c.points.new(0.0, 0.0)536map_c.points.new(1.0, 1.0)537removed_start = removed_end = False538for i in range(len(map_c.points) - 1, -1, -1):539 p = map_c.points[i]540 if not removed_start and p.location[0] == map.clip_min_x and p.location[1] == map.clip_min_y:541 map_c.points.remove(p)542 removed_start = True543 if not removed_end and p.location[0] == 1 and p.location[1] == 1:544 map_c.points.remove(p)545 removed_end = True 546map_c = map.curves[1]547map_c.points.new(0.0, 0.0)548map_c.points.new(1.0, 1.0)549removed_start = removed_end = False550for i in range(len(map_c.points) - 1, -1, -1):551 p = map_c.points[i]552 if not removed_start and p.location[0] == map.clip_min_x and p.location[1] == map.clip_min_y:553 map_c.points.remove(p)554 removed_start = True555 if not removed_end and p.location[0] == 1 and p.location[1] == 1:556 map_c.points.remove(p)557 removed_end = True 558map_c = map.curves[2]559map_c.points.new(0.0, 0.0)560map_c.points.new(1.0, 1.0)561removed_start = removed_end = False562for i in range(len(map_c.points) - 1, -1, -1):563 p = map_c.points[i]564 if not removed_start and p.location[0] == map.clip_min_x and p.location[1] == map.clip_min_y:565 map_c.points.remove(p)566 removed_start = True567 if not removed_end and p.location[0] == 1 and p.location[1] == 1:568 map_c.points.remove(p)569 removed_end = True 570map_c = map.curves[3]571map_c.points.new(0.0, 0.0)572map_c.points.new(1.0, 1.0)573removed_start = removed_end = False574for i in range(len(map_c.points) - 1, -1, -1):575 p = map_c.points[i]576 if not removed_start and p.location[0] == map.clip_min_x and p.location[1] == map.clip_min_y:577 map_c.points.remove(p)578 removed_start = True579 if not removed_end and p.location[0] == 1 and p.location[1] == 1:580 map_c.points.remove(p)581 removed_end = True 582map.update()583new_node.name = 'RGB Curves'584new_node.select = False585new_node.width = 240.0586new_node.inputs[0].default_value = 1.0587new_node.inputs[1].default_value = [0.0, 0.0, 0.0, 1.0]588new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]589590new_node = nodes.new(type='ShaderNodeBump')591new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)592new_node.invert = False593new_node.location = (0.0, 0.0)594new_node.name = 'Bump'595new_node.select = False596new_node.width = 140.0597new_node.inputs[0].default_value = 1.0598new_node.inputs[1].default_value = 1.0599new_node.inputs[2].default_value = 1.0600new_node.inputs[3].default_value = 1.0601new_node.inputs[4].default_value = 1.0602new_node.inputs[5].default_value = [0.0, 0.0, 0.0]603new_node.outputs[0].default_value = [0.0, 0.0, 0.0]604605new_node = nodes.new(type='ShaderNodeDisplacement')606new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)607new_node.location = (0.0, 0.0)608new_node.name = 'Displacement'609new_node.select = False610new_node.space = 'OBJECT'611new_node.width = 140.0612new_node.inputs[0].default_value = 0.0613new_node.inputs[1].default_value = 0.5614new_node.inputs[2].default_value = 1.0615new_node.inputs[3].default_value = [0.0, 0.0, 0.0]616new_node.outputs[0].default_value = [0.0, 0.0, 0.0]617618new_node = nodes.new(type='ShaderNodeMapping')619new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)620new_node.location = (0.0, 0.0)621new_node.name = 'Mapping'622new_node.select = False623new_node.vector_type = 'POINT'624new_node.width = 140.0625new_node.inputs[0].default_value = [0.0, 0.0, 0.0]626new_node.inputs[1].default_value = [0.0, 0.0, 0.0]627new_node.inputs[2].default_value = [0.0, 0.0, 0.0]628new_node.inputs[3].default_value = [1.0, 1.0, 1.0]629new_node.outputs[0].default_value = [0.0, 0.0, 0.0]630631new_node = nodes.new(type='ShaderNodeNormal')632new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)633new_node.location = (0.0, 0.0)634new_node.name = 'Normal'635new_node.select = False636new_node.width = 140.0637new_node.inputs[0].default_value = [0.0, 0.0, 1.0]638new_node.outputs[0].default_value = [0.0, 0.0, 1.0]639new_node.outputs[1].default_value = 0.0640641new_node = nodes.new(type='ShaderNodeNormalMap')642new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)643new_node.location = (0.0, 0.0)644new_node.name = 'Normal Map'645new_node.select = False646new_node.space = 'TANGENT'647new_node.width = 150.0648new_node.inputs[0].default_value = 1.0649new_node.inputs[1].default_value = [0.5, 0.5, 1.0, 1.0]650new_node.outputs[0].default_value = [0.0, 0.0, 0.0]651652new_node = nodes.new(type='ShaderNodeVectorCurve')653new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)654new_node.location = (0.0, 0.0)655map = new_node.mapping656map.clip_max_x = 1.0657map.clip_max_y = 1.0658map.clip_min_x = -1.0659map.clip_min_y = -1.0660map.tone = 'STANDARD'661map.use_clip = True 662map_c = map.curves[0]663map_c.points.new(-1.0, -1.0)664map_c.points.new(1.0, 1.0)665removed_start = removed_end = False666for i in range(len(map_c.points) - 1, -1, -1):667 p = map_c.points[i]668 if not removed_start and p.location[0] == map.clip_min_x and p.location[1] == map.clip_min_y:669 map_c.points.remove(p)670 removed_start = True671 if not removed_end and p.location[0] == 1 and p.location[1] == 1:672 map_c.points.remove(p)673 removed_end = True 674map_c = map.curves[1]675map_c.points.new(-1.0, -1.0)676map_c.points.new(1.0, 1.0)677removed_start = removed_end = False678for i in range(len(map_c.points) - 1, -1, -1):679 p = map_c.points[i]680 if not removed_start and p.location[0] == map.clip_min_x and p.location[1] == map.clip_min_y:681 map_c.points.remove(p)682 removed_start = True683 if not removed_end and p.location[0] == 1 and p.location[1] == 1:684 map_c.points.remove(p)685 removed_end = True 686map_c = map.curves[2]687map_c.points.new(-1.0, -1.0)688map_c.points.new(1.0, 1.0)689removed_start = removed_end = False690for i in range(len(map_c.points) - 1, -1, -1):691 p = map_c.points[i]692 if not removed_start and p.location[0] == map.clip_min_x and p.location[1] == map.clip_min_y:693 map_c.points.remove(p)694 removed_start = True695 if not removed_end and p.location[0] == 1 and p.location[1] == 1:696 map_c.points.remove(p)697 removed_end = True 698map.update()699new_node.name = 'Vector Curves'700new_node.select = False701new_node.width = 240.0702new_node.inputs[0].default_value = 1.0703new_node.inputs[1].default_value = [0.0, 0.0, 0.0]704new_node.outputs[0].default_value = [0.0, 0.0, 0.0]705706new_node = nodes.new(type='ShaderNodeVectorDisplacement')707new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)708new_node.location = (0.0, 0.0)709new_node.name = 'Vector Displacement'710new_node.select = False711new_node.space = 'TANGENT'712new_node.width = 140.0713new_node.inputs[0].default_value = [0.0, 0.0, 0.0, 0.0]714new_node.inputs[1].default_value = 0.0715new_node.inputs[2].default_value = 1.0716new_node.outputs[0].default_value = [0.0, 0.0, 0.0]717718new_node = nodes.new(type='ShaderNodeVectorRotate')719new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)720new_node.invert = False721new_node.location = (0.0, 0.0)722new_node.name = 'Vector Rotate'723new_node.rotation_type = 'AXIS_ANGLE'724new_node.select = False725new_node.width = 140.0726new_node.inputs[0].default_value = [0.0, 0.0, 0.0]727new_node.inputs[1].default_value = [0.0, 0.0, 0.0]728new_node.inputs[2].default_value = [0.0, 0.0, 1.0]729new_node.inputs[3].default_value = 0.0730new_node.inputs[4].default_value = [0.0, 0.0, 0.0]731new_node.outputs[0].default_value = [0.0, 0.0, 0.0]732733new_node = nodes.new(type='ShaderNodeVectorTransform')734new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)735new_node.convert_from = 'WORLD'736new_node.convert_to = 'OBJECT'737new_node.location = (0.0, 0.0)738new_node.name = 'Vector Transform'739new_node.select = False740new_node.vector_type = 'VECTOR'741new_node.width = 140.0742new_node.inputs[0].default_value = [0.5, 0.5, 0.5]743new_node.outputs[0].default_value = [0.0, 0.0, 0.0]744745new_node = nodes.new(type='ShaderNodeOutputAOV')746new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)747new_node.location = (0.0, 0.0)748new_node.select = False749new_node.width = 140.0750new_node.inputs[0].default_value = [0.0, 0.0, 0.0, 1.0]751new_node.inputs[1].default_value = 0.0752753new_node = nodes.new(type='NodeGroupOutput')754new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)755new_node.is_active_output = True756new_node.location = (0.0, 0.0)757new_node.name = 'Group Output'758new_node.select = False759new_node.width = 140.0760761new_node = nodes.new(type='ShaderNodeOutputLight')762new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)763new_node.is_active_output = True764new_node.location = (0.0, 0.0)765new_node.name = 'Light Output'766new_node.select = False767new_node.target = 'ALL'768new_node.width = 140.0769770new_node = nodes.new(type='ShaderNodeOutputLineStyle')771new_node.blend_type = 'MIX'772new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)773new_node.is_active_output = True774new_node.location = (0.0, 0.0)775new_node.name = 'Line Style Output'776new_node.select = False777new_node.target = 'ALL'778new_node.use_alpha = False779new_node.use_clamp = False780new_node.width = 140.0781new_node.inputs[0].default_value = [1.0, 0.0, 1.0, 1.0]782new_node.inputs[1].default_value = 1.0783new_node.inputs[2].default_value = 1.0784new_node.inputs[3].default_value = 1.0785786new_node = nodes.new(type='ShaderNodeOutputMaterial')787new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)788new_node.is_active_output = False789new_node.location = (0.0, 0.0)790new_node.name = 'Material Output.001'791new_node.select = False792new_node.target = 'ALL'793new_node.width = 140.0794new_node.inputs[2].default_value = [0.0, 0.0, 0.0]795796new_node = nodes.new(type='ShaderNodeOutputWorld')797new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)798new_node.is_active_output = True799new_node.location = (0.0, 0.0)800new_node.name = 'World Output'801new_node.select = False802new_node.target = 'ALL'803new_node.width = 140.0804805new_node = nodes.new(type='ShaderNodeScript')806new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)807new_node.location = (0.0, 0.0)808new_node.mode = 'INTERNAL'809new_node.name = 'Script'810new_node.script = None811new_node.select = False812new_node.use_auto_update = False813new_node.width = 140.0814815new_node = nodes.new(type='ShaderNodeAddShader')816new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)817new_node.location = (0.0, 0.0)818new_node.name = 'Add Shader'819new_node.select = False820new_node.width = 140.0821822new_node = nodes.new(type='ShaderNodeBsdfAnisotropic')823new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)824new_node.distribution = 'GGX'825new_node.location = (0.0, 0.0)826new_node.name = 'Anisotropic BSDF'827new_node.select = False828new_node.width = 150.0829new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]830new_node.inputs[1].default_value = 0.5831new_node.inputs[2].default_value = 0.5832new_node.inputs[3].default_value = 0.0833new_node.inputs[4].default_value = [0.0, 0.0, 0.0]834new_node.inputs[5].default_value = [0.0, 0.0, 0.0]835836new_node = nodes.new(type='ShaderNodeBackground')837new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)838new_node.location = (0.0, 0.0)839new_node.name = 'Background'840new_node.select = False841new_node.width = 140.0842new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]843new_node.inputs[1].default_value = 1.0844845new_node = nodes.new(type='ShaderNodeBsdfDiffuse')846new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)847new_node.location = (0.0, 0.0)848new_node.name = 'Diffuse BSDF'849new_node.select = False850new_node.width = 150.0851new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]852new_node.inputs[1].default_value = 0.0853new_node.inputs[2].default_value = [0.0, 0.0, 0.0]854855new_node = nodes.new(type='ShaderNodeEmission')856new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)857new_node.location = (0.0, 0.0)858new_node.name = 'Emission'859new_node.select = False860new_node.width = 140.0861new_node.inputs[0].default_value = [1.0, 1.0, 1.0, 1.0]862new_node.inputs[1].default_value = 1.0863864new_node = nodes.new(type='ShaderNodeBsdfGlass')865new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)866new_node.distribution = 'BECKMANN'867new_node.location = (0.0, 0.0)868new_node.name = 'Glass BSDF'869new_node.select = False870new_node.width = 150.0871new_node.inputs[0].default_value = [1.0, 1.0, 1.0, 1.0]872new_node.inputs[1].default_value = 0.0873new_node.inputs[2].default_value = 1.4500000476837158874new_node.inputs[3].default_value = [0.0, 0.0, 0.0]875876new_node = nodes.new(type='ShaderNodeBsdfGlossy')877new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)878new_node.distribution = 'GGX'879new_node.location = (0.0, 0.0)880new_node.name = 'Glossy BSDF'881new_node.select = False882new_node.width = 150.0883new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]884new_node.inputs[1].default_value = 0.5885new_node.inputs[2].default_value = [0.0, 0.0, 0.0]886887new_node = nodes.new(type='ShaderNodeBsdfHair')888new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)889new_node.component = 'Reflection'890new_node.location = (0.0, 0.0)891new_node.name = 'Hair BSDF'892new_node.select = False893new_node.width = 150.0894new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]895new_node.inputs[1].default_value = 0.0896new_node.inputs[2].default_value = 0.10000000149011612897new_node.inputs[3].default_value = 1.0898new_node.inputs[4].default_value = [0.0, 0.0, 0.0]899900new_node = nodes.new(type='ShaderNodeHoldout')901new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)902new_node.location = (0.0, 0.0)903new_node.name = 'Holdout'904new_node.select = False905new_node.width = 140.0906907new_node = nodes.new(type='ShaderNodeMixShader')908new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)909new_node.location = (0.0, 0.0)910new_node.name = 'Mix Shader'911new_node.select = False912new_node.width = 140.0913new_node.inputs[0].default_value = 0.5914915new_node = nodes.new(type='ShaderNodeBsdfPrincipled')916new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)917new_node.distribution = 'GGX'918new_node.location = (0.0, 0.0)919new_node.name = 'Principled BSDF.001'920new_node.select = False921new_node.subsurface_method = 'BURLEY'922new_node.width = 240.0923new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]924new_node.inputs[1].default_value = 0.0925new_node.inputs[2].default_value = [1.0, 0.20000000298023224, 0.10000000149011612]926new_node.inputs[3].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]927new_node.inputs[4].default_value = 0.0928new_node.inputs[5].default_value = 0.5929new_node.inputs[6].default_value = 0.0930new_node.inputs[7].default_value = 0.5931new_node.inputs[8].default_value = 0.0932new_node.inputs[9].default_value = 0.0933new_node.inputs[10].default_value = 0.0934new_node.inputs[11].default_value = 0.5935new_node.inputs[12].default_value = 0.0936new_node.inputs[13].default_value = 0.029999999329447746937new_node.inputs[14].default_value = 1.4500000476837158938new_node.inputs[15].default_value = 0.0939new_node.inputs[16].default_value = 0.0940new_node.inputs[17].default_value = [0.0, 0.0, 0.0, 1.0]941new_node.inputs[18].default_value = 1.0942new_node.inputs[19].default_value = [0.0, 0.0, 0.0]943new_node.inputs[20].default_value = [0.0, 0.0, 0.0]944new_node.inputs[21].default_value = [0.0, 0.0, 0.0]945946new_node = nodes.new(type='ShaderNodeBsdfHairPrincipled')947new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)948new_node.location = (0.0, 0.0)949new_node.name = 'Principled Hair BSDF'950new_node.parametrization = 'COLOR'951new_node.select = False952new_node.width = 240.0953new_node.inputs[0].default_value = [0.01751299947500229, 0.005762999877333641, 0.002059000078588724, 1.0]954new_node.inputs[1].default_value = 0.800000011920929955new_node.inputs[2].default_value = 1.0956new_node.inputs[3].default_value = [1.0, 1.0, 1.0, 1.0]957new_node.inputs[4].default_value = [0.24553099274635315, 0.5199999809265137, 1.3650000095367432]958new_node.inputs[5].default_value = 0.30000001192092896959new_node.inputs[6].default_value = 0.30000001192092896960new_node.inputs[7].default_value = 0.0961new_node.inputs[8].default_value = 1.5499999523162842962new_node.inputs[9].default_value = 0.03490658476948738963new_node.inputs[10].default_value = 0.0964new_node.inputs[11].default_value = 0.0965new_node.inputs[12].default_value = 0.0966967new_node = nodes.new(type='ShaderNodeVolumePrincipled')968new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)969new_node.location = (0.0, 0.0)970new_node.name = 'Principled Volume'971new_node.select = False972new_node.width = 240.0973new_node.inputs[0].default_value = [0.5, 0.5, 0.5, 1.0]974new_node.inputs[1].default_value = 975new_node.inputs[2].default_value = 1.0976new_node.inputs[3].default_value = density977new_node.inputs[4].default_value = 0.0978new_node.inputs[5].default_value = [0.0, 0.0, 0.0, 1.0]979new_node.inputs[6].default_value = 0.0980new_node.inputs[7].default_value = [1.0, 1.0, 1.0, 1.0]981new_node.inputs[8].default_value = 0.0982new_node.inputs[9].default_value = [1.0, 1.0, 1.0, 1.0]983new_node.inputs[10].default_value = 1000.0984new_node.inputs[11].default_value = temperature985986new_node = nodes.new(type='ShaderNodeBsdfRefraction')987new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)988new_node.distribution = 'BECKMANN'989new_node.location = (0.0, 0.0)990new_node.name = 'Refraction BSDF'991new_node.select = False992new_node.width = 150.0993new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]994new_node.inputs[1].default_value = 0.0995new_node.inputs[2].default_value = 1.4500000476837158996new_node.inputs[3].default_value = [0.0, 0.0, 0.0]997998new_node = nodes.new(type='ShaderNodeEeveeSpecular')999new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1000new_node.location = (0.0, 0.0)1001new_node.name = 'Specular'1002new_node.select = False1003new_node.width = 140.01004new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]1005new_node.inputs[1].default_value = [0.029999999329447746, 0.029999999329447746, 0.029999999329447746, 1.0]1006new_node.inputs[2].default_value = 0.200000002980232241007new_node.inputs[3].default_value = [0.0, 0.0, 0.0, 1.0]1008new_node.inputs[4].default_value = 0.01009new_node.inputs[5].default_value = [0.0, 0.0, 0.0]1010new_node.inputs[6].default_value = 0.01011new_node.inputs[7].default_value = 0.01012new_node.inputs[8].default_value = [0.0, 0.0, 0.0]1013new_node.inputs[9].default_value = 1.010141015new_node = nodes.new(type='ShaderNodeSubsurfaceScattering')1016new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1017new_node.falloff = 'BURLEY'1018new_node.location = (0.0, 0.0)1019new_node.name = 'Subsurface Scattering'1020new_node.select = False1021new_node.width = 150.01022new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]1023new_node.inputs[1].default_value = 1.01024new_node.inputs[2].default_value = [1.0, 0.20000000298023224, 0.10000000149011612]1025new_node.inputs[3].default_value = 0.01026new_node.inputs[4].default_value = 0.01027new_node.inputs[5].default_value = [0.0, 0.0, 0.0]10281029new_node = nodes.new(type='ShaderNodeBsdfToon')1030new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1031new_node.component = 'DIFFUSE'1032new_node.location = (0.0, 0.0)1033new_node.name = 'Toon BSDF'1034new_node.select = False1035new_node.width = 150.01036new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]1037new_node.inputs[1].default_value = 0.51038new_node.inputs[2].default_value = 0.01039new_node.inputs[3].default_value = [0.0, 0.0, 0.0]10401041new_node = nodes.new(type='ShaderNodeBsdfTranslucent')1042new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1043new_node.location = (0.0, 0.0)1044new_node.name = 'Translucent BSDF'1045new_node.select = False1046new_node.width = 140.01047new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]1048new_node.inputs[1].default_value = [0.0, 0.0, 0.0]10491050new_node = nodes.new(type='ShaderNodeBsdfTransparent')1051new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1052new_node.location = (0.0, 0.0)1053new_node.name = 'Transparent BSDF'1054new_node.select = False1055new_node.width = 140.01056new_node.inputs[0].default_value = [1.0, 1.0, 1.0, 1.0]10571058new_node = nodes.new(type='ShaderNodeBsdfVelvet')1059new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1060new_node.location = (0.0, 0.0)1061new_node.name = 'Velvet BSDF'1062new_node.select = False1063new_node.width = 140.01064new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]1065new_node.inputs[1].default_value = 1.01066new_node.inputs[2].default_value = [0.0, 0.0, 0.0]10671068new_node = nodes.new(type='ShaderNodeVolumeAbsorption')1069new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1070new_node.location = (0.0, 0.0)1071new_node.name = 'Volume Absorption'1072new_node.select = False1073new_node.width = 140.01074new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]1075new_node.inputs[1].default_value = 1.010761077new_node = nodes.new(type='ShaderNodeVolumeScatter')1078new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1079new_node.location = (0.0, 0.0)1080new_node.name = 'Volume Scatter'1081new_node.select = False1082new_node.width = 140.01083new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]1084new_node.inputs[1].default_value = 1.01085new_node.inputs[2].default_value = 0.010861087new_node = nodes.new(type='ShaderNodeTexBrick')1088new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1089new_node.location = (0.0, 0.0)1090new_node.name = 'Brick Texture'1091new_node.offset = 0.51092new_node.offset_frequency = 21093new_node.select = False1094new_node.squash = 1.01095new_node.squash_frequency = 21096new_node.width = 150.01097new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1098new_node.inputs[1].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]1099new_node.inputs[2].default_value = [0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 1.0]1100new_node.inputs[3].default_value = [0.0, 0.0, 0.0, 1.0]1101new_node.inputs[4].default_value = 5.01102new_node.inputs[5].default_value = 0.0199999995529651641103new_node.inputs[6].default_value = 0.100000001490116121104new_node.inputs[7].default_value = 0.01105new_node.inputs[8].default_value = 0.51106new_node.inputs[9].default_value = 0.251107new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]1108new_node.outputs[1].default_value = 0.011091110new_node = nodes.new(type='ShaderNodeTexChecker')1111new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1112new_node.location = (0.0, 0.0)1113new_node.name = 'Checker Texture'1114new_node.select = False1115new_node.width = 140.01116new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1117new_node.inputs[1].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]1118new_node.inputs[2].default_value = [0.20000000298023224, 0.20000000298023224, 0.20000000298023224, 1.0]1119new_node.inputs[3].default_value = 5.01120new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]1121new_node.outputs[1].default_value = 0.011221123new_node = nodes.new(type='ShaderNodeTexEnvironment')1124new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1125new_node.image = None1126img_text = new_node.image_user")1127img_text.frame_current = 01128img_text.frame_duration = 1001129img_text.frame_offset = 01130img_text.frame_start = 11131img_text.use_auto_refresh = False1132img_text.use_cyclic = False1133img_text.tile = 0 1134new_node.interpolation = 'Linear'1135new_node.location = (0.0, 0.0)1136new_node.name = 'Environment Texture'1137new_node.projection = 'EQUIRECTANGULAR'1138new_node.select = False1139new_node.width = 240.01140new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1141new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]11421143new_node = nodes.new(type='ShaderNodeTexGradient')1144new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1145new_node.gradient_type = 'LINEAR'1146new_node.location = (0.0, 0.0)1147new_node.name = 'Gradient Texture'1148new_node.select = False1149new_node.width = 140.01150new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1151new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]1152new_node.outputs[1].default_value = 0.011531154new_node = nodes.new(type='ShaderNodeTexIES')1155new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1156new_node.ies = None1157new_node.location = (0.0, 0.0)1158new_node.mode = 'INTERNAL'1159new_node.name = 'IES Texture'1160new_node.select = False1161new_node.width = 140.01162new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1163new_node.inputs[1].default_value = 1.01164new_node.outputs[0].default_value = 0.011651166new_node = nodes.new(type='ShaderNodeTexImage')1167new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1168new_node.extension = 'REPEAT'1169new_node.image = None1170img_text = new_node.image_user")1171img_text.frame_current = 01172img_text.frame_duration = 1001173img_text.frame_offset = 01174img_text.frame_start = 11175img_text.use_auto_refresh = False1176img_text.use_cyclic = False1177img_text.tile = 0 1178new_node.interpolation = 'Linear'1179new_node.location = (0.0, 0.0)1180new_node.name = 'Image Texture'1181new_node.projection = 'FLAT'1182new_node.projection_blend = 0.01183new_node.select = False1184new_node.width = 240.01185new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1186new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]1187new_node.outputs[1].default_value = 0.011881189new_node = nodes.new(type='ShaderNodeTexMagic')1190new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1191new_node.location = (0.0, 0.0)1192new_node.name = 'Magic Texture'1193new_node.select = False1194new_node.turbulence_depth = 21195new_node.width = 140.01196new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1197new_node.inputs[1].default_value = 5.01198new_node.inputs[2].default_value = 1.01199new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]1200new_node.outputs[1].default_value = 0.012011202new_node = nodes.new(type='ShaderNodeTexMusgrave')1203new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1204new_node.location = (0.0, 0.0)1205new_node.musgrave_dimensions = '3D'1206new_node.musgrave_type = 'FBM'1207new_node.name = 'Musgrave Texture'1208new_node.select = False1209new_node.width = 150.01210new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1211new_node.inputs[1].default_value = 0.01212new_node.inputs[2].default_value = 5.01213new_node.inputs[3].default_value = 2.01214new_node.inputs[4].default_value = 2.01215new_node.inputs[5].default_value = 2.01216new_node.inputs[6].default_value = 0.01217new_node.inputs[7].default_value = 1.01218new_node.outputs[0].default_value = 0.012191220new_node = nodes.new(type='ShaderNodeTexNoise')1221new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1222new_node.location = (0.0, 0.0)1223new_node.name = 'Noise Texture'1224new_node.noise_dimensions = '3D'1225new_node.select = False1226new_node.width = 140.01227new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1228new_node.inputs[1].default_value = 0.01229new_node.inputs[2].default_value = 5.01230new_node.inputs[3].default_value = 2.01231new_node.inputs[4].default_value = 0.51232new_node.inputs[5].default_value = 0.01233new_node.outputs[0].default_value = 0.01234new_node.outputs[1].default_value = [0.0, 0.0, 0.0, 0.0]12351236new_node = nodes.new(type='ShaderNodeTexPointDensity')1237new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1238new_node.interpolation = 'Linear'1239new_node.location = (0.0, 0.0)1240new_node.name = 'Point Density'1241new_node.object = None1242new_node.particle_color_source = 'PARTICLE_AGE'1243new_node.particle_system = None1244new_node.point_source = 'PARTICLE_SYSTEM'1245new_node.radius = 0.300000011920928961246new_node.resolution = 1001247new_node.select = False1248new_node.space = 'OBJECT'1249new_node.vertex_color_source = 'VERTEX_COLOR'1250new_node.width = 140.01251new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1252new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 1.0]1253new_node.outputs[1].default_value = 0.012541255new_node = nodes.new(type='ShaderNodeTexSky')1256new_node.air_density = 1.01257new_node.altitude = 0.01258new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1259new_node.dust_density = 1.01260new_node.ground_albedo = 0.300000011920928961261new_node.location = (0.0, 0.0)1262new_node.name = 'Sky Texture'1263new_node.ozone_density = 1.01264new_node.select = False1265new_node.sky_type = 'NISHITA'1266new_node.sun_direction = (0.0, 0.0, 1.0)1267new_node.sun_disc = True1268new_node.sun_elevation = 0.26179939508438111269new_node.sun_intensity = 1.01270new_node.sun_rotation = 0.01271new_node.sun_size = 0.0095120444893836981272new_node.turbidity = 2.2000000476837161273new_node.width = 150.01274new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1275new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]12761277new_node = nodes.new(type='ShaderNodeTexVoronoi')1278new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1279new_node.distance = 'EUCLIDEAN'1280new_node.feature = 'F1'1281new_node.location = (0.0, 0.0)1282new_node.name = 'Voronoi Texture'1283new_node.select = False1284new_node.voronoi_dimensions = '3D'1285new_node.width = 140.01286new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1287new_node.inputs[1].default_value = 0.01288new_node.inputs[2].default_value = 5.01289new_node.inputs[3].default_value = 1.01290new_node.inputs[4].default_value = 0.51291new_node.inputs[5].default_value = 1.01292new_node.outputs[0].default_value = 0.01293new_node.outputs[1].default_value = [0.0, 0.0, 0.0, 0.0]1294new_node.outputs[2].default_value = [0.0, 0.0, 0.0]1295new_node.outputs[3].default_value = 0.01296new_node.outputs[4].default_value = 0.012971298new_node = nodes.new(type='ShaderNodeTexWave')1299new_node.bands_direction = 'X'1300new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1301new_node.location = (0.0, 0.0)1302new_node.name = 'Wave Texture'1303new_node.rings_direction = 'X'1304new_node.select = False1305new_node.wave_profile = 'SIN'1306new_node.wave_type = 'BANDS'1307new_node.width = 150.01308new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1309new_node.inputs[1].default_value = 5.01310new_node.inputs[2].default_value = 0.01311new_node.inputs[3].default_value = 2.01312new_node.inputs[4].default_value = 1.01313new_node.inputs[5].default_value = 0.51314new_node.inputs[6].default_value = 0.01315new_node.outputs[0].default_value = [0.0, 0.0, 0.0, 0.0]1316new_node.outputs[1].default_value = 0.013171318new_node = nodes.new(type='ShaderNodeTexWhiteNoise')1319new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1320new_node.location = (1.8810313940048218, 0.0)1321new_node.name = 'White Noise Texture'1322new_node.noise_dimensions = '3D'1323parent = nodes.get('Frame')1324if parent:1325 new_node.parent = parent1326 while True:1327 new_node.location += parent.location1328 if parent.parent:1329 parent = parent.parent1330 else:1331 break 1332new_node.select = False1333new_node.width = 140.01334new_node.inputs[0].default_value = [0.0, 0.0, 0.0]1335new_node.inputs[1].default_value = 0.01336new_node.outputs[0].default_value = 0.01337new_node.outputs[1].default_value = [0.0, 0.0, 0.0, 0.0]13381339new_node = nodes.new(type='ShaderNodeBsdfPrincipled')1340new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1341new_node.distribution = 'GGX'1342new_node.location = (10.0, 300.0)1343new_node.name = 'Principled BSDF'1344new_node.subsurface_method = 'BURLEY'1345new_node.width = 240.01346new_node.inputs[0].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]1347new_node.inputs[1].default_value = 0.01348new_node.inputs[2].default_value = [1.0, 0.20000000298023224, 0.10000000149011612]1349new_node.inputs[3].default_value = [0.800000011920929, 0.800000011920929, 0.800000011920929, 1.0]1350new_node.inputs[4].default_value = 0.01351new_node.inputs[5].default_value = 0.51352new_node.inputs[6].default_value = 0.01353new_node.inputs[7].default_value = 0.51354new_node.inputs[8].default_value = 0.01355new_node.inputs[9].default_value = 0.01356new_node.inputs[10].default_value = 0.01357new_node.inputs[11].default_value = 0.51358new_node.inputs[12].default_value = 0.01359new_node.inputs[13].default_value = 0.0299999993294477461360new_node.inputs[14].default_value = 1.45000004768371581361new_node.inputs[15].default_value = 0.01362new_node.inputs[16].default_value = 0.01363new_node.inputs[17].default_value = [0.0, 0.0, 0.0, 1.0]1364new_node.inputs[18].default_value = 1.01365new_node.inputs[19].default_value = [0.0, 0.0, 0.0]1366new_node.inputs[20].default_value = [0.0, 0.0, 0.0]1367new_node.inputs[21].default_value = [0.0, 0.0, 0.0]13681369new_node = nodes.new(type='ShaderNodeOutputMaterial')1370new_node.color = (0.6079999804496765, 0.6079999804496765, 0.6079999804496765)1371new_node.is_active_output = True1372new_node.location = (300.0, 300.0)1373new_node.name = 'Material Output'1374new_node.target = 'ALL'1375new_node.width = 140.01376new_node.inputs[2].default_value = [0.0, 0.0, 0.0]13771378# Links :1379
...
main.py
Source:main.py
1import sys, os, re2import configparser3import datetime4import json5import math6config = configparser.ConfigParser()7config.read('../../databases.config')8DB_URL = os.environ.get('DB_URL') if os.environ.get('DB_URL') else config['CASSANDRA']['host']9DB_NAME = os.environ.get('DB_NAME') if os.environ.get('DB_NAME') else config['CASSANDRA']['db_name']10TIME_PATTERN = os.environ.get('TIME_PATTERN') or config['FORMATS']['time']11DATE_PATTERN = os.environ.get('DATE_PATTERN') or config['FORMATS']['date']12TIMESTAMP_PATTERN = os.environ.get('TIMESTAMP_PATTERN') or config['FORMATS']['timestamp']13import graphene14from cassandra.cqlengine import connection15sys.path.append('../../logbook/entities')16from position import Position17from control_action import ControlAction18sys.path.append(os.environ['SPACE_SHIP_HOME'] + '/logbook/adapters/')19import mongo_adapter20import neo4j_adapter21sys.path.append(os.environ['SPACE_SHIP_HOME'] + '/logbook/native/')22import select_queries23from converters import time_to_str, date_to_str24sys.path.append(os.environ['SPACE_SHIP_HOME'] + '/api/background/mappers')25sys.path.append(os.environ['SPACE_SHIP_HOME'] + '/relations/entities/')26sys.path.append(os.environ['SPACE_SHIP_HOME'] + '/logbook')27from data_adapters import string_to_bytes28from requirement import Requirement29from shift import Shift30from operation import Operation31from control_action_mapper import ControlActionMapper32from position_mapper import PositionMapper33from system_test_mapper import SystemTestMapper34from operation_state_mapper import OperationStateMapper35from shift_state_mapper import ShiftStateMapper36from sensor_data_mapper import SensorDataMapper37from person_mapper import PersonMapper38from department_mapper import DepartmentMapper39from property_type_mapper import PropertyTypeMapper40from specialization_mapper import SpecializationMapper41from property_mapper import PropertyMapper42from system_state_mapper import SystemStateMapper43from system_type_mapper import SystemTypeMapper44from location_mapper import LocationMapper45from boat_mapper import BoatMapper46from sensor_mapper import SensorMapper47from system_mapper import SystemMapper48from requirement_mapper import RequirementMapper49from shift_mapper import ShiftMapper50from operation_mapper import OperationMapper51sys.path.append(os.environ['SPACE_SHIP_HOME'] + '/recital/native')52import mongo_native53sys.path.append(os.environ['SPACE_SHIP_HOME'] + '/api/background/manipulators')54import location_manipulator55import sensor_manipulator56import department_manipulator57import person_manipulator58import specialization_manipulator59import boat_manipulator60import system_type_manipulator61import system_state_manipulator62import property_type_manipulator63import system_manipulator64import property_manipulator65import shift_manipulator66import operation_manipulator67import requirement_manipulator68import position_manipulator69import control_action_manipulator70import system_test_manipulator71import sensor_data_manipulator72import shift_state_manipulator73import operation_state_manipulator74INFINITY = float('inf')75sys.path.append(os.environ['SPACE_SHIP_HOME'] + '/logbook')76import cassandra_mediator77sys.path.append(os.environ['SPACE_SHIP_HOME'] + '/relations')78import neo4j_mediator79def has_item_valid_time(hour, minute, second, item_time):80 return (hour < 0 or item_time.hour == hour) and\81 (minute < 0 or item_time.minute == minute) and\82 (second < 0 or item_time.second == second)83class FirstMutation(graphene.ObjectType):84 create_location = location_manipulator.CreateLocation.Field()85 remove_location = location_manipulator.RemoveLocation.Field()86 eradicate_location = location_manipulator.EradicateLocation.Field()87 update_locations = location_manipulator.UpdateLocations.Field()88 create_sensor = sensor_manipulator.CreateSensor.Field()89 remove_sensor = sensor_manipulator.RemoveSensor.Field()90 update_sensors = sensor_manipulator.UpdateSensors.Field()91 create_department = department_manipulator.CreateDepartment.Field()92 remove_department = department_manipulator.RemoveDepartment.Field()93 eradicate_department = department_manipulator.EradicateDepartment.Field()94 update_departments = department_manipulator.UpdateDepartments.Field()95 create_specialization = specialization_manipulator.CreateSpecialization.Field()96 remove_specialization = specialization_manipulator.RemoveSpecialization.Field()97 eradicate_specialization = specialization_manipulator.EradicateSpecialization.Field()98 update_specializations = specialization_manipulator.UpdateSpecializations.Field()99 create_person = person_manipulator.CreatePerson.Field()100 remove_person = person_manipulator.RemovePerson.Field()101 eradicate_person = person_manipulator.EradicatePerson.Field()102 update_people = person_manipulator.UpdatePeople.Field()103 create_boat = boat_manipulator.CreateBoat.Field()104 remove_boat = boat_manipulator.RemoveBoat.Field()105 update_boats = boat_manipulator.UpdateBoats.Field()106 create_systemtype = system_type_manipulator.CreateSystemType.Field()107 remove_systemtype = system_type_manipulator.RemoveSystemType.Field()108 eradicate_systemtype = system_type_manipulator.EradicateSystemType.Field()109 update_systemtypes = system_type_manipulator.UpdateSystemTypes.Field()110 create_systemstate = system_state_manipulator.CreateSystemState.Field()111 remove_systemstate = system_state_manipulator.RemoveSystemState.Field()112 eradicate_systemstate = system_state_manipulator.EradicateSystemState.Field()113 update_systemstates = system_state_manipulator.UpdateSystemStates.Field()114 create_propertytype = property_type_manipulator.CreatePropertyType.Field()115 remove_propertytype = property_type_manipulator.RemovePropertyType.Field()116 eradicate_propertytype = property_type_manipulator.EradicatePropertyType.Field()117 update_propertytypes = property_type_manipulator.UpdatePropertyTypes.Field()118 create_system = system_manipulator.CreateSystem.Field()119 remove_system = system_manipulator.RemoveSystem.Field()120 update_systems = system_manipulator.UpdateSystems.Field()121 create_property = property_manipulator.CreateProperty.Field()122 remove_property = property_manipulator.RemoveProperty.Field()123 update_properties = property_manipulator.UpdateProperties.Field()124 #125 create_shift = shift_manipulator.CreateShift.Field()126 remove_shift = shift_manipulator.RemoveShift.Field()127 update_shifts = shift_manipulator.UpdateShifts.Field()128 create_operation = operation_manipulator.CreateOperation.Field()129 remove_operation = operation_manipulator.RemoveOperation.Field()130 update_operations = operation_manipulator.UpdateOperations.Field()131 create_requirement = requirement_manipulator.CreateRequirement.Field()132 remove_requirement = requirement_manipulator.RemoveRequirement.Field()133 update_requirements = requirement_manipulator.UpdateRequirements.Field()134 #135 create_position = position_manipulator.CreatePosition.Field()136 remove_position = position_manipulator.RemovePosition.Field()137 update_position = position_manipulator.UpdatePositions.Field()138 create_controlaction = control_action_manipulator.CreateControlAction.Field()139 remove_controlaction = control_action_manipulator.RemoveControlAction.Field()140 update_controlaction = control_action_manipulator.UpdateControlActions.Field()141 create_systemtest = system_test_manipulator.CreateSystemTest.Field()142 remove_systemtest = system_test_manipulator.RemoveSystemTest.Field()143 update_systemtest = system_test_manipulator.UpdateSystemTests.Field()144 create_sensordata = sensor_data_manipulator.CreateSensorData.Field()145 remove_sensordata = sensor_data_manipulator.RemoveSensorData.Field()146 update_sensordata = sensor_data_manipulator.UpdateSensorData.Field()147 create_shiftstate = shift_state_manipulator.CreateShiftState.Field()148 remove_shiftstate = shift_state_manipulator.RemoveShiftState.Field()149 update_shiftstate = shift_state_manipulator.UpdateShiftStates.Field()150 create_operationstate = operation_state_manipulator.CreateOperationState.Field()151 remove_operationstate = operation_state_manipulator.RemoveOperationState.Field()152 update_operationstate = operation_state_manipulator.UpdateOperationStates.Field()153class FirstQuery(graphene.ObjectType):154 position = graphene.List(PositionMapper, date = graphene.String(default_value = ''),155 time = graphene.String(default_value = ''),156 x = graphene.Float(default_value = float('nan')),157 y = graphene.Float(default_value = float('nan')),158 z = graphene.Float(default_value = float('nan')),159 attack_angle = graphene.Float(default_value = float('nan')),160 direction_angle = graphene.Float(default_value = float('nan')),161 speed = graphene.Float(default_value = float('nan')))162 controlaction = graphene.List(ControlActionMapper, date = graphene.String(default_value = ''),163 time = graphene.String(default_value = ''),164 mac = graphene.String(default_value = ''),165 user = graphene.String(default_value = ''),166 command = graphene.String(default_value = ''),167 params = graphene.String(default_value = ''),168 result = graphene.String(default_value = ''))169 systemtest = graphene.List(SystemTestMapper, date = graphene.String(default_value = ''),170 time = graphene.String(default_value = ''),171 system = graphene.String(default_value = ''),172 result = graphene.Int(default_value = -1))173 operationstate = graphene.List(OperationStateMapper,date = graphene.String(default_value = ''),174 time = graphene.String(default_value = ''),175 boat = graphene.String(default_value = ''),176 operation = graphene.String(default_value = ''),177 status = graphene.String(default_value = ''),178 distancetotheship = graphene.Float(default_value = float('nan')),179 zenith = graphene.Float(default_value = float('nan')),180 azimuth = graphene.Float(default_value = float('nan')),181 hydrogenium = graphene.Float(default_value = float('nan')),182 helium = graphene.Float(default_value = float('nan')),183 lithium = graphene.Float(default_value = float('nan')),184 beryllium = graphene.Float(default_value = float('nan')),185 borum = graphene.Float(default_value = float('nan')),186 carboneum = graphene.Float(default_value = float('nan')),187 nitrogenium = graphene.Float(default_value = float('nan')),188 oxygenium = graphene.Float(default_value = float('nan')),189 fluorum = graphene.Float(default_value = float('nan')),190 neon = graphene.Float(default_value = float('nan')),191 natrium = graphene.Float(default_value = float('nan')),192 magnesium = graphene.Float(default_value = float('nan')),193 aluminium = graphene.Float(default_value = float('nan')),194 silicium = graphene.Float(default_value = float('nan')),195 phosphorus = graphene.Float(default_value = float('nan')),196 sulfur = graphene.Float(default_value = float('nan')),197 chlorum = graphene.Float(default_value = float('nan')),198 argon = graphene.Float(default_value = float('nan')),199 kalium = graphene.Float(default_value = float('nan')),200 calcium = graphene.Float(default_value = float('nan')),201 scandium = graphene.Float(default_value = float('nan')),202 titanium = graphene.Float(default_value = float('nan')),203 vanadium = graphene.Float(default_value = float('nan')),204 chromium = graphene.Float(default_value = float('nan')),205 manganum = graphene.Float(default_value = float('nan')),206 ferrum = graphene.Float(default_value = float('nan')),207 cobaltum = graphene.Float(default_value = float('nan')),208 niccolum = graphene.Float(default_value = float('nan')),209 cuprum = graphene.Float(default_value = float('nan')),210 zincum = graphene.Float(default_value = float('nan')),211 gallium = graphene.Float(default_value = float('nan')),212 germanium = graphene.Float(default_value = float('nan')),213 arsenicum = graphene.Float(default_value = float('nan')),214 selenium = graphene.Float(default_value = float('nan')),215 bromum = graphene.Float(default_value = float('nan')),216 crypton = graphene.Float(default_value = float('nan')),217 rubidium = graphene.Float(default_value = float('nan')),218 strontium = graphene.Float(default_value = float('nan')),219 yttrium = graphene.Float(default_value = float('nan')),220 zirconium = graphene.Float(default_value = float('nan')),221 niobium = graphene.Float(default_value = float('nan')),222 molybdaenum = graphene.Float(default_value = float('nan')),223 technetium = graphene.Float(default_value = float('nan')),224 ruthenium = graphene.Float(default_value = float('nan')),225 rhodium = graphene.Float(default_value = float('nan')),226 palladium = graphene.Float(default_value = float('nan')),227 argentum = graphene.Float(default_value = float('nan')),228 cadmium = graphene.Float(default_value = float('nan')),229 indium = graphene.Float(default_value = float('nan')),230 stannum = graphene.Float(default_value = float('nan')),231 stibium = graphene.Float(default_value = float('nan')),232 tellurium = graphene.Float(default_value = float('nan')),233 iodium = graphene.Float(default_value = float('nan')),234 xenon = graphene.Float(default_value = float('nan')),235 caesium = graphene.Float(default_value = float('nan')),236 barium = graphene.Float(default_value = float('nan')),237 lanthanum = graphene.Float(default_value = float('nan')),238 cerium = graphene.Float(default_value = float('nan')),239 praseodymium = graphene.Float(default_value = float('nan')),240 neodymium = graphene.Float(default_value = float('nan')),241 promethium = graphene.Float(default_value = float('nan')),242 samarium = graphene.Float(default_value = float('nan')),243 europium = graphene.Float(default_value = float('nan')),244 gadolinium = graphene.Float(default_value = float('nan')),245 terbium = graphene.Float(default_value = float('nan')),246 dysprosium = graphene.Float(default_value = float('nan')),247 holmium = graphene.Float(default_value = float('nan')),248 erbium = graphene.Float(default_value = float('nan')),249 thulium = graphene.Float(default_value = float('nan')),250 ytterbium = graphene.Float(default_value = float('nan')),251 lutetium = graphene.Float(default_value = float('nan')),252 hafnium = graphene.Float(default_value = float('nan')),253 tantalum = graphene.Float(default_value = float('nan')),254 wolframium = graphene.Float(default_value = float('nan')),255 rhenium = graphene.Float(default_value = float('nan')),256 osmium = graphene.Float(default_value = float('nan')),257 iridium = graphene.Float(default_value = float('nan')),258 platinum = graphene.Float(default_value = float('nan')),259 aurum = graphene.Float(default_value = float('nan')),260 hydrargyrum = graphene.Float(default_value = float('nan')),261 thallium = graphene.Float(default_value = float('nan')),262 plumbum = graphene.Float(default_value = float('nan')),263 bismuthum = graphene.Float(default_value = float('nan')),264 polonium = graphene.Float(default_value = float('nan')),265 astatum = graphene.Float(default_value = float('nan')),266 radon = graphene.Float(default_value = float('nan')),267 francium = graphene.Float(default_value = float('nan')),268 radium = graphene.Float(default_value = float('nan')),269 actinium = graphene.Float(default_value = float('nan')),270 thorium = graphene.Float(default_value = float('nan')),271 protactinium = graphene.Float(default_value = float('nan')),272 uranium = graphene.Float(default_value = float('nan')),273 neptunium = graphene.Float(default_value = float('nan')),274 plutonium = graphene.Float(default_value = float('nan')),275 americium = graphene.Float(default_value = float('nan')),276 curium = graphene.Float(default_value = float('nan')),277 berkelium = graphene.Float(default_value = float('nan')),278 californium = graphene.Float(default_value = float('nan')),279 einsteinium = graphene.Float(default_value = float('nan')),280 fermium = graphene.Float(default_value = float('nan')),281 mendelevium = graphene.Float(default_value = float('nan')),282 nobelium = graphene.Float(default_value = float('nan')),283 lawrencium = graphene.Float(default_value = float('nan')),284 rutherfordium = graphene.Float(default_value = float('nan')),285 dubnium = graphene.Float(default_value = float('nan')),286 seaborgium = graphene.Float(default_value = float('nan')),287 bohrium = graphene.Float(default_value = float('nan')),288 hassium = graphene.Float(default_value = float('nan')),289 meitnerium = graphene.Float(default_value = float('nan')),290 darmstadtium = graphene.Float(default_value = float('nan')),291 roentgenium = graphene.Float(default_value = float('nan')),292 copernicium = graphene.Float(default_value = float('nan')),293 nihonium = graphene.Float(default_value = float('nan')),294 flerovium = graphene.Float(default_value = float('nan')),295 moscovium = graphene.Float(default_value = float('nan')),296 livermorium = graphene.Float(default_value = float('nan')),297 tennessium = graphene.Float(default_value = float('nan')),298 oganesson = graphene.Float(default_value = float('nan')),299 comment = graphene.String(default_value = ''))300 shiftstate = graphene.List(ShiftStateMapper, date = graphene.String(default_value = ''),301 time = graphene.String(default_value = ''),302 shift = graphene.String(default_value = ''),303 warninglevel = graphene.String(default_value = ''),304 remainingcartridges = graphene.Int(default_value = -1),305 remainingair = graphene.Int(default_value = -1),306 remainingelectricity = graphene.Int(default_value = -1),307 comment = graphene.String(default_value = ''))308 sensordata = graphene.List(SensorDataMapper, date = graphene.String(default_value = ''),309 time = graphene.String(default_value = ''),310 sensor = graphene.String(default_value = ''),311 event = graphene.String(default_value = ''),312 valuename = graphene.String(default_value = ''),313 value = graphene.Float(default_value = float('nan')),314 units = graphene.String(default_value = ''))315 people = graphene.List(PersonMapper, id = graphene.String(default_value = ''),316 name = graphene.String(default_value = ''),317 surname = graphene.String(default_value = ''),318 patronymic = graphene.String(default_value = ''),319 phone = graphene.String(default_value = ''),320 department = graphene.String(default_value = ''),321 specialization = graphene.String(default_value = ''))322 departments = graphene.List(DepartmentMapper, id = graphene.String(default_value = ''),323 name = graphene.String(default_value = ''),324 vk = graphene.String(default_value = ''))325 property_types = graphene.List(PropertyTypeMapper, id = graphene.String(default_value = ''), desc = graphene.String(default_value = ''),326 name = graphene.String(default_value = ''))327 specializations = graphene.List(SpecializationMapper, id = graphene.String(default_value = ''), name = graphene.String(default_value = ''))328 properties = graphene.List(PropertyMapper, id = graphene.String(default_value = ''), name = graphene.String(default_value = ''),329 type_ = graphene.String(default_value = ''),330 admission = graphene.String(default_value = ''),331 comissioning = graphene.String(default_value = ''),332 department = graphene.String(default_value = ''))333 systemstates = graphene.List(SystemStateMapper, id = graphene.String(default_value = ''), desc = graphene.String(default_value = ''),334 name = graphene.String(default_value = ''))335 systemtypes = graphene.List(SystemTypeMapper, id = graphene.String(default_value = ''), desc = graphene.String(default_value = ''),336 name = graphene.String(default_value = ''))337 locations = graphene.List(LocationMapper, id = graphene.String(default_value = ''), name = graphene.String(default_value = ''))338 boats = graphene.List(BoatMapper, id = graphene.String(default_value = ''), name = graphene.String(default_value = ''), 339 capacity = graphene.Int(default_value = -1))340 sensors = graphene.List(SensorMapper, id = graphene.String(default_value = ''), 341 name = graphene.String(default_value = ''),342 location = graphene.String(default_value = ''))343 systems = graphene.List(SystemMapper, id = graphene.String(default_value = ''), name = graphene.String(default_value = ''),344 serialnumber = graphene.Float(default_value = float('nan')),345 launched = graphene.String(default_value = ''),346 checked = graphene.String(default_value = ''),347 state = graphene.String(default_value = ''),348 supervisor = graphene.String(default_value = ''),349 type_ = graphene.String(default_value = ''))350 requirements = graphene.List(RequirementMapper, id = graphene.String(default_value = ''), name = graphene.String(default_value = ''),351 specializations = graphene.String(default_value = ''))352 shifts = graphene.List(ShiftMapper, id = graphene.String(default_value = ''),353 start = graphene.String(default_value = ''), end = graphene.String(default_value = ''))354 operations = graphene.List(OperationMapper, id = graphene.String(default_value = ''), name = graphene.String(default_value = ''),355 start = graphene.String(default_value = ''), end = graphene.String(default_value = ''))356 #recital357 def resolve_people(self, info, id, name, surname, patronymic, phone, department, specialization):358 id_matcher = re.compile(id + '.*')359 department_id_matcher = re.compile(department + '.*')360 specialization_id_matcher = re.compile(specialization + '.*')361 return [PersonMapper.init_scalar(item)\362 for item in mongo_native.select_people(name = name, surname = surname, patronymic = patronymic, phone = phone)\363 if id_matcher.match(str(item['_id'])) and department_id_matcher.match(str(item['department'])) and specialization_id_matcher.match(str(item['specialization']))]364 def resolve_departments(self, info, id, name, vk):365 id_matcher = re.compile(id + '.*')366 return [DepartmentMapper.init_scalar(item) for item in mongo_native.select_departments(name = name, vk = vk) if id_matcher.match(str(item['_id']))]367 def resolve_property_types(self, info, id, name, desc):368 id_matcher = re.compile(id + '.*')369 return [PropertyTypeMapper.init_scalar(item) for item in mongo_native.select_property_types(name = name, description = desc)\370 if id_matcher.match(str(item['_id']))]371 def resolve_specializations(self, info, id, name):372 id_matcher = re.compile(id + '.*')373 return [SpecializationMapper.init_scalar(item) for item in mongo_native.select_specializations(name = name)\374 if id_matcher.match(str(item['_id']))]375 def resolve_properties(self, info, id, name, type_, admission, comissioning, department):376 id_matcher = re.compile(id + '.*')377 type_id_matcher = re.compile(type_ + '.*')378 department_id_matcher = re.compile(department + '.*')379 return [PropertyMapper.init_scalar(item) for item in mongo_native.select_properties(name = name, 380 admission = datetime.datetime.strptime(admission, TIMESTAMP_PATTERN) if admission else None, 381 comissioning = datetime.datetime.strptime(comissioning, TIMESTAMP_PATTERN) if comissioning else None)\382 if id_matcher.match(str(item['_id'])) and type_id_matcher.match(str(item['type'])) and department_id_matcher.match(str(item['department']))]383 def resolve_systemstates(self, info, id, name, desc):384 id_matcher = re.compile(id + '.*')385 return [SystemStateMapper.init_scalar(item) for item in mongo_native.select_system_states(name = name, description = desc)\386 if id_matcher.match(str(item['_id']))]387 def resolve_systemtypes(self, info, id, name, desc):388 id_matcher = re.compile(id + '.*')389 return [SystemTypeMapper.init_scalar(item) for item in mongo_native.select_system_types(name = name, description = desc)\390 if id_matcher.match(str(item['_id']))]391 def resolve_locations(self, info, id, name):392 id_matcher = re.compile(id + '.*')393 return [LocationMapper.init_scalar(item) for item in mongo_native.select_locations(name = name) if id_matcher.match(str(item['_id']))]394 def resolve_boats(self, info, id, name, capacity):395 id_matcher = re.compile(id + '.*')396 return [BoatMapper.init_scalar(item) for item in mongo_native.select_boats(name = name, 397 capacity = capacity if capacity != -1 else None) if id_matcher.match(str(item['_id']))]398 def resolve_sensors(self, info, id, name, location):399 id_matcher = re.compile(id + '.*')400 location_id_matcher = re.compile(location + '.*')401 return [SensorMapper.init_scalar(item) for item in mongo_native.select_sensors(name = name)\402 if id_matcher.match(str(item['_id'])) and location_id_matcher.match(str(item.get('location')))]403 def resolve_systems(self, info, id, name, launched, checked, serialnumber, state, type_, supervisor):404 id_matcher = re.compile(id + '.*')405 state_id_matcher = re.compile(state + '.*')406 type_id_matcher = re.compile(type_ + '.*')407 supervisor_id_matcher = re.compile(supervisor + '.*')408 return [SystemMapper.init_scalar(item) for item in mongo_native.select_systems(name = name,409 serialnumber = serialnumber if not math.isnan(serialnumber) else None,410 launched = datetime.datetime.strptime(launched, TIMESTAMP_PATTERN) if launched else None,411 checked = datetime.datetime.strptime(checked, TIMESTAMP_PATTERN) if checked else None)412 if id_matcher.match(str(item['_id'])) and state_id_matcher.match(str(item.get('state'))) and type_id_matcher.match(str(item.get('type'))) and \413 supervisor_id_matcher.match(str(item.get('supervisor')))]414 #logbook415 def resolve_systemtest(self, info, date, time, system, result):416 return [SystemTestMapper.init_scalar(item) for item in cassandra_mediator.select_system_tests(417 date = None if not date else datetime.datetime.strptime(date, DATE_PATTERN).date(),418 time = None if not time else datetime.datetime.strptime(time, TIME_PATTERN).time(),419 system_id = None if not system else string_to_bytes(system),420 result = result)]421 def resolve_controlaction(self, info, date, time, mac, user, command, params, result):422 return [ControlActionMapper.init_scalar(item) for item in cassandra_mediator.select_control_actions(423 date = None if not date else datetime.datetime.strptime(date, DATE_PATTERN).date(),424 time = None if not time else datetime.datetime.strptime(time, TIME_PATTERN).time(),425 mac_address = None if not mac else string_to_bytes(mac), 426 user_id = None if not user else string_to_bytes(user), 427 command = command, params = params, result = result)]428 def resolve_position(self, info, date, time, x, y, z, speed, attack_angle, direction_angle):429 return [PositionMapper.init_scalar(item) for item in cassandra_mediator.select_positions(430 date = None if not date else datetime.datetime.strptime(date, DATE_PATTERN).date(),431 time = None if not time else datetime.datetime.strptime(time, TIME_PATTERN).time(),432 x = x, y = y, z = z, speed = speed, attack_angle = attack_angle, direction_angle = direction_angle)]433 def resolve_operationstate(self, info, date, time, boat, operation, status, distancetotheship, zenith, azimuth, hydrogenium,434 helium, lithium, beryllium, borum,435 carboneum, nitrogenium, oxygenium, fluorum, neon, natrium, magnesium, aluminium, silicium, phosphorus, sulfur, chlorum, argon, kalium, calcium,\436 scandium, titanium, vanadium, chromium, manganum, ferrum, cobaltum, niccolum, cuprum, zincum, gallium, germanium, arsenicum, selenium, bromum,\437 crypton, rubidium, strontium, yttrium, zirconium, niobium, molybdaenum, technetium, ruthenium, rhodium, palladium, argentum, cadmium, indium,\438 stannum, stibium, tellurium, iodium, xenon, caesium, barium, lanthanum, cerium, praseodymium, neodymium, promethium, samarium, europium, gadolinium,\439 terbium, dysprosium, holmium, erbium, thulium, ytterbium, lutetium, hafnium, tantalum, wolframium, rhenium, osmium, iridium, platinum, aurum,\440 hydrargyrum, thallium, plumbum, bismuthum, polonium, astatum, radon, francium, radium, actinium, thorium, protactinium, uranium, neptunium,\441 plutonium, americium, curium, berkelium, californium, einsteinium, fermium, mendelevium, nobelium, lawrencium, rutherfordium, dubnium,\442 seaborgium, bohrium, hassium, meitnerium, darmstadtium, roentgenium, copernicium, nihonium, flerovium, moscovium, livermorium, tennessium,\443 oganesson, comment):444 return [OperationStateMapper.init_scalar(item) for item in cassandra_mediator.select_operation_states(445 date = None if not date else datetime.datetime.strptime(date, DATE_PATTERN).date(),446 time = None if not time else datetime.datetime.strptime(time, TIME_PATTERN).time(),447 boat_id = None if not boat else string_to_bytes(boat),448 operation_id = None if not operation else string_to_bytes(operation),449 status = status, distance_to_the_ship = distancetotheship, zenith = zenith, azimuth = azimuth, 450 hydrogenium = hydrogenium, helium = helium, lithium = lithium, beryllium = beryllium, borum = borum, carboneum = carboneum, 451 nitrogenium = nitrogenium, oxygenium = oxygenium, fluorum = fluorum, neon = neon, natrium = natrium, magnesium = magnesium, 452 aluminium = aluminium, silicium = silicium, phosphorus = phosphorus, sulfur = sulfur, chlorum = chlorum, argon = argon, kalium = kalium, 453 calcium = calcium, scandium = scandium, titanium = titanium, vanadium = vanadium, chromium = chromium, manganum = manganum, 454 ferrum = ferrum, cobaltum = cobaltum, niccolum = niccolum, cuprum = cuprum, zincum = zincum, gallium = gallium, germanium = germanium, 455 arsenicum = arsenicum, selenium = selenium, bromum = bromum, crypton = crypton, rubidium = rubidium, strontium = strontium, 456 yttrium = yttrium, zirconium = zirconium, niobium = niobium, molybdaenum = molybdaenum, technetium = technetium, ruthenium = ruthenium, 457 rhodium = rhodium, palladium = palladium, argentum = argentum, cadmium = cadmium, indium = indium, stannum = stannum, stibium = stibium, 458 tellurium = tellurium, iodium = iodium, xenon = xenon, caesium = caesium, barium = barium, lanthanum = lanthanum, cerium = cerium, 459 praseodymium = praseodymium, neodymium = neodymium, promethium = promethium, samarium = samarium, europium = europium, gadolinium = gadolinium, 460 terbium = terbium, dysprosium = dysprosium, holmium = holmium, erbium = erbium, thulium = thulium, ytterbium = ytterbium, lutetium = lutetium, 461 hafnium = hafnium, tantalum = tantalum, wolframium = wolframium, rhenium = rhenium, osmium = osmium, iridium = iridium, platinum = platinum, 462 aurum = aurum, hydrargyrum = hydrargyrum, thallium = thallium, plumbum = plumbum, bismuthum = bismuthum, polonium = polonium, astatum = astatum, 463 radon = radon, francium = francium, radium = radium, actinium = actinium, thorium = thorium, protactinium = protactinium, uranium = uranium, 464 neptunium = neptunium, plutonium = plutonium, americium = americium, curium = curium, berkelium = berkelium, californium = californium, 465 einsteinium = einsteinium, fermium = fermium, mendelevium = mendelevium, nobelium = nobelium, lawrencium = lawrencium, 466 rutherfordium = rutherfordium, dubnium = dubnium, seaborgium = seaborgium, bohrium = bohrium, hassium = hassium, meitnerium = meitnerium, 467 darmstadtium = darmstadtium, roentgenium = roentgenium, copernicium = copernicium, nihonium = nihonium, flerovium = flerovium, 468 moscovium = moscovium, livermorium = livermorium, tennessium = tennessium, oganesson = oganesson, comment = comment)]469 def resolve_shiftstate(self, info, date, time, shift, warninglevel, remainingcartridges, remainingair, remainingelectricity, comment):470 return [ShiftStateMapper.init_scalar(item) for item in cassandra_mediator.select_shift_states(471 date = None if not date else datetime.datetime.strptime(date, DATE_PATTERN).date(),472 time = None if not time else datetime.datetime.strptime(time, TIME_PATTERN).time(),473 shift_id = None if not shift else string_to_bytes(shift), 474 warning_level = warninglevel, remaining_cartridges = remainingcartridges, remaining_air = remainingair, remaining_electricity = remainingelectricity,475 comment = comment)]476 def resolve_sensordata(self, info, date, time, sensor, event, valuename, value, units):477 return [SensorDataMapper.init_scalar(item) for item in cassandra_mediator.select_sensor_data(478 date = None if not date else datetime.datetime.strptime(date, DATE_PATTERN).date(),479 time = None if not time else datetime.datetime.strptime(time, TIME_PATTERN).time(),480 source_id = None if not sensor else string_to_bytes(sensor), 481 event = event, value_name = valuename, value = value, units = units)]482 #relations483 def resolve_requirements(self, info, id, name, specializations):484 id_matcher = re.compile(id + '.*')485 return [RequirementMapper.init_scalar(item) for item in neo4j_mediator.select_requirements(486 name__regex = '.*' + name + '.*', specializations = specializations)]487 def resolve_shifts(self, info, id, start, end):488 id_matcher = re.compile(id + '.*')489 return [ShiftMapper.init_scalar(item) for item in neo4j_mediator.select_shifts(490 start = datetime.datetime.strptime(start, TIMESTAMP_PATTERN) if start else None,491 end = datetime.datetime.strptime(end, TIMESTAMP_PATTERN) if end else None) if id_matcher.match(str(item.ident))]492 def resolve_operations(self, info, id, name, start, end):493 id_matcher = re.compile(id + '.*')494 return [OperationMapper.init_scalar(item) for item in neo4j_mediator.select_operations(name__regex = '.*' + name + '.*',495 start = datetime.datetime.strptime(start, TIMESTAMP_PATTERN) if start else None,496 end = datetime.datetime.strptime(end, TIMESTAMP_PATTERN) if end else None) 497 if id_matcher.match(str(item.ident))]498 #return [OperationMapper.init_scalar(item) for item in Operation.nodes.filter() if id_matcher.match(str(item.ident))]499def get_mutation_description(explored_class):500 result = str(explored_class).lower().replace('create','create_').replace('remove','remove_').replace('eradicate','eradicate_') + ' {\n'501 for field in dir(explored_class.Arguments()):502 if '__' not in field:503 try:504 result += (' ' + field + ': ' + str(type(getattr(explored_class.Arguments(),field))) + '\n')505 except:506 result += (' ' + field + '\n')507 result += '}\n\n'508 return result509def get_docs():510 result = ''511 result += get_mutation_description(location_manipulator.CreateLocation)512 result += get_mutation_description(location_manipulator.RemoveLocation)513 result += get_mutation_description(location_manipulator.EradicateLocation)514 result += get_mutation_description(sensor_manipulator.CreateSensor)515 result += get_mutation_description(sensor_manipulator.RemoveSensor)516 result += get_mutation_description(department_manipulator.CreateDepartment)517 result += get_mutation_description(department_manipulator.RemoveDepartment)518 result += get_mutation_description(department_manipulator.EradicateDepartment)519 result += get_mutation_description(specialization_manipulator.CreateSpecialization)520 result += get_mutation_description(specialization_manipulator.RemoveSpecialization)521 result += get_mutation_description(specialization_manipulator.Eradicate)522 result += get_mutation_description(person_manipulator.CreatePerson)523 result += get_mutation_description(person_manipulator.RemovePerson)524 result += get_mutation_description(person_manipulator.EradicatePerson)525 result += get_mutation_description(boat_manipulator.CreateBoat)526 result += get_mutation_description(boat_manipulator.RemoveBoat)527 result += get_mutation_description(system_type_manipulator.CreateSystemType)528 result += get_mutation_description(system_type_manipulator.RemoveSystemType)529 result += get_mutation_description(system_type_manipulator.EradicateSystemType)530 result += get_mutation_description(system_state_manipulator.CreateSystemState)531 result += get_mutation_description(system_state_manipulator.RemoveSystemState)532 result += get_mutation_description(system_state_manipulator.EradicateSystemState)533 result += get_mutation_description(property_type_manipulator.CreatePropertyType)534 result += get_mutation_description(property_type_manipulator.RemovePropertyType)535 result += get_mutation_description(property_type_manipulator.EradicatePropertyType)536 result += get_mutation_description(system_manipulator.CreateSystem)537 result += get_mutation_description(system_manipulator.RemoveSystem)538 result += get_mutation_description(property_manipulator.CreateProperty)539 result += get_mutation_description(property_manipulator.RemoveProperty)540 result += get_mutation_description(shift_manipulator.CreateShift)541 result += get_mutation_description(shift_manipulator.RemoveShift)542 result += get_mutation_description(operation_manipulator.CreateOperation)543 result += get_mutation_description(operation_manipulator.RemoveOperation)544 result += get_mutation_description(requirement_manipulator.CreateRequirement)545 result += get_mutation_description(requirement_manipulator.RemoveRequirement)546 result += get_mutation_description(position_manipulator.CreatePosition)547 result += get_mutation_description(position_manipulator.RemovePosition)548 result += get_mutation_description(control_action_manipulator.CreateControlAction)549 result += get_mutation_description(control_action_manipulator.RemoveControlAction)550 result += get_mutation_description(system_test_manipulator.CreateSystemTest)551 result += get_mutation_description(system_test_manipulator.RemoveSystemTest)552 result += get_mutation_description(sensor_data_manipulator.CreateSensorData)553 result += get_mutation_description(sensor_data_manipulator.RemoveSensorData)554 result += get_mutation_description(shift_state_manipulator.CreateShiftState)555 result += get_mutation_description(shift_state_manipulator.RemoveShiftState)556 result += get_mutation_description(operation_state_manipulator.CreateOperationState)557 result += get_mutation_description(operation_state_manipulator.RemoveOperationState)558 return result559def main():560 if len(sys.argv) < 2:561 print('There is no query')562 sys.exit()563 query = sys.argv[1]564 if query == 'docs':565 print(get_docs())566 print('=====')567 return568 569 connection.setup([DB_URL], DB_NAME)570 schema = graphene.Schema(query = FirstQuery, mutation = FirstMutation)571 572 '''573 query MyFirstQuery {574 position(hour : 20, second : 12){575 x,576 y,577 speed,578 time,579 date580 }581 }582 '''583 print(json.dumps(schema.execute(query).data, indent = 4, sort_keys = True))584 print('=====')585if __name__ == '__main__':...
operation_state_manipulator.py
Source:operation_state_manipulator.py
1import sys, os2import configparser3import datetime4import graphene5import numpy as np6sys.path.append(os.environ['SPACE_SHIP_HOME'] + '/api/background/mappers')7from operation_state_mapper import OperationStateMapper8sys.path.append(os.environ['SPACE_SHIP_HOME'] + '/logbook')9import cassandra_mediator10from data_adapters import string_to_bytes11sys.path.append(os.environ['SPACE_SHIP_HOME'] + '/logbook/entities')12from operation_state import OperationState13config = configparser.ConfigParser()14config.read(os.environ['SPACE_SHIP_HOME'] + '/databases.config')15TIMESTAMP_PATTERN = os.environ.get('TIMESTAMP_PATTERN') or config['FORMATS']['timestamp']16class CreateOperationState(graphene.Mutation):17 class Arguments:18 timestamp = graphene.String()19 boat = graphene.String(default_value = '')20 operation = graphene.String()21 22 status = graphene.String()23 24 distancetotheship = graphene.Float()25 zenith = graphene.Float()26 azimuth = graphene.Float()27 hydrogenium = graphene.Float(default_value = 0)28 helium = graphene.Float(default_value = 0)29 lithium = graphene.Float(default_value = 0)30 beryllium = graphene.Float(default_value = 0)31 borum = graphene.Float(default_value = 0)32 carboneum = graphene.Float(default_value = 0)33 nitrogenium = graphene.Float(default_value = 0)34 oxygenium = graphene.Float(default_value = 0)35 fluorum = graphene.Float(default_value = 0)36 neon = graphene.Float(default_value = 0)37 natrium = graphene.Float(default_value = 0)38 magnesium = graphene.Float(default_value = 0)39 aluminium = graphene.Float(default_value = 0)40 silicium = graphene.Float(default_value = 0)41 phosphorus = graphene.Float(default_value = 0)42 sulfur = graphene.Float(default_value = 0)43 chlorum = graphene.Float(default_value = 0)44 argon = graphene.Float(default_value = 0)45 kalium = graphene.Float(default_value = 0)46 calcium = graphene.Float(default_value = 0)47 scandium = graphene.Float(default_value = 0)48 titanium = graphene.Float(default_value = 0)49 vanadium = graphene.Float(default_value = 0)50 chromium = graphene.Float(default_value = 0)51 manganum = graphene.Float(default_value = 0)52 ferrum = graphene.Float(default_value = 0)53 cobaltum = graphene.Float(default_value = 0)54 niccolum = graphene.Float(default_value = 0)55 cuprum = graphene.Float(default_value = 0)56 zincum = graphene.Float(default_value = 0)57 gallium = graphene.Float(default_value = 0)58 germanium = graphene.Float(default_value = 0)59 arsenicum = graphene.Float(default_value = 0)60 selenium = graphene.Float(default_value = 0)61 bromum = graphene.Float(default_value = 0)62 crypton = graphene.Float(default_value = 0)63 rubidium = graphene.Float(default_value = 0)64 strontium = graphene.Float(default_value = 0)65 yttrium = graphene.Float(default_value = 0)66 zirconium = graphene.Float(default_value = 0)67 niobium = graphene.Float(default_value = 0)68 molybdaenum = graphene.Float(default_value = 0)69 technetium = graphene.Float(default_value = 0)70 ruthenium = graphene.Float(default_value = 0)71 rhodium = graphene.Float(default_value = 0)72 palladium = graphene.Float(default_value = 0)73 argentum = graphene.Float(default_value = 0)74 cadmium = graphene.Float(default_value = 0)75 indium = graphene.Float(default_value = 0)76 stannum = graphene.Float(default_value = 0)77 stibium = graphene.Float(default_value = 0)78 tellurium = graphene.Float(default_value = 0)79 iodium = graphene.Float(default_value = 0)80 xenon = graphene.Float(default_value = 0)81 caesium = graphene.Float(default_value = 0)82 barium = graphene.Float(default_value = 0)83 lanthanum = graphene.Float(default_value = 0)84 cerium = graphene.Float(default_value = 0)85 praseodymium = graphene.Float(default_value = 0)86 neodymium = graphene.Float(default_value = 0)87 promethium = graphene.Float(default_value = 0)88 samarium = graphene.Float(default_value = 0)89 europium = graphene.Float(default_value = 0)90 gadolinium = graphene.Float(default_value = 0)91 terbium = graphene.Float(default_value = 0)92 dysprosium = graphene.Float(default_value = 0)93 holmium = graphene.Float(default_value = 0)94 erbium = graphene.Float(default_value = 0)95 thulium = graphene.Float(default_value = 0)96 ytterbium = graphene.Float(default_value = 0)97 lutetium = graphene.Float(default_value = 0)98 hafnium = graphene.Float(default_value = 0)99 tantalum = graphene.Float(default_value = 0)100 wolframium = graphene.Float(default_value = 0)101 rhenium = graphene.Float(default_value = 0)102 osmium = graphene.Float(default_value = 0)103 iridium = graphene.Float(default_value = 0)104 platinum = graphene.Float(default_value = 0)105 aurum = graphene.Float(default_value = 0)106 hydrargyrum = graphene.Float(default_value = 0)107 thallium = graphene.Float(default_value = 0)108 plumbum = graphene.Float(default_value = 0)109 bismuthum = graphene.Float(default_value = 0)110 polonium = graphene.Float(default_value = 0)111 astatum = graphene.Float(default_value = 0)112 radon = graphene.Float(default_value = 0)113 francium = graphene.Float(default_value = 0)114 radium = graphene.Float(default_value = 0)115 actinium = graphene.Float(default_value = 0)116 thorium = graphene.Float(default_value = 0)117 protactinium = graphene.Float(default_value = 0)118 uranium = graphene.Float(default_value = 0)119 neptunium = graphene.Float(default_value = 0)120 plutonium = graphene.Float(default_value = 0)121 americium = graphene.Float(default_value = 0)122 curium = graphene.Float(default_value = 0)123 berkelium = graphene.Float(default_value = 0)124 californium = graphene.Float(default_value = 0)125 einsteinium = graphene.Float(default_value = 0)126 fermium = graphene.Float(default_value = 0)127 mendelevium = graphene.Float(default_value = 0)128 nobelium = graphene.Float(default_value = 0)129 lawrencium = graphene.Float(default_value = 0)130 rutherfordium = graphene.Float(default_value = 0)131 dubnium = graphene.Float(default_value = 0)132 seaborgium = graphene.Float(default_value = 0)133 bohrium = graphene.Float(default_value = 0)134 hassium = graphene.Float(default_value = 0)135 meitnerium = graphene.Float(default_value = 0)136 darmstadtium = graphene.Float(default_value = 0)137 roentgenium = graphene.Float(default_value = 0)138 copernicium = graphene.Float(default_value = 0)139 nihonium = graphene.Float(default_value = 0)140 flerovium = graphene.Float(default_value = 0)141 moscovium = graphene.Float(default_value = 0)142 livermorium = graphene.Float(default_value = 0)143 tennessium = graphene.Float(default_value = 0)144 oganesson = graphene.Float(default_value = 0)145 146 comment = graphene.String()147 ok = graphene.Boolean()148 operationstate = graphene.Field(lambda: OperationStateMapper)149 def mutate(self, info, timestamp, boat, operation, status, distancetotheship, zenith, azimuth, hydrogenium, helium, lithium, beryllium, borum,\150 carboneum, nitrogenium, oxygenium, fluorum, neon, natrium, magnesium, aluminium, silicium, phosphorus, sulfur, chlorum, argon, kalium, calcium,\151 scandium, titanium, vanadium, chromium, manganum, ferrum, cobaltum, niccolum, cuprum, zincum, gallium, germanium, arsenicum, selenium, bromum,\152 crypton, rubidium, strontium, yttrium, zirconium, niobium, molybdaenum, technetium, ruthenium, rhodium, palladium, argentum, cadmium, indium,\153 stannum, stibium, tellurium, iodium, xenon, caesium, barium, lanthanum, cerium, praseodymium, neodymium, promethium, samarium, europium, gadolinium,\154 terbium, dysprosium, holmium, erbium, thulium, ytterbium, lutetium, hafnium, tantalum, wolframium, rhenium, osmium, iridium, platinum, aurum,\155 hydrargyrum, thallium, plumbum, bismuthum, polonium, astatum, radon, francium, radium, actinium, thorium, protactinium, uranium, neptunium,\156 plutonium, americium, curium, berkelium, californium, einsteinium, fermium, mendelevium, nobelium, lawrencium, rutherfordium, dubnium,\157 seaborgium, bohrium, hassium, meitnerium, darmstadtium, roentgenium, copernicium, nihonium, flerovium, moscovium, livermorium, tennessium,\158 oganesson, comment):159 operationstate = OperationStateMapper.init_scalar(cassandra_mediator.create_operation_state(datetime.datetime.strptime(timestamp, TIMESTAMP_PATTERN),\160 boat, operation, status, distancetotheship, zenith, azimuth, hydrogenium, helium, lithium, beryllium, borum,\161 carboneum, nitrogenium, oxygenium, fluorum, neon, natrium, magnesium, aluminium, silicium, phosphorus, sulfur, chlorum, argon, kalium, calcium,\162 scandium, titanium, vanadium, chromium, manganum, ferrum, cobaltum, niccolum, cuprum, zincum, gallium, germanium, arsenicum, selenium, bromum,\163 crypton, rubidium, strontium, yttrium, zirconium, niobium, molybdaenum, technetium, ruthenium, rhodium, palladium, argentum, cadmium, indium,\164 stannum, stibium, tellurium, iodium, xenon, caesium, barium, lanthanum, cerium, praseodymium, neodymium, promethium, samarium, europium, gadolinium,\165 terbium, dysprosium, holmium, erbium, thulium, ytterbium, lutetium, hafnium, tantalum, wolframium, rhenium, osmium, iridium, platinum, aurum,\166 hydrargyrum, thallium, plumbum, bismuthum, polonium, astatum, radon, francium, radium, actinium, thorium, protactinium, uranium, neptunium,\167 plutonium, americium, curium, berkelium, californium, einsteinium, fermium, mendelevium, nobelium, lawrencium, rutherfordium, dubnium,\168 seaborgium, bohrium, hassium, meitnerium, darmstadtium, roentgenium, copernicium, nihonium, flerovium, moscovium, livermorium, tennessium,\169 oganesson, comment))170 ok = True171 return CreateOperationState(operationstate = operationstate, ok = ok)172class RemoveOperationState(graphene.Mutation):173 class Arguments:174 timestamp = graphene.String()175 ok = graphene.Boolean()176 operationstate = graphene.Field(lambda: OperationStateMapper)177 def mutate(self, info, timestamp):178 operationstate = OperationStateMapper.init_scalar(cassandra_mediator.remove_operation_state(datetime.datetime.strptime(timestamp, TIMESTAMP_PATTERN)))179 ok = True180 return RemoveOperationState(operationstate = operationstate, ok = ok)181class UpdateOperationStates(graphene.Mutation):182 class Arguments:183 timestamp = graphene.String(default_value = '')184 boat = graphene.String(default_value = '')185 operation = graphene.String(default_value = '')186 status = graphene.String(default_value = '')187 distancetotheship = graphene.Float(default_value = float('nan'))188 zenith = graphene.Float(default_value = float('nan'))189 azimuth = graphene.Float(default_value = float('nan'))190 hydrogenium = graphene.Float(default_value = float('nan'))191 helium = graphene.Float(default_value = float('nan'))192 lithium = graphene.Float(default_value = float('nan'))193 beryllium = graphene.Float(default_value = float('nan'))194 borum = graphene.Float(default_value = float('nan'))195 carboneum = graphene.Float(default_value = float('nan'))196 nitrogenium = graphene.Float(default_value = float('nan'))197 oxygenium = graphene.Float(default_value = float('nan'))198 fluorum = graphene.Float(default_value = float('nan'))199 neon = graphene.Float(default_value = float('nan'))200 natrium = graphene.Float(default_value = float('nan'))201 magnesium = graphene.Float(default_value = float('nan'))202 aluminium = graphene.Float(default_value = float('nan'))203 silicium = graphene.Float(default_value = float('nan'))204 phosphorus = graphene.Float(default_value = float('nan'))205 sulfur = graphene.Float(default_value = float('nan'))206 chlorum = graphene.Float(default_value = float('nan'))207 argon = graphene.Float(default_value = float('nan'))208 kalium = graphene.Float(default_value = float('nan'))209 calcium = graphene.Float(default_value = float('nan'))210 scandium = graphene.Float(default_value = float('nan'))211 titanium = graphene.Float(default_value = float('nan'))212 vanadium = graphene.Float(default_value = float('nan'))213 chromium = graphene.Float(default_value = float('nan'))214 manganum = graphene.Float(default_value = float('nan'))215 ferrum = graphene.Float(default_value = float('nan'))216 cobaltum = graphene.Float(default_value = float('nan'))217 niccolum = graphene.Float(default_value = float('nan'))218 cuprum = graphene.Float(default_value = float('nan'))219 zincum = graphene.Float(default_value = float('nan'))220 gallium = graphene.Float(default_value = float('nan'))221 germanium = graphene.Float(default_value = float('nan'))222 arsenicum = graphene.Float(default_value = float('nan'))223 selenium = graphene.Float(default_value = float('nan'))224 bromum = graphene.Float(default_value = float('nan'))225 crypton = graphene.Float(default_value = float('nan'))226 rubidium = graphene.Float(default_value = float('nan'))227 strontium = graphene.Float(default_value = float('nan'))228 yttrium = graphene.Float(default_value = float('nan'))229 zirconium = graphene.Float(default_value = float('nan'))230 niobium = graphene.Float(default_value = float('nan'))231 molybdaenum = graphene.Float(default_value = float('nan'))232 technetium = graphene.Float(default_value = float('nan'))233 ruthenium = graphene.Float(default_value = float('nan'))234 rhodium = graphene.Float(default_value = float('nan'))235 palladium = graphene.Float(default_value = float('nan'))236 argentum = graphene.Float(default_value = float('nan'))237 cadmium = graphene.Float(default_value = float('nan'))238 indium = graphene.Float(default_value = float('nan'))239 stannum = graphene.Float(default_value = float('nan'))240 stibium = graphene.Float(default_value = float('nan'))241 tellurium = graphene.Float(default_value = float('nan'))242 iodium = graphene.Float(default_value = float('nan'))243 xenon = graphene.Float(default_value = float('nan'))244 caesium = graphene.Float(default_value = float('nan'))245 barium = graphene.Float(default_value = float('nan'))246 lanthanum = graphene.Float(default_value = float('nan'))247 cerium = graphene.Float(default_value = float('nan'))248 praseodymium = graphene.Float(default_value = float('nan'))249 neodymium = graphene.Float(default_value = float('nan'))250 promethium = graphene.Float(default_value = float('nan'))251 samarium = graphene.Float(default_value = float('nan'))252 europium = graphene.Float(default_value = float('nan'))253 gadolinium = graphene.Float(default_value = float('nan'))254 terbium = graphene.Float(default_value = float('nan'))255 dysprosium = graphene.Float(default_value = float('nan'))256 holmium = graphene.Float(default_value = float('nan'))257 erbium = graphene.Float(default_value = float('nan'))258 thulium = graphene.Float(default_value = float('nan'))259 ytterbium = graphene.Float(default_value = float('nan'))260 lutetium = graphene.Float(default_value = float('nan'))261 hafnium = graphene.Float(default_value = float('nan'))262 tantalum = graphene.Float(default_value = float('nan'))263 wolframium = graphene.Float(default_value = float('nan'))264 rhenium = graphene.Float(default_value = float('nan'))265 osmium = graphene.Float(default_value = float('nan'))266 iridium = graphene.Float(default_value = float('nan'))267 platinum = graphene.Float(default_value = float('nan'))268 aurum = graphene.Float(default_value = float('nan'))269 hydrargyrum = graphene.Float(default_value = float('nan'))270 thallium = graphene.Float(default_value = float('nan'))271 plumbum = graphene.Float(default_value = float('nan'))272 bismuthum = graphene.Float(default_value = float('nan'))273 polonium = graphene.Float(default_value = float('nan'))274 astatum = graphene.Float(default_value = float('nan'))275 radon = graphene.Float(default_value = float('nan'))276 francium = graphene.Float(default_value = float('nan'))277 radium = graphene.Float(default_value = float('nan'))278 actinium = graphene.Float(default_value = float('nan'))279 thorium = graphene.Float(default_value = float('nan'))280 protactinium = graphene.Float(default_value = float('nan'))281 uranium = graphene.Float(default_value = float('nan'))282 neptunium = graphene.Float(default_value = float('nan'))283 plutonium = graphene.Float(default_value = float('nan'))284 americium = graphene.Float(default_value = float('nan'))285 curium = graphene.Float(default_value = float('nan'))286 berkelium = graphene.Float(default_value = float('nan'))287 californium = graphene.Float(default_value = float('nan'))288 einsteinium = graphene.Float(default_value = float('nan'))289 fermium = graphene.Float(default_value = float('nan'))290 mendelevium = graphene.Float(default_value = float('nan'))291 nobelium = graphene.Float(default_value = float('nan'))292 lawrencium = graphene.Float(default_value = float('nan'))293 rutherfordium = graphene.Float(default_value = float('nan'))294 dubnium = graphene.Float(default_value = float('nan'))295 seaborgium = graphene.Float(default_value = float('nan'))296 bohrium = graphene.Float(default_value = float('nan'))297 hassium = graphene.Float(default_value = float('nan'))298 meitnerium = graphene.Float(default_value = float('nan'))299 darmstadtium = graphene.Float(default_value = float('nan'))300 roentgenium = graphene.Float(default_value = float('nan'))301 copernicium = graphene.Float(default_value = float('nan'))302 nihonium = graphene.Float(default_value = float('nan'))303 flerovium = graphene.Float(default_value = float('nan'))304 moscovium = graphene.Float(default_value = float('nan'))305 livermorium = graphene.Float(default_value = float('nan'))306 tennessium = graphene.Float(default_value = float('nan'))307 oganesson = graphene.Float(default_value = float('nan'))308 comment = graphene.String(default_value = '')309 set_boat = graphene.String(default_value = '')310 set_operation = graphene.String(default_value = '')311 set_status = graphene.String(default_value = '')312 set_distancetotheship = graphene.Float(default_value = float('nan'))313 set_zenith = graphene.Float(default_value = float('nan'))314 set_azimuth = graphene.Float(default_value = float('nan'))315 set_hydrogenium = graphene.Float(default_value = float('nan'))316 set_helium = graphene.Float(default_value = float('nan'))317 set_lithium = graphene.Float(default_value = float('nan'))318 set_beryllium = graphene.Float(default_value = float('nan'))319 set_borum = graphene.Float(default_value = float('nan'))320 set_carboneum = graphene.Float(default_value = float('nan'))321 set_nitrogenium = graphene.Float(default_value = float('nan'))322 set_oxygenium = graphene.Float(default_value = float('nan'))323 set_fluorum = graphene.Float(default_value = float('nan'))324 set_neon = graphene.Float(default_value = float('nan'))325 set_natrium = graphene.Float(default_value = float('nan'))326 set_magnesium = graphene.Float(default_value = float('nan'))327 set_aluminium = graphene.Float(default_value = float('nan'))328 set_silicium = graphene.Float(default_value = float('nan'))329 set_phosphorus = graphene.Float(default_value = float('nan'))330 set_sulfur = graphene.Float(default_value = float('nan'))331 set_chlorum = graphene.Float(default_value = float('nan'))332 set_argon = graphene.Float(default_value = float('nan'))333 set_kalium = graphene.Float(default_value = float('nan'))334 set_calcium = graphene.Float(default_value = float('nan'))335 set_scandium = graphene.Float(default_value = float('nan'))336 set_titanium = graphene.Float(default_value = float('nan'))337 set_vanadium = graphene.Float(default_value = float('nan'))338 set_chromium = graphene.Float(default_value = float('nan'))339 set_manganum = graphene.Float(default_value = float('nan'))340 set_ferrum = graphene.Float(default_value = float('nan'))341 set_cobaltum = graphene.Float(default_value = float('nan'))342 set_niccolum = graphene.Float(default_value = float('nan'))343 set_cuprum = graphene.Float(default_value = float('nan'))344 set_zincum = graphene.Float(default_value = float('nan'))345 set_gallium = graphene.Float(default_value = float('nan'))346 set_germanium = graphene.Float(default_value = float('nan'))347 set_arsenicum = graphene.Float(default_value = float('nan'))348 set_selenium = graphene.Float(default_value = float('nan'))349 set_bromum = graphene.Float(default_value = float('nan'))350 set_crypton = graphene.Float(default_value = float('nan'))351 set_rubidium = graphene.Float(default_value = float('nan'))352 set_strontium = graphene.Float(default_value = float('nan'))353 set_yttrium = graphene.Float(default_value = float('nan'))354 set_zirconium = graphene.Float(default_value = float('nan'))355 set_niobium = graphene.Float(default_value = float('nan'))356 set_molybdaenum = graphene.Float(default_value = float('nan'))357 set_technetium = graphene.Float(default_value = float('nan'))358 set_ruthenium = graphene.Float(default_value = float('nan'))359 set_rhodium = graphene.Float(default_value = float('nan'))360 set_palladium = graphene.Float(default_value = float('nan'))361 set_argentum = graphene.Float(default_value = float('nan'))362 set_cadmium = graphene.Float(default_value = float('nan'))363 set_indium = graphene.Float(default_value = float('nan'))364 set_stannum = graphene.Float(default_value = float('nan'))365 set_stibium = graphene.Float(default_value = float('nan'))366 set_tellurium = graphene.Float(default_value = float('nan'))367 set_iodium = graphene.Float(default_value = float('nan'))368 set_xenon = graphene.Float(default_value = float('nan'))369 set_caesium = graphene.Float(default_value = float('nan'))370 set_barium = graphene.Float(default_value = float('nan'))371 set_lanthanum = graphene.Float(default_value = float('nan'))372 set_cerium = graphene.Float(default_value = float('nan'))373 set_praseodymium = graphene.Float(default_value = float('nan'))374 set_neodymium = graphene.Float(default_value = float('nan'))375 set_promethium = graphene.Float(default_value = float('nan'))376 set_samarium = graphene.Float(default_value = float('nan'))377 set_europium = graphene.Float(default_value = float('nan'))378 set_gadolinium = graphene.Float(default_value = float('nan'))379 set_terbium = graphene.Float(default_value = float('nan'))380 set_dysprosium = graphene.Float(default_value = float('nan'))381 set_holmium = graphene.Float(default_value = float('nan'))382 set_erbium = graphene.Float(default_value = float('nan'))383 set_thulium = graphene.Float(default_value = float('nan'))384 set_ytterbium = graphene.Float(default_value = float('nan'))385 set_lutetium = graphene.Float(default_value = float('nan'))386 set_hafnium = graphene.Float(default_value = float('nan'))387 set_tantalum = graphene.Float(default_value = float('nan'))388 set_wolframium = graphene.Float(default_value = float('nan'))389 set_rhenium = graphene.Float(default_value = float('nan'))390 set_osmium = graphene.Float(default_value = float('nan'))391 set_iridium = graphene.Float(default_value = float('nan'))392 set_platinum = graphene.Float(default_value = float('nan'))393 set_aurum = graphene.Float(default_value = float('nan'))394 set_hydrargyrum = graphene.Float(default_value = float('nan'))395 set_thallium = graphene.Float(default_value = float('nan'))396 set_plumbum = graphene.Float(default_value = float('nan'))397 set_bismuthum = graphene.Float(default_value = float('nan'))398 set_polonium = graphene.Float(default_value = float('nan'))399 set_astatum = graphene.Float(default_value = float('nan'))400 set_radon = graphene.Float(default_value = float('nan'))401 set_francium = graphene.Float(default_value = float('nan'))402 set_radium = graphene.Float(default_value = float('nan'))403 set_actinium = graphene.Float(default_value = float('nan'))404 set_thorium = graphene.Float(default_value = float('nan'))405 set_protactinium = graphene.Float(default_value = float('nan'))406 set_uranium = graphene.Float(default_value = float('nan'))407 set_neptunium = graphene.Float(default_value = float('nan'))408 set_plutonium = graphene.Float(default_value = float('nan'))409 set_americium = graphene.Float(default_value = float('nan'))410 set_curium = graphene.Float(default_value = float('nan'))411 set_berkelium = graphene.Float(default_value = float('nan'))412 set_californium = graphene.Float(default_value = float('nan'))413 set_einsteinium = graphene.Float(default_value = float('nan'))414 set_fermium = graphene.Float(default_value = float('nan'))415 set_mendelevium = graphene.Float(default_value = float('nan'))416 set_nobelium = graphene.Float(default_value = float('nan'))417 set_lawrencium = graphene.Float(default_value = float('nan'))418 set_rutherfordium = graphene.Float(default_value = float('nan'))419 set_dubnium = graphene.Float(default_value = float('nan'))420 set_seaborgium = graphene.Float(default_value = float('nan'))421 set_bohrium = graphene.Float(default_value = float('nan'))422 set_hassium = graphene.Float(default_value = float('nan'))423 set_meitnerium = graphene.Float(default_value = float('nan'))424 set_darmstadtium = graphene.Float(default_value = float('nan'))425 set_roentgenium = graphene.Float(default_value = float('nan'))426 set_copernicium = graphene.Float(default_value = float('nan'))427 set_nihonium = graphene.Float(default_value = float('nan'))428 set_flerovium = graphene.Float(default_value = float('nan'))429 set_moscovium = graphene.Float(default_value = float('nan'))430 set_livermorium = graphene.Float(default_value = float('nan'))431 set_tennessium = graphene.Float(default_value = float('nan'))432 set_oganesson = graphene.Float(default_value = float('nan'))433 set_comment = graphene.String(default_value = '')434 ok = graphene.Boolean()435 def mutate(self, info, timestamp, boat, operation, status, distancetotheship, zenith, azimuth, hydrogenium, helium, lithium, beryllium, borum,\436 carboneum, nitrogenium, oxygenium, fluorum, neon, natrium, magnesium, aluminium, silicium, phosphorus, sulfur, chlorum, argon, kalium, calcium,\437 scandium, titanium, vanadium, chromium, manganum, ferrum, cobaltum, niccolum, cuprum, zincum, gallium, germanium, arsenicum, selenium, bromum,\438 crypton, rubidium, strontium, yttrium, zirconium, niobium, molybdaenum, technetium, ruthenium, rhodium, palladium, argentum, cadmium, indium,\439 stannum, stibium, tellurium, iodium, xenon, caesium, barium, lanthanum, cerium, praseodymium, neodymium, promethium, samarium, europium, gadolinium,\440 terbium, dysprosium, holmium, erbium, thulium, ytterbium, lutetium, hafnium, tantalum, wolframium, rhenium, osmium, iridium, platinum, aurum,\441 hydrargyrum, thallium, plumbum, bismuthum, polonium, astatum, radon, francium, radium, actinium, thorium, protactinium, uranium, neptunium,\442 plutonium, americium, curium, berkelium, californium, einsteinium, fermium, mendelevium, nobelium, lawrencium, rutherfordium, dubnium,\443 seaborgium, bohrium, hassium, meitnerium, darmstadtium, roentgenium, copernicium, nihonium, flerovium, moscovium, livermorium, tennessium,\444 oganesson, comment, set_boat, set_operation, set_status, set_distancetotheship, set_zenith, set_azimuth, set_hydrogenium, set_helium,445 set_lithium, set_beryllium, set_borum, set_carboneum, set_nitrogenium, set_oxygenium, set_fluorum, set_neon, set_natrium, set_magnesium,446 set_aluminium, set_silicium, set_phosphorus, set_sulfur, set_chlorum, set_argon, set_kalium, set_calcium, set_scandium, set_titanium,447 set_vanadium, set_chromium, set_manganum, set_ferrum, set_cobaltum, set_niccolum, set_cuprum, set_zincum, set_gallium, set_germanium,448 set_arsenicum, set_selenium, set_bromum, set_crypton, set_rubidium, set_strontium, set_yttrium, set_zirconium, set_niobium, set_molybdaenum,449 set_technetium, set_ruthenium, set_rhodium, set_palladium, set_argentum, set_cadmium, set_indium, set_stannum, set_stibium, set_tellurium,450 set_iodium, set_xenon, set_caesium, set_barium, set_lanthanum, set_cerium, set_praseodymium, set_neodymium, set_promethium, set_samarium,451 set_europium, set_gadolinium, set_terbium, set_dysprosium, set_holmium, set_erbium, set_thulium, set_ytterbium, set_lutetium, set_hafnium,452 set_tantalum, set_wolframium, set_rhenium, set_osmium, set_iridium, set_platinum, set_aurum, set_hydrargyrum, set_thallium, set_plumbum,453 set_bismuthum, set_polonium, set_astatum, set_radon, set_francium, set_radium, set_actinium, set_thorium, set_protactinium, set_uranium,454 set_neptunium, set_plutonium, set_americium, set_curium, set_berkelium, set_californium, set_einsteinium, set_fermium, set_mendelevium,455 set_nobelium, set_lawrencium, set_rutherfordium, set_dubnium, set_seaborgium, set_bohrium, set_hassium, set_meitnerium, set_darmstadtium, 456 set_roentgenium, set_copernicium, set_nihonium, set_flerovium, set_moscovium, set_livermorium, set_tennessium, set_oganesson,set_comment):457 parsed_timestamp = None if not timestamp else datetime.datetime.strptime(timestamp, TIMESTAMP_PATTERN)458 operationstate = cassandra_mediator.update_operation_states(date = None if not parsed_timestamp else parsed_timestamp.date,\459 time = None if not parsed_timestamp else parsed_timestamp.time,460 boat_id = None if not boat else string_to_bytes(boat), 461 operation_id = None if not operation else string_to_bytes(operation), 462 operation_status = status, zenith = zenith, azimuth = azimuth, comment = comment, distancetotheship = distancetotheship,463 set_boat_id = None if not set_boat else OperationState.validate_boat_id(string_to_bytes(set_boat)), 464 set_operation_id = None if not set_operation else OperationState.validate_boat_id(string_to_bytes(set_operation)), 465 set_operation_status = None if not set_status else OperationState.validate_operation_status(set_status), 466 set_distancetotheship = set_distancetotheship,467 set_zenith = None if not set_zenith == float('nan') else OperationState.validate_angle(set_zenith), 468 set_azimuth = None if not set_azimuth == float('nan') else OperationState.validate_angle(set_azimuth),469 set_comment = set_comment,470 set_hydrogenium = set_hydrogenium, hydrogenium = hydrogenium, set_helium = set_helium, helium = helium, 471 set_lithium = set_lithium, lithium = lithium, set_beryllium = set_beryllium, beryllium = beryllium, 472 set_borum = set_borum, borum = borum, set_carboneum = set_carboneum, carboneum = carboneum, set_nitrogenium = set_nitrogenium, 473 nitrogenium = nitrogenium, set_oxygenium = set_oxygenium, oxygenium = oxygenium, set_fluorum = set_fluorum, fluorum = fluorum, 474 set_neon = set_neon, neon = neon, set_natrium = set_natrium, natrium = natrium, set_magnesium = set_magnesium, magnesium = magnesium, 475 set_aluminium = set_aluminium, aluminium = aluminium, set_silicium = set_silicium, silicium = silicium, set_phosphorus = set_phosphorus, 476 phosphorus = phosphorus, set_sulfur = set_sulfur, sulfur = sulfur, set_chlorum = set_chlorum, chlorum = chlorum, set_argon = set_argon, 477 argon = argon, set_kalium = set_kalium, kalium = kalium, set_calcium = set_calcium, calcium = calcium, set_scandium = set_scandium, 478 scandium = scandium, set_titanium = set_titanium, titanium = titanium, set_vanadium = set_vanadium, vanadium = vanadium, 479 set_chromium = set_chromium, chromium = chromium, set_manganum = set_manganum, manganum = manganum, set_ferrum = set_ferrum, 480 ferrum = ferrum, set_cobaltum = set_cobaltum, cobaltum = cobaltum, set_niccolum = set_niccolum, niccolum = niccolum, 481 set_cuprum = set_cuprum, cuprum = cuprum, set_zincum = set_zincum, zincum = zincum, set_gallium = set_gallium, 482 gallium = gallium, set_germanium = set_germanium, germanium = germanium, set_arsenicum = set_arsenicum, 483 arsenicum = arsenicum, set_selenium = set_selenium, selenium = selenium, set_bromum = set_bromum, 484 bromum = bromum, set_crypton = set_crypton, crypton = crypton, set_rubidium = set_rubidium, rubidium = rubidium, 485 set_strontium = set_strontium, strontium = strontium, set_yttrium = set_yttrium, yttrium = yttrium, set_zirconium = set_zirconium, 486 zirconium = zirconium, set_niobium = set_niobium, niobium = niobium, set_molybdaenum = set_molybdaenum, molybdaenum = molybdaenum, 487 set_technetium = set_technetium, technetium = technetium, set_ruthenium = set_ruthenium, ruthenium = ruthenium, set_rhodium = set_rhodium, 488 rhodium = rhodium, set_palladium = set_palladium, palladium = palladium, set_argentum = set_argentum, argentum = argentum, 489 set_cadmium = set_cadmium, cadmium = cadmium, set_indium = set_indium, indium = indium, set_stannum = set_stannum, stannum = stannum, 490 set_stibium = set_stibium, stibium = stibium, set_tellurium = set_tellurium, tellurium = tellurium, set_iodium = set_iodium, 491 iodium = iodium, set_xenon = set_xenon, xenon = xenon, set_caesium = set_caesium, caesium = caesium, set_barium = set_barium, 492 barium = barium, set_lanthanum = set_lanthanum, lanthanum = lanthanum, set_cerium = set_cerium, cerium = cerium, 493 set_praseodymium = set_praseodymium, praseodymium = praseodymium, set_neodymium = set_neodymium, neodymium = neodymium, 494 set_promethium = set_promethium, promethium = promethium, set_samarium = set_samarium, samarium = samarium, set_europium = set_europium, 495 europium = europium, set_gadolinium = set_gadolinium, gadolinium = gadolinium, set_terbium = set_terbium, terbium = terbium, 496 set_dysprosium = set_dysprosium, dysprosium = dysprosium, set_holmium = set_holmium, holmium = holmium, set_erbium = set_erbium, 497 erbium = erbium, set_thulium = set_thulium, thulium = thulium, set_ytterbium = set_ytterbium, ytterbium = ytterbium, 498 set_lutetium = set_lutetium, lutetium = lutetium, set_hafnium = set_hafnium, hafnium = hafnium, set_tantalum = set_tantalum, 499 tantalum = tantalum, set_wolframium = set_wolframium, wolframium = wolframium, set_rhenium = set_rhenium, rhenium = rhenium, 500 set_osmium = set_osmium, osmium = osmium, set_iridium = set_iridium, iridium = iridium, set_platinum = set_platinum, platinum = platinum, 501 set_aurum = set_aurum, aurum = aurum, set_hydrargyrum = set_hydrargyrum, hydrargyrum = hydrargyrum, set_thallium = set_thallium, 502 thallium = thallium, set_plumbum = set_plumbum, plumbum = plumbum, set_bismuthum = set_bismuthum, bismuthum = bismuthum, 503 set_polonium = set_polonium, polonium = polonium, set_astatum = set_astatum, astatum = astatum, set_radon = set_radon, radon = radon, 504 set_francium = set_francium, francium = francium, set_radium = set_radium, radium = radium, set_actinium = set_actinium, actinium = actinium, 505 set_thorium = set_thorium, thorium = thorium, set_protactinium = set_protactinium, protactinium = protactinium, set_uranium = set_uranium, 506 uranium = uranium, set_neptunium = set_neptunium, neptunium = neptunium, set_plutonium = set_plutonium, plutonium = plutonium,507 set_americium = set_americium, americium = americium, set_curium = set_curium, curium = curium, set_berkelium = set_berkelium, 508 berkelium = berkelium, set_californium = set_californium, californium = californium, set_einsteinium = set_einsteinium, einsteinium = einsteinium, 509 set_fermium = set_fermium, fermium = fermium, set_mendelevium = set_mendelevium, mendelevium = mendelevium, set_nobelium = set_nobelium, 510 nobelium = nobelium, set_lawrencium = set_lawrencium, lawrencium = lawrencium, set_rutherfordium = set_rutherfordium, 511 rutherfordium = rutherfordium, set_dubnium = set_dubnium, dubnium = dubnium, set_seaborgium = set_seaborgium, seaborgium = seaborgium, 512 set_bohrium = set_bohrium, bohrium = bohrium, set_hassium = set_hassium, hassium = hassium, set_meitnerium = set_meitnerium, 513 meitnerium = meitnerium, set_darmstadtium = set_darmstadtium, darmstadtium = darmstadtium, set_roentgenium = set_roentgenium, 514 roentgenium = roentgenium, set_copernicium = set_copernicium, copernicium = copernicium, set_nihonium = set_nihonium, nihonium = nihonium, 515 set_flerovium = set_flerovium, flerovium = flerovium, set_moscovium = set_moscovium, moscovium = moscovium, set_livermorium = set_livermorium, 516 livermorium = livermorium, set_tennessium = set_tennessium, tennessium = tennessium, set_oganesson = set_oganesson, oganesson = oganesson)517 ok = True...
manager.py
Source:manager.py
1from decimal import Decimal2from typing import TYPE_CHECKING, Any, List, Optional, Union3from django.conf import settings4from django.utils.module_loading import import_string5from django_countries.fields import Country6from prices import Money, MoneyRange, TaxedMoney, TaxedMoneyRange7from ..core.payments import PaymentInterface8from ..core.taxes import TaxType, quantize_price9from .models import PluginConfiguration10if TYPE_CHECKING:11 from .base_plugin import BasePlugin12 from ..checkout.models import Checkout, CheckoutLine13 from ..product.models import Product14 from ..account.models import Address, User15 from ..order.models import OrderLine, Order16 from ..payment.interface import PaymentData, TokenConfig17class ExtensionsManager(PaymentInterface):18 """Base manager for handling plugins logic."""19 plugins = None20 def __init__(self, plugins: List[str]):21 self.plugins = []22 for plugin_path in plugins:23 plugin_class = import_string(plugin_path)24 self.plugins.append(plugin_class())25 def __run_method_on_plugins(26 self, method_name: str, default_value: Any, *args, **kwargs27 ):28 """Try to run a method with the given name on each declared plugin."""29 value = default_value30 for plugin in self.plugins:31 value = self.__run_method_on_single_plugin(32 plugin, method_name, value, *args, **kwargs33 )34 return value35 def __run_method_on_single_plugin(36 self,37 plugin: "BasePlugin",38 method_name: str,39 previous_value: Any,40 *args,41 **kwargs,42 ) -> Any:43 """Run method_name on plugin.44 Method will return value returned from plugin's45 method. If plugin doesn't have own implementation of expected method_name, it46 will return previous_value.47 """48 plugin_method = getattr(plugin, method_name, NotImplemented)49 if plugin_method == NotImplemented:50 return previous_value51 returned_value = plugin_method(*args, **kwargs, previous_value=previous_value)52 if returned_value == NotImplemented:53 return previous_value54 return returned_value55 def change_user_address(56 self, address: "Address", address_type: Optional[str], user: Optional["User"]57 ) -> "Address":58 default_value = address59 return self.__run_method_on_plugins(60 "change_user_address", default_value, address, address_type, user61 )62 def calculate_checkout_total(63 self, checkout: "Checkout", discounts: List["DiscountInfo"]64 ) -> TaxedMoney:65 total = checkout.get_total(discounts)66 default_value = quantize_price(67 TaxedMoney(net=total, gross=total), total.currency68 )69 return self.__run_method_on_plugins(70 "calculate_checkout_total", default_value, checkout, discounts71 )72 def calculate_checkout_subtotal(73 self, checkout: "Checkout", discounts: List["DiscountInfo"]74 ) -> TaxedMoney:75 subtotal = checkout.get_subtotal(discounts)76 default_value = quantize_price(77 TaxedMoney(net=subtotal, gross=subtotal), subtotal.currency78 )79 return self.__run_method_on_plugins(80 "calculate_checkout_subtotal", default_value, checkout, discounts81 )82 def calculate_checkout_shipping(83 self, checkout: "Checkout", discounts: List["DiscountInfo"]84 ) -> TaxedMoney:85 total = checkout.get_shipping_price()86 total = TaxedMoney(net=total, gross=total)87 default_value = quantize_price(total, total.currency)88 return self.__run_method_on_plugins(89 "calculate_checkout_shipping", default_value, checkout, discounts90 )91 def calculate_order_shipping(self, order: "Order") -> TaxedMoney:92 shipping_price = order.shipping_method.price93 default_value = quantize_price(94 TaxedMoney(net=shipping_price, gross=shipping_price),95 shipping_price.currency,96 )97 return self.__run_method_on_plugins(98 "calculate_order_shipping", default_value, order99 )100 def calculate_checkout_line_total(101 self, checkout_line: "CheckoutLine", discounts: List["DiscountInfo"]102 ):103 total = checkout_line.get_total(discounts)104 default_value = quantize_price(105 TaxedMoney(net=total, gross=total), total.currency106 )107 return self.__run_method_on_plugins(108 "calculate_checkout_line_total", default_value, checkout_line, discounts109 )110 def calculate_order_line_unit(self, order_line: "OrderLine") -> TaxedMoney:111 unit_price = order_line.unit_price112 default_value = quantize_price(unit_price, unit_price.currency)113 return self.__run_method_on_plugins(114 "calculate_order_line_unit", default_value, order_line115 )116 def get_tax_rate_type_choices(self) -> List[TaxType]:117 default_value = []118 return self.__run_method_on_plugins("get_tax_rate_type_choices", default_value)119 def show_taxes_on_storefront(self) -> bool:120 default_value = False121 return self.__run_method_on_plugins("show_taxes_on_storefront", default_value)122 def taxes_are_enabled(self) -> bool:123 default_value = False124 return self.__run_method_on_plugins("taxes_are_enabled", default_value)125 def apply_taxes_to_product(126 self, product: "Product", price: Money, country: Country127 ):128 default_value = quantize_price(129 TaxedMoney(net=price, gross=price), price.currency130 )131 return self.__run_method_on_plugins(132 "apply_taxes_to_product", default_value, product, price, country133 )134 def apply_taxes_to_shipping(135 self, price: Money, shipping_address: "Address"136 ) -> TaxedMoney:137 default_value = quantize_price(138 TaxedMoney(net=price, gross=price), price.currency139 )140 return self.__run_method_on_plugins(141 "apply_taxes_to_shipping", default_value, price, shipping_address142 )143 def apply_taxes_to_shipping_price_range(self, prices: MoneyRange, country: Country):144 start = TaxedMoney(net=prices.start, gross=prices.start)145 stop = TaxedMoney(net=prices.stop, gross=prices.stop)146 default_value = quantize_price(147 TaxedMoneyRange(start=start, stop=stop), start.currency148 )149 return self.__run_method_on_plugins(150 "apply_taxes_to_shipping_price_range", default_value, prices, country151 )152 def preprocess_order_creation(153 self, checkout: "Checkout", discounts: List["DiscountInfo"]154 ):155 default_value = None156 return self.__run_method_on_plugins(157 "preprocess_order_creation", default_value, checkout, discounts158 )159 def customer_created(self, customer: "User"):160 default_value = None161 return self.__run_method_on_plugins("customer_created", default_value, customer)162 def product_created(self, product: "Product"):163 default_value = None164 return self.__run_method_on_plugins("product_created", default_value, product)165 def order_created(self, order: "Order"):166 default_value = None167 return self.__run_method_on_plugins("order_created", default_value, order)168 def order_fully_paid(self, order: "Order"):169 default_value = None170 return self.__run_method_on_plugins("order_fully_paid", default_value, order)171 def order_updated(self, order: "Order"):172 default_value = None173 return self.__run_method_on_plugins("order_updated", default_value, order)174 def order_cancelled(self, order: "Order"):175 default_value = None176 return self.__run_method_on_plugins("order_cancelled", default_value, order)177 def order_fulfilled(self, order: "Order"):178 default_value = None179 return self.__run_method_on_plugins("order_fulfilled", default_value, order)180 def authorize_payment(181 self, gateway: str, payment_information: "PaymentData"182 ) -> Optional["GatewayResponse"]:183 method_name = "authorize_payment"184 return self.__run_payment_method(gateway, method_name, payment_information)185 def capture_payment(186 self, gateway: str, payment_information: "PaymentData"187 ) -> Optional["GatewayResponse"]:188 method_name = "capture_payment"189 return self.__run_payment_method(gateway, method_name, payment_information)190 def refund_payment(191 self, gateway: str, payment_information: "PaymentData"192 ) -> Optional["GatewayResponse"]:193 method_name = "refund_payment"194 return self.__run_payment_method(gateway, method_name, payment_information)195 def void_payment(196 self, gateway: str, payment_information: "PaymentData"197 ) -> Optional["GatewayResponse"]:198 method_name = "void_payment"199 return self.__run_payment_method(gateway, method_name, payment_information)200 def confirm_payment(201 self, gateway: str, payment_information: "PaymentData"202 ) -> Optional["GatewayResponse"]:203 method_name = "confirm_payment"204 return self.__run_payment_method(gateway, method_name, payment_information)205 def process_payment(206 self, gateway: str, payment_information: "PaymentData"207 ) -> Optional["GatewayResponse"]:208 method_name = "process_payment"209 return self.__run_payment_method(gateway, method_name, payment_information)210 def create_payment_form(self, data, gateway, payment_information):211 method_name = "create_form"212 return self.__run_payment_method(213 gateway, method_name, payment_information, data=data214 )215 def get_client_token(self, gateway, token_config: "TokenConfig") -> str:216 method_name = "get_client_token"217 default_value = None218 gtw = self.get_plugin(gateway)219 return self.__run_method_on_single_plugin(220 gtw, method_name, default_value, token_config=token_config221 )222 def list_payment_sources(223 self, gateway: str, customer_id: str224 ) -> List["CustomerSource"]:225 default_value = []226 gtw = self.get_plugin(gateway)227 if gtw is not None:228 return self.__run_method_on_single_plugin(229 gtw, "list_payment_sources", default_value, customer_id=customer_id230 )231 raise Exception(f"Payment plugin {gateway} is inaccessible!")232 def list_payment_gateways(self, active_only: bool = True) -> List[dict]:233 payment_method = "process_payment"234 plugins = self.plugins235 if active_only:236 plugins = [237 plugin238 for plugin in plugins239 if self.get_plugin_configuration(plugin.PLUGIN_NAME).active240 ]241 return [242 {243 "name": plugin.PLUGIN_NAME,244 "config": self.__get_payment_config(plugin.PLUGIN_NAME),245 }246 for plugin in plugins247 if payment_method in type(plugin).__dict__248 ]249 def get_payment_template(self, gateway: str) -> str:250 method_name = "get_payment_template"251 default_value = None252 gtw = self.get_plugin(gateway)253 return self.__run_method_on_single_plugin(gtw, method_name, default_value)254 def __get_payment_config(self, gateway: str) -> List[dict]:255 method_name = "get_payment_config"256 default_value = []257 gtw = self.get_plugin(gateway)258 return self.__run_method_on_single_plugin(gtw, method_name, default_value)259 def __run_payment_method(260 self,261 gateway: str,262 method_name: str,263 payment_information: "PaymentData",264 **kwargs,265 ) -> Optional["GatewayResposne"]:266 default_value = None267 gtw = self.get_plugin(gateway)268 if gtw is not None:269 resp = self.__run_method_on_single_plugin(270 gtw,271 method_name,272 previous_value=default_value,273 payment_information=payment_information,274 **kwargs,275 )276 if resp is not None:277 return resp278 raise Exception(279 f"Payment plugin {gateway} for {method_name}"280 " payment method is inaccessible!"281 )282 # FIXME these methods should be more generic283 def assign_tax_code_to_object_meta(284 self, obj: Union["Product", "ProductType"], tax_code: str285 ):286 default_value = None287 return self.__run_method_on_plugins(288 "assign_tax_code_to_object_meta", default_value, obj, tax_code289 )290 def get_tax_code_from_object_meta(291 self, obj: Union["Product", "ProductType"]292 ) -> TaxType:293 default_value = TaxType(code="", description="")294 return self.__run_method_on_plugins(295 "get_tax_code_from_object_meta", default_value, obj296 )297 def get_tax_rate_percentage_value(298 self, obj: Union["Product", "ProductType"], country: Country299 ) -> Decimal:300 default_value = Decimal("0").quantize(Decimal("1."))301 return self.__run_method_on_plugins(302 "get_tax_rate_percentage_value", default_value, obj, country303 ).quantize(Decimal("1."))304 def save_plugin_configuration(self, plugin_name, cleaned_data: dict):305 plugin_configuration = PluginConfiguration.objects.get(name=plugin_name)306 for plugin in self.plugins:307 if plugin.PLUGIN_NAME == plugin_name:308 return plugin.save_plugin_configuration(309 plugin_configuration, cleaned_data310 )311 def get_plugin(self, plugin_name: str) -> Optional["BasePlugin"]:312 for plugin in self.plugins:313 if plugin.PLUGIN_NAME == plugin_name:314 return plugin315 def get_plugin_configuration(self, plugin_name) -> Optional["PluginConfiguration"]:316 plugin = self.get_plugin(plugin_name)317 if plugin is not None:318 plugin_configurations_qs = PluginConfiguration.objects.all()319 return plugin.get_plugin_configuration(plugin_configurations_qs)320 def get_plugin_configurations(self) -> List["PluginConfiguration"]:321 plugin_configuration_ids = []322 plugin_configurations_qs = PluginConfiguration.objects.all()323 for plugin in self.plugins:324 plugin_configuration = plugin.get_plugin_configuration(325 plugin_configurations_qs326 )327 plugin_configuration_ids.append(plugin_configuration.pk)328 return PluginConfiguration.objects.filter(pk__in=plugin_configuration_ids)329def get_extensions_manager(330 manager_path: str = None, plugins: List[str] = None331) -> ExtensionsManager:332 if not manager_path:333 manager_path = settings.EXTENSIONS_MANAGER334 if plugins is None:335 plugins = settings.PLUGINS336 manager = import_string(manager_path)...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!